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

Skip to content

Commit a711c9e

Browse files
committed
Minor cleanup and initial work for #58
1 parent 4beef09 commit a711c9e

7 files changed

Lines changed: 40 additions & 30 deletions

File tree

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,7 @@ def maskSensitiveData(msg):
27682768

27692769
retVal = msg
27702770

2771-
for item in filter(None, map(lambda x: conf.get(x), ("hostname", "googleDork", "aCred", "pCred", "tbl", "db", "col", "user", "cookie", "proxy"))):
2771+
for item in filter(None, map(lambda x: conf.get(x), ("hostname", "googleDork", "authCred", "proxyCred", "tbl", "db", "col", "user", "cookie", "proxy"))):
27722772
regex = SENSITIVE_DATA_REGEX % re.sub("(\W)", r"\\\1", item)
27732773
while extractRegexResult(regex, retVal):
27742774
value = extractRegexResult(regex, retVal)

lib/core/option.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _urllib2Opener():
180180
if conf.proxy:
181181
warnMsg += "with HTTP(s) proxy"
182182
logger.warn(warnMsg)
183-
elif conf.aType:
183+
elif conf.authType:
184184
warnMsg += "with authentication methods"
185185
logger.warn(warnMsg)
186186
else:
@@ -1011,8 +1011,8 @@ def _setHTTPProxy():
10111011
errMsg = "proxy value must be in format '(%s)://url:port'" % "|".join(_[0].lower() for _ in getPublicTypeMembers(PROXY_TYPE))
10121012
raise SqlmapSyntaxException(errMsg)
10131013

1014-
if conf.pCred:
1015-
_ = re.search("^(.*?):(.*?)$", conf.pCred)
1014+
if conf.proxyCred:
1015+
_ = re.search("^(.*?):(.*?)$", conf.proxyCred)
10161016
if not _:
10171017
errMsg = "Proxy authentication credentials "
10181018
errMsg += "value must be in format username:password"
@@ -1025,9 +1025,9 @@ def _setHTTPProxy():
10251025
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5 if scheme == PROXY_TYPE.SOCKS5 else socks.PROXY_TYPE_SOCKS4, hostname, port, username=username, password=password)
10261026
socks.wrapmodule(urllib2)
10271027
else:
1028-
if conf.pCred:
1028+
if conf.proxyCred:
10291029
# Reference: http://stackoverflow.com/questions/34079/how-to-specify-an-authenticated-proxy-for-a-python-http-connection
1030-
proxyString = "%s@" % conf.pCred
1030+
proxyString = "%s@" % conf.proxyCred
10311031
else:
10321032
proxyString = ""
10331033

@@ -1097,24 +1097,24 @@ def _setHTTPAuthentication():
10971097

10981098
global authHandler
10991099

1100-
if not conf.aType and not conf.aCred and not conf.aCert:
1100+
if not conf.authType and not conf.authCred and not conf.authCert:
11011101
return
11021102

1103-
elif conf.aType and not conf.aCred and not conf.aCert:
1103+
elif conf.authType and not conf.authCred and not conf.authCert:
11041104
errMsg = "you specified the HTTP authentication type, but "
11051105
errMsg += "did not provide the credentials"
11061106
raise SqlmapSyntaxException(errMsg)
11071107

1108-
elif not conf.aType and conf.aCred:
1108+
elif not conf.authType and conf.authCred:
11091109
errMsg = "you specified the HTTP authentication credentials, "
11101110
errMsg += "but did not provide the type"
11111111
raise SqlmapSyntaxException(errMsg)
11121112

1113-
if not conf.aCert:
1113+
if not conf.authCert:
11141114
debugMsg = "setting the HTTP authentication type and credentials"
11151115
logger.debug(debugMsg)
11161116

1117-
aTypeLower = conf.aType.lower()
1117+
aTypeLower = conf.authType.lower()
11181118

11191119
if aTypeLower not in (AUTH_TYPE.BASIC, AUTH_TYPE.DIGEST, AUTH_TYPE.NTLM, AUTH_TYPE.CERT):
11201120
errMsg = "HTTP authentication type value must be "
@@ -1133,7 +1133,7 @@ def _setHTTPAuthentication():
11331133
errMsg += "usage of option `--auth-cert`"
11341134
raise SqlmapSyntaxException(errMsg)
11351135

1136-
aCredRegExp = re.search(regExp, conf.aCred)
1136+
aCredRegExp = re.search(regExp, conf.authCred)
11371137

11381138
if not aCredRegExp:
11391139
raise SqlmapSyntaxException(errMsg)
@@ -1165,7 +1165,7 @@ def _setHTTPAuthentication():
11651165
debugMsg = "setting the HTTP(s) authentication certificate"
11661166
logger.debug(debugMsg)
11671167

1168-
aCertRegExp = re.search("^(.+?),\s*(.+?)$", conf.aCert)
1168+
aCertRegExp = re.search("^(.+?),\s*(.+?)$", conf.authCert)
11691169

11701170
if not aCertRegExp:
11711171
errMsg = "HTTP authentication certificate option "

lib/core/optiondict.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
"host": "string",
3434
"referer": "string",
3535
"headers": "string",
36-
"aType": "string",
37-
"aCred": "string",
38-
"aCert": "string",
36+
"authType": "string",
37+
"authCred": "string",
38+
"authCert": "string",
3939
"proxy": "string",
40-
"pCred": "string",
40+
"proxyCred": "string",
41+
"proxyFile": "string",
4142
"ignoreProxy": "boolean",
4243
"tor": "boolean",
4344
"torPort": "integer",

lib/parse/cmdline.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,28 @@ def cmdLineParser():
108108
request.add_option("--headers", dest="headers",
109109
help="Extra headers (e.g. \"Accept-Language: fr\\nETag: 123\")")
110110

111-
request.add_option("--auth-type", dest="aType",
111+
request.add_option("--auth-type", dest="authType",
112112
help="HTTP authentication type "
113113
"(Basic, Digest, NTLM or Cert)")
114114

115-
request.add_option("--auth-cred", dest="aCred",
115+
request.add_option("--auth-cred", dest="authCred",
116116
help="HTTP authentication credentials "
117117
"(name:password)")
118118

119-
request.add_option("--auth-cert", dest="aCert",
119+
request.add_option("--auth-cert", dest="authCert",
120120
help="HTTP authentication certificate ("
121121
"key_file,cert_file)")
122122

123123
request.add_option("--proxy", dest="proxy",
124124
help="Use a proxy to connect to the target URL")
125125

126-
request.add_option("--proxy-cred", dest="pCred",
126+
request.add_option("--proxy-cred", dest="proxyCred",
127127
help="Proxy authentication credentials "
128128
"(name:password)")
129129

130+
request.add_option("--proxy-file", dest="proxyFile",
131+
help="Load proxy list from a file")
132+
130133
request.add_option("--ignore-proxy", dest="ignoreProxy", action="store_true",
131134
help="Ignore system default proxy settings")
132135

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def getPage(**kwargs):
372372

373373
conn = urllib2.urlopen(req)
374374

375-
if not kb.authHeader and getRequestHeader(req, HTTP_HEADER.AUTHORIZATION) and conf.aType == AUTH_TYPE.BASIC:
375+
if not kb.authHeader and getRequestHeader(req, HTTP_HEADER.AUTHORIZATION) and conf.authType == AUTH_TYPE.BASIC:
376376
kb.authHeader = getRequestHeader(req, HTTP_HEADER.AUTHORIZATION)
377377

378378
if not kb.proxyAuthHeader and getRequestHeader(req, HTTP_HEADER.PROXY_AUTHORIZATION):

sqlmap.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ url =
1818
# 'conversations/' folder path
1919
logFile =
2020

21+
# Scan multiple targets enlisted in a given textual file
22+
bulkFile =
23+
2124
# Load HTTP request from a file
2225
# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme
2326
requestFile =
@@ -76,17 +79,17 @@ headers = Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
7679
# HTTP Authentication type. Useful only if the target URL requires
7780
# HTTP Basic, Digest or NTLM authentication and you have such data.
7881
# Valid: Basic, Digest, NTLM or Cert
79-
aType =
82+
authType =
8083

8184
# HTTP authentication credentials. Useful only if the target URL requires
8285
# HTTP Basic, Digest or NTLM authentication and you have such data.
8386
# Syntax: username:password
84-
aCred =
87+
authCred =
8588

8689
# HTTP Authentication certificate. Useful only if the target URL requires
8790
# logon certificate and you have such data.
8891
# Syntax: key_file,cert_file
89-
aCert =
92+
authCert =
9093

9194
# Use a proxy to connect to the target URL.
9295
# Syntax: http://address:port
@@ -95,7 +98,10 @@ proxy =
9598
# Proxy authentication credentials. Useful only if the proxy requires
9699
# Basic or Digest authentication and you have such data.
97100
# Syntax: username:password
98-
pCred =
101+
proxyCred =
102+
103+
# Load proxy list from a file
104+
proxyFile =
99105

100106
# Ignore system default proxy settings.
101107
# Valid: True or False

xml/livetests.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,8 +3423,8 @@
34233423
<switches>
34243424
<url value="http://debiandev/sqlmap/mysql/basic/get_int.php?id=1"/>
34253425
<tech value="E"/>
3426-
<aType value="Basic"/>
3427-
<aCred value="testuser:testpass"/>
3426+
<authType value="Basic"/>
3427+
<authCred value="testuser:testpass"/>
34283428
<getBanner value="True"/>
34293429
</switches>
34303430
<parse>
@@ -3435,8 +3435,8 @@
34353435
<switches>
34363436
<url value="http://debiandev/sqlmap/mysql/digest/get_int.php?id=1"/>
34373437
<tech value="E"/>
3438-
<aType value="Digest"/>
3439-
<aCred value="testuser:testpass"/>
3438+
<authType value="Digest"/>
3439+
<authCred value="testuser:testpass"/>
34403440
<getBanner value="True"/>
34413441
</switches>
34423442
<parse>

0 commit comments

Comments
 (0)