News
sqlsus 0.4 released !
New "brute" command, to bruteforce the names of the tables and columns (dictionnary / brute force).
Multithreading support for inband queries.
Added option to convert spaces to /**/ and version information display when starting sqlsus.
Introduction
sqlsus is an open source MySQL injection and takeover tool, written in perl.
Via a command line interface that mimics a mysql console, you can retrieve the databases structure, inject SQL queries, download files from the web server, upload and control a backdoor, clone the databases, and much more...
It is designed to maximize the amount of data gathered per server hit, making the best use (I can think of) of MySQL functions to optimise the available injection space.
Using multithreading, stacked subqueries (inband), regular expression matching (blind), sqlsus is an extremly fast database dumper.
It uses sqlite databases as a backend, for an easier use of what has been dumped, and integrates a lot of common features (see below) such as cookies support, http proxy, https..
Features
General
Both quoted and numeric injections are supported.
All quoted texts can be translated as their hex equivalent to bypass any quotes filtering (eg: magic_quotes_gpc) (eg : "sqlsus" will become 0x73716c737573)
sqlsus also supports these 2 scenarios of injection :
- inband : the result of the request will be in the HTML returned by the web server
- blind : when you can't see the result of the request directly
Support for GET and POST parameters injection vectors.
Support for HTTP proxy and HTTP simple authentication.
Support for HTTPS.
Support for cookies.
Full SQLite backend, storing queries / results as they come, databases structure, key variables. This allows you to recall a command and its cached answer, even in a later re-use of the session.
Possibility to clone a database / table / column, into a local SQLite database, and continue over different sessions.
If you can't access the information_schema database, or if it doesn't exist, sqlsus will help you bruteforce the names of the tables and columns.
Possibility to change the current database and still use all the commands transparently.
Inband
If your query is likely to return more than one row, sqlsus will loop using as many subqueries it can use at a time (per query) without hitting a configurable limit.
Therefore, it can grab dozens, hundreds, thousands of results (depending on the available injection space) in just 1 server hit (yes, one), allowing excessively faster database retrieval in the case of new connection rate restrictions on the remote server.
Databases names, tables names, columns names, count(*) per table, privileges... On MySQL > 5, the database structure can be grabbed in one command from within sqlsus.
Once you have found an inband injection, you need to find the correct number of columns for UNION. sqlsus will do the job for you, identifying the needed number of columns, and which of them are suitable for injection.
To speed things up, multithreading (actually, multi processes) can be used.
Blind
Blind injection is supported, using conditional responses, and multithreading.
The engine has been optimised in speed and server hit :
- keep all the threads busy with micro tasks, whenever it makes sense.
- match each item against a few regular expressions, prior to bruteforcing, to determine the character space to use.
Takeover
If the database user has the FILE privilege, and if you can use quotes in your injection (mandatory for a SELECT INTO OUTFILE), then sqlsus will help you place a php backdoor on the remote system, recursively looking for writable directories.
You can use "download file" from sqlsus shell, to download an arbitrary (world readable) file from the remote server. The file will be stored in the local filesystem, rebuilding the path tree to the file for easier parsing.
sqlsus has the ability to crawl the website at a configurable depth, looking for all the directories it can find, via hypertext links, img links, etc... Then, it tries to upload a tiny php uploader on each candidate directory until it finds one world writable, later used to upload the backdoor itself.
It ships with a PHP backdoor and a controller, to help you execute system commands, PHP commands, and SQL queries as if you were sitting on a normal direct MySQL connection.
Getting started
Copy conf.pm to your own configuration file (or edit conf.pm directly), read carefully the comments above each option before doing any change.
Launch sqlsus, in the sqlsus directory, with your configuration as parameter (-c), you will get a shell.
type "help" and follow your instincts :)
Notes
Be aware that using a huge number of subqueries, especially with complex queries, can result in a heavy load on the target MySQL server.
sqlsus expects the terminal to be in UTF-8.
Other
License
sqlsus is released under the GPL v2.
Disclaimer
Use it at your own risk.
Just keep in mind that whatever you do with this tool, the author (aka me, not you) won't be held responsible for anything.
Author
Jérémy "sativouf" Ruffet : sativouf <at> gmail -dot- com