@@ -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
470474def _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 ()
0 commit comments