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

Skip to content

Commit 87ad11d

Browse files
committed
Fixes #4383 and #4384
1 parent 3663fa9 commit 87ad11d

3 files changed

Lines changed: 39 additions & 31 deletions

File tree

lib/core/option.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,14 @@ def retrieve():
413413
else:
414414
conf.googlePage += 1
415415

416-
def _setBulkMultipleTargets():
417-
if not conf.bulkFile:
418-
return
416+
def _setStdinPipeTargets():
417+
if isinstance(conf.stdinPipe, collections.Iterable):
418+
infoMsg = "using 'STDIN' for parsing targets list"
419+
logger.info(infoMsg)
419420

420-
if isinstance(conf.bulkFile, collections.Iterable):
421421
class _(object):
422422
def __init__(self):
423-
self.__rest = set()
423+
self.__rest = OrderedSet()
424424

425425
def __iter__(self):
426426
return self
@@ -429,43 +429,47 @@ def __next__(self):
429429
return self.next()
430430

431431
def next(self):
432-
line = next(conf.bulkFile)
432+
line = next(conf.stdinPipe)
433433
if line:
434-
match = re.search(r"\bhttps?://[^\s'\"]+", line, re.I)
434+
match = re.search(r"\b(https?://[^\s'\"]+|[\w.]+\.\w{2,3}[/\w+]*\?[^\s'\"]+)", line, re.I)
435435
if match:
436436
return (match.group(0), conf.method, conf.data, conf.cookie, None)
437437
elif self.__rest:
438438
return self.__rest.pop()
439-
else:
440-
raise StopIteration()
439+
440+
raise StopIteration()
441441

442442
def add(self, elem):
443443
self.__rest.add(elem)
444444

445445
kb.targets = _()
446-
else:
447-
conf.bulkFile = safeExpandUser(conf.bulkFile)
448446

449-
infoMsg = "parsing multiple targets list from '%s'" % conf.bulkFile
450-
logger.info(infoMsg)
447+
def _setBulkMultipleTargets():
448+
if not conf.bulkFile:
449+
return
451450

452-
if not checkFile(conf.bulkFile, False):
453-
errMsg = "the specified bulk file "
454-
errMsg += "does not exist"
455-
raise SqlmapFilePathException(errMsg)
451+
conf.bulkFile = safeExpandUser(conf.bulkFile)
456452

457-
found = False
458-
for line in getFileItems(conf.bulkFile):
459-
if conf.scope and not re.search(conf.scope, line, re.I):
460-
continue
453+
infoMsg = "parsing multiple targets list from '%s'" % conf.bulkFile
454+
logger.info(infoMsg)
461455

462-
if re.match(r"[^ ]+\?(.+)", line, re.I) or kb.customInjectionMark in line:
463-
found = True
464-
kb.targets.add((line.strip(), conf.method, conf.data, conf.cookie, None))
456+
if not checkFile(conf.bulkFile, False):
457+
errMsg = "the specified bulk file "
458+
errMsg += "does not exist"
459+
raise SqlmapFilePathException(errMsg)
465460

466-
if not found and not conf.forms and not conf.crawlDepth:
467-
warnMsg = "no usable links found (with GET parameters)"
468-
logger.warn(warnMsg)
461+
found = False
462+
for line in getFileItems(conf.bulkFile):
463+
if conf.scope and not re.search(conf.scope, line, re.I):
464+
continue
465+
466+
if re.match(r"[^ ]+\?(.+)", line, re.I) or kb.customInjectionMark in line:
467+
found = True
468+
kb.targets.add((line.strip(), conf.method, conf.data, conf.cookie, None))
469+
470+
if not found and not conf.forms and not conf.crawlDepth:
471+
warnMsg = "no usable links found (with GET parameters)"
472+
logger.warn(warnMsg)
469473

470474
def _findPageForms():
471475
if not conf.forms or conf.crawlDepth:
@@ -2802,7 +2806,7 @@ def init():
28022806

28032807
parseTargetDirect()
28042808

2805-
if any((conf.url, conf.logFile, conf.bulkFile, conf.requestFile, conf.googleDork)):
2809+
if any((conf.url, conf.logFile, conf.bulkFile, conf.requestFile, conf.googleDork, conf.stdinPipe)):
28062810
_setHostname()
28072811
_setHTTPTimeout()
28082812
_setHTTPExtraHeaders()
@@ -2816,6 +2820,7 @@ def init():
28162820
_setSocketPreConnect()
28172821
_setSafeVisit()
28182822
_doSearch()
2823+
_setStdinPipeTargets()
28192824
_setBulkMultipleTargets()
28202825
_checkTor()
28212826
_setCrawler()

lib/core/settings.py

Lines changed: 1 addition & 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.4.10.9"
21+
VERSION = "1.4.10.10"
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)

lib/parse/cmdline.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ def cmdLineParser(argv=None):
803803
parser.add_argument("--smoke-test", dest="smokeTest", action="store_true",
804804
help=SUPPRESS)
805805

806+
parser.add_argument("--stdin-pipe", dest="stdinPipe",
807+
help=SUPPRESS)
808+
806809
parser.add_argument("--vuln-test", dest="vulnTest", action="store_true",
807810
help=SUPPRESS)
808811

@@ -1036,9 +1039,9 @@ def _format_action_invocation(self, action):
10361039
args.url = args.url or DUMMY_URL
10371040

10381041
if hasattr(sys.stdin, "fileno") and not os.isatty(sys.stdin.fileno()) and '-' not in sys.argv:
1039-
args.bulkFile = iter(sys.stdin.readline, None)
1042+
args.stdinPipe = iter(sys.stdin.readline, None)
10401043

1041-
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.vulnTest, args.bedTest, args.fuzzTest, args.wizard, args.dependencies, args.purge, args.listTampers, args.hashFile)):
1044+
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.vulnTest, args.bedTest, args.fuzzTest, args.wizard, args.dependencies, args.purge, args.listTampers, args.hashFile, args.stdinPipe)):
10421045
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --list-tampers, --wizard, --update, --purge or --dependencies). "
10431046
errMsg += "Use -h for basic and -hh for advanced help\n"
10441047
parser.error(errMsg)

0 commit comments

Comments
 (0)