ipg.src
// Color constants for better output
COLOR_DEFAULT = "#009900"
COLOR_ERROR = "#FF0000"
COLOR_INFO = "#33CCFF"
COLOR_WARNING = "#FFA500"
COLOR_SUCCESS = "#00FF00"
// Utility function to print colored messages
printMsg = function(msg, color=COLOR_DEFAULT)
print("<color=" + color + ">" + msg + "</color>")
end function
// Generate a random, valid IP address
getRandomIp = function()
firstByteRange = range(1, 223) // 1-223 avoids most reserved/private ranges
firstByteRange.remove(10) // Private
firstByteRange.remove(172) // Private (172.16-31 handled below)
firstByteRange.remove(192) // Private (192.168 handled below)
restByteRange = range(0, 255)
while true
ip = [firstByteRange[floor(rnd() * firstByteRange.len)], floor(rnd() * 256), floor(rnd() * 256), floor(rnd() * 256)].join(".")
// Skip private/reserved ranges more precisely
if ip.indexOf("172.") then
secondByte = ip.split(".")[1].to_int
if secondByte >= 16 and secondByte <= 31 then continue
end if
if ip.indexOf("192.168.") then continue
if is_valid_ip(ip) and get_router(ip) and get_shell.ping(ip) then
return ip
end if
end while
end function
// Scan for libraries or router version
scanLibrary = function(lib, ver, ipCountLimit)
ipCount = 0
scannedIps = 0
matches = [] // List to store matches
// Single initial scan message
if ver then
scanMessage = "Scanning for " + lib + " v" + ver + "..."
else
scanMessage = "Scanning for " + lib + " (any version)..."
end if
printMsg(scanMessage, COLOR_SUCCESS)
while ipCount < ipCountLimit
wait(0.05)
ip = getRandomIp()
scannedIps = scannedIps + 1
if is_lan_ip(ip) then continue
router = get_router(ip)
if not router then continue
if lib == "router" then
kernelVer = router.kernel_version
if not ver or kernelVer == ver then
matches.push(ip + " router kernel " + kernelVer)
ipCount = ipCount + 1
end if
else
ports = router.used_ports
for port in ports
info = router.port_info(port).split(" ")
if info.len < 2 then continue
portLib = info[0]
portVer = info[-1]
if portLib == lib then
if not ver or portVer == ver then
matches.push(ip + ":" + port.port_number + " " + portLib + " " + portVer)
ipCount = ipCount + 1
end if
end if
end for
end if
end while
// Final summary
printMsg("Scanned " + scannedIps + " IPs, found " + ipCount + " matches", COLOR_WARNING)
// Display all matches after scanning
printMsg("\nFound Matches:", COLOR_INFO)
for match in matches
printMsg(match, COLOR_SUCCESS)
end for
rescan(lib, ver, ipCountLimit)
end function
// Display menu and get user choice
menu = function()
clear_screen
printMsg("[Available Libraries]", COLOR_INFO)
options = ["1: ssh", "2: repository", "3: chat", "4: http", "5: ftp", "6: rshell", "7: router"]
for opt in options
printMsg(opt, COLOR_DEFAULT)
end for
return user_input("Enter number (1-7): ")
end function
// Handle rescan options
rescan = function(lib, ver, ipCountLimit)
printMsg("\nScan complete!", COLOR_SUCCESS)
printMsg("Options:", COLOR_INFO)
printMsg("1: Rescan same library", COLOR_DEFAULT)
printMsg("2: Return to menu", COLOR_DEFAULT)
printMsg("3: Exit", COLOR_DEFAULT)
choice = user_input("Choice (1-3): ")
if choice == "1" then
scanLibrary(lib, ver, ipCountLimit)
else if choice == "2" then
main()
else if choice == "3" then
exit("Exiting...")
else
printMsg("Invalid choice, returning to menu", COLOR_ERROR)
main()
end if
end function
// Main execution
main = function()
choice = menu()
libMap = {
"1": "ssh",
"2": "repository",
"3": "chat",
"4": "http",
"5": "ftp",
"6": "rshell",
"7": "router", // the last , has to be here for it to be read correctly in greyscript
}
lib = libMap[choice]
if not lib then
exit("Invalid choice. Usage: [lib] (version)")
end if
ver = null
if choice != "6" then
verInput = user_input("Enter version (press Enter for any): ")
if verInput != "" then ver = verInput
end if
ipCountLimit = user_input("Number of IPs to find? > ").to_int
if ipCountLimit == 0 then
printMsg("Please enter a positive number", COLOR_ERROR)
main()
return
end if
scanLibrary(lib, ver, ipCountLimit)
end function
main()