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

Skip to content

Commit 3127d5b

Browse files
committed
Initial support for #25 (and #1387)
1 parent 9043d9d commit 3127d5b

5 files changed

Lines changed: 32 additions & 2 deletions

File tree

lib/core/agent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8+
import base64
89
import re
910

1011
from lib.core.common import Backend
@@ -164,6 +165,11 @@ def payload(self, place=None, parameter=None, value=None, newValue=None, where=N
164165

165166
newValue = self.cleanupPayload(newValue, origValue)
166167

168+
if re.sub(r" \(.+", "", parameter) in conf.base64Parameter:
169+
# TODO: support for POST_HINT
170+
newValue = base64.b64encode(newValue)
171+
origValue = base64.b64encode(origValue)
172+
167173
if place in (PLACE.URI, PLACE.CUSTOM_POST, PLACE.CUSTOM_HEADER):
168174
_ = "%s%s" % (origValue, kb.customInjectionMark)
169175
if kb.postHint == POST_HINT.JSON and not isNumber(newValue) and not '"%s"' % _ in paramString:

lib/core/common.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,20 @@ def paramToDict(place, parameters=None):
603603
condition |= place == PLACE.COOKIE and len(intersect((PLACE.COOKIE,), conf.testParameter, True)) > 0
604604

605605
if condition:
606-
testableParameters[parameter] = "=".join(parts[1:])
606+
value = "=".join(parts[1:])
607+
608+
if parameter in (conf.base64Parameter or []):
609+
try:
610+
oldValue = value
611+
value = value.decode("base64")
612+
parameters = re.sub(r"\b%s\b" % re.escape(oldValue), value, parameters)
613+
except:
614+
errMsg = "parameter '%s' does not contain " % parameter
615+
errMsg += "valid Base64 encoded value ('%s')" % value
616+
raise SqlmapValueException(errMsg)
617+
618+
testableParameters[parameter] = value
619+
607620
if not conf.multipleTargets and not (conf.csrfToken and re.search(conf.csrfToken, parameter, re.I)):
608621
_ = urldecode(testableParameters[parameter], convall=True)
609622
if (_.endswith("'") and _.count("'") == 1 or re.search(r'\A9{3,}', _) or re.search(r'\A-\d+\Z', _) or re.search(DUMMY_USER_INJECTION, _)) and not parameter.upper().startswith(GOOGLE_ANALYTICS_COOKIE_PREFIX):

lib/core/option.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,13 @@ def _cleanupOptions():
16131613
else:
16141614
conf.testParameter = []
16151615

1616+
if conf.base64Parameter:
1617+
conf.base64Parameter = urldecode(conf.base64Parameter)
1618+
conf.base64Parameter = conf.base64Parameter.replace(" ", "")
1619+
conf.base64Parameter = re.split(PARAMETER_SPLITTING_REGEX, conf.base64Parameter)
1620+
else:
1621+
conf.base64Parameter = []
1622+
16161623
if conf.agent:
16171624
conf.agent = re.sub(r"[\r\n]", "", conf.agent)
16181625

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

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

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,10 @@ def cmdLineParser(argv=None):
681681
help="Simple wizard interface for beginner users")
682682

683683
# Hidden and/or experimental options
684+
parser.add_option("--base64", dest="base64Parameter",
685+
help=SUPPRESS_HELP)
686+
# help="Parameter(s) containing Base64 encoded values")
687+
684688
parser.add_option("--crack", dest="hashFile",
685689
help=SUPPRESS_HELP)
686690
# help="Load and crack hashes from a file (standalone)")

0 commit comments

Comments
 (0)