Advertisement
casencty

scnlan

Nov 13th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. //command: scnlan
  2. formatstring= function(len,string)
  3.     newstring=" "*len
  4.     newstring=""+newstring[0:len-string.len]+string
  5.     return newstring
  6. end function
  7. if params.len then
  8.     if is_valid_ip(params[0]) then
  9.         info= "Scanning network @ <color=#00ff00>"+formatstring(15,params[0])+" "
  10.         router = get_router(params[0])
  11.         if router then
  12.             ips = [router.local_ip]+router.computers_lan_ip
  13.         end if
  14.     else
  15.         print("<b><u>Usage:</b></u>")
  16.         print("<b>scnlan [Ip Adress]<b>")
  17.         print("<i>scan a distant network and show all services running on the network</i>")
  18.         print("<b>scnlan <b>")
  19.         print("<i>scan a local network and show all services on all computers</i>")
  20.         exit   
  21.     end if
  22. else
  23.     info= "Scanning Local network             "
  24.     router = get_router
  25.     ips = [router.local_ip]+router.computers_lan_ip
  26. end if
  27. if not router then
  28.     info= "<B>invalid ip Scanning Local network</B>"
  29.     router = get_router
  30.     ips = [router.local_ip]+router.computers_lan_ip
  31. end if
  32. computer = get_shell.host_computer
  33. if not router or not computer.is_network_active then exit("Not connected to the network.")
  34. ips = [router.local_ip]+router.computers_lan_ip
  35. print("+----------------------------------------------+-----+")
  36. print("| Advanced Lan Scanner                         |<u>V.1.0</u>|")
  37. print("| "+info+"                |")
  38. print("+-------------------+---------------------------------")
  39. for ipAddress in ips
  40.     isRouterIp = router.local_ip == ipAddress
  41.     ports = null
  42.     isLanIp = is_lan_ip( ipAddress )
  43.     info=""
  44.     if not isLanIp or isRouterIp then
  45.         ports = router.used_ports
  46.         print("|   "+formatstring(15,"[Router]")+" |                                |")
  47.         print("|   "+formatstring(15,ipAddress)+" |  Port  status   informations   |")
  48.     else
  49.         ports = router.computer_ports(ipAddress)
  50.         if ports.len>0 then
  51.             print("|   "+formatstring(15,ipAddress)+" |  Port  status   informations   |")
  52.         else
  53.             print("|   "+formatstring(15,ipAddress)+" |    No opened ports detected    |")
  54.         end if
  55.     end if
  56.     if ports!= null then
  57.         for port in ports
  58.             service_info = router.port_info(port)
  59.             lan_ips = port.get_lan_ip
  60.             port_status = "open"       
  61.             if(port.is_closed and not isLanIp) then
  62.                 port_status = "closed"
  63.             end if
  64.             print( "|                   |"+formatstring(6,str(port.port_number)) + "  " + formatstring(6,port_status) + " " + formatstring(15,service_info) + "  |")
  65.         end for        
  66.     end if
  67.     print("+----------------------------------------------------+")
  68.     end for
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement