同步操作将从 yeqingchen1/sqlmap 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python"""Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)See the file 'LICENSE' for copying permission"""import reimport socketfrom lib.core.common import getSafeExStringfrom lib.core.common import popValuefrom lib.core.common import pushValuefrom lib.core.common import readInputfrom lib.core.common import urlencodefrom lib.core.convert import getUnicodefrom lib.core.data import conffrom lib.core.data import kbfrom lib.core.data import loggerfrom lib.core.decorators import stackedmethodfrom lib.core.enums import CUSTOM_LOGGINGfrom lib.core.enums import HTTP_HEADERfrom lib.core.enums import REDIRECTIONfrom lib.core.exception import SqlmapBaseExceptionfrom lib.core.exception import SqlmapConnectionExceptionfrom lib.core.exception import SqlmapUserQuitExceptionfrom lib.core.settings import BING_REGEXfrom lib.core.settings import DUCKDUCKGO_REGEXfrom lib.core.settings import DUMMY_SEARCH_USER_AGENTfrom lib.core.settings import GOOGLE_REGEXfrom lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUEfrom lib.core.settings import UNICODE_ENCODINGfrom lib.request.basic import decodePagefrom thirdparty.six.moves import http_client as _http_clientfrom thirdparty.six.moves import urllib as _urllibfrom thirdparty.socks import socksdef _search(dork):"""This method performs the effective search on Google providingthe google dork and the Google session cookie"""if not dork:return Nonepage = Nonedata = NonerequestHeaders = {}responseHeaders = {}requestHeaders[HTTP_HEADER.USER_AGENT] = dict(conf.httpHeaders).get(HTTP_HEADER.USER_AGENT, DUMMY_SEARCH_USER_AGENT)requestHeaders[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUEtry:req = _urllib.request.Request("https://www.google.com/ncr", headers=requestHeaders)conn = _urllib.request.urlopen(req)except Exception as ex:errMsg = "unable to connect to Google ('%s')" % getSafeExString(ex)raise SqlmapConnectionException(errMsg)gpage = conf.googlePage if conf.googlePage > 1 else 1logger.info("using search result page #%d" % gpage)url = "https://www.google.com/search?"url += "q=%s&" % urlencode(dork, convall=True)url += "num=100&hl=en&complete=0&safe=off&filter=0&btnG=Search"url += "&start=%d" % ((gpage - 1) * 100)try:req = _urllib.request.Request(url, headers=requestHeaders)conn = _urllib.request.urlopen(req)requestMsg = "HTTP request:\nGET %s" % urlrequestMsg += " %s" % _http_client.HTTPConnection._http_vsn_strlogger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)page = conn.read()code = conn.codestatus = conn.msgresponseHeaders = conn.info()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 _urllib.error.HTTPError as ex:try:page = ex.read()responseHeaders = ex.info()except Exception as _:warnMsg = "problem occurred while trying to get "warnMsg += "an error page information (%s)" % getSafeExString(_)logger.critical(warnMsg)return Noneexcept (_urllib.error.URLError, _http_client.error, socket.error, socket.timeout, socks.ProxyError):errMsg = "unable to connect to Google"raise SqlmapConnectionException(errMsg)page = decodePage(page, responseHeaders.get(HTTP_HEADER.CONTENT_ENCODING), responseHeaders.get(HTTP_HEADER.CONTENT_TYPE))retVal = [_urllib.parse.unquote(match.group(1) or match.group(2)) for match in re.finditer(GOOGLE_REGEX, page, re.I)]if not retVal and "detected unusual traffic" in page:warnMsg = "Google has detected 'unusual' traffic from "warnMsg += "used IP address disabling further searches"if conf.proxyList:raise SqlmapBaseException(warnMsg)else:logger.critical(warnMsg)if not retVal:message = "no usable links found. What do you want to do?"message += "\n[1] (re)try with DuckDuckGo (default)"message += "\n[2] (re)try with Bing"message += "\n[3] quit"choice = readInput(message, default='1')if choice == '3':raise SqlmapUserQuitExceptionelif choice == '2':url = "https://www.bing.com/search?q=%s&first=%d" % (urlencode(dork, convall=True), (gpage - 1) * 10 + 1)regex = BING_REGEXelse:url = "https://duckduckgo.com/html/"data = "q=%s&s=%d" % (urlencode(dork, convall=True), (gpage - 1) * 30)regex = DUCKDUCKGO_REGEXtry:req = _urllib.request.Request(url, data=data, headers=requestHeaders)conn = _urllib.request.urlopen(req)requestMsg = "HTTP request:\nGET %s" % urlrequestMsg += " %s" % _http_client.HTTPConnection._http_vsn_strlogger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)page = conn.read()code = conn.codestatus = conn.msgresponseHeaders = 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 _urllib.error.HTTPError as ex:try:page = ex.read()page = decodePage(page, ex.headers.get("Content-Encoding"), ex.headers.get("Content-Type"))except socket.timeout:warnMsg = "connection timed out while trying "warnMsg += "to get error page information (%d)" % ex.codelogger.critical(warnMsg)return Noneexcept:errMsg = "unable to connect"raise SqlmapConnectionException(errMsg)retVal = [_urllib.parse.unquote(match.group(1).replace("&", "&")) for match in re.finditer(regex, page, re.I | re.S)]if not retVal and "issue with the Tor Exit Node you are currently using" in page:warnMsg = "DuckDuckGo has detected 'unusual' traffic from "warnMsg += "used (Tor) IP address"if conf.proxyList:raise SqlmapBaseException(warnMsg)else:logger.critical(warnMsg)return retVal@stackedmethoddef search(dork):pushValue(kb.redirectChoice)kb.redirectChoice = REDIRECTION.YEStry:return _search(dork)except SqlmapBaseException as ex:if conf.proxyList:logger.critical(getSafeExString(ex))warnMsg = "changing proxy"logger.warn(warnMsg)conf.proxy = NonesetHTTPHandlers()return search(dork)else:raisefinally:kb.redirectChoice = popValue()def setHTTPHandlers(): # Cross-referenced functionraise NotImplementedError
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。