adding --random-agent and removing -a

This commit is contained in:
Miroslav Stampar 2011-02-02 14:51:12 +00:00
parent 2dae57a56d
commit 5f49e20cc8
4 changed files with 14 additions and 16 deletions

View File

@ -981,7 +981,7 @@ def __setHTTPUserAgent():
conf.httpHeaders.append(("User-Agent", conf.agent))
return
if not conf.userAgentsFile:
if not conf.randomAgent:
addDefaultUserAgent = True
for header, _ in conf.httpHeaders:
@ -996,14 +996,14 @@ def __setHTTPUserAgent():
if not kb.userAgents:
debugMsg = "loading random HTTP User-Agent header(s) from "
debugMsg += "file '%s'" % conf.userAgentsFile
debugMsg += "file '%s'" % paths.USER_AGENTS
logger.debug(debugMsg)
try:
kb.userAgents = getFileItems(conf.userAgentsFile)
kb.userAgents = getFileItems(paths.USER_AGENTS)
except IOError:
warnMsg = "unable to read HTTP User-Agent header "
warnMsg += "file '%s'" % conf.userAgentsFile
warnMsg += "file '%s'" % paths.USER_AGENTS
logger.warn(warnMsg)
conf.httpHeaders.append(("User-Agent", __defaultHTTPUserAgent()))
@ -1021,7 +1021,7 @@ def __setHTTPUserAgent():
conf.httpHeaders.append(("User-Agent", __userAgent))
logMsg = "fetched random HTTP User-Agent header from "
logMsg += "file '%s': %s" % (conf.userAgentsFile, __userAgent)
logMsg += "file '%s': %s" % (paths.USER_AGENTS, __userAgent)
logger.info(logMsg)
def __setHTTPReferer():
@ -1129,9 +1129,6 @@ def __cleanupOptions():
conf.nullConnection = not conf.textOnly
conf.threads = 4 if conf.threads < 4 else conf.threads
if conf.realTest:
conf.userAgentsFile = paths.USER_AGENTS
def __setConfAttributes():
"""
This function set some needed attributes into the configuration

View File

@ -28,7 +28,7 @@ optDict = {
"cookieUrlencode": "boolean",
"dropSetCookie": "boolean",
"agent": "string",
"userAgentsFile": "string",
"randomAgent": "boolean",
"referer": "string",
"headers": "string",
"aType": "string",

View File

@ -78,9 +78,9 @@ def cmdLineParser():
request.add_option("--user-agent", dest="agent",
help="HTTP User-Agent header")
request.add_option("-a", dest="userAgentsFile",
help="Load a random HTTP User-Agent "
"header from file")
request.add_option("--random-agent", dest="randomAgent",
action="store_true", default=False,
help="Use randomly selected HTTP User-Agent header")
request.add_option("--referer", dest="referer",
help="HTTP Referer header")

View File

@ -58,9 +58,10 @@ dropSetCookie = False
# sqlmap will also test for SQL injection on the HTTP User-Agent value.
agent =
# Load a random HTTP User-Agent header from file
# Example: ./txt/user-agents.txt
userAgentsFile =
# Use randomly selected HTTP User-Agent header
# Valid: True or False
randomAgent = False
# HTTP Referer header. Useful to fake the HTTP Referer header value at
# each HTTP request.