Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified Finger.py
100644 → 100755
Empty file.
Binary file added api/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/fofa.cpython-310.pyc
Binary file not shown.
Binary file added api/__pycache__/quake.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/color.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/config.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/data.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/datatype.cpython-310.pyc
Binary file not shown.
Binary file added config/__pycache__/log.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/IpFactory.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/checkenv.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/cmdline.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/identify.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/ip2Region.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/ipAttributable.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/options.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/output.cpython-310.pyc
Binary file not shown.
Binary file added lib/__pycache__/req.cpython-310.pyc
Binary file not shown.
64 changes: 42 additions & 22 deletions lib/checkenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
import time
import requests
import hashlib
from config.config import head,FingerPrint_Update
from config.data import path,logging
from config.config import head, FingerPrint_Update
from config.data import path, logging


class CheckEnv:

def __init__(self):
self.pyVersion = platform.python_version()
self.path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
self.path = os.path.dirname(os.path.dirname(
os.path.realpath(__file__)))
self.python_check()
self.path_check()
if FingerPrint_Update:
self.update()

def python_check(self):
if self.pyVersion < "3.6":
logging.error("此Python版本 ('{0}') 不兼容,成功运行程序你必须使用版本 >= 3.6 (访问 ‘https://www.python.org/downloads/".format(self.pyVersion))
if self.compare_version(self.pyVersion, "3.6") < 1:
logging.error(
"此Python版本 ('{0}') 不兼容,成功运行程序你必须使用版本 >= 3.6 (访问 ‘https://www.python.org/downloads/"
.format(self.pyVersion))
exit(0)

def path_check(self):
Expand All @@ -32,8 +37,8 @@ def path_check(self):
logging.error(errMsg)
exit(0)
path.home = self.path
path.output = os.path.join(self.path,'output')
path.config = os.path.join(self.path,'config')
path.output = os.path.join(self.path, 'output')
path.config = os.path.join(self.path, 'config')
path.library = os.path.join(self.path, 'library')
if not os.path.exists(path.output):
warnMsg = "The output folder is not created, it will be created automatically"
Expand All @@ -46,27 +51,42 @@ def update(self):
nowTime = time.strftime("%Y%m%d%H%M%S", time.localtime())
logging.info("正在在线更新指纹库。。")
Fingerprint_Page = "https://cdn.jsdelivr.net/gh/EASY233/Finger/library/finger.json"
response = requests.get(Fingerprint_Page,timeout = 10,headers = head)
filepath = os.path.join(path.library,"finger.json")
bakfilepath = os.path.join(path.library,"finger_{}.json.bak".format(nowTime))
with open(filepath,"rb") as file:
if hashlib.md5(file.read()).hexdigest() == hashlib.md5(response.content).hexdigest():
response = requests.get(Fingerprint_Page, timeout=10, headers=head)
filepath = os.path.join(path.library, "finger.json")
bakfilepath = os.path.join(path.library,
"finger_{}.json.bak".format(nowTime))
with open(filepath, "rb") as file:
if hashlib.md5(file.read()).hexdigest() == hashlib.md5(
response.content).hexdigest():
logging.info("指纹库已经是最新")
is_update = False
if is_update:
logging.info("检查到指纹库有更新,正在同步指纹库。。。")
os.rename(filepath,bakfilepath)
with open(filepath,"wb") as file:
os.rename(filepath, bakfilepath)
with open(filepath, "wb") as file:
file.write(response.content)
with open(filepath,'rb') as file:
Msg = "更新成功!" if hashlib.md5(file.read()).hexdigest() == hashlib.md5(response.content).hexdigest() else "更新失败"
with open(filepath, 'rb') as file:
Msg = "更新成功!" if hashlib.md5(
file.read()).hexdigest() == hashlib.md5(
response.content).hexdigest() else "更新失败"
logging.info(Msg)
except Exception as e:
logging.warning("在线更新指纹库失败!")







def compare_version(self, ver1, ver2):
list1 = str(ver1).split(".")
list2 = str(ver2).split(".")
for i in range(len(list1)) if len(list1) < len(list2) else range(
len(list2)):
if int(list1[i]) == int(list2[i]):
pass
elif int(list1[i]) < int(list2[i]):
return -1
else:
return 1
if len(list1) == len(list2):
return 0
elif len(list1) < len(list2):
return -1
else:
return 1