Archeagus

Mapscan v1.0 - Archeagus Grey Hack Series, Episode 4

Jun 7th, 2026 (edited)
26,983
0
Never
17
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Command mapscan v1.0
  2. if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit("<b>Usage: "+program_path.split("/")[-1]+" [ip_address]</b>")
  3.  
  4. metax = include_lib("/lib/metaxploit.so")
  5. if not metax then exit("<b>Error: Unable to find 'metaxploit.so'. Put missing library in the 'lib' folder.</b>")
  6.  
  7. shell = get_shell
  8. computer = shell.host_computer
  9.  
  10. if not is_valid_ip(params[0]) then exit("<b>nmap: invalid ip address</b>")
  11. if not computer.is_network_active then exit("<b>nmap: No internet access.</b>")
  12.  
  13. ipAddress = params[0]
  14. if ipAddress == "127.0.0.1" then ipAddress = computer.local_ip
  15. isLanIp = is_lan_ip( ipAddress )
  16.  
  17. if isLanIp then
  18.    router = get_router;
  19. else
  20.    router = get_router( ipAddress )
  21. end if
  22.  
  23. if router == null then exit("<b>nmap: ip address not found</b>")
  24.  
  25. ports = null
  26.  
  27. if not isLanIp then
  28.    ports = router.used_ports
  29. else
  30.    ports = router.device_ports(ipAddress)
  31. end if
  32.  
  33. if ports == null then exit("<b>nmap: ip address not found</b>")
  34. if typeof(ports) == "string" then exit(ports)
  35.  
  36. targetsFolderName = "Targets"
  37. targetsFolderPath = "/home/"+active_user
  38. targetsFolder = targetsFolderPath + "/" + targetsFolderName
  39. if computer.File(targetsFolder) == null then computer.create_folder(targetsFolderPath, targetsFolderName)
  40.  
  41. outputFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  42.  
  43. if outputFile == null then
  44.     computer.touch(targetsFolder, ipAddress + ".txt")
  45.     outputFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  46. end if
  47.  
  48. output = ""
  49.      
  50. info = "PORT STATE SERVICE VERSION LAN"  
  51. print("\nStarting nmap v2.0 at " + current_date)
  52. print("Interesting ports on " + params[0] + "\n")
  53. if(ports.len == 0) then exit("Scan finished. No open ports.")
  54.  
  55. for port in ports
  56.    service_info = router.port_info(port)
  57.    lan_ips = port.get_lan_ip
  58.    port_status = "open"
  59.  
  60.    if(port.is_closed and not isLanIp) then
  61.       port_status = "closed"
  62.    end if
  63.    info = info + "\n" + port.port_number + " " + port_status + " " + service_info + " " + lan_ips
  64. end for
  65. print(format_columns(info) + "\n")
  66. output = output + format_columns(info) + char(10)
  67.  
  68. for port in ports
  69.    net_session = metax.net_use(ipAddress, port.port_number)
  70.    if not net_session then exit("<b>Error: Unable to connect.</b>")
  71.      
  72.    metaLib = net_session.dump_lib
  73.    print("\nScanning " + metaLib.lib_name + " v" + metaLib.version + " on port " + port.port_number)
  74.    output = output + char(10) + char(10) + "Scanned " + metaLib.lib_name + " v" + metaLib.version + " on port " + port.port_number
  75.    scanResult = metax.scan(metaLib)
  76.  
  77.    for zone in scanResult
  78.       memory_scan = metax.scan_address(metaLib, zone)
  79.       print("\nFound memory zone: " + zone)
  80.       output = output + char(10) + char(10) + "Exploits for zone: " + zone
  81.       xpList = memory_scan.split("Unsafe check: ")[1:]
  82.       exploits = []
  83.       for xp in xpList
  84.          labelStart = xp.indexOf("<b>")
  85.          labelEnd = xp.indexOf("</b>")
  86.          exploits.push(xp[labelStart + 3: labelEnd])
  87.       end for
  88.       print("Available vulnerabilities: " + exploits.join(", "))
  89.       output = output + char(10) + "Vulnerabilities found: " + exploits.join(char(10))
  90.    end for
  91. end for
  92. outputFile.set_content(output)
  93. print ("\nNMAP Scan completed.\nResults saved to " + ipAddress + ".txt in " + targetsFolderName + " folder.")
Advertisement