Exemple #1
0
def shell_client(sendto=db.get("shell_manager"), command_list=None):
    receiver = Receiver()
    cdb = yield db.load()

    logging.debug("UUID: {0}".format(db.get("uuid")))
    sender = Sender(sendto, receiver.get_addr(), db.get("uuid"))
   
    if command_list == None:
        input_ = lambda (host, port): (
            yield raw_input("{0}:{1} ~/ $: ".format(host, port))
        )
    elif type(command_list) == list:
        input_ = lambda (host, port): (
                yield command_list.pop() if len(command_list) > 0 else "quit" 
        )
    
    while True:
        command = input_(sendto).next()
        if not command:
            continue

        if command.startswith("@ping"):
            query = ("", "ping")
            resp, addr, rpc_no, uuid = yield rpc_call(query, sender, receiver)
            #print resp["data"]
            yield resp
            continue
 
        if command.startswith("upload"):
            try:
                filename = command.split()[1]
                yield sender.send_file(filename)
            except Exception, e:
                logging.error("No file specified, error: {0}".format(e))
            continue
                   
        if command.startswith("quit"):
            break
        
        ## RPC call!
        # yield sender.send_query(command, "shellcmd")
        # resp, addr = yield receiver.recv()
        
        query = (command, "shellcmd")
        resp, addr, rpc_no, uuid = yield rpc_call(query, sender, receiver) 

        #print resp["data"]
        yield resp["data"]
Exemple #2
0
    p.start()
    

    logging.info("Shell manager started on {0}:{1}".format(
        external_ip, port))
    
    db.add("shell_manager", (external_ip, port))
    db.add("uuid", get_hash(str(get_mac())))
    
    yield db.save()
    logging.info("DB saved to hdd: {0}".format(db.get_all()))
    
    ## event rpc listener loop
    while True:
        resp, addr, rpc_no, uuid = yield receiver.recv()
        sender = Sender(addr, receiver.get_addr(), uuid)
        yield sender.send_resp(resp, rpc_no)
    


def shell_client(sendto=db.get("shell_manager"), command_list=None):
    receiver = Receiver()
    cdb = yield db.load()

    logging.debug("UUID: {0}".format(db.get("uuid")))
    sender = Sender(sendto, receiver.get_addr(), db.get("uuid"))
   
    if command_list == None:
        input_ = lambda (host, port): (
            yield raw_input("{0}:{1} ~/ $: ".format(host, port))
        )