From 4ef190261ada44121eb210d5b3a2f114c831bbe8 Mon Sep 17 00:00:00 2001 From: PYDT <85057800+87owo@users.noreply.github.com> Date: Wed, 31 May 2023 16:11:26 +0800 Subject: [PATCH] Add files via upload --- PYAS.py | 24 ++++++++++++++---------- PYAS_Language.py | 13 +++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/PYAS.py b/PYAS.py index 285ff19..8fc6d55 100644 --- a/PYAS.py +++ b/PYAS.py @@ -939,7 +939,7 @@ class MainWindow_Controller(QtWidgets.QMainWindow): self.ui.Virus_Scan_output.setModel(self.Virus_List_output) for d in range(26): try: - self.traverse_path(str(chr(65+d))+":/",[".exe",".dll",".com",".msi",".js",".vbs",".xls",".xlsx",".doc",".docx"]) + self.traverse_path(f"{chr(65+d)}:/",[".exe",".dll",".com",".msi",".js",".vbs",".xls",".xlsx",".doc",".docx"]) except: pass self.answer_scan() @@ -1022,13 +1022,15 @@ class MainWindow_Controller(QtWidgets.QMainWindow): def Delete_Private_File(self): file, filetype = QFileDialog.getOpenFileName(self,self.text_Translate("刪除檔案"),"C:/","") - if file != "" and file != str(sys.argv[0]): + if file != "" and file.replace("\\", "/") != str(sys.argv[0]).replace("\\", "/"): if QMessageBox.warning(self,self.text_Translate("刪除檔案"),self.text_Translate("您確定要刪除此檔案嗎?"),QMessageBox.Yes|QMessageBox.No) == 16384: try: os.remove(file) QMessageBox.information(self,self.text_Translate("刪除成功"),self.text_Translate("成功: 刪除成功"),QMessageBox.Ok) except Exception as e: self.pyas_bug_log(e) + else: + self.pyas_bug_log("權限錯誤") def Customize_CMD_Command(self): CMD_Command = self.ui.Customize_CMD_Command_lineEdit.text() @@ -1113,7 +1115,7 @@ class MainWindow_Controller(QtWidgets.QMainWindow): self.find_files = [] for d in range(26): try: - self.traverse_find_file(str(chr(65+d))+":/",file_name) + self.traverse_find_file(f"{chr(65+d)}:/",file_name) except: pass if self.find_files != []: @@ -1123,7 +1125,7 @@ class MainWindow_Controller(QtWidgets.QMainWindow): QApplication.processEvents() self.Change_Tools(self.ui.Look_for_File_widget) else: - QMessageBox.critical(self,self.text_Translate("錯誤"),self.text_Translate(f"錯誤: 未找到檔案 {file_name}"),QMessageBox.Ok) + QMessageBox.critical(self,self.text_Translate("錯誤"),self.text_Translate(f"未找到檔案: {file_name}"),QMessageBox.Ok) except Exception as e: self.pyas_bug_log(e) @@ -1276,8 +1278,8 @@ class MainWindow_Controller(QtWidgets.QMainWindow): QPushButton{border:none;background-color:rgba(20,200,20,100);border-radius: 15px;} QPushButton:hover{background-color:rgba(20,200,20,120);}""") for d in range(26): - if os.path.exists(str(chr(65+d)+":\\")): - Thread(target=self.protect_system_file, args=(str(chr(65+d)+":\\"),)).start() + if os.path.exists(f"{chr(65+d)}:/"): + Thread(target=self.protect_system_file, args=(f"{chr(65+d)}:/",)).start() def protect_threading_init_3(self): if self.ui.Protection_switch_Button_3.text() == self.text_Translate("已開啟"): @@ -1314,12 +1316,13 @@ class MainWindow_Controller(QtWidgets.QMainWindow): ##################################### 實時防護 ##################################### def protect_system_processes(self): + pyas = str(sys.argv[0]).replace("\\", "/") while self.proc_protect: for p in psutil.process_iter(): try: time.sleep(0.001) - file, name = str(p.exe()), str(p.name()) - if str(sys.argv[0]) == file or ":\Windows" in file or ":\Program" in file or ":\XboxGames" in file or "AppData" in file: + file, name = str(p.exe()).replace("\\", "/"), str(p.name()) + if pyas == file or ":/Windows" in file or ":/Program" in file or ":/XboxGames" in file or "/AppData/" in file: continue elif self.high_sensitivity == 0: if self.api_scan(file) or self.pe_scan(file): @@ -1336,13 +1339,14 @@ class MainWindow_Controller(QtWidgets.QMainWindow): pass def protect_system_file(self,path): + pyas = str(sys.argv[0]).replace("\\", "/") sflist = [".exe",".dll",".com",".msi",".js",".vbs",".xls",".xlsx",".doc",".docx"] 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 self.file_protect: try: for action, file in win32file.ReadDirectoryChangesW(hDir,1024,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): - file = str(path+file) - if str(sys.argv[0]) == file or ":\$Recycle" in file or ":\Windows" in file or ":\Program" in file or ":\XboxGames" in file or "AppData" in file: + file = str(f"{path}{file}").replace("\\", "/") + if pyas == file or ":/$Recycle" in file or ":/Windows" in file or ":/Program" in file or ":/XboxGames" in file or "AppData" in file: continue elif action and str(os.path.splitext(file)[1]).lower() in sflist and self.sign_scan(file): if self.api_scan(file): diff --git a/PYAS_Language.py b/PYAS_Language.py index 9a9d2ff..061bf93 100644 --- a/PYAS_Language.py +++ b/PYAS_Language.py @@ -14,7 +14,7 @@ translations = {"zh_TW": {"已开启":"已開啟","已关闭":"已關閉","On":" "類":"类","輸":"输","執":"执","數":"数","尋":"寻","網":"网","詢":"询", "製":"制","員":"员","許":"许","條":"条","藍":"蓝","紅":"红","綠":"绿", "態":"态","擇":"择","務":"务","連":"连","檢":"检","測":"测","庫":"库", - "簽":"签","無":"无","關":"关"}, + "簽":"签","無":"无","關":"关","權":"权"}, "en_US": {"已開啟":"On","已關閉":"Off","已开启":"On","已关闭":"Off",",":", ", "啟用":"Enable ","禁用":"Disable ","正在初始化中":"Initializing ", "正在掃描":"Scanning ","正在檢測":"Checking ","正在尋找":"Searching ", @@ -49,8 +49,9 @@ translations = {"zh_TW": {"已开启":"已開啟","已关闭":"已關閉","On":" "變更":"Change ","總數":"Total","結束":"End ","文字":"Text", "加密":"Encrypt ","解密":"Decrypt ","類型":"Type","資料":"Data", "更新":"Update","規則":"Rules","密碼":"Password ","相關":"Related ", - "全盤":"Full ","日誌":"Log","停止":"Stop ","前":"Before","後":"After", - "值":"Value ","此":"This ","名":"Name","開啟":"Open ","您":"You ", - "但":"But ","並":"And ","嗎":"","高":"High ","新":"New ","是":"Is ", - "到":"For ","未":"Not ","已":"Has ","和":"And ","會":"Can ", - "個":"","顯示":"","的":"","立即":"","中":"","行":"","稱":""," ":" "}} + "全盤":"Full ","日誌":"Log","停止":"Stop ","權限":"Permissions ", + "前":"Before","後":"After","名":"Name","開啟":"Open ","您":"You ", + "值":"Value ","此":"This ","但":"But ","並":"And ","嗎":"", + "高":"High ","新":"New ","是":"Is ","和":"And ","會":"Can ", + "到":"For ","未":"Not ","已":"Has ","個":"","顯示":"","的":"", + "立即":"","中":"","行":"","稱":""," ":" "}}