Skip to content

Commit 160011b

Browse files
committed
Couple of bug fixes
1 parent 36ee4d6 commit 160011b

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

extra/vulnserver/vulnserver.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def do_REQUEST(self):
129129
self.url, self.params = path, params
130130

131131
if self.url == '/':
132-
133132
if not any(_ in self.params for _ in ("id", "query")):
134133
self.send_response(OK)
135134
self.send_header("Content-type", "text/html; charset=%s" % UNICODE_ENCODING)
@@ -158,18 +157,22 @@ def do_REQUEST(self):
158157

159158
output += "<b>SQL results:</b><br>\n"
160159

161-
if results:
162-
output += "<table border=\"1\">\n"
160+
if self.params.get("code", ""):
161+
if not results:
162+
code = INTERNAL_SERVER_ERROR
163+
else:
164+
if results:
165+
output += "<table border=\"1\">\n"
163166

164-
for row in results:
165-
output += "<tr>"
166-
for value in row:
167-
output += "<td>%s</td>" % value
168-
output += "</tr>\n"
167+
for row in results:
168+
output += "<tr>"
169+
for value in row:
170+
output += "<td>%s</td>" % value
171+
output += "</tr>\n"
169172

170-
output += "</table>\n"
171-
else:
172-
output += "no results found"
173+
output += "</table>\n"
174+
else:
175+
output += "no results found"
173176

174177
output += "</body></html>"
175178
except Exception as ex:
@@ -196,7 +199,7 @@ def do_GET(self):
196199
self.do_REQUEST()
197200

198201
def do_PUT(self):
199-
self.do_REQUEST()
202+
self.do_POST()
200203

201204
def do_HEAD(self):
202205
self.do_REQUEST()

lib/controller/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def genCmpPayload():
529529
truePage, trueHeaders, trueCode = threadData.lastComparisonPage or "", threadData.lastComparisonHeaders, threadData.lastComparisonCode
530530
trueRawResponse = "%s%s" % (trueHeaders, truePage)
531531

532-
if trueResult and not(truePage == falsePage and not kb.nullConnection):
532+
if trueResult and not(truePage == falsePage and not any((kb.nullConnection, conf.code))):
533533
# Perform the test's False request
534534
falseResult = Request.queryPage(genCmpPayload(), place, raise404=False)
535535

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.5.2.2"
21+
VERSION = "1.5.2.3"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/testing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def vulnTest():
4141
("-h", ("to see full list of options run with '-hh'",)),
4242
("--dependencies --deprecations", ("sqlmap requires", "third-party library", "~DeprecationWarning:")),
4343
("-u <url> --data='reflect=1' --flush-session --wizard", ("Please choose:", "back-end DBMS: SQLite", "current user is DBA: True", "banner: '3.")),
44+
("-u <url> --data='code=1' --code=200 --technique=B --banner --flush-session", ("back-end DBMS: SQLite", "banner: '3.")),
4445
(u"-c <config> --flush-session --smart --roles --statements --hostname --privileges --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=U", (u": '\u0161u\u0107uraj'", "on SQLite it is not possible")),
4546
(u"-u <url> --flush-session --sql-query=\"SELECT '\u0161u\u0107uraj'\" --technique=B --no-escape --string=luther --unstable", (u": '\u0161u\u0107uraj'",)),
4647
("--dummy", ("all tested parameters do not appear to be injectable", "does not seem to be injectable", "there is not at least one", "~might be injectable")),
@@ -51,15 +52,15 @@ def vulnTest():
5152
("<piped> -r <request> -l <log> --flush-session --banner --technique=B", ("banner: '3.", "STDIN")),
5253
("-l <log> --flush-session --keep-alive --skip-waf -v 5 --technique=U --union-from=users --banner --parse-errors", ("banner: '3.", "ORDER BY term out of range", "~xp_cmdshell", "Connection: keep-alive")),
5354
("-l <log> --offline --banner -v 5", ("banner: '3.", "~[TRAFFIC OUT]")),
54-
("-u <url> --flush-session --data='id=1&_=Eewef6oh' --chunked --randomize=_ --random-agent --banner", ("fetched random HTTP User-Agent header value", "Parameter: id (POST)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.")),
55+
("-u <base> --flush-session --data='id=1&_=Eewef6oh' --chunked --randomize=_ --random-agent --banner", ("fetched random HTTP User-Agent header value", "Parameter: id (POST)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.")),
5556
("-u <base64> -p id --base64=id --data='base64=true' --flush-session --banner --technique=B", ("banner: '3.",)),
5657
("-u <base64> -p id --base64=id --data='base64=true' --flush-session --tables --technique=U", (" users ",)),
5758
("-u <url> --flush-session --banner --technique=B --not-string 'no results'", ("banner: '3.",)),
5859
("-u <url> --flush-session --banner --technique=B --first=1 --last=2", ("banner: '3.'",)),
5960
("-u <url> --flush-session --encoding=ascii --forms --crawl=2 --threads=2 --banner", ("total of 2 targets", "might be injectable", "Type: UNION query", "banner: '3.")),
60-
("-u <url> --flush-session --data='{\"id\": 1}' --banner", ("might be injectable", "3 columns", "Payload: {\"id\"", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.")),
61-
("-u <url> --flush-session -H 'Foo: Bar' -H 'Sna: Fu' --data='<root><param name=\"id\" value=\"1*\"/></root>' --union-char=1 --mobile --answers='smartphone=3' --banner --smart -v 5", ("might be injectable", "Payload: <root><param name=\"id\" value=\"1", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.", "Nexus", "Sna: Fu", "Foo: Bar")),
62-
("-u <url> --flush-session --method=PUT --data='a=1&b=2&c=3&id=1' --skip-static --har=<tmp> --dump -T users --start=1 --stop=2", ("might be injectable", "Parameter: id (PUT)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "2 entries")),
61+
("-u <base> --flush-session --data='{\"id\": 1}' --banner", ("might be injectable", "3 columns", "Payload: {\"id\"", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.")),
62+
("-u <base> --flush-session -H 'Foo: Bar' -H 'Sna: Fu' --data='<root><param name=\"id\" value=\"1*\"/></root>' --union-char=1 --mobile --answers='smartphone=3' --banner --smart -v 5", ("might be injectable", "Payload: <root><param name=\"id\" value=\"1", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "banner: '3.", "Nexus", "Sna: Fu", "Foo: Bar")),
63+
("-u <base> --flush-session --method=PUT --data='a=1;id=1;b=2' --param-del=';' --skip-static --har=<tmp> --dump -T users --start=1 --stop=2", ("might be injectable", "Parameter: id (PUT)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", "2 entries")),
6364
("-u <url> --flush-session -H 'id: 1*' --tables -t <tmp>", ("might be injectable", "Parameter: id #1* ((custom) HEADER)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", " users ")),
6465
("-u <url> --flush-session --banner --invalid-logical --technique=B --predict-output --test-filter='OR boolean' --tamper=space2dash", ("banner: '3.", " LIKE ")),
6566
("-u <url> --flush-session --cookie=\"PHPSESSID=d41d8cd98f00b204e9800998ecf8427e; id=1*; id2=2\" --tables --union-cols=3", ("might be injectable", "Cookie #1* ((custom) HEADER)", "Type: boolean-based blind", "Type: time-based blind", "Type: UNION query", " users ")),
@@ -121,7 +122,8 @@ def _thread():
121122
open(request, "w+").write(content)
122123
open(log, "w+").write('<port>%d</port><request base64="true"><![CDATA[%s]]></request>' % (port, encodeBase64(content, binary=False)))
123124

124-
url = "http://%s:%d/?id=1" % (address, port)
125+
base = "http://%s:%d/" % (address, port)
126+
url = "%s?id=1" % base
125127
direct = "sqlite3://%s" % database
126128

127129
content = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.conf"))).read().replace("url =", "url = %s" % url)
@@ -131,7 +133,7 @@ def _thread():
131133
status = '%d/%d (%d%%) ' % (count, len(TESTS), round(100.0 * count / len(TESTS)))
132134
dataToStdout("\r[%s] [INFO] complete: %s" % (time.strftime("%X"), status))
133135

134-
for tag, value in (("<url>", url), ("<direct>", direct), ("<request>", request), ("<log>", log), ("<config>", config), ("<base64>", url.replace("id=1", "id=MZ=%3d"))):
136+
for tag, value in (("<url>", url), ("<base>", base), ("<direct>", direct), ("<request>", request), ("<log>", log), ("<config>", config), ("<base64>", url.replace("id=1", "id=MZ=%3d"))):
135137
options = options.replace(tag, value)
136138

137139
cmd = "%s \"%s\" %s --batch --non-interactive --debug" % (sys.executable, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "sqlmap.py")), options)

0 commit comments

Comments
 (0)