implemented --mobile switch

This commit is contained in:
Miroslav Stampar 2011-04-29 19:27:23 +00:00
parent b299912de4
commit 11124b21f9
5 changed files with 55 additions and 18 deletions

View File

@ -69,6 +69,15 @@ class HASH:
SHA1_GENERIC = r'(?i)\A[0-9a-f]{40}\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:
ACCEPT_ENCODING = "Accept-Encoding"
AUTHORIZATION = "Authorization"

View File

@ -57,6 +57,7 @@ from lib.core.datatype import injectionDict
from lib.core.enums import DBMS
from lib.core.enums import HTTPHEADER
from lib.core.enums import HTTPMETHOD
from lib.core.enums import MOBILES
from lib.core.enums import PAYLOAD
from lib.core.enums import PRIORITY
from lib.core.exception import sqlmapFilePathException
@ -1051,14 +1052,31 @@ def __setHTTPUserAgent():
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"
logger.debug(debugMsg)
conf.httpHeaders.append(("User-Agent", conf.agent))
return
if not conf.randomAgent:
elif not conf.randomAgent:
addDefaultUserAgent = True
for header, _ in conf.httpHeaders:
@ -1069,9 +1087,7 @@ def __setHTTPUserAgent():
if addDefaultUserAgent:
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
return
if not kb.userAgents:
elif not kb.userAgents:
debugMsg = "loading random HTTP User-Agent header(s) from "
debugMsg += "file '%s'" % paths.USER_AGENTS
logger.debug(debugMsg)
@ -1085,8 +1101,7 @@ def __setHTTPUserAgent():
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, __defaultHTTPUserAgent()))
return
else:
count = len(kb.userAgents)
if count == 1:
@ -1566,6 +1581,10 @@ def __basicOptionValidation():
errMsg = "switch --tor is incompatible with switch --ignore-proxy"
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:
errMsg = "switch --proxy is incompatible with switch --ignore-proxy"
raise sqlmapSyntaxException, errMsg

View File

@ -163,6 +163,7 @@ optDict = {
"checkPayload": "boolean",
"cleanup": "boolean",
"googlePage": "integer",
"mobile": "boolean",
"pageRank": "boolean",
"parseErrors": "boolean",
"replicate": "boolean",

View File

@ -497,6 +497,10 @@ def cmdLineParser():
miscellaneous.add_option("--gpage", dest="googlePage", type="int",
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",
action="store_true", default=False,
help="Display page rank (PR) for Google dork results")

View File

@ -538,6 +538,10 @@ forms = False
# Default: 1
googlePage = 1
# Imitate smartphone through HTTP User-Agent header.
# Valid: True or False
mobile = False
# Display page rank (PR) for Google dork results.
# Valid: True or False
pageRank = False