mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-02 20:54:13 +03:00
Fixes #1237
This commit is contained in:
parent
d2a9c7584f
commit
d70215ad6c
|
@ -75,6 +75,12 @@ GOOGLE_REGEX = r"url\?\w+=((?![^>]+webcache\.googleusercontent\.com)http[^>]+)&(
|
||||||
# Regular expression used for extracting results from DuckDuckGo search
|
# Regular expression used for extracting results from DuckDuckGo search
|
||||||
DUCKDUCKGO_REGEX = r'"u":"([^"]+)'
|
DUCKDUCKGO_REGEX = r'"u":"([^"]+)'
|
||||||
|
|
||||||
|
# Regular expression used for extracting results from Disconnect Search
|
||||||
|
DISCONNECT_SEARCH_REGEX = r'<p class="url wrapword">([^<]+)</p>'
|
||||||
|
|
||||||
|
# Dummy user agent for search (if default one returns different results)
|
||||||
|
DUMMY_SEARCH_USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0"
|
||||||
|
|
||||||
# Regular expression used for extracting content from "textual" tags
|
# Regular expression used for extracting content from "textual" tags
|
||||||
TEXT_TAG_REGEX = r"(?si)<(abbr|acronym|b|blockquote|br|center|cite|code|dt|em|font|h\d|i|li|p|pre|q|strong|sub|sup|td|th|title|tt|u)(?!\w).*?>(?P<result>[^<]+)"
|
TEXT_TAG_REGEX = r"(?si)<(abbr|acronym|b|blockquote|br|center|cite|code|dt|em|font|h\d|i|li|p|pre|q|strong|sub|sup|td|th|title|tt|u)(?!\w).*?>(?P<result>[^<]+)"
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,11 @@ from lib.core.enums import CUSTOM_LOGGING
|
||||||
from lib.core.enums import HTTP_HEADER
|
from lib.core.enums import HTTP_HEADER
|
||||||
from lib.core.exception import SqlmapConnectionException
|
from lib.core.exception import SqlmapConnectionException
|
||||||
from lib.core.exception import SqlmapGenericException
|
from lib.core.exception import SqlmapGenericException
|
||||||
from lib.core.settings import GOOGLE_REGEX
|
from lib.core.exception import SqlmapUserQuitException
|
||||||
|
from lib.core.settings import DUMMY_SEARCH_USER_AGENT
|
||||||
from lib.core.settings import DUCKDUCKGO_REGEX
|
from lib.core.settings import DUCKDUCKGO_REGEX
|
||||||
|
from lib.core.settings import DISCONNECT_SEARCH_REGEX
|
||||||
|
from lib.core.settings import GOOGLE_REGEX
|
||||||
from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE
|
from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE
|
||||||
from lib.core.settings import UNICODE_ENCODING
|
from lib.core.settings import UNICODE_ENCODING
|
||||||
from lib.request.basic import decodePage
|
from lib.request.basic import decodePage
|
||||||
|
@ -108,54 +111,67 @@ class Google(object):
|
||||||
raise SqlmapGenericException(warnMsg)
|
raise SqlmapGenericException(warnMsg)
|
||||||
|
|
||||||
if not retVal:
|
if not retVal:
|
||||||
message = "no usable links found. "
|
message = "no usable links found. What do you want to do?"
|
||||||
message += "do you want to (re)try with DuckDuckGo? [Y/n] "
|
message += "\n[1] (re)try with DuckDuckGo (default)"
|
||||||
output = readInput(message, default="Y")
|
message += "\n[2] (re)try with Disconnect Search"
|
||||||
|
message += "\n[3] quit"
|
||||||
|
choice = readInput(message, default="1").strip().upper()
|
||||||
|
|
||||||
if output.strip().lower() != 'n':
|
if choice == "Q":
|
||||||
|
raise SqlmapUserQuitException
|
||||||
|
elif choice == "2":
|
||||||
|
url = "https://search.disconnect.me/searchTerms/search?"
|
||||||
|
url += "start=nav&option=Web"
|
||||||
|
url += "&query=%s" % urlencode(dork, convall=True)
|
||||||
|
url += "&ses=Google&location_option=US"
|
||||||
|
url += "&nextDDG=%s" % urlencode("/search?q=&num=100&hl=en&start=%d&sa=N" % ((gpage - 1) * 10), convall=True)
|
||||||
|
url += "&sa=N&showIcons=false&filterIcons=none&js_enabled=1"
|
||||||
|
regex = DISCONNECT_SEARCH_REGEX
|
||||||
|
else:
|
||||||
url = "https://duckduckgo.com/d.js?"
|
url = "https://duckduckgo.com/d.js?"
|
||||||
url += "q=%s&p=%d&s=100" % (urlencode(dork, convall=True), gpage)
|
url += "q=%s&p=%d&s=100" % (urlencode(dork, convall=True), gpage)
|
||||||
|
regex = DUCKDUCKGO_REGEX
|
||||||
|
|
||||||
if not conf.randomAgent:
|
if not conf.randomAgent:
|
||||||
self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.USER_AGENT.lower()]
|
self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.USER_AGENT.lower()]
|
||||||
self.opener.addheaders.append((HTTP_HEADER.USER_AGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0"))
|
self.opener.addheaders.append((HTTP_HEADER.USER_AGENT, DUMMY_SEARCH_USER_AGENT))
|
||||||
|
|
||||||
self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.ACCEPT_ENCODING.lower()]
|
self.opener.addheaders = [_ for _ in self.opener.addheaders if _[0].lower() != HTTP_HEADER.ACCEPT_ENCODING.lower()]
|
||||||
self.opener.addheaders.append((HTTP_HEADER.ACCEPT_ENCODING, HTTP_ACCEPT_ENCODING_HEADER_VALUE))
|
self.opener.addheaders.append((HTTP_HEADER.ACCEPT_ENCODING, HTTP_ACCEPT_ENCODING_HEADER_VALUE))
|
||||||
|
|
||||||
|
try:
|
||||||
|
conn = self.opener.open(url)
|
||||||
|
|
||||||
|
requestMsg = "HTTP request:\nGET %s" % url
|
||||||
|
requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
|
||||||
|
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
||||||
|
|
||||||
|
page = conn.read()
|
||||||
|
code = conn.code
|
||||||
|
status = conn.msg
|
||||||
|
responseHeaders = conn.info()
|
||||||
|
page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))
|
||||||
|
|
||||||
|
responseMsg = "HTTP response (%s - %d):\n" % (status, code)
|
||||||
|
|
||||||
|
if conf.verbose <= 4:
|
||||||
|
responseMsg += getUnicode(responseHeaders, UNICODE_ENCODING)
|
||||||
|
elif conf.verbose > 4:
|
||||||
|
responseMsg += "%s\n%s\n" % (responseHeaders, page)
|
||||||
|
|
||||||
|
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
|
||||||
|
except urllib2.HTTPError, e:
|
||||||
try:
|
try:
|
||||||
conn = self.opener.open(url)
|
page = e.read()
|
||||||
|
except socket.timeout:
|
||||||
|
warnMsg = "connection timed out while trying "
|
||||||
|
warnMsg += "to get error page information (%d)" % e.code
|
||||||
|
logger.critical(warnMsg)
|
||||||
|
return None
|
||||||
|
except:
|
||||||
|
errMsg = "unable to connect"
|
||||||
|
raise SqlmapConnectionException(errMsg)
|
||||||
|
|
||||||
requestMsg = "HTTP request:\nGET %s" % url
|
retVal = [urllib.unquote(match.group(1)) for match in re.finditer(regex, page, re.I | re.S)]
|
||||||
requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
|
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
|
||||||
|
|
||||||
page = conn.read()
|
|
||||||
code = conn.code
|
|
||||||
status = conn.msg
|
|
||||||
responseHeaders = conn.info()
|
|
||||||
page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))
|
|
||||||
|
|
||||||
responseMsg = "HTTP response (%s - %d):\n" % (status, code)
|
|
||||||
|
|
||||||
if conf.verbose <= 4:
|
|
||||||
responseMsg += getUnicode(responseHeaders, UNICODE_ENCODING)
|
|
||||||
elif conf.verbose > 4:
|
|
||||||
responseMsg += "%s\n%s\n" % (responseHeaders, page)
|
|
||||||
|
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
|
|
||||||
except urllib2.HTTPError, e:
|
|
||||||
try:
|
|
||||||
page = e.read()
|
|
||||||
except socket.timeout:
|
|
||||||
warnMsg = "connection timed out while trying "
|
|
||||||
warnMsg += "to get error page information (%d)" % e.code
|
|
||||||
logger.critical(warnMsg)
|
|
||||||
return None
|
|
||||||
except:
|
|
||||||
errMsg = "unable to connect to DuckDuckGo"
|
|
||||||
raise SqlmapConnectionException(errMsg)
|
|
||||||
|
|
||||||
retVal = [urllib.unquote(match.group(1)) for match in re.finditer(DUCKDUCKGO_REGEX, page, re.I | re.S)]
|
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user