Skip to content

Commit 17844eb

Browse files
committed
Refactoring to --technique
1 parent 287f74d commit 17844eb

7 files changed

Lines changed: 95 additions & 17 deletions

File tree

doc/README.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ <H2><A NAME="s5">5.</A> <A HREF="#toc5">Usage</A></H2>
937937
These options can be used to tweak testing of specific SQL injection
938938
techniques.
939939

940+
--technique=TECH SQL injection techniques to test for (default all)
940941
--time-sec=TIMESEC Seconds to delay the DBMS response (default 5)
941942
--union-cols=UCOLS Range of columns to test for UNION query SQL injection
942943
--union-char=UCHAR Character to use for bruteforcing number of columns
@@ -1796,6 +1797,39 @@ <H2><A NAME="ss5.7">5.7</A> <A HREF="#toc5.7">Techniques</A>
17961797
techniques.</P>
17971798

17981799

1800+
<H3>SQL injection techniques to test for</H3>
1801+
1802+
<P>Switch: <CODE>-</CODE><CODE>-technique</CODE></P>
1803+
1804+
<P>This switch can be used to specify which SQL injection type to test for.
1805+
By default sqlmap tests for <B>all</B> types/techniques it supports.</P>
1806+
1807+
<P>In certain situations you may want to test only for one or few specific
1808+
types of SQL injection thought and this is where this switch comes into
1809+
play.</P>
1810+
1811+
<P>This switch requires an argument. Such argument is a string composed by
1812+
any combination of <CODE>B</CODE>, <CODE>E</CODE>, <CODE>U</CODE>, <CODE>S</CODE> and
1813+
<CODE>T</CODE> characters where each letter stands for a different technique:</P>
1814+
<P>
1815+
<UL>
1816+
<LI><CODE>B</CODE>: Boolean-based blind SQL injection</LI>
1817+
<LI><CODE>E</CODE>: Error-based SQL injection</LI>
1818+
<LI><CODE>U</CODE>: UNION query SQL injection</LI>
1819+
<LI><CODE>S</CODE>: Stacked queries SQL injection</LI>
1820+
<LI><CODE>T</CODE>: Time-based blind SQL injection</LI>
1821+
</UL>
1822+
</P>
1823+
1824+
<P>For instance, you can provide <CODE>ES</CODE> if you want to test for and
1825+
exploit error-based and stacked queries SQL injection types only.
1826+
The default value is <CODE>BEUST</CODE>.</P>
1827+
1828+
<P>Note that the string must include stacked queries technique letter,
1829+
<CODE>S</CODE>, when you want to access the file system, takeover the
1830+
operating system or access Windows registry hives.</P>
1831+
1832+
17991833
<H3>Seconds to delay the DBMS response for time-based blind SQL injection</H3>
18001834

18011835
<P>Switch: <CODE>-</CODE><CODE>-time-sec</CODE></P>

doc/README.pdf

1.39 KB
Binary file not shown.

doc/README.sgml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,36 @@ techniques.
17911791
Switch: <tt>-</tt><tt>-technique</tt>
17921792

17931793
<p>
1794-
TODO
1794+
This switch can be used to specify which SQL injection type to test for.
1795+
By default sqlmap tests for <bf>all</bf> types/techniques it supports.
1796+
1797+
<p>
1798+
In certain situations you may want to test only for one or few specific
1799+
types of SQL injection thought and this is where this switch comes into
1800+
play.
1801+
1802+
<p>
1803+
This switch requires an argument. Such argument is a string composed by
1804+
any combination of <tt>B</tt>, <tt>E</tt>, <tt>U</tt>, <tt>S</tt> and
1805+
<tt>T</tt> characters where each letter stands for a different technique:
1806+
1807+
<itemize>
1808+
<item><tt>B</tt>: Boolean-based blind SQL injection
1809+
<item><tt>E</tt>: Error-based SQL injection
1810+
<item><tt>U</tt>: UNION query SQL injection
1811+
<item><tt>S</tt>: Stacked queries SQL injection
1812+
<item><tt>T</tt>: Time-based blind SQL injection
1813+
</itemize>
1814+
1815+
<p>
1816+
For instance, you can provide <tt>ES</tt> if you want to test for and
1817+
exploit error-based and stacked queries SQL injection types only.
1818+
The default value is <tt>BEUST</tt>.
1819+
1820+
<p>
1821+
Note that the string must include stacked queries technique letter,
1822+
<tt>S</tt>, when you want to access the file system, takeover the
1823+
operating system or access Windows registry hives.
17951824

17961825

17971826
<sect2>Seconds to delay the DBMS response for time-based blind SQL injection

lib/core/option.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from lib.controller.checks import checkConnection
2828
from lib.core.common import Backend
2929
from lib.core.common import dataToStdout
30+
from lib.core.common import getPublicTypeMembers
3031
from lib.core.common import extractRegexResult
3132
from lib.core.common import filterStringValue
3233
from lib.core.common import getConsoleWidth
@@ -605,8 +606,22 @@ def __setOS():
605606
raise sqlmapUnsupportedDBMSException, errMsg
606607

607608
def __setTechnique():
608-
if not conf.tech or not isinstance(conf.tech, int):
609-
conf.tech = []
609+
validTechniques = getPublicTypeMembers(PAYLOAD.TECHNIQUE)
610+
selTechniques = []
611+
612+
if conf.tech and isinstance(conf.tech, basestring):
613+
for t in conf.tech:
614+
if t.upper() not in ("B", "E", "U", "S", "T"):
615+
errMsg = "value for --technique must be a string composed "
616+
errMsg += "by the letters B, E, U, S and T. Refer to the "
617+
errMsg += "user's manual for details"
618+
raise sqlmapSyntaxException, errMsg
619+
620+
for validTech, validInt in validTechniques:
621+
if t.upper() == validTech[0]:
622+
selTechniques.append(validInt)
623+
break
624+
conf.tech = selTechniques
610625
else:
611626
conf.tech = filter(lambda x: x in PAYLOAD.SQLINJECTION, [int(c) for c in str(conf.tech)])
612627

@@ -617,7 +632,7 @@ def __setTechnique():
617632
'osCmd', 'osShell', 'osPwn', 'osSmb', 'osBof', 'regRead', \
618633
'regAdd', 'regDel'])) and PAYLOAD.TECHNIQUE.STACKED not in conf.tech:
619634
errMsg = "value for --technique must include stacked queries "
620-
errMsg += "technique (4) when you want to access the file "
635+
errMsg += "technique (S) when you want to access the file "
621636
errMsg += "system, takeover the operating system or access "
622637
errMsg += "Windows registry hives"
623638
raise sqlmapSyntaxException, errMsg

lib/core/optiondict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171

7272
"Techniques": {
73-
"tech": "integer",
73+
"tech": "string",
7474
"timeSec": "integer",
7575
"uCols": "string",
7676
"uChar": "string"

lib/parse/cmdline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ def cmdLineParser():
207207
"used to tweak testing of specific SQL "
208208
"injection techniques.")
209209

210-
techniques.add_option("--technique", dest="tech", type="int",
211-
default=0, help="SQL injection techniques to "
212-
"test for (default all)")
210+
techniques.add_option("--technique", dest="tech", default="BEUST",
211+
help="SQL injection techniques to test for "
212+
"(default BEUST)")
213213

214214
techniques.add_option("--time-sec", dest="timeSec",
215215
type="int", default=TIME_DEFAULT_DELAY,

sqlmap.conf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,16 @@ textOnly = False
224224
[Techniques]
225225

226226
# SQL injection techniques to test for.
227-
# Valid: an integer composed by 1, 2, 3, 4 or 5 where:
228-
# 1: boolean-based blind SQL injection
229-
# 2: error-based SQL injection
230-
# 3: UNION query SQL injection
231-
# 4: stacked queries SQL injection
232-
# 5: time-based blind SQL injection
233-
# Example: 24 (means test for error-based and stacked queries SQL
227+
# Valid: a string composed by B, E, U, S and T where:
228+
# B: Boolean-based blind SQL injection
229+
# E: Error-based SQL injection
230+
# U: UNION query SQL injection
231+
# S: Stacked queries SQL injection
232+
# T: Time-based blind SQL injection
233+
# Example: ES (means test for error-based and stacked queries SQL
234234
# injection types only)
235-
# Default: 0 (means test for all SQL injection types - recommended)
236-
tech = 0
235+
# Default: BEUST (means test for all SQL injection types - recommended)
236+
tech = BEUST
237237

238238
# Seconds to delay the response from the DBMS.
239239
# Valid: integer

0 commit comments

Comments
 (0)