Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- SETLOCAL EnableDelayedExpansion
- mode con cols=70 lines=15
- chcp 65001 >nul
- title RandomWeb ^| By Aypleck
- color f0
- :: #### CHECKING WINDOWS VERSION ####
- for /f "tokens=4-5 delims=. " %%i in ('ver') do (
- if "%%i" NEQ "10" (
- call :headerwarn
- echo [%time%] DETECTED WINDOWS VERSION : %%i
- echo [%time%] This script has been created for windows 10, You may encounter issues by running it on other versions of windows.
- pause>nul
- color f0
- )
- )
- :: #### CREATING CONFIG FILE ####
- if not exist "%~n0.ini" (
- echo sitelistpath=sitelist.txt >%~n0.ini
- echo maxping=500 >>%~n0.ini
- )
- :: #### DOWNLOADING http-ping.exe ####
- if not exist "http-ping.exe" (
- call :headerwarn
- echo [%time%] RandomWeb needs http-ping.exe to work, press any key to download it from coretechnologies.com.
- pause>nul
- powershell -Command "Invoke-WebRequest https://www.coretechnologies.com/products/http-ping/http-ping.exe -OutFile http-ping.exe"
- )
- :: #### PARSING CONFIG FILE ####
- call :readconfig
- :: #############
- :: # MAIN MENU #
- :: #############
- :mainMenu
- color f0
- call :header
- echo 1. Search for websites
- echo 2. Manage discovered sites
- echo 3. Change options
- echo 0. Exit
- choice /c 1230 /n >nul
- if !errorlevel! EQU 1 goto :searchMenu
- if !errorlevel! EQU 2 goto :manageMenu
- if !errorlevel! EQU 3 goto :optionsMenu
- if !errorlevel! EQU 4 exit
- :: ##################
- :: # SEARCH SECTION #
- :: ##################
- :searchMenu
- call :headersearch
- echo [%time%] Search started.
- :searchloop
- set /a ip1="%random%%%254"
- set /a ip2="%random%%%254"
- set /a ip3="%random%%%254"
- set /a ip4="%random%%%254"
- set host=%ip1%.%ip2%.%ip3%.%ip4%
- ping -n 1 %host% -w !maxping! >nul
- if !errorlevel! EQU 0 (
- REM PortQry.exe -n %host% -e 80 -q
- http-ping %host% -n 1 -e -w 1 -s>nul
- if !errorlevel! GTR 200 (
- if !errorlevel! LSS 399 (
- for /f %%l in (!sitelistpath!) DO (
- if %%l EQU %host% ( goto :a )
- )
- echo %host% >>!sitelistpath!
- echo [%time%] host %host% responded with code !errorlevel!
- )
- )
- )
- )
- goto :searchloop
- :: ##################
- :: # MANAGE SECTION #
- :: ##################
- :manageMenu
- call :headermanage
- ::Showing file states
- ::Compute Number of sites
- set sitenbr=0
- for /f %%l in (!sitelistpath!) do (set /a sitenbr=!sitenbr!+1)
- ::Compute size of file
- for /f "tokens=3" %%o in ('dir /-c ^| findstr "!sitelistpath!"') do (set size=%%o)
- ::Echo stats
- echo !sitelistpath! stores !sitenbr! sites, the file weight !size! octets.
- echo 1. Open site list file.
- echo 2. Open all sites in a web browser.
- echo 3. Clear sites list.
- echo 0. Back
- choice /c 1230 /n
- :: Open site list
- if %errorlevel% EQU 1 (
- call :headermanage
- start !sitelistpath!
- echo !sitelistpath! has been opened in notepad.
- pause>nul
- goto :manageMenu
- )
- :: Open site list in a browser
- if %errorlevel% EQU 2 (
- call :headermanage
- for /f %%l in (!sitelistpath!) do (
- start "" "http://%%l"
- )
- echo All sites has been opened in you default browser.
- pause>nul
- goto :manageMenu
- )
- :: Clear site list
- if %errorlevel% EQU 3 (
- call :headermanage
- break>!sitelistpath!
- echo File !sitelistpath! has been cleared.
- pause>nul
- goto manageMenu
- )
- ::Back
- if %errorlevel% EQU 4 (
- goto :mainMenu
- )
- goto :mainMenu
- :: ###################
- :: # OPTIONS SECTION #
- :: ###################
- :optionsMenu
- call :headeroptions
- echo 1. Change site list file path : !sitelistpath!
- echo 2. Change maximum latency for an host during search : !maxping!
- echo 0. Back
- choice /c 012 /n
- if !errorlevel! EQU 1 goto :mainMenu
- if !errorlevel! EQU 2 (
- cls
- call :headeroptions
- set /p newpath=Where do you want to store found sites :
- call :setSitelistpath !newpath!
- goto :optionsMenu
- )
- if !errorlevel! EQU 3 (
- cls
- call :headeroptions
- set /p newPing=Set the max ping for a host before considering it as down :
- call :setMaxping !newPing!
- goto :optionsMenu
- )
- :: #############
- :: # FUNCTIONS #
- :: #############
- :readconfig
- :: #### READING CONFIG FILE ####
- :: For each line of the config file
- for /f "delims= tokens=*" %%l in (%~n0.ini) do (
- :: Get the word behind the charcter "="
- for /f "delims== tokens=1" %%k in ("%%l") do (
- :: Get the word after the "="
- for /f "delims== tokens=2" %%v in ("%%l") do (
- :: If there is something after the "="
- if %errorlevel% == 0 (
- :: Set a variable with the name of the word behind the space and with the value of the word after the space
- set "%%k=%%v"
- )
- )
- )
- )
- goto :EOF
- rem ## OPTION MODIFYING FUCNTIONS ##
- :setSitelistpath
- echo sitelistpath=%1>%~n0.ini
- echo maxping=!maxping!>>%~n0.ini
- set sitelistpath=%1
- GOTO :eof
- :setMaxping
- echo sitelistpath=!sitelistpath!>%~n0.ini
- echo maxping=%1>>%~n0.ini
- set maxping=%1
- GOTO :eof
- rem ## GRAPHICALS FUCNTIONS ##
- :header
- cls
- echo ╔═════════════════════════════════════╗
- echo ║ RandomWeb by Aypleck ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
- :headersearch
- cls
- echo ╔═════════════════════════════════════╗
- echo ║ Search for random websites ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
- :headermanage
- cls
- echo ╔═════════════════════════════════════╗
- echo ║ Manage your website list ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
- :headeroptions
- cls
- echo ╔═════════════════════════════════════╗
- echo ║ OPTIONS ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
- :headerwarn
- cls
- color 06
- echo ╔═════════════════════════════════════╗
- echo ║ WARNING ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
- :headererror
- cls
- color 0c
- echo ╔═════════════════════════════════════╗
- echo ║ FATAL ERROR ║
- echo ╚═════════════════════════════════════╝
- echo.
- echo.
- GOTO :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement