Skip to content

Commit b445512

Browse files
committed
Fixes #3165
1 parent 4ecf6ee commit b445512

File tree

6 files changed

+28
-30
lines changed

6 files changed

+28
-30
lines changed

lib/core/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.7.6"
22+
VERSION = "1.2.7.7"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/techniques/blind/inference.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def blindThread():
485485

486486
if kb.threadContinue:
487487
if showEta:
488-
progress.progress(calculateDeltaSeconds(start), threadData.shared.index[0])
488+
progress.progress(threadData.shared.index[0])
489489
elif conf.verbose >= 1:
490490
startCharIndex = 0
491491
endCharIndex = 0
@@ -578,7 +578,7 @@ def blindThread():
578578
# Did we have luck?
579579
if result:
580580
if showEta:
581-
progress.progress(calculateDeltaSeconds(start), len(commonValue))
581+
progress.progress(len(commonValue))
582582
elif conf.verbose in (1, 2) or conf.api:
583583
dataToStdout(filterControlChars(commonValue[index - 1:]))
584584

@@ -628,7 +628,7 @@ def blindThread():
628628
threadData.shared.value = partialValue = partialValue + val
629629

630630
if showEta:
631-
progress.progress(calculateDeltaSeconds(start), index)
631+
progress.progress(index)
632632
elif conf.verbose in (1, 2) or conf.api:
633633
dataToStdout(filterControlChars(val))
634634

lib/techniques/error/use.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def errorThread():
419419
with kb.locks.value:
420420
index = None
421421
if threadData.shared.showEta:
422-
threadData.shared.progress.progress(time.time() - valueStart, threadData.shared.counter)
422+
threadData.shared.progress.progress(threadData.shared.counter)
423423
for index in xrange(1 + len(threadData.shared.buffered)):
424424
if index < len(threadData.shared.buffered) and threadData.shared.buffered[index][0] >= num:
425425
break

lib/techniques/union/use.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def unionThread():
333333
items = parseUnionPage(output)
334334

335335
if threadData.shared.showEta:
336-
threadData.shared.progress.progress(time.time() - valueStart, threadData.shared.counter)
336+
threadData.shared.progress.progress(threadData.shared.counter)
337337
if isListLike(items):
338338
# in case that we requested N columns and we get M!=N then we have to filter a bit
339339
if len(items) > 1 and len(expressionFieldsList) > 1:
@@ -355,7 +355,7 @@ def unionThread():
355355
else:
356356
index = None
357357
if threadData.shared.showEta:
358-
threadData.shared.progress.progress(time.time() - valueStart, threadData.shared.counter)
358+
threadData.shared.progress.progress(threadData.shared.counter)
359359
for index in xrange(1 + len(threadData.shared.buffered)):
360360
if index < len(threadData.shared.buffered) and threadData.shared.buffered[index][0] >= num:
361361
break

lib/utils/progress.py

+16-18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8+
import time
9+
810
from lib.core.common import getUnicode
911
from lib.core.common import dataToStdout
1012
from lib.core.data import conf
@@ -17,13 +19,12 @@ class ProgressBar(object):
1719

1820
def __init__(self, minValue=0, maxValue=10, totalWidth=None):
1921
self._progBar = "[]"
20-
self._oldProgBar = ""
2122
self._min = int(minValue)
2223
self._max = int(maxValue)
2324
self._span = max(self._max - self._min, 0.001)
2425
self._width = totalWidth if totalWidth else conf.progressWidth
2526
self._amount = 0
26-
self._times = []
27+
self._start = None
2728
self.update()
2829

2930
def _convertSeconds(self, value):
@@ -52,7 +53,7 @@ def update(self, newAmount=0):
5253
percentDone = min(100, int(percentDone))
5354

5455
# Figure out how many hash bars the percentage should be
55-
allFull = self._width - len("100%% [] %s/%s ETA 00:00" % (self._max, self._max))
56+
allFull = self._width - len("100%% [] %s/%s (ETA 00:00)" % (self._max, self._max))
5657
numHashes = (percentDone / 100.0) * allFull
5758
numHashes = int(round(numHashes))
5859

@@ -68,19 +69,18 @@ def update(self, newAmount=0):
6869
percentString = getUnicode(percentDone) + "%"
6970
self._progBar = "%s %s" % (percentString, self._progBar)
7071

71-
def progress(self, deltaTime, newAmount):
72+
def progress(self, newAmount):
7273
"""
7374
This method saves item delta time and shows updated progress bar with calculated eta
7475
"""
7576

76-
if len(self._times) <= ((self._max * 3) / 100) or newAmount > self._max:
77+
if self._start is None or newAmount > self._max:
78+
self._start = time.time()
7779
eta = None
7880
else:
79-
midTime = sum(self._times) / len(self._times)
80-
midTimeWithLatest = (midTime + deltaTime) / 2
81-
eta = midTimeWithLatest * (self._max - newAmount)
81+
delta = time.time() - self._start
82+
eta = (self._max - self._min) * (1.0 * delta / newAmount) - delta
8283

83-
self._times.append(deltaTime)
8484
self.update(newAmount)
8585
self.draw(eta)
8686

@@ -89,15 +89,13 @@ def draw(self, eta=None):
8989
This method draws the progress bar if it has changed
9090
"""
9191

92-
if self._progBar != self._oldProgBar:
93-
self._oldProgBar = self._progBar
94-
dataToStdout("\r%s %d/%d%s" % (self._progBar, self._amount, self._max, (" ETA %s" % self._convertSeconds(int(eta))) if eta is not None else ""))
95-
if self._amount >= self._max:
96-
if not conf.liveTest:
97-
dataToStdout("\r%s\r" % (" " * self._width))
98-
kb.prependFlag = False
99-
else:
100-
dataToStdout("\n")
92+
dataToStdout("\r%s %d/%d%s" % (self._progBar, self._amount, self._max, (" (ETA %s)" % (self._convertSeconds(int(eta)) if eta is not None else "??:??"))))
93+
if self._amount >= self._max:
94+
if not conf.liveTest:
95+
dataToStdout("\r%s\r" % (" " * self._width))
96+
kb.prependFlag = False
97+
else:
98+
dataToStdout("\n")
10199

102100
def __str__(self):
103101
"""

txt/checksum.md5

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4848
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
4949
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5050
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
51-
f1e0cc7708df13f9f973dbcabfd77007 lib/core/settings.py
51+
c4439324bd9484f4a35d648a20d7bf87 lib/core/settings.py
5252
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5353
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5454
95f04c1c1d8c3998d86e1bdf0e12771c lib/core/target.py
@@ -89,17 +89,17 @@ fb9e34d558293b5d6b9727f440712886 lib/takeover/registry.py
8989
48575dde7bb867b7937769f569a98309 lib/takeover/udf.py
9090
f6f835e4190a55e42d13c1e7ca3f728f lib/takeover/web.py
9191
f1decf0a987bd3a4bc757212cbe6a6c8 lib/takeover/xp_cmdshell.py
92-
4a7f231e597f754e9fcd116d13ad1a4d lib/techniques/blind/inference.py
92+
09beb19c2ec9fdd14329f1c0b59a2d05 lib/techniques/blind/inference.py
9393
1e5532ede194ac9c083891c2f02bca93 lib/techniques/blind/__init__.py
9494
1e5532ede194ac9c083891c2f02bca93 lib/techniques/dns/__init__.py
9595
799faf9008527d2e9da9d923e50f685a lib/techniques/dns/test.py
9696
48a24f48da791e67309003fd5e8428cb lib/techniques/dns/use.py
9797
1e5532ede194ac9c083891c2f02bca93 lib/techniques/error/__init__.py
98-
f5fb02487edaf9adaa81d54324c84f8f lib/techniques/error/use.py
98+
b9f6148c8df6b9d3316ce082dc1a63dd lib/techniques/error/use.py
9999
1e5532ede194ac9c083891c2f02bca93 lib/techniques/__init__.py
100100
1e5532ede194ac9c083891c2f02bca93 lib/techniques/union/__init__.py
101101
94d7a22bb6725a91e84ba2cd9973e96d lib/techniques/union/test.py
102-
11ecf2effbe9f40b361843d546c3c521 lib/techniques/union/use.py
102+
8b770864bdb106ef50c70173c824395c lib/techniques/union/use.py
103103
77ff35587af9e3dfde63b8327e230f9a lib/utils/api.py
104104
37dfb641358669f62c2acedff241348b lib/utils/brute.py
105105
31b1e7eb489eac837db6a2bc1dcb7da7 lib/utils/crawler.py
@@ -111,7 +111,7 @@ cc1cfe36057f1d9bbdcba1bcc03359f9 lib/utils/hash.py
111111
011d2dbf589e0faa0deca61a651239cc lib/utils/htmlentities.py
112112
1e5532ede194ac9c083891c2f02bca93 lib/utils/__init__.py
113113
010d8327239d33af4ce9f25683cfc012 lib/utils/pivotdumptable.py
114-
5cb78b0e60fd7fd84502d62cf85d2064 lib/utils/progress.py
114+
683c3bd05b6164f56a57ed495c162684 lib/utils/progress.py
115115
0ec5cec9d93d5ffd1eaeda6e942ecadf lib/utils/purge.py
116116
2c5a655c8e94cbe2664ee497752ac1f2 lib/utils/search.py
117117
571884f530796534f03c49cf3f380a4c lib/utils/sqlalchemy.py

0 commit comments

Comments
 (0)