Exemplo n.º 1
0
 def socket_remote_access_connection_handler(self, conn, s_key):
     import logger
     import cryptographer as cr
     import main
     loggerloc = "File: main.py | Class: Handler | Function: socket_remote_access_connection_handler | "
     logger.write("i", loggerloc+"Started new connection handler!")
     logger.write("i", loggerloc+"Waiting for client to authenticate!")
     authenticated = False
     text = "[send];[Please authenticate with username:password !];[info]"
     text = cr.encrypt(s_key, text)
     conn.send(text)
     while authenticated is False:
         edata = conn.recv(15360)
         if edata is "123":
             authenticated = True
     while True:
         edata = conn.recv(15360)
         logger.write("i", loggerloc+"Received data! Decrypting it! Data: "+str(edata))
         try:
             ddata = cr.decrypt(s_key, edata)
         except:
             logger.write("e", loggerloc+"Could not decrypt data: "+str(edata))
             conn.send("[send];[Server was not able to decrypt sent data!];[error]")
         logger.write("i", loggerloc+"Handing over decrypted data to socket_remote_access_command_handler! Data: "+str(ddata))
         Handler.socket_remote_access_command_handler(ddata, conn, VarKeeper.s_key)
def sender():
    while True:
        send = raw_input("=> ")
        edata = cr.encrypt(s_key, send)
        if sendlock is False:
            socket.send(edata)
        else:
            CSPrint("info", "SendLock is acquired ! Please resend in a few seconds!")
Exemplo n.º 3
0
    def socket_remote_access_command_handler(self, recv_data, conn, s_key):
        import main
        import logger
        import cryptographer as cr
        loggerloc = "File: main.py | Class: Handler | Function: socket_remote_access_command_handler | "
        tmp = str(recv_data)
        recv_data = tmp
        recv_data = recv_data.split(";")
        sender = recv_data[0]
        command = recv_data[1]
        args = recv_data[2]
        sender = sender.strip("[")
        sender = sender.strip("]")
        command = command.strip("[")
        command = command.strip("]")
        args = args.strip("[")
        args = args.strip("]")
        args = args.split(", ")
        logger.write("i", loggerloc+"Successfully split received data! Sender: "+str(sender)+" | Command: "+str(command)+" | Args: "+str(args))

        if command is "test":
            main.Output.CSPrint("info", "Recv Data: ["+str(sender)+":"+str(command)+":"+str(args))
            etext = cr.encrypt(s_key, "[send];[Successfully sent test!];[debug]")
            conn.send(etext)