Skip to main content

An encryption tool, designed for CTF challenges and fun purposes.

Project description

Memecrypt

Memecrypt is an encryption tool designed for fun and CTF challenge use. It can be imported as a python module or used as a standalone program, depending on whichever is needed.

GitHub forks GitHub stars GitHub watchers

Usage

There are 2 main ways to use memecrypt. Both ways are covered here.

Program use

Install from PyPi

$ python3 -m pip install memecrypt

Options

Let's start by viewing all the supported arguments.

$ memecrypt
[+] Usage: memecrypt [options]

[i] Examples:

      memecrypt -se -i foo -k bar

      memecrypt --subs -x -f file.txt -k "a_key"

      memecrypt -sx -i 'lorem ipsum' -k 'some key'

      memecrypt --subs -e -u cat.thatlinuxbox.com -k 'ascii cat'

[i] Positional arguments:

       -s --subs
              Select the substitution cipher.
       -e --encrypt
              Select encryption mode.
       -x --decrypt
              Select decryption mode.
       -k --key key
              Specify key.
       -i --input input-string
              Specify input string.
       -u --url url
              GETs data from the url.
       -f --file file-path
              Specify input file path.

[i] Optional arguments:

       -h --help
              Show this help screen and exit.
       -v --version
              Print version and exit.
       -q --quiet
              Only show output. Any errors are still displayed.
       -o --output-file file
              Specify a file to write to.
       -p --pipe-input
              Take input from stdin.

Encryption

# As an argument
$ ./memecrypt.py -se -i "foo bar" -k "lorem ipsum"
[!] Note: Please use the same key for decryption.
[+] Encrypted result:
---------------------
MHFGL1AjdjpSXXx8

# From a URL
$ ./memecrypt.py --subs --encrypt --url cat.thatlinuxbox.com --key "cat"
[+] Fetched data from URL.
[!] Note: Please use the same key for decryption.
[+] Encrypted result:
---------------------
WiJeTFoiXkxaOl5ETDpeREw6XkRMOl5ET.....(and so on).....

# From a local file
$ ./memecrypt.py -se -f <file-path> -k "foobar" -q
NWl8eSlMd35ZXTQxU289Y0ZdNGdGTCdrU2FBQ3pM...(and so on)...

Decryption

# Decrypt as an argument.
./memecrypt.py -sx -i bVQ0cjJfVkY1TGNCKFRWWzIkZVF... -k wow
[+] Decrypted result:
---------------------
Much encryption, very wow

# Decrypt from file
$ ./memecrypt.py --subs --decrypt -f ../../projects/outputfile -k lol
[+] Decrypted result:
---------------------
Cupcake ipsum dolor. Sit amet topping chocolate bar

Notes

Arguments can be placed in any order and combined however you want, as long as they don't need a passed value or directly contradict.

Module use

Install using python3 -m pip install memecrypt

Initialising

Let's start by creating an instance of the meme_cipher class.

# Import our module
import memecrypt

# Create an instance
cipher = memecrypt.meme_cipher(message=None, enc_key=None, show_colors=True)

# message is the message to work on
# enc_key is the key
# show_colors=False to turn off all colors

Setting a message

Set message using method or attribute.

# Using our previous instance
cipher.set_message("foo")

# We can access/modify this by accessing the message attribute
print(cipher.message)
# Prints: foo

# Let's try and set a blank message.
cipher.set_message(None)
# Prints: [!] Memecrypt: Plaintext/Ciphertext cannot be empty.

Setting a key

This works the same way as setting a message. We'll use our cipher instance. Again, the key cannot be blank or None.

# Setting a key
cipher.set_key("bar")

# We can access/modify the key from the enc_key attribute
print(cipher.enc_key)
# Prints: bar

# Same as before, we can't set a blank key
cipher.set_key('')
# Prints: [!] Memecrypt: Key value cannot be empty.

Encrypting

Encrypt the values. If key or message is missing, error.

# message => foo, key => bar
cipher.encrypt()
# Returns: 'NEgydQ=='

Decrypting

Perform decryption

# message => NEgydQ==, key=> bar
cipher.decrypt()
# Returns: 'foo'

Input sources

Take input from file.

# transfer the contents of the url.
cat = cipher.fetch_url("cat.thatlinuxbox.com")
# Returns a ascii cat.
cipher.set_message(cat)
# We just set our message as the ascii cat!

# Read a local file.
foo_file = cipher.read_file("/path/to/file/file.txt")
# foo_file will have contents of file.txt

# Set our message to contents of file.txt
cipher.set_message(foo_file)

Output files

Write output to a file.

# Append to a file. Create file if file non-existent.
cipher.write_to("path/to/file/file.txt", "lorem ipsum dolor")

# Let's put our encrypted output to a file.
cipher.write_to("foo_bar.txt", cipher.encrypt())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memecrypt-1.5.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

memecrypt-1.5.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file memecrypt-1.5.0.tar.gz.

File metadata

  • Download URL: memecrypt-1.5.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.0 CPython/3.8.6 Linux/5.4.0-48-generic

File hashes

Hashes for memecrypt-1.5.0.tar.gz
Algorithm Hash digest
SHA256 61eb1d4e825ad25a25aa0181ba07e2e4434d3ca43418ddb36dd534696f1ad4b7
MD5 8062b9de9f3e618b082af0a4db5851cb
BLAKE2b-256 115d825874364f96810bdc6e9c53fa0a9ec7232cb2332ba3d9a6a11b63234a6a

See more details on using hashes here.

File details

Details for the file memecrypt-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: memecrypt-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.0 CPython/3.8.6 Linux/5.4.0-48-generic

File hashes

Hashes for memecrypt-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5a536ca6560cd58dbbc2b6ca1f1cca7678b4216b331782c132b6a258c7d6988
MD5 74e9aa6f9222599538dacf4e3e42f373
BLAKE2b-256 850c5438b67296cc90bdb4002d1b2eed004ee2b1be2cf390988527d0c0aa5f4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page