Repository navigation
FAQ
commix (short for [comm]and [i]njection e[x]ploiter) is an open source penetration testing tool that automates the detection and exploitation of OS command injection flaws. Given a request and a place in it to test, it works out whether the target runs what it is given, by which of four techniques the answer comes back, and - once one holds - what can be done through it: a command, a shell, a file read or written, the Windows registry, the target's users and their password hashes.
python commix.py -hThe full list of options, with the ones a first run rarely needs:
python commix.py -hhcommix needs Python 3.7 or newer and nothing else - every third-party library it uses is
bundled, which is why a clone is all it takes. --dependencies
says which of the optional ones this host has.
Yes. commix is released under the terms of the GPLv3, so a derivative work may be distributed under the rights that licence already grants.
There are three ways to drive it from somewhere else, in rising order of how much you want back:
-
The exit status -
0where an injection point was found,2where everything asked for was tested and nothing was,1where the run ended on an error. See what a run exits with. -
--report-json- the findings, the payload behind each, acurlcommand that reproduces it, and what went wrong where something did. Written as the run goes, so it can be read while it is still going. -
The REST API -
commixapi.py, where each scan is a task that is created, given options, started, and then read.
Bug reports are welcome. Please open one on the issue tracker.
What makes a report easy to act on:
- Check the open and closed issues first, and the user's manual.
- Reproduce it against the latest development version, since it may already be fixed.
- Say what you ran and what happened. The whole command line, with
-v4where the problem is in what was sent, and the traceback where there is one. - A target anyone can reach is worth more than any description of one. The commix-testbed is the easiest way to show a case that does not depend on a site only you can see.
- For a feature, say what it would let you do that nothing else does.
Yes. Clone the repository, read the user's manual, and send a pull request.
A few things that make a patch land faster:
- One logical change per patch.
- Match the surrounding code: two spaces of indentation,
lower_snake_casenames,UPPERCASEconstants, and comments that say why rather than what. - Run the suite -
python -m unittest discover -s tests -t .- and the smoke test,python commix.py --smoke-test. The build runs both. - A new technique, module or tamper script has a place it is registered rather than wired in by hand; module development describes one of them.
- Leave
src/thirdparty/alone.
No. commix is for testing systems you own or have been given permission to test, and attacking anything else is a crime wherever you are reading this. The project does not take such requests and nobody on it will answer one.
The commix-testbed is the official one: a container of deliberately vulnerable pages, one per shape of the bug, which every example in this wiki is captured against. The command injection testbeds page lists the others worth knowing.
Then use that tool.
Tools are written around different assumptions about what a target does with the value it is given, so the sets of targets they handle overlap without matching, and neither side of that is a fault in the other. What matters is that the target gets tested; which program reached it is secondary.
There is no answer that holds for every one of them, because what a filter blocks is what decides it.
What does work is reading what the target refused and picking the script that stops producing it:
a filter that eats whitespace wants space2ifs or one of its neighbours, one that blocks a command's
name wants ansiquote or phpnoletters, one that blocks $() wants backticks.
--list-tampers prints every script with what it does to a payload, the
tamper script table
records what each is compatible with, and
filters bypass examples
works through real ones. Several can be combined, and are applied in a fixed order.
Yes. --eval
tests the string a target evaluates as code, in PHP, Python, Ruby, JavaScript or
PowerShell, over the same techniques. The shellshock module tests CGI targets for
CVE-2014-6271, and
--jwt
reads a JSON Web Token the request carries and tests its kid as an injection point of its own.
Yes - that is what three of the four techniques are for. Only the results-based one needs the
command's output to reach the response. The boolean-based one reads which of two pages came back,
the time-based one reads the delay, and the file-based one reads a file the command wrote. Where
none of those can answer, --oob
has the target reach a server you control instead. The
techniques page describes what each one
asks of a target.
A technique is how execution is proven, and a type is what the finding is reported as.
--type="c" is the same as --technique="r", and --type="b" the same as --technique="btf" -
so the second is the shorter way to ask for a whole class when the distinction that matters is
whether output is visible at all. The two cannot be given together.
Because it has to put a file somewhere the web server will serve back, and the document root is
not something a target usually says. Where commix cannot work it out, it offers the common
locations, a list of your own, a file of them, or a brute-force search - see
the document root menu.
--web-root
skips the question when you already know it.
-
--threads- the bytes of an answer are independent of one another, so several can be read at once. Nothing here is timed, so overlapping requests cost the answer nothing. -
--charset- telling it the output is a number, or a hash, is a question not asked for every byte. -
--maxlen- a shorter ceiling is a shorter search for the length itself. - A technique that is not going to answer is time spent either way:
--techniquenames the ones to try.
Yes. The payloads, the shells and the enumeration all have a cmd.exe and PowerShell side, and
--os
forces the choice where detection cannot make it.
Windows and Unix-like targets at a glance
sets out how the two differ.
No. What a run learns about a target is kept in a session file of its own, so a second run against
the same target answers at once rather than testing again -
resume from stored session data.
--flush-session discards it and --ignore-session leaves it in place and ignores it.
--os-shell is the one to reach for
first: a prompt on the target over whichever technique confirmed. Beyond it there are the built-in
reverse_tcp and bind_tcp handlers, upgradeable to a full PTY with --pty, and the Metasploit
ones. Getting shells works through
each.
Every release is tagged in the repository.
--version says which one is running, and
--update brings a clone up to
the latest development version.
At the right side panel, you can find detailed information about Commix Project.
- Features - What commix implements, at a glance
- Usage - Exhaustive breakdown of all options and switches together with examples
- Techniques - Techniques supported by commix
- API - Driving commix over HTTP, a scan at a time
- Download and update - Keep your copy up-to-date
- Module development - Guide for extending commix with custom modules
- Third party libraries - Third-party components used by commix
- FAQ - Frequently Asked Questions
- License - Copyright information
- Usage examples - Real-world examples of using commix against vulnerable applications
- Filters bypass examples - Payloads and techniques used to evade input filters
- Getting shells - Getting an interactive, reverse or bind shell
- Presentations - Conference talks and public presentations featuring commix
- Screenshots - Visual examples of commix in action
- Third party references - References to commix in books, articles, research papers and blog posts
- Command injection testbeds - Deliberately vulnerable targets for safely testing commix