Friday, March 23, 2012

Batch Ping Scan and Name Resolution

It's not fancy, but if you can't "import" any tools to a windows system this will do a basic job of finding hosts and resolving their names.

Quick, simple, uses nothing but built in components in the windows system.

@echo off
Title Scan
mode con: cols=20 lines=5
echo    Enter Network:
echo [Example 192.168.1]
set /p network=
cls
mode con: cols=60 lines=254
title Scanning Network %network%.0/24
echo Scanning...
for /L %%i in (1,1,255) do ping -n 1 -w 60 %network%.%%i | find /i "reply" >> ~temp1
for /f "tokens=3 delims=: " %%i in (~temp1) do echo %%i >> ~temp2
del /f /q ~temp1 > nul
cls
title Resolving Network %network%.0/24
for /f %%i in (~temp2) do for /f "tokens=2 delims=: " %%g in ('nslookup %%i 2^>nul ^| find /i "name"') do echo %%i %%g
for /f %%i in (~temp2) do for /f "tokens=1 delims=: " %%g in ('nslookup %%i 2^>^&1 ^| find /i "***"') do echo %%i Hostname Lookup Failed
del /f /q ~temp2 > nul
pause

No comments:

Post a Comment

All comments moderated.
Comments like "sweet dude" or "this is awesome" or "thanks" will be denied,
if you've got something genuinely interesting to say, say it. Other than that just sit back and bask in the glory.