mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 11:03:47 +03:00
implemented --mobile switch
This commit is contained in:
parent
b299912de4
commit
11124b21f9
|
@ -69,6 +69,15 @@ class HASH:
|
||||||
SHA1_GENERIC = r'(?i)\A[0-9a-f]{40}\Z'
|
SHA1_GENERIC = r'(?i)\A[0-9a-f]{40}\Z'
|
||||||
CRYPT_GENERIC = r'(?i)\A[./0-9A-Za-z]{13}\Z'
|
CRYPT_GENERIC = r'(?i)\A[./0-9A-Za-z]{13}\Z'
|
||||||
|
|
||||||
|
class MOBILES:
|
||||||
|
IPHONE = "Apple iPhone 4;Apple-iPhone3C1/801.306"
|
||||||
|
BLACKBERRY = "Blackberry 9800;Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+"
|
||||||
|
NEXUS = "Google Nexus One;Mozilla/5.0 (Linux; U; Android 2.2; en-US; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
||||||
|
KINDLE = "Amazon Kindle 3;Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) Version/4.0 Kindle/3.0 (screen 600X800; rotate)"
|
||||||
|
GALAXY = "Samsung Galaxy S;Mozilla/5.0 (Linux; U; Android 2.2; en-US; SGH-T959D Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
||||||
|
NOKIA = "Nokia N97;Mozilla/5.0 (SymbianOS/9.3; U; Series60/3.2 NokiaN79-1/32.001; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/413 (KHTML, like Gecko) Safari/413"
|
||||||
|
HP = "HP iPAQ 6365;Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320; HP iPAQ h6300)"
|
||||||
|
|
||||||
class HTTPHEADER:
|
class HTTPHEADER:
|
||||||
ACCEPT_ENCODING = "Accept-Encoding"
|
ACCEPT_ENCODING = "Accept-Encoding"
|
||||||
AUTHORIZATION = "Authorization"
|
AUTHORIZATION = "Authorization"
|
||||||
|
|
|
@ -57,6 +57,7 @@ from lib.core.datatype import injectionDict
|
||||||
from lib.core.enums import DBMS
|
from lib.core.enums import DBMS
|
||||||
from lib.core.enums import HTTPHEADER
|
from lib.core.enums import HTTPHEADER
|
||||||
from lib.core.enums import HTTPMETHOD
|
from lib.core.enums import HTTPMETHOD
|
||||||
|
from lib.core.enums import MOBILES
|
||||||
from lib.core.enums import PAYLOAD
|
from lib.core.enums import PAYLOAD
|
||||||
from lib.core.enums import PRIORITY
|
from lib.core.enums import PRIORITY
|
||||||
from lib.core.exception import sqlmapFilePathException
|
from lib.core.exception import sqlmapFilePathException
|
||||||
|
@ -1051,14 +1052,31 @@ def __setHTTPUserAgent():
|
||||||
file choosed as user option
|
file choosed as user option
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if conf.agent:
|
if conf.mobile:
|
||||||
|
message = "which smartphone do you want sqlmap to imitate through HTTP User-Agent header?\n"
|
||||||
|
items = sorted(getPublicTypeMembers(MOBILES, True))
|
||||||
|
|
||||||
|
for count in xrange(len(items)):
|
||||||
|
item = items[count]
|
||||||
|
message += "[%d] %s%s\n" % (count + 1, item[:item.find(';')], " (default)" if item==MOBILES.IPHONE else "")
|
||||||
|
|
||||||
|
test = readInput(message.rstrip('\n'), default=items.index(MOBILES.IPHONE) + 1)
|
||||||
|
try:
|
||||||
|
item = items[int(test) - 1]
|
||||||
|
except:
|
||||||
|
item = MOBILES.IPHONE
|
||||||
|
|
||||||
|
item = item[item.find(';') + 1:]
|
||||||
|
|
||||||
|
conf.httpHeaders.append(("User-Agent", item))
|
||||||
|
|
||||||
|
elif conf.agent:
|
||||||
debugMsg = "setting the HTTP User-Agent header"
|
debugMsg = "setting the HTTP User-Agent header"
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
conf.httpHeaders.append(("User-Agent", conf.agent))
|
conf.httpHeaders.append(("User-Agent", conf.agent))
|
||||||
return
|
|
||||||
|
|
||||||
if not conf.randomAgent:
|
elif not conf.randomAgent:
|
||||||
addDefaultUserAgent = True
|
addDefaultUserAgent = True
|
||||||
|
|
||||||
for header, _ in conf.httpHeaders:
|
for header, _ in conf.httpHeaders:
|
||||||
|
@ -1069,9 +1087,7 @@ def __setHTTPUserAgent():
|
||||||
if addDefaultUserAgent:
|
if addDefaultUserAgent:
|
||||||
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
|
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
|
||||||
|
|
||||||
return
|
elif not kb.userAgents:
|
||||||
|
|
||||||
if not kb.userAgents:
|
|
||||||
debugMsg = "loading random HTTP User-Agent header(s) from "
|
debugMsg = "loading random HTTP User-Agent header(s) from "
|
||||||
debugMsg += "file '%s'" % paths.USER_AGENTS
|
debugMsg += "file '%s'" % paths.USER_AGENTS
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
@ -1085,21 +1101,20 @@ def __setHTTPUserAgent():
|
||||||
|
|
||||||
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, __defaultHTTPUserAgent()))
|
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, __defaultHTTPUserAgent()))
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
count = len(kb.userAgents)
|
|
||||||
|
|
||||||
if count == 1:
|
|
||||||
userAgent = kb.userAgents[0]
|
|
||||||
else:
|
else:
|
||||||
userAgent = kb.userAgents[randomRange(stop=count-1)]
|
count = len(kb.userAgents)
|
||||||
|
|
||||||
userAgent = sanitizeStr(userAgent)
|
if count == 1:
|
||||||
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, userAgent))
|
userAgent = kb.userAgents[0]
|
||||||
|
else:
|
||||||
|
userAgent = kb.userAgents[randomRange(stop=count-1)]
|
||||||
|
|
||||||
logMsg = "fetched random HTTP User-Agent header from "
|
userAgent = sanitizeStr(userAgent)
|
||||||
logMsg += "file '%s': %s" % (paths.USER_AGENTS, userAgent)
|
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, userAgent))
|
||||||
logger.info(logMsg)
|
|
||||||
|
logMsg = "fetched random HTTP User-Agent header from "
|
||||||
|
logMsg += "file '%s': %s" % (paths.USER_AGENTS, userAgent)
|
||||||
|
logger.info(logMsg)
|
||||||
|
|
||||||
def __setHTTPReferer():
|
def __setHTTPReferer():
|
||||||
"""
|
"""
|
||||||
|
@ -1566,6 +1581,10 @@ def __basicOptionValidation():
|
||||||
errMsg = "switch --tor is incompatible with switch --ignore-proxy"
|
errMsg = "switch --tor is incompatible with switch --ignore-proxy"
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
|
if conf.mobile and conf.agent:
|
||||||
|
errMsg = "switch --mobile is incompatible with switch --user-agent"
|
||||||
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
if conf.proxy and conf.ignoreProxy:
|
if conf.proxy and conf.ignoreProxy:
|
||||||
errMsg = "switch --proxy is incompatible with switch --ignore-proxy"
|
errMsg = "switch --proxy is incompatible with switch --ignore-proxy"
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
|
@ -163,6 +163,7 @@ optDict = {
|
||||||
"checkPayload": "boolean",
|
"checkPayload": "boolean",
|
||||||
"cleanup": "boolean",
|
"cleanup": "boolean",
|
||||||
"googlePage": "integer",
|
"googlePage": "integer",
|
||||||
|
"mobile": "boolean",
|
||||||
"pageRank": "boolean",
|
"pageRank": "boolean",
|
||||||
"parseErrors": "boolean",
|
"parseErrors": "boolean",
|
||||||
"replicate": "boolean",
|
"replicate": "boolean",
|
||||||
|
|
|
@ -497,6 +497,10 @@ def cmdLineParser():
|
||||||
miscellaneous.add_option("--gpage", dest="googlePage", type="int",
|
miscellaneous.add_option("--gpage", dest="googlePage", type="int",
|
||||||
help="Use Google dork results from specified page number")
|
help="Use Google dork results from specified page number")
|
||||||
|
|
||||||
|
miscellaneous.add_option("--mobile", dest="mobile",
|
||||||
|
action="store_true", default=False,
|
||||||
|
help="Imitate smartphone through HTTP User-Agent header")
|
||||||
|
|
||||||
miscellaneous.add_option("--page-rank", dest="pageRank",
|
miscellaneous.add_option("--page-rank", dest="pageRank",
|
||||||
action="store_true", default=False,
|
action="store_true", default=False,
|
||||||
help="Display page rank (PR) for Google dork results")
|
help="Display page rank (PR) for Google dork results")
|
||||||
|
|
|
@ -538,6 +538,10 @@ forms = False
|
||||||
# Default: 1
|
# Default: 1
|
||||||
googlePage = 1
|
googlePage = 1
|
||||||
|
|
||||||
|
# Imitate smartphone through HTTP User-Agent header.
|
||||||
|
# Valid: True or False
|
||||||
|
mobile = False
|
||||||
|
|
||||||
# Display page rank (PR) for Google dork results.
|
# Display page rank (PR) for Google dork results.
|
||||||
# Valid: True or False
|
# Valid: True or False
|
||||||
pageRank = False
|
pageRank = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user