Skip to content

Commit

Permalink
优化 CMS 识别插件
Browse files Browse the repository at this point in the history
  • Loading branch information
Chu committed Sep 29, 2014
1 parent 110b216 commit 6781522
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
10 changes: 2 additions & 8 deletions database/whatweb.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{
"discuz": [
{
"type": "hash",
"url": "/static/image/admincp/bg_repno.gif",
"md5": "403889213f03534a0651d7cfd6878b2c"
},
{
"type": "text",
"url": "/",
"text": "<meta name=\"generator\" content=\"Discuz!"
},
{
"type": "re",
"url": "/",
"regexp": "<script src=\".*?logging\\.js"
"text": "<meta name=\"generator\" content=\"Discuz!",
"regexp": "<script src=\".*?logging\\.js"
}
],
"phpwind": [
Expand Down
13 changes: 6 additions & 7 deletions plugins/multi/whatweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ def identify_cms(self, cms):
"""
for rule in self.rules[cms]:
try:
rule_type = rule["type"]
r = requests.get(self.url + rule["url"], timeout=5)
r.encoding = r.apparent_encoding
r.close()
if (rule_type == "hash"
if ("md5" in rule
and hashlib.md5(r.content).hexdigest() == rule["md5"]) \
or (rule_type == "text" and rule["text"] in r.text) \
or (rule_type == "re" and
re.search(rule["regexp"], r.text)) \
or (rule_type == "header" and rule["field"] in r.headers
and rule["value"] in r.headers[rule["field"]]):
or ("field" in rule
and rule["value"] in r.headers[rule["field"]]) \
or ("text" in rule and rule["text"] in r.text) \
or ("regexp" in rule
and re.search(rule["regexp"], r.text)):
return cms

except Exception:
Expand Down

0 comments on commit 6781522

Please sign in to comment.