Пример #1
0
def connection_manager(clientSocket, clientAddress, inbox):

    clientIP, PORT = clientAddress

    if clientIP and PORT:
        print "\n\nACCEPTED connection from: ", clientIP, " on port number: ", PORT

        cipherText = clientSocket.recv(
            BUFFER_SIZE)  #retrieve the message from the client

        if not cipherText:
            print "\nMESSAGE WAS INVALID\n"

        else:
            dmessage = RC4.decrypt(
                cipherText, 20,
                "password")  #decryption; 20 rounds of key scheduling
            print "\nMESSAGE RECEIVED >> \r\n", dmessage

            LocalTime = time.asctime(time.localtime(
                time.time()))  #get current time
            savedMessage = "TIME RECEIVED: " + LocalTime + "\n\nMESSAGE: " + dmessage  #add time to message

            inbox.append(
                savedMessage)  ###STORE MESSAGE IN RECEIVED MESSAGES LIST

        clientSocket.close()
Пример #2
0
def threaded_client(conn):
    while True:
        data = conn.recv(1024)
        if not data:
            break
        x = RC4.decrypt(data)
        m = RC4.getMessage(x)
        print("\nRECEIVED: ", m)
        if not data:
            break
    conn.close()
Пример #3
0
def decrypt(dec_type, message, key):
    mac = message[-40:]
    message = message[:-40]
    if dec_type == 2:
        message = ecc.decrypt(message, key)
    elif dec_type == 0:
        message = des.decrypt(message, key)
    elif dec_type == 1:
        message = RC4.decrypt(message, key)
    if (hmac.hmac(key, message) == mac):
        return -1
    return message
Пример #4
0
def connection_manager(clientSocket, clientAddress):

    clientIP, PORT = clientAddress

    if clientIP and PORT:
        print "Accepted connection from: ", clientIP, " on port number: ", PORT

        cipherText = clientSocket.recv(BUFFER_SIZE)

        if cipherText:
            dmessage = RC4.decrypt(cipherText, 200, "test")
            print "\nMESSAGE RECEIVED >> ", dmessage
        else:
            print "\nMESSAGE WAS INVALID\n"

        clientSocket.close()
Пример #5
0
    mkey = b""

    for line in tbslog.readlines():
        line = line.strip()
        if not line:
            continue

        flag = line[:len_of_mkey][:3]
        if flag != b"013":
            log_data += line
            continue
        else:
            log_data_list.append((mkey, log_data))

            log_data = line[len_of_mkey:]
            mkey = RC4.decrypt(line[:len_of_mkey][3:], key_of_mkey)
            if len(mkey) != 13:
                mkey = b""
                continue
    if mkey and log_data:
        log_data_list.append((mkey, log_data))

    for key, value in log_data_list:
        if not key or not value:
            continue
        log = RC4.decrypt(value, key)
        pass

    log_list = [
        RC4.decrypt(value, key) for key, value in log_data_list
        if key and value