diff --git a/lib/core/option.py b/lib/core/option.py index 1f6565152..1ee7f9932 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -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 diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index 716141fca..dc8c3bb10 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -28,7 +28,7 @@ optDict = { "cookieUrlencode": "boolean", "dropSetCookie": "boolean", "agent": "string", - "userAgentsFile": "string", + "randomAgent": "boolean", "referer": "string", "headers": "string", "aType": "string", diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 3b648795c..c10615cf3 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -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") diff --git a/sqlmap.conf b/sqlmap.conf index bdb29f9d5..387349237 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -56,11 +56,12 @@ dropSetCookie = False # HTTP User-Agent header. Useful to fake the HTTP User-Agent header value # at each HTTP request # sqlmap will also test for SQL injection on the HTTP User-Agent value. -agent = +agent = + +# Use randomly selected HTTP User-Agent header +# Valid: True or False +randomAgent = False -# Load a random HTTP User-Agent header from file -# Example: ./txt/user-agents.txt -userAgentsFile = # HTTP Referer header. Useful to fake the HTTP Referer header value at # each HTTP request.