Skip to content

Commit b528fc0

Browse files
committed
Update for sqlmapproject#4928
1 parent 25d6479 commit b528fc0

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
21162116
kb.pageStable = None
21172117
kb.partRun = None
21182118
kb.permissionFlag = False
2119+
kb.place = None
21192120
kb.postHint = None
21202121
kb.postSpaceToPlus = False
21212122
kb.postUrlEncode = True

lib/core/settings.py

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

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

lib/core/target.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
from lib.core.common import removePostHintPrefix
2727
from lib.core.common import resetCookieJar
2828
from lib.core.common import safeStringFormat
29+
from lib.core.common import unArrayizeValue
2930
from lib.core.common import urldecode
3031
from lib.core.compat import xrange
32+
from lib.core.convert import decodeBase64
3133
from lib.core.convert import getUnicode
3234
from lib.core.data import conf
3335
from lib.core.data import kb
@@ -741,6 +743,15 @@ class _(six.text_type):
741743
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
742744
kb.postSpaceToPlus = '+' in original
743745

746+
if conf.data and unArrayizeValue(conf.base64Parameter) == HTTPMETHOD.POST:
747+
if '=' not in conf.data.strip('='):
748+
try:
749+
original = conf.data
750+
conf.data = _(decodeBase64(conf.data, binary=False))
751+
setattr(conf.data, UNENCODED_ORIGINAL_VALUE, original)
752+
except:
753+
pass
754+
744755
match = re.search(INJECT_HERE_REGEX, "%s %s %s" % (conf.url, conf.data, conf.httpHeaders))
745756
kb.customInjectionMark = match.group(0) if match else CUSTOM_INJECTION_MARK_CHAR
746757

lib/core/testing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def vulnTest():
6565
("-u <url> --flush-session --banner --invalid-logical --technique=B --predict-output --test-filter=\"OR boolean\" --tamper=space2dash", ("banner: '3.", " LIKE ")),
6666
("-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 ")),
6767
("-u <url> --flush-session --null-connection --technique=B --tamper=between,randomcase --banner --count -T users", ("NULL connection is supported with HEAD method", "banner: '3.", "users | 5")),
68+
("-u <base> --data=\"aWQ9MQ==\" --flush-session --base64=POST -v 6", ("aWQ9MTtXQUlURk9SIERFTEFZICcwOjA",)),
6869
("-u <url> --flush-session --parse-errors --test-filter=\"subquery\" --eval=\"import hashlib; id2=2; id3=hashlib.md5(id.encode()).hexdigest()\" --referer=\"localhost\"", ("might be injectable", ": syntax error", "back-end DBMS: SQLite", "WHERE or HAVING clause (subquery")),
6970
("-u <url> --banner --schema --dump -T users --binary-fields=surname --where \"id>3\"", ("banner: '3.", "INTEGER", "TEXT", "id", "name", "surname", "2 entries", "6E616D6569736E756C6C")),
7071
("-u <url> --technique=U --fresh-queries --force-partial --dump -T users --dump-format=HTML --answers=\"crack=n\" -v 3", ("performed 6 queries", "nameisnull", "~using default dictionary", "dumped to HTML file")),

lib/request/connect.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ class WebSocketException(Exception):
5656
from lib.core.common import singleTimeLogMessage
5757
from lib.core.common import singleTimeWarnMessage
5858
from lib.core.common import stdev
59+
from lib.core.common import unArrayizeValue
5960
from lib.core.common import unsafeVariableNaming
6061
from lib.core.common import urldecode
6162
from lib.core.common import urlencode
6263
from lib.core.common import wasLastResponseDelayed
6364
from lib.core.compat import patchHeaders
6465
from lib.core.compat import xrange
66+
from lib.core.convert import encodeBase64
6567
from lib.core.convert import getBytes
6668
from lib.core.convert import getText
6769
from lib.core.convert import getUnicode
@@ -466,7 +468,7 @@ def getPage(**kwargs):
466468
break
467469

468470
if post is not None and not multipart and not getHeader(headers, HTTP_HEADER.CONTENT_TYPE):
469-
headers[HTTP_HEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE)
471+
headers[HTTP_HEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE if unArrayizeValue(conf.base64Parameter) != HTTPMETHOD.POST else PLAIN_TEXT_CONTENT_TYPE)
470472

471473
if headers.get(HTTP_HEADER.CONTENT_TYPE) == POST_HINT_CONTENT_TYPES[POST_HINT.MULTIPART]:
472474
warnMsg = "missing 'boundary parameter' in '%s' header. " % HTTP_HEADER.CONTENT_TYPE
@@ -552,6 +554,13 @@ class _(dict):
552554
else:
553555
post = getBytes(post)
554556

557+
if unArrayizeValue(conf.base64Parameter) == HTTPMETHOD.POST:
558+
if kb.place != HTTPMETHOD.POST:
559+
conf.data = getattr(conf.data, UNENCODED_ORIGINAL_VALUE, conf.data)
560+
else:
561+
post = urldecode(post, convall=True)
562+
post = encodeBase64(post)
563+
555564
if target and cmdLineOptions.method or method and method not in (HTTPMETHOD.GET, HTTPMETHOD.POST):
556565
req = MethodRequest(url, post, headers)
557566
req.set_method(cmdLineOptions.method or method)
@@ -976,6 +985,8 @@ def queryPage(value=None, place=None, content=False, getRatioValue=False, silent
976985
if not place:
977986
place = kb.injection.place or PLACE.GET
978987

988+
kb.place = place
989+
979990
if not auxHeaders:
980991
auxHeaders = {}
981992

@@ -1191,7 +1202,7 @@ def _adjustParameter(paramString, parameter, newValue):
11911202

11921203
if not token:
11931204
if conf.csrfUrl and conf.csrfToken and conf.csrfUrl != conf.url and code == _http_client.OK:
1194-
if headers and "text/plain" in headers.get(HTTP_HEADER.CONTENT_TYPE, ""):
1205+
if headers and PLAIN_TEXT_CONTENT_TYPE in headers.get(HTTP_HEADER.CONTENT_TYPE, ""):
11951206
token.name = conf.csrfToken
11961207
token.value = page
11971208

0 commit comments

Comments
 (0)