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

Function fileExists

lib/utils/brute.py:324–408  ·  view source on GitHub ↗
(pathFile)

Source from the content-addressed store, hash-verified

322
323@stackedmethod
324def fileExists(pathFile):
325 retVal = []
326
327 message = "which common files file do you want to use?\n"
328 message += "[1] default '%s' (press Enter)\n" % pathFile
329 message += "[2] custom"
330 choice = readInput(message, default='1')
331
332 if choice == '2':
333 message = "what's the custom common files file location?\n"
334 pathFile = readInput(message) or pathFile
335
336 infoMsg = "checking files existence using items from '%s'" % pathFile
337 logger.info(infoMsg)
338
339 paths = getFileItems(pathFile, unique=True)
340
341 kb.bruteMode = True
342
343 try:
344 conf.dbmsHandler.readFile(randomStr())
345 except SqlmapNoneDataException:
346 pass
347 except:
348 kb.bruteMode = False
349 raise
350
351 threadData = getCurrentThreadData()
352 threadData.shared.count = 0
353 threadData.shared.limit = len(paths)
354 threadData.shared.files = []
355
356 def fileExistsThread():
357 threadData = getCurrentThreadData()
358
359 while kb.threadContinue:
360 kb.locks.count.acquire()
361 if threadData.shared.count < threadData.shared.limit:
362 path = ntToPosixSlashes(paths[threadData.shared.count])
363 threadData.shared.count += 1
364 kb.locks.count.release()
365 else:
366 kb.locks.count.release()
367 break
368
369 try:
370 result = unArrayizeValue(conf.dbmsHandler.readFile(path))
371 except SqlmapNoneDataException:
372 result = None
373
374 kb.locks.io.acquire()
375
376 if not isNoneValue(result):
377 threadData.shared.files.append(result)
378
379 if not conf.api:
380 clearConsoleLine(True)
381 infoMsg = "[%s] [INFO] retrieved: '%s'\n" % (time.strftime("%X"), path)

Callers 1

actionFunction · 0.90

Calls 9

readInputFunction · 0.90
getFileItemsFunction · 0.90
randomStrFunction · 0.90
getCurrentThreadDataFunction · 0.90
runThreadsFunction · 0.90
clearConsoleLineFunction · 0.90
dataToStdoutFunction · 0.90
infoMethod · 0.80
readFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…