Home
Port List
API Docs
Clock
IDE
SQL Sandbox
Default Code Library
Guild Listings
Tool Listings
Default Websites
Bug Tracker
aircrack
//command: aircrack cryptools = include_lib("/lib/crypto.so") if not cryptools then exit("Error: Missing crypto library") if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("aircrack_usage")) pathFile = get_abs_path(params[0]) file = get_shell.host_computer.File(pathFile) if file == null then exit("aircrack: file not found: "+pathFile) if not file.is_binary then exit("aircrack: Can't process file. Not valid filecap.") if not file.has_permission("r") then exit("aircrack: permission denied") key = cryptools.aircrack(file.path) if key then print("KEY FOUND! [" + key + "]" ) else print("aircrack: Unable to get the key" ) end if
aireplay
//command: aireplay cryptools = include_lib("/lib/crypto.so") if not cryptools then exit("Error: Missing crypto library") if params.len != 4 or params[0] == "-h" or params[0] == "--help" or params[0] != "-b" or params[2] != "-e" then exit(command_info("aireplay_usage")) bssid = params[1] essid = params[3] result = cryptools.aireplay(bssid, essid) if typeof(result) == "string" then exit(result)
airmon
//command: airmon cryptools = include_lib("/lib/crypto.so") if not cryptools then exit("Error: Missing crypto library") if params.len > 0 and (params.len != 2 or params[0] == "-h" or params[0] == "--help") then exit(command_info("airmon_usage")) computer = get_shell.host_computer formatOutput = "Interface Chipset Monitor_Mode\n" if params.len == 0 then exit(format_columns(formatOutput + computer.network_devices)) option = params[0] device = params[1] if option != "start" and option != "stop" then exit(command_info("airmon_usage")) output = cryptools.airmon(option, device) if not output then exit("airmon: " + device + " not found") if typeof(output) == "string" then exit(output) print(format_columns(formatOutput + computer.network_devices))
apt-get
//command: apt-get aptclient = include_lib("/lib/aptclient.so") if not aptclient then aptclient = include_lib(current_path + "/aptclient.so") end if if not aptclient then exit("Error: Missing aptclient.so library in the /lib path or the current folder") PendingUpdating = function(folderPath) pendingUpdate = [] targetFolder = get_shell.host_computer.File(folderPath) if targetFolder != null then files = targetFolder.get_files for itemFile in files output = aptclient.check_upgrade(itemFile.path) if output == true then pendingUpdate.push(itemFile.name) end if end for end if return pendingUpdate end function if params.len == 0 or params.len > 3 then exit(command_info("apt-get_usage")) action = params[0] if action == "update" then print("Updating package lists...") output = aptclient.update if output then print(output) else if action == "install" then print("Reading package lists...") if params.len < 2 then exit(command_info("apt-get_usage")) print("Downloading " + params[1]) customPath = "" if params.len == 3 then customPath = params[2] output = aptclient.install(params[1], customPath) if output == true then exit(params[1] + " installed") print(output) else if action == "search" then if params.len != 2 then exit(command_info("apt-get_usage")) print(aptclient.search(params[1])) else if action == "show" then if params.len != 2 then exit(command_info("apt-get_usage")) print(aptclient.show(params[1])) else if action == "addrepo" then if params.len < 2 or params.len > 3 then exit(command_info("apt-get_usage")) port = 1542 if params.len == 3 then port = params[2] output = aptclient.add_repo(params[1], port) if output then exit(output) print("Repository " + params[1] + " added succesfully.\nLaunch apt with the update option to apply the changes") else if action == "delrepo" then if params.len != 2 then exit(command_info("apt-get_usage")) output = aptclient.del_repo(params[1]) if output then exit(output) print("Repository " + params[1] + " removed succesfully.\nLaunch apt with the update option to apply the changes") else if action == "upgrade" then print("Reading package lists...") //upgrade all packages if params.len == 1 then pendingPackages = PendingUpdating("/lib") + PendingUpdating("/bin") if pendingPackages.len == 0 then exit("No updates needed") print("The following packages will be updated:") pkgs = "" for itemPackage in pendingPackages pkgs = pkgs + " " + itemPackage end for print(pkgs) option = user_input("\nDo you want to continue?(y/n): ") if option == "y" or option == "yes" then counter = 0 for itemPackage in pendingPackages output = aptclient.install(itemPackage) if output == true then counter = counter + 1 else if output then print(output) end if end for print(counter + " packages updated") else exit("aborted") end if //upgrade specific package else if params.len == 2 then output = aptclient.check_upgrade("/lib/" + params[1]) if typeof(output) == "string" then output = aptclient.check_upgrade("/bin/" + params[1]) end if if not output then exit("No updates needed") if output == true then print("The following package will be updated:\n" + params[1]) option = user_input("\nDo you want to continue?(y/n): ") if option == "y" or option == "yes" then output = aptclient.install(params[1]) if output == true then exit(params[1] + " installed.") print(output) else exit("aborted") end if else print(output) end if end if else print(command_info("apt-get_usage")) end if
bash
//command: bash Bash = function() deviceName = get_shell.host_computer.get_name promptCurrentFolder = deviceName + ":" + current_path + "$" if (active_user == "root") then promptCurrentFolder = deviceName + ":" + current_path + "#" else if (current_path.indexOf(home_dir) != null) then promptCurrentFolder = deviceName + ":~"+ current_path.replace(home_dir, "") +"$" end if output = user_input(active_user + "@" + promptCurrentFolder + " ", false, false, true) if(output.len == 0) then return listCmd = output.trim.split(" ") command = listCmd[0] shellArgs = "" if(listCmd.len > 1) then listCmd.remove(0) shellArgs = listCmd.join end if if(command == "exit") then exit if(command == "clear") then clear_screen else cmdPath = GetFinalPath(command) output = get_shell.launch(cmdPath, shellArgs) if output and output != 1 then print(output) end if end function GetFinalPath = function(command) paths = [current_path, "/bin", "/usr/bin"] for i in range(0, paths.len - 1) if i == 0 then absPath = get_abs_path(command) else absPath = paths[i] + "/" + command end if cmdFile = get_shell.host_computer.File(absPath) if (cmdFile != null) then return absPath end for return command end function while(true) Bash() end while
build
//command: build if params.len != 2 then print(command_info("build_usage")) else pathSource = get_abs_path(params[0]) programPath = get_abs_path(params[1]) shell = get_shell computer = shell.host_computer fileSource = computer.File(pathSource) folderDest = computer.File(programPath) if fileSource == null then exit("build: can't find "+ pathSource) if folderDest == null then exit("build: can't find " + programPath) output = shell.build(fileSource.path, folderDest.path) if output.len == 0 then print("build successful.") else print(output); end if end if
cat
//command: cat if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("cat_usage")) pathFile = get_abs_path(params[0]) file = get_shell.host_computer.File(pathFile) if file == null then exit("cat: file not found: "+pathFile) if file.is_binary then exit("cat: can't open " + file.path + ". Binary file") if not file.has_permission("r") then exit("cat: permission denied") print(file.get_content)
cd
//command: cd if params.len > 0 and (params[0] == "-h" or params[0] == "--help") then exit(command_info("cd_usage")) pathFile = home_dir if(params.len > 0) then pathFile = get_abs_path(params[0]) end if print(cd(pathFile))
chgrp
//command: chgrp if params.len < 2 or (params.len == 3 and params[0] != "-R") then exit(command_info("chgrp_usage")) group = params[0] pathFile = get_abs_path(params[1]) isRecursive = 0 if params.len == 3 then group = params[1] pathFile = params[2] isRecursive = 1 end if file = get_shell.host_computer.File(pathFile) if file == null then exit("chgrp: file not found: "+pathFile) output = file.set_group(group, isRecursive) if output then print(output)
chmod
//command: chmod if params.len < 2 or (params.len == 3 and params[0] != "-R") then exit(command_info("chmod_usage")) permissions = params[0] pathFile = get_abs_path(params[1]) isRecursive = 0 if params.len == 3 then permissions = params[1] pathFile = params[2] isRecursive = 1 end if file = get_shell.host_computer.File(pathFile) if file == null then exit("chmod: can't find " + pathFile) output = file.chmod(permissions, isRecursive) if output then print(output)
chown
//command: chown if params.len < 2 or (params.len == 3 and params[0] != "-R") then exit(command_info("chown_usage")) owner = params[0] pathFile = get_abs_path(params[1]) isRecursive = 0 if params.len == 3 then owner = params[1] pathFile = params[2] isRecursive = 1 end if file = get_shell.host_computer.File(pathFile) if file == null then exit("chown: file not found: "+pathFile) output = file.set_owner(owner, isRecursive) if output then print(output)
cp
//command: cp Basename = function(p) if p == "/" then return "/" if p.len > 1 and p[p.len-1:p.len] == "/" then p = p[0:p.len-1] end if parts = p.split("/") return parts[parts.len-1] end function if params.len != 2 or params[0] == "-h" or params[0] == "--help" then exit(command_info("cp_usage")) origFile = get_abs_path(params[0]) destFolder = get_abs_path(params[1]) computer = get_shell.host_computer file = computer.File(origFile) if not file then exit("cp: can't find " + origFile) newName = "" folder = computer.File(destFolder) if not folder then //Check if the user wants to put a new name. pathParent = parent_path(destFolder) if pathParent == destFolder then newName = destFolder destFolder = file.parent.path output = file.copy(destFolder, newName) if output and output != 1 then print(output) exit end if folder = computer.File(pathParent) newName = Basename(destFolder) if not folder then exit("cp: can't copy file. " + destFolder + " doesn't exist.") end if if folder then //Check if is trying to copy the file on itself. Ignored. if folder.parent != null and file.parent.path == folder.parent.path and file.name == folder.name then exit finalDest = folder.path if(newName.len == 0) then newName = file.name end if if not folder.is_folder then finalDest = file.parent.path newName = folder.name end if output = file.copy(finalDest, newName) if output and output != 1 then print(output) end if
decipher
//command: decipher cryptools = include_lib("/lib/crypto.so") if not cryptools then exit("Error: Missing crypto library") GetPassword = function(userPass) if userPass.len != 2 then exit("decipher: " + file.path + " wrong syntax") password = cryptools.decipher(userPass[1]) return password end function if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("decipher_usage")) origFile = get_abs_path(params[0]) file = get_shell.host_computer.File(origFile) if not file then exit("decipher: can't find " + origFile) if file.is_binary then exit("decipher: can't read " + origFile + ". Binary file") if not file.has_permission("r") then exit("decipher: can't read file. Permission denied") if file.get_content.len == 0 then exit("decipher: no users found") lines = file.get_content.split("\n") password = null if lines.len == 1 then userPass = lines[0].split(":") password = GetPassword(userPass) else print("Multiple users found.") numLine = 1 for line in lines if line.len > 0 then print(numLine + ": " + line) numLine = numLine + 1 end if end for option = "" inputOk = false while( not inputOk ) option = user_input("Select user: ").to_int if typeof(option) != "number" or (option < 1 or option > lines.len) then print("Invalid input. Type a valid number") else inputOk = true end if end while userPass = lines[option - 1].split(":") print("Selected user: " + userPass[0] + "\nDeciphering...") password = GetPassword(userPass) end if if not password then exit("Can't find password :(") print("password found! => " + password)
ftp
//Command: ftp CommandLine = function() output = user_input("ftp> ", false, false, true) if(output.len == 0) then return listCmd = output.trim.split(" ") command = listCmd[0] shellArgs = "" if(listCmd.len > 1) then listCmd.remove(0) shellArgs = listCmd.join end if if(command == "quit") then globals.connected = false return end if if(command == "clear") then clear_screen else output = Launch(command, shellArgs) if output and output != 1 then print(output) end if end function ParseParams = function(rawParams) tokens = rawParams.split(" ") params = [] for t in tokens if t != "" then params.push(t) end for return params end function Launch = function(command, shellArgs) params = ParseParams(shellArgs) if command == "ls" then LsCommand(params) else if command == "cd" then CdCommand(params) else if command == "get" then GetCommand(params) else if command == "put" then PutCommand(params) else if command == "mkdir" then MkdirCommand(params) else if command == "rm" then RmCommand(params) else if command == "pwd" then PwdCommand() else if command == "cp" then CpCommand(params) else if command == "mv" then MvCommand(params) else if command == "help" then ShowHelp else print("command not found in ftp.\nType
help
to access the available ftp commands.") end if end function CdCommand = function(params) if params.len > 0 and (params[0] == "-h" or params[0] == "--help") then print(command_info("cd_usage")) return end if pathFile = ftp_home_dir if(params.len > 0) then pathFile = get_abs_path(params[0], ftp_current_path) end if output = ftp_shell.host_computer.File(pathFile) if output == null then print "Error: Path not found: " + pathFile return end if if not output.is_folder then print "Error: Not a folder" return end if globals.ftp_current_path = pathFile print("Directory successfully changed.") end function PwdCommand = function() print(ftp_current_path) end function CpCommand = function(params) if params.len != 2 or params[0] == "-h" or params[0] == "--help" then print(command_info("cp_usage")) return end if origFile = get_abs_path(params[0], ftp_current_path) destFolder = get_abs_path(params[1], ftp_current_path) computer = ftp_shell.host_computer file = computer.File(origFile) if not file then print("cp: can't find " + origFile) return end if newName = "" folder = computer.File(destFolder) if not folder then //Check if the user wants to put a new name. pathParent = parent_path(destFolder) if pathParent == destFolder then newName = destFolder destFolder = file.parent.path output = file.copy(destFolder, newName) if output and output != 1 then print(output) return end if folder = computer.File(pathParent) newName = destFolder[destFolder.len - (destFolder.len - pathParent.len):] if newName[0] == "/" then newName = newName[1:] end if if not folder then print("cp: can't copy file. " + destFolder + " doesn't exist.") return end if end if if folder then //Check if is trying to copy the file on itself. Ignored. if file.parent.path != folder.parent.path or file.name != folder.name then finalDest = folder.path if(newName.len == 0) then newName = file.name end if if not folder.is_folder then finalDest = file.parent.path newName = folder.name end if output = file.copy(finalDest, newName) if output and output != 1 then print(output) end if end if end function MvCommand = function(params) if params.len != 2 then print(command_info("mv_usage")) else origFile = get_abs_path(params[0], ftp_current_path) destFolder = get_abs_path(params[1], ftp_current_path) computer = ftp_shell.host_computer file = computer.File(origFile) if file == null then print("mv: can't find " + origFile) else newName = "" folder = computer.File(destFolder) if folder == null then //Check if the user wants to put a new name. pathParent = parent_path(destFolder) if pathParent == destFolder then newName = destFolder destFolder = file.parent.path file.move(destFolder, newName) else folder = computer.File(pathParent) newName = destFolder[destFolder.len - (destFolder.len - pathParent.len):] if newName[0] == "/" then newName = newName[1:] end if if folder == null then print("mv: can't copy file. " + destFolder + " doesn't exist.") end if end if end if if folder != null then //Check if is trying to copy the file on itself. Ignored. if file.parent.path != folder.parent.path or file.name != folder.name then finalDest = folder.path if(newName.len == 0) then newName = file.name end if if not folder.is_folder then finalDest = file.parent.path newName = folder.name end if if file.parent.path == folder.parent.path and newName != file.name then file.rename(newName) else file.move(finalDest, newName) end if end if end if end if end if end function MkdirCommand = function(params) if params.len != 1 or params[0] == "-h" or params[0] == "--help" then print(command_info("mkdir_usage")) else computer = ftp_shell.host_computer pathFile = params[0] pathParent = parent_path(pathFile) existFile = computer.File(pathFile) if pathParent == pathFile then pathParent = ftp_current_path end if parent = computer.File(get_abs_path(pathParent, ftp_current_path)) if parent == null then print("mkdir: " + pathParent + " not found") else if existFile != null then print("mkdir: " + existFile.path + " file exists") else if not parent.has_permission("w") then print("mkdir: permission denied") else arrayPath = pathFile.split("/") output = computer.create_folder(parent.path, arrayPath[arrayPath.len - 1]) if output != null and output != 1 then print(output) end if end if end if end function RmCommand = function(params) if params.len < 1 or params.len > 2 or params[0] == "-h" or params[0] == "--help" then print(command_info("rm_usage")) return end if pathFile = params[0] isRecursive = 0 if params[0] == "-r" then if params.len == 1 then print(command_info("rm_usage")) return end if isRecursive = 1 pathFile = params[1] end if file = ftp_shell.host_computer.File(get_abs_path(pathFile, ftp_current_path)) if file == null then print("rm: file not found: "+pathFile) return end if if not file.has_permission("w") then print("rm: permission denied") return end if if file.is_folder == 1 and isRecursive == 0 and file.is_symlink == 0 then print("rm: " + file.name + " is a directory") else output = file.delete if output.len > 0 then print(output) end if end function ValidateLsInput = function(input) return (input == "-la" or input == "-l" or input == "-a") end function LsParamsValid = function(prms) if prms.len > 3 then return false for p in prms if p.indexOf("-") != null and not ValidateLsInput(p) then return false end for return true end function LsCommand = function(params) if not LsParamsValid(params) then print(command_info("ls_usage")) else computer = ftp_shell.host_computer folderPath = ftp_current_path if params and params[params.len - 1].indexOf("-") == null then folderPath = params[params.len - 1] end if folderPath = get_abs_path(folderPath, ftp_current_path) folder = computer.File(folderPath) if folder == null then print("ls: No such file or directory " + folderPath) else if not folder.has_permission("r") then print("ls: permission denied") else showHide = 0 if params and params[0].indexOf("a") != null then showHide = 1 end if showDetails = 0 if params and params[0].indexOf("l") != null then showDetails = 1 end if subFiles = folder.get_folders + folder.get_files output = "" for subFile in subFiles nameFile = subFile.name permission = subFile.permissions owner = subFile.owner size = subFile.size group = subFile.group if showHide or nameFile.indexOf(".") != 0 then if output.len > 0 then output = output + "\n" end if if showDetails then output = output + permission + " " + owner + " " + group + " " + size + " 00:00 " + nameFile if subFile.is_symlink then output = output + "-->" + subFile.path(true) else output = output + nameFile end if end if end for print(format_columns(output)) end if end if end if end function PutCommand = function(params) if params.len != 2 then print(command_info("put_usage")) return end if source = get_abs_path(params[0], current_path) dest = get_abs_path(params[1], ftp_current_path) output = ftp_shell.scp(source, dest, null, true) if output == null then print("put: there is no active remote connections") else if output != 1 then print(output) end if end function GetCommand = function(params) if params.len != 2 then print(command_info("get_usage")) return end if source = get_abs_path(params[0], ftp_current_path) dest = get_abs_path(params[1], current_path) output = ftp_shell.scp(source, dest, null, false) if output == null then print("put: there is no active remote connections") else if output != 1 then print(output) end if end function ShowHelp = function() help = "Available commands: ls
- List files and directories. cd
- Change current directory. pwd - Show current directory. get
- Download a file from the server. put
- Upload a file to the server. mkdir
- Create a new directory. rm
- Delete a file. cp
- Copy a file. mv
- Move a file. quit - Close the FTP connection. Type the command followed by any required arguments." print(help) end function //Main if params.len < 2 or params.len > 3 then exit(command_info("ftp_usage")) credentials = params[0].split("@") user = credentials[0] password = credentials[1] connected = true port = 21 if params.len == 3 then port = params[2].to_int if typeof(port) != "number" then exit("Invalid port: " + port) print("Connecting...") ftp_current_path = "" ftp_home_dir = "" ftp_shell = get_shell.connect_service(params[1], port, user, password, "ftp") if typeof(ftp_shell) == "string" then exit(ftp_shell) if ftp_shell then ftp_current_path = "/root" if user != "root" then ftp_current_path = "/home/" + user ftp_home_dir = ftp_current_path while connected CommandLine end while else print("connection failed") end if
groupadd
//command: groupadd if params.len != 2 or params[0] == "-h" or params[0] == "--help" then exit(command_info("groupadd_usage")) user = params[0] group = params[1] output = get_shell.host_computer.create_group(user, group) if output == true then exit("Group " + group + " added to user " + user) if output then exit(output) print("Error: the group could not be created.")
groupdel
//command: groupdel if params.len != 2 or params[0] == "-h" or params[0] == "--help" then exit(command_info("groupdel_usage")) user = params[0] group = params[1] output = get_shell.host_computer.delete_group(user, group) if output == true then exit("Group " + group + " deleted from user " + user) if output then exit(output) print("Error: the group could not be deleted.")
groups
//command: groups if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("groups_usage")) user = params[0] output = get_shell.host_computer.groups(user) if not output then exit(command_info("groups_usage")) print(output)
ifconfig
//command: ifconfig if params.len != 0 and (params.len != 4 or params[0] == "-h" or params[0] == "--help") then exit(command_info("ifconfig_usage")) computer = get_shell.host_computer if (params.len == 0) then if computer.is_network_active then router = get_router lip = computer.local_ip pip = router.public_ip gw = computer.network_gateway if computer.active_net_card == "WIFI" then if router.local_ip != gw then router = get_router(gw) end if output = "\nConnected to Wi-Fi:\nEssid: " + router.essid_name + "\nBssid: " + router.bssid_name else output = "\nEthernet connection:" end if else lip = "0.0.0.0" pip = "0.0.0.0" gw = "0.0.0.0" output = "\nNot connected to the network." end if print( output + "\n----------------\nPublic IP: " + pip + "\nLocal IP: " + lip + "\nGateway: " + gw + "\n") else if params[2] != "gateway" then exit(command_info("ifconfig_usage")) device = params[0] address = params[1] gateway = params[3] if not is_valid_ip(address) then exit("ifconfig: invalid ip address") if not is_valid_ip(gateway) then exit("ifconfig: invalid gateway") output = computer.connect_ethernet(device, address, gateway) if output.len > 0 then print(output) end if
iwconfig
//command: iwconfig if params.len != 4 or params[0] == "-h" or params[0] == "--help" then exit(command_info("iwconfig_usage")) computer = get_shell.host_computer devices = computer.network_devices if devices == null or devices.indexOf(params[0]) == null then exit("iwconfig: Network device not found") bssid = params[1] essid = params[2] password = params[3] status = computer.connect_wifi(params[0], bssid, essid, password) if typeof(status) == "string" then print(status)
iwlist
//command: iwlist if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("iwlist_usage")) computer = get_shell.host_computer devices = computer.network_devices if devices == null or devices.indexOf(params[0]) == null then exit("iwlist: Network device not found") if params[0].indexOf("eth") != null then exit("iwlist: ethernet cards not supported for this command") networks = computer.wifi_networks(params[0]) if networks == null then exit(command_info("iwlist_usage")) if(typeof(networks) == "string") then exit(networks) info = "BSSID PWR ESSID" for network in networks info = info + "\n" + network end for print(format_columns(info))
kill
//command: kill if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("kill_usage")) PID = params[0].to_int if typeof(PID) != "number" then exit("The PID must be a number\n" + command_info("kill_usage")) output = get_shell.host_computer.close_program(PID) if output == true then exit("Process " + PID + " closed"); if output then exit(output) print("Process " + PID + " not found")
ln
//command: ln if params.len > 0 and params[0] == "-s" then params = params[1:] end if if params.len != 2 or params[0] == "-h" or params[0] == "--help" then exit(command_info("ln_usage")) pathFile = get_abs_path(params[0]) pathLink = get_abs_path(params[1]) pathParent = parent_path(pathLink) if pathParent == pathLink then pathParent = current_path end if file = get_shell.host_computer.File(pathFile) if file == null then exit("ln: file not found: "+pathFile) if not file.has_permission("w") then exit("ln: permission denied") arrayPath = pathLink.split("/") newName = arrayPath[arrayPath.len-1] output = file.symlink(pathParent, newName) if output and output != 1 then print(output)
ls
//command: ls ValidateInput = function(input) return (input == "-la" or input == "-l" or input == "-a") end function ParamsValid = function(params) if params.len > 3 then return false for p in params if p.indexOf("-") != null and not ValidateInput(p) then return false end for return true end function if not ParamsValid(params) then print(command_info("ls_usage")) else computer = get_shell.host_computer folderPath = current_path if params and params[params.len - 1].indexOf("-") == null then folderPath = get_abs_path(params[params.len - 1]) end if folder = computer.File(folderPath) if folder == null then print("ls: No such file or directory") else if not folder.has_permission("r") then print("ls: permission denied") else showHide = 0 if params and params[0].indexOf("a") != null then showHide = 1 end if showDetails = 0 if params and params[0].indexOf("l") != null then showDetails = 1 end if subFiles = folder.get_folders + folder.get_files output = "" for subFile in subFiles nameFile = subFile.name permission = subFile.permissions owner = subFile.owner size = subFile.size group = subFile.group if showHide or nameFile.indexOf(".") != 0 then if output.len > 0 then output = output + "\n" end if if showDetails then output = output + permission + " " + owner + " " + group + " " + size + " 00:00 " + nameFile if subFile.is_symlink then output = output + "-->" + subFile.path(true) else output = output + nameFile end if end if end for print(format_columns(output)) end if end if end if
man
//command: man if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("man_usage")) command = params[0] info = command_info(command) if info == command.upper then exit("man: manual entry for "+command+" not found") print(info)
mkdir
//command: mkdir if params.len != 1 or params[0] == "-h" or params[0] == "--help" then print(command_info("mkdir_usage")) else computer = get_shell.host_computer pathFile = get_abs_path(params[0]) pathParent = parent_path(pathFile) existFile = computer.File(pathFile) if pathParent == pathFile then pathParent = current_path end if parent = computer.File(pathParent) if parent == null then print("mkdir: " + pathParent + " not found") else if existFile != null then print("mkdir: " + existFile.path + " file exists") else if not parent.has_permission("w") then print("mkdir: permission denied") else arrayPath = pathFile.split("/") output = computer.create_folder(parent.path, arrayPath[arrayPath.len - 1]) if output != null and output != 1 then print(output) end if end if end if
mv
//command: mv Basename = function(p) if p == "/" then return "/" if p.len > 1 and p[p.len-1:p.len] == "/" then p = p[0:p.len-1] end if parts = p.split("/") return parts[parts.len-1] end function if params.len != 2 then print(command_info("mv_usage")) else origFile = get_abs_path(params[0]) destFolder = get_abs_path(params[1]) computer = get_shell.host_computer file = computer.File(origFile) if file == null then print("mv: can't find " + origFile) else newName = "" folder = computer.File(destFolder) if folder == null then //Check if the user wants to put a new name. pathParent = parent_path(destFolder) if pathParent == destFolder then newName = destFolder destFolder = file.parent.path file.move(destFolder, newName) else folder = computer.File(pathParent) newName = Basename(destFolder) if folder == null then print("mv: can't copy file. " + destFolder + " doesn't exist.") end if end if end if if folder != null then //Check if is trying to copy the file on itself. Ignored. if folder.parent != null and file.parent.path == folder.parent.path and file.name == folder.name then exit finalDest = folder.path if(newName.len == 0) then newName = file.name end if if not folder.is_folder then finalDest = file.parent.path newName = folder.name end if fileParentPath = "none" folderParentPath = "none" if file.parent != null then fileParentPath = file.parent.path if folder.parent != null then folderParentPath = folder.parent.path if fileParentPath == folderParentPath and finalDest == folderParentPath and newName != file.name then output = file.rename(newName) if output and output != 1 then print(output) else output = file.move(finalDest, newName) if output and output != 1 then print(output) end if end if end if end if
nslookup
//command: nslookup if params.len != 1 or params[0] == "-h" or params[0] == "--help" then print(command_info("nslookup_usage")) else address = params[0] print("Address: "+nslookup(address)); end if
nmap
//command: nmap if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("nmap_usage")) if not is_valid_ip(params[0]) then exit("nmap: invalid ip address") if not get_shell.host_computer.is_network_active then exit("nmap: No internet access.") ipAddress = params[0] if ipAddress == "127.0.0.1" then ipAddress = get_shell.host_computer.local_ip isLanIp = is_lan_ip( ipAddress ) if isLanIp then router = get_router; else router = get_router( ipAddress ) end if if router == null then exit("nmap: ip address not found") ports = null if not isLanIp then ports = router.used_ports else ports = router.device_ports(ipAddress) end if if ports == null then exit("nmap: ip address not found") if typeof(ports) == "string" then exit(ports) info = "PORT STATE SERVICE VERSION LAN" print("\nStarting nmap v1.1 at " + current_date) print("Interesting ports on " + params[0] + "\n") if(ports.len == 0) then exit("Scan finished. No open ports.") for port in ports service_info = router.port_info(port) lan_ips = port.get_lan_ip port_status = "open" if(port.is_closed and not isLanIp) then port_status = "closed" end if info = info + "\n" + port.port_number + " " + port_status + " " + service_info + " " + lan_ips end for print(format_columns(info) + "\n")
passwd
//command: passwd if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("passwd_usage")) inputMsg = "Changing password for user " + params[0] +".\nNew password:" inputPass = user_input(inputMsg, true) output = get_shell.host_computer.change_password(params[0], inputPass) if output == true then exit("password modified OK") if output then exit(output) print("Error: password not modified")
ping
//Command: ping if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("ping_usage")) result = get_shell.ping(params[0]) if result then if typeof(result) == "string" then print(result) else print("Ping successful") end if else print("ip unreachable"); end if
ps
//command: ps if params.len > 0 then exit(command_info("ps_usage")) output = get_shell.host_computer.show_procs print(format_columns(output))
pwd
//command: pwd print(current_path)
reboot
//command: reboot if params.len > 0 and (params[0] == "-h" or params[0] == "-help") then exit(command_info("reboot_usage")) isSafeMode = params.len > 0 and params[0] == "-sm" output = get_shell.host_computer.reboot(isSafeMode) if output and output != 1 then print(output) else print("Closing programs...\nRestarting...") end if
rm
//command: rm if params.len < 1 or params.len > 2 or params[0] == "-h" or params[0] == "--help" then exit(command_info("rm_usage")) pathFile = get_abs_path(params[0]) isRecursive = 0 if params[0] == "-r" then if params.len == 1 then exit(command_info("rm_usage")) isRecursive = 1 pathFile = params[1] end if file = get_shell.host_computer.File(pathFile) if file == null then exit("rm: file not found: "+pathFile) if not file.has_permission("w") then exit("rm: permission denied") if file.is_folder == 1 and isRecursive == 0 and file.is_symlink == 0 then print("rm: " + file.name + " is a directory") else output = file.delete if output.len > 0 then print(output) end if
rmdir
//command: rmdir if params.len < 1 or params.len > 2 or params[0] == "help" then exit(command_info("rmdir_usage")) path = get_abs_path(params[0]) f = get_shell.host_computer.File(path) if typeof(f) != "file" then exit("rmdir: failed to remove '" + path + "': no such file or directory") if f.is_folder == 0 then exit("Error: " + f.name + " is not a directory.") if f.get_files.len >= 1 or f.get_folders.len >= 1 then exit("rmdir: failed to remove '" + path + "': directory not empty") fd = f.delete if fd.trim.len == 0 then exit exit("rmdir: failed to remove '" + path + "': " + fd.trim)
scp
//command: scp if params.len != 3 or (params[0] != "-u" and params[0] != "-d") then exit(command_info("scp_usage")) origPath = get_abs_path(params[1]) destPath = get_abs_path(params[2]) output = get_shell.scp(origPath, destPath, null, params[0] == "-u") if output == null then exit("scp: there is no active remote connections") if output != 1 then print(output)
ssh
//Command: ssh if params.len < 2 or params.len > 3 then exit(command_info("ssh_usage")) credentials = params[0].split("@") user = credentials[0] password = credentials[1] port = 22 // params is a list of strings, so you have to convert it to integer, which is what connect_service accepts. if params.len == 3 then port = params[2].to_int if typeof(port) != "number" then exit("Invalid port: " + port) print("Connecting...") shell = get_shell.connect_service(params[1], port, user, password, "ssh") if typeof(shell) == "string" then exit(shell) if shell then shell.start_terminal else print("connection failed") end if
sudo
//command: sudo if not params or params[0] == "-h" or params[0] == "--help" then exit(command_info("sudo_usage")) if params[0] == "-u" and params.len != 2 then exit(command_info("sudo_usage")) inputPass = user_input("Password: ", true) if params[0] == "-u" then shell = get_shell(params[1], inputPass) if not shell then exit("sudo: incorrect username or password") else shell = get_shell("root", inputPass) if not shell then exit("sudo: incorrect password") end if if params[0] == "-s" or params[0] == "-u" then shell.start_terminal else computer = shell.host_computer args = params[1:].join(" ") if not params[0].indexOf("/") then globalPath = [current_path, "/bin", "/usr/bin"] for path in globalPath program = computer.File(path + "/" + params[0]) if program != null then shell.launch(program.path, args) exit end if end for else program = computer.File(params[0]) if not program then exit(params[0] + " not found.") shell.launch(program.path, args) end if end if
touch
//command: touch if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("touch_usage")) pathFile = get_abs_path(params[0]) pathParent = parent_path(pathFile) computer = get_shell.host_computer if pathParent == pathFile then pathParent = current_path end if parent = computer.File(pathParent) if not parent then exit("touch: " + pathParent + " not found") if not parent.has_permission("w") then exit("touch: permission denied") arrayPath = pathFile.split("/") output = computer.touch(parent.path, arrayPath[arrayPath.len - 1]) if output and output != 1 then print(output)
useradd
//command: useradd if params.len != 1 or params[0] == "-h" or params[0] == "--help" then exit(command_info("useradd_usage")) inputMsg = "Setting password for user " + params[0] +".\nNew password: " inputPass = user_input(inputMsg, true) output = get_shell.host_computer.create_user(params[0], inputPass) if output == true then exit("User created OK") if output then exit(output) print("Error: the user could not be created.")
userdel
//command: userdel if not params.len or (params.len == 1 and params[0] == "-r") or params[0] == "-h" or params[0] == "--help" then exit(command_info("userdel_usage")) delete = 0 if params[0] == "-r" then delete = 1 params.pull end if output = get_shell.host_computer.delete_user(params[0], delete) if output == true then exit("user " + params[0] + " deleted.") if output then exit(output) print("Error: user not deleted.")
wallet
//command: wallet ShowOptions = function(options) print("\n[Options]") i = 1 for option in options print("["+ i +"] - " + option) i = i + 1 end for inputOk = false option = 0 while(true) option = user_input("\n[Select option]: ").to_int if typeof(option) == "number" and option <= i and option >= 1 then return option else print("Invalid option. Please input a valid number") end if end while end function MainMenu = function() print("########################\n### WALLET MAIN MENU ###\n########################", true) wait(0.1) return ShowOptions(["Login", "Create wallet", "Exit"]) end function LoginWallet = function() print("####################\n### WALLET LOGIN ###\n####################\n", true) wait(0.1) wallet = null while(typeof(wallet) != "wallet") user = user_input("Wallet user: ") pass = user_input("Wallet password: ", true) wallet = blockchain.login_wallet(user, pass) if typeof(wallet) == "string" then print(wallet) back = user_input("Back to main menu?(y/n): ") if(back == "y" or back == "yes") then return "back" end if end if end while return wallet end function CreateWallet = function() print("#######################\n### WALLET CREATION ###\n#######################\n", true) wait(0.1) user = user_input("Insert username: ") pass = user_input("Insert password: ", true) wallet = blockchain.create_wallet(user, pass) if typeof(wallet) == "wallet" then user_input("Wallet created succesfully!\nPress any key to continue", false, true) ShowWallet(wallet) else print(wallet) user_input("Press any key to continue", false, true) StartProgram() end if end function ShowWallet = function(wallet) print("#####################\n### WALLET DETAIL ###\n#####################\n\nBalance:", true) wait(0.1) listCoins = wallet.list_coins for itemCoin in listCoins coins = wallet.get_balance(itemCoin) print("[ " + itemCoin + " ==> " + coins + " coins ]") end for if listCoins.len == 0 then print("Empty wallet") end if option = ShowOptions(["Buy coins", "Sell coins", "Pending trade", "Cancel trade", "Show global offers", "Show PIN", "Exit"]) if option == 1 then print("Purchasing coins...") coinName = user_input("Insert coin name: ") amount = user_input("Insert the amount of coins to buy: ").val unitPrice = user_input("Insert the proposed price per unit: ").val subwalletUser = user_input("Insert your subwallet user: ") output = wallet.buy_coin(coinName, amount, unitPrice, subwalletUser) if output == true then user_input("Purchase completed!\nPress any key to continue", false, true) else print(output) user_input("Press any key to continue", false, true) end if else if option == 2 then print("Selling coins...") coinName = user_input("Insert coin name: ") amount = user_input("Insert the amount of coins to sell: ").val unitPrice = user_input("Insert the proposed price per unit: ").val subwalletUser = user_input("Insert your subwallet user: ") output = wallet.sell_coin(coinName, amount, unitPrice, subwalletUser) if output == true then user_input("Sale completed!\nPress any key to continue", false, true) else print(output) user_input("Press any key to continue", false, true) end if else if option == 3 then print("Listing pending trade...") coinName = user_input("Insert coin name: ") info = wallet.get_pending_trade(coinName) if typeof(info) == "list" then print(info[0] + " Offer: " + info[1] + " | Unit price: $" + info[2]) else print(info) end if user_input("Press any key to continue", false, true) else if option == 4 then print("Canceling pending trade...") coinName = user_input("Insert coin name: ") output = wallet.cancel_pending_trade(coinName) if(output.len == 0) then print("Trade cancelled") else print(output) end if else if option == 5 then print("Show global offers...") coinName = user_input("Insert coin name: ") info = wallet.get_global_offers(coinName) if typeof(info) == "map" then for item in info.indexes print("[" + item + "] " + info[item][0] + " Offer: " + info[item][1] + " | Unit price: $" + info[item][2]) end for else print(info) end if user_input("Press any key to continue", false, true) else if option == 6 then print("PIN: " + wallet.get_pin) print("This is the PIN used to register in a coin-store. It renews automatically in a few minutes.") user_input("Press any key to continue", false, true) else if option == 7 then exit end if ShowWallet(wallet) end function StartProgram = function() option = MainMenu() if option == 1 then wallet = LoginWallet() if typeof(wallet) != "wallet" then StartProgram() return end if ShowWallet(wallet) else if option == 2 then CreateWallet() else if option == 3 then exit end function blockchain = include_lib("/lib/blockchain.so") if not blockchain then blockchain = include_lib(current_path + "/blockchain.so") end if if not blockchain then get_shell.launch("/bin/apt-get", "update") get_shell.launch("/bin/apt-get", "install blockchain.so") blockchain = include_lib("/lib/blockchain.so") end if if not blockchain then exit("Error: Missing blockchain.so library in the /lib path or the current folder") StartProgram()
whoami
//Command: whoami print(active_user)
whois
//command: whois if params.len != 1 or params[0] == "-h" or params[0] == "--help" then print(command_info("whois_usage")) else address = params[0] print(whois(address)) end if
Back to Top