Advertisement
Aypleck

RandomWeb

Feb 21st, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 7.11 KB | None | 0 0
  1. @echo off
  2. SETLOCAL EnableDelayedExpansion
  3. mode con cols=70 lines=15
  4. chcp 65001 >nul
  5. title RandomWeb ^| By Aypleck
  6. color f0
  7.  
  8. :: #### CHECKING WINDOWS VERSION ####
  9.  
  10. for /f "tokens=4-5 delims=. " %%i in ('ver') do (
  11.     if "%%i" NEQ "10" (
  12.         call :headerwarn
  13.         echo [%time%] DETECTED WINDOWS VERSION : %%i
  14.         echo [%time%] This script has been created for windows 10, You may encounter issues by running it on other versions of windows.
  15.         pause>nul
  16.         color f0
  17.     )
  18. )
  19.  
  20.  
  21. :: #### CREATING CONFIG FILE ####
  22.  
  23. if not exist "%~n0.ini" (
  24.     echo sitelistpath=sitelist.txt >%~n0.ini
  25.     echo maxping=500 >>%~n0.ini
  26. )
  27.  
  28. :: #### DOWNLOADING http-ping.exe ####
  29. if not exist "http-ping.exe" (
  30.     call :headerwarn
  31.     echo [%time%] RandomWeb needs http-ping.exe to work, press any key to download it from coretechnologies.com.
  32.     pause>nul
  33.     powershell -Command "Invoke-WebRequest https://www.coretechnologies.com/products/http-ping/http-ping.exe -OutFile http-ping.exe"
  34. )
  35. :: #### PARSING CONFIG FILE ####
  36. call :readconfig
  37.  
  38. :: #############
  39. :: # MAIN MENU #
  40. :: #############
  41.  
  42. :mainMenu
  43. color f0
  44. call :header
  45. echo 1. Search for websites
  46. echo 2. Manage discovered sites
  47. echo 3. Change options
  48. echo 0. Exit
  49.  
  50. choice /c 1230 /n >nul
  51.  
  52. if !errorlevel! EQU 1 goto :searchMenu
  53. if !errorlevel! EQU 2 goto :manageMenu
  54. if !errorlevel! EQU 3 goto :optionsMenu
  55. if !errorlevel! EQU 4 exit
  56.  
  57. :: ##################
  58. :: # SEARCH SECTION #
  59. :: ##################
  60.  
  61. :searchMenu
  62. call :headersearch
  63.  
  64. echo [%time%] Search started.
  65. :searchloop
  66. set /a ip1="%random%%%254"
  67. set /a ip2="%random%%%254"
  68. set /a ip3="%random%%%254"
  69. set /a ip4="%random%%%254"
  70. set host=%ip1%.%ip2%.%ip3%.%ip4%
  71. ping -n 1 %host% -w !maxping! >nul
  72. if !errorlevel! EQU 0 (
  73.     REM PortQry.exe -n %host% -e 80 -q
  74.     http-ping %host% -n 1 -e -w 1 -s>nul
  75.     if !errorlevel! GTR 200 (
  76.         if !errorlevel! LSS 399 (
  77.             for /f %%l in (!sitelistpath!) DO (
  78.                 if %%l EQU %host% ( goto :a )
  79.             )
  80.             echo %host% >>!sitelistpath!  
  81.             echo [%time%] host %host% responded with code !errorlevel!
  82.             )
  83.         )
  84.     )
  85. )
  86. goto :searchloop
  87.  
  88.  
  89.  
  90. :: ##################
  91. :: # MANAGE SECTION #
  92. :: ##################
  93.  
  94. :manageMenu
  95. call :headermanage
  96. ::Showing file states
  97. ::Compute Number of sites
  98. set sitenbr=0
  99. for /f %%l in (!sitelistpath!) do (set /a sitenbr=!sitenbr!+1)
  100. ::Compute size of file
  101. for /f "tokens=3" %%o in ('dir /-c ^| findstr "!sitelistpath!"') do (set size=%%o)
  102. ::Echo stats
  103. echo !sitelistpath! stores !sitenbr! sites, the file weight !size! octets.
  104.  
  105. echo 1. Open site list file.
  106. echo 2. Open all sites in a web browser.
  107. echo 3. Clear sites list.
  108. echo 0. Back
  109. choice /c 1230 /n
  110.  
  111. :: Open site list
  112. if %errorlevel% EQU 1 (
  113.     call :headermanage
  114.     start !sitelistpath!
  115.     echo !sitelistpath! has been opened in notepad.
  116.     pause>nul
  117.     goto :manageMenu
  118. )
  119.  
  120. :: Open site list in a browser
  121. if %errorlevel% EQU 2 (
  122.     call :headermanage
  123.     for /f %%l in (!sitelistpath!) do (
  124.         start "" "http://%%l"
  125.     )
  126.     echo All sites has been opened in you default browser.
  127.     pause>nul
  128.     goto :manageMenu
  129. )
  130.  
  131. :: Clear site list
  132. if %errorlevel% EQU 3 (
  133.     call :headermanage
  134.     break>!sitelistpath!
  135.     echo File !sitelistpath! has been cleared.
  136.     pause>nul
  137.     goto manageMenu
  138. )
  139. ::Back
  140. if %errorlevel% EQU 4 (
  141.     goto :mainMenu
  142. )
  143.  
  144. goto :mainMenu
  145.  
  146. :: ###################
  147. :: # OPTIONS SECTION #
  148. :: ###################
  149.  
  150. :optionsMenu
  151. call :headeroptions
  152. echo 1. Change site list file path : !sitelistpath!
  153. echo 2. Change maximum latency for an host during search : !maxping!
  154. echo 0. Back
  155. choice /c 012 /n
  156.  
  157. if !errorlevel! EQU 1 goto :mainMenu
  158.  
  159. if !errorlevel! EQU 2 (
  160.     cls
  161.     call :headeroptions
  162.     set /p newpath=Where do you want to store found sites :
  163.     call :setSitelistpath !newpath!
  164.     goto :optionsMenu
  165. )
  166.  
  167. if !errorlevel! EQU 3 (
  168.     cls
  169.     call :headeroptions
  170.     set /p newPing=Set the max ping for a host before considering it as down :
  171.     call :setMaxping !newPing!
  172.     goto :optionsMenu
  173. )
  174.  
  175.  
  176.  
  177. :: #############
  178. :: # FUNCTIONS #
  179. :: #############
  180.  
  181. :readconfig
  182.  
  183. :: #### READING CONFIG FILE ####
  184.  
  185. :: For each line of the config file
  186. for /f "delims= tokens=*" %%l in (%~n0.ini) do (
  187.    :: Get the word behind the charcter "="
  188.     for /f "delims== tokens=1" %%k in ("%%l") do (
  189.        :: Get the word after the "="
  190.         for /f "delims== tokens=2" %%v in ("%%l") do (
  191.            :: If there is something after the "="
  192.             if %errorlevel% == 0 (
  193.                :: Set a variable with the name of the word behind the space and with the value of the word after the space
  194.                 set "%%k=%%v"
  195.             )
  196.         )
  197.     )
  198. )
  199. goto :EOF
  200. rem ## OPTION MODIFYING FUCNTIONS ##
  201.  
  202. :setSitelistpath
  203. echo sitelistpath=%1>%~n0.ini
  204. echo maxping=!maxping!>>%~n0.ini
  205. set sitelistpath=%1
  206. GOTO :eof
  207.  
  208. :setMaxping
  209. echo sitelistpath=!sitelistpath!>%~n0.ini
  210. echo maxping=%1>>%~n0.ini
  211. set maxping=%1
  212. GOTO :eof
  213.  
  214. rem ## GRAPHICALS FUCNTIONS ##
  215.  
  216. :header
  217. cls
  218. echo                ╔═════════════════════════════════════╗
  219. echo                ║         RandomWeb by Aypleck        ║
  220. echo                ╚═════════════════════════════════════╝
  221. echo.
  222. echo.
  223. GOTO :eof
  224.  
  225. :headersearch
  226. cls
  227. echo                ╔═════════════════════════════════════╗
  228. echo                ║     Search for random websites      ║
  229. echo                ╚═════════════════════════════════════╝
  230. echo.
  231. echo.
  232. GOTO :eof
  233.  
  234. :headermanage
  235. cls
  236. echo                ╔═════════════════════════════════════╗
  237. echo                ║     Manage your website list        ║
  238. echo                ╚═════════════════════════════════════╝
  239. echo.
  240. echo.
  241. GOTO :eof
  242.  
  243.  
  244. :headeroptions
  245. cls
  246. echo                ╔═════════════════════════════════════╗
  247. echo                ║              OPTIONS                ║
  248. echo                ╚═════════════════════════════════════╝
  249. echo.
  250. echo.
  251. GOTO :eof
  252.  
  253. :headerwarn
  254. cls
  255. color 06
  256. echo                ╔═════════════════════════════════════╗
  257. echo                ║              WARNING                ║
  258. echo                ╚═════════════════════════════════════╝
  259. echo.
  260. echo.
  261. GOTO :eof
  262.  
  263. :headererror
  264. cls
  265. color 0c
  266. echo                ╔═════════════════════════════════════╗
  267. echo                ║            FATAL ERROR              ║
  268. echo                ╚═════════════════════════════════════╝
  269. echo.
  270. echo.
  271. GOTO :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement