Simple Network Scanner

Sometimes the simplest of things is still quite hard. Say you’re connected to a client’s network by RDP and want to get a quick view of the devices on his network. Choosing, downloading and running a port-scanner may be unacceptable, but how can a few pings and arps in a batch file be a problem?

 

Ladies and Gentlemen, I give you:

NetMap.cmd

setlocal
 
if "%1"=="" (
    set RANGE=192.168.0
) else (
    set RANGE=%1
)
 
if "%2"=="" (
    set OUT=CON:
) else (
    set OUT=%2
)
 
 
for /l %%i in (1,1,254) do start ping -n 1 %RANGE%.%%i
pause
 
@echo off
for /f "skip=3 tokens=1,2 delims= " %%i in ('arp -a') do (
    for /f "tokens=1-3 delims= " %%k in ('ping -n 1 -a %%i') do (
        if "%%k"=="Pinging" (
            if "%%m"=="with" (
                echo %%j    [%%l]     Unknown>>%OUT%
            ) else (
                echo %%j    %%m     %%l>>%OUT%
            )
        )
    )
)
 
endlocal
 
if "%2"=="" (
    pause
)

Usage:

Just double-click (assumes you’re on the 192.168.0/24 subnet)

NetMap (from a command prompt)

When it gets to the 1st pause, wait till all the ping boxes have gone, them press Enter.

-or-

NetMap 192.168.100 C:\NetMap.log to specify the subnet and the output file name

 

Enjoy.

Advertisements
This entry was posted in Code. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s