MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _setRequestFromFile

Function _setRequestFromFile

lib/core/option.py:293–343  ·  view source on GitHub ↗

This function checks if the way to make a HTTP request is through supplied textual file, parses it and saves the information into the knowledge base.

()

Source from the content-addressed store, hash-verified

291 FORMATTER.format = format
292
293def _setRequestFromFile():
294 """
295 This function checks if the way to make a HTTP request is through supplied
296 textual file, parses it and saves the information into the knowledge base.
297 """
298
299 if conf.requestFile:
300 for requestFile in re.split(PARAMETER_SPLITTING_REGEX, conf.requestFile):
301 requestFile = safeExpandUser(requestFile)
302 url = None
303 seen = set()
304
305 if not checkFile(requestFile, False):
306 errMsg = "specified HTTP request file '%s' " % requestFile
307 errMsg += "does not exist"
308 raise SqlmapFilePathException(errMsg)
309
310 infoMsg = "parsing HTTP request from '%s'" % requestFile
311 logger.info(infoMsg)
312
313 for target in parseRequestFile(requestFile):
314 url = target[0]
315 if url not in seen:
316 kb.targets.add(target)
317 if len(kb.targets) > 1:
318 conf.multipleTargets = True
319 seen.add(url)
320
321 if url is None:
322 errMsg = "specified file '%s' " % requestFile
323 errMsg += "does not contain a usable HTTP request (with parameters)"
324 raise SqlmapDataException(errMsg)
325
326 if conf.secondReq:
327 conf.secondReq = safeExpandUser(conf.secondReq)
328
329 if not checkFile(conf.secondReq, False):
330 errMsg = "specified second-order HTTP request file '%s' " % conf.secondReq
331 errMsg += "does not exist"
332 raise SqlmapFilePathException(errMsg)
333
334 infoMsg = "parsing second-order HTTP request from '%s'" % conf.secondReq
335 logger.info(infoMsg)
336
337 try:
338 target = next(parseRequestFile(conf.secondReq, False))
339 kb.secondReq = target
340 except StopIteration:
341 errMsg = "specified second-order HTTP request file '%s' " % conf.secondReq
342 errMsg += "does not contain a valid HTTP request"
343 raise SqlmapDataException(errMsg)
344
345def _setCrawler():
346 if not conf.crawlDepth:

Callers 1

initFunction · 0.85

Calls 7

safeExpandUserFunction · 0.90
checkFileFunction · 0.90
parseRequestFileFunction · 0.90
SqlmapDataExceptionClass · 0.90
infoMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…