Jump to content

IP Scanning


Recommended Posts

I've been trying to find an IP scanner that would print to file a list of live ip addresses on a LAN. Without ping details or any other junk.

Just one ip address per line.

I've tried various scanner without any joy. So I've decided to have a crack at learning about AutoIT. I know this could take a long time.

I am hoping to design a window that will have 3 input boxes that I can input the first, second & third octet of the ip address. Then an Ok button that would trigger a scan using these user defined octets to scan the 1-254 range of the fourth octet. Printing to a file, no preference of location so where ever the script is that would be fine.

I dont want to reinvent the wheel or bug the life out of you guys if alot of this scripting has been achieved here.

So any pointers in that direction would be much appreciated. Whilst I slog away at this. :)

Link to comment
Share on other sites

this could be fairly easy...

make a GUI using GUICreate(), Inputs using GUICtrlCreateInput(), then use loops to Ping() the IP Addresses that you want. Someone else isn't going to do this for you, so, get started, and post your source when you come across problems.

EDIT: Read the inputs with GUICtrlRead()

Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

Link to comment
Share on other sites

its your lucky day, made it a week ago:

Kept it simple, with output to a CSV file, so its nothing too fancy. so it can be manipulated in excel.. i use it to find free IPs for new hardware (such as printers etc)

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.2.0
 Author:         tAK Telapis

 Script Function:
    Ping IP addresses and produce report on usage.

#ce ----------------------------------------------------------------------------

; Includes:
#include <inet.au3>
; Set hotkey to exit script:
HotKeySet("{ESC}", "_Terminate")

; Set variables:
$INIFile = @ScriptDir&"\IP_Usage_Settings.ini"
If FileExists($INIFile) Then
    ; No need to do anything
Else
    FileInstall("D:\Documents and Settings\nathan.stewart\My Documents\Scripts\Auto IT\IP Usage\IP_Usage_Settings.ini", @ScriptDir&"\IP_Usage_Settings.ini")
    MsgBox(0, "No settings in ini file", "please edit the INI file first")
    Run("notepad.exe "&$INIFile, @ScriptDir)
    Exit
EndIf
$IPStart = INIRead($INIFile, "settings", "IPStart", "Value not Set") ; First 3 numbers of IP address, including final . as read from ini file
$IPTotal = INIRead($INIFile, "settings", "IPTotal", "Value not Set") ; total number of IPs to check as read from ini file
If $IPTotal <1 OR $IPTotal > 254 Then
    MsgBox(0, "Invalid IPTotal", "You have set: "&$IPTotal&" As your Total number of IPs" & @CRLF & _
    "This value is invalid, please edit the ini file and try again")
    Exit
EndIf
$ReportFile = @ScriptDir&"\IPUsageReport_"&$IPStart&"1_to_."&$IPTotal&".csv" ; Text CSV file to produce report in

; open the ReportFile and check that it opened
$File = FileOpen($ReportFile, 10)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Sartup TCP services for getting the HostName
TCPStartup()

; Setup a progress bar
ProgressOn("Scanning IPs", "Checking IPs in range", "0 Percent", (@DesktopWidth / 2)-150, (@DesktopHeight / 2), 18)
    $PercentIncrement = Round(100 / $IPTotal, 0)
    $z = 0
    
; Loop through the IPs and get required details
For $i = 1 to $IPTotal Step 1
    $z = $z + $PercentIncrement
    Ping($IPStart&$i)
    If @error = 0 Then
        $HostName = _TCPIpToName($IPStart&$i)
        FileWriteLine($file, $IPStart&$i&","&$HostName&@LF)
    Else
        FileWriteLine($file, $IPStart&$i&",IP IS FREE"&@LF)
    EndIf
    ; Update the progress bar
    ProgressSet( $z, $z & " percent")
    sleep(100)
Next
; Finish of the Progress Bar by setting it to 100% and closing it
ProgressSet(100 , "Done", "Complete")
ProgressOff()

; Message Box to indicate end of report
MsgBox(0, "IP Report Complete", "Your report has been produced")

; Function to exit based on HotKey
func _Terminate()
    Exit
EndFunc ;==> _Terminate

And the contents of the ini file:

to be called IP_Usage_Settings.ini and be kept in the same dir as the script.

[settings]
# First three numbers of the IP range to check, including final .
IPStart=127.0.0.

# Total number of IPs to check
IPTotal=1

#Note that the REPORT file will appear in the same directory as the .exe file when the program is complete, and will be named based on the IP range which you provide, if you run a report on the same range twice, this file will be over-written
Link to comment
Share on other sites

I've been trying to find an IP scanner that would print to file a list of live ip addresses on a LAN. Without ping details or any other junk.

Just one ip address per line.

I've tried various scanner without any joy. So I've decided to have a crack at learning about AutoIT. I know this could take a long time.

I am hoping to design a window that will have 3 input boxes that I can input the first, second & third octet of the ip address. Then an Ok button that would trigger a scan using these user defined octets to scan the 1-254 range of the fourth octet. Printing to a file, no preference of location so where ever the script is that would be fine.

I dont want to reinvent the wheel or bug the life out of you guys if alot of this scripting has been achieved here.

So any pointers in that direction would be much appreciated. Whilst I slog away at this. :)

Hi,

Check my script above, in my signature.

Fell free to modify!

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...