mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-18 04:20:35 +03:00
Minor speed up
This commit is contained in:
parent
38fcc5a35a
commit
814d710320
|
@ -968,7 +968,12 @@ def randomRange(start=0, stop=1000, seed=None):
|
||||||
423
|
423
|
||||||
"""
|
"""
|
||||||
|
|
||||||
randint = random.WichmannHill(seed).randint if seed is not None else random.randint
|
if seed is not None:
|
||||||
|
_ = getCurrentThreadData().random
|
||||||
|
_.seed(seed)
|
||||||
|
randint = _.randint
|
||||||
|
else:
|
||||||
|
randint = random.randint
|
||||||
|
|
||||||
return int(randint(start, stop))
|
return int(randint(start, stop))
|
||||||
|
|
||||||
|
@ -981,7 +986,12 @@ def randomInt(length=4, seed=None):
|
||||||
874254
|
874254
|
||||||
"""
|
"""
|
||||||
|
|
||||||
choice = random.WichmannHill(seed).choice if seed is not None else random.choice
|
if seed is not None:
|
||||||
|
_ = getCurrentThreadData().random
|
||||||
|
_.seed(seed)
|
||||||
|
choice = _.choice
|
||||||
|
else:
|
||||||
|
choice = random.choice
|
||||||
|
|
||||||
return int("".join(choice(string.digits if _ != 0 else string.digits.replace('0', '')) for _ in xrange(0, length)))
|
return int("".join(choice(string.digits if _ != 0 else string.digits.replace('0', '')) for _ in xrange(0, length)))
|
||||||
|
|
||||||
|
@ -994,7 +1004,12 @@ def randomStr(length=4, lowercase=False, alphabet=None, seed=None):
|
||||||
'RNvnAv'
|
'RNvnAv'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
choice = random.WichmannHill(seed).choice if seed is not None else random.choice
|
if seed is not None:
|
||||||
|
_ = getCurrentThreadData().random
|
||||||
|
_.seed(seed)
|
||||||
|
choice = _.choice
|
||||||
|
else:
|
||||||
|
choice = random.choice
|
||||||
|
|
||||||
if alphabet:
|
if alphabet:
|
||||||
retVal = "".join(choice(alphabet) for _ in xrange(0, length))
|
retVal = "".join(choice(alphabet) for _ in xrange(0, length))
|
||||||
|
@ -3147,14 +3162,6 @@ def intersect(valueA, valueB, lowerCase=False):
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def cpuThrottle(value):
|
|
||||||
"""
|
|
||||||
Does a CPU throttling for lesser CPU consumption
|
|
||||||
"""
|
|
||||||
|
|
||||||
delay = 0.00001 * (value ** 2)
|
|
||||||
time.sleep(delay)
|
|
||||||
|
|
||||||
def removeReflectiveValues(content, payload, suppressWarning=False):
|
def removeReflectiveValues(content, payload, suppressWarning=False):
|
||||||
"""
|
"""
|
||||||
Neutralizes reflective values in a given content based on a payload
|
Neutralizes reflective values in a given content based on a payload
|
||||||
|
|
|
@ -11,7 +11,6 @@ _defaults = {
|
||||||
"csvDel": ",",
|
"csvDel": ",",
|
||||||
"timeSec": 5,
|
"timeSec": 5,
|
||||||
"googlePage": 1,
|
"googlePage": 1,
|
||||||
"cpuThrottle": 5,
|
|
||||||
"verbose": 1,
|
"verbose": 1,
|
||||||
"delay": 0,
|
"delay": 0,
|
||||||
"timeout": 30,
|
"timeout": 30,
|
||||||
|
|
|
@ -2331,10 +2331,6 @@ def _basicOptionValidation():
|
||||||
errMsg = "value for option '--first' (firstChar) must be smaller than or equal to value for --last (lastChar) option"
|
errMsg = "value for option '--first' (firstChar) must be smaller than or equal to value for --last (lastChar) option"
|
||||||
raise SqlmapSyntaxException(errMsg)
|
raise SqlmapSyntaxException(errMsg)
|
||||||
|
|
||||||
if isinstance(conf.cpuThrottle, int) and (conf.cpuThrottle > 100 or conf.cpuThrottle < 0):
|
|
||||||
errMsg = "value for option '--cpu-throttle' (cpuThrottle) must be in range [0,100]"
|
|
||||||
raise SqlmapSyntaxException(errMsg)
|
|
||||||
|
|
||||||
if conf.textOnly and conf.nullConnection:
|
if conf.textOnly and conf.nullConnection:
|
||||||
errMsg = "switch '--text-only' is incompatible with switch '--null-connection'"
|
errMsg = "switch '--text-only' is incompatible with switch '--null-connection'"
|
||||||
raise SqlmapSyntaxException(errMsg)
|
raise SqlmapSyntaxException(errMsg)
|
||||||
|
|
|
@ -230,7 +230,6 @@ optDict = {
|
||||||
"disablePrecon": "boolean",
|
"disablePrecon": "boolean",
|
||||||
"binaryFields": "string",
|
"binaryFields": "string",
|
||||||
"profile": "boolean",
|
"profile": "boolean",
|
||||||
"cpuThrottle": "integer",
|
|
||||||
"forceDns": "boolean",
|
"forceDns": "boolean",
|
||||||
"identifyWaf": "boolean",
|
"identifyWaf": "boolean",
|
||||||
"skipWaf": "boolean",
|
"skipWaf": "boolean",
|
||||||
|
|
|
@ -20,7 +20,7 @@ from lib.core.enums import OS
|
||||||
from lib.core.revision import getRevisionNumber
|
from lib.core.revision import getRevisionNumber
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.0.4.10"
|
VERSION = "1.0.4.11"
|
||||||
REVISION = getRevisionNumber()
|
REVISION = getRevisionNumber()
|
||||||
STABLE = VERSION.count('.') <= 2
|
STABLE = VERSION.count('.') <= 2
|
||||||
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")
|
VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev")
|
||||||
|
|
|
@ -6,6 +6,7 @@ See the file 'doc/COPYING' for copying permission
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
|
import random
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -51,6 +52,7 @@ class _ThreadData(threading.local):
|
||||||
self.lastRequestMsg = None
|
self.lastRequestMsg = None
|
||||||
self.lastRequestUID = 0
|
self.lastRequestUID = 0
|
||||||
self.lastRedirectURL = None
|
self.lastRedirectURL = None
|
||||||
|
self.random = random.WichmannHill()
|
||||||
self.resumed = False
|
self.resumed = False
|
||||||
self.retriesCount = 0
|
self.retriesCount = 0
|
||||||
self.seqMatcher = difflib.SequenceMatcher(None)
|
self.seqMatcher = difflib.SequenceMatcher(None)
|
||||||
|
|
|
@ -763,9 +763,6 @@ def cmdLineParser(argv=None):
|
||||||
parser.add_option("--binary-fields", dest="binaryFields",
|
parser.add_option("--binary-fields", dest="binaryFields",
|
||||||
help=SUPPRESS_HELP)
|
help=SUPPRESS_HELP)
|
||||||
|
|
||||||
parser.add_option("--cpu-throttle", dest="cpuThrottle", type="int",
|
|
||||||
help=SUPPRESS_HELP)
|
|
||||||
|
|
||||||
parser.add_option("--force-dns", dest="forceDns", action="store_true",
|
parser.add_option("--force-dns", dest="forceDns", action="store_true",
|
||||||
help=SUPPRESS_HELP)
|
help=SUPPRESS_HELP)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ from lib.core.agent import agent
|
||||||
from lib.core.common import asciifyUrl
|
from lib.core.common import asciifyUrl
|
||||||
from lib.core.common import calculateDeltaSeconds
|
from lib.core.common import calculateDeltaSeconds
|
||||||
from lib.core.common import clearConsoleLine
|
from lib.core.common import clearConsoleLine
|
||||||
from lib.core.common import cpuThrottle
|
|
||||||
from lib.core.common import dataToStdout
|
from lib.core.common import dataToStdout
|
||||||
from lib.core.common import evaluateCode
|
from lib.core.common import evaluateCode
|
||||||
from lib.core.common import extractRegexResult
|
from lib.core.common import extractRegexResult
|
||||||
|
@ -220,8 +219,6 @@ class Connect(object):
|
||||||
|
|
||||||
if isinstance(conf.delay, (int, float)) and conf.delay > 0:
|
if isinstance(conf.delay, (int, float)) and conf.delay > 0:
|
||||||
time.sleep(conf.delay)
|
time.sleep(conf.delay)
|
||||||
elif conf.cpuThrottle:
|
|
||||||
cpuThrottle(conf.cpuThrottle)
|
|
||||||
|
|
||||||
if conf.offline:
|
if conf.offline:
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user