Compare commits

...
64 Commits
Author SHA1 Message Date
PYDT 6f93f6ab06 Add files via upload 2024-03-14 08:49:33 +08:00
PYDT 9de1f44288 Add files via upload 2024-03-13 22:04:03 +08:00
PYDT 3d360b0881 Add files via upload 2024-03-12 21:23:09 +08:00
PYDT cf1c415846 Add files via upload 2024-03-12 14:52:45 +08:00
PYDT 90133e2444 Add files via upload 2024-03-11 11:15:55 +08:00
PYDT 81246046b8 Add files via upload 2024-03-10 13:05:03 +08:00
PYDT 20e037ab9e Add files via upload 2024-03-09 03:24:41 +08:00
PYDT bc27036ba7 Add files via upload 2024-03-07 16:35:31 +08:00
PYDT 1cd470b90b Add files via upload 2024-03-07 16:03:41 +08:00
PYDT 64471e34bc Add files via upload 2024-03-07 14:09:51 +08:00
PYDT f4c5d3de09 Add files via upload 2024-03-07 13:40:44 +08:00
PYDT 0dc59405e3 Update README.md 2024-03-06 15:34:29 +08:00
PYDT 7c775bdc9b Add files via upload 2024-03-06 15:19:10 +08:00
PYDT 61400ff4d4 Add files via upload 2024-03-02 17:33:31 +08:00
PYDT e119e34ebe Add files via upload 2024-03-01 15:48:26 +08:00
PYDT 6f059747bf Add files via upload 2024-03-01 09:32:59 +08:00
PYDT 24d72641fa Update README.md 2024-02-29 08:08:03 +08:00
PYDT b91fca3aa6 Update README.md 2024-02-29 08:06:59 +08:00
mtkiao a6f1947837 Merge pull request #18 from zackzheng1121/main
增加中文
2024-02-28 21:01:35 +08:00
zackzheng1121 6919131cef Update README_zh.md 2024-02-28 21:00:31 +08:00
PYDT 9186d801fc Add files via upload 2024-02-27 07:35:29 +08:00
PYDT 76e2f200bd Add files via upload 2024-02-26 23:21:40 +08:00
PYDT 1400bbd9ce Add files via upload 2024-02-26 15:02:04 +08:00
PYDT fd37628ac2 Add files via upload 2024-02-25 23:12:15 +08:00
PYDT 4396d5afc4 Add files via upload 2024-02-25 16:16:02 +08:00
PYDT f5faf80883 Add files via upload 2024-02-25 15:58:53 +08:00
PYDT ba32da97c8 Add files via upload 2024-02-25 10:42:07 +08:00
PYDT ec2de73d3a Update README.md 2024-02-25 02:34:20 +08:00
PYDT f4d032e5c7 Add files via upload 2024-02-25 02:17:22 +08:00
PYDT 4114aac6c3 Add files via upload 2024-02-25 01:45:23 +08:00
PYDT 0c43c6bb5f Add files via upload 2024-02-24 23:43:10 +08:00
PYDT 7b3c965b88 Add files via upload 2024-02-24 21:55:53 +08:00
zackzheng1121 d1035268f6 Update README_zh.md 2024-02-24 19:44:58 +08:00
zackzheng1121 8968f30bf9 Update README_zh.md 2024-02-24 19:43:45 +08:00
zackzheng1121 84c2c29600 Update README.md 2024-02-24 19:43:23 +08:00
zackzheng1121 b2a59f261c Update README.md 2024-02-24 19:40:42 +08:00
zackzheng1121 363a330f8e Create README.md 2024-02-24 19:39:20 +08:00
zackzheng1121 1d2aa059ee Update and rename README.md to README_zh.md 2024-02-24 19:38:16 +08:00
zackzheng1121 f2bfa908a1 add readme_zh 2024-02-24 19:32:40 +08:00
PYDT 02a8de4696 Add files via upload 2024-02-23 08:38:55 +08:00
PYDT 22fa3eff71 Add files via upload 2024-02-22 14:32:17 +08:00
PYDT 69361209c3 Add files via upload 2024-02-22 01:08:15 +08:00
PYDT ff0aeaa4ef Add files via upload 2024-02-21 10:21:38 +08:00
PYDT 3c461dfd4b Add files via upload 2024-02-21 10:13:11 +08:00
PYDT c6beda383e Add files via upload 2024-02-21 07:10:15 +08:00
PYDT 3d59f3befd Add files via upload 2024-02-21 00:42:59 +08:00
PYDT e54f0db239 Update README.md 2024-02-20 14:41:04 +08:00
PYDT 0f877f2749 Delete PYAS_Function.vdb 2024-02-20 14:02:47 +08:00
PYDT b69ba165d9 Add files via upload 2024-02-20 14:02:37 +08:00
PYDT 965076fe52 Delete PYAS_Compress.py 2024-02-20 13:43:32 +08:00
PYDT f4d6cb0430 Add files via upload 2024-02-19 10:39:21 +08:00
PYDT 19d412188c Add files via upload 2024-02-19 10:38:19 +08:00
PYDT 798d85978a Add files via upload 2024-02-11 19:53:57 +08:00
PYDT 819742d753 Add files via upload 2024-02-11 16:12:59 +08:00
PYDT 9b32fa6219 Add files via upload 2024-02-11 10:56:55 +08:00
PYDT 2c93661726 Add files via upload 2024-02-10 23:02:45 +08:00
PYDT bddaca2a1e Add files via upload 2024-02-10 22:08:39 +08:00
PYDT 2f06f2e051 Add files via upload 2024-02-10 20:52:38 +08:00
PYDT 1d26e46bd9 Add files via upload 2024-02-10 20:01:52 +08:00
PYDT fa0ff826a3 Add files via upload 2024-02-10 19:50:01 +08:00
PYDT e1b3114c83 Add files via upload 2024-02-10 19:41:34 +08:00
PYDT a655f075db Add files via upload 2024-02-10 19:40:54 +08:00
PYDT 13d4ebbf6b Add files via upload 2024-02-09 14:24:52 +08:00
PYDT 913d10b1ee Add files via upload 2024-02-09 14:18:30 +08:00
10 changed files with 410 additions and 173 deletions

No files matched your search

+145 -134
View File
@@ -3,8 +3,8 @@ import hashlib, pefile, socket, msvcrt
import xml.etree.ElementTree as xmlet
import requests, pyperclip, win32file
import win32gui, win32api, win32con
from PYAS_Engine import ListSimHash
from PYAS_Extension import slist, alist
from PYAS_Compress import ListCompressor
from PYAS_Language import translate_dict
from PYAS_Interface import Ui_MainWindow
from threading import Thread
@@ -19,8 +19,8 @@ class MainWindow_Controller(QMainWindow):
self.setWindowFlags(Qt.FramelessWindowHint)
self.pyas = sys.argv[0].replace("\\", "/")
self.dir = os.path.dirname(self.pyas)
self.pyae_version = "0000-00-00"
self.pyas_version = "3.0.2"
self.pyae_version = "SimHash Engine"
self.pyas_version = "3.0.7"
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.init_show_pyas()
@@ -52,11 +52,10 @@ class MainWindow_Controller(QMainWindow):
def init_data_base(self):
try:
file_path = os.path.join(self.dir, "PYAS_Function.vdb")
file_path = os.path.join(self.dir, "PYAS_Model.json")
if os.path.exists(file_path):
self.pe = ListCompressor()
self.pe = ListSimHash()
self.pe.load_model(file_path)
self.pyae_version = self.pe.get_label()
except Exception as e:
self.bug_event(e)
@@ -625,29 +624,11 @@ class MainWindow_Controller(QMainWindow):
except:
pass
def update_database(self):
try:
if self.question_event("您確定要更新數據庫嗎?"):
file_path = os.path.join(self.dir, "PYAS_Function.vdb")
response = requests.get('http://27.147.30.238:5001/database', params={"version": self.pyae_version}, timeout=5)
if response.status_code == 200:
with open(file_path, 'wb') as f:
f.write(response.content)
self.init_data_base()
self.init_lang_text()
self.info_event(f"數據庫更新成功: {self.pyae_version}")
elif response.status_code == 204:
self.info_event(f"數據庫已經是最新: {self.pyae_version}")
except Exception as e:
self.bug_event(e)
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():
@@ -665,8 +646,6 @@ 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 change_sensitive(self):
sw_state = self.ui.high_sensitivity_switch_Button.text()
@@ -706,7 +685,7 @@ class MainWindow_Controller(QMainWindow):
QApplication.processEvents()
try:
for file in self.virus_list:
self.unlock_file(file)
self.lock_file(file, False)
except:
pass
self.scan_file = True
@@ -733,17 +712,14 @@ class MainWindow_Controller(QMainWindow):
copyPath.triggered.connect(lambda: copyPathFunc())
menu.exec_(self.ui.Virus_Scan_output.mapToGlobal(point))
def lock_file(self, file):
def lock_file(self, file, lock):
try:
self.virus_lock[file] = os.open(file, os.O_RDWR)
msvcrt.locking(self.virus_lock[file], msvcrt.LK_NBLCK, 0)
except:
pass
def unlock_file(self, file):
try:
msvcrt.locking(self.virus_lock[file], msvcrt.LK_UNLCK, 0)
os.close(self.virus_lock[file])
if lock:
self.virus_lock[file] = os.open(file, os.O_RDWR)
msvcrt.locking(self.virus_lock[file], msvcrt.LK_NBLCK, 0)
else:
msvcrt.locking(self.virus_lock[file], msvcrt.LK_UNLCK, 0)
os.close(self.virus_lock[file])
except:
pass
@@ -755,10 +731,10 @@ class MainWindow_Controller(QMainWindow):
if self.ui.Virus_Scan_output.findItems(file, Qt.MatchContains)[0].checkState() == Qt.Checked:
self.ui.Virus_Scan_text.setText(self.trans("正在刪除: ")+file)
QApplication.processEvents()
self.unlock_file(file)
self.lock_file(file, False)
os.remove(file)
else:
self.unlock_file(file)
self.lock_file(file, False)
except:
continue
self.virus_lock = {}
@@ -771,14 +747,15 @@ class MainWindow_Controller(QMainWindow):
def write_scan(self, state, file):
try:
self.lock_file(file)
self.virus_list.append(file)
self.virus_list_ui.append(f"[{state}] {file}")
item = QListWidgetItem()
item.setText(f"[{state}] {file}")
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked)
self.ui.Virus_Scan_output.addItem(item)
if state and file:
self.lock_file(file, True)
self.virus_list.append(file)
self.virus_list_ui.append(f"[{state}] {file}")
item = QListWidgetItem()
item.setText(f"[{state}] {file}")
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked)
self.ui.Virus_Scan_output.addItem(item)
except:
pass
@@ -816,7 +793,7 @@ class MainWindow_Controller(QMainWindow):
file = str(QFileDialog.getOpenFileName(self,self.trans("病毒掃描"),"C:/")[0])
if file and file not in self.whitelist:
self.init_scan()
self.start_scan(file)
self.write_scan(self.start_scan(file),file)
self.answer_scan()
except Exception as e:
self.bug_event(e)
@@ -844,58 +821,57 @@ class MainWindow_Controller(QMainWindow):
self.bug_event(e)
self.virus_scan_break()
def start_scan(self, file):
try:
file_type = str(f".{file.split('.')[-1]}").lower()
if self.json["high_sensitive"] and file != self.pyas:
if self.api_scan(file):
self.write_scan(self.trans("惡意"),file)
elif self.pe_scan(file):
self.write_scan(self.trans("可疑"),file)
elif file_type in slist and file != self.pyas:
if self.api_scan(file):
self.write_scan(self.trans("惡意"),file)
elif self.pe_scan(file):
self.write_scan(self.trans("可疑"),file)
except:
pass
def traverse_path(self,path):
for fd in os.listdir(path):
try:
file = str(os.path.join(path,fd)).replace("\\", "/")
if self.scan_file == False:
break
elif ":/Windows" in file:
continue
elif os.path.isdir(file):
self.traverse_path(file)
elif file not in self.whitelist:
self.ui.Virus_Scan_text.setText(self.trans(f"正在掃描: ")+file)
QApplication.processEvents()
self.start_scan(file)
self.write_scan(self.start_scan(file),file)
gc.collect()
except:
pass
def api_scan(self, file):
def start_scan(self, file):
try:
if self.json["cloud_services"] == 1:
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=5)
return response.status_code == 200 and float(xmlet.fromstring(response.text).find('.//e_level').text) > 50
level = self.api_scan(file)
if file != self.pyas and level > 50:
return f"Cloud/Blacklist.{level}"
elif file != self.pyas and level > 10:
vl, wl = self.pe_scan(file)
if vl > wl and vl == 100:
return f"Pefile/Blacklist.{vl}"
elif vl >= wl and self.json["high_sensitive"]:
return f"Fusion/Predict.{vl}"
elif file != self.pyas and not level:
vl, wl = self.pe_scan(file)
if vl > wl and vl == 100:
return f"Pefile/Blacklist.{vl}"
elif vl >= wl and self.json["high_sensitive"]:
return f"Pefile/Predict.{vl}"
return False
except:
return False
def sign_scan(self, file):
def api_scan(self, file):
try:
with pefile.PE(file, fast_load=True) as pe:
return pe.OPTIONAL_HEADER.DATA_DIRECTORY[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_SECURITY"]].VirtualAddress == 0
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:
return int(float(xmlet.fromstring(response.text).find('.//e_level').text))
return False
except:
return True
return False
def pe_scan(self, file):
try:
@@ -907,20 +883,29 @@ class MainWindow_Controller(QMainWindow):
fn.append(str(func.name, "utf-8"))
except:
pass
if self.json["high_sensitive"]:
return self.pe.predict(fn)
elif "_CorExeMain" not in fn:
return self.pe.predict(fn)
return False
QApplication.processEvents()
out = self.pe.predict_all(fn)
virus = int(out["Virus"]*100)
white = int(out["White"]*100)
return virus, white
except:
return False
def proc_scan(self, pid):
def sign_scan(self, file):
try:
for entry in psutil.Process(pid).memory_maps():
with pefile.PE(file, fast_load=True) as pe:
return pe.OPTIONAL_HEADER.DATA_DIRECTORY[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_SECURITY"]].VirtualAddress == 0
except:
return True
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():
file = entry.path.replace("\\", "/")
if ":/Windows" not in file and ":/Program" not in file:
if self.api_scan(file) or self.pe_scan(file):
if self.start_scan(file):
return True
return False
except:
@@ -1027,9 +1012,8 @@ class MainWindow_Controller(QMainWindow):
for i in Permission:
try:
win32api.RegDeleteValue(key,i)
self.proc.kill()
file = self.proc.exe().replace("\\", "/")
self.send_notify(self.trans("惡意行為攔截: ")+file)
self.kill_process(self.proc, "惡意行為攔截", file)
except:
pass
win32api.RegCloseKey(key)
@@ -1111,7 +1095,7 @@ class MainWindow_Controller(QMainWindow):
self.block_window = True
self.block_window_init()
except Exception as e:
self.bug_event(e)
self.bug_event(e)
def block_window_init(self):
self.block_window = True
@@ -1120,7 +1104,7 @@ class MainWindow_Controller(QMainWindow):
def block_software_window(self):
while self.block_window:
try:
time.sleep(0.5)
time.sleep(0.2)
for window_name in self.blocklist:
win32gui.PostMessage(win32gui.FindWindow(None, window_name), 274, 61536, 0)
except:
@@ -1169,7 +1153,11 @@ class MainWindow_Controller(QMainWindow):
if self.Process_popMenu.exec_(self.ui.Process_list.mapToGlobal(pos)) == self.kill_Process:
for p in psutil.process_iter():
if p.pid == self.pid:
p.kill()
file = p.exe().replace("\\", "/")
if file == self.pyas:
self.close()
else:
p.kill()
except:
pass
@@ -1249,77 +1237,101 @@ class MainWindow_Controller(QMainWindow):
Thread(target=self.protect_net_thread, daemon=True).start()
def protect_proc_thread(self):
existing_processes = set()
existing_process = set()
for p in psutil.process_iter():
if p.pid not in existing_processes:
existing_processes.add(p.pid)
existing_process.add(p.pid)
while self.proc_protect:
time.sleep(0.01)
new_process = set()
for p in psutil.process_iter():
new_process.add(p.pid)
for pid in new_process - existing_process:
try:
if p.pid not in existing_processes:
existing_processes.add(p.pid)
name, file, cmd = p.name(), p.exe().replace("\\", "/"), p.cmdline()
if file != self.pyas and file not in self.whitelist:
psutil.Process(p.pid).suspend()
if "powershell" in name and self.api_scan(cmd[-1].split("'")[-2]):
p.kill()
file = cmd[-1].split("'")[-2].replace("\\", "/")
self.send_notify(self.trans("惡意腳本攔截: ")+file)
elif "cmd.exe" in name and self.api_scan(" ".join(cmd[2:])):
p.kill()
file = " ".join(cmd[2:]).replace("\\", "/")
self.send_notify(self.trans("惡意腳本攔截: ")+file)
elif ":/Windows" in file and self.api_scan(cmd[-1]):
p.kill()
file = cmd[-1].replace("\\", "/")
self.send_notify(self.trans("惡意軟體攔截: ")+file)
elif ":/Windows" not in file and self.proc_scan(p.pid):
p.kill()
self.send_notify(self.trans("惡意軟體攔截: ")+file)
elif ":/Windows" not in file and self.sign_scan(file):
self.proc = p
psutil.Process(p.pid).resume()
gc.collect()
p = psutil.Process(pid)
self.handle_new_process(p)
except:
pass
existing_process = new_process
def handle_new_process(self, p):
try:
name, file, cmd = p.name(), p.exe().replace("\\", "/"), p.cmdline()
if file != self.pyas and file not in self.whitelist:
self.lock_process(p, True)
if "powershell" in name and self.start_scan(cmd[-1].split("'")[-2]):
file = cmd[-1].split("'")[-2].replace("\\", "/")
self.kill_process(p, "惡意腳本攔截", file)
elif "cmd.exe" in name and self.start_scan(" ".join(cmd[2:])):
file = " ".join(cmd[2:]).replace("\\", "/")
self.kill_process(p, "惡意腳本攔截", file)
elif ":/Windows" in file and self.start_scan(cmd[-1]):
file = cmd[-1].replace("\\", "/")
self.kill_process(p, "惡意軟體攔截", file)
elif ":/Windows" not in file and self.proc_scan(p):
self.kill_process(p, "惡意軟體攔截", file)
elif ":/Windows" not in file and self.sign_scan(file):
self.proc = p
self.lock_process(p, False)
except:
self.lock_process(p, False)
def lock_process(self, p, lock):
try:
if lock:
psutil.Process(p.pid).suspend()
else:
psutil.Process(p.pid).resume()
except:
pass
def kill_process(self, parent, info, file):
try:
parent.kill()
self.send_notify(self.trans(f"{info}: ")+file)
for child in parent.children(recursive=True):
child.kill()
except:
pass
def protect_file_thread(self):
hDir = win32file.CreateFile("C:/Users/",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)
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)
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:/Users/{file}").replace("\\", "/")
fpath = str(f"C:/{file}").replace("\\", "/")
ftype = str(f".{fpath.split('.')[-1]}").lower()
if action == 3 and ftype in slist and os.path.getsize(fpath) <= 20971520:
if self.api_scan(fpath) or self.pe_scan(fpath):
os.remove(fpath)
self.send_notify(self.trans("惡意軟體刪除: ")+fpath)
if action == 2 and ":/Users" in fpath and ftype in alist:
file = self.proc.exe().replace("\\", "/")
if "/AppData/" not in file and ":/Program" not in file:
self.kill_process(self.proc, "勒索行為攔截", file)
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):
os.remove(fpath)
self.send_notify(self.trans("惡意軟體刪除: ")+fpath)
except:
pass
def protect_boot_thread(self):
while self.mbr_protect and self.mbr_value:
try:
time.sleep(0.5)
time.sleep(0.2)
with open(r"\\.\PhysicalDrive0", "r+b") as f:
if self.mbr_value[510:512] != b'\x55\xAA':
self.proc.kill()
file = self.proc.exe().replace("\\", "/")
self.send_notify(self.trans("惡意行為攔截: ")+file)
self.kill_process(self.proc, "惡意行為攔截", file)
elif f.read(512) != self.mbr_value:
f.seek(0)
f.write(self.mbr_value)
self.proc.kill()
file = self.proc.exe().replace("\\", "/")
self.send_notify(self.trans("惡意行為攔截: ")+file)
self.kill_process(self.proc, "惡意行為攔截", file)
except:
pass
def protect_reg_thread(self):
while self.reg_protect:
try:
time.sleep(0.5)
time.sleep(0.2)
self.repair_system_image()
self.repair_system_restrict()
self.repair_system_file_type()
@@ -1330,14 +1342,13 @@ class MainWindow_Controller(QMainWindow):
def protect_net_thread(self):
while self.net_protect:
try:
time.sleep(0.5)
time.sleep(0.2)
local = socket.gethostbyname(socket.gethostname())
for conn in self.proc.connections():
file = self.proc.exe().replace("\\", "/")
if ":/Windows" not in file and ":/Program" not in file:
if "/AppData/" not in file and ":/Program" not in file:
if conn.laddr.ip == local:
self.proc.kill()
self.send_notify(self.trans("網路通訊攔截: ")+file)
self.kill_process(self.proc, "網路通訊攔截", file)
except:
pass
-31
View File
@@ -1,31 +0,0 @@
import json, hashlib
class ListCompressor:
def __init__(self):
self.model = {}
def save_model(self, file_name):
with open(file_name, 'w') as f:
json.dump(self.model, f)
print(f"\nModel Is Saved In {file_name}")
def load_model(self, model_data):
if isinstance(model_data, str):
with open(model_data, 'r') as f:
model_data = json.load(f)
self.model = model_data
def train_model(self, label, data):
if label not in self.model:
self.model[label] = []
for lst in data:
self.model[label].append(hashlib.md5(''.join(map(str, lst)).encode()).hexdigest()[:8])
def predict(self, new_list):
for label, items in self.model.items():
if label != 'word' and hashlib.md5(''.join(map(str, new_list)).encode()).hexdigest()[:8] in items:
return True
return False
def get_label(self):
return list(self.model.keys())[0]
+84
View File
@@ -0,0 +1,84 @@
import time, json, hashlib, numpy
from collections import Counter
class ListSimHash:
def __init__(self):
self.model = {}
def save_model(self, file_name):
with open(file_name, 'w') as f:
json.dump(self.model, f)
print(f"\nModel Is Saved In {file_name}")
def load_model(self, model_data):
if isinstance(model_data, str):
with open(model_data, 'r') as f:
model_data = json.load(f)
self.model = model_data
def get_model(self, label):
return self.model[label]
def train_model(self, label, data):
start = time.time()
print(f"Convert {label}")
if label not in self.model:
self.model[label] = []
for i, x in enumerate(data, 1):
self.model[label].append(self.build_text(x))
used = "{0:.2f}".format(time.time()-start)
prefix, suffix = f'{i}/{len(data)}:', f'{used}s'
self.progress_bar(i, len(data), prefix, suffix)
def build_text(self, content):
sums, batch, count = [], [], 0
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)
if len(batch) >= 10000:
sums.append(self.sum_hashes(batch))
batch = []
if batch:
sums.append(self.sum_hashes(batch))
combined_sums = numpy.sum(sums, 0)
v = numpy.packbits(combined_sums > count / 2).tobytes()
return int.from_bytes(v, 'big')
def sum_hashes(self, digests):
bitarray = numpy.unpackbits(numpy.frombuffer(b''.join(digests), dtype='>B'))
return numpy.sum(numpy.reshape(bitarray, (-1, 128)), 0)
def progress_bar(self, iteration, total, prefix='', suffix='', length=50, fill='█'):
percent = min(100.0, max(0.0, 100 * (iteration / float(total))))
end_char = '\n' if percent >= 100 else '\r'
percent_string = "{0:.2f}".format(percent)
filled_length = int(length * iteration // total)
bar = fill * filled_length + ' ' * (length - filled_length)
print(f'\r {prefix: <10} |{bar}| {percent_string}% {suffix}', end=end_char)
def predict_all(self, query):
label_similarities = {}
query_hash = self.build_text(query)
for label in self.model:
max_similarity = 0
for data_point in self.model[label]:
similarity = self.similar(data_point, query_hash)
if similarity > max_similarity:
max_similarity = similarity
label_similarities[label] = max_similarity
return label_similarities
def predict(self, query):
max_similarity, max_label = 0, None
query_hash = self.build_text(query)
for label in self.model:
for data_point in self.model[label]:
similarity = self.similar(data_point, query_hash)
if similarity > max_similarity:
max_similarity, max_label = similarity, label
return max_label, max_similarity
def similar(self, x, y):
hamming_distance = bin(x ^ y).count('1')
return 1 - hamming_distance / 128
+1 -2
View File
@@ -5,5 +5,4 @@ alist = [".ppt",".pptx",".wps",".txt",".rtf",
".pdf",".xls",".xlsx",".doc",".docx",
".jpg",".jpeg",".png",".webp",".gif",
".mp3",".wav",".aac",".ogg",".flac",
".mp4",".avi",".mov",".wmv",".mkv",
".zip",".7z",".rar",".tar",".gz"]
".mp4",".avi",".mov",".wmv",".mkv"]
-1
View File
@@ -1 +0,0 @@
{"2024-01-30 18:57:47": ["f8eaca69", "f0f5732f", "1b02d2da", "9b83055e", "fa39258e", "ebad499a", "7e7275ce", "f9f96fde", "dc2bd521", "2e3086b1", "4cbbe367", "62a39640", "628691a4", "7feb71ad", "c8756155", "724103b9", "21bb3aef", "8b136daa", "d2668208", "5e47ce27", "55e78944", "ec90753b", "cb9e21ee", "55634643", "d1ad686f", "319e2db4", "632f4531", "ecf51f02", "57b1794e", "cf04dfb7", "68b4c29f", "776c99fe", "bafe8409", "07483ddf", "e4753bc3", "86f8c21f", "c069d7d5", "0513868a", "55433105", "a51343e5", "5dd1e0c9", "8b6a35fc", "b2c4204c", "736a55d1", "0e2d378e", "221b87e3", "62a348cf", "1f53d69f", "ac0b27eb", "bee130c7", "00b0d86d", "f1dc8325", "d1e142b8", "87074aa5", "2bd013a0", "d2528b9e", "d90657b4", "b16889df", "c21af82e", "e81da5d7", "0ae06db8", "a072f779", "6c48e028", "acf0fbaa", "846a7177", "97be1e02", "94c2d42c", "e1240e10", "ee0a9c21", "0facf2a6", "2beae172", "39ae5ad7", "6a0c7324", "f074f5b4", "e952305f", "c969fd9d", "9af5a01e", "14688765", "596a470f", "94691d9a", "f30de2e7", "191f1163", "bdcb5a86", "18b3bf16", "30739d24", "e91746a4", "36888e71", "e26dfd80", "d8261ac3", "1a5cb45a", "23191f29", "20cb7eec", "94497ba5", "ce095672", "acf3bb61", "94bff605", "aea0475c", "b6a46047", "f1ae2ce5", "f25e7c70", "4c626e62", "d4da4030", "35eeb9fc", "010bd7e6", "088b5c3d", "4e552f39", "234f232b", "be39b5c7", "4d57d439", "3efc231b", "e3e0254f", "cf88078b", "957e7561", "0157ab1a", "6d75bcaa", "fdf069cb", "a1895d33", "aebc3614", "43d61eab", "967929f9", "11b631fb", "fbe63639", "0593e9a2", "c838e850", "a33c2ab4", "fa8ceeae", "71fa160a", "05178537", "f1bde64f", "30547b8f", "7fe931dd", "5dea0cda", "af0d6ebb", "f242ebc1", "ef2ac9f8", "09082309", "85a4b8a4", "65284f49", "cf215013", "6be2182a", "39d583d4", "e65f4785", "3cbb09cf", "73b78451", "61099a43", "1fe35f2e", "690b5995", "19d85999", "fcaa2063", "522ec9f6", "dfea1c9a", "1e54fc8c", "3d19c3b6", "13102764", "f0949aca", "7782a5e0", "a141f55e", "16eb1d17", "f14e284b", "3c36ae8e", "44349994", "0077b966", "8d8e66bb", "26dbaaa7", "69134125", "6be14646", "d4afaff6", "10c1954f", "07687215", "18b6668e", "295e94f1", "4beef072", "15bbc35a", "833b1998", "b81c15eb", "d0c36eb5", "30ff5635", "23edb694", "b5f2dd11", "9542f014", "2ba7934b", "8ac3e370", "be5348af", "2f7ca0b7", "c11f9756", "72646e9e", "ebaa875f", "d8efdadd", "cea3f4a5", "8f74e253", "c8ee6a44", "29a60790", "b6ed92dc", "022ab8d8", "f45011dd", "5606be13", "9fe86003", "c90d1128", "7bf6f523", "5dc456d1", "d41f3fb7", "839f31ff", "72e25499", "d0008616", "d6d13cfd", "018b8805", "3bd56a87", "7bf71a77", "302c6754", "639a51eb", "3025c6b7", "b233ddd9", "9297a1cb", "c10f2cf6", "a0a8dfd1", "6399f135", "8d394492", "d786ef37", "f516133b", "b71b7a0d", "a51484ee", "b6ec2abf", "184ccf63", "6cc57095", "897e3a5f", "5064bd10", "0abbe6f4", "57d2bb57", "3e3a904e", "cb25c53f", "35ebf1ea", "ec883603", "6c3d2e9a", "cd48542a", "e0b6a475", "1ed5d4af", "5cfe1ec3", "2f3f077c", "817d5bcb", "e7e4805a", "a8ac4be7", "3ae3b681", "781b603d", "99e3aca7", "d3cb5549", "e4e549d2", "eda8c8fd", "5a34fc94", "35385307", "b47d2a97", "8c0d1b23", "5529b024", "068c506c", "41858343", "861a909a", "96471e95", "a2b9d78f", "97255487", "506d0366", "7c5e3180", "e1aee43f", "99ad8db1", "1f4f4ab1", "cc431464", "cffd3e92", "ece85b50", "de6d3489", "9425f525", "c9dfa23f", "a97155f3", "002e23f2", "d440e8ed", "08798831", "96474097", "34962f83", "979532a1", "31f03b48", "5b692416", "c56d5e02", "5c2a1c1e", "6d642743", "fb15345a", "1bf7af93", "bb94e602", "4492b29b", "355885b6", "1e62932b", "f1bede8b", "6104f9a3", "86a6529d", "971f7f79", "8ace816a", "86a8a864", "4f85c567", "333b7df1", "cebe043f", "aa818d5e", "5458e526", "5354fc59", "14238173", "4794d596", "bd2797bd", "7e5013a9", "4211942c", "8c919cb4", "39bae570", "c8476924", "59d0bcc8", "29a47420", "62145122", "0b95337c", "55cd1300", "6fec3fac", "7abd0227", "ec842bbb", "f60b523e", "8ec73106", "e29225d6", "54224ade", "d722b746", "9342c1e3", "ce494c91", "4c1e1a2e", "20879280", "1c623712", "0ab6b9b5", "3cbe70c8", "090a5016", "1176c81f", "c4ca6358", "0ac1e588", "327018cc", "1aa3b54f", "9d8ed7e1", "98ecee4c", "1250f47d", "b48f6dcc", "2fd8a8a8", "df5292b9", "43ca2196", "eabebfd0", "5ef75e18", "6043426b", "5668ab16", "5694217b", "8da2c149", "8e108bc2", "4c44a17c", "ccdbc95c", "d578162e", "a828b92d", "226217c3", "5008e44f", "6ff4ce20", "10f2a2b1", "ee6b50e6", "1bc9bab0", "a69a2aba", "9dbfcd08", "539bc501", "640f2927", "e7e38d5e", "43adb03a", "7033ad33", "a98e1d1d", "19c928b8", "20fcecfd", "2038f57b", "1938493f", "47a32506", "6aa98b23", "051020bf", "4f5a3b25", "34d7276a", "79f68a23", "5b28a176", "15826bb9", "6a2eaaab", "23269a41", "79d85fa6", "51fe1954", "8f737801", "44dde6a5", "f8b69084", "136c1369", "086c7679", "0016c379", "2fe5822d", "1b146d77", "ff778b87", "6357bd68", "95840477", "c605b02a", "d9e4a2da", "1488771c", "1d067fed", "6c1c79f2", "4ce7e503", "c0d7b8fb", "ef0a1059", "f8984bae", "c9f98890", "f4eb7828", "5e570d46", "9ea12215", "de09d16e", "a470767a", "8c43a7fe", "65f145c0", "e425c385", "51453f5f", "fbca4af8", "5f213b95", "a6e2669f", "0d8e3Line truncated
+1 -1
View File
@@ -18,7 +18,7 @@ translate_dict = {
"惡":"恶","據":"据","庫":"库","經":"经","敗":"败"},
"en_US": {"已開啟":"On","已關閉":"Off","已开启":"On","已关闭":"Off",",":", ",
"立即刪除":"Delete Now","安全模式":"Safe Mode","官方網站":"Website",
"惡意檔案":"Virus ","惡意軟體":"Malware ","勒索軟體":"Ransom ",
"惡意檔案":"Virus ","惡意軟體":"Malware ","勒索行為":"Ransom ",
"惡意腳本":"Script ","惡意行為":"Behavior ","可疑軟體":"Suspicious ",
"許可條款":"License Terms","惡意":"Malicious","可疑":"Suspicious",
"啟用":"Enable ","禁用":"Disable ","正在初始化中":"Initializing ",
+1
View File
@@ -0,0 +1 @@
{"Virus": [261318414186602332274638176436767278092, 138027491891768042595443233665640385515, 110357087572968576943094470150101987119, 89628141614819275279501592421270658611, 9625936089192481713091234633207548145, 146573019333239184433892013297795962994, 264541877314875483358485439014616010241, 89378687258170412207570345845754816506, 295491687946453794463476073658069199320, 270110569967616684464025230399867156597, 317767290038007567692141082439138927345, 18885788501897915917239730749935859793, 95067756796967225976055101492886444145, 5340774248576581325353819949912031489, 127221069722257753511418504633757572348, 10415246439899713411029597770193411184, 95651985866123533435079044203969354868, 188173655331549916271106901837471791624, 115920025419090664908814181482465136245, 264555963058906459534362468816145940272, 95651985871075295954016225919772204788, 230418814927598623996991522865620895293, 307822865305226887780395456446154510073, 292376319578571219959135358926367053520, 894545638663197114170691953086909252, 307408049865722049855100904733744729280, 281395069059347277039468499503754758797, 10580035239361434345353152238353587444, 116667039230079911205687280113439840357, 105638824952820428052005376209508641704, 10159525814797641639514752130410024305, 799868415884320332536138129537778698, 22744055344958721368630687581251847176, 255349869106614732679810651086278546442, 315759149185061187179391478424305256898, 95315785306000038407304639293114375376, 110684881900941951709859261701564766961, 145716650028545025053236635988099140033, 95562399119788972561845288789790891122, 222253752239577871278657531622986138289, 94821380653995263056920242811808354032, 105453663146661214242864956330772860016, 133237106118017744142061791759548170883, 106285815540718769887458629487913147505, 171522714730243767599747450471850906780, 201783522381387157888199381457569830339, 95559052534575041823542189821460810608, 6803412338476848613694005563166320666, 105787286451833022929870383496648011249, 106280623246394143467097978838728292593, 94820584548412181705953186602301163257, 95563048166632561463187231032275512432, 108010814655804390841927389574188560953, 173324173206867137081876750353781475864, 95232708608642156662699453866682554993, 106285815540717561551934825217444224113, 95318319972117721345303221798918291186, 95559057605177442847140260259121040241, 305010456281757544171469123445447117681, 106198844586809641198104478887777078384, 179710050855676845982141937253360453053, 94818541689698630943530703193593974512, 105455042350511842344155948214062747248, 20881613063668797611160339818896853168, 31018193447326218505924275935240096368, 143088668467296939342778818474878950647, 110684892675972091428741019788518218489, 137521268273704145345759177480636558327, 106119662154515582210221674170892663408, 105949568716338471638768471668461534962, 89670460543521034706908097860639104624, 10332169700047182535948410013892054257, 95145598865408927095247444731707367024, 100629312664727978741143555078594927795, 148748393343889971317559945312215468786, 93989806751692355346109462915386284256, 107244620726926889373575057027717450762, 94987377598500779420569757831453449840, 100878647073583869926186814218125905113, 20215706740235798874506125693183790832, 110684912958381676190945511157408029425, 105949568706125465724368274041836011250, 300558662558418689647121992472167150144, 106201415362574605111426884001172884597, 110684882592911957008875737340312369917, 94987377577609631169063907051139341428, 105039010693725170460743583068113023705, 114380135952416886874949645426965728392, 124017012583193473160915936873388365506, 94662072863013290725024950240040430327, 143175020845977086618208175741834533027, 132011016412170201801452237305311191441, 10580035240599374384629243014119103732, 105576376886969565715901422869178687219, 172003113737697601641723035082316482624, 109023346904934388839803760995464461049, 10496943991486934504031035936730090609, 127216527016950104546694906326424083058, 336983008266790509743060629130917677774, 10248965448213412269216028810651597936, 79036768232931406417351794113275712068, 105532141803327881065557146349585635569, 100963036754215599502702416838888975610, 105787367661937540200783035652543688177, 95319034907171535697107975830043465952, 95150935027941497330695649661434404081, 31018193447326218505924275935240096368, 176177498613631404614794194516575496896, 136271405179532594000996159423307548914, 66833476002653370931812317778542555093, 9915421242395013439142248483403569396, 162357332045345094604141502928937491106, 95650044561417669529155573147468110960, 95065159985079431125978131216282192112, 18639272732092977493351497242647705306, 230570463661756059397447611038616439025, 95484514342568128463910419849540603504, 266025808443819672030174370144173223456, 47343025305025541868952332865095320248, 100968228555433537808235270915390512872, 105953482575652408268669106292717067508, 95311896151231050439910957073435270256, 105867687984072457600475937752904732400, 116Line truncated
+2 -1
View File
@@ -1,7 +1,8 @@
import pyinstaller_versionfile
pyinstaller_versionfile.create_versionfile(
output_file="versionfile.txt",
version='3.0.2',
version='3.0.7',
company_name="PYAS Security",
file_description="Python Antivirus Software",
internal_name="PYAS",
+9 -3
View File
@@ -1,16 +1,20 @@
# PYAS (Python Antivirus Software)
![PYAS](https://github.com/87owo/PYAS/assets/85057800/153bcad9-18ab-4c81-bcb6-186434d0ef1b)
![PYAS](https://github.com/87owo/PYAS/assets/85057800/8136aaca-d388-4321-bedb-abc4fcecfa8b)
## Readme Language
[繁體中文](https://github.com/zackzheng1121/PYAS/blob/main/README_zh.md)
## File Information
PYAS.py -> Main PYAS Program (including animation, scanning, protection functions, etc.)
PYAS_Compress.py -> Conversion Database (used to convert database dict and list to and from each other)
PYAS_Engine.py -> Conversion Database (used to convert database dict and list to and from each other)
PYAS_Extension.py -> File Extension (including scanned file extensions and common file extensions)
PYAS_Function.* -> Virus Database (the virus database must be placed in the same directory)
PYAS_Model.* -> Virus Database (the virus database must be placed in the same directory)
PYAS_Interface.py -> PyQt5 Interface (designed by QT designer, must be matched with the main program)
@@ -113,6 +117,8 @@ def proc_detect():
print(f"File: {file}")
print(f"Pid: {p.pid}")
print(f"Cmd: {cmd}")
elif not psutil.pid_exists(p.pid):
existing_processes.remove(p.pid)
except:
pass
+167
View File
@@ -0,0 +1,167 @@
# PYAS (Python 防毒軟體)
![PYAS](https://github.com/87owo/PYAS/assets/85057800/153bcad9-18ab-4c81-bcb6-186434d0ef1b)
## 文件訊息
PYAS.py -> PYAS主程式(包括動畫、掃描、保護功能等)
PYAS_Engine.py -> 轉換資料庫(用於相互轉換資料庫字典和清單)
PYAS_Extension.py -> 檔案副檔名(包括掃描檔案副檔名和常用檔案副檔名)
PYAS_Model.* -> 病毒庫(病毒庫必須放在同一目錄下)
PYAS_Interface.py -> PyQt5 Interface(由QT設計師設計,必須與主程式相符)
PYAS_Resource.py -> PyQt5資源(狀態圖片、圖示包、按鈕圖示等)
PYAS_Language.py -> 翻譯字典(繁體中文、簡體中文、英文)
PYAS_Version.py -> Pyinstaller Info(檔案資訊、版本資訊、原名等)
## 要求
使用 pip install requirements 來安裝需要的模組
```
psutil==5.9.5
pefile==2023.2.7
requests==2.31.0
pyperclip==1.8.2
pywin32==306
PyQt5==5.15.9
```
## 哈希掃描
使用奇虎360雲端服務掃描已知惡意文件
```
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檔案函數導入表進行掃描
```
import pefile
def pe_scan(file):
try:
fn = []
with pefile.PE(file) as pe:
for entry in pe.DIRECTORY_ENTRY_IMPORT:
for func in entry.imports:
try:
fn.append(str(func.name, "utf-8"))
except:
pass
if fn in known_malicious_list:
return "Virus"
return "Safe"
return "Unknown"
except Exception as e:
return f"Error: {e}"
info = pe_scan("path to file")
print(info)
```
## 進程偵測
顯示新進程名稱、檔案路徑、cmd 行、pid
```
import psutil, time
def proc_detect():
existing_processes = set()
for p in psutil.process_iter():
if p.pid not in existing_processes:
existing_processes.add(p.pid)
while True:
time.sleep(0.1)
for p in psutil.process_iter():
try:
if p.pid not in existing_processes:
existing_processes.add(p.pid)
name, file, cmd = p.name(), p.exe(), p.cmdline()
print(f"Name: {name}")
print(f"File: {file}")
print(f"Pid: {p.pid}")
print(f"Cmd: {cmd}")
except:
pass
proc_detect()
```
## 檔案偵測
監控指定路徑下的檔案變化
```
import os, win32file, win32con
def file_detect(path):
hDir = win32file.CreateFile(path,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)
while True:
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 = os.path.join(path, file)
if action == 1:
print(f"File Create: {fpath}")
elif action == 2:
print(f"File Delete: {fpath}")
elif action == 3:
print(f"File Modify: {fpath}")
elif action == 4:
print(f"File Rename: {fpath}")
elif action == 5:
print(f"File Rename: {fpath}")
except:
pass
file_detect("path")
```
## 官方網頁
https://pyantivirus.wixsite.com/pyas
https://github.com/87owo/PYAS
## 開源許可證
https://github.com/87owo/PYAS/blob/main/LICENSE.md
## 支援的系統
Windows 8.1, 10, 11 (64-bit),記憶體 1GB, 磁碟容量 1GB 或更高
Other systems may experience software malfunctions or crash
## Special Thanks
360, Wix, VirusShare, mtkiao129, AV-T Team of LisectGroup
Copyright© 2020~2024 PYAS Security By 87owo