Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if params.len != 2 then exit("<b>Example: <i>spyshell</i> [IP] [LAN IP]</b>")
- ip = params[0]
- lanIP = params[1]
- //BaseClass//
- ftpShell = { }
- ftpShell.ctor = function(userPC, target, workdir = "/")
- self.userPC = userPC
- self.target = target
- self.workdir = workdir
- self.localWorkdir = parent_path(program_path)
- self.localDownloads = self.localWorkdir + "/Downloads"
- self.unloadStore = self.localDownloads + "/" + ip
- end function
- //Functions//
- ftpShell.help = function()
- print("<b>[Help]</b>\n|(*) - maybe not work, req root or write access\n|exit\n|ps\n|(*)useradd\n|(*)userdel\n|(*)passwd\n|cat\n|(*)chmod\n|decipher/dec\n|download/get (use cat)\n|pwd\n|ls\n|cd\n|(*)rm\n|(*)mkdir\n|(*)touch\n|(*)mv\n|(*)cp")
- end function
- ftpShell.com_ps = function()
- print(format_columns(self.target.show_procs))
- end function
- ftpShell.com_pwd = function()
- print(self.workdir)
- end function
- ftpShell.absPath = function(path)
- if path.len > 1 and path[path.len - 1] == "/" then path = path[0:path.len - 1]
- if path[0] == "/" then return path
- if path == ".." then return parent_path(self.workdir)
- if self.workdir == "/" then return self.workdir + path
- return self.workdir + "/" + path
- end function
- ftpShell.getWorkDir = function()
- return self.target.File(self.workdir)
- end function
- ftpShell.findObject = function(path, out = true)
- obj = self.target.File(path)
- if obj == null then
- if out then print("Not found object - '" + path + "'")
- return false
- end if
- return obj
- end function
- ftpShell.findFolder = function(path, out = true)
- dir = self.findObject(path, false)
- if not dir or not dir.is_folder then
- if out then print("Not found folder - '" + path + "'")
- return false
- end if
- return dir
- end function
- ftpShell.findFile = function(path, out = true)
- file = self.findObject(path, false)
- if not file or file.is_folder then
- if out then print("Not found file - '" + path + "'")
- return false
- end if
- return file
- end function
- ftpShell.existObject = function(path)
- obj = self.target.File(path)
- if obj == null then return false
- return true
- end function
- ftpShell.existFolder = function(path)
- folder = self.target.File(path)
- if folder == null or not folder.is_folder then return false
- return true
- end function
- ftpShell.existFile = function(path)
- file = self.target.File(path)
- if file == null or file.is_folder then return false
- return true
- end function
- ftpShell.com_ls = function(args)
- dirPath = self.workdir
- if args != null and args.len > 0 then dirPath = self.absPath(args[0])
- dir = self.findFolder(dirPath)
- if not dir then return
- out = ""
- subObjects = dir.get_folders + dir.get_files
- for object in subObjects
- out = out + object.permissions + " " + object.owner + " " + object.size + " " + object.name + "\n"
- end for
- print(format_columns(out))
- end function
- ftpShell.com_cd = function(args)
- dirPath = "/root"
- if args != null and args.len > 0 then dirPath = self.absPath(args[0])
- dir = self.findFolder(dirPath)
- if not dir then return
- self.workdir = dirPath
- end function
- ftpShell.com_rm = function(args)
- if args == null or args.len == 0 then
- print(command_info("rm_usage"))
- return
- end if
- count = 0
- for arg in args
- if arg == "*" then
- dir = self.getWorkDir()
- objs = dir.get_folders + dir.get_files
- count = count + objs.len
- for obj in objs
- print("Deleted - " + obj.path)
- obj.delete()
- end for
- else
- obj = self.findObject(self.absPath(arg))
- if not obj then continue
- count = count + 1
- print("Deleted - " + obj.path)
- obj.delete()
- end if
- end for
- print("<i>(i)Deleted " + count + " objects</i>")
- end function
- ftpShell.com_mkdir = function(args)
- if args == null or args.len == 0 then
- print(command_info("mkdir_usage"))
- return
- end if
- count = 0
- for arg in args
- arg = self.absPath(arg)
- argSplited = arg.split("/")
- name = argSplited[argSplited.len - 1]
- dirPath = parent_path(arg)
- dir = self.findFolder(dirPath)
- if not dir then continue
- self.target.create_folder(dir.path, name)
- count = count + 1
- print("Created folder - " + arg)
- end for
- print("<i>(i)Created " + count + " folders</i>")
- end function
- ftpShell.com_touch = function(args)
- if args == null or args.len == 0 then
- print(command_info("touch_usage"))
- return
- end if
- count = 0
- for arg in args
- arg = self.absPath(arg)
- argSplited = arg.split("/")
- name = argSplited[argSplited.len - 1]
- dirPath = parent_path(arg)
- dir = self.findFolder(dirPath)
- if not dir then continue
- self.target.touch(dir.path, name)
- count = count + 1
- print("Created file - " + arg)
- end for
- print("<i>(i)Created " + count + " files</i>")
- end function
- ftpShell.com_mv = function(args)
- if args == null or args.len != 2 then
- print(command_info("mv_usage"))
- return
- end if
- origFile = self.absPath(args[0])
- dirPath = self.absPath(args[1])
- file = self.findFile(origFile)
- if not file then return
- newName = file.name
- if not self.existFolder(dirPath) then
- newName = dirPath.split("/").pop
- dirPath = parent_path(dirPath)
- end if
- file.move(dirPath, newName)
- print("<i>(i)File - '" + origFile + "' moved to '" + dirPath + "/" + newName + "'</i>" )
- end function
- ftpShell.com_cp = function(args)
- if args == null or args.len != 2 then
- print(command_info("cp_usage"))
- return
- end if
- origFile = self.absPath(args[0])
- dirPath = self.absPath(args[1])
- file = self.findFile(origFile)
- if not file then return
- newName = file.name
- if not self.existFolder(dirPath) then
- newName = dirPath.split("/").pop
- dirPath = parent_path(dirPath)
- end if
- file.copy(dirPath, newName)
- print("<i>(i)File - '" + origFile + "' copyed to '" + dirPath + "/" + newName + "'</i>" )
- end function
- ftpShell.com_useradd = function(args)
- if args == null or args.len != 2 then
- print(command_info("useradd_usage"))
- return
- end if
- user = args[0]
- pass = args[1]
- if self.target.create_user(user, pass) then
- print("<i>(i)User '" + user + "' created</i>")
- return
- end if
- print("<i>Could not create user :/</i>")
- end function
- ftpShell.com_userdel = function(args)
- if args == null or args.len < 1 then
- print(command_info("userdel_usage"))
- return
- end if
- rec = false
- if args.len == 1 then
- user = args[0]
- else
- if args[0] == "-r" then rec = true
- user = args[1]
- end if
- if self.target.create_user(user, rec) then
- print("<i>(i)User '" + user + "' deleted</i>")
- return
- end if
- print("<i>Could not delete user :/</i>")
- end function
- ftpShell.com_passwd = function(args)
- if args == null or args.len != 2 then
- print("<b>Example:</b> passwd [user] [new password]")
- return
- end if
- user = args[0]
- pass = args[1]
- if self.target.create_user(user, pass) then
- print("<i>(i)Password for '" + user + "' changed</i>")
- return
- end if
- print("<i>Could not change password :/</i>")
- end function
- ftpShell.com_cat = function(args)
- if args == null or args.len == 0 then
- print(command_info("cat_usage"))
- return
- end if
- count = 0
- for arg in args
- arg = self.absPath(arg)
- file = self.findFile(arg)
- if not file then continue
- content = file.content
- if content == null then
- print("Cannot read file - '" + arg + "'")
- else
- print("<b>[Content - </b><i>'" + arg + "'</i><b>]</b>")
- print(content)
- count = count + 1
- end if
- end for
- print("<i>(i)Read " + count + " files</i>")
- end function
- ftpShell.com_chmod = function(args)
- if args == null or args.len < 2 then
- print(command_info("chmod_usage"))
- return
- end if
- rec = false
- if args[0] == "-R" or args[0] == "-r" then
- rec = true
- perm = args[1]
- args.remove(0)
- else
- perm = args[0]
- end if
- args.remove(0)
- count = 0
- for arg in args
- arg = self.absPath(arg)
- obj = self.findObject(arg)
- if not obj then continue
- obj.chmod(perm, rec)
- print("Object - '" + arg + "' chmoded")
- count = count + 1
- end for
- print("<i>(i)Chmoded '" + count + "' objects</i>")
- end function
- ftpShell.rmLocalFile = function(path)
- file = self.userPC.File(path)
- if file == null then return
- file.delete()
- end function
- ftpShell.unloadFile = function(file, prev = null, out = true)
- if file.content == null then return false
- if prev == null then
- path = self.unloadStore
- else
- path = prev
- end if
- self.userPC.touch(path, file.name)
- localFile = self.userPC.File(path + "/" + file.name)
- localFile.set_content(file.content)
- if out then print("<i>File '" + file.path + "' saved to '" + localFile.path + "'</i>")
- return localFile.path
- end function
- ftpShell.unloadFolder = function(folder, prev = null, out = true)
- if prev == null then
- path = self.unloadStore
- else
- path = prev
- end if
- self.userPC.create_folder(path, folder.name)
- createdPath = path + "/" + folder.name
- if out then print("<i>Created folder - " + createdPath + "</i>")
- folders = folder.get_folders
- files = folder.get_files
- for f in folders
- self.unloadFolder(f, createdPath)
- end for
- for file in folder.get_files
- self.unloadFile(file, createdPath)
- end for
- return true
- end function
- ftpShell.unloadObject = function(obj)
- if obj.is_folder then
- return self.unloadFolder(obj)
- else
- return self.unloadFile(obj)
- end if
- end function
- ftpShell.checkLocalStore = function()
- if self.userPC.File(self.localWorkdir) == null then
- self.userPC.create_folder(parent_path(self.localWorkdir), self.localWorkdir.split("/").pop)
- end if
- if self.userPC.File(self.localDownloads) == null then
- self.userPC.create_folder(parent_path(self.localDownloads), self.localDownloads.split("/").pop)
- end if
- if self.userPC.File(self.unloadStore) == null then
- self.userPC.create_folder(parent_path(self.unloadStore), self.unloadStore.split("/").pop)
- end if
- end function
- ftpShell.com_download = function(args)
- if args == null or args.len == 0 then
- print("<b>Example:</b> download/get [path1] [path2] ...")
- return
- end if
- self.checkLocalStore()
- countFolders = 0
- countFiles = 0
- for arg in args
- arg = self.absPath(arg)
- obj = self.findObject(arg)
- if not obj then return
- if obj.is_folder then
- self.unloadFolder(obj)
- countFolders = countFolders + 1
- else
- self.unloadFile(obj)
- countFiles = countFiles + 1
- end if
- end for
- print("<i>(i)Downloaded " + countFolders + " folders</i>")
- print("<i>(i)Downloaded " + countFiles + " files</i>")
- end function
- ftpShell.com_decipher = function(args)
- if args == null or args.len == 0 then
- print("<b>Example:</b> [path1] [path2] ...")
- return
- end if
- crypto = include_lib("crypto")
- if not crypto then exit("<b><i>Crypto.so</i> not found!</b>")
- out = "FILE DECRYPTED\n"
- for arg in args
- arg = self.absPath(arg)
- file = self.findFile(arg)
- if not file then continue
- tempPath = self.unloadFile(file, null, false)
- if not tempPath then continue
- out = out + arg + " " + crypto.decipher(tempPath) + "\n"
- self.rmLocalFile(tempPath)
- end for
- print(format_columns(out))
- end function
- ftpShell.runShell = function()
- print("<i>(i)Hided ftp-shell opened</i>")
- isExit = false
- input = ""
- cmd = ""
- args = []
- while not isExit
- input = user_input(ip + ":" + self.workdir + "> ")
- args = input.split(" ")
- if args.len < 1 then continue
- cmd = args[0]
- args.remove(0)
- if cmd == "exit" then
- isExit = true
- else if cmd == "help" then
- self.help()
- else if cmd == "ps" then
- self.com_ps()
- else if cmd == "useradd" then
- self.com_useradd(args)
- else if cmd == "userdel" then
- self.com_userdel(args)
- else if cmd == "passwd" then
- self.com_passwd(args)
- else if cmd == "cat" then
- self.com_cat(args)
- else if cmd == "chmod" then
- self.com_chmod(args)
- else if cmd == "download" or cmd == "get" then
- self.com_download(args)
- else if cmd == "decipher" or cmd == "dec" then
- self.com_decipher(args)
- else if cmd == "pwd" then
- self.com_pwd()
- else if cmd == "ls" then
- self.com_ls(args)
- else if cmd == "cd" then
- self.com_cd(args)
- else if cmd == "rm" then
- self.com_rm(args)
- else if cmd == "mkdir" then
- self.com_mkdir(args)
- else if cmd == "touch" then
- self.com_touch(args)
- else if cmd == "mv" then
- self.com_mv(args)
- else if cmd == "cp" then
- self.com_cp(args)
- else
- print("Command not found")
- end if
- end while
- print("<i>(i)Hided ftp-shell closed</i>")
- end function
- userShell = get_shell()
- userPC = userShell.host_computer()
- print("<b><i>SpyShell</i></b>")
- router = get_router(ip)
- if not router then exit("<b>Host not found :/</b>")
- target = router.get_computer(lanIP)
- if not target then exit("<b>LAN Host not found :(</b>")
- print("<i>Connected - <b>OK</b></i>")
- print()
- ftpShell.ctor(userPC, target)
- ftpShell.runShell()
- print()
- print("<b><i>SpyShell</i></b>")
- print("<b><i>By LINKI :)</i></b>")
Add Comment
Please, Sign In to add comment