Skip to content

Commit cfa7b3c

Browse files
committed
Implements sqlmapproject#4656
1 parent 76b310c commit cfa7b3c

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/core/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import re
1212
import string
1313
import sys
14+
import time
1415

1516
from lib.core.enums import DBMS
1617
from lib.core.enums import DBMS_DIRECTORY_NAME
1718
from lib.core.enums import OS
1819
from thirdparty.six import unichr as _unichr
1920

2021
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.5.4.8"
22+
VERSION = "1.5.4.9"
2223
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2324
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2425
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -125,6 +126,9 @@
125126
# Regular expression used for extracting results from Google search
126127
GOOGLE_REGEX = r"webcache\.googleusercontent\.com/search\?q=cache:[^:]+:([^+]+)\+&amp;cd=|url\?\w+=((?![^>]+webcache\.googleusercontent\.com)http[^>]+)&(sa=U|rct=j)"
127128

129+
# Google Search consent cookie
130+
GOOGLE_CONSENT_COOKIE = "CONSENT=YES+shp.gws-%s-0-RC1.%s+FX+740" % (time.strftime("%Y%m%d"), "".join(random.sample(string.ascii_lowercase, 2)))
131+
128132
# Regular expression used for extracting results from DuckDuckGo search
129133
DUCKDUCKGO_REGEX = r'<a class="result__url" href="(htt[^"]+)'
130134

lib/utils/search.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from lib.core.settings import BING_REGEX
2929
from lib.core.settings import DUCKDUCKGO_REGEX
3030
from lib.core.settings import DUMMY_SEARCH_USER_AGENT
31+
from lib.core.settings import GOOGLE_CONSENT_COOKIE
3132
from lib.core.settings import GOOGLE_REGEX
3233
from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE
3334
from lib.core.settings import UNICODE_ENCODING
@@ -52,6 +53,7 @@ def _search(dork):
5253

5354
requestHeaders[HTTP_HEADER.USER_AGENT] = dict(conf.httpHeaders).get(HTTP_HEADER.USER_AGENT, DUMMY_SEARCH_USER_AGENT)
5455
requestHeaders[HTTP_HEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE
56+
requestHeaders[HTTP_HEADER.COOKIE] = GOOGLE_CONSENT_COOKIE
5557

5658
try:
5759
req = _urllib.request.Request("https://www.google.com/ncr", headers=requestHeaders)
@@ -63,7 +65,7 @@ def _search(dork):
6365
gpage = conf.googlePage if conf.googlePage > 1 else 1
6466
logger.info("using search result page #%d" % gpage)
6567

66-
url = "http://www.google.com/search?" # NOTE: https version goes to the consent
68+
url = "https://www.google.com/search?" # NOTE: if consent fails, try to use the "http://"
6769
url += "q=%s&" % urlencode(dork, convall=True)
6870
url += "num=100&hl=en&complete=0&safe=off&filter=0&btnG=Search"
6971
url += "&start=%d" % ((gpage - 1) * 100)

0 commit comments

Comments
 (0)