Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0df2592

Browse files
committed
Trivial speedup
1 parent eeacab0 commit 0df2592

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
19971997
kb.cache = AttribDict()
19981998
kb.cache.addrinfo = {}
19991999
kb.cache.content = {}
2000+
kb.cache.comparison = {}
20002001
kb.cache.encoding = {}
20012002
kb.cache.alphaBoundaries = None
20022003
kb.cache.hashRegex = None

lib/core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.5.3.0"
21+
VERSION = "1.5.3.1"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -505,6 +505,9 @@
505505
# Chars which can be used as a failsafe values in case of too long URL encoding value
506506
URLENCODE_FAILSAFE_CHARS = "()|,"
507507

508+
# Factor used for yuge page multiplication
509+
YUGE_FACTOR = 1000
510+
508511
# Maximum length of URL encoded value after which failsafe procedure takes away
509512
URLENCODE_CHAR_LIMIT = 2000
510513

lib/request/comparison.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,14 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
154154
seqMatcher.set_seq1(seq1)
155155
seqMatcher.set_seq2(seq2)
156156

157-
ratio = round(seqMatcher.quick_ratio() if not kb.heavilyDynamic else seqMatcher.ratio(), 3)
157+
key = (hash(seq1), hash(seq2))
158+
159+
if key in kb.cache.comparison:
160+
ratio = kb.cache.comparison[key]
161+
else:
162+
ratio = round(seqMatcher.quick_ratio() if not kb.heavilyDynamic else seqMatcher.ratio(), 3)
163+
164+
kb.cache.comparison[key] = ratio
158165

159166
# If the url is stable and we did not set yet the match ratio and the
160167
# current injected value changes the url page content

lib/request/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class WebSocketException(Exception):
126126
from lib.core.settings import URI_HTTP_HEADER
127127
from lib.core.settings import WARN_TIME_STDEV
128128
from lib.core.settings import WEBSOCKET_INITIAL_TIMEOUT
129+
from lib.core.settings import YUGE_FACTOR
129130
from lib.request.basic import decodePage
130131
from lib.request.basic import forgeHeaders
131132
from lib.request.basic import processResponse
@@ -253,7 +254,7 @@ def _connReadProxy(conn):
253254
break
254255

255256
if conf.yuge:
256-
retVal = 100 * retVal
257+
retVal = YUGE_FACTOR * retVal
257258

258259
return retVal
259260

0 commit comments

Comments
 (0)