-
Notifications
You must be signed in to change notification settings - Fork 159
/
identify.py
74 lines (63 loc) · 2.84 KB
/
identify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author = EASY
import os
import re
import json
from config.data import path
from config.color import color
from config.data import logging,Webinfo
class Identify:
def __init__(self):
filepath = os.path.join(path.library,'finger.json')
with open(filepath, 'r', encoding='utf-8') as file:
finger= json.load(file)
for name,value in finger.items():
self.obj = value
# 初始化指纹库
self._prepare_app()
def run(self,datas):
self.datas = datas
cms = self._has_app()
if cms:
self.datas["cms"] = str(set(cms)).replace("{","").replace("}","")
Webinfo.result.insert(0,{"url": self.datas["url"], "cms": self.datas["cms"], "title": self.datas["title"],
"status": self.datas["status"], "Server": self.datas['Server'],
"size": self.datas["size"]})
else:
self.datas["cms"] = ""
Webinfo.result.append({"url": self.datas["url"], "cms": self.datas["cms"], "title": self.datas["title"],
"status": self.datas["status"], "Server": self.datas['Server'],
"size": self.datas["size"]})
Msg = "{0} {1} {2} {4} {3}".format(color.green(self.datas['cms']),
color.blue(self.datas['Server']), self.datas['title'],
color.yellow(self.datas['status']), self.datas["url"])
logging.success(Msg)
def _prepare_app(self):
for line in self.obj:
if "regula" == line["method"]:
self.obj[self.obj.index(line)]["keyword"] = self._prepare_pattern(line["keyword"][0])
def _prepare_pattern(self, pattern):
regex, _, rest = pattern.partition('\\;')
try:
return re.compile(regex, re.I)
except re.error as e:
return re.compile(r'(?!x)x')
def _has_app(self):
cms = []
for line in self.obj:
flag = 1
if line['method'] == "faviconhash" and str(self.datas["faviconhash"]) == line["keyword"][0]:
cms.append(line["cms"])
elif line["method"] == "keyword":
for key in line["keyword"]:
if key not in str(self.datas[line["location"]]):
flag = 0
if flag == 1:
cms.append(line["cms"])
elif line["method"] == "regula":
if line["keyword"].search(self.datas[line["location"]]):
cms.append(line["cms"])
else:
pass
return cms