Jump to content

IP Scanner


llewxam
 Share

Recommended Posts

Ian,

Good work, but there's a small bug in your code. For a class C network, there is no host at x.x.x.255 so if you change the size of the address[] array to 254 and change the For/Next to use up to 253 then you'll cover the 'legal' range of 1-254 inclusive, as shown in the snippet below.

I'd love to see this handle a bigger network, say 1024 hosts (subnet mask, 255.255.252.0) and I've had a look at changing it, but it's a lot of work with the way you handle the octets at the moment.

;Local $address[255]
Local $address[254]                         ; 4Eyes - 24/Sep/2011
;For $i = 0 To 254
For $i = 0 To 253                                ; 4Eyes - 24/Sep/2011 - for a class C network only need 1-254
      $address[$i] = $range & $i + 1        ; We generate some IPs
Next

A coworker just mentioned the 254 thing a couple days ago, and another coworker and I were talking about the possible usefulness of having the tool work on different network classes, but since I never have a use for it and he almost never would, it kinda isn't likely to happen. And I agree, the way I have it coded would suck to make it work better for your purposes, so if you should happen to put something together (based off my code or not), please let me know!

Thanks

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 1 year later...
  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

First post updated with new code, I put a lot of little changes in over the past year or so which make the app much nicer.

Enjoy

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 5 months later...

Very kind, and glad you like it! My URL does not have a nice page onit, I mainly use my webserver as a file locker. Can't beat it for $6/month! :)

How about just list it as "Ian Maxwell (llewxam @ AutoIt forums)"

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I love the software, but as someone else said, it would be great to be able to scan a larger network area(like 25.56.xxx.xxx), but I don't know how well autoit would handle that much recursive processing, just an suggestion you might wanna toy with.

(for example I think it would be great to be able to scan any range, for say, a P2P program, that automatically locates peers on the internet. [xxx.xxx.xxx.xxx)

Edited by nullschritt
Link to comment
Share on other sites

I made a small adaptation, to allow it to scan larger networks, starting from the address entered.

;~ Coded by Ian Maxwell (llewxam) modified by nullschritt
;~ Based off threaded IP script by Manadar
;~ http://www.autoitscript.com/forum/topic/104334-whats-wrong-with-ping-or-with-me/page__view__findpost__p__740697

#include <iNet.au3>
#include <ClipBoard.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$HowManyReq = 1 ;number of ping requests in _MSPing
$TimeoutDefault = 500 ;timeout in miliseconds
Global $HostName, $WhichList, $List, $Used, $StartTime, $Finished, $CurrentIP, $CurrentIndex, $FreeCount, $Progress, $CurrentlyScanning, $FinishMessage, $fDblClkMessage
Global Const $MAX_PROCESS = 20 ; Maximum processes at once
Global $fDblClk = False, $aLV_Click_Info

$Found = 0 ;how many active connections you have
$chosenip = InputBox("Input IP Address","Input the IP address you would like to begin scanning at.")

$GUI = GUICreate("IP Scanner", 510, 385)
GUISetBkColor(0xb2ccff, $GUI)
$IPinBrowser = GUICtrlCreateButton("Open In Browser", 10, 10, 100, 20)
GUICtrlSetTip(-1, "The selected IP address will be opened in a web browser (best for printers)")
$IPinWinExplorer = GUICtrlCreateButton("Open In Explorer", 120, 10, 100, 20)
GUICtrlSetTip(-1, "The selected IP address will be opened in Windows Explorer (best for computers with network shares)")
$CopyToClip = GUICtrlCreateButton("Copy Selected", 230, 10, 100, 20)
GUICtrlSetTip(-1, "The selected IP address will be copied to the clipboard")
$SaveToFile = GUICtrlCreateButton("Export To CSV", 340, 10, 100, 20)
GUICtrlSetTip(-1, "The results of the scan will be saved to a CSV file")
$Rescan = GUICtrlCreateButton("Rescan", 450, 10, 50, 20)
GUICtrlSetTip(-1, "The results of the scan will be saved to a CSV file")
$Unused = _GUICtrlListView_Create($GUI, "Unused IP Addresses", 10, 40, 140, 260)
_GUICtrlListView_SetColumnWidth($Unused, 0, 120)
$Used = _GUICtrlListView_Create($GUI, "IP Address|Host Name|Time", 160, 40, 340, 260)
_GUICtrlListView_SetColumnWidth($Used, 0, 95)
_GUICtrlListView_SetColumnWidth($Used, 1, 169)
_GUICtrlListView_SetColumnWidth($Used, 2, 50)
Local $StatusParts[4] = [250, 500, -1]
$StatusBar = _GUICtrlStatusBar_Create($GUI)
_GUICtrlStatusBar_SetParts($StatusBar, $StatusParts)
$Box = GUICtrlCreateGraphic(10, 343, 500, 2) ; <-----------------------------------------------|
GUICtrlSetGraphic($Box, $GUI_GR_COLOR, 0x787878) ; <--|
GUICtrlSetGraphic($Box, $GUI_GR_MOVE, 295, 1) ; <--|
GUICtrlSetGraphic($Box, $GUI_GR_LINE, 500, 1) ; <--|
GUICtrlCreateLabel("MaxImuM AdVaNtAgE SofTWarE© 2012", 300, 345, 200, 20, $SS_RIGHT) ; <--|
GUICtrlSetColor(-1, 0x787878) ; <-----------------------------------------------------------|
GUISetState(@SW_SHOW, $GUI)

GUIRegisterMsg($WM_NOTIFY, "_DoubleClick")

_Scan()

Do
$MSG = GUIGetMsg()
If $MSG == $GUI_EVENT_CLOSE Then Exit
If $MSG == $IPinBrowser Then _OpenInBrowser()
If $MSG == $IPinWinExplorer Then _OpenInExplorer()
If $MSG == $CopyToClip Then _CopyToClip()
If $MSG == $SaveToFile Then _SaveToFlie()
If $MSG == $Rescan Then
_GUICtrlListView_DeleteAllItems($Used)
_GUICtrlListView_DeleteAllItems($Unused)
_Scan()
EndIf
If $fDblClk Then
$fDblClk = False
Switch $aLV_Click_Info[1]
Case 0 ; On Item
$sText = _GUICtrlListView_GetItemText($Used, $aLV_Click_Info[0])
_PingSpecific($sText)
EndSwitch
EndIf
Until 1 = 2
Exit

Func _Scan()
GUICtrlDelete($FinishMessage)
GUICtrlDelete($fDblClkMessage)
GUICtrlSetState($IPinBrowser, $GUI_DISABLE)
GUICtrlSetState($IPinWinExplorer, $GUI_DISABLE)
GUICtrlSetState($CopyToClip, $GUI_DISABLE)
GUICtrlSetState($SaveToFile, $GUI_DISABLE)
GUICtrlSetState($Rescan, $GUI_DISABLE)
$Progress = GUICtrlCreateProgress(10, 310, 490, 20)
$ScanningMessage = GUICtrlCreateLabel("Currently Scanning:", 10, 340, 95, 15)
$CurrentlyScanning = GUICtrlCreateLabel("", 105, 340, 80, 15)

Local $a_process[$MAX_PROCESS] ; An array to keep a reference to spawned processes, in the next loop we fill it with value 0
For $n = 0 To UBound($a_process) - 1
$a_process[$n] = 0
Next

$Oct = StringSplit($ChosenIP, ".")
$Range = $Oct[1] & "." ;now we just add an incrementing number and ping away
Local $Address[16581375]
global $x=0
For $i3 = $oct[2] To 254
For $i2 = $oct[3] To 254
For $i = $oct[4] To 254
$Address[$x] = $Range &$i3+1&"."&$i2+1&"."& $i + 1 ; We generate some IPs
$x+=1
Next
Next
Next
Local $i = 0 ; A pointer to run through the $Address array
$Finished = 0 ; <==== New line
$CurrentIndex = 0; Needed to keep the _GUICtrlListView_AddSubItem working right...
$FreeCount = 0
AdlibRegister("_Display", 500)
$StartTime = TimerInit()

Do
; Check on the current processes, and look if there is one finished for use with our next host in line (from $Address)
For $n = 0 To UBound($a_process) - 1
$MSG = GUIGetMsg()
If $MSG = $GUI_EVENT_CLOSE Then Exit
If ($i <> UBound($Address) And $a_process[$n] == 0) Then ; Check if we need a spot, and there is an existing spot
; There is an empty spot
$a_process[$n] = _MSPing($Address[$i])
$i += 1
Else
; Something is running here, let's check on the output
If ($a_process[$n] <> 0 And _MSPingIsReady($a_process[$n])) Then
$CurrentIP = _MSPingGetHostname($a_process[$n])
$PingTime = _MSPingGetResult($a_process[$n])
$ShowHost = StringSplit($CurrentIP, ".")
$LastOct = StringFormat("%.3i", $ShowHost[4])
If ($PingTime <> -1) Then
_GUICtrlListView_AddItem($Used, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $PingTime & "ms", 2)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, "looking up host name.....", 1)
$HostName = _HostName($CurrentIP)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $HostName, 1)
$CurrentIndex += 1
Else
$FreeCount += 1
_GUICtrlListView_AddItem($Unused, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
EndIf
; Free up an empty space for the next address to Ping
$a_process[$n] = 0
$Finished += 1 ; <=== New line
If ($Finished == UBound($Address)) Then
ExitLoop 2 ; Return
EndIf
EndIf
EndIf
Next
Until 1 = 2
AdlibUnRegister()
_Display()
GUICtrlDelete($Progress)
GUICtrlDelete($ScanningMessage)
GUICtrlDelete($CurrentlyScanning)
GUICtrlSetState($IPinBrowser, $GUI_ENABLE)
GUICtrlSetState($IPinWinExplorer, $GUI_ENABLE)
GUICtrlSetState($CopyToClip, $GUI_ENABLE)
GUICtrlSetState($SaveToFile, $GUI_ENABLE)
GUICtrlSetState($Rescan, $GUI_ENABLE)
$FinishMessage = GUICtrlCreateLabel("Finished scanning IP range in " & Round((TimerDiff($StartTime) / 1000), 2) & " seconds", 105, 315, 300, 20, $SS_CENTER)
$fDblClkMessage = GUICtrlCreateLabel("Double click any used IP to ping", 10, 335, 180, 20)
ControlFocus("IP Scanner", "MaxImuM AdVaNtAgE SofTWarE", $Used)
EndFunc ;==>_Scan

Func _OpenInBrowser()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ;strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
ShellExecute("http://" & $FinalIP)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc ;==>_OpenInBrowser

Func _OpenInExplorer()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ;strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
ShellExecute("\\" & $FinalIP)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc ;==>_OpenInExplorer

Func _CopyToClip()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ;strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
_ClipBoard_SetData($FinalIP)
TrayTip("Done", "IP address " & $FinalIP & " sent to clipboard", 8, 16)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc ;==>_CopyToClip

Func _SaveToFlie()
$FileName = FileSaveDialog("Choose a location and name for the file", @DesktopDir, "CSV (*.CSV)", 16, "IPScan Output.csv")
If $FileName <> "" Then
FileDelete($FileName)
$Output = FileOpen($FileName, 1 + 8)
FileWriteLine($Output, "IP Address,Device Name,Ping Time")
FileWriteLine($Output, "")
$Count = _GUICtrlListView_GetItemCount($Used)
For $a = 0 To $Count - 1
$Item = _GUICtrlListView_GetItemText($Used, $a, 0)
$Oct = StringSplit($Item, ".")
$Last = Number($Oct[4]) ;strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
$DeviceName = _GUICtrlListView_GetItemText($Used, $a, 1)
$PingTime = _GUICtrlListView_GetItemText($Used, $a, 2)
FileWriteLine($Output, $FinalIP & "," & $DeviceName & "," & $PingTime)
Next
FileWriteLine($Output, "")
FileWriteLine($Output, "")
FileWriteLine($Output, "")
FileWriteLine($Output, ",,,,Scan results saved " & @MON & "-" & @MDAY & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
FileWriteLine($Output, ",,,,-MaxImuM AdVaNtAgE SofTWarE (C) 2012")
FileClose($Output)
TrayTip("Done", "IP address list has been saved", 8, 16)
Else
MsgBox(16, "ERROR", "A location or file name were not chosen, nothing was saved.")
EndIf
EndFunc ;==>_SaveToFlie

Func _PingSpecific($PingIP)
$Oct = StringSplit($PingIP, ".")
$Last = Number($Oct[4]) ;strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
SplashTextOn("", "Please wait, pinging " & $FinalIP, 200, 80, (@DesktopWidth / 2) - 100, (@DesktopHeight / 2) - 40)
$CMD = "ping " & $FinalIP & " -n 4"
$PID = Run($CMD, @ScriptDir, @SW_HIDE, "0x2")
$Text = ""
While ProcessExists($PID)
$Line = StdoutRead($PID, 0)
If @error Then ExitLoop
$Text &= $Line
WEnd
SplashOff()
MsgBox(64, "Result", $Text)
EndFunc ;==>_PingSpecific

Func _MSPing($CurrentIP, $Timeout = $TimeoutDefault)
Local $Return_Struc[4]
; [0] = Result (in ms)
; [1] = The hostname originally used
; [2] = Process handle (for internal use only)
; [3] = Buffer (for internal use only)
$Return_Struc[1] = $CurrentIP
$Return_Struc[2] = Run("ping " & $CurrentIP & " -n " & $HowManyReq & " -w " & $Timeout, "", @SW_HIDE, $STDOUT_CHILD)
Return $Return_Struc
EndFunc ;==>_MSPing
Func _MSPingIsReady(ByRef $Return_Struc)
Return ___MSPingReadOutput($Return_Struc)
EndFunc ;==>_MSPingIsReady
Func _MSPingGetResult($Return_Struc)
Return $Return_Struc[0]
EndFunc ;==>_MSPingGetResult
Func _MSPingGetHostname($Return_Struc)
Return $Return_Struc[1]
EndFunc ;==>_MSPingGetHostname
; Internal use only
Func ___MSPingReadOutput(ByRef $Return_Struc)
$data = StdoutRead($Return_Struc[2])
If (@error) Then
___MSPingParseResult($Return_Struc)
Return 1
Else
$Return_Struc[3] &= $data
Return 0
EndIf
EndFunc ;==>___MSPingReadOutput
; Internal use only
Func ___MSPingParseResult(ByRef $Return_Struc)
$Result = StringRegExp($Return_Struc[3], "([0-9]*)ms", 3)
If @error Then
$Return_Struc[0] = -1
Else
$Return_Struc[0] = $Result[0]
EndIf
EndFunc ;==>___MSPingParseResult

Func _HostName($CurIP)
GUICtrlSetData($CurrentlyScanning, $CurrentIP)
TCPStartup()
$DevName = _TCPIpToName($CurIP)
If @error Then $DevName = "Unknown"
TCPShutdown()
Return $DevName
EndFunc ;==>_HostName

Func _Display()
ConsoleWrite($Finished&@CR)
GUICtrlSetData($Progress, ($Finished / $x) * 100)
GUICtrlSetData($CurrentlyScanning, $CurrentIP)
_GUICtrlStatusBar_SetText($StatusBar, "Used IP Addresses: " & $CurrentIndex, 0)
_GUICtrlStatusBar_SetText($StatusBar, "Free IP Addresses: " & $FreeCount, 1)
EndFunc ;==>_Display

; WM_NOTIFY event handler
Func _DoubleClick($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $Used And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
$aLV_Click_Info = _GUICtrlListView_SubItemHitTest($Used)
; As long as the click was on an item or subitem
If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>_DoubleClick

Posted Image

Note: The interface might be laggy during scanning(depending on what IP address you start scanning at). I modified this personally, as a method to find other P2P clients over the internet, but I suppose it could be used for a number of things. Just though I'de share.

Edited by nullschritt
Link to comment
Share on other sites

  • 7 months later...

Updated for the first time in a long time - RDP button added, revised IP range inclusion (x.x.x.0-x.x.x.254), general cleanups.

Enjoy

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 2 months later...

Another update, been adding some more new features:

  • Tool shows which IP address is the PC doing the scanning, as well as what IP address is the gateway (router)
  • Allows you to ping a specific IP address from within the tool, rather than having to open a command prompt to ping Google or whatever other address for testing connection to the outside world
  • You can now also get the external IP address of the modem

 

Not sure how many more features can be included in this tool, but necessity may bring up a couple more down the road!  :)

Enjoy

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

One little thing : I would strip leading zero's

10.0.0.001 should be 10.0.0.1

hehe, yeah, I know, you're not the first to dislike that, bit for some reason it just bugs the heck out of me to see it listed as

.18

.19

.2

.20

.21

So I padded the last octet to not have to see that.  The copy to clipboard function as well as RDP, Explorer, web browser etc all strip the zeros to make sure it works as expected, of course feel free to remove them for your own purposes.

Glad you like it, today I did think of yet another addition to make in the coming days, scan a specific range, maybe omit a range as well.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 4 months later...

Alright

 

I cleaned the GUI up a bit, didn't steal credit at all, made it look very nice.

 

Here are the major changes I made to it:

 

Change log:

  • Organized all the functions into a menu
  • Removed the rescan button and added a stop button. (You can now just press the scan button to rescan)
  • Added an About gui that shows the author information and revision
  • BIG: I added the ability to find the user of an IP, which depends on the machine and if you have rights to it or not (will help to iron out any bugs) 
  • Added error checking for the user function
  • changed the double click function to copy the IP to clipboard and set it to work with both "Used" and "Unused" lists
Things needed:
  • Speed up the scan function (I have a few ideas on how to do this)
  • Add settings to it so that the user has more control over it
  • Add an update function that will allow users to download the latest version (optional, simply a thing that I end up doing to all programs/scripts)
I take no credit, so please don't throw any my way, send it all to llewxam

I will however take blame for any edits I've made and offer my time fixing/improving anything I've done to llewxam's original code

 

CODE:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Program Files (x86)\AutoIt3\Icons\au3script_v10.ico
#AutoIt3Wrapper_Outfile=IPScannerPro.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;~ Coded by Ian Maxwell (llewxam)
;~ Based off threaded IP script by Manadar
;~ [url=http://www.autoitscript.com/forum/topic/104334-whats-wrong-with-ping-or-with-me/page__view__findpost__p__740697]http://www.autoitscript.com/forum/topic/104334-whats-wrong-with-ping-or-with-me/page__view__findpost__p__740697[/url]
 
;~ Build date January 25 2014
 
#include <iNet.au3>
#include <ClipBoard.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
 
 
TCPStartup()
 
;~ HotKeySet("{SPACE}", "Start_Scan")
 
;~ $HowManyReq = 1 ; number of ping requests in _MSPing
$TimeoutDefault = 500 ; timeout in miliseconds
Global $HostName, $WhichList, $List, $Used, $StartTime, $Finished, $CurrentIP, $CurrentIndex, $FreeCount, $Progress, $CurrentlyScanning, $FinishMessage, $fDblClkMessage
Global Const $MAX_PROCESS = 30 ; maximum processes at once
Global $fDblClk = False, $aLV_Click_Info, $ChosenIP, $zGetGateway, $Gateway, $ScanSTOP=0, $Rescan=False, $DblClkList=0
 
$Found = 0 ;how many active connections you have
$LocalIP1 = @IPAddress1
$LocalIP2 = @IPAddress2
$LocalIP3 = @IPAddress3
$LocalIP4 = @IPAddress4
If $LocalIP1 <> "0.0.0.0" Then $Found += 1
If $LocalIP2 <> "0.0.0.0" Then $Found += 1
If $LocalIP3 <> "0.0.0.0" Then $Found += 1
If $LocalIP4 <> "0.0.0.0" Then $Found += 1
 
 
If $Found == 0 Then
MsgBox(16, "OOPS", "There are no adapters with an IP address present.  Please check your adapters and cables.")
Exit
EndIf
If $Found > 1 Then ; if there is more than one network available you will be prompted to choose which to scan
$Choose = GUICreate("Choose an IP range", 240, 115, (@DesktopWidth / 2) - 120, @DesktopHeight / 4)
GUISetBkColor(0xb2ccff, $Choose)
GUISetFont(8.5)
$IPShow = StringSplit($LocalIP1, ".")
$Button1 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 5, 5, 110, 40)
$IPShow = StringSplit($LocalIP2, ".")
$Button2 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 125, 5, 110, 40)
$IPShow = StringSplit($LocalIP3, ".")
$Button3 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 5, 50, 110, 40)
$IPShow = StringSplit($LocalIP4, ".")
$Button4 = GUICtrlCreateButton($IPShow[1] & "." & $IPShow[2] & "." & $IPShow[3] & ".xxx", 125, 50, 110, 40)
;~  $Box = GUICtrlCreateGraphic(5, 83, 130, 2) ;       <-------------------------------------------|
;~  GUICtrlSetGraphic($Box, $GUI_GR_COLOR, 0x787878) ;                                          <--|
;~  GUICtrlSetGraphic($Box, $GUI_GR_MOVE, 30, 1) ;                                              <--|  logo :)
;~  GUICtrlSetGraphic($Box, $GUI_GR_LINE, 230, 1) ;                                             <--|
;~  GUICtrlCreateLabel("MaxImuM AdVaNtAgE SofTWarE© 2014", 35, 86, 290, 20) ;                   <--|
;~  GUICtrlSetColor(-1, 0x787878) ;                    <-------------------------------------------|
If @IPAddress1 == "0.0.0.0" Then GUICtrlDelete($Button1)
If @IPAddress2 == "0.0.0.0" Then GUICtrlDelete($Button2)
If @IPAddress3 == "0.0.0.0" Then GUICtrlDelete($Button3)
If @IPAddress4 == "0.0.0.0" Then GUICtrlDelete($Button4)
GUISetState(@SW_SHOW, "Choose an IP range")
Do
$MSG = GUIGetMsg()
If $MSG == $GUI_EVENT_CLOSE Then Exit
If $MSG == $Button1 Then
$ChosenIP = @IPAddress1
ExitLoop
EndIf
If $MSG == $Button2 Then
$ChosenIP = @IPAddress2
ExitLoop
EndIf
If $MSG == $Button3 Then
$ChosenIP = @IPAddress3
ExitLoop
EndIf
If $MSG == $Button4 Then
$ChosenIP = @IPAddress4
ExitLoop
EndIf
Until 1 == 2
GUIDelete("Choose an IP range")
Else ; if only one network is available, skip the selection GUI and go
If $LocalIP1 <> "0.0.0.0" Then $ChosenIP = $LocalIP1
If $LocalIP2 <> "0.0.0.0" Then $ChosenIP = $LocalIP2
If $LocalIP3 <> "0.0.0.0" Then $ChosenIP = $LocalIP3
If $LocalIP4 <> "0.0.0.0" Then $ChosenIP = $LocalIP4
EndIf
 
 
$GUI = GUICreate("IP Scanner", 510, 400)
GUISetBkColor(0xb2ccff, $GUI)
GUISetFont(8.5)
 
$Menu1 = GUICtrlCreateMenu("Scanner")
$MenuItem1 = GUICtrlCreateMenuItem("Settings", $Menu1)
$MenuItem2 = GUICtrlCreateMenuItem("Reset", $Menu1)
 
$MenuItem3 = GUICtrlCreateMenuItem("", $Menu1)
$MenuItem4 = GUICtrlCreateMenuItem("Close", $Menu1)
$Menu2 = GUICtrlCreateMenu("IP Options")
$MenuItem6 = GUICtrlCreateMenu("Open IP", $Menu2, 1)
$MenuItem7 = GUICtrlCreateMenuItem("In WebBrowser", $MenuItem6)
$MenuItem8 = GUICtrlCreateMenuItem("In Explorer", $MenuItem6)
$MenuItem9 = GUICtrlCreateMenuItem("In Remote Desktop", $MenuItem6)
$MenuItem10 = GUICtrlCreateMenuItem("", $Menu2)
$MenuItem11 = GUICtrlCreateMenuItem("Copy Selected", $Menu2)
$MenuItem12 = GUICtrlCreateMenuItem("Export to CSV", $Menu2)
$MenuItem13 = GUICtrlCreateMenuItem("", $Menu2)
$MenuItem14 = GUICtrlCreateMenuItem("Ping Specific", $Menu2)
$MenuItem15 = GUICtrlCreateMenuItem("Get External IP", $Menu2)
;~ $MenuItem16 = GUICtrlCreateMenuItem("Rescan", $Menu1)
$Menu3 = GUICtrlCreateMenu("User Options")
$MenuItem17 = GUICtrlCreateMenu("Get User", $Menu3, 1)
$MenuItem18 = GUICtrlCreateMenuItem("Selected IP", $MenuItem17)
$MenuItem19 = GUICtrlCreateMenuItem("", $MenuItem17)
$MenuItem20 = GUICtrlCreateMenuItem("Custom", $MenuItem17)
$Menu4 = GUICtrlCreateMenu("Tools")
$MenuItem21 = GUICtrlCreateMenuItem("About", $Menu4)
$MenuItem22 = GUICtrlCreateMenuItem("", $Menu4)
$MenuItem23 = GUICtrlCreateMenuItem("Check for Update", $Menu4)
 
 
;~ $IPinBrowser = GUICtrlCreateButton("Open With &Web Browser", 10, 5, 160, 20)
;~ GUICtrlSetTip(-1, "The selected IP address will be opened in a web browser (best for printers)")
;~ $IPinWinExplorer = GUICtrlCreateButton("Open With Windows &Explorer", 175, 5, 160, 20)
;~ GUICtrlSetTip(-1, "The selected IP address will be opened in Windows Explorer (best for computers with network shares)")
;~ $IPinRDP = GUICtrlCreateButton("Open With &Remote Desktop", 340, 5, 160, 20)
;~ GUICtrlSetTip(-1, "The selected IP address will be opened in Windows Explorer (best for computers with network shares)")
;~ $CopyToClip = GUICtrlCreateButton("&Copy Selected", 10, 30, 90, 20)
;~ GUICtrlSetTip(-1, "The selected IP address will be copied to the clipboard")
;~ $SaveToFile = GUICtrlCreateButton("E&xport To CSV", 110, 30, 90, 20)
;~ GUICtrlSetTip(-1, "The results of the scan will be saved to a CSV file")
;~ $PingSpecific = GUICtrlCreateButton("&Ping Specific", 210, 30, 90, 20)
;~ GUICtrlSetTip(-1, "Scan a specific IP address")
;~ $GetExternalIP = GUICtrlCreateButton("&Get External IP", 310, 30, 90, 20)
;~ GUICtrlSetTip(-1, "Scan a specific IP address")
;~ $Rescan = GUICtrlCreateButton("Resca&n", 410, 30, 90, 20)
;~ GUICtrlSetTip(-1, "The results of the scan will be saved to a CSV file")
$StartScan_btn = GUICtrlCreateButton ("SCAN", 9, 3, 492, 45)
$StopScan_btn = GUICtrlCreateButton ("STOP", 430, 345, 70, 20)
GUICtrlSetState($StopScan_btn, $GUI_DISABLE)
$Unused = _GUICtrlListView_Create($GUI, "Unused IP Addresses", 10, 55, 140, 260)
_GUICtrlListView_SetColumnWidth($Unused, 0, 120)
$Used = _GUICtrlListView_Create($GUI, "IP Address|Host Name|Time", 160, 55, 340, 260)
_GUICtrlListView_SetColumnWidth($Used, 0, 95)
_GUICtrlListView_SetColumnWidth($Used, 1, 169)
_GUICtrlListView_SetColumnWidth($Used, 2, 50)
$ExternalIP=GUICtrlCreateLabel("", 10, 355, 260, 15)
Local $StatusParts[4] = [250, 510, -1]
$StatusBar = _GUICtrlStatusBar_Create($GUI)
_GUICtrlStatusBar_SetParts($StatusBar, $StatusParts)
;~ $Box = GUICtrlCreateGraphic(10, 358, 500, 2) ;      <----------------------------------------------|
;~ GUICtrlSetGraphic($Box, $GUI_GR_COLOR, 0x787878) ;                                              <--|
;~ GUICtrlSetGraphic($Box, $GUI_GR_MOVE, 295, 1) ;                                                 <--|
;~ GUICtrlSetGraphic($Box, $GUI_GR_LINE, 500, 1) ;                                                 <--|
;~ GUICtrlCreateLabel("MaxImuM AdVaNtAgE SofTWarE© 2014", 300, 360, 200, 20, $SS_RIGHT) ;          <--|
;~ GUICtrlSetColor(-1, 0x787878) ;        <-----------------------------------------------------------|
;~ Local $AccelKeys[8][2] = [["^w", $IPinBrowser],["^e", $IPinWinExplorer],["^r", $IPinRDP],["^c", $CopyToClip],["^x", $SaveToFile],["^p", $PingSpecific],["^g", $GetExternalIP],["^n", $Rescan]]
;~ GUISetAccelerators($AccelKeys)
GUISetState(@SW_SHOW, $GUI)
 
GUIRegisterMsg($WM_NOTIFY, "_DoubleClick")
 
 
 
 
Do
$MSG = GUIGetMsg()
If $MSG == $GUI_EVENT_CLOSE Then Exit
If $MSG == $StartScan_btn And $Rescan=False Then Start_Scan()
If $MSG == $MenuItem7 Then _OpenInBrowser()
If $MSG == $MenuItem8 Then _OpenInExplorer()
If $MSG == $MenuItem9 Then _OpenInRDP()
If $MSG == $MenuItem11 Then _CopyToClip()
If $MSG == $MenuItem12 Then _SaveToFlie()
If $MSG == $MenuItem18 Then _GetUserSelected()
If $MSG == $MenuItem2 Then _Reset()
If $MSG == $MenuItem4 Then Exit
If $MSG == $MenuItem21 Then _About()
If $MSG == $MenuItem14 Then
$GetSpecific=InputBox("Ping Specific","Enter an IP Address to ping")
If @error=1 Then
Else
_PingSpecific($GetSpecific)
EndIf
EndIf
If $MSG == $MenuItem20 Then
$GetSpecific=InputBox("Retrieve User","Enter an IP Address to locate the associated User")
If @error=1 Then
Else
_GetUser($GetSpecific)
EndIf
EndIf
If $MSG == $MenuItem15 Then
GUICtrlSetData($ExternalIP,"External IP Address: working...")
$GetExternalIPAddress=_GetExternalIP()
GUICtrlSetData($ExternalIP,"External IP Address: "&$GetExternalIPAddress)
EndIf
If $MSG == $StartScan_btn And $Rescan=True Then
_GUICtrlListView_DeleteAllItems($Used)
_GUICtrlListView_DeleteAllItems($Unused)
_Scan()
EndIf
If $fDblClk Then
$fDblClk = False
Switch $aLV_Click_Info[1]
Case 0 ; On Item
_CopyToClip()
$DblClkList=0
EndSwitch
EndIf
Sleep(10)
Until 1 == 2
Exit
 
Func _Reset();Exits, then runs the script again, thus resetting it
If @Compiled Then
Run(FileGetShortName(@ScriptFullPath))
Else
Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
EndIf
Exit
EndFunc   ;==>_Reset
 
Func Start_Scan()
$Gateway=_GetGateway()
_Scan()
EndFunc
 
func _GetGateway()
$zPID = Run(@ComSpec & " /c" & "ipconfig","", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $zOutput = ""
While 1
$zOutput &= StdoutRead($zPID)
If @error Then ExitLoop
Wend
$zBreak=StringSplit($zOutput,@CR)
for $a=1 to $zBreak[0]
if StringInStr($zBreak[$a],$ChosenIP) Then
$zGetGatewayLine=$zBreak[$a+2]
$zGetGateway=StringMid($zGetGatewayLine,41,StringLen($zGetGatewayLine)-40)
ExitLoop
EndIf
next
return $zGetGateway
EndFunc
 
Func _Scan()
$Rescan=True
GUICtrlDelete($FinishMessage)
GUICtrlDelete($fDblClkMessage)
GUICtrlSetState($StartScan_btn, $GUI_DISABLE)
GUICtrlSetState($Menu1, $GUI_DISABLE)
GUICtrlSetState($MenuItem1, $GUI_DISABLE)
GUICtrlSetState($Menu2, $GUI_DISABLE)
GUICtrlSetState($Menu3, $GUI_DISABLE)
GUICtrlSetState($StopScan_btn, $GUI_ENABLE)
;~  GUICtrlSetState($IPinBrowser, $GUI_DISABLE)
;~  GUICtrlSetState($IPinWinExplorer, $GUI_DISABLE)
;~  GUICtrlSetState($IPinRDP, $GUI_DISABLE)
;~  GUICtrlSetState($CopyToClip, $GUI_DISABLE)
;~  GUICtrlSetState($SaveToFile, $GUI_DISABLE)
;~  GUICtrlSetState($PingSpecific, $GUI_DISABLE)
;~  GUICtrlSetState($GetExternalIP, $GUI_DISABLE)
;~  GUICtrlSetState($Rescan, $GUI_DISABLE)
$Progress = GUICtrlCreateProgress(10, 320, 490, 20)
$ScanningMessage = GUICtrlCreateLabel("Scanning:", 10, 340, 95, 15)
$CurrentlyScanning = GUICtrlCreateLabel("", 75, 340, 95, 15)
 
Local $a_process[$MAX_PROCESS] ; an array to keep a reference to spawned processes, in the next loop we fill it with value 0
For $n = 0 To UBound($a_process) - 1
$a_process[$n] = 0
Next
 
$Oct = StringSplit($ChosenIP, ".")
$Range = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." ; now we just add an incrementing number and ping away
Local $Address[255]
For $i = 0 To 254
$Address[$i] = $Range & $i ; we generate some IPs
Next
 
Local $i = 0 ; a pointer to run through the $Address array
$Finished = 0 ; <==== new line
$CurrentIndex = 0; needed to keep the _GUICtrlListView_AddSubItem working right...
$FreeCount = 0
AdlibRegister("_Display", 100)
$StartTime = TimerInit()
 
Do
; check on the current processes, and look if there is one finished for use with our next host in line (from $Address)
For $n = 0 To UBound($a_process) - 1
$MSG = GUIGetMsg()
If $MSG == $GUI_EVENT_CLOSE Then Exit
If $MSG == $StopScan_btn Then
ExitLoop 2
$ScanSTOP=1
EndIf
If($i <> UBound($Address) And $a_process[$n] == 0) Then ; check if we need a spot, and there is an existing spot
; there is an empty spot
$a_process[$n] = _MSPing($Address[$i])
$i += 1
Else
; something is running here, let's check on the output
If($a_process[$n] <> 0 And _MSPingIsReady($a_process[$n])) Then
$CurrentIP = _MSPingGetHostname($a_process[$n])
$PingTime = _MSPingGetResult($a_process[$n])
$ShowHost = StringSplit($CurrentIP, ".")
$LastOct = StringFormat("%.3i", $ShowHost[4])
If($PingTime <> -1) Then
_GUICtrlListView_AddItem($Used, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $PingTime & "ms", 2)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, "looking up host name.....", 1)
$HostName = _HostName($CurrentIP)
_GUICtrlListView_AddSubItem($Used, $CurrentIndex, $HostName, 1)
$CurrentIndex += 1
Else
$FreeCount += 1
_GUICtrlListView_AddItem($Unused, $ShowHost[1] & "." & $ShowHost[2] & "." & $ShowHost[3] & "." & $LastOct, $CurrentIndex)
EndIf
; free up an empty space for the next address to Ping
$a_process[$n] = 0
$Finished += 1 ; <=== new line
If($Finished == UBound($Address)) Then
ExitLoop 2 ; return
EndIf
EndIf
EndIf
Next
Until 1 == 2 Or $ScanSTOP=1
AdlibUnRegister()
_Display()
GUICtrlDelete($Progress)
GUICtrlDelete($ScanningMessage)
GUICtrlDelete($CurrentlyScanning)
GUICtrlSetState($StartScan_btn, $GUI_ENABLE)
GUICtrlSetState($Menu1, $GUI_ENABLE)
GUICtrlSetState($MenuItem1, $GUI_ENABLE)
GUICtrlSetState($Menu2, $GUI_ENABLE)
GUICtrlSetState($Menu3, $GUI_ENABLE)
GUICtrlSetState($StopScan_btn, $GUI_DISABLE)
;~  GUICtrlSetState($IPinBrowser, $GUI_ENABLE)
;~  GUICtrlSetState($IPinWinExplorer, $GUI_ENABLE)
;~  GUICtrlSetState($IPinRDP, $GUI_ENABLE)
;~  GUICtrlSetState($CopyToClip, $GUI_ENABLE)
;~  GUICtrlSetState($SaveToFile, $GUI_ENABLE)
;~  GUICtrlSetState($PingSpecific, $GUI_ENABLE)
;~  GUICtrlSetState($GetExternalIP, $GUI_ENABLE)
;~  GUICtrlSetState($Rescan, $GUI_ENABLE)
;~  $FinishMessage = GUICtrlCreateLabel("Finished scanning IP range in " & Round((TimerDiff($StartTime) / 1000), 2) & " seconds", 105, 315, 300, 20, $SS_CENTER)
$fDblClkMessage = GUICtrlCreateLabel("Double click an IP to copy-to-clipboard", 150, 350, 300, 20)
EndFunc   ;==>_Scan
 
Func _OpenInBrowser()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
ShellExecute("http://" & $FinalIP)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc   ;==>_OpenInBrowser
 
Func _OpenInExplorer()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
Local $HostName=_HostName($IP)
;~  $Oct = StringSplit($IP, ".")
;~  $Last = Number($Oct[4]) ; strips out any leading 0s
;~  $FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
ShellExecute("\\" & $HostName & "\c$")
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc   ;==>_OpenInExplorer
 
Func _OpenInRDP()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
ShellExecute("mstsc", " /v:" & $FinalIP)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc   ;==>_OpenInRDP
 
Func _CopyToClip()
If $DblClkList=1 Then
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Unused, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Unused, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
_ClipBoard_SetData($FinalIP)
TrayTip("", "IP address " & $FinalIP & " sent to clipboard", 8, 16)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
ElseIf $DblClkList=2 Then
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
_ClipBoard_SetData($FinalIP)
TrayTip("", "IP address " & $FinalIP & " sent to clipboard", 8, 16)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndIf
EndFunc   ;==>_CopyToClip
 
Func _GetUserSelected()
$IP = ""
$Index = _GUICtrlListView_GetSelectedIndices($Used, False)
If $Index <> "" Then $IP = _GUICtrlListView_GetItemText($Used, $Index, 0)
If $IP <> "" Then
$Oct = StringSplit($IP, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
_GetUser($FinalIP)
Else
MsgBox(16, "ERROR", "You have not selected an IP address yet.")
EndIf
EndFunc   ;==>_CopyToClip
 
Func _SaveToFlie()
$FileName = FileSaveDialog("Choose a location and name for the file", @DesktopDir, "CSV (*.CSV)", 16, "IPScan Output.csv")
If $FileName <> "" Then
FileDelete($FileName)
$Output = FileOpen($FileName, 1 + 8)
FileWriteLine($Output, "IP Address,Device Name,Ping Time")
FileWriteLine($Output, "")
$Count = _GUICtrlListView_GetItemCount($Used)
For $a = 0 To $Count - 1
$Item = _GUICtrlListView_GetItemText($Used, $a, 0)
$Oct = StringSplit($Item, ".")
$Last = Number($Oct[4]) ; strips out any leading 0s
$FinalIP = $Oct[1] & "." & $Oct[2] & "." & $Oct[3] & "." & $Last
$DeviceName = _GUICtrlListView_GetItemText($Used, $a, 1)
$PingTime = _GUICtrlListView_GetItemText($Used, $a, 2)
FileWriteLine($Output, $FinalIP & "," & $DeviceName & "," & $PingTime)
Next
FileWriteLine($Output, "")
FileWriteLine($Output, "")
FileWriteLine($Output, "")
FileWriteLine($Output, ",,,,Scan results saved " & @MON & "-" & @MDAY & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC)
FileWriteLine($Output, ",,,,-MaxImuM AdVaNtAgE SofTWarE (C) 2014")
FileClose($Output)
TrayTip("Done", "IP address list has been saved", 8, 16)
Else
EndIf
EndFunc   ;==>_SaveToFlie
 
Func _PingSpecific($PingIP)
SplashTextOn("", "Please wait, pinging " & $PingIP, 200, 80, (@DesktopWidth / 2) - 100, (@DesktopHeight / 2) - 40)
$CMD = "ping " & $PingIP & " -n 4"
$PID = Run($CMD, @ScriptDir, @SW_HIDE, "0x2")
$Text = ""
While ProcessExists($PID)
$Line = StdoutRead($PID, 0)
If @error Then ExitLoop
$Text &= $Line
WEnd
SplashOff()
MsgBox(64, "Ping Result", $Text)
EndFunc   ;==>_PingSpecific
 
Func _GetUser($PingIP)
SplashTextOn("", "Retrieving User" & $PingIP, 200, 80, (@DesktopWidth / 2) - 100, (@DesktopHeight / 2) - 40)
$CMD = "wmic.exe /node:" & $PingIP & " ComputerSystem Get UserName"
$PID = Run($CMD, @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
$Text = ""
While ProcessExists($PID)
$Line = StdoutRead($PID)
If @error Then ExitLoop
$Text &= StringStripCR($Line)
WEnd
SplashOff()
Local $Error1=StringInStr($Text, "Access is denied")
Local $Error2=StringInStr($Text, " The RPC server is unavailable")
If $Error1>0 Then
MsgBox(16, "Error", "You do not have permission to view the User of this IP")
ElseIf $Error2>0 Then
MsgBox(16, "Error", "This machine does not support this function")
Else
MsgBox(64, "Lookup Result", $Text)
EndIf
EndFunc   ;==>_PingSpecific
 
Func _MSPing($CurrentIP, $Timeout = $TimeoutDefault)
Local $Return_Struc[4]
; [0] = Result (in ms)
; [1] = The hostname originally used
; [2] = Process handle (for internal use only)
; [3] = Buffer (for internal use only)
$Return_Struc[1] = $CurrentIP
$Return_Struc[2] = Run("ping " & $CurrentIP & " -n 1 -w " & $Timeout, "", @SW_HIDE, $STDOUT_CHILD)
Return $Return_Struc
EndFunc   ;==>_MSPing
Func _MSPingIsReady(ByRef $Return_Struc)
Return ___MSPingReadOutput($Return_Struc)
EndFunc   ;==>_MSPingIsReady
Func _MSPingGetResult($Return_Struc)
Return $Return_Struc[0]
EndFunc   ;==>_MSPingGetResult
Func _MSPingGetHostname($Return_Struc)
Return $Return_Struc[1]
EndFunc   ;==>_MSPingGetHostname
; Internal use only
Func ___MSPingReadOutput(ByRef $Return_Struc)
$data = StdoutRead($Return_Struc[2])
If(@error) Then
___MSPingParseResult($Return_Struc)
Return 1
Else
$Return_Struc[3] &= $data
Return 0
EndIf
EndFunc   ;==>___MSPingReadOutput
; Internal use only
Func ___MSPingParseResult(ByRef $Return_Struc)
$Result = StringRegExp($Return_Struc[3], "([0-9]*)ms", 3)
If @error Then
$Return_Struc[0] = -1
Else
$Return_Struc[0] = $Result[0]
EndIf
EndFunc   ;==>___MSPingParseResult
 
Func _HostName($CurIP)
GUICtrlSetData($CurrentlyScanning, $CurrentIP)
$DevName = _TCPIpToName($CurIP)
If @error Then $DevName = "Unknown"
if $CurIP==$ChosenIP Then
$DevName&=" (** this PC)"
endif
if $CurIP==$Gateway Then
$DevName&=" (** gateway)"
endif
Return $DevName
EndFunc   ;==>_HostName
 
Func _GetExternalIP()
    Local $bRead = InetRead("[url=http://checkip.dyndns.org/]http://checkip.dyndns.org/")[/url]
    If @error Then $bRead = InetRead("[url=http://automation.whatismyip.com/n09230945.asp]http://automation.whatismyip.com/n09230945.asp")[/url]
    If Not @error Then
        Local $aIp = StringRegExp(BinaryToString($bRead),'\d{1,3}(\.\d{1,3}){3}',2)
        If Not @error Then Return $aIp[0]
    EndIf
    Return SetError(1,0,'SOMETHING WENT WRONG')
EndFunc   ;==>_GetIP2
 
Func _Display()
GUICtrlSetData($Progress, ($Finished / 255) * 100)
GUICtrlSetData($CurrentlyScanning, $CurrentIP)
_GUICtrlStatusBar_SetText($StatusBar, "Used IP Addresses: " & $CurrentIndex, 0)
_GUICtrlStatusBar_SetText($StatusBar, "Free IP Addresses: " & $FreeCount, 1)
EndFunc   ;==>_Display
 
Func _About()
Local $AboutText = "Author: Ian Maxwell" & @CRLF & _
  "AutoIt: autoitscript.com/forum/user/49852-llewxam/" & @CRLF & _
  "Publish Date: 17 June 2010" & @CRLF & _
  "Current Version: Rev.8" & @CRLF & _
  "Last Update: 1/25/14"
 
$AboutGUI = GUICreate("About Info", 394, 150, 192, 110)
$AboutEdit = GUICtrlCreateEdit($AboutText, 35, 10, 325, 85, $ES_READONLY)
GUICtrlSetState($AboutEdit, $GUI_DISABLE)
$Box = GUICtrlCreateGraphic(5, 103, 130, 2) ;       <-------------------------------------------|
GUICtrlSetGraphic($Box, $GUI_GR_COLOR, 0x787878) ;                                          <--|
GUICtrlSetGraphic($Box, $GUI_GR_MOVE, 30, 1) ;                                              <--|  logo :)
GUICtrlSetGraphic($Box, $GUI_GR_LINE, 230, 1) ;                                             <--|
GUICtrlCreateLabel("MaxImuM AdVaNtAgE SofTWarE© 2014", 35, 106, 290, 20) ;                   <--|
GUICtrlSetColor(-1, 0x787878) ;                    <-------------------------------------------|
GUISetState(@SW_SHOW, $AboutGUI)
 
     While 1
         ; We can only get messages from the second GUI
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 GUIDelete($AboutGUI)
                 ExitLoop
  EndSwitch
  WEnd
 
EndFunc
 
; WM_NOTIFY event handler
Func _DoubleClick($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) == $Used And DllStructGetData($tNMHDR, "Code") == $NM_DBLCLK Then
$DblClkList=2
$aLV_Click_Info = _GUICtrlListView_SubItemHitTest($Used)
; as long as the click was on an item or subitem
If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
EndIf
If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) == $Unused And DllStructGetData($tNMHDR, "Code") == $NM_DBLCLK Then
$DblClkList=1
$aLV_Click_Info = _GUICtrlListView_SubItemHitTest($Unused)
; as long as the click was on an item or subitem
If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
EndIf
Return $GUI_RUNDEFMSG
EndFunc   ;==>_DoubleClick

IPScanEdit.au3

Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

I dig the menu system, good idea.  Couple snags though:

The code comments still say build date January 25 2014, probably should be changed, and please add yourself as an author/coauthor/modifier/whatever to the code notes and About  to distinguish that it was not my build.

Using Get External IP leads to a slight control overlap:

ipedit.jpg

 

Also, I know you changed double click to clipboard which is also a good idea, makes sense, and ping specific is also still there so a user could double click, ping specific, and paste, but a more direct way to have the selected IP get the standard ping would be nice.  Open IP option for Explorer should also be renamed to Windows Explorer to prevent anyone from thinking it could mean Internet Explorer.  Also, how about it starting the scan immediately on run?  (Unless you will be adding a feature later that not running right away will make sense)

Another thought, would it make sense to add a Resume after Stop to pick up where it left off, or just have it start from .0?  I'm not sure which way I would prefer to use it, just a thought.....

You also have all Menu items go to $GUI_Disable except for Tools ($Menu4) during Scan.

Last thing, the TrayTip in _CopyToClip doesn't work for me, but I think it was also not working for me in my last build, Win7 x64...I caught that after posting but have not looked in to it.....

You made some cool changes, thanks for sharing, sorry for so many Also's..... :)

Ian

EDIT:  Forgot to say that I really like the feature to identify the user!!!!!!!  Great move, some offices don't name the computers in a way that you know who is on it.

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I don't mind adding myself as a modifier in the code comments somewhere, but I wanted to avoid taking any real credit as you did the major work here. I thought I cleaned up the control-clashes but it seems I missed one, I'll have another look at it again. I added the settings section  so that later someone (You, I, or else) could add the ability to customize what the double clicking does as well as some other customization.

The tray tip in the copy function didn't work before my edits so I believe I removed it.

Also, I made it not start the scan because speaking from experience it seemed like a bad idea. I work in the IT department for a company where we have almost 200 computers, 20 printers, and a fax machine. Each time I started the program up it would take several minutes before I could even interact with the program which was frustrating honestly. Plus you have functions in the program that don't require a scan to have been done.

Regarding adding a resume scan function, that wouldn't be too hard, I also thought about adding the ability to scan within a set range to reduce the scan time and limit any useless scans. Sometimes we have an idea of the range and may just need to scan a small amount and not all possible.

The disabling of the menu was done to prevent tasks from clogging the scan job. It seemed to make sense to wait until the scan had completed to allow the user to do anything with the scan results. leaving the "Tools" menu enabled didn't really seem to problematic because the only thing in it for now is the about window.

I'll make the change to the "Explorer" and make it "Windows Explorer", I actually meant to but was swept up in the code and forgot.

Do you have any Idea on how to speed up the scan?

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to comment
Share on other sites

By far the slowest part is getting the hostname, scanning is waaaaay faster if that is skipped. I was playing around with grabbing an ARP table for hostnames (and all used IPs really) but found the ARP table could contain information about machines no longer on the LAN, so unforunately I don't think that can be relied upon as trustworthy.

So either have hostname enumeration being optional or findung another way (WMI, SNMP) would probably be best.

Also, the number of simultaneous threads can affect it, but then you run in to performance issues on slower machines. I have never done a comprehensive study to see what the best value might be.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 8 months later...

Hi Everyone.

how can i see only the unused IP?

and at the same time filewrite them.

Thanks.

Christian

don't know what you mean. I did run the code from >post 32, it works fine.

on a Win7,x64

and XP, x32 ( with tweaking on AutoIt v3.2.12.1 )

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

@boniakowski

You would have to modify the program to do that, which of course you are welcome to do.

I'd suggest specifying the file name at the top of the script or possibly adding a button to the GUI, and removing the listview and related code for the used IPs. From there it would be easy to add a FileWrite command after each new unused IP is found.

Ian

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

 

Hi Everyone.

how can i see only the unused IP?

and at the same time filewrite them.

Thanks.

Christian

 

maybe you could also be interested to "versatile multi ping" function.

since it's designed not as a finished program, but just as a multipurpose function, it's ready to be used in your programs without modifications.

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 1 year later...

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...