The Hive
GitHubLinkedInEmail
  • 🏠Home
  • 🌐RECON
    • πŸ“‘Passive (OSINT)
      • ⏩Metadata
      • ⏩Social Platforms
        • Email
        • Tumbler
        • Redit
        • Github
        • Tinder
        • TikTok
        • Snapchat
        • Instagram
        • Facebook
        • Twitter
        • Google
        • LinkedIn
    • πŸ“‘Active
      • ⏩Host Discovery / Network Mapping
      • ⏩nmap cheat sheet
      • ⏩masscan cheat sheet
    • πŸ“‘Web Recon
      • ⏩Web Server Discovery
      • ⏩Hidden Hosts
      • ⏩Directories & Subdomains
      • ⏩SSL Certs
      • ⏩CMS
      • ⏩WAF Detection
    • πŸ“‘Firewall Evasion
  • πŸ“—Web Attacks
    • 🟒Server Side
      • 🟩Authentication Mechanisms
      • 🟩Access Control (Authorization)
      • 🟩Directory Traversal
      • 🟩OS Command Injection
      • 🟩Server-Side Request Forgery (SSRF)
      • 🟩XML External Entity (XXE) Injection
      • 🟩File Upload
      • πŸ”§SQL Injection
      • 🟩Information Disclosure
      • 🟩Business Logic
    • 🟒Client Side
      • 🟩Cross-site request forgery (CSRF)
      • πŸ”§Cross-site scripting (XSS)
  • πŸ“’Network attacks
    • 🟑Network Services
      • 🟨Brute Force
      • 🟨DNS
      • 🟨IPv6
      • 🟨FTP
      • 🟨SSH
      • 🟨SMB
      • 🟨SNMP
      • 🟨SMTP
      • 🟨POP3
      • 🟨IMAP
      • 🟨MSSQL
      • 🟨MySQL
      • 🟨MSRPC / RPCbind
      • 🟨LDAP
      • 🟨NTP
      • 🟨NFS
      • 🟨Telnet
      • 🟨WebDAV
      • 🟨RDP
      • 🟨RSIP
      • 🟨Rlogin
      • 🟨VPNs
      • 🟨Echo
      • πŸ”§RTP
      • πŸ”§VOIP
        • SIP
    • 🟑Network Devices
      • 🟨IPv6 Attacks
        • Neighbor Impersonation
        • Router Advertisement Flooding
      • 🟨Switch Attacks
        • Cisco Exploitation
        • STP Spoofing
        • VLAN Hopping
        • MAC Flood
      • 🟨Router Attacks
        • Router Exploitation
        • HSRP Hijacking
        • πŸ”§RIP Spoofing
        • πŸ”§OSPF Attacks
        • πŸ”§VRRP MitM
      • 🟨NAC Bypass
        • Captive Portal
        • 802.1X / EAP Bypass
      • 🟨Printer Exploitation
    • 🟑MITM & Poisoning
      • 🟨Bettercap
      • 🟨HTTPS Downgrade / HSTS Bypass
      • 🟨Session Hijackings
      • 🟨Malicious Update
      • 🟨RDP Downgrade
      • 🟨DNS Spoofing
      • 🟨NTP Spoofing
      • 🟨ARP Spoofing
      • 🟨DHCP Poisoning
      • 🟨DHCPv6 Spoofing
      • 🟨SSDP Spoofing
      • 🟨WSUS Spoofing
      • 🟨ADIDNS Poisoning
      • 🟨WPAD Abuse
    • 🟑Wireless Attacks
      • 🟨Protocol Concepts
      • 🟨Basics
      • 🟨Attacks
    • 🟑Sniffing
      • 🟨Wireshark
      • 🟨tcpdump
    • 🟑Denial of Service
  • πŸ“•Red Team
    • πŸ”΄Windows
      • β­•Security Concepts
        • Windows Security Components
        • Active Directory Components
        • Kerberos
        • Loggon Sessions and Access Tokens
        • Permissions and Access Control
        • Windows Registry
        • Object Management
      • β­•Physical Attack
      • β­•Enumeration
      • β­•Privilege Escalation
        • DLL Hijacking
          • Phantom DLL Hijacking / Replacement
          • Search Order Hijacking ( Preloading )
          • DLL Side-Loading
        • Service Misconfigurations
          • Weak Registry Permissions
          • Insecure Service Executables
          • Insecure Permission
          • Unquoted Service Path
        • Creating a New Service (admin to system)
        • Registry
          • AlwaysInstallElevated
          • AutoRuns
        • Scheduled Tasks
        • Mass Roll-outs
        • Startup Apps
        • Installed Applications
        • Loopback Services
        • Insecure GUI APPs
        • Potatos
        • Printspoofer / SEImpersonate
        • PSEXEC (admin to system)
      • β­•Credential Dumping
      • β­•Persistence
        • Invisible Account Forger
        • Add User
        • Scheduled Tasks
        • Run Registry Keys
        • Logon Scripts
        • Screensavers Hijack
        • Powershell Profiles & Modules
        • Service Creation/Modification
        • Shortcut Modification
        • Startup Folder
        • RDP backdoors
        • COM Hijacking
    • πŸ”΄Active Directory
      • β­•Domain Enumeration
      • β­•Tools & Frameworks
        • Evil-WinRM
        • CME cheat sheet
        • SharpSploit
        • impacket cheat sheet
        • DeathStar
      • β­•Exploitation
        • LLMNR Poisoning
        • SMB/NTLM Relay
        • DNS Takeover + LDAP Relay
        • Cracking Hashes
        • Password spraying
        • ADCS + PetitPotam NTLM Relay
        • EternalBlue
        • ZeroLogon
        • MS Exchange ProxyShell
        • MS Exchange ProxyLogon
        • Java JBOSS
      • β­•Privilege Escalation
        • Token Impersonation
        • DNS Admins
        • AD CS Abuse
        • ACL Abuse
          • GenericAll
          • Write Property
          • Self-membership
          • ForceChangePassword
          • Managed Security Groups
          • Exchange Windows Permissions
        • Group Policy Objects (GPOs)
        • Custom SSPs
        • PrintNightmare
      • β­•Lateral Movement
        • RDP Password Decryption
        • RDP Session Hijacking
        • headless RDP with SharpRDP
        • Domain Shares
        • SCF File Attacks
        • Pass the Hash / Password
        • Overpass the Hash / Pass the Key
        • Pass The Ticket
        • Kerberosting / AS-REP Rosting
        • Kerberos Delegation
      • β­•Credential Dumping
        • CredSSP / TSPKG
        • Wdigest Clear Text
        • DPAPI secrets
        • SAM & Registry
        • NTDS.dit & vshadow
        • comsvcs.dll
        • Meterpreter
        • Procdump & LSASS
        • AD User Comments
        • SYSVOL & Group Policy Preferences
        • LAPS Passwords
        • GSMA Passwords
        • HiveNightmare
        • Mimikatz Cheat sheet
        • Other Tools / Techniques
      • β­•Persistence
        • Certificates
        • DCSync
        • DCShadow
        • Silver Ticket
        • Golden Ticket
        • Skeleton Key
        • WMI
        • PowerShell Remoting
        • Remote Registry
        • Rights Abuse
        • AdminSDHolder
        • DSRM
        • Kerberos Checksum Validation ( MS14-068 )
    • πŸ”΄Linux
      • β­•Physical Attacks
      • β­•Enumeration
      • β­•Privilege Escalation
        • SUID / SGID abuse
        • /etc/shadow & /etc/passwd
        • cron/crontab abuse
        • Sudo Abuse
        • Capabilities Abuse
        • Environment Variables
          • LD_LIBRARY_PATH
          • LD_PRELOAD
        • Shared Object Injection
        • NFS
        • man CE Pager Argument
        • MySQL UDF
        • UDEVD
        • STDIN/STDOUT
        • Unix Socket Exploitation
        • Dirty Pipe
        • Docker
          • SUID Docker
      • β­•Lateral Movement
        • Infecting Running Processes
        • VIM Config File Keylogger
        • SSH Hijacking
        • Samba Secrets to Domain Admin
        • Hiding Processes
        • Simple User-mode Rootkits
        • Vino VNC Server
      • β­•Credential Dumping
        • Swap Dump
        • mimipinguin
        • unshadow
        • 3snake
      • β­•Persistence
        • Startup User File Backdoor
        • PHP Backdoor
        • Apache mod_rootme
        • Startup Service Backdoor
        • xdg Backdoor
        • rootbash SUID
        • apt Backdoor
        • Driver Backdoor
        • Core Pattern
        • dash Backdoor
        • Creating an SUID Binary
        • Systemd netcat bind shell
        • Xinetd UDP portnock
        • openSSL reverse shell
        • motd Backdoor
        • Auth Log Backdoor
        • RSYSLOG Backdoor
        • sshd Backdoor
        • VIM Config Backdoor
        • .bashrc Backdoor
        • Adding a Root user
        • Crontab Reverse Shell
        • SSH persistence password-less
      • β­•Covering Tracks
    • πŸ”΄Command & Control (C2)
      • β­•Cobalt Strike
      • β­•Metasploit
      • β­•Empire & Starkiller
      • β­•Covenant
    • πŸ”΄Shells and Payloads
      • β­•Shell Escape / Interactive Shell
      • β­•LOL Binaries
      • β­•msfvenom
      • β­•SharpShooter & Ivy
      • β­•Other Payloads
    • πŸ”΄Payload Delivery
      • β­•Powershell Reflective DLL Load
      • β­•HTML Smuggling
      • β­•Office Macros
      • β­•DDE Auto - Word/Excel
      • β­•.SLK Excel
      • β­•XLM Macro 4.0
      • β­•LNK
      • β­•embedded OLE + LNK objects
      • β­•JScript
      • β­•HTA
      • β­•VBS
      • β­•VBA
      • β­•RTF
      • β­•REG
      • β­•MSI / MSIEXEC
      • β­•IQY
      • β­•CHM / HHC
      • β­•SCR
    • πŸ”΄Pivoting
      • β­•SSH Forwarding
      • β­•Socat Stealth Port Forward
      • β­•Socat Reverse Shell Relay
      • β­•HTTP Tunneling
      • β­•ICMP Tunneling
      • β­•DNS Tunneling
      • β­•Metasploit Pivoting
      • β­•Cobalt Strike Pivoteing
      • β­•VPN Tunneling
      • β­•Other Tools
    • πŸ”΄Exfiltration / File Transfer
      • β­•Encode / Decode Files
      • β­•TCP / UDP
      • β­•DNS
      • β­•SSH
      • β­•ICMP
      • β­•SMB
      • β­•FTP
      • β­•HTTP
      • β­•Other Methods
    • πŸ”΄Password Attacks
      • β­•Online Attacks
      • β­•Offline Attack
      • β­•Word List
      • β­•Cheat Sheet
    • πŸ”΄Defense Evasion
      • β­•Basic Tricks
      • πŸ”§Powershell Tricks
      • β­•Disabling Defenses
      • β­•UAC Bypass
      • β­•Process Migration
      • β­•Dechaining Macros
      • β­•VBA Sandbox Evasion
      • β­•AMSI Bypass
      • β­•SRP & AppLocker Bypass
      • β­•GPO Bypass
  • πŸ“˜Blue Team
    • πŸ”΅Threat Modeling / Hunting / Intelligence
    • πŸ”΅Linux Hardening
      • πŸ”ΉOS Security
        • Update Strategy
        • Service Management
        • Physical Security
        • Grub Hardening
        • Kernel Parameters
        • Process Isolation
      • πŸ”ΉAccounts & Passwords
        • Users & Groups
        • Password Security & Sudoers
      • πŸ”ΉAccess Control & Ownership
      • πŸ”ΉFile System Security
      • πŸ”ΉIntegrity Check
      • πŸ”ΉSandboxing
      • πŸ”ΉNetwork
      • πŸ”Ήiptables
        • Rule Sets
      • πŸ”ΉService Hardening
        • BIND9
        • vsftpd
        • Nginx
        • Apache
        • SSH
      • πŸ”ΉSystem Audit
      • πŸ”ΉLogging
        • auditd
      • πŸ”ΉEncryption
    • πŸ”΅Security Architecture
      • πŸ”ΉLayered Security
  • πŸŸͺPurple Teaming
    • 🟣Adversary Emulation
  • 🟧programming
    • 🟠C Programming
      • πŸ”ΈBasic Structure
      • πŸ”ΈGCC Compiler
      • πŸ”ΈPreprocessors
      • πŸ”ΈData Types
      • πŸ”ΈType Qualifiers
      • πŸ”ΈPointers
      • πŸ”ΈDynamic Memory Allocation
      • πŸ”ΈLoops
      • πŸ”ΈConditional Statements
      • πŸ”ΈFunctions
      • πŸ”ΈInput / Output
      • πŸ”ΈMacros
      • πŸ”ΈFiles
      • πŸ”ΈStrings Manipulation
      • πŸ”ΈBit Manipulation
      • πŸ”ΈData Structures
        • Arrays
        • Structures
        • Unions
      • πŸ”ΈAbstract Data Types
        • Stack
        • Queue
        • Linked List
          • Singly Linked List
          • Doubly Linked List
      • πŸ”ΈLibraries & Linking
      • πŸ”ΈError Recovery
    • πŸ”§Assembly ( NASM )
      • Intel IA-32 Environment
      • Basic Structure
      • Variables and Data Types
      • Most-used Instructions
      • input / output
  • 🟫Miscellaneous
    • 🟀GNU Screen / tmux
    • 🟀SSH Tricks
    • 🟀Cats
      • netcat
      • ncat
      • pwncat
      • socat
      • πŸ”§powercat
    • 🟀Curl
    • 🟀Cross-compiling Binaries
Powered by GitBook
On this page
  • LUKS
  • GNU Privacy Guard (GPG)
  • Symmetrically Encrypting Files
  • Encrypting Files with Public Keys
  • Signing a File Without Encryption
  • eCryptfs
  • Encrypting a Home Directory for a New User Account
  • Creating a Private Directory Within an Existing Home Directory
  • Encrypting the swap Partition with ecryptfs
  • VeraCrypt (cross-platform)
  • creating and mounting a VeraCrypt volume in console mode
  • OpenSSL
  1. Blue Team
  2. Linux Hardening

Encryption

LUKS

You can implement LUKS only before system installation because LUKS is an FDE solution and your file system will be implemented on top of it, so there is no way to setup LUKS on a system with installed OS.

create a linux partition:

fdisk /dev/sdb1
cryptsetup --help

create an encryption layer on top of /dev/sdb1

cryptsetup luksFormat /dev/sdb1 

open the device with the given name in /dev/mapper

cryptsetup luksOpen /dev/sdb1 [name] 
cd /dev/mapper

mkfs.ext4 /dev/mapper/[name]

mkdir /secrey 

mount /dev/mapper/secret /secret

cryptset luksClose /dev/mapper/secret

for automatic mount of the encrypted device we have to create a config file and an entry in /etc/fstab:

dd if=/dev/urandom of=/root/lukskey bs=4096 count=1

cryptsetup luksAddkey /dev/sdb1 /root/lukskey

nano /etc/crypttab add following:

secret  /dev/sdb1   /root/lukskey

nano /etc/fstab add following:

/dev/mapper/secret      /secret ext4    defaults    1   2

reboot

GNU Privacy Guard (GPG)

create key pair:

gpg --gen-key

list keys:

gpg --list-keys
ls -l .gnupg

Symmetrically Encrypting Files

gpg -c file.txt

the -c option indicates that I chose to use symmetric encryption with a passphrase for the file. The passphrase that you enter will be for the file, not for your private key.

decryption:

gpg -d file.txt

Encrypting Files with Public Keys

after creating key pairs on both ends, extract your own public keys into an ASCII text file.

cd .gnupg
gpg --export -a -o donnie_public-key.txt

do this on both ends

export pubkeys

gpg --import pub.txt

Normally, the participants in this would send their keys to each other either through an email attachment or by placing the keys in a shared directory place these pub keys into your respective .gnupg directories. Once that's done, import each other's keys.

encrypt your file:

gpg -s -e secret.txt

send the file

decrypt and open the file on the other side:

gpg -d secret.txt.gpg

to add the pub key to the trusted keys:

cd .gnupg
gpg --edit-key [username]
gpg> trust

Signing a File Without Encryption

If a file isn't secret but you still need to ensure authenticity and integrity, you can just sign it without encrypting it the pub key exchange should be done before doing this:

Create an unencrypted message and sign it:

gpg -s secret.txt

Send the message, try to open it with less:

less secret.txt.gpg

There's a lot of gibberish there because of the signature, but if you look carefully,you'll see the plain, unencrypted message.

use gpg with the --verify option to verify that the signature really does belong to you:

gpg --verify secret.txt.gpg

eCryptfs

Red Hat and CentOS no longer include eCryptfs in either version 7 or 8 of their products.

Encrypting a Home Directory for a New User Account

install the ecryptfs-utils package:

sudo apt install ecryptfs-utils

create Goldie's account with an encrypted directory:

sudo adduser --encrypt-home goldie

Have Goldie log in. Have her unwrap her mount passphrase, write it down, and store it in a secure place. She'll need it if she ever needs to recover a corrupted directory:

ecryptfs-unwrap-passphrase .ecryptfs/wrapped-passphrase

Creating a Private Directory Within an Existing Home Directory

Instead of encrypting an entire home directory, any user can create an encrypted private directory within his or her own home directory

ecryptfs-setup-private

Encrypting the swap Partition with ecryptfs

sudo ecryptfs-setup-swap

Don't mind the warning about the missing /dev/mapper/cryptswap1 file. It will get created the next time you reboot the machine.

VeraCrypt (cross-platform)

VeraCrypt is the successor to TrueCrypt, and it allows the sharing of encrypted containers across Linux, Windows, macOS, and FreeBSD machines. Although LUKS and eCryptfs are good, VeraCrypt does offer more flexibility in certain ways:

As mentioned, VeraCrypt offers cross-platform sharing, whereas LUKS and eCryptfs don't.

VeraCrypt allows you to encrypt either whole partitions or whole storage devices, or to create virtual encrypted disks.

Not only can you create encrypted volumes with VeraCrypt, you can also hide them, giving you plausible deniability.

VeraCrypt comes in both command-line and GUI variants, so it's appropriate for either server use or for the casual desktop user.

Like LUKS and eCryptfs, VeraCrypt is free open source software, which means that it's free to use, and that the source code can be audited for either bugs or backdoors.

Download VeraCrypt from here:

dpkg -i [package name]

creating and mounting a VeraCrypt volume in console mode

To create a new encrypted volume

veracrypt -c

This will take you into an easy-to-use interactive utility. For the most part, you'll be fine just accepting the default options

Mount this container in order to use it. Begin by creating a mount point directory

mkdir good_stuff_dir
veracrypt good_stuff good_stuff_dir

To see what VeraCrypt volumes you have mounted

veracrypt -l

OpenSSL

With OpenSSL, we can encrypt information on the fly as it goes across the network. There's no need to manually encrypt our data before we send it across the network because OpenSSL encryption happens automatically. This is important because online commerce and banking couldn't exist without it.

generating rsa key:

openssl genrsa -aes256 -out example.pem 2048

see the key structure:

openssl rsa -text -in example.pem

separate public key from key file:

openssl rsa -in example.pem -pubout -out public.pem

generate DSA key

openssl dsaparam -genkey 2048 | openssl dsa -out dsa.key -aes256

generate an ECDSA key :

// Sopenssl ecparam -genkey -name secp256r1 | openssl ec -out ec.key -aes256

OpenSSL supports many named curves (you can get a full list with the -list_curves switch), but, for web server keys, you’re limited to only two curves that are supported by all major browsers: secp256r1 (OpenSSL uses the name prime256v1 ) and secp384r1 .

Creating Certificate Signing Requests

openssl -req -key -new example.pem -out example.csr

check the CSR:

openssl -req -text -in example.csr -noout

generate a public and private key pair:

 openssl genrsa -des3 -out private.pem 2048

That generates a 2048-bit RSA key pair, encrypts them with a password you provide and writes them to a file. You need to next extract the public key file. You will use this, for instance, on your web server to encrypt content so that it can only be read with the private key.

create a 2048-bit private key (domain.key) and a CSR (domain.csr) from scratch:

 openssl req  -newkey rsa:2048 -nodes -keyout domain.key  -out domain.csr

Generate a CSR from an Existing Private Key

 openssl req  -key domain.key  -new -out domain.csr

Generate a Self-Signed Certificate

openssl req  -newkey rsa:2048 -nodes -keyout domain.key  -x509 -days 365 -out domain.crt

Generate a Self-Signed Certificate from an Existing Private Key

 openssl req  -key domain.key  -new  -x509 -days 365 -out domain.crt

Generate a Self-Signed Certificate from an Existing Private Key and CSR

 openssl x509  -signkey domain.key  -in domain.csr -req -days 365 -out domain.crt

View Certificate Entries

openssl x509 -text -noout -in domain.crt

Verify a Certificate was Signed by a CA

openssl verify -verbose -CAFile ca.crt domain.crt

Create a Private Key

openssl genrsa -des3 -out domain.key 2048

Verify a Private Key

openssl rsa -check -in domain.key

Verify a Private Key Matches a Certificate and CSR

openssl rsa -noout -modulus -in domain.key | openssl md5
openssl x509 -noout -modulus -in domain.crt | openssl md5
openssl req -noout -modulus -in domain.csr | openssl md5

Encrypt a Private Key

/ openssl rsa -des3 -in unencrypted.key  -out encrypted.key
PreviousauditdNextSecurity Architecture

Last updated 2 years ago

πŸ“˜
πŸ”΅
πŸ”Ή
VeraCrypt - Free Open source disk encryption with strong security for the Paranoid
Logo