SHARE
TWEET

portscanner

a guest Jan 24th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. p_start = 8000
  2. p_end = 65000
  3. s_url = "http://IP:{PORT}/console?command=ping"
  4.  
  5. local function add_log(_sLog)
  6.   l = fs.open("/log_ps", fs.exists("/log_ps") and "a" or "w")
  7.   l.writeLine(_sLog)
  8.   l.close()
  9.   return true
  10. end
  11.  
  12. add_log("=== "..p_start.." - "..p_end)
  13. add_log("===STARTED AT:")
  14. add_log(s_url)
  15.  
  16. local function get(_sPort, _sUrl)
  17.   _sUrl = string.gsub(_sUrl, "{PORT}", _sPort)
  18.   tmp_success = nil
  19.   http.request(_sUrl)
  20.   print(_sPort)
  21.   while true do
  22.    
  23.     ev, url, sFileContent = os.pullEvent()
  24.    
  25.     if (ev == "http_success") then
  26.       print(_sPort.." OPEN!")
  27.       add_log("OPEN: ".._sPort)
  28.       tmp_success = true
  29.     elseif (ev == "http_failure") then
  30.       tmp_success = false
  31.     end
  32.    
  33.     if tmp_success ~= nil then
  34.       break
  35.     end
  36.   end
  37.  
  38.   return false
  39. end
  40.  
  41.  
  42.  
  43. for i=p_start, p_end do
  44.   get(i, s_url)
  45. end
  46. add_log("===FINNISHED===")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top