Merge pull request #712 from midoks/dev

简单优化
pull/720/head
Mr Chen 2 months ago committed by GitHub
commit 225ea91f43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      plugins/tamper_proof_py/index.py
  2. 4
      plugins/tamper_proof_py/info.json
  3. 14
      plugins/tamper_proof_py/tamper_proof_service.py
  4. 2
      plugins/webhook/install.sh

@ -324,8 +324,7 @@ class App:
siteInfo['open'] = not siteInfo['open'] siteInfo['open'] = not siteInfo['open']
m_logs = {True: '开启', False: '关闭'} m_logs = {True: '开启', False: '关闭'}
self.writeLog('%s站点[%s]防篡改保护' % self.writeLog('%s站点[%s]防篡改保护' % (m_logs[siteInfo['open']], siteInfo['siteName']))
(m_logs[siteInfo['open']], siteInfo['siteName']))
self.siteReload(siteInfo) self.siteReload(siteInfo)
self.saveSiteConfig(siteInfo) self.saveSiteConfig(siteInfo)
self.restart() self.restart()
@ -458,8 +457,7 @@ class App:
if not protectExt in siteInfo['protectExt']: if not protectExt in siteInfo['protectExt']:
continue continue
siteInfo['protectExt'].remove(protectExt) siteInfo['protectExt'].remove(protectExt)
self.writeLog('站点[%s]从受保护列表中删除[.%s]' % self.writeLog('站点[%s]从受保护列表中删除[.%s]' % (siteInfo['siteName'], protectExt))
(siteInfo['siteName'], protectExt))
self.siteReload(siteInfo) self.siteReload(siteInfo)
self.saveSiteConfig(siteInfo) self.saveSiteConfig(siteInfo)
return mw.returnJson(True, '删除成功!') return mw.returnJson(True, '删除成功!')
@ -593,8 +591,7 @@ class App:
for i in range(len(sites)): for i in range(len(sites)):
if sites[i]['siteName'] in siteNames: if sites[i]['siteName'] in siteNames:
sites[i]['open'] = siteState sites[i]['open'] = siteState
self.writeLog('%s站点[%s]防篡改保护' % self.writeLog('%s站点[%s]防篡改保护' % (m_logs[siteState], sites[i]['siteName']))
(m_logs[siteState], sites[i]['siteName']))
self.writeSites(sites) self.writeSites(sites)
return mw.returnJson(True, '批量设置成功') return mw.returnJson(True, '批量设置成功')

@ -1,9 +1,9 @@
{ {
"title": "网站防篡改程序[PY]", "title": "网站防篡改程序PY",
"tip": "lib", "tip": "lib",
"name": "tamper_proof_py", "name": "tamper_proof_py",
"type": "soft", "type": "soft",
"ps": "事件型防篡改程序,可有效保护网站重要文件不被木马篡改", "ps": "事件型防篡改程序,可有效保护网站重要文件不被木马篡改[Python]",
"versions": "1.0", "versions": "1.0",
"shell": "install.sh", "shell": "install.sh",
"checks": "server/tamper_proof_py", "checks": "server/tamper_proof_py",

@ -123,10 +123,10 @@ class MyEventHandler(pyinotify.ProcessEvent):
return ret[0:20] return ret[0:20]
return ret return ret
def get_site_logs(self, Stiename): def get_site_logs(self, site_name):
try: try:
pythonV = sys.version_info[0] pythonV = sys.version_info[0]
path = '/www/wwwlogs/' + Stiename + '.log' path = '/www/wwwlogs/' + site_name + '.log'
num = 500 num = 500
if not os.path.exists(path): if not os.path.exists(path):
return [] return []
@ -422,7 +422,7 @@ class MyEventHandler(pyinotify.ProcessEvent):
os.system('chattr -R -a {} &> /dev/null'.format(path)) os.system('chattr -R -a {} &> /dev/null'.format(path))
self.set_user_ini(path) self.set_user_ini(path)
def close(self, reload=False): def close(self, close_reload=False):
# 解除锁定 # 解除锁定
sites = self.get_sites() sites = self.get_sites()
print("") print("")
@ -433,11 +433,10 @@ class MyEventHandler(pyinotify.ProcessEvent):
tip = self._PLUGIN_PATH + '/tips/' + siteInfo['siteName'] + '.pl' tip = self._PLUGIN_PATH + '/tips/' + siteInfo['siteName'] + '.pl'
if not siteInfo['open'] and not os.path.exists(tip): if not siteInfo['open'] and not os.path.exists(tip):
continue continue
if reload and siteInfo['open']: if close_reload and siteInfo['open']:
continue continue
if sys.version_info[0] == 2: if sys.version_info[0] == 2:
print( print("{}】|-Unlock website[{}]".format(mw.formatDate(), siteInfo['siteName'])),
"{}】|-Unlock website[{}]".format(mw.formatDate(), siteInfo['siteName'])),
else: else:
os.system("echo -e '{}|-Unlock website[{}]\c'".format(mw.formatDate(), siteInfo['siteName'])) os.system("echo -e '{}|-Unlock website[{}]\c'".format(mw.formatDate(), siteInfo['siteName']))
#print("【{}】|-解锁网站[{}]".format(mw.format_date(),siteInfo['siteName']),end=" ") #print("【{}】|-解锁网站[{}]".format(mw.format_date(),siteInfo['siteName']),end=" ")
@ -514,8 +513,7 @@ def run():
if not os.path.exists(tip): if not os.path.exists(tip):
event.list_DIR(siteInfo['path'], siteInfo) event.list_DIR(siteInfo['path'], siteInfo)
try: try:
watchManager.add_watch( watchManager.add_watch(siteInfo['path'], mode, auto_add=True, rec=True)
siteInfo['path'], mode, auto_add=True, rec=True)
except: except:
print(mw.getTracebackInfo()) print(mw.getTracebackInfo())
tout = round(time.time() - s, 2) tout = round(time.time() - s, 2)

@ -15,6 +15,8 @@ Install_App()
mkdir -p $serverPath/webhook mkdir -p $serverPath/webhook
echo "${VERSION}" > $serverPath/webhook/version.pl echo "${VERSION}" > $serverPath/webhook/version.pl
echo '安装完成' echo '安装完成'
which mw && mw restart
} }
Uninstall_App() Uninstall_App()

Loading…
Cancel
Save