def run(self, env, args): from honeypot.shell.shell import run if len(args) == 0: env.write("Busybox built-in shell (ash)\n") return 0 fname = args[0] contents = env.readFile(fname) if contents == None: env.write("sh: 0: Can't open " + fname) return 1 else: shell = Proc.get("exec") for line in contents.split("\n"): line = line.strip() line = line.split("#")[0] run(line, env) return 0
"""BusyBox v1.22.1 (Ubuntu 1:1.22.0-19ubuntu2) multi-call binary. Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE] [--header 'header: value'] [-Y|--proxy on/off] [-P DIR] [-U|--user-agent AGENT] URL... Retrieve files via HTTP or FTP -s Spider mode - only check file existence -c Continue retrieval of aborted transfer -q Quiet -P DIR Save to DIR (default .) -O FILE Save to FILE ('-' for stdout) -U STR Use STR for User-Agent header -Y Use proxy ('on' or 'off') """) return 1 else: echo = True for arg in args: if arg == "-O": echo = False for url in args: if url.startswith("http"): self.dl(env, url, echo=echo) return 0 Proc.register("wget", Wget())
from base import Proc class Shell(Proc): def run(self, env, args): from honeypot.shell.shell import run if len(args) == 0: env.write("Busybox built-in shell (ash)\n") return 0 fname = args[0] contents = env.readFile(fname) if contents == None: env.write("sh: 0: Can't open " + fname) return 1 else: shell = Proc.get("exec") for line in contents.split("\n"): line = line.strip() line = line.split("#")[0] run(line, env) return 0 Proc.register("sh", Shell())
"download", { "url": "tftp://" + host + ":" + str(port) + "/" + path, "path": fname, "info": None }) self.env.write("\nFinished. Saved to " + fname + ".\n") except: env.write("tftp: timeout\n") traceback.print_exc() def download(self, host, port, fname): output = DummyIO() client = TftpClient(host, port) self.env.write("Trying " + host + ":" + str(port) + " ... ") client.download(fname, output, timeout=5, packethook=self.pkt) return output.data def pkt(self, data): if not (self.connected): self.env.write("OK\n") self.connected = True #if self.chunks % 60 == 0: # self.env.write("\n") self.chunks += 1 #self.env.write(".") Proc.register("tftp", StaticTftp())