MCPcopy Create free account
hub / github.com/EASY233/Finger / Identify

Class Identify

lib/identify.py:13–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class Identify:
14 def __init__(self):
15 filepath = os.path.join(path.library, 'finger.json')
16 with open(filepath, 'r', encoding='utf-8') as file:
17 finger = json.load(file)
18 for name, value in finger.items():
19 self.obj = value
20 # 初始化指纹库
21 self._prepare_app()
22
23 def run(self, datas):
24 self.datas = datas
25 cms = self._has_app()
26 self.datas["cms"] = ','.join(set(cms))
27 _url = "://{0}".format(urlsplit(self.datas['url']).netloc) # 添加://降低误报率
28 _webinfo = str(Webinfo.result)
29 if _url in _webinfo and self.datas["title"] in _webinfo:
30 pass
31 else:
32 results = {"url": self.datas["url"], "cms": self.datas["cms"], "title": self.datas["title"],
33 "status": self.datas["status"], "Server": self.datas['Server'],
34 "size": self.datas["size"], "iscdn": self.datas["iscdn"], "ip": self.datas["ip"],
35 "address": self.datas["address"], "isp": self.datas["isp"]}
36 if cms:
37 Webinfo.result.insert(0, results)
38 else:
39 Webinfo.result.append(results)
40 Msg = "{0} {1} {2} {4} {3}".format(color.green(self.datas['cms']),
41 color.blue(self.datas['Server']), self.datas['title'],
42 color.yellow(self.datas['status']), self.datas["url"])
43 logging.success(Msg)
44
45 def _prepare_app(self):
46 for line in self.obj:
47 if "regula" == line["method"]:
48 self.obj[self.obj.index(line)]["keyword"] = self._prepare_pattern(line["keyword"][0])
49
50 def _prepare_pattern(self, pattern):
51 regex, _, rest = pattern.partition('\\;')
52 try:
53 return re.compile(regex, re.I)
54 except re.error as e:
55 return re.compile(r'(?!x)x')
56
57 def _has_app(self):
58 cms = []
59 for line in self.obj:
60 flag = 1
61 if line['method'] == "faviconhash" and str(self.datas["faviconhash"]) == line["keyword"][0]:
62 cms.append(line["cms"])
63 elif line["method"] == "keyword":
64 for key in line["keyword"]:
65 if key not in str(self.datas[line["location"]]):
66 flag = 0
67 if flag == 1:
68 cms.append(line["cms"])
69 elif line["method"] == "regula":
70 if line["keyword"].search(self.datas[line["location"]]):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected