Bash Tool
The Bash tool executes shell commands for system interaction, tool invocation, and security testing.
📸 SCREENSHOT: bash-execution.png
Bash tool command execution
Overview
The Bash tool enables:
- Running security tools (nmap, nuclei, sqlmap)
- System administration commands
- Git operations
- Package management
- Custom scripts
Basic Usage
Simple Commands
> Run nmap scan on 192.168.1.1Executes:
nmap -sV 192.168.1.1With Arguments
> Check open ports on target with service detectionExecutes:
nmap -sV -sC -p- 192.168.1.1Piped Commands
> Find all .env files and search for API keysExecutes:
find . -name "*.env*" -exec grep -l "API" {} \;Security Tools
Network Scanning
> Scan the network 10.0.0.0/24 for live hostsnmap -sn 10.0.0.0/24Vulnerability Scanning
> Run nuclei templates against https://target.comnuclei -u https://target.com -t cves/Web Testing
> Fuzz directories on target websiteffuf -u https://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txtPassword Attacks
> Test for default credentials on SSHhydra -L users.txt -P passwords.txt ssh://192.168.1.1Command Timeout
Default Timeout
Commands timeout after 120 seconds by default.
Long-Running Commands
For extended operations:
> Run comprehensive port scan (may take a while)The agent will use appropriate timeout:
timeout 600 nmap -p- -sV 192.168.1.1Background Execution
> Start the scan in backgroundnmap -p- 192.168.1.1 > scan_results.txt &Working Directory
Current Directory
Commands run in the current working directory:
> List files in current directoryls -laChange Directory
> Navigate to the web directory and list contentscd /var/www/html && ls -laEnvironment Variables
Using Variables
> Use the target IP from environmentnmap -sV $TARGET_IPSetting Variables
> Set target and scanexport TARGET="192.168.1.1" && nmap $TARGETOutput Handling
Capturing Output
> Save scan results to filenmap -sV 192.168.1.1 -oN scan_results.txtJSON Output
> Get scan results in JSON formatnmap -sV 192.168.1.1 -oX - | xq .Parsing Results
> Extract open ports from nmap outputgrep "^[0-9]" scan_results.txt | cut -d'/' -f1Permission Control
Dangerous Commands
Destructive commands require explicit permission:
| Command Type | Example | Requires Permission |
|---|---|---|
| Read-only | ls, cat, nmap | No |
| File modification | rm, mv | Yes |
| System changes | apt install | Yes |
| Network attacks | msfconsole | Yes |
Auto-approve Commands
{ "permissions": { "allow": [ "Bash(nmap *)", "Bash(nuclei *)", "Bash(ffuf *)" ] }}Block Dangerous Commands
{ "permissions": { "deny": [ "Bash(rm -rf *)", "Bash(dd *)", "Bash(:(){ :|:& };:)" ] }}Security Testing Workflows
Reconnaissance
> Perform initial reconnaissance on target.com
1. DNS enumeration2. Subdomain discovery3. Port scanning4. Service identificationExecutes multiple commands:
dig target.com ANYsubfinder -d target.comnmap -sV -sC target.comExploitation
> Attempt SQL injection with sqlmapsqlmap -u "https://target.com/page?id=1" --batch --dbsPost-Exploitation
> Enumerate the compromised systemuname -aidcat /etc/passwdls -la /home/Tool Integration
Metasploit
> Search for exploits for Apache 2.4.49msfconsole -q -x "search apache 2.4.49; exit"Burp Suite
> Start Burp Suite in headless modejava -jar burpsuite.jar --headlessCustom Scripts
> Run the custom enumeration script./scripts/enum.sh $TARGETError Handling
Command Errors
Failed commands show error output:
Command failed:$ nmap -sV nonexistent.hostHost seems down. If it is really up, but blocking our ping probes, try -PnRetry Logic
> Retry the scan with -Pn flagnmap -sV -Pn 192.168.1.1Best Practices
- Verify targets - Double-check IPs and domains
- Use timeouts - Set appropriate timeouts for long scans
- Save output - Always save important results
- Check permissions - Ensure authorized access
- Clean up - Remove temporary files after testing
Danger
Never run commands against targets without authorization. Unauthorized access is illegal.
Troubleshooting
Command Not Found
Error: command not found: nucleiInstall the tool or check PATH:
which nucleiexport PATH=$PATH:/opt/toolsPermission Denied
Error: permission deniedMay need sudo:
sudo nmap -sS 192.168.1.1Timeout
Error: command timed outUse explicit timeout or background execution.
Related Documentation
- File Operations - File handling
- Permissions - Command permissions
- MCP Kali - Additional security tools