dascondor

IP Scan from a IP list

5 posts in this topic

#1 ·  Posted

I need some help putting an IP Scanner from a list of IPs. I've seen some out there that might work, but I am so far unsuccessful at getting them working.

Basically, my idea is someone can create a list in notepad to change or add IPs and device names like...

10.20.30.1 Gateway

10.20.30.2  WAP

10.20.30.3 Computer 1

... and so on and so on.

and have it report back with 

10.20.30.1 Gateway is Online

10.20.30.2 WAP is Offline

10.20.30.3 Computer 1 is Online

... Again so on and so on.

 

Really is sounds kinda dump to some but for the people that do IP checks this could help make it easier for some

 

Share this post


Link to post
Share on other sites



#3 ·  Posted

or maybe also this other one:

 


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

Share this post


Link to post
Share on other sites

#4 ·  Posted

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>


#Region ### START Koda GUI section ### Form=
$IPpong = GUICreate("IP Pinger", 572, 253, -1, -1)
$data1 = GUICtrlCreateInput("1", 184, 104, 81, 37, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$data2 = GUICtrlCreateInput("23", 280, 104, 73, 37, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$gobutton = GUICtrlCreateButton("GO", 80, 192, 75, 25)
GUICtrlSetBkColor(-1, 0x00FF00)
$Label1 = GUICtrlCreateLabel("What Store?", 200, 40, 145, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$exitbutton = GUICtrlCreateButton("exitbutton", 400, 192, 75, 25)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $replace2 = "Second"

Global $replace3 = "Thrid"

Global $userdata1 = GUICtrlRead($data1)

Global $userdata2 = GUICtrlRead($data2)

Global $Spath = FileSaveDialog( "Choose Your IP_List.txt", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" ,"All (*.*)")

Global $IP = "IP_List.txt"

Global $sMessage = "Select a folder"

;Local $sFileSelectFolder = FileSelectFolder($sMessage, "")





While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $gobutton
         $Spath
         $userdata1 = GUICtrlRead($data1)
         $userdata2 = GUICtrlRead($data2)

         replace()





         Case $exitbutton
         exit


    EndSwitch
WEnd



Func replace()

   _ReplaceStringInFile( $Spath , $replace3, $userdata2 )
   _ReplaceStringInFile( $Spath , $replace2 ,$userdata1 )
;~    exit
   ; MsgBox(0,"Waiting","hold")
   ;_ReplaceStringInFile( $Spath , $userdata1,$replace2 )
   ;_ReplaceStringInFile( $Spath , $userdata2,$replace3 )
Exit


EndFunc

@Chimp

I found a solution to my IP_list problem. But I'm Still Farley new to programming / autoit  and I can't get the multiping.au3 to flow into it.

I am using a version of your ping script.

I'm trying to make it push my filemod script plus your ping script and it doesn't seem to work the way I've tried it any thought on which way to take it

 

 

And this is your code im trying to us in it

; this is to ping continuously a list of IP addresses, get and display ping result "live"
; it simulates the dos "ping -t" command but performed simultaneously on many IP
; presenting the results in a ListView highlighting not responding devices with a red box

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>

#include 'MultiPing.au3' ; <-- take this from the following link:
; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping

Opt("GUIOnEventMode", 1)
HotKeySet("{esc}", "_button1")


Local $Win_X = 600, $Win_Y = 600 ; dimension of window
$PingGui = GUICreate("IP addresses monitor", $Win_X, $Win_Y, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
$listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
GUICtrlSetFont(-1, 6)
GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP)

; Generate colored square images
$hImage = _GUIImageList_Create(16, 16)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 16, 16)) ; yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 16, 16)) ; red
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 16, 16)) ; green

_GUICtrlListView_SetImageList($listview, $hImage, 0)

$button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
GUICtrlSetTip(-1, "End of program")
GUICtrlSetOnEvent(-1, "_button1")
GUISetState(@SW_SHOW)

$IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's
;
; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt
; values in the file should be separated by a semicolon, something like in the following example:
;
; hostname1;192.168.0.1
; hostname2;192.168.0.5
; hostnameX;10.59.7.200
; etc....
;
;  if values in the file are not separated by a semicolon, but another char is used, for example a comma,
;  then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",")
;
_GUICtrlListView_BeginUpdate($listview)
_GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView
_GUICtrlListView_EndUpdate($listview)

   While 1 ; continuously ping addresses of the previously loaded file (IP_List.txt)
    Sleep(10)
    ;
    ;        $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case)
    ;        |
    ;        |      1 means the IP are in the second column of the $IPlist array (first colun is nr. 0)
    ;        |      |
    ;        |      |  +-->  0 means return back an array loaded with results from all pinged addresses (responding and not responding)
    ;        |      |  |     if you use 1 then only responding addresses are loaded in the returned array [default]
    ;        |      |  |     if you use 2 then only NOT responding addresses are loaded in the returned array
    ;        |      |  |     In this case we do not need an  array to be returned, we only need to perform all pings and pass results
    ;        |      |  |     directly (on the fly) to the "_refresh" callback function that will refresh the listview
    ;        |      |  |
    ;        |      |  |  0 means NO lookup name resolution must be performed
    ;        |      |  |  |
    ;        |      |  |  |   +--> this is the callback function to be called for each pinged address each time the ping has finished
    ;        |      |  |  |   |    (see the MultiPing.au3 file for info on all passed params)
    ;        |      |  |  |   |    6 parameters are passed to this function, but only 2 are used by the called function in this case:
    ;        |      |  |  |   |    [4] roundtrip of the responding ping or -1 if IP is down
    ;        |      |  |  |   |    [5] Index (position) of this IP within the caller's passed array
    ;        |      |  |  |   |
    ;        v      v  v  v   v
    _nPing($IPlist, 1, 0, 0, "_refresh")
    ;
   WEnd

   Func _refresh($Params) ; this receive ping results and displays them in the ListView
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
   EndFunc   ;==>_refresh

   Func _button1() ; Button 1 clicked
    Exit
   EndFunc   ;==>_button1
;Credit Chimp

 

And my plan is to work in ,a save to .csv soon

And I want to say the code you made is pretty badass I just have to teak it a bit

and I'm just starting to learn so thing you could help me on would be great.

Thoughts?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

On 26/4/2017 at 9:56 PM, dascondor said:

@chimp

. . . I want to say the code you made is pretty badass . . .

thank you .... :)

p.s.

some tips to your question on your other thread...

Edited by Chimp

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

Share this post


Link to post
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