Archeagus

Mapscan v2.4 - Archeagus Grey Hack Series, Episode 6

Jun 14th, 2026 (edited)
23,524
0
Never
16
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 12.26 KB | Gaming | 0 0
  1. // Command mapscan
  2. script_version = 2.4
  3.  
  4. // Changes:
  5. // - Added support for separate library/version logging
  6. // - Removed system.log text logic and replaced with Log Viewer logic
  7. // - Added --interactive mode for password privilege level processing
  8. // - Added first pass of color formatting to terminal output
  9. // Version 2.0
  10. // - Added password variable for vulnerability testing
  11. // - Added logic to capture and display new objects returned by exploit testing
  12. // - Added logic to determine the privilege level of shell objects returned by exploit testing
  13. // - Added logic to show and delete system.log using highest level shell access (DEPRECATED)
  14.  
  15. if params.len < 1 or params.len > 2 or params[0] == "-h" or params[0] == "--help" then exit("<color=yellow>Usage: "+program_path.split("/")[-1]+" [ip_address] [optional --interactive]</color>")
  16.  
  17. // Get metax library
  18. metax = include_lib("/lib/metaxploit.so")
  19. if not metax then exit("<color=red>Error: Unable to find 'metaxploit.so'. Put missing library in the 'lib' folder.</color>")
  20.  
  21. // Function to strip all HTML tags from a given string
  22. stripHtml = function(inputString)
  23.     if not inputString then return ""
  24.     result = ""
  25.     inTag = false
  26.     // Loop through each character in the string
  27.     for i in range(0, inputString.len - 1)
  28.         char = inputString[i]
  29.        
  30.         if char == "<" then
  31.             inTag = true
  32.             continue
  33.         else if char == ">" then
  34.             inTag = false
  35.             continue
  36.         end if
  37.        
  38.         // Append character only if it's outside of a tag
  39.         if not inTag then
  40.             result = result + char
  41.         end if
  42.     end for    
  43.     return result
  44. end function
  45.  
  46. // Global (local) variables
  47. shell = get_shell
  48. computer = shell.host_computer
  49. password = "password"
  50.  
  51. // Optional interactive mode - Allows user to provide password privilege levels from terminal output
  52. interactive_mode = 0
  53. if params.len == 2 then
  54.     if params[1] == "--interactive" then interactive_mode = 1
  55. end if
  56.  
  57. if not is_valid_ip(params[0]) then exit("<color=white>MapScan:</color> invalid ip address")
  58. if not computer.is_network_active then exit("<color=white>MapScan:</color> No internet access.")
  59.  
  60. ipAddress = params[0]
  61. if ipAddress == "127.0.0.1" then ipAddress = computer.local_ip
  62. isLanIp = is_lan_ip( ipAddress )
  63.  
  64. if isLanIp then
  65.    router = get_router;
  66. else
  67.    router = get_router( ipAddress )
  68. end if
  69.  
  70. if router == null then exit("<color=white>MapScan:</color> ip address not found")
  71.  
  72. ports = null
  73.  
  74. if not isLanIp then
  75.    ports = router.used_ports
  76. else
  77.    ports = router.device_ports(ipAddress)
  78. end if
  79.  
  80. if ports == null then exit("<color=white>MapScan:</color> ip address not found")
  81. if typeof(ports) == "string" then exit(ports)
  82.  
  83. mapscanFolderPath = "/home/"+active_user
  84. targetsFolderName = "Targets"
  85. targetsFolder = mapscanFolderPath + "/" + targetsFolderName
  86. if computer.File(targetsFolder) == null then computer.create_folder(mapscanFolderPath, targetsFolderName)
  87. explibFolderName = "ExpLib"
  88. explibFolder = mapscanFolderPath + "/" + explibFolderName
  89. if computer.File(explibFolder) == null then computer.create_folder(mapscanFolderPath, explibFolderName)
  90.  
  91. tgtFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  92. if tgtFile == null then
  93.     computer.touch(targetsFolder, ipAddress + ".txt")
  94.     tgtFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  95. end if
  96.  
  97. output = ""
  98.      
  99. info = "PORT STATE SERVICE VERSION LAN"
  100. info_length = info.len  
  101. clear_screen
  102. line1 = "<color=white>[+] MapScan v"+script_version+" - Advanced Network Exploitation Engine</color>"
  103. line2 = "<color=white>[+] Target: </color>" + params[0]
  104. line3 = "<color=white>[+] Time: "+ current_date + "</color>"
  105. line4 = "<color=white>[+] PHASE 1: SERVICE ANALYSIS</color>"
  106. print(line1)
  107. output = output + line1 + char(10)
  108. print(line2)
  109. output = output + line2 + char(10)
  110. print(line3)
  111. output = output + line3 + char(10)
  112. print(line4)
  113. output = output + line4 + char(10)
  114. if(ports.len == 0) then exit("<color=white>Scan finished. No open ports.</color>")
  115.  
  116. for port in ports
  117.    service_info = router.port_info(port)
  118.    lan_ips = port.get_lan_ip
  119.    port_status = "open"
  120.  
  121.    if(port.is_closed and not isLanIp) then
  122.       port_status = "closed"
  123.    end if
  124.    new_entry = port.port_number + " " + port_status + " " + service_info + " " + lan_ips
  125.    if info_length < new_entry.len then info_length = new_entry.len
  126.    info = info + "\n" + new_entry
  127. end for
  128. dashes = "<color=white>"
  129. for c in range(1, info_length+8)
  130.     dashes = dashes + "-"
  131. end for
  132. dashes = dashes + "</color>"
  133. print(dashes)
  134. print(format_columns(info))
  135. print(dashes)
  136. output = stripHtml(output + char(10) + dashes + char(10) + format_columns(info) + char(10) + dashes + char(10))
  137. tgtFile.set_content(output)
  138.  
  139. // New variables for tracking new result objects and SQL library scans and capturing root shell access
  140. new_types = []
  141. sql_scanned = false
  142. cuZone = null
  143. cuExploit = null
  144. cuPort = null
  145. cuType = null
  146.  
  147. line5 = "<color=white>[+] PHASE 2: VULNERABILITY MAPPING & TESTING</color>"
  148. print(dashes + char(10) + line5)
  149. output = ""
  150. for port in ports
  151.    net_session = metax.net_use(ipAddress, port.port_number)
  152.    if not net_session then exit("<color=red>Error: Unable to connect to port "+port.port_number+"</color>")
  153.      
  154.    metaLib = net_session.dump_lib
  155.    expFilename = metaLib.lib_name + "-v" + metaLib.version + ".txt"
  156.    expFile = computer.File(explibFolder + "/" + expFilename)
  157.    if expFile == null then
  158.       computer.touch(explibFolder, expFilename)
  159.       expFile = computer.File(targetsFolder + "/" + ipAddress + ".txt")
  160.       print("\nScanning " + metaLib.lib_name + " v" + metaLib.version + " on port " + port.port_number)
  161.       expFile = computer.File(explibFolder + "/" + metaLib.lib_name + "-v" + metaLib.version + ".txt")
  162.       output = metaLib.lib_name + " v" + metaLib.version
  163.       scanResult = metax.scan(metaLib)
  164.  
  165.       for zone in scanResult
  166.          memory_scan = metax.scan_address(metaLib, zone)
  167.          print("\nFound memory zone: " + zone)
  168.          output = output + char(10) + char(10) + "Exploits for zone: " + zone
  169.          xpList = memory_scan.split("Unsafe check: ")[1:]
  170.          exploits = []
  171.          for xp in xpList
  172.             labelStart = xp.indexOf("<b>")
  173.             labelEnd = xp.indexOf("</b>")
  174.             exploit = xp[labelStart + 3: labelEnd]
  175.          print("\nTesting: " + exploit)
  176.          wait(1)
  177.             // Added password parameter for number type results
  178.             result = metaLib.overflow(zone, exploit, password)
  179.             if result == null then
  180.                status = "Undefined / Conditional"
  181.             else if typeof(result) == "shell" then
  182.                status = "Shell (?)"
  183.                
  184.                target_comp = result.host_computer
  185.                shell_user = "guest" // Default
  186.                   // Create a file in /var (accessible by all accounts)
  187.                   target_comp.touch("/var", "tmp.txt")
  188.                   temp_file = target_comp.File("/var/tmp.txt")
  189.                  
  190.                   if temp_file != null then
  191.                      shell_user = temp_file.owner // The owner of a newly touched file is the active shell user
  192.                      temp_file.delete // More deletions to cleanup later
  193.                   end if              
  194.  
  195.                if shell_user == "root" then
  196.                     status = "Shell (ROOT)"
  197.                  
  198.                   // Flag the root exploit details if we don't have a root yet
  199.                   if cuType == null or cuType != "Root" then
  200.                      cuZone = zone
  201.                      cuExploit = exploit
  202.                      cuPort = port.port_number
  203.                      cuType = "Root"
  204.                      print("Saved as final cleanup vector.")
  205.                   end if
  206.                else
  207.                  
  208.                   status = "Shell ("+shell_user+")"
  209.                   if cuType == null then
  210.                      cuZone = zone
  211.                      cuExploit = exploit
  212.                      cuPort = port.port_number
  213.                      cuType = shell_user
  214.                      print("Saved as possible cleanup vector.")
  215.                   else if cuType == "guest" and shell_user != "guest" then
  216.                      cuZone = zone
  217.                      cuExploit = exploit
  218.                      cuPort = port.port_number
  219.                      cuType = shell_user
  220.                      print("Saved as possible cleanup vector.")
  221.                   end if
  222.                end if
  223.             else if typeof(result) == "file" then
  224.                status = "File"
  225.             else if typeof(result) == "number" then
  226.                 status = ""
  227.                if interactive_mode == 1 then
  228.                     print("Privelege level?")
  229.                     paused = 5
  230.                     pwdLevel = ""
  231.                     while paused and pwdLevel != "r" and pwdLevel != "u" and pwdLevel != "g"
  232.                         pwdLevel = user_input("[R]oot, [U]ser or [G]uest: ")
  233.                         wait(1)
  234.                         paused = paused - 1
  235.                     end while
  236.                     if pwdLevel == "r" then
  237.                         status = "Privilege: Root" + char(10)      
  238.                     else if pwdLevel == "u" then
  239.                         username = user_input("Username? ")
  240.                         status = "User: " + username + char(10)
  241.                     else if pwdLevel == "g" then
  242.                         status = "Privilege: Guest" + char(10)
  243.                     end if
  244.                 end if
  245.                 status = status + "Password: '"+password+"'"
  246.             else if typeof(result) == "computer" then
  247.                status = "Computer"
  248.             else
  249.                status ="New type found: " + typeof(result)
  250.                if new_types.indexOf(typeOf(result)) == null then new_types.push(typeOf(result))
  251.             end if
  252.             exploits.push(exploit + " (" + status + ")")
  253.          wait(0.5)
  254.          end for
  255.          print("\nMemory zone: " + zone + "\nAvailable vulnerabilities:\n" + exploits.join("\n"))
  256.          output = output + char(10) + exploits.join(char(10))
  257.          if new_types.len > 0 then
  258.             print("\nNew vulnerability types found:\n" + new_types.join("\n"))
  259.             output = output + char(10) + char(10) + "New Vulnerability Types:" + char(10) + new_types.join(char(10))
  260.          end if
  261.          if metaLib.lib_name.indexOf("sql") then sql_scanned = true
  262.       end for
  263.       expFile.set_content(output)
  264.    else
  265.       print(expFilename + " found in Exploit library.")
  266.    end if
  267.    print(dashes)
  268. end for
  269. print ("\n<color=white>MapScan completed.</color>\n<color=white>Results saved to " + ipAddress + ".txt in " + targetsFolderName + " folder.</color>")
  270. line6 = "<color=white>[+] PHASE 3: SYSTEM LOG CLEANUP</color>"
  271. print(dashes + char(10) + line6)
  272. // --- V2: Clear Our Tracks ---
  273. if cuExploit != null then
  274.     print("\n<color=white>[+] Cleaning tracks ..................")
  275.    
  276.     // Re-trigger the saved root vulnerability
  277.     cleanup_session = metax.net_use(ipAddress, cuPort)
  278.     if cleanup_session then
  279.         cleanup_lib = cleanup_session.dump_lib
  280.         tgt_shell = cleanup_lib.overflow(cuZone, cuExploit)
  281.        
  282.         if typeof(tgt_shell) == "shell" then
  283.             tgt_comp = tgt_shell.host_computer
  284.             log_file = tgt_comp.File("/var/system.log")
  285.            
  286.             if log_file != null then
  287.                 // Show the log before deletion
  288.                 print("\n<color=white>[+] Sending target system log to Log Viewer.</color>")
  289.                 tgt_shell.launch("/usr/bin/LogViewer.exe", "/var/system.log")
  290.                 wait(6)
  291.                
  292.                 // Deletion / Fresh log
  293.                 log_file.delete
  294.                 tgt_comp.touch("/var", "system.log")
  295.                 print("\n<color=white>[+] Processing deletion... Replacing with blank structure...</color>")
  296.                 wait(2)
  297.                
  298.                 // Show the fresh log
  299.                 print("\n<color=white>[+] Sending refreshed system log to Log Viewer.</color>")
  300.                 tgt_shell.launch("/usr/bin/LogViewer.exe", "/var/system.log")
  301.                 wait(6)
  302.                
  303.             else
  304.                 print("<color=red>Error: /var/system.log missing or inaccessible.</color>")
  305.             end if
  306.             print(dashes)
  307.             // Let's talk aboug "start_terminal" and bash ...
  308.             tgt_shell.launch("/bin/bash")
  309.         end if
  310.     end if
  311. else
  312.     print(dashes)
  313.     print("\n<color=#FF0000>[WARNING] Scan complete, but no root exploit was found. Logs could not be cleared automatically.</color>")
  314. end if
  315.  
Advertisement