Advertisement
duquesne9

xmap from vid

Jan 14th, 2024
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. //command: nmap
  2. if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("nmap_usage")) 
  3. if not is_valid_ip(params[0]) then exit("nmap: invalid ip address")
  4. if not get_shell.host_computer.is_network_active then exit("nmap: No internet access.")
  5.  
  6. ipAddress = params[0]
  7. isLanIp = is_lan_ip( ipAddress )
  8.  
  9. if isLanIp then
  10.    router = get_router;
  11. else
  12.    router = get_router( ipAddress )
  13. end if
  14.  
  15. if router == null then exit("nmap: ip address not found")
  16.  
  17. print_ports = function(ports)
  18.     //info = "<b>PORT STATE SERVICE VERSION LAN</b>"  
  19.     if typeof(ports) == "string" then return print(ports)
  20.     if ports.len == 0 then return print("Scan finished, no open ports\n")
  21.  
  22.     if(ports.len == 0) then exit("Scan finished. No open ports.")
  23.  
  24.     for port in ports
  25.         service_info = router.port_info(port)
  26.         lan_ips = port.get_lan_ip
  27.         //port_status = "open"
  28.         port_status = "<color=#00FF00>open</color>"
  29.  
  30.         if(port.is_closed and not isLanIp) then
  31.             // port_status = "closed"
  32.             port_status = "<color=#FF0000>closed</color>"
  33.         end if
  34.         info = info + "\n<color=#EA31E4>" + port.port_number + "</color> " + port_status + " <color=#4690C2>" + service_info + "</color><color=#E2C73F> " + lan_ips + "</color>"
  35.     end for
  36.     print(format_columns(info) + "\n")
  37. end function
  38.  
  39.  
  40. print("\nStarting nmap v1.1 at " + current_date)
  41. print("Interesting ports on " + params[0] + "\n")
  42. print_ports(router.used_ports)
  43.  
  44. ports = []
  45. for lan in router.devices_lan_ip
  46.     ports = ports + router.device_ports(lan)
  47. end for
  48. print_ports(ports)
  49.  
  50.      
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement