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

Skip to content

Commit 1678b60

Browse files
committed
Update for #2597
1 parent aef5d66 commit 1678b60

10 files changed

Lines changed: 230 additions & 345 deletions

File tree

lib/controller/checks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def checkSqlInjection(place, parameter, value):
117117

118118
while tests:
119119
test = tests.pop(0)
120-
threadData.requestCollector.reset()
121120

122121
try:
123122
if kb.endDetection:
@@ -701,7 +700,6 @@ def genCmpPayload():
701700
injection.data[stype].matchRatio = kb.matchRatio
702701
injection.data[stype].trueCode = trueCode
703702
injection.data[stype].falseCode = falseCode
704-
injection.data[stype].collectedRequests = threadData.requestCollector.obtain()
705703

706704
injection.conf.textOnly = conf.textOnly
707705
injection.conf.titles = conf.titles

lib/core/common.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,17 +2601,15 @@ def logHTTPTraffic(requestLogMsg, responseLogMsg):
26012601
"""
26022602
Logs HTTP traffic to the output file
26032603
"""
2604-
threadData = getCurrentThreadData()
2605-
assert threadData.requestCollector is not None, "Request collector should be initialized by now"
2606-
threadData.requestCollector.collectRequest(requestLogMsg, responseLogMsg)
26072604

2608-
if not conf.trafficFile:
2609-
return
2605+
if conf.harFile:
2606+
conf.httpCollector.collectRequest(requestLogMsg, responseLogMsg)
26102607

2611-
with kb.locks.log:
2612-
dataToTrafficFile("%s%s" % (requestLogMsg, os.linesep))
2613-
dataToTrafficFile("%s%s" % (responseLogMsg, os.linesep))
2614-
dataToTrafficFile("%s%s%s%s" % (os.linesep, 76 * '#', os.linesep, os.linesep))
2608+
if not conf.trafficFile:
2609+
with kb.locks.log:
2610+
dataToTrafficFile("%s%s" % (requestLogMsg, os.linesep))
2611+
dataToTrafficFile("%s%s" % (responseLogMsg, os.linesep))
2612+
dataToTrafficFile("%s%s%s%s" % (os.linesep, 76 * '#', os.linesep, os.linesep))
26152613

26162614
def getPageTemplate(payload, place): # Cross-linked function
26172615
raise NotImplementedError

lib/core/option.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
from lib.request.rangehandler import HTTPRangeHandler
150150
from lib.request.redirecthandler import SmartRedirectHandler
151151
from lib.request.templates import getPageTemplate
152-
from lib.utils.collect import RequestCollectorFactory
152+
from lib.utils.har import HTTPCollectorFactory
153153
from lib.utils.crawler import crawl
154154
from lib.utils.deps import checkDependencies
155155
from lib.utils.search import search
@@ -1830,6 +1830,7 @@ def _setConfAttributes():
18301830
conf.dumpPath = None
18311831
conf.hashDB = None
18321832
conf.hashDBFile = None
1833+
conf.httpCollector = None
18331834
conf.httpHeaders = []
18341835
conf.hostname = None
18351836
conf.ipv6 = False
@@ -1845,7 +1846,7 @@ def _setConfAttributes():
18451846
conf.scheme = None
18461847
conf.tests = []
18471848
conf.trafficFP = None
1848-
conf.requestCollectorFactory = None
1849+
conf.HARCollectorFactory = None
18491850
conf.wFileType = None
18501851

18511852
def _setKnowledgeBaseAttributes(flushAll=True):
@@ -2230,10 +2231,11 @@ def _setTrafficOutputFP():
22302231

22312232
conf.trafficFP = openFile(conf.trafficFile, "w+")
22322233

2233-
def _setupRequestCollector():
2234-
conf.requestCollectorFactory = RequestCollectorFactory(collect=conf.collectRequests)
2235-
threadData = getCurrentThreadData()
2236-
threadData.requestCollector = conf.requestCollectorFactory.create()
2234+
def _setupHTTPCollector():
2235+
if not conf.harFile:
2236+
return
2237+
2238+
conf.httpCollector = HTTPCollectorFactory(conf.harFile).create()
22372239

22382240
def _setDNSServer():
22392241
if not conf.dnsDomain:
@@ -2611,7 +2613,7 @@ def init():
26112613
_setTamperingFunctions()
26122614
_setWafFunctions()
26132615
_setTrafficOutputFP()
2614-
_setupRequestCollector()
2616+
_setupHTTPCollector()
26152617
_resolveCrossReferences()
26162618
_checkWebSocket()
26172619

lib/core/optiondict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@
197197
"binaryFields": "string",
198198
"charset": "string",
199199
"checkInternet": "boolean",
200-
"collectRequests": "string",
201200
"crawlDepth": "integer",
202201
"crawlExclude": "string",
203202
"csvDel": "string",
@@ -206,6 +205,7 @@
206205
"flushSession": "boolean",
207206
"forms": "boolean",
208207
"freshQueries": "boolean",
208+
"harFile": "string",
209209
"hexConvert": "boolean",
210210
"outputDir": "string",
211211
"parseErrors": "boolean",

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
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.1.7.2"
22+
VERSION = "1.1.7.3"
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/parse/cmdline.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,6 @@ def cmdLineParser(argv=None):
618618
general = OptionGroup(parser, "General", "These options can be used "
619619
"to set some general working parameters")
620620

621-
#general.add_option("-x", dest="xmlFile",
622-
# help="Dump the data into an XML file")
623-
624621
general.add_option("-s", dest="sessionFile",
625622
help="Load session from a stored (.sqlite) file")
626623

@@ -632,10 +629,6 @@ def cmdLineParser(argv=None):
632629
action="store_true",
633630
help="Never ask for user input, use the default behaviour")
634631

635-
general.add_option("--collect-requests", dest="collectRequests",
636-
action="store_true",
637-
help="Collect requests in HAR format")
638-
639632
general.add_option("--binary-fields", dest="binaryFields",
640633
help="Result fields having binary values (e.g. \"digest\")")
641634

@@ -661,8 +654,7 @@ def cmdLineParser(argv=None):
661654

662655
general.add_option("--eta", dest="eta",
663656
action="store_true",
664-
help="Display for each output the "
665-
"estimated time of arrival")
657+
help="Display for each output the estimated time of arrival")
666658

667659
general.add_option("--flush-session", dest="flushSession",
668660
action="store_true",
@@ -676,6 +668,9 @@ def cmdLineParser(argv=None):
676668
action="store_true",
677669
help="Ignore query results stored in session file")
678670

671+
general.add_option("--har", dest="harFile",
672+
help="Log all HTTP traffic into a HAR file")
673+
679674
general.add_option("--hex", dest="hexConvert",
680675
action="store_true",
681676
help="Use DBMS hex function(s) for data retrieval")

0 commit comments

Comments
 (0)