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

Skip to content

Commit 7b4ecd9

Browse files
committed
added skeleton code for issue #34, still not usable
1 parent 4736d46 commit 7b4ecd9

5 files changed

Lines changed: 37 additions & 3 deletions

File tree

lib/core/option.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,28 @@ def __findPageForms():
558558

559559
findPageForms(page, conf.url, True, True)
560560

561+
def __setDBMSAuthentication():
562+
"""
563+
Check and set the DBMS authentication credentials to run statements as
564+
another user, not the session user
565+
"""
566+
567+
if not conf.dCred:
568+
return
569+
570+
debugMsg = "setting the DBMS authentication credentials"
571+
logger.debug(debugMsg)
572+
573+
dCredRegExp = re.search("^(.+?):(.*?)$", conf.dCred)
574+
575+
if not dCredRegExp:
576+
errMsg = "DBMS authentication credentials value must be in format "
577+
errMsg += "username:password"
578+
raise sqlmapSyntaxException, errMsg
579+
580+
conf.dbmsUsername = dCredRegExp.group(1)
581+
conf.dbmsPassword = dCredRegExp.group(2)
582+
561583
def __setMetasploit():
562584
if not conf.osPwn and not conf.osSmb and not conf.osBof:
563585
return
@@ -1992,7 +2014,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
19922014
__setOS()
19932015
__setWriteFile()
19942016
__setMetasploit()
1995-
2017+
__setDBMSAuthentication()
19962018
loadPayloads()
19972019
__setPrefixSuffix()
19982020
update()

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"checkTor": "boolean",
168168
"crawlDepth": "integer",
169169
"csvDel": "string",
170+
"dCred": "string",
170171
"eta": "boolean",
171172
"flushSession": "boolean",
172173
"forms": "boolean",

lib/parse/cmdline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,13 @@ def cmdLineParser():
516516
help="Delimiting character used in CSV output "
517517
"(default \"%s\")" % defaults.csvDel)
518518

519+
general.add_option("--dbms-cred", dest="dCred",
520+
help="DBMS authentication credentials (user:password)")
521+
519522
general.add_option("--eta", dest="eta",
520523
action="store_true",
521524
help="Display for each output the "
522-
"estimated time of arrival")
525+
"estimated time of arrival")
523526

524527
general.add_option("--flush-session", dest="flushSession",
525528
action="store_true",

lib/request/inject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def goStacked(expression, silent=False):
479479
return direct(expression)
480480

481481
comment = queries[Backend.getIdentifiedDbms()].comment.query
482-
query = agent.prefixQuery("; %s" % expression)
482+
query = agent.prefixQuery(";%s" % expression)
483483
query = agent.suffixQuery("%s;%s" % (query, comment))
484484
payload = agent.payload(newValue=query)
485485
Request.queryPage(payload, content=False, silent=silent, noteResponseTime=False, timeBasedCompare=True)

sqlmap.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,14 @@ crawlDepth = 0
567567
# Default: ,
568568
csvDel = ,
569569

570+
# DBMS authentication credentials (user:password). Useful if you want to
571+
# run SQL statements as another user, the back-end database management
572+
# system is PostgreSQL or Microsoft SQL Server and the parameter is
573+
# vulnerable by stacked queries SQL injection or you are connecting directly
574+
# to the DBMS (-d switch).
575+
# Syntax: username:password
576+
dCred =
577+
570578
# Retrieve each query output length and calculate the estimated time of
571579
# arrival in real time.
572580
# Valid: True or False

0 commit comments

Comments
 (0)