Files

ls.src
  • draft // Custom LS Script
  • // Usage: ls [directory]
  • // Fixed issue with directory not finding anything else other than current_path
  • cyan = "<color=#0EC6FE>"
  • orange = "<color=#FF8D08>"
  • purple = "<color=#AC0BC3>"
  • gold = "<color=#E0E10C>"
  • green = "<color=#2CC018>"
  • cend = "</color>"
  • computer = get_shell.host_computer
  • listDirectory = function(directoryPath)
  • folder = computer.File(directoryPath)
  • if folder == null then
  • print("ls: No such file or directory")
  • return
  • end if
  • if not folder.has_permission("r") then
  • print("ls: permission denied")
  • return
  • end if
  • subFiles = folder.get_folders + folder.get_files
  • folderOutput = ""
  • fileOutput = ""
  • for subFile in subFiles
  • nameFile = subFile.name
  • permission = subFile.permissions
  • owner = subFile.owner
  • size = subFile.size
  • group = subFile.group
  • if nameFile.indexOf(".") == 0 then
  • continue // Skip hidden files and folders
  • end if
  • if subFile.is_folder then
  • folderLine = cyan + nameFile + cend + " " + orange + permission + cend + " " + "<color=red>" + owner + "</color>" + " " + "<color=red>" + group + "</color>" + " " + size
  • folderOutput = folderOutput + folderLine + "\n"
  • else
  • fileLine = cyan + nameFile + cend + " " + orange + permission + cend + " " + "<color=red>" + owner + "</color>" + " " + "<color=red>" + group + "</color>" + " " + size
  • fileOutput = fileOutput + fileLine + "\n"
  • end if
  • end for
  • if folderOutput != "" then
  • print("FOLDERS: PERMISSION OWNER GROUP SIZE")
  • print("====================================================")
  • print(folderOutput)
  • print("====================================================")
  • end if
  • if fileOutput != "" then
  • print("FILES: PERMISSION OWNER GROUP SIZE")
  • print("====================================================")
  • print(fileOutput)
  • print("====================================================")
  • end if
  • end function
  • params = params()
  • if params.len == 0 then
  • directoryPath = current_path
  • else
  • directoryPath = params[0]
  • end if
  • listDirectory(directoryPath)
  • content
ipgen2.0.src
  • ver = null
  • ips = get_shell.host_computer.File(current_path + "/ips")
  • if not ips then
  • get_shell.host_computer.touch(current_path, "ips")
  • ips = get_shell.host_computer.File(current_path + "/ips")
  • end if
  • // Define a function for the scanning process
  • scanLibrary = function(lib, ver)
  • ipCount = 0
  • st = time
  • while ipCount < 30 // Change 30 to your desired number of scans, it currently stops after finding 31 ips/libs
  • while 1
  • ip = getRandomIp
  • if not get_router(ip) or is_lan_ip(ip) then
  • continue
  • end if
  • break
  • end while
  • router = get_router(ip)
  • if lib == "router" then
  • v = router.kernel_version
  • ipCount = ipCount + 1 // Increment the IP address count correctly
  • if not ver then
  • print(ip+" "+lib+" "+v+" > "+current_path+"/ips")
  • print("Time since last found "+(time - st))
  • st=time
  • cont=ips.get_content.split("\n")
  • while cont.indexOf("") != null
  • cont.remove(cont.indexOf(""))
  • end while
  • cont.push(ip+" "+lib+"#"+v)
  • ips.set_content(cont.join(char(10)))
  • continue
  • end if
  • if v == ver then
  • print(ip+" "+lib+" "+v+" > "+current_path+"/ips")
  • print("Time since last found "+(time - st))
  • st=time
  • cont=ips.get_content.split("\n")
  • while cont.indexOf("") != null
  • cont.remove(cont.indexOf(""))
  • end while
  • cont.push(ip+" "+lib+"#"+v)
  • ips.set_content(cont.join(char(10)))
  • continue
  • end if
  • continue
  • end if
  • ports = router.used_ports
  • rports = []
  • for port in ports
  • serv = [port.port_number]
  • serv = serv + router.port_info(port).split(" ")
  • rports.push(serv)
  • end for
  • for port in rports
  • ipCount = ipCount + 1 // Increment the IP address count correctly
  • if not ver then
  • if port[1] == lib then // Check if the port's library matches the chosen library
  • print(ip+" "+port[1]+" "+port[-1]+" > "+current_path+"/ips")
  • print("Time since last found "+(time - st))
  • st=time
  • cont=ips.get_content.split("\n")
  • while cont.indexOf("") != null
  • cont.remove(cont.indexOf(""))
  • end while
  • cont.push(ip+" "+port[1]+"#"+port[-1])
  • ips.set_content(cont.join(char(10)))
  • end if
  • continue
  • end if
  • if port[1] == lib and port[-1] == ver then
  • print(ip+" "+port[1]+" "+port[-1]+" > "+current_path+"/ips")
  • print("Time since last found "+(time - st))
  • st=time
  • cont=ips.get_content.split("\n")
  • while cont.indexOf("") != null
  • cont.remove(cont.indexOf(""))
  • end while
  • cont.push(ip+" "+port[1]+"#"+port[-1])
  • ips.set_content(cont.join(char(10)))
  • end if
  • end for
  • print("<color=green>Scanned </color>" + ipCount + "<color=green> IP's for the library choosen.</color>")
  • end while
  • end function
  • menu = function()
  • print("[Libraries]")
  • print("1: ssh")
  • print("2: repository")
  • print("3: chat")
  • print("4: http")
  • print("5: ftp")
  • print("6: rshell")
  • print("7: router")
  • return user_input("Enter the number corresponding to the library: ")
  • end function
  • choice = menu() // Call the menu function and store the choice
  • lib = ""
  • if choice == "1" then
  • lib = "ssh"
  • else if choice == "2" then
  • lib = "repository"
  • else if choice == "3" then
  • lib = "chat"
  • else if choice == "4" then
  • lib = "http"
  • else if choice == "5" then
  • lib = "ftp"
  • else if choice == "6" then
  • lib = "rshell"
  • else if choice == "7" then
  • lib = "router"
  • else
  • exit("[lib] (version)\nInvalid choice. Exiting...")
  • end if
  • if lib == "repository" then
  • lib = "repo"
  • end if
  • if choice != "7" then
  • ver = user_input("Enter the library version (press Enter for no version): ")
  • end if
  • getRandomIp = function()
  • //1-223.0-255.0-255.0-255
  • octets = []
  • for i in range(0, 3)
  • if i == 0 then
  • octets.push(ceil(rnd * 223))
  • else
  • octets.push(floor(rnd * 256))
  • end if
  • end for
  • return octets.join(".")
  • end function
  • st = time
  • ipCount = 0
  • print("Starting scanning loop...") // Add a debug print
  • // Call the scanLibrary function
  • scanLibrary(lib, ver)
  • // After each scan, ask the user if they want to rescan, return to the menu, or exit
  • rescanMenu = user_input("Options:\n1: Rescan same library\n2: Return to menu\n3: Exit\nEnter your choice: ")
  • if rescanMenu == "2" then
  • // Return to the menu (you can implement the menu logic here)
  • else if rescanMenu == "3" then
  • // Exit the program
  • exit("Exiting...")
  • end if