Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
87owo authored Jul 16, 2024
1 parent 14bde5a commit b248913
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 69 deletions.
67 changes: 41 additions & 26 deletions PYAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from PyQt5.QtGui import *
from subprocess import *

# experimental version 2024/07 PYAS Security

class MainWindow_Controller(QMainWindow):
def __init__(self):
# init program window
Expand All @@ -28,7 +26,7 @@ def __init__(self):

# init self program version
self.pyae_version = "Fusion Engine"
self.pyas_version = "3.1.4"
self.pyas_version = "3.1.5"

# startup ui config
self.first_startup = True
Expand Down Expand Up @@ -147,19 +145,20 @@ def init_config_read(self):
# check config file exists
if not os.path.exists("C:/ProgramData/PYAS/PYAS.json"):
self.write_config({"language":"en_US","theme_color":"White",
"high_sensitive":0,"cloud_services":"None"})
"high_sensitive":0,"extension_kits":1,"cloud_services":"None"})
try:
# read config json data
with open("C:/ProgramData/PYAS/PYAS.json", "r") as f:
self.json = json.load(f)
except:
self.json = {"language":"en_US","theme_color":"White",
"high_sensitive":0,"cloud_services":"None"}
"high_sensitive":0,"extension_kits":1,"cloud_services":"None"}

# default json config
self.json["language"] = self.json.get("language", "en_US")
self.json["theme_color"] = self.json.get("theme_color", "White")
self.json["high_sensitive"] = self.json.get("high_sensitive", 0)
self.json["extension_kits"] = self.json.get("extension_kits", 1)
self.json["cloud_services"] = self.json.get("cloud_services", "None")

# reflash high_sensitive ui text
Expand All @@ -169,6 +168,12 @@ def init_config_read(self):
QPushButton{border:none;background-color:rgb(200, 250, 200);border-radius: 10px;}
QPushButton:hover{background-color:rgb(210, 250, 210);}""")

if self.json["extension_kits"] == 1:
self.ui.extension_kit_switch_Button.setText(self.trans("已開啟"))
self.ui.extension_kit_switch_Button.setStyleSheet("""
QPushButton{border:none;background-color:rgb(200, 250, 200);border-radius: 10px;}
QPushButton:hover{background-color:rgb(210, 250, 210);}""")

# reflash language ui setChecked
if self.json["language"] == "zh_TW":
self.ui.Language_Traditional_Chinese.setChecked(True)
Expand Down Expand Up @@ -246,7 +251,7 @@ def init_control(self):

# connect settings ui and function control
self.ui.high_sensitivity_switch_Button.clicked.connect(self.change_sensitive)
self.ui.cloud_services_switch_Button.clicked.connect(self.cloud_service)
self.ui.extension_kit_switch_Button.clicked.connect(self.extension_kit)
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)
Expand Down Expand Up @@ -384,11 +389,11 @@ def init_lang_text(self):
self.ui.PYAS_URL_title.setText(self.trans("官方網站:"))
self.ui.PYAS_URL.setText(self.trans("<html><head/><body><p><a href=\"https://github.com/87owo/PYAS\"><span style=\" text-decoration: underline; color:#000000;\">https://github.com/87owo/PYAS</span></a></p></body></html>"))
self.ui.high_sensitivity_title.setText(self.trans("高靈敏度模式"))
self.ui.high_sensitivity_illustrate.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.extension_kit_title.setText(self.trans("擴展掃描引擎"))
self.ui.extension_kit_illustrate.setText(self.trans("啟用此選項可以使用第三方擴展套件"))
self.ui.extension_kit_switch_Button.setText(self.trans(self.ui.extension_kit_switch_Button.text()))
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()))
Expand Down Expand Up @@ -799,6 +804,24 @@ def change_sensitive(self):
QPushButton:hover{background-color:rgb(210,250,210);}""")
self.write_config(self.json)

def extension_kit(self):
sw_state = self.ui.extension_kit_switch_Button.text()
if sw_state == self.trans("已開啟"):
# close extension kit mode
self.json["extension_kits"] = 0
self.ui.extension_kit_switch_Button.setText(self.trans("已關閉"))
self.ui.extension_kit_switch_Button.setStyleSheet("""
QPushButton{border:none;background-color:rgb(230,230,230);border-radius: 10px;}
QPushButton:hover{background-color:rgb(220,220,220);}""")
else:
# open extension kit mode
self.json["extension_kits"] = 1
self.ui.extension_kit_switch_Button.setText(self.trans("已開啟"))
self.ui.extension_kit_switch_Button.setStyleSheet("""
QPushButton{border:none;background-color:rgb(200,250,200);border-radius: 10px;}
QPushButton:hover{background-color:rgb(210,250,210);}""")
self.write_config(self.json)

def cloud_service(self):
try:
# cloud services config /ProgramData/PYAS.json
Expand Down Expand Up @@ -997,26 +1020,18 @@ def start_scan(self, file):
if label and "Unknown" == label:
if self.rule_scan(file):
return "Rules"
elif self.exten.bdc_scan(file):
return "Exten"
elif label and "White" != label:
if self.json["high_sensitive"]:
return label
elif level and level >= 1.0:
return label
elif self.rule_scan(file):
return "Rules"
elif self.exten.bdc_scan(file):
return "Exten"
elif not label and ftype in slist:
if self.rule_scan(file):
return "Rules"
elif self.exten.bdc_scan(file):
return "Exten"
elif self.json["high_sensitive"]:
if self.rule_scan(file):
return "Rules"
elif self.exten.bdc_scan(file):
if self.json["extension_kits"]:
if self.exten.bdc_scan(file):
return "Exten"
return False
except:
Expand Down Expand Up @@ -1375,7 +1390,7 @@ def protect_drv_init(self):
if not self.first_startup:
if result == 0 or result == 577:
if self.question_event("使用此選項需要重啟,您確定要重啟嗎?"):
Popen(f'"{file_path}/Uninstall_Driver.bat"', shell=True, stdout=PIPE, stderr=PIPE).wait()
Popen(f'"{file_path}/Uninstall_Driver.bat"', shell=True, stdout=PIPE, stderr=PIPE)
else:
Popen("sc start PYAS_Driver", shell=True, stdout=PIPE, stderr=PIPE).wait()
if result == 1062 or result == 1060:
Expand All @@ -1389,7 +1404,7 @@ def protect_drv_init(self):
if result == 1060 or result == 3 or result == 577:
if self.question_event("此選項可能會與其他軟體不兼容,您確定要開啟嗎?"):
Popen("sc delete PYAS_Driver", shell=True, stdout=PIPE, stderr=PIPE).wait()
Popen(f'"{file_path}/Install_Driver.bat"', shell=True, stdout=PIPE, stderr=PIPE).wait()
Popen(f'"{file_path}/Install_Driver.bat"', shell=True, stdout=PIPE, stderr=PIPE)
else:
Popen("sc stop PYAS_Driver", shell=True, stdout=PIPE, stderr=PIPE).wait()
if result == 0 or result == 1056:
Expand Down Expand Up @@ -1475,10 +1490,10 @@ def proc_scan(self, p):
if ":/Windows" not in file and self.start_scan(file):
self.kill_process(p, "加載攔截", False)
return True
self.lock_process(p, False)
time.sleep(0.2)
if self.exten.pe_sieve(p):
self.kill_process(p, "記憶體攔截", True)
if self.json["extension_kits"]:
self.lock_process(p, False)
if self.exten.pe_sieve(p):
self.kill_process(p, "記憶體攔截", True)
return False
except:
return False
Expand Down
7 changes: 3 additions & 4 deletions PYAS_Extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self):

def bdc_scan(self, file):
if self.exten.replace("\\", "/") not in file.replace("\\", "/"):
cmd = f'"{self.exten}\\Bitdefender\\bdc.exe" "{file}"'
cmd = f'"{self.exten}\\bitdefender\\bdc.exe" "{file}"'
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
for match in re.finditer(r'(?P<filename>[^\s]+)\s+infected:\s+(?P<virusname>.+)', p.communicate()[0]):
return match.groupdict()
Expand All @@ -30,7 +30,6 @@ def pe_sieve(self, p):
output = p.communicate()[0]
for match in re.finditer(r'(\d+)', output):
line = output[:match.start()].split('\n')[-1].strip().replace(':', '')
if line in ["Implanted shc", "Replaced", "IAT Hooks", "Other"]:
if int(match.group(1)) > 0:
return line
if line in ["Implanted shc", "Replaced", "IAT Hooks"] and int(match.group(1)) > 0:
return line
return False
70 changes: 35 additions & 35 deletions PYAS_Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,49 +1569,49 @@ def setupUi(self, MainWindow):
self.Language_illustrate.raise_()
self.Language_Choose_widget.raise_()
self.Language_title.raise_()
self.Show_cloud_services = QtWidgets.QWidget(self.Setting_widget)
self.Show_cloud_services.setGeometry(QtCore.QRect(30, 130, 781, 81))
self.Show_cloud_services.setAcceptDrops(False)
self.Show_cloud_services.setAutoFillBackground(False)
self.Show_cloud_services.setObjectName("Show_cloud_services")
self.cloud_services_title = QtWidgets.QLabel(self.Show_cloud_services)
self.cloud_services_title.setGeometry(QtCore.QRect(20, 10, 451, 31))
self.Show_extension_kit = QtWidgets.QWidget(self.Setting_widget)
self.Show_extension_kit.setGeometry(QtCore.QRect(30, 130, 781, 81))
self.Show_extension_kit.setAcceptDrops(False)
self.Show_extension_kit.setAutoFillBackground(False)
self.Show_extension_kit.setObjectName("Show_extension_kit")
self.extension_kit_title = QtWidgets.QLabel(self.Show_extension_kit)
self.extension_kit_title.setGeometry(QtCore.QRect(20, 10, 451, 31))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei")
font.setPointSize(17)
font.setBold(False)
font.setWeight(50)
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
self.cloud_services_title.setFont(font)
self.cloud_services_title.setStyleSheet("color: rgb(70,70,70);")
self.cloud_services_title.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.cloud_services_title.setObjectName("cloud_services_title")
self.cloud_services_illustrate = QtWidgets.QLabel(self.Show_cloud_services)
self.cloud_services_illustrate.setGeometry(QtCore.QRect(20, 40, 451, 31))
self.extension_kit_title.setFont(font)
self.extension_kit_title.setStyleSheet("color: rgb(70,70,70);")
self.extension_kit_title.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.extension_kit_title.setObjectName("extension_kit_title")
self.extension_kit_illustrate = QtWidgets.QLabel(self.Show_extension_kit)
self.extension_kit_illustrate.setGeometry(QtCore.QRect(20, 40, 451, 31))
font = QtGui.QFont()
font.setFamily("Microsoft YaHei")
font.setPointSize(11)
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
self.cloud_services_illustrate.setFont(font)
self.cloud_services_illustrate.setStyleSheet("color: rgb(70,70,70);")
self.cloud_services_illustrate.setScaledContents(False)
self.cloud_services_illustrate.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.cloud_services_illustrate.setWordWrap(True)
self.cloud_services_illustrate.setObjectName("cloud_services_illustrate")
self.cloud_services_switch_Button = QtWidgets.QPushButton(self.Show_cloud_services)
self.cloud_services_switch_Button.setGeometry(QtCore.QRect(660, 20, 91, 31))
self.extension_kit_illustrate.setFont(font)
self.extension_kit_illustrate.setStyleSheet("color: rgb(70,70,70);")
self.extension_kit_illustrate.setScaledContents(False)
self.extension_kit_illustrate.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.extension_kit_illustrate.setWordWrap(True)
self.extension_kit_illustrate.setObjectName("extension_kit_illustrate")
self.extension_kit_switch_Button = QtWidgets.QPushButton(self.Show_extension_kit)
self.extension_kit_switch_Button.setGeometry(QtCore.QRect(660, 20, 91, 31))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.cloud_services_switch_Button.sizePolicy().hasHeightForWidth())
self.cloud_services_switch_Button.setSizePolicy(sizePolicy)
sizePolicy.setHeightForWidth(self.extension_kit_switch_Button.sizePolicy().hasHeightForWidth())
self.extension_kit_switch_Button.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setFamily("Microsoft YaHei")
font.setPointSize(11)
font.setStyleStrategy(QtGui.QFont.PreferAntialias)
self.cloud_services_switch_Button.setFont(font)
self.cloud_services_switch_Button.setFocusPolicy(QtCore.Qt.StrongFocus)
self.cloud_services_switch_Button.setStyleSheet("QPushButton\n"
self.extension_kit_switch_Button.setFont(font)
self.extension_kit_switch_Button.setFocusPolicy(QtCore.Qt.StrongFocus)
self.extension_kit_switch_Button.setStyleSheet("QPushButton\n"
"{\n"
" border:none;\n"
" background-color:rgb(230,230,230);\n"
Expand All @@ -1622,12 +1622,12 @@ def setupUi(self, MainWindow):
" background-color:rgb(220,220,220);\n"
"}\n"
"")
self.cloud_services_switch_Button.setIconSize(QtCore.QSize(16, 16))
self.cloud_services_switch_Button.setCheckable(False)
self.cloud_services_switch_Button.setObjectName("cloud_services_switch_Button")
self.cloud_services_illustrate.raise_()
self.cloud_services_switch_Button.raise_()
self.cloud_services_title.raise_()
self.extension_kit_switch_Button.setIconSize(QtCore.QSize(16, 16))
self.extension_kit_switch_Button.setCheckable(False)
self.extension_kit_switch_Button.setObjectName("extension_kit_switch_Button")
self.extension_kit_illustrate.raise_()
self.extension_kit_switch_Button.raise_()
self.extension_kit_title.raise_()
self.Setting_Back = QtWidgets.QPushButton(self.Setting_widget)
self.Setting_Back.setGeometry(QtCore.QRect(25, 10, 101, 41))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
Expand Down Expand Up @@ -1885,9 +1885,9 @@ def retranslateUi(self, MainWindow):
self.Language_English.setText(_translate("MainWindow", "English"))
self.Language_Traditional_Chinese.setText(_translate("MainWindow", "繁體中文"))
self.Language_Simplified_Chinese.setText(_translate("MainWindow", "简体中文"))
self.cloud_services_title.setText(_translate("MainWindow", "雲端掃描服務"))
self.cloud_services_illustrate.setText(_translate("MainWindow", "啟用此選項可以連接雲端掃描服務"))
self.cloud_services_switch_Button.setText(_translate("MainWindow", "已關閉"))
self.extension_kit_title.setText(_translate("MainWindow", "雲端掃描服務"))
self.extension_kit_illustrate.setText(_translate("MainWindow", "啟用此選項可以連接雲端掃描服務"))
self.extension_kit_switch_Button.setText(_translate("MainWindow", "已關閉"))
self.Setting_Back.setText(_translate("MainWindow", "返回"))
self.Add_White_list_title.setText(_translate("MainWindow", "增加到白名單"))
self.Add_White_list_illustrate.setText(_translate("MainWindow", "此選項可以選擇檔案並增加到白名單"))
Expand Down
6 changes: 3 additions & 3 deletions PYAS_Language.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"許可條款":"License Terms ","惡意":"Malicious","可疑":"Suspicious",
"啟用":"Enable ","禁用":"Disable ","正在初始化中":"Initializing ",
"正在掃描":"Scanning ","正在刪除":"Deleting ","最小化到":"Minimize To ",
"確定要":"Sure Want To ","靈敏度":"Sensitivity ","更新":"Update ",
"確定要":"Sure Want To ","引擎靈敏度":"Sensitivity ","更新":"Update ",
"白色主題":"White","黃色主題":"Yellow","紅色主題":"Red","語言":"Language ",
"藍色主題":"Blue","綠色主題":"Green","自定主題":"Custom","最新":"Latest ",
"特別感謝":"Contributors ","版本資訊":"Information","通訊":"Connect ",
Expand Down Expand Up @@ -53,7 +53,7 @@
"日誌":"Log","已":"Has ","彈窗":"Window ","要":"To ","驅動":"Driver ",
"的":"","顯示":"","個":"","嗎":"","中":"","了":"","行":"","立即":"",
"密鑰":"Key ","檢測":"Detect ","製作":"Maker ","運行":"Running",
"擴展套件":"Extension Kit ","自動":"Auto ","上報":"Report ","與":"With ",
"擴展":"Extension ","套件":"Kit ","自動":"Auto ","上報":"Report ","與":"With ",
"分析":"Analysis ","自身":"Self ","其他":"Other ","配置":"Config ",
"丟失":"Lost ","網站":"Website ","不兼容":"Not Compatible ","追蹤":"Tracking ",
"竄改":"Tamper "," ":" "}}
"竄改":"Tamper ","靈敏度":"Sensitivity ","第三方":"Other "," ":" "}}
2 changes: 1 addition & 1 deletion PYAS_Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pyinstaller_versionfile.create_versionfile(
output_file="versionfile.txt",
version='3.1.4',
version='3.1.5',
company_name="PYAS Security",
file_description="Python Antivirus Software",
internal_name="PYAS",
Expand Down

0 comments on commit b248913

Please sign in to comment.