File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import inspect
1111import logging
1212import os
13+ import random
1314import re
1415import socket
1516import string
4546from lib .core .common import parseTargetDirect
4647from lib .core .common import parseTargetUrl
4748from lib .core .common import paths
48- from lib .core .common import randomRange
4949from lib .core .common import randomStr
5050from lib .core .common import readCachedFileContent
5151from lib .core .common import readInput
@@ -1331,15 +1331,7 @@ def _setHTTPUserAgent():
13311331 conf .httpHeaders .append ((HTTP_HEADER .USER_AGENT , _defaultHTTPUserAgent ()))
13321332 return
13331333
1334- count = len (kb .userAgents )
1335-
1336- if count == 1 :
1337- userAgent = kb .userAgents [0 ]
1338- else :
1339- userAgent = kb .userAgents [randomRange (stop = count - 1 )]
1340-
1341- userAgent = sanitizeStr (userAgent )
1342- conf .httpHeaders .append ((HTTP_HEADER .USER_AGENT , userAgent ))
1334+ userAgent = random .sample (kb .userAgents or [_defaultHTTPUserAgent ()], 1 )[0 ]
13431335
13441336 infoMsg = "fetched random HTTP User-Agent header from "
13451337 infoMsg += "file '%s': %s" % (paths .USER_AGENTS , userAgent )
You can’t perform that action at this time.
0 commit comments