This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Encription

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

Encryption is a method used to protect data by converting it into a secure format that can only be accessed by authorized users. This process involves using algorithms to transform readable data (plaintext) into an unreadable format (ciphertext). Only those with the correct decryption key can revert the ciphertext back to its original form, ensuring that sensitive information remains confidential.

There are two main types of encryption: symmetric and asymmetric. Symmetric encryption uses the same key for both encryption and decryption, making it fast and efficient for large amounts of data. Asymmetric encryption, on the other hand, uses a pair of keys – a public key for encryption and a private key for decryption. This method is often used for secure communication and digital signatures.

Encryption is widely used to protect data in transit and at rest. For data in transit, encryption ensures that information sent over networks, such as emails and online transactions, remains secure from eavesdroppers. For data at rest, encryption safeguards stored data, such as files on a hard drive or in a cloud storage service, from unauthorized access.

Implementing encryption is crucial for compliance with data protection regulations and standards, such as GDPR and HIPAA. It helps organizations protect sensitive information, such as personal data, financial records, and intellectual property, from cyber threats and data breaches.

Overall, encryption is a fundamental component of data security, providing a robust layer of protection for sensitive information. It ensures that data remains confidential, maintains its integrity, and is accessible only to authorized individuals. As cyber threats continue to evolve, encryption remains a critical tool for safeguarding digital assets.

1 - 🖥️cryptsetup

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the cryptsetup command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                 ██████╗██████╗ ██╗   ██╗██████╗ ████████╗███████╗███████╗████████╗██╗   ██╗██████╗ 
#                ██╔════╝██╔══██╗╚██╗ ██╔╝██╔══██╗╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██║   ██║██╔══██╗
#                ██║     ██████╔╝ ╚████╔╝ ██████╔╝   ██║   ███████╗█████╗     ██║   ██║   ██║██████╔╝
#                ██║     ██╔══██╗  ╚██╔╝  ██╔═══╝    ██║   ╚════██║██╔══╝     ██║   ██║   ██║██╔═══╝ 
#                ╚██████╗██║  ██║   ██║   ██║        ██║   ███████║███████╗   ██║   ╚██████╔╝██║     
#                 ╚═════╝╚═╝  ╚═╝   ╚═╝   ╚═╝        ╚═╝   ╚══════╝╚══════╝   ╚═╝    ╚═════╝ ╚═╝     
                                                                                                    
                                                                                                    
                                                                                                  
# open encrypted partition /dev/sdb1 (reachable at /dev/mapper/backup)
cryptsetup open --type luks /dev/sdb1 backup

# open encrypted partition /dev/sdb1 using a keyfile (reachable at /dev/mapper/hdd)
cryptsetup open --type luks --key-file hdd.key /dev/sdb1 hdd

# close luks container at /dev/mapper/hdd
cryptsetup close hdd

#==============================##==============================#
# CMD cryptsetup						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

2 - 🖥️gpg

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the gpg command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                 ██████╗ ██████╗  ██████╗ 
#                ██╔════╝ ██╔══██╗██╔════╝ 
#                ██║  ███╗██████╔╝██║  ███╗
#                ██║   ██║██╔═══╝ ██║   ██║
#                ╚██████╔╝██║     ╚██████╔╝
#                 ╚═════╝ ╚═╝      ╚═════╝ 
                                          
                                          
                                          
                                         
# Create a key

 gpg --gen-key

# Show keys

  To list a summary of all keys

    gpg --list-keys

  To show your public key

    gpg --armor --export

  To show the fingerprint for a key

    gpg --fingerprint KEY_ID

# Search for keys

  gpg --search-keys '[email protected]'

# To Encrypt a File

  gpg --encrypt --recipient '[email protected]' example.txt

# To Decrypt a File

  gpg --output example.txt --decrypt example.txt.gpg

# Export keys

  gpg --output ~/public_key.txt --armor --export KEY_ID
  gpg --output ~/private_key.txt --armor --export-secret-key KEY_ID

  Where KEY_ID is the 8 character GPG key ID.

  Store these files to a safe location, such as a USB drive, then
  remove the private key file.

    shred -zu ~/private_key.txt

# Import keys

  Retrieve the key files which you previously exported.

    gpg --import ~/public_key.txt
    gpg --allow-secret-key-import --import ~/private_key.txt

  Then delete the private key file.

    shred -zu ~/private_key.txt

# Revoke a key

  Create a revocation certificate.

    gpg --output ~/revoke.asc --gen-revoke KEY_ID

  Where KEY_ID is the 8 character GPG key ID.

  After creating the certificate import it.

    gpg --import ~/revoke.asc

  Then ensure that key servers know about the revokation.

    gpg --send-keys KEY_ID

# Signing and Verifying files

  If you are uploading files to launchpad you may also want to include
  a GPG signature file.

    gpg -ba filename

  or if you need to specify a particular key:

    gpg --default-key <key ID> -ba filename

  This then produces a file with a .asc extension which can be uploaded.
  If you need to set the default key more permanently then edit the
  file ~/.gnupg/gpg.conf and set the default-key parameter.

  To verify a downloaded file using its signature file.

  gpg --verify filename.asc

# Signing Public Keys

  Import the public key or retrieve it from a server.

    gpg --keyserver <keyserver> --recv-keys <Key_ID>

  Check its fingerprint against any previously stated value.

    gpg --fingerprint <Key_ID>

  Sign the key.

    gpg --sign-key <Key_ID>

  Upload the signed key to a server.

    gpg --keyserver <keyserver> --send-key <Key_ID>

# Change the email address associated with a GPG key

  gpg --edit-key <key ID>
  adduid

  Enter the new name and email address. You can then list the addresses with:

    list

  If you want to delete a previous email address first select it:

    uid <list number>

  Then delete it with:

    deluid

  To finish type:

    save

  Publish the key to a server:

    gpg --send-keys <key ID>

# Creating Subkeys

  Subkeys can be useful if you do not wish to have your main GPG key
  installed on multiple machines. In this way you can keep your
  master key safe and have subkeys with expiry periods or which may be
  separately revoked installed on various machines. This avoids
  generating entirely separate keys and so breaking any web of trust
  which has been established.

    gpg --edit-key <key ID>

  At the prompt type:

    addkey

  Choose RSA (sign only), 4096 bits and select an expiry period.
  Entropy will be gathered.

  At the prompt type:

    save

  You can also repeat the procedure, but selecting RSA (encrypt only).
  To remove the master key, leaving only the subkey/s in place:

    gpg --export-secret-subkeys <subkey ID> > subkeys
    gpg --export <key ID> > pubkeys
    gpg --delete-secret-key <key ID>

  Import the keys back.

    gpg --import pubkeys subkeys

  Verify the import.

    gpg -K

  Should show sec# instead of just sec.

  
#==============================##==============================#
# CMD GPG						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░