8585from lib .core .log import LOGGER_HANDLER
8686from lib .core .optiondict import optDict
8787from lib .core .purge import purge
88+ from lib .core .settings import ACCESS_ALIASES
89+ from lib .core .settings import BURP_REQUEST_REGEX
8890from lib .core .settings import CODECS_LIST_PAGE
8991from lib .core .settings import CRAWL_EXCLUDE_EXTENSIONS
92+ from lib .core .settings import DB2_ALIASES
9093from lib .core .settings import DEFAULT_GET_POST_DELIMITER
9194from lib .core .settings import DEFAULT_PAGE_ENCODING
9295from lib .core .settings import DEFAULT_TOR_HTTP_PORTS
9396from lib .core .settings import DEFAULT_TOR_SOCKS_PORT
97+ from lib .core .settings import FIREBIRD_ALIASES
9498from lib .core .settings import IS_WIN
99+ from lib .core .settings import LOCALHOST
100+ from lib .core .settings import MAXDB_ALIASES
101+ from lib .core .settings import MAX_NUMBER_OF_THREADS
102+ from lib .core .settings import MSSQL_ALIASES
103+ from lib .core .settings import MYSQL_ALIASES
95104from lib .core .settings import NULL
105+ from lib .core .settings import ORACLE_ALIASES
106+ from lib .core .settings import PARAMETER_SPLITTING_REGEX
107+ from lib .core .settings import PGSQL_ALIASES
96108from lib .core .settings import PYVERSION
97109from lib .core .settings import SITE
110+ from lib .core .settings import SQLITE_ALIASES
98111from lib .core .settings import SUPPORTED_DBMS
99112from lib .core .settings import SUPPORTED_OS
100- from lib .core .settings import VERSION_STRING
101- from lib .core .settings import MSSQL_ALIASES
102- from lib .core .settings import MYSQL_ALIASES
103- from lib .core .settings import PGSQL_ALIASES
104- from lib .core .settings import ORACLE_ALIASES
105- from lib .core .settings import SQLITE_ALIASES
106- from lib .core .settings import ACCESS_ALIASES
107- from lib .core .settings import FIREBIRD_ALIASES
108- from lib .core .settings import MAXDB_ALIASES
109113from lib .core .settings import SYBASE_ALIASES
110- from lib .core .settings import DB2_ALIASES
111- from lib .core .settings import BURP_REQUEST_REGEX
112- from lib .core .settings import LOCALHOST
113- from lib .core .settings import MAX_NUMBER_OF_THREADS
114- from lib .core .settings import PARAMETER_SPLITTING_REGEX
115114from lib .core .settings import TIME_DELAY_CANDIDATES
116115from lib .core .settings import UNENCODED_ORIGINAL_VALUE
117116from lib .core .settings import UNION_CHAR_REGEX
118117from lib .core .settings import UNKNOWN_DBMS_VERSION
118+ from lib .core .settings import URI_INJECTABLE_REGEX
119+ from lib .core .settings import VERSION_STRING
119120from lib .core .settings import WEBSCARAB_SPLITTER
120121from lib .core .threads import getCurrentThreadData
121122from lib .core .update import update
@@ -212,8 +213,8 @@ def __parseWebScarabLog(content):
212213 continue
213214
214215 if not (conf .scope and not re .search (conf .scope , url , re .I )):
215- if not kb .targetUrls or url not in addedTargetUrls :
216- kb .targetUrls .add ((url , method , None , cookie ))
216+ if not kb .targets or url not in addedTargetUrls :
217+ kb .targets .add ((url , method , None , cookie ))
217218 addedTargetUrls .add (url )
218219
219220 def __parseBurpLog (content ):
@@ -322,8 +323,8 @@ def __parseBurpLog(content):
322323 port = None
323324
324325 if not (conf .scope and not re .search (conf .scope , url , re .I )):
325- if not kb .targetUrls or url not in addedTargetUrls :
326- kb .targetUrls .add ((url , method , urldecode (data ) if data and urlencode (DEFAULT_GET_POST_DELIMITER , None ) not in data else data , cookie ))
326+ if not kb .targets or url not in addedTargetUrls :
327+ kb .targets .add ((url , method , urldecode (data ) if data and urlencode (DEFAULT_GET_POST_DELIMITER , None ) not in data else data , cookie ))
327328 addedTargetUrls .add (url )
328329
329330 fp = openFile (reqFile , "rb" )
@@ -374,7 +375,7 @@ def __setMultipleTargets():
374375 mode.
375376 """
376377
377- initialTargetsCount = len (kb .targetUrls )
378+ initialTargetsCount = len (kb .targets )
378379 addedTargetUrls = set ()
379380
380381 if not conf .logFile :
@@ -405,7 +406,7 @@ def __setMultipleTargets():
405406 errMsg += "nor a directory"
406407 raise sqlmapFilePathException , errMsg
407408
408- updatedTargetsCount = len (kb .targetUrls )
409+ updatedTargetsCount = len (kb .targets )
409410
410411 if updatedTargetsCount > initialTargetsCount :
411412 infoMsg = "sqlmap parsed %d " % (updatedTargetsCount - initialTargetsCount )
@@ -493,37 +494,48 @@ def __setGoogleDorking():
493494 handlers .append (keepAliveHandler )
494495
495496 googleObj = Google (handlers )
496- googleObj . getCookie ()
497+ kb . data . onlyGETs = None
497498
498- def search ():
499- matches = googleObj .search (conf .googleDork )
499+ def retrieve ():
500+ links = googleObj .search (conf .googleDork )
500501
501- if not matches :
502+ if not links :
502503 errMsg = "unable to find results for your "
503504 errMsg += "Google dork expression"
504505 raise sqlmapGenericException , errMsg
505506
506- googleObj .getTargetUrls ()
507- return matches
507+ for link in links :
508+ link = urldecode (link )
509+ if re .search (r"(.*?)\?(.+)" , link ):
510+ kb .targets .add ((link , conf .method , conf .data , conf .cookie ))
511+ elif re .search (URI_INJECTABLE_REGEX , link , re .I ):
512+ if kb .data .onlyGETs is None and conf .data is None :
513+ message = "do you want to scan only results containing GET parameters? [Y/n] "
514+ test = readInput (message , default = "Y" )
515+ kb .data .onlyGETs = test .lower () != 'n'
516+ if not kb .data .onlyGETs :
517+ kb .targets .add ((link , conf .method , conf .data , conf .cookie ))
518+
519+ return links
508520
509521 while True :
510- matches = search ()
522+ links = retrieve ()
511523
512- if kb .targetUrls :
513- infoMsg = "sqlmap got %d results for your " % len (matches )
524+ if kb .targets :
525+ infoMsg = "sqlmap got %d results for your " % len (links )
514526 infoMsg += "Google dork expression, "
515527
516- if len (matches ) == len (kb .targetUrls ):
528+ if len (links ) == len (kb .targets ):
517529 infoMsg += "all "
518530 else :
519- infoMsg += "%d " % len (kb .targetUrls )
531+ infoMsg += "%d " % len (kb .targets )
520532
521533 infoMsg += "of them are testable targets"
522534 logger .info (infoMsg )
523535 break
524536
525537 else :
526- message = "sqlmap got %d results " % len (matches )
538+ message = "sqlmap got %d results " % len (links )
527539 message += "for your Google dork expression, but none of them "
528540 message += "have GET parameters to test for SQL injection. "
529541 message += "Do you want to skip to the next result page? [Y/n]"
@@ -550,7 +562,7 @@ def __setBulkMultipleTargets():
550562
551563 for line in getFileItems (conf .bulkFile ):
552564 if re .search (r"[^ ]+\?(.+)" , line , re .I ):
553- kb .targetUrls .add ((line .strip (), None , None , None ))
565+ kb .targets .add ((line .strip (), None , None , None ))
554566
555567def __findPageForms ():
556568 if not conf .forms or conf .crawlDepth :
@@ -1571,9 +1583,8 @@ def __setKnowledgeBaseAttributes(flushAll=True):
15711583 kb .headerPaths = {}
15721584 kb .keywords = set (getFileItems (paths .SQL_KEYWORDS ))
15731585 kb .passwordMgr = None
1574- kb .scanOnlyGoogleGETs = None
15751586 kb .tamperFunctions = []
1576- kb .targetUrls = oset ()
1587+ kb .targets = oset ()
15771588 kb .testedParams = set ()
15781589 kb .userAgents = None
15791590 kb .vainRun = True
0 commit comments