Cyber Security / Ethical Hacking
  • Prologue
  • CTF/OSCP Prep
    • Fundamentals
      • Linux
        • Basics
        • Bash Scripting
      • Windows
        • Basics
        • PowerShell
          • Scripting
        • CMD
      • Kali Survivor Skills
    • Information Gathering
      • Passive Recon
      • Active Recon
    • Enumeration
      • Common Ports
      • Vulnerability Analysis
    • Exploitation
      • Shells
  • Binary Exploitation / Exploit Development
    • Useful tools and techniques for Binary Exploitation
    • Shellcoders Handbook
      • Chapter 2 - Stack Overflows
        • Linux Buffer Overflow With Command Injection
        • Linux Buffer Overflow Without Shellcode
      • Chapter 3 - Shellcode
  • TryHackMe
    • Linux Fundamentals
      • Linux Challenges
      • RP: tmux
      • Common Linux Privesc
    • Advent of Cyber
      • Inventory Management
      • Arctic Forum
      • Evil Elf
      • Training
      • Ho-Ho-Hosint
      • Data Elf-iltration
      • Skilling Up
      • SUID Shenanigans
      • Requests
      • Metasploit-a-ho-ho-ho
      • Elf Applications
      • Elfcryption
      • Accumulate
      • Unknown Storage
    • Web Application Security
      • Web Fundamentals
      • Juice Shop
      • WebAppSec 101
    • Linux Privesc Playground
    • Intro to x86-64
    • Ninja Skills
    • CC: Radare2
    • Reversing ELF
    • Intro to Python
    • ToolsRus
  • Programming
    • Python
      • Simple TCP Port Scanner/ Banner Grabber
      • Botnet
      • Keylogger
      • Nmap Scanner
    • Golang
      • Execute Commands
      • MAC changer
      • TCP Port Scanner
      • TCP Port Scanner (improved with goroutines)
      • GoNmap Scanner
  • Protostar
    • Stack 0
    • Stack 1
    • Stack 2
  • Web App Pentesting
    • Recon
    • Authentication (Portswigger Academy)
      • Vulnerabilities in password-based login
        • Username Enumeration via different responses
        • Username enumeration via subtly different responses
        • Username enumeration via response timing
        • Broken brute-force protection, IP block
        • Username enumeration via account lock
        • Broken brute-force protection, multiple credentials per request
      • Vulnerabilities in multi-factor authentication
        • 2FA simple bypass
        • 2FA Broken Logic
        • 2FA bypass using a brute-force attack
      • Vulnerabilities in other authentication mechanisms
    • Broken Acess Controls
      • Insecure direct object references (IDOR)
        • Insecure direct object references lab
  • HackTheBox
    • Active
      • Untitled
      • Blunder
Powered by GitBook
On this page
  • Symmetric Encryption
  • Asymmetric Encryption

Was this helpful?

  1. TryHackMe
  2. Advent of Cyber

Elfcryption

Encryption

Symmetric Encryption

Symmetric encryption is where we use the same key to encrypt and decrypt data.

We can use gpg to encrypt a file, using the command gpg -c file.txt and typing the password when prompted, creating the file file.txt.gpg. This file is encrypted and the data is all scrambled. GPG uses the AES algorithm to encrypt the files.

Once encrypted, to decrypt the file we use the command gpg -d file.txt.gpg and type the password (key) used to encrypt it.

To check the integrity of a file, we can see it hash value with md5sum file.txt. If the hash value is different from the one when the file was first created, it means the file was modified, if not it means it is the original file.

Asymmetric Encryption

Asymmetric Encryption uses a public and a private key. If we encrypt data with someone else's public key, it can only be decrypted with that persons private key.

SSH key uses public and private keys. We generate a private key, and with that we have a public key generated also. The we place our public key onto the server, then when we want to SSH into a machine, we use our private key to authenticate ourselves as if the server can successfully decrypt our message with the public key.

So, if we use a public key to encrypt a message, it can only be decrypted with our private key. If we use a private key to encrypt a message, it can only be decrypted with our public key.

To generate a private key we use the following command (8912 creates the key 8912 bits long):

openssl genrsa -aes256 -out private.key 8912

To generate a public key we use our previously generated private key:

openssl rsa -in private.key -pubout -out public.key

Lets now encrypt a file (plaintext.txt) using our public key:

openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out encrypted.txt

Now, if we use our private key, we can decrypt the file and get the original message:

openssl rsautl -decrypt -inkey private.key -in encrypted.txt -out plaintext.txt

PreviousElf ApplicationsNextAccumulate

Last updated 5 years ago

Was this helpful?