Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf2a857

Browse files
committed
Minor adjustments and minor bug fixes. Documentation almost complete for sqlmap 0.6.3.
1 parent 072eb71 commit bf2a857

12 files changed

Lines changed: 2098 additions & 991 deletions

File tree

doc/README.html

Lines changed: 1012 additions & 496 deletions
Large diffs are not rendered by default.

doc/README.pdf

21.1 KB
Binary file not shown.

doc/README.sgml

Lines changed: 985 additions & 478 deletions
Large diffs are not rendered by default.

extra/msfauxmod/README.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ To use Metasploit's sqlmap auxiliary module launch msfconsole and follow
22
the example below.
33

44
Note that if you are willing to run Metasploit's sqlmap auxiliary module on
5-
Metasploit Framework 3.0 or 3.1 you first need to copy wmap_sqlmap.rb to
6-
your <msf3 root path>/modules/auxiliary/scanner/http/ folder then launch
7-
msfconsole because this module has been officially integrated in Metasploit
8-
from the release 3.2.
5+
through WMAP framework you first need to install sqlmap on your system or
6+
add its file system path to the PATH environment variable.
7+
98

109
$ ./msfconsole
1110

lib/controller/checks.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626

27+
import re
2728
import time
2829

2930
from lib.controller.action import action
@@ -35,6 +36,7 @@
3536
from lib.core.data import logger
3637
from lib.core.exception import sqlmapConnectionException
3738
from lib.core.session import setString
39+
from lib.core.session import setRegexp
3840
from lib.request.connect import Connect as Request
3941

4042

@@ -337,6 +339,38 @@ def checkString():
337339
return False
338340

339341

342+
def checkRegexp():
343+
if not conf.regexp:
344+
return True
345+
346+
condition = (
347+
kb.resumedQueries.has_key(conf.url) and
348+
kb.resumedQueries[conf.url].has_key("Regular expression") and
349+
kb.resumedQueries[conf.url]["Regular expression"][:-1] == conf.regexp
350+
)
351+
352+
if condition:
353+
return True
354+
355+
infoMsg = "testing if the provided regular expression matches within "
356+
infoMsg += "the target URL page content"
357+
logger.info(infoMsg)
358+
359+
page = Request.queryPage(content=True)
360+
361+
if re.search(conf.regexp, page, re.I | re.M):
362+
setRegexp()
363+
return True
364+
else:
365+
errMsg = "you provided '%s' as the regular expression to " % conf.regexp
366+
errMsg += "match, but such a regular expression does not have any "
367+
errMsg += "match within the target URL page content, please provide "
368+
errMsg += "another regular expression."
369+
logger.error(errMsg)
370+
371+
return False
372+
373+
340374
def checkConnection():
341375
infoMsg = "testing connection to the target url"
342376
logger.info(infoMsg)

lib/controller/controller.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from lib.controller.checks import checkDynParam
3030
from lib.controller.checks import checkStability
3131
from lib.controller.checks import checkString
32+
from lib.controller.checks import checkRegexp
3233
from lib.controller.checks import checkConnection
3334
from lib.core.common import paramToDict
3435
from lib.core.common import readInput
@@ -117,7 +118,7 @@ def start():
117118

118119
if conf.multipleTargets:
119120
hostCount += 1
120-
message = "url %d:\n%s %s" % (hostCount, conf.method, targetUrl)
121+
message = "url %d:\n%s %s" % (hostCount, conf.method or "GET", targetUrl)
121122

122123
if conf.cookie:
123124
message += "\nCookie: %s" % conf.cookie
@@ -140,7 +141,7 @@ def start():
140141

141142
initTargetEnv()
142143

143-
if not checkConnection() or not checkString():
144+
if not checkConnection() or not checkString() or not checkRegexp():
144145
continue
145146

146147
for _, cookie in enumerate(conf.cj):
@@ -173,14 +174,14 @@ def start():
173174
__testableParameters = True
174175

175176
if not kb.injPlace or not kb.injParameter or not kb.injType:
176-
if not conf.string:
177+
if not conf.string and not conf.regexp and not conf.eRegexp:
177178
if checkStability():
178179
logMsg = "url is stable"
179180
logger.info(logMsg)
180181
else:
181-
errMsg = "url is not stable, try with --string option, refer "
182-
errMsg += "to the user's manual paragraph 'String match' "
183-
errMsg += "for details"
182+
errMsg = "url is not stable, try with --string or "
183+
errMsg += "--regexp options, refer to the user's manual "
184+
errMsg += "paragraph 'Page comparison' for details"
184185

185186
if conf.multipleTargets:
186187
errMsg += ", skipping to next url"
@@ -214,7 +215,6 @@ def start():
214215

215216
if injType:
216217
injData.append((place, parameter, injType))
217-
kb.parenthesis = parenthesis
218218

219219
break
220220
else:

lib/core/session.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ def setString():
4848
dataToSessionFile("[%s][None][None][String][%s]\n" % (conf.url, conf.string))
4949

5050

51+
def setRegexp():
52+
"""
53+
Save regular expression to match in session file.
54+
"""
55+
56+
condition = (
57+
not kb.resumedQueries or ( kb.resumedQueries.has_key(conf.url) and
58+
not kb.resumedQueries[conf.url].has_key("Regular expression") )
59+
)
60+
61+
if condition:
62+
dataToSessionFile("[%s][None][None][Regular expression][%s]\n" % (conf.url, conf.regexp))
63+
64+
5165
def setInjection():
5266
"""
5367
Save information retrieved about injection place and parameter in the
@@ -178,6 +192,28 @@ def resumeConfKb(expression, url, value):
178192
if not test or test[0] in ("y", "Y"):
179193
conf.string = string
180194

195+
elif expression == "Regular expression" and url == conf.url:
196+
regexp = value[:-1]
197+
198+
logMsg = "resuming regular expression match '%s' from session file" % regexp
199+
logger.info(logMsg)
200+
201+
if regexp and ( not conf.regexp or regexp != conf.regexp ):
202+
if not conf.regexp:
203+
message = "you did not provide any regular expression "
204+
message += "to match. "
205+
else:
206+
message = "The regular expression you provided does not "
207+
message += "match the resumed regular expression. "
208+
209+
message += "Do you want to use the resumed regular expression "
210+
message += "to be matched in page when the query "
211+
message += "is valid? [Y/n] "
212+
test = readInput(message, default="Y")
213+
214+
if not test or test[0] in ("y", "Y"):
215+
conf.regexp = regexp
216+
181217
elif expression == "Injection point" and url == conf.url:
182218
injPlace = value[:-1]
183219

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
# sqlmap version and site
33-
VERSION = "0.6.3-rc5"
33+
VERSION = "0.6.3"
3434
VERSION_STRING = "sqlmap/%s" % VERSION
3535
SITE = "http://sqlmap.sourceforge.net"
3636

lib/parse/cmdline.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525

2626

27+
import sys
28+
2729
from optparse import OptionError
2830
from optparse import OptionGroup
2931
from optparse import OptionParser
@@ -37,7 +39,7 @@ def cmdLineParser():
3739
This function parses the command line parameters and arguments
3840
"""
3941

40-
usage = "sqlmap.py [options]"
42+
usage = "%s [options]" % sys.argv[0]
4143
parser = OptionParser(usage=usage, version=VERSION_STRING)
4244

4345
try:
@@ -108,7 +110,12 @@ def cmdLineParser():
108110

109111

110112
# Injection options
111-
injection = OptionGroup(parser, "Injection")
113+
injection = OptionGroup(parser, "Injection", "These options can be "
114+
"used to specify which parameters to test "
115+
"for, provide custom injection payloads and "
116+
"how to parse and compare HTTP responses "
117+
"page content when using the blind SQL "
118+
"injection technique.")
112119

113120
injection.add_option("-p", dest="testParameter",
114121
help="Testable parameter(s)")

lib/utils/parenthesis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ def checkForParenthesis():
4646

4747
count = 0
4848

49+
if kb.parenthesis != None:
50+
return
51+
4952
if conf.prefix or conf.postfix:
53+
kb.parenthesis = 0
5054
return
5155

5256
for parenthesis in range(1, 4):

0 commit comments

Comments
 (0)