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

Skip to content

Commit 2bf22df

Browse files
committed
Implementing support for piped input of targets
1 parent 0585a55 commit 2bf22df

4 files changed

Lines changed: 36 additions & 20 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def start():
291291
logger.error(errMsg)
292292
return False
293293

294-
if kb.targets and len(kb.targets) > 1:
294+
if kb.targets and isListLike(kb.targets) and len(kb.targets) > 1:
295295
infoMsg = "found a total of %d targets" % len(kb.targets)
296296
logger.info(infoMsg)
297297

lib/core/option.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import division
99

1010
import codecs
11+
import collections
1112
import functools
1213
import glob
1314
import inspect
@@ -416,28 +417,39 @@ def _setBulkMultipleTargets():
416417
if not conf.bulkFile:
417418
return
418419

419-
conf.bulkFile = safeExpandUser(conf.bulkFile)
420+
if isinstance(conf.bulkFile, collections.Iterable):
421+
def _():
422+
for line in conf.bulkFile:
423+
if line:
424+
match = re.search(r"\bhttps?://[^\s'\"]+", line, re.I)
425+
if match:
426+
yield (match.group(0), conf.method, conf.data, conf.cookie, None)
427+
else:
428+
break
429+
kb.targets = _()
430+
else:
431+
conf.bulkFile = safeExpandUser(conf.bulkFile)
420432

421-
infoMsg = "parsing multiple targets list from '%s'" % conf.bulkFile
422-
logger.info(infoMsg)
433+
infoMsg = "parsing multiple targets list from '%s'" % conf.bulkFile
434+
logger.info(infoMsg)
423435

424-
if not checkFile(conf.bulkFile, False):
425-
errMsg = "the specified bulk file "
426-
errMsg += "does not exist"
427-
raise SqlmapFilePathException(errMsg)
436+
if not checkFile(conf.bulkFile, False):
437+
errMsg = "the specified bulk file "
438+
errMsg += "does not exist"
439+
raise SqlmapFilePathException(errMsg)
428440

429-
found = False
430-
for line in getFileItems(conf.bulkFile):
431-
if conf.scope and not re.search(conf.scope, line, re.I):
432-
continue
441+
found = False
442+
for line in getFileItems(conf.bulkFile):
443+
if conf.scope and not re.search(conf.scope, line, re.I):
444+
continue
433445

434-
if re.match(r"[^ ]+\?(.+)", line, re.I) or kb.customInjectionMark in line:
435-
found = True
436-
kb.targets.add((line.strip(), conf.method, conf.data, conf.cookie, None))
446+
if re.match(r"[^ ]+\?(.+)", line, re.I) or kb.customInjectionMark in line:
447+
found = True
448+
kb.targets.add((line.strip(), conf.method, conf.data, conf.cookie, None))
437449

438-
if not found and not conf.forms and not conf.crawlDepth:
439-
warnMsg = "no usable links found (with GET parameters)"
440-
logger.warn(warnMsg)
450+
if not found and not conf.forms and not conf.crawlDepth:
451+
warnMsg = "no usable links found (with GET parameters)"
452+
logger.warn(warnMsg)
441453

442454
def _findPageForms():
443455
if not conf.forms or conf.crawlDepth:
@@ -1631,7 +1643,8 @@ def _cleanupOptions():
16311643

16321644
for key, value in conf.items():
16331645
if value and any(key.endswith(_) for _ in ("Path", "File", "Dir")):
1634-
conf[key] = safeExpandUser(value)
1646+
if isinstance(value, str):
1647+
conf[key] = safeExpandUser(value)
16351648

16361649
if conf.testParameter:
16371650
conf.testParameter = urldecode(conf.testParameter)

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.5"
21+
VERSION = "1.4.10.6"
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,9 @@ def _format_action_invocation(self, action):
10351035
if args.dummy:
10361036
args.url = args.url or DUMMY_URL
10371037

1038+
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)
1040+
10381041
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)):
10391042
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --list-tampers, --wizard, --update, --purge or --dependencies). "
10401043
errMsg += "Use -h for basic and -hh for advanced help\n"

0 commit comments

Comments
 (0)