@@ -45,6 +45,7 @@ def _search(dork):
4545 if not dork :
4646 return None
4747
48+ data = None
4849 headers = {}
4950
5051 headers [HTTP_HEADER .USER_AGENT ] = dict (conf .httpHeaders ).get (HTTP_HEADER .USER_AGENT , DUMMY_SEARCH_USER_AGENT )
@@ -123,12 +124,12 @@ def _search(dork):
123124 url = "https://www.bing.com/search?q=%s&first=%d" % (urlencode (dork , convall = True ), (gpage - 1 ) * 10 + 1 )
124125 regex = BING_REGEX
125126 else :
126- url = "https://duckduckgo.com/d.js? "
127- url + = "q=%s&p =%d&s=100 " % (urlencode (dork , convall = True ), gpage )
127+ url = "https://duckduckgo.com/html/ "
128+ data = "q=%s&s =%d" % (urlencode (dork , convall = True ), ( gpage - 1 ) * 30 )
128129 regex = DUCKDUCKGO_REGEX
129130
130131 try :
131- req = urllib2 .Request (url , headers = headers )
132+ req = urllib2 .Request (url , data = data , headers = headers )
132133 conn = urllib2 .urlopen (req )
133134
134135 requestMsg = "HTTP request:\n GET %s" % url
@@ -152,6 +153,7 @@ def _search(dork):
152153 except urllib2 .HTTPError , e :
153154 try :
154155 page = e .read ()
156+ page = decodePage (page , e .headers .get ("Content-Encoding" ), e .headers .get ("Content-Type" ))
155157 except socket .timeout :
156158 warnMsg = "connection timed out while trying "
157159 warnMsg += "to get error page information (%d)" % e .code
@@ -163,6 +165,15 @@ def _search(dork):
163165
164166 retVal = [urllib .unquote (match .group (1 )) for match in re .finditer (regex , page , re .I | re .S )]
165167
168+ if not retVal and "issue with the Tor Exit Node you are currently using" in page :
169+ warnMsg = "DuckDuckGo has detected 'unusual' traffic from "
170+ warnMsg += "used (Tor) IP address"
171+
172+ if conf .proxyList :
173+ raise SqlmapBaseException (warnMsg )
174+ else :
175+ logger .critical (warnMsg )
176+
166177 return retVal
167178
168179@stackedmethod
0 commit comments