cmg189 / singleKey_exploit

Exploiting the many-time pad vulnerability

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single Key Exploit

This program demonstrates the single key exploit by way of ciphertext decryption. The single key exploit has also been know to go by other names including one-time pad and many-time pad.

Table of Contents

  1. Description
  2. Program Output
  3. Execution
  4. Function Headers
  5. Resources

Description

Single Key Exploit is a python program that decrypts ciphertext. This ciphertext has been encrypted using a single key for each message, leading to the single key exploit. Upon execution, the program will display the plaintext message that will be encrypted. Then it will try to decrypt as much of the encrypted text as possible. The resulting decrypted text will be output to the user.

Program Output

Execution

To execute run the command python3 main.py

Function Headers

display_info()
  • Description:

    Outputs plain text to be encrypted

  • Parameters:

    None

  • Return:

    msgs List containing strings to be encrypted

    key List of bytes representing the encryption key


make_cipher(text, key)
  • Description:

    Creates a list of strings representing ciphertext

  • Parameters:

    text List representing plaintext

    key List of bytes representing the encryption key

  • Return:

    cipher List containing ciphertext


encrypt(msg, key)
  • Description:

    Encrypts plain text using an encryption key

  • Parameters:

    mag String to be encrypted

    key List representing encryption key

  • Return:

    bytes String representing encrypted text in hexadecimal


preprocess(text)
  • Description:

    Turns encrypted text into hexadecimal and initializes a list of dashes acting as placeholders

  • Parameters:

    text List containing ciphertext

  • Return:

    hex List representing hexadecimal representation of encrypted text

    place_holders List containing dashes -


break_encryption(encrypted_text, decrypted_text)
  • Description:

    Attempts to break encryption by utilizing XOR operations

  • Parameters:

    encrypted_text List containing the ciphertext

    decrypted_text List of placeholders to store decrypted text

  • Return:

    cracked_cipher List of decrypted text


ascii_space(not_cracked, current_char, columns)
  • Description:

    Checks a character to determine if it is a space

  • Parameters:

    not_cracked List containing text that has not been decrypted

    current_char Char representing the current character that is being test to determine if it is a space

    columns Int representing the index of the current character we are testing

  • Return:

    Bool True if a space is found, False otherwise


output_text(text)
  • Description:

    Outputs the decrypted text

  • Parameters:

    text List containing decrypted text

  • Return:

    None

Resources

To learn more about this encryption vulnerability refer to this article: One-time Pad

About

Exploiting the many-time pad vulnerability

License:MIT License


Languages

Language:Python 100.0%