1_ MCRYPT

Class lab 7-1: MCRYPT

COUNTERMEASURES AGAINST CYBERATTACKS

SYMMETRIC CRYPTOGRAPHY

MCRYPT LAB

Lab Description: This laboratory exercise will provide some hands-on experience with symmetric encryption using command-line tools in Linux. You will conduct symmetric encryption using the Mcrypt tool for Linux. After completing this lab, you will know how to encrypt and decrypt files through the Linux command line using symmetric key cryptography.

Lab Files Needed: The lab instructions as you go will direct you to download a text file to your virtual machine to encrypt. You may wish to create your own .txt file instead of downloading that file.

Lab Environment: This lab uses bootable Kali Thumbdrives provided by Instructor.

ENVIRONMENT SETUP

  1. Working with a partner – power off one of your workstations

  2. Plug the USB Thumbdrive into the powered off workstation

  3. Hit the F10 key during the NUC Splash Screen

  4. From the Boot Menu – Select UEFI Vendor Product Code 2

  5. Select β€œLive System (amd64)” (first option) from the menu

  6. That will take you into a Live Kali Linux desktop

  7. If needed:

    • Username: kali

    • Password: kali

  8. Once you Login to your Kali Linux virtual machine and launch a web browser. You can launch Firefox web browser through the Applications menu at the top right

SYMMETRIC ENCRYPTION WITH MCRYPT

Mcrypt is a symmetric file and stream encryption utility for Linux and Unix that replaces the weaker crypt utility. Mcrypt can be used to encrypt files using several different symmetric encryption algorithms. By default, it uses the Rijndael cipher, which is the algorithm on which the Advanced Encryption Standard (AES) is based.

Linux Tips:

Kali is a Linux distribution optimized for cybersecurity tasks. Here are some Linux terminal commands that might be helpful for the lab:

  • pwd: β€œpresent working directory” will identify which directory you are currently working in

  • ls: β€œlist” files in a directory

  • cd: β€œchange directory” will change to the directory specified (e.g. cd /home/kali will change the working directory to /home/kali)

TASK 1: INSTALLING MCRYPT

1. Mcrypt is not installed by default on your Linux virtual machine. Open a terminal and use the Linux package manager to install this software at the command line as follows.

$ sudo apt-get update

$ sudo apt-get install mcrypt

To install mcrypt, confirm β€œDo you want to continue? [Y/n]” by typing "Y" and the Enter button.

Although we will be using mcrypt in default mode, it is very powerful and full-featured. To see all of the command-line options available to mcrypt (and check that it has been installed), use the following command:

$ mcrypt --help

You should receive a description about mcrypt and the options that can be passed into the program.

If mcrypt --help returns an error about not being found, try installing mcrypt following the instructions above.

Mcrypt provides a variety of symmetric encryption techniques (you would use the -m option at the command line to access these). For a list of the various symmetric encryption modes available to mcrypt, use the following command:

$ mcrypt --list

TASK 2: FETCH / CREATE A TEXT FILE TO ENCRYPT

Next we need a file to encrypt. You can create a text file using a text editor on your Linux virtual machine (β€œTextEditor” on your Kali Linux virtual machine) and save it in your home directory.

You can examine the contents of the file using the Linux β€˜cat’ utility as follows (textfile1.txt is the filename in this example)

$ cat textfile1.txt

TASK 3: SYMMETRIC ENCRYPTING WITH MCRYPT

Use mcrypt to encrypt your textfile. Mcrypt will ask for an encryption key – you can simply type a passphrase at the command line (you will use the same passphrase to decrypt the file). Be sure that you are in the directory location as your text file and encrypt it as follows.

$ mcrypt textfile1.txt

If you list your directory (using ls) you should see textfile1.txt.nc – the encrypted version of the file replaced the plaintext version. Use the linux β€˜cat’ utility to view the file. It should be unintelligible.

$ cat textfile1.txt.nc

You could now send this file to someone else and as long as they have the passphrase, they can decrypt and read it. Now you can safely delete textfile1.txt (as long as you remember your passphrase so you can decrypt textfile1.txt.nc)!

$ rm textfile1.txt

TASK 4: DECRYPT A FILE WITH THE SYMMETRIC KEY

Use mcrypt with the –d switch to decrypt your file. Be sure to use the same passphrase as in step 3, above.

$ mcrypt –d textfile1.txt.nc

Your unencrypted file should be restored to textfile1.txt (use β€˜cat’ to be sure).

$ cat textfile1.txt

WHAT TO SUBMIT

SUBMIT SCREENSHOT AND ANSWERS TO QUESTIONS

SUBMISSION SCREENSHOT: Capture one or more screenshots showing the successfully run encryption and decryption commands in the terminal.

REFLECTION QUESTION 1: Did you encounter any challenges in completing the lab? If so, describe them and describe how you overcame them.

REFLECTION QUESTION 2 -Linux Command Review/Research: Describe in your own words the purpose of the following Linux commands (can research - but don’t just copy and paste an answer)

  • apt-get

This command allows you to get installation packages off the internet. It is a package manager which manages packages.

  • cat

Opens the contents of a file.

  • rm

This command removes whatever file name is specified.

  • cd

Cd stands for change directory.

  • ls

Ls stands for list the files in the directory.

  • pwd

Tells you the directory you are currently in.

  • sudo

Sudo is the superuser do command (aka the please do this command with root permissions)

Last updated