Skip to content

Commit

Permalink
Fix how requests are handled to fix plugin scan
Browse files Browse the repository at this point in the history
  • Loading branch information
atarantini committed Aug 6, 2011
1 parent c34da58 commit c79a6d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion wpbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run(self):
# load into wordlist additional keywords from blog main page
if args.nokeywords:
wordlist.append(wplib.filter_domain(urlparse.urlparse(wp.get_base_url()).hostname)) # add domain name to the queue
[wordlist.append(w) for w in wp.find_keywords_in_url(config.min_keyword_len, config.min_frequency, config.ignore_with) ]
[wordlist.append(w.strip()) for w in wp.find_keywords_in_url(config.min_keyword_len, config.min_frequency, config.ignore_with)]

# load logins into task queue
logger.info("%s passwords will be tested", str(len(wordlist)))
Expand All @@ -155,6 +155,7 @@ def run(self):
login_task.setUsername(config.username)
login_task.setPassword(password)
task_queue.put(login_task)
del wordlist

# start workers
logger.info("Starting workers...")
Expand Down
12 changes: 7 additions & 5 deletions wplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ def request(self, url, params, cache=False, data=True):
self.logger.debug("Requesting %s %s", url, params)
try:
response = opener.open(request, urllib.urlencode(params))
response_data = response.read()
except urllib2.HTTPError:
return False

if cache and data and len(params) is 0:
self._cache[url] = response.read()
self._cache[url] = response_data
pass

if data:
return response.read()
return response_data

return response

Expand Down Expand Up @@ -302,7 +304,7 @@ def find_keywords_in_url(self, min_keyword_len=3, min_frequency=2, ignore_with=F
min_frequency -- Filter keywords number of times than a keyword appears within the content
ignore_with -- Ignore words that contains any characters in this list
"""
data = self.request(self._base_url, [], True)
data = self.request(self._base_url, [], cache=True)
keywords = []

# get keywords from title
Expand Down Expand Up @@ -343,8 +345,8 @@ def check_plugin(self, plugin):
return - WordPress version or false if not found
"""
url = self._base_url+"wp-content/plugins/"+plugin
data = self.request(url, [], True)
if data:
data = self.request(url, [])
if data is not False:
return True
else:
return False
Expand Down

0 comments on commit c79a6d4

Please sign in to comment.