Hey guys, im just looking for some opinions on this little batch script i wrote. It scans a range of IP adresses and lists all the shared folders that it finds. You can also add some syntax to drop files and preform remote commands to the shares once it finds them.
1. Run Netview.bat (Scans IPs)
2. Run Search.bat (Searches Scanned Results for Shares)
3. Open c:/hackme.txt (Results)
NETVIEW.BAT Code:
echo off
prompt ~
IF NOT EXIST c:a mkdir c:a
IF EXIST c:a del /q c:a*
cls
echo.
echo.
echo.
echo TYPE THE IP ADRESS IN THE FORM (w.x.y.z)
echo.
echo.
echo w=
set /p w=
echo x=
set /p x=
echo y=
set /p y=
echo z=
set /p z=
set count=0
:10
set ipadd=%w%.%x%.%y%.%z%
cls
echo %ipadd%
REM --------- CHECKING IP TO SEE IF ONLINE
ping -n 1 -l 10 -f -w 1 %w%.%x%.%y%.%z% >> c:ping5.txt
findstr "Reply" c:ping5.txt
If %errorlevel% EQU 0 GOTO :NETVIEW
del c:ping5.txt
:IPCOUNTER
set /a count=%count%+1
If %w% EQU 255 If %x% EQU 255 If %y% EQU 255 If %z% EQU 255 (cls && echo The number of combinations is %count%)
If %x% EQU 255 If %y% EQU 255 If %z% EQU 255 (Set /a w=%w%+1 && Set x=0 && Set y=0 && Set z=0 && goto :10)
If %y% EQU 255 If %z% EQU 255 (Set /a x=%x%+1 && Set y=0 && Set z=0 && goto :10)
If %z% EQU 255 (Set /a y=%y%+1 && Set z=0 && goto :10)
set /a z=%z%+1
GOTO :10
:NETVIEW
del c:ping5.txt
echo ^e^cho off >> c:aview%w%.%x%.%y%.%z%.bat
echo net view %w%.%x%.%y%.%z% ^>^> c:aview%w%.%x%.%y%.%z%.txt >> c:aview%w%.%x%.%y%.%z%.bat
echo exit >> c:aview%w%.%x%.%y%.%z%.bat
start c:aview%w%.%x%.%y%.%z%.bat
GOTO :IPCOUNTER
SEARCH.BAT Code:
echo off
prompt ~
cls
echo.
echo.
echo.
echo TYPE THE STARTING IP ADRESS IN THE FORM (w.x.y.z)
echo.
echo.
echo w=
set /p w=
echo x=
set /p x=
echo y=
set /p y=
echo z=
set /p z=
set count=0
:10
echo c:aview%w%.%x%.%y%.%z%.txt
IF EXIST c:aview%w%.%x%.%y%.%z%.txt GOTO :FIND
:BACK
set /a count=%count%+1
If %w% EQU 255 If %x% EQU 255 If %y% EQU 255 If %z% EQU 255 (cls && echo The number of combinations is %count%)
If %x% EQU 255 If %y% EQU 255 If %z% EQU 255 (Set /a w=%w%+1 && Set x=0 && Set y=0 && Set z=0 && goto :10)
If %y% EQU 255 If %z% EQU 255 (Set /a x=%x%+1 && Set y=0 && Set z=0 && goto :10)
If %z% EQU 255 (Set /a y=%y%+1 && Set z=0 && goto :10)
set /a z=%z%+1
cls
GOTO :10
:FIND
FINDSTR Share c:aview%w%.%x%.%y%.%z%.txt
If %errorlevel% EQU 0 echo %w%.%x%.%y%.%z% >> c:SHAREIP.txt
IF %ERRORLEVEL% EQU 0 type c:aview%w%.%x%.%y%.%z%.txt >> c:hackme.txt
GOTO :BACK
