Archeagus

Mapscan v2.0 - Archeagus Grey Hack Series, Episode 5

Jun 11th, 2026 (edited)
32,544
0
Never
20
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Command mapscan v2.0 (RC)
  2. if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit("Usage: "+program_path.split("/")[-1]+" [ip_address]")
  3.  
  4. metax = include_lib("/lib/metaxploit.so")
  5. if not metax then exit("Error: Unable to find 'metaxploit.so'. Put missing library in the 'lib' folder.")
  6.  
  7. // Adding password variable for vulnerability testing
  8. shell = get_shell
  9. computer = shell.host_computer
  10. password = "password"
  11.  
  12. if not is_valid_ip(params[0]) then exit("nmap: invalid ip address")
  13. if not computer.is_network_active then exit("nmap: No internet access.")
  14.  
  15. ipAddress = params[0]
  16. if ipAddress == "127.0.0.1" then ipAddress = computer.local_ip
  17. isLanIp = is_lan_ip( ipAddress )
  18.  
  19. if isLanIp then
  20.    router = get_router;
  21. else
  22.    router = get_router( ipAddress )
  23. end if
  24.  
  25. if router == null then exit("nmap: ip address not found")
  26.  
  27. ports = null
  28.  
  29. if not isLanIp then
  30.    ports = router.used_ports
  31. else
  32.    ports = router.device_ports(ipAddress)
  33. end if
  34.  
  35. if ports == null then exit("nmap: ip address not found")
  36. if typeof(ports) == "string" then exit(ports)
  37.  
  38. targetsFolderName = "Targets"
  39. targetsFolderPath = "/home/"+active_user
  40. targetsFolder = targetsFolderPath + "/" + targetsFolderName
  41. if computer.File(targetsFolder) == null then computer.create_folder(targetsFolderPath, targetsFolderName)
  42.  
  43. outputFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  44.  
  45. if outputFile == null then
  46.     computer.touch(targetsFolder, ipAddress + ".txt")
  47.     outputFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  48. end if
  49.  
  50. output = ""
  51.      
  52. info = "PORT STATE SERVICE VERSION LAN"  
  53. clear_screen
  54. print("Starting nmap v2.0 at " + current_date)
  55. print("Interesting ports on " + params[0] + "\n")
  56. if(ports.len == 0) then exit("Scan finished. No open ports.")
  57.  
  58. for port in ports
  59.    service_info = router.port_info(port)
  60.    lan_ips = port.get_lan_ip
  61.    port_status = "open"
  62.  
  63.    if(port.is_closed and not isLanIp) then
  64.       port_status = "closed"
  65.    end if
  66.    info = info + "\n" + port.port_number + " " + port_status + " " + service_info + " " + lan_ips
  67. end for
  68. print(format_columns(info) + "\n")
  69. output = output + format_columns(info) + char(10)
  70.  
  71. // New variables for tracking new result objects and SQL library scans and capturing root shell access
  72. new_types = []
  73. sql_scanned = false
  74. cuZone = null
  75. cuExploit = null
  76. cuPort = null
  77. cuType = null
  78.  
  79. for port in ports
  80.    net_session = metax.net_use(ipAddress, port.port_number)
  81.    if not net_session then exit("Error: Unable to connect.")
  82.      
  83.    metaLib = net_session.dump_lib
  84.    if not metaLib.lib_name.indexOf("sql") or not sql_scanned then
  85.       print("\nScanning " + metaLib.lib_name + " v" + metaLib.version + " on port " + port.port_number)
  86.       output = output + char(10) + char(10) + metaLib.lib_name + " v" + metaLib.version + " on port " + port.port_number
  87.       scanResult = metax.scan(metaLib)
  88.  
  89.       for zone in scanResult
  90.          memory_scan = metax.scan_address(metaLib, zone)
  91.          print("\nFound memory zone: " + zone)
  92.          output = output + char(10) + char(10) + "Exploits for zone: " + zone
  93.          xpList = memory_scan.split("Unsafe check: ")[1:]
  94.          exploits = []
  95.          for xp in xpList
  96.             labelStart = xp.indexOf("<b>")
  97.             labelEnd = xp.indexOf("</b>")
  98.             exploit = xp[labelStart + 3: labelEnd]
  99.          print("\nTesting: " + exploit)
  100.          wait(1)
  101.             // Added password parameter for number type results
  102.             result = metaLib.overflow(zone, exploit, password)
  103.             if result == null then
  104.                status = "Undefined / Conditional"
  105.             else if typeof(result) == "shell" then
  106.                status = "Shell (?)"
  107.                
  108.                target_comp = result.host_computer
  109.                shell_user = "guest" // Default
  110.                   // Create a file in /var (accessible by all accounts)
  111.                   target_comp.touch("/var", "tmp.txt")
  112.                   temp_file = target_comp.File("/var/tmp.txt")
  113.                  
  114.                   if temp_file != null then
  115.                      shell_user = temp_file.owner // The owner of a newly touched file is the active shell user
  116.                      temp_file.delete // More deletions to cleanup later
  117.                   end if              
  118.  
  119.                if shell_user == "root" then
  120.                     status = "Shell (ROOT)"
  121.                  
  122.                   // Flag the root exploit details if we don't have a root yet
  123.                   if cuType == null or cuType != "Root" then
  124.                      cuZone = zone
  125.                      cuExploit = exploit
  126.                      cuPort = port.port_number
  127.                      cuType = "Root"
  128.                      print("Saved as final cleanup vector.")
  129.                   end if
  130.                else
  131.                  
  132.                   status = "Shell ("+shell_user+")"
  133.                   if cuType == null then
  134.                      cuZone = zone
  135.                      cuExploit = exploit
  136.                      cuPort = port.port_number
  137.                      cuType = shell_user
  138.                      print("Saved as possible cleanup vector.")
  139.                   else if cuType == "guest" and shell_user != "guest" then
  140.                      cuZone = zone
  141.                      cuExploit = exploit
  142.                      cuPort = port.port_number
  143.                      cuType = shell_user
  144.                      print("Saved as possible cleanup vector.")
  145.                   end if
  146.                end if
  147.             else if typeof(result) == "file" then
  148.                status = "File"
  149.             else if typeof(result) == "number" then
  150.                status = "Password: '"+password+"'"
  151.             else if typeof(result) == "computer" then
  152.                status = "Computer"
  153.             else
  154.                status ="New type found: " + typeof(result)
  155.                if new_types.indexOf(typeOf(result)) == null then new_types.push(typeOf(result))
  156.             end if
  157.             exploits.push(exploit + " (" + status + ")")
  158.          wait(0.5)
  159.          end for
  160.          print("\nMemory zone: " + zone + "\nAvailable vulnerabilities:\n" + exploits.join("\n"))
  161.          output = output + char(10) + exploits.join(char(10))
  162.          if new_types.len > 0 then
  163.             print("\nNew vulnerability types found:\n" + new_types.join("\n"))
  164.             output = output + char(10) + char(10) + "New Vulnerability Types:" + char(10) + new_types.join(char(10))
  165.          end if
  166.          if metaLib.lib_name.indexOf("sql") then sql_scanned = true
  167.       end for
  168.    end if
  169. end for
  170. outputFile.set_content(output)
  171. print ("\nNMAP Scan completed.\nResults saved to " + ipAddress + ".txt in " + targetsFolderName + " folder.")
  172.  
  173. // --- V2: Clear Our Tracks ---
  174. if cuExploit != null then
  175.     print("\nCleaning tracks")
  176.    
  177.     // Re-trigger the saved root vulnerability
  178.     cleanup_session = metax.net_use(ipAddress, cuPort)
  179.     if cleanup_session then
  180.         cleanup_lib = cleanup_session.dump_lib
  181.         root_shell = cleanup_lib.overflow(cuZone, cuExploit)
  182.        
  183.         if typeof(root_shell) == "shell" then
  184.             tgt_comp = root_shell.host_computer
  185.             log_file = tgt_comp.File("/var/system.log")
  186.            
  187.             //if log_file != null then
  188.                 // Show the log before deletion
  189.                 // print("\nTarget system log before deletion:")
  190.                 // print("--------------------------------------------------")
  191.                 // log_content = log_file.get_content
  192.                 // if log_content == "" or log_content == null then
  193.                 //     print("[Log is currently empty]")
  194.                 //else
  195.                 //    print(log_content)
  196.                 //end if
  197.                 //print("--------------------------------------------------")
  198.                
  199.                 //wait(3)
  200.                
  201.                 // Deletion / Fresh log
  202.                 log_file.delete
  203.                 tgt_comp.touch("/var", "system.log")
  204.                 print("\nProcessing deletion... Replacing with blank structure...")
  205.                 wait(1)
  206.                
  207.                 // Show the fresh log
  208.                 //fresh_log_file = tgt_comp.File("/var/system.log")
  209.                 //print("\nTarget system log after deletion:")
  210.                 //print("--------------------------------------------------")
  211.                 //if fresh_log_file != null then
  212.                     //new_content = fresh_log_file.get_content
  213.                     //if new_content == "" or new_content == null then
  214.                    //     print("<color=green>[SUCCESS] Log is completely blank. Tracks cleared!</color>")
  215.                    // else
  216.                    //     print(new_content)
  217.                     //end if
  218.                 //else
  219.                     //print("<color=red>[ERROR] Failed to verify replacement log file.</color>")
  220.                 //end if
  221.                 //print("--------------------------------------------------")
  222.                
  223.             //else
  224.             //    print("<color=red>Error: /var/system.log missing or inaccessible.</color>")
  225.             //end if
  226.            
  227.             // Let's talk aboug "start_terminal" and bash ...
  228.             root_shell.launch("/bin/bash")
  229.         end if
  230.     end if
  231. else
  232.     print("\n[WARNING] Scan complete, but no root exploit was found. Logs could not be cleared automatically.")
  233. end if
  234.  
Advertisement