Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80c9976832 | ||
|
|
b6326c25b9 | ||
|
|
35f591cf49 | ||
|
|
67e437bbd7 | ||
|
|
194dae8ce1 | ||
|
|
a89442ceb0 | ||
|
|
24debf6062 | ||
|
|
ff98846c99 | ||
|
|
e3f5a0bca1 | ||
|
|
7278e4f051 | ||
|
|
709a511c1d | ||
|
|
452027f085 | ||
|
|
8574802428 | ||
|
|
79fb044921 | ||
|
|
13ac634fea | ||
|
|
04a68bc262 | ||
|
|
47de15ab68 | ||
|
|
512af24a05 | ||
|
|
e5ff46d3bb | ||
|
|
c7a0979140 | ||
|
|
7fd7245df2 | ||
|
|
026301b011 | ||
|
|
5cc77f90ae | ||
|
|
0d4568ac8a | ||
|
|
a6ed491a39 | ||
|
|
90dfc3f1ae | ||
|
|
36388fb0d7 | ||
|
|
043166d0c8 | ||
|
|
b92d488851 | ||
|
|
d841a04a89 | ||
|
|
d8553baa78 | ||
|
|
8521d5aee3 | ||
|
|
ebe21d9c7f | ||
|
|
3b83abdbd3 | ||
|
|
aead2463c9 | ||
|
|
5cc5676672 | ||
|
|
ecc32ca18d | ||
|
|
661640de79 | ||
|
|
96dfdab7ed | ||
|
|
56bed5fd3b | ||
|
|
3fd3b18406 | ||
|
|
45bac97a16 | ||
|
|
2c6eca4a92 | ||
|
|
8109d59655 | ||
|
|
8a15571cd2 | ||
|
|
a15c8f2e60 | ||
|
|
cec3d6c04d |
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import os, gc, sys, time, json, psutil
|
||||
import hashlib, pefile, socket, msvcrt
|
||||
import xml.etree.ElementTree as xmlet
|
||||
import os, gc, sys, time, json, yara
|
||||
import pefile, socket, msvcrt, psutil
|
||||
import requests, pyperclip, win32file
|
||||
import win32gui, win32api, win32con
|
||||
from PYAS_Engine import ListSimHash
|
||||
@@ -19,11 +18,12 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.setWindowFlags(Qt.FramelessWindowHint)
|
||||
self.pyas = sys.argv[0].replace("\\", "/")
|
||||
self.dir = os.path.dirname(self.pyas)
|
||||
self.pyae_version = "SimHash Engine"
|
||||
self.pyas_version = "3.0.8"
|
||||
self.pyae_version = "Fusion Engine"
|
||||
self.pyas_version = "3.1.0"
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.init_show_pyas()
|
||||
self.init_startup()
|
||||
self.init_rule_dict()
|
||||
self.init_data_base()
|
||||
self.init_read_json()
|
||||
self.init_tray_icon()
|
||||
@@ -50,12 +50,47 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.tray_icon.activated.connect(self.init_show_pyas)
|
||||
self.tray_icon.show()
|
||||
|
||||
def init_startup(self):
|
||||
try:
|
||||
if len(sys.argv) > 1:
|
||||
param = sys.argv[1]
|
||||
if "h" in param or "hid" in param:
|
||||
pass
|
||||
else:
|
||||
self.init_show_pyas()
|
||||
elif len(sys.argv) <= 1:
|
||||
self.init_show_pyas()
|
||||
except Exception as e:
|
||||
self.bug_event(e)
|
||||
|
||||
def init_data_base(self):
|
||||
try:
|
||||
file_path = os.path.join(self.dir, "PYAS_Model.json")
|
||||
if os.path.exists(file_path):
|
||||
self.pe = ListSimHash()
|
||||
self.pe.load_model(file_path)
|
||||
file_path = os.path.join(self.dir, "Model")
|
||||
for root, dirs, files in os.walk(file_path):
|
||||
for file in files:
|
||||
model_path = os.path.join(root, file)
|
||||
ftype = str(f".{file.split('.')[-1]}").lower()
|
||||
if ftype in [".json", ".txt"]:
|
||||
self.pe = ListSimHash()
|
||||
self.pe.load_model(model_path)
|
||||
elif ftype in [".h5", ".pkl"]:
|
||||
pass # Not Sp Yet !
|
||||
except Exception as e:
|
||||
self.bug_event(e)
|
||||
|
||||
def init_rule_dict(self):
|
||||
try:
|
||||
self.compiled_rules = {}
|
||||
file_path = os.path.join(self.dir, "Rules")
|
||||
for root, dirs, files in os.walk(file_path):
|
||||
for file in files:
|
||||
yara_path = os.path.join(root, file)
|
||||
ftype = str(f".{file.split('.')[-1]}").lower()
|
||||
if ftype in [".yara", ".yar"]:
|
||||
rules = yara.compile(yara_path)
|
||||
elif ftype in [".yc", ".yrc"]:
|
||||
rules = yara.load(yara_path)
|
||||
self.compiled_rules[yara_path] = rules
|
||||
except Exception as e:
|
||||
self.bug_event(e)
|
||||
|
||||
@@ -93,19 +128,19 @@ class MainWindow_Controller(QMainWindow):
|
||||
if not os.path.exists("C:/ProgramData/PYAS"):
|
||||
os.makedirs("C:/ProgramData/PYAS")
|
||||
if not os.path.exists("C:/ProgramData/PYAS/PYAS.json"):
|
||||
self.write_config({"high_sensitive":0,"cloud_services":1,
|
||||
self.write_config({"high_sensitive":0,"cloud_services":"http://127.0.0.1/",
|
||||
"language":"en_US","theme_color":"White","theme_custom":""})
|
||||
with open("C:/ProgramData/PYAS/PYAS.json", "r") as f:
|
||||
self.json = json.load(f)
|
||||
except:
|
||||
self.write_config({"high_sensitive":0,"cloud_services":1,
|
||||
self.write_config({"high_sensitive":0,"cloud_services":"http://127.0.0.1/",
|
||||
"language":"en_US","theme_color":"White","theme_custom":""})
|
||||
with open("C:/ProgramData/PYAS/PYAS.json", "r") as f:
|
||||
self.json = json.load(f)
|
||||
|
||||
def init_config_json(self):
|
||||
self.json["high_sensitive"] = self.json.get("high_sensitive", 0)
|
||||
self.json["cloud_services"] = self.json.get("cloud_services", 1)
|
||||
self.json["cloud_services"] = self.json.get("cloud_services", "http://127.0.0.1/")
|
||||
self.json["language"] = self.json.get("language", "en_US")
|
||||
self.json["theme_color"] = self.json.get("theme_color", "White")
|
||||
self.json["theme_custom"] = self.json.get("theme_custom", "")
|
||||
@@ -114,11 +149,6 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.ui.high_sensitivity_switch_Button.setStyleSheet("""
|
||||
QPushButton{border:none;background-color:rgb(200, 250, 200);border-radius: 10px;}
|
||||
QPushButton:hover{background-color:rgb(210, 250, 210);}""")
|
||||
if self.json["cloud_services"] == 1:
|
||||
self.ui.cloud_services_switch_Button.setText(self.trans("已開啟"))
|
||||
self.ui.cloud_services_switch_Button.setStyleSheet("""
|
||||
QPushButton{border:none;background-color:rgb(200, 250, 200);border-radius: 10px;}
|
||||
QPushButton:hover{background-color:rgb(210, 250, 210);}""")
|
||||
if self.json["language"] == "zh_TW":
|
||||
self.ui.Language_Traditional_Chinese.setChecked(True)
|
||||
elif self.json["language"] == "zh_CN":
|
||||
@@ -170,7 +200,7 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.ui.Protection_switch_Button_4.clicked.connect(self.protect_reg_init)
|
||||
self.ui.Protection_switch_Button_5.clicked.connect(self.protect_net_init)
|
||||
self.ui.high_sensitivity_switch_Button.clicked.connect(self.change_sensitive)
|
||||
self.ui.cloud_services_switch_Button.clicked.connect(self.change_cloud_service)
|
||||
self.ui.cloud_services_switch_Button.clicked.connect(self.cloud_service)
|
||||
self.ui.Add_White_list_Button.clicked.connect(self.add_white_list)
|
||||
self.ui.Language_Traditional_Chinese.clicked.connect(self.init_change_lang)
|
||||
self.ui.Language_Simplified_Chinese.clicked.connect(self.init_change_lang)
|
||||
@@ -292,9 +322,9 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.ui.high_sensitivity_title.setText(self.trans("高靈敏度模式"))
|
||||
self.ui.high_sensitivity_illustrate.setText(self.trans("啟用此選項可以提高引擎的靈敏度"))
|
||||
self.ui.high_sensitivity_switch_Button.setText(self.trans(self.ui.high_sensitivity_switch_Button.text()))
|
||||
self.ui.cloud_services_title.setText(self.trans("雲端掃描服務"))
|
||||
self.ui.cloud_services_illustrate.setText(self.trans("啟用此選項可以連接雲端掃描服務"))
|
||||
self.ui.cloud_services_switch_Button.setText(self.trans(self.ui.cloud_services_switch_Button.text()))
|
||||
self.ui.cloud_services_title.setText(self.trans("上報雲端分析"))
|
||||
self.ui.cloud_services_illustrate.setText(self.trans("此選項可以選擇檔案並上報雲端分析"))
|
||||
self.ui.cloud_services_switch_Button.setText(self.trans("選擇"))
|
||||
self.ui.Add_White_list_title.setText(self.trans("增加到白名單"))
|
||||
self.ui.Add_White_list_illustrate.setText(self.trans("此選項可以選擇檔案並增加到白名單"))
|
||||
self.ui.Add_White_list_Button.setText(self.trans(self.ui.Add_White_list_Button.text()))
|
||||
@@ -564,8 +594,8 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.setWindowOpacity(self.pyas_opacity/100)
|
||||
else:
|
||||
self.timer.stop()
|
||||
self.show()
|
||||
self.pyas_opacity = 0
|
||||
self.show()
|
||||
self.timer = QTimer()
|
||||
self.timer.timeout.connect(update_opacity)
|
||||
self.timer.start(2)
|
||||
@@ -589,6 +619,12 @@ class MainWindow_Controller(QMainWindow):
|
||||
|
||||
def closeEvent(self, event):
|
||||
if self.question_event("您確定要退出 PYAS 和所有防護嗎?"):
|
||||
self.block_window = False
|
||||
self.proc_protect = False
|
||||
self.file_protect = False
|
||||
self.mbr_protect = False
|
||||
self.reg_protect = False
|
||||
self.net_protect = False
|
||||
self.virus_scan_break()
|
||||
event.accept()
|
||||
else:
|
||||
@@ -627,8 +663,10 @@ class MainWindow_Controller(QMainWindow):
|
||||
def show_menu(self):
|
||||
self.WindowMenu = QMenu()
|
||||
Main_Settings = QAction(self.trans("設定"),self)
|
||||
#Main_Update = QAction(self.trans("更新"),self)
|
||||
Main_About = QAction(self.trans("關於"),self)
|
||||
self.WindowMenu.addAction(Main_Settings)
|
||||
#self.WindowMenu.addAction(Main_Update)
|
||||
self.WindowMenu.addAction(Main_About)
|
||||
Qusetion = self.WindowMenu.exec_(self.ui.Menu_Button.mapToGlobal(QPoint(0, 30)))
|
||||
if Qusetion == Main_About and self.ui.About_widget.isHidden():
|
||||
@@ -646,6 +684,15 @@ class MainWindow_Controller(QMainWindow):
|
||||
self.ui.Window_widget.raise_()
|
||||
self.change_animation_3(self.ui.Setting_widget,0.5)
|
||||
self.change_animation_5(self.ui.Setting_widget,10,50,831,481)
|
||||
#if Qusetion == Main_Update:
|
||||
#self.update_database()
|
||||
|
||||
def update_database(self):
|
||||
try:
|
||||
if self.question_event("您確定要更新數據庫嗎?"):
|
||||
pass
|
||||
except Exception as e:
|
||||
self.bug_event(e)
|
||||
|
||||
def change_sensitive(self):
|
||||
sw_state = self.ui.high_sensitivity_switch_Button.text()
|
||||
@@ -663,21 +710,17 @@ class MainWindow_Controller(QMainWindow):
|
||||
QPushButton:hover{background-color:rgb(210,250,210);}""")
|
||||
self.write_config(self.json)
|
||||
|
||||
def change_cloud_service(self):
|
||||
sw_state = self.ui.cloud_services_switch_Button.text()
|
||||
if sw_state == self.trans("已關閉"):
|
||||
self.json["cloud_services"] = 1
|
||||
self.ui.cloud_services_switch_Button.setText(self.trans("已開啟"))
|
||||
self.ui.cloud_services_switch_Button.setStyleSheet("""
|
||||
QPushButton{border:none;background-color:rgb(200,250,200);border-radius: 10px;}
|
||||
QPushButton:hover{background-color:rgb(210,250,210);}""")
|
||||
elif sw_state == self.trans("已開啟"):
|
||||
self.json["cloud_services"] = 0
|
||||
self.ui.cloud_services_switch_Button.setText(self.trans("已關閉"))
|
||||
self.ui.cloud_services_switch_Button.setStyleSheet("""
|
||||
QPushButton{border:none;background-color:rgb(230,230,230);border-radius: 10px;}
|
||||
QPushButton:hover{background-color:rgb(220,220,220);}""")
|
||||
self.write_config(self.json)
|
||||
def cloud_service(self):
|
||||
try:
|
||||
file = str(QFileDialog.getOpenFileName(self,self.trans("上報雲端分析"),"C:/")[0]).replace("\\", "/")
|
||||
if file and self.question_event("您確定要上報雲端分析嗎?"):
|
||||
response = requests.post(self.json["cloud_services"], files={'file': open(file, 'rb')})
|
||||
if response.status_code == 200:
|
||||
self.info_event(f"成功上報雲端分析: "+file)
|
||||
else:
|
||||
self.bug_event(response.status_code)
|
||||
except Exception as e:
|
||||
self.bug_event(e)
|
||||
|
||||
def init_scan(self):
|
||||
try:
|
||||
@@ -791,7 +834,7 @@ class MainWindow_Controller(QMainWindow):
|
||||
def file_scan(self):
|
||||
try:
|
||||
file = str(QFileDialog.getOpenFileName(self,self.trans("病毒掃描"),"C:/")[0])
|
||||
if file and file not in self.whitelist:
|
||||
if file and file not in self.whitelist and file != self.pyas:
|
||||
self.init_scan()
|
||||
self.write_scan(self.start_scan(file),file)
|
||||
self.answer_scan()
|
||||
@@ -829,7 +872,7 @@ class MainWindow_Controller(QMainWindow):
|
||||
break
|
||||
elif os.path.isdir(file):
|
||||
self.traverse_path(file)
|
||||
elif file not in self.whitelist:
|
||||
elif file not in self.whitelist and file != self.pyas:
|
||||
self.ui.Virus_Scan_text.setText(self.trans(f"正在掃描: ")+file)
|
||||
QApplication.processEvents()
|
||||
self.write_scan(self.start_scan(file),file)
|
||||
@@ -839,42 +882,23 @@ class MainWindow_Controller(QMainWindow):
|
||||
|
||||
def start_scan(self, file):
|
||||
try:
|
||||
label, level = self.api_scan(file)
|
||||
if file != self.pyas and level > 50:
|
||||
return f"{label}"#.{level}"
|
||||
elif file != self.pyas and level > 10:
|
||||
label_2, level_2 = self.pe_scan(file)
|
||||
if "White" not in label_2 and "Unknown" not in label_2:
|
||||
return f"{label_2}"#.{int(level_2*100)}"
|
||||
elif "Unknown" in label_2 and self.json["high_sensitive"]:
|
||||
return f"{label_2}"#.{int(level_2*100)}"
|
||||
elif file != self.pyas and not level:
|
||||
label_2, level_2 = self.pe_scan(file)
|
||||
if "White" not in label_2 and "Unknown" not in label_2:
|
||||
return f"{label_2}"#.{int(level_2*100)}"
|
||||
elif "Unknown" in label_2 and self.json["high_sensitive"]:
|
||||
return f"{label_2}"#.{int(level_2*100)}"
|
||||
ftype = str(f".{file.split('.')[-1]}").lower()
|
||||
label, level = self.pe_scan(file)
|
||||
if label and "Unknown" in label:
|
||||
if self.rule_scan(file):
|
||||
return "Rules"
|
||||
elif label and "White" not in label:
|
||||
if self.json["high_sensitive"]:
|
||||
return label
|
||||
elif level and level >= 0.9:
|
||||
return label
|
||||
elif self.json["high_sensitive"]:
|
||||
if self.rule_scan(file):
|
||||
return "Rules"
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
|
||||
def api_scan(self, file):
|
||||
try:
|
||||
if self.json["cloud_services"]:
|
||||
with open(file, "rb") as f:
|
||||
text = str(hashlib.md5(f.read()).hexdigest())
|
||||
QApplication.processEvents()
|
||||
strBody = f'-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="md5s"\r\n\r\n{text}\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="format"\r\n\r\nXML\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="product"\r\n\r\n360zip\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="combo"\r\n\r\n360zip_main\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="v"\r\n\r\n2\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="osver"\r\n\r\n5.1\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="vk"\r\n\r\na03bc211\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="mid"\r\n\r\n8a40d9eff408a78fe9ec10a0e7e60f62\r\n-------------------------------7d83e2d7a141e--'
|
||||
response = requests.post('http://qup.f.360.cn/file_health_info.php', data=strBody, timeout=5)
|
||||
QApplication.processEvents()
|
||||
if response.status_code == 200:
|
||||
label = str(xmlet.fromstring(response.text).find('.//malware').text).split('/')[1].split('.')
|
||||
level = int(float(xmlet.fromstring(response.text).find('.//e_level').text))
|
||||
return f"{label[0]}", level#/{label[1]}"
|
||||
return False, False
|
||||
except:
|
||||
return False, False
|
||||
|
||||
def pe_scan(self, file):
|
||||
try:
|
||||
fn = []
|
||||
@@ -897,11 +921,21 @@ class MainWindow_Controller(QMainWindow):
|
||||
except:
|
||||
return True
|
||||
|
||||
def rule_scan(self, file):
|
||||
try:
|
||||
with open(file, "rb") as f:
|
||||
data = f.read()
|
||||
for name, rules in self.compiled_rules.items():
|
||||
QApplication.processEvents()
|
||||
if rules.match(data=data):
|
||||
return True
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
|
||||
def proc_scan(self, p):
|
||||
try:
|
||||
if isinstance(p, str) and os.path.exists(p):
|
||||
return self.start_scan(file)
|
||||
for entry in psutil.Process(p.pid).memory_maps():
|
||||
for entry in p.memory_maps():
|
||||
file = entry.path.replace("\\", "/")
|
||||
if ":/Windows" not in file and ":/Program" not in file:
|
||||
if self.start_scan(file):
|
||||
@@ -1235,6 +1269,7 @@ class MainWindow_Controller(QMainWindow):
|
||||
Thread(target=self.protect_net_thread, daemon=True).start()
|
||||
|
||||
def protect_proc_thread(self):
|
||||
self.proc = None
|
||||
existing_process = set()
|
||||
for p in psutil.process_iter():
|
||||
existing_process.add(p.pid)
|
||||
@@ -1267,44 +1302,55 @@ class MainWindow_Controller(QMainWindow):
|
||||
elif ":/Windows" not in file and self.sign_scan(file):
|
||||
self.proc = p
|
||||
self.lock_process(p, False)
|
||||
gc.collect()
|
||||
except:
|
||||
self.lock_process(p, False)
|
||||
|
||||
def lock_process(self, p, lock):
|
||||
try:
|
||||
if lock:
|
||||
psutil.Process(p.pid).suspend()
|
||||
p.suspend()
|
||||
else:
|
||||
psutil.Process(p.pid).resume()
|
||||
p.resume()
|
||||
except:
|
||||
pass
|
||||
|
||||
def kill_process(self, parent, info):
|
||||
def kill_process(self, p, info):
|
||||
try:
|
||||
if psutil.pid_exists(parent.pid):
|
||||
file = parent.exe().replace("\\", "/")
|
||||
if p.is_running():
|
||||
file = p.exe().replace("\\", "/")
|
||||
self.send_notify(self.trans(f"{info}: ")+file)
|
||||
for child in parent.children(recursive=True):
|
||||
for child in p.children(recursive=True):
|
||||
child.kill()
|
||||
parent.kill()
|
||||
p.kill()
|
||||
self.proc = None
|
||||
except:
|
||||
pass
|
||||
|
||||
def protect_file_thread(self):
|
||||
hDir = win32file.CreateFile("C:/",win32con.GENERIC_READ,win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE|win32con.FILE_SHARE_DELETE,None,win32con.OPEN_EXISTING,win32con.FILE_FLAG_BACKUP_SEMANTICS,None)
|
||||
self.ransom_counts = 0
|
||||
while self.file_protect:
|
||||
for action, file in win32file.ReadDirectoryChangesW(hDir,10485760,True,win32con.FILE_NOTIFY_CHANGE_FILE_NAME|win32con.FILE_NOTIFY_CHANGE_DIR_NAME|win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES|win32con.FILE_NOTIFY_CHANGE_SIZE|win32con.FILE_NOTIFY_CHANGE_LAST_WRITE|win32con.FILE_NOTIFY_CHANGE_SECURITY,None,None):
|
||||
try:
|
||||
fpath = str(f"C:/{file}").replace("\\", "/")
|
||||
ftype = str(f".{fpath.split('.')[-1]}").lower()
|
||||
if action == 2 and ":/Users" in fpath and "/AppData/" not in fpath:
|
||||
file = self.proc.exe().replace("\\", "/")
|
||||
if ":/Program" not in file and ftype in alist:
|
||||
self.kill_process(self.proc, "勒索行為攔截")
|
||||
elif action == 3 and ":/Users" in fpath and "/AppData/" not in fpath:
|
||||
if os.path.getsize(fpath) <= 52428800 and ftype in slist:
|
||||
if self.start_scan(fpath):
|
||||
if self.ransom_counts >= 3 and self.proc:
|
||||
self.ransom_counts = 0
|
||||
self.kill_process(self.proc, "勒索行為攔截")
|
||||
elif ":/Windows" in fpath and "/Temp/" not in fpath:
|
||||
if action == 2 and ftype in alist:
|
||||
self.ransom_counts += 1
|
||||
elif action == 4 and ftype in alist:
|
||||
self.ransom_counts += 1
|
||||
elif ":/Users" in fpath and "/AppData/" not in fpath:
|
||||
if action == 2 and ftype in alist:
|
||||
self.ransom_counts += 1
|
||||
elif action == 4 and ftype in alist:
|
||||
self.ransom_counts += 1
|
||||
elif action == 3 and ftype in slist and os.path.getsize(fpath) <= 52428800:
|
||||
self.send_notify(self.trans(f"正在掃描: ")+fpath)
|
||||
if self.sign_scan(file) and self.start_scan(fpath):
|
||||
os.remove(fpath)
|
||||
self.send_notify(self.trans("惡意軟體刪除: ")+fpath)
|
||||
except:
|
||||
@@ -1341,7 +1387,7 @@ class MainWindow_Controller(QMainWindow):
|
||||
time.sleep(0.2)
|
||||
local = socket.gethostbyname(socket.gethostname())
|
||||
for conn in self.proc.connections():
|
||||
if "/AppData/" not in file and ":/Program" not in file:
|
||||
if ":/Windows" not in file and ":/Program" not in file:
|
||||
if conn.laddr.ip == local:
|
||||
self.kill_process(self.proc, "網路通訊攔截")
|
||||
except:
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ class ListSimHash:
|
||||
features = dict(Counter(sorted(content)))
|
||||
for f, w in features.items():
|
||||
count += w
|
||||
batch.append(hashlib.md5(json.dumps(f).encode('utf-8')).digest() * w)
|
||||
batch.append(hashlib.sha256(json.dumps(f).encode('utf-8')).digest() * w)
|
||||
if len(batch) >= 10000:
|
||||
sums.append(self.sum_hashes(batch))
|
||||
batch = []
|
||||
@@ -47,7 +47,7 @@ class ListSimHash:
|
||||
|
||||
def sum_hashes(self, digests):
|
||||
bitarray = numpy.unpackbits(numpy.frombuffer(b''.join(digests), dtype='>B'))
|
||||
return numpy.sum(numpy.reshape(bitarray, (-1, 128)), 0)
|
||||
return numpy.sum(numpy.reshape(bitarray, (-1, 256)), 0)
|
||||
|
||||
def progress_bar(self, iteration, total, prefix='', suffix='', length=50, fill='█'):
|
||||
percent = min(100.0, max(0.0, 100 * (iteration / float(total))))
|
||||
@@ -81,4 +81,4 @@ class ListSimHash:
|
||||
|
||||
def similar(self, x, y):
|
||||
hamming_distance = bin(x ^ y).count('1')
|
||||
return 1 - hamming_distance / 128
|
||||
return 1 - hamming_distance / 256
|
||||
+4
-3
@@ -4,7 +4,7 @@ translate_dict = {
|
||||
"軟體":"软件","檔案":"文件","確定":"确认","設定":"设置","關於":"关于",
|
||||
"錯誤":"错误","實時":"实时","發現":"发现","關閉":"关闭","裝置":"设备",
|
||||
"總數":"总数","註冊":"注册","圖標":"图标","路徑":"路径","網路":"网络",
|
||||
"位元":"字节","彈窗":"弹窗","靈敏":"敏感","誤報":"误报","複製":"复制",
|
||||
"位元":"字节","彈窗":"弹窗","靈敏":"敏感","複製":"复制","誤":"误","報":"报",
|
||||
"訊":"讯","項":"项","掃":"扫","試":"试","黃":"黄","嗎":"吗","防":"保",
|
||||
"鑰":"钥","當":"当","後":"后","護":"护","導":"导","區":"区","復":"复",
|
||||
"攔":"拦","請":"请","統":"统","刪":"删","進":"进","個":"个","選":"选",
|
||||
@@ -47,8 +47,9 @@ translate_dict = {
|
||||
"增加到":"Add File To ","白名單":"White List ","軟體":"Software ",
|
||||
"增加":"Add","移除":"Delete","項目":"Items ","生成":"Create ","稱":"",
|
||||
"複製":"Copy ","開啟":"Open ","此":"This ","並":"And ","全盤":"Full ",
|
||||
"已經是":"Already ","數據庫":"Database ","誤報":"False Positive ",
|
||||
"已經在":"Already ","數據庫":"Database ","誤報":"False Positive ",
|
||||
"高":"High ","新":"New ","和":"And ","可能會":"Possible ","會":"Can ",
|
||||
"日誌":"Log","已":"Has ","彈窗":"Window ","要":"To ","驅動":"Drive ",
|
||||
"的":"","顯示":"","個":"","嗎":"","中":"","了":"","行":"","立即":"",
|
||||
"密鑰":"Key ","檢測":"Detect ","製作":"Make"," ":" "}}
|
||||
"密鑰":"Key ","檢測":"Detect ","製作":"Make","運行":"Running",
|
||||
"自動":"Auto ","上報":"Report ","分析":"Analysis "," ":" "}}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"Unknown": [10199010580531108378153827424457992432, 20965212707052912989658218281213053170, 20963924773736013955013492889397430514, 20965222847950647661922877313293420786, 20963924773736089512877253988092938483, 10533913729454048551192748670221101302, 10497567570978277785165438149536581872, 230418814927598623996991522865620895293], "White": [126672244860282820431531292152154892541, 126555244512863767515621062938772454385, 78206639303253050193082960917406129821, 180439547362931620767428561827016696106, 96103515196312870469979178835907426963, 106202738889863580199047548478556282224, 260681472954591486442301293972682570259, 334352372173892944739362819086050576826, 270698534086324527574602815275595168743, 52278935817957542072232518657580445973, 99964490807793194121661552779445205157, 114471449979609419026325537602253303510, 170288120086869810213050150585452458992, 20129952829430162432875533418501193427, 266141180604311766657329911262256522695, 194231769680954789184967343915738715269, 137555894938392968938334822886799145665, 32033385634193095265531812355001705364, 110412723075988544148987035520371252041, 95564371670156926573557604030875376880, 95235309747885939408380636606625811569, 272762168699147334321583996672002378255, 95234011064914281942190040816173653105, 94471327154819245031506476509638106704, 95313696146069105288568328992515893493, 93984468150284189415663958982282127605, 191147052097100843670989027331488156725, 103210672664238242772979731817227685237, 56724333007221946388761990730009660128, 101562244577076015330628724737265682909, 97287175069805646577858533189449166301, 137063300177336245346774014048969161649, 316391968656924997605188916362257077459, 264287352948858755174876745019957203391, 127136776672701393662717729226704358773, 9912885994425979960261799249926495473, 214498205255495472884061693173662060219, 105039659248652423950583866198328679776, 106486519388821918892958052791862913681, 81533898116464931264738244322343722087, 127128973031678141900306064284785253496, 257976287344519798598519417614968543943, 95234579695571071996043856278635879538, 307531936139217865648235621101964847809, 205524205305644077365818951604097443015, 10082933643349790779259596715866791152, 105863211359421133420308580490619723120, 105536091507504387016141979202387910000, 115256152418524974755063297364983094641, 258226055192645594643924661804242821079, 184879672381654838626194080314169453584, 105909917863928976433791749005432917096, 34668429459089199253155684394504639701, 9333342038490638804353570140444499409, 49992947087053905927423189110869930637, 114390951894751980367497997972138956045, 40525380716593540848111929430426386129, 92531564279929657078344831661770634033, 137845158706024438551516917025209916775, 82711778578996712205456007623860083392, 142895363148849470268902285117702200512, 176210598858636561054489191954962668740, 133988075388031745460051108783604183680, 127463789261350104996635356465169505635, 98401956749501984262112138828559240544, 105619903475864025251671385889627380849, 194216192765620392180514937530431948487, 178730848644410936934440792379530771324, 258767967557372966404648755263173813716, 95568909833307793735851930883495894385, 105203216600314032187918420804040465776, 10160172324731669179270431009861737585, 95562338257159239457022778648277753201, 125705675445940363792857463789011840389, 105782103246308081595321955114562886777, 34490061240648476397849656073168201108, 337793686977585440073129666111702532467, 278253338747731733314329375842609871921, 204788843742030229839080201679229506773, 106117654063199359331238217293466812006, 123266687541636144245366511635599982231, 113845713591553304589832425329269218672, 102400300404095555238772811174816483363, 115752031916027952368786798048662461543, 205193551069866139019248248605938239445, 101437234347196055762008445071888009636, 148030553843923537774182040572301348817, 95562399131158503793285318098946563443, 144743835053038288880188325484490464627, 329456512868359962875761871381429648792, 214132526311861388081693372283346711315, 212807863125887894065170197859985748755, 90639505994802779364701320439314232445, 109312881611100283088661575235655027037, 268695571549372555579983860480753996530, 276556254823007156956265006607247855228, 158532724662396204460585683955318721251, 190236918274156159301867868769173894064, 115505281197039501762156314342977388146, 181151739907962908273686170106830254275, 103040304820632656358846714092274654455, 283839353929015376840553872262568182165, 126305356110326106528653817459839286387, 232772214119775911616044955505922667440, 267224571901232164108563912343781345315, 248870611769713486967773923305072182805, 94401261442397178213607895041941511616, 126697942675733486251713755064939650169, 52680527483000227468312744969526057584, 100468409853345213529992161170862574067, 195546595259106600444307572967932415185, 121396668310321681197001161772784753777, 102772203717048361679815565428970429489, 118636962645139146202043096156604144755, 130735009156835Line truncated
|
||||
{"Unknown": [38413146381396798812836662586219087594480760119241756145287379993031670453973, 96759775057307603829199050115151442660431386536877578909394799687553144825391], "White": [92860071170291586757870565976957954052649178883790647665503983139114277816413, 50625869624179221836524636484722091669820057030729734765256925026245308185143, 79303266820014134748061006437377483029320717142203104125806969476209010566146, 50391760446499089493384482654016917630509060287507523223191455177998253781572, 34733894651460458125941968926483828168477919119649839915356573816494375383659, 16447578251589668808184123721615810667991570306415913809506896532563163557975, 18668853151306203943053249777678854424409647574074706653144503993068509738028, 16447129799599854768187525514242197965987640167415805965954293039200573272151, 42965648781535883376480003940402366467478625051031283341289116138472520399484, 45637511530246203537935382208327538642024163565740899790237852717178844340385, 100662025713257198141308144602569453810226448934776598411982222249289646045820, 2813878798545665948450767843887867208740292941021073849284371582085785669685, 54695748401254225125045716155327877471149349614359435230254611073117412307518, 27428665293760567560050957450577436769403462770366418052177943137905489504373, 32018095881556959863902669246154132691484124511748151111295836576906027842532, 82735669648112373508385530969898006750362429118827185652448450648454052106395, 27853809242729492000984914092533936796891917926358854729439436487683423285261, 20030429995379197455160031864140436552884002299333955332088108013764717533796, 82338140557728967648601024370995428985866052631101882076231147335348455671038, 71339449324799277130427957011381342555145697382104653874846579353871764366968, 2432232479351500614611699169184443988440809841079862157291791071419485606436, 9463527399566410848087352636323112952591923803840644609432039785310381355253, 17287926889345790925003722717807755244540044472850272987265624141065166747251, 31507509644511868166890345905396462199402122513677304280568315890707028374136, 92802443753971611323223428952970105040389824130209263287070763891097867755624, 45133408084728538869955951560598604064861024543940290379768365214821771604584, 43161770374046173333870752071317153674965637163816017117315179871715332666383, 55200886519442939000007636174371797768786544863806926514781108850256791225983, 102124766481586899841647737641698083212305154684644839980199278690335383712492, 52992286898317605666180786036367620316269750824654214415314225077986227890804, 96307454545313440124283308270263825589093792315386382296096934270155352236733, 36073459579994433898643313577597321150634749356791285363958792075031385371364, 2671602537216404752611755689384448521170725107261295121211275163689399347529, 31174448189678483951801405655647041557287598300853213718404097030076935043252, 6997953573828232905847825866256444005094471443450029313008738013465446666864, 41288968033780608769032189481784193916730262129846893330891418484950645535282, 56724589038911745751056508177185337741291265472470897077742981563488398484126, 3353938097938067320481103667469354721822387389147415219233498938990215839034, 21195721951654457114265478558602466514207347021822959737607658828495062116920, 2916561284514958799877078174216081002558870786437593202464334407456915288119, 93137488384582768487662730765406914258099784103320160609442537879778117334700, 21195721951654457114265478558602377311225888285332501136798116331518898022972, 85036278951571446667616241901438186945472743486751871120301019617002115253240, 14623491695050192413097067629676318500123044497134202517578785087180871258165, 2022308710750553104057453378681448926020203033444470910346149752954363011822, 16435447118324352510213480738895714506136417806014749563314727656196027207884, 20110908101408861236178371339075650317185505287106087252378028881915405550816, 97262306467112548995108413358594977802790545321935863056096364390382492643957, 96614497885586867524036482497010189662872359368622249290846422070379022959337, 1895288773648887609359329471072769468085207279473521707976899919066265183340, 2651591106060448314208209841614702280337184080195391257416359882876000875095, 114619913163036058498985801603082782363327281628924544162718017899237779173997, 2481883953883130814217575190747389944608730963897863224598923997640828351014, 45000300637061336566799421885334051647634671537987073940268834014403441552901, 79047998258892679051555952202178856054614923426747250310189496005785954516966, 92887093185298651693450115442544102614083847612212241647641096093293220418098, 7140769773119319253009453104401896171570019200295580355390762162793695491644, 17012496707164921800767104952565848716212381967476981614870260538046339441223, 55577404054451500506896476492698809966352434385747804245366700591039970820656, 42705951800174486650758821275676750976088492908259259071295096144374682903086, 49945662818205539045803005800855628211260206264132745568273429553565001939621, 1971375Line truncated
|
||||
+1
-1
@@ -2,7 +2,7 @@ import pyinstaller_versionfile
|
||||
|
||||
pyinstaller_versionfile.create_versionfile(
|
||||
output_file="versionfile.txt",
|
||||
version='3.0.8',
|
||||
version='3.0.9',
|
||||
company_name="PYAS Security",
|
||||
file_description="Python Antivirus Software",
|
||||
internal_name="PYAS",
|
||||
|
||||
@@ -37,35 +37,6 @@ pywin32==306
|
||||
PyQt5==5.15.9
|
||||
```
|
||||
|
||||
## Hash Scanning
|
||||
|
||||
Use Qihoo 360 cloud service to scan known malicious files
|
||||
|
||||
```
|
||||
import hashlib, requests
|
||||
import xml.etree.ElementTree as xmlet
|
||||
|
||||
def hash_scan(file):
|
||||
try:
|
||||
with open(file, "rb") as f:
|
||||
text = str(hashlib.md5(f.read()).hexdigest())
|
||||
strBody = f'-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="md5s"\r\n\r\n{text}\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="format"\r\n\r\nXML\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="product"\r\n\r\n360zip\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="combo"\r\n\r\n360zip_main\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="v"\r\n\r\n2\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="osver"\r\n\r\n5.1\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="vk"\r\n\r\na03bc211\r\n-------------------------------7d83e2d7a141e\r\nContent-Disposition: form-data; name="mid"\r\n\r\n8a40d9eff408a78fe9ec10a0e7e60f62\r\n-------------------------------7d83e2d7a141e--'
|
||||
response = requests.post('http://qup.f.360.cn/file_health_info.php', data=strBody, timeout=3)
|
||||
if response.status_code == 200:
|
||||
level = float(xmlet.fromstring(response.text).find('.//e_level').text)
|
||||
if level > 50:
|
||||
return "Virus"
|
||||
elif level <= 10:
|
||||
return "Safe"
|
||||
return "Unknown"
|
||||
return f"Error: {response.status_code}"
|
||||
except Exception as e:
|
||||
return f"Error: {e}"
|
||||
|
||||
info = hash_scan("path to file")
|
||||
print(info)
|
||||
```
|
||||
|
||||
## Pefile Scanning
|
||||
|
||||
Get the pefile file function import table for scanning
|
||||
|
||||
Reference in new issue
Block a user