mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-06 17:47:39 +02:00
update to 6.8.37
This commit is contained in:
+27
-23
@@ -7,45 +7,49 @@
|
||||
import sys,os
|
||||
os.chdir('/www/server/panel')
|
||||
sys.path.append("class/")
|
||||
if sys.version_info[0] == 2:
|
||||
if sys.version_info[0] == 2:
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
import public,db,time
|
||||
import panelBackup
|
||||
|
||||
class backupTools(panelBackup.backup):
|
||||
def backupSite(self,name,count):
|
||||
self.backup_site(name,save=count)
|
||||
|
||||
def backupDatabase(self,name,count):
|
||||
self.backup_database(name,save=count)
|
||||
|
||||
#备份指定目录
|
||||
def backupPath(self,path,count):
|
||||
self.backup_path(path,save=count)
|
||||
|
||||
|
||||
def backupSiteAll(self,save):
|
||||
self.backup_site_all(save)
|
||||
|
||||
def backupSite(self,name,count,echo_id=None):
|
||||
self.backup_site(name,save=count,echo_id=echo_id)
|
||||
|
||||
def backupDatabaseAll(self,save):
|
||||
self.backup_database_all(save)
|
||||
def backupDatabase(self,name,count,echo_id=None):
|
||||
self.backup_database(name,save=count,echo_id=echo_id)
|
||||
|
||||
#备份指定目录
|
||||
def backupPath(self,path,count,echo_id=None):
|
||||
self.backup_path(path,save=count,echo_id=echo_id)
|
||||
|
||||
|
||||
def backupSiteAll(self,save,echo_id=None):
|
||||
self.backup_site_all(save,echo_id=echo_id)
|
||||
|
||||
|
||||
def backupDatabaseAll(self,save,echo_id=None):
|
||||
self.backup_database_all(save,echo_id=echo_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
backup = backupTools()
|
||||
type = sys.argv[1]
|
||||
echo_id = None
|
||||
if len(sys.argv) > 4: echo_id = sys.argv[4]
|
||||
if type == 'site':
|
||||
if sys.argv[2] == 'ALL':
|
||||
backup.backupSiteAll( sys.argv[3])
|
||||
backup.backupSiteAll( sys.argv[3],echo_id)
|
||||
else:
|
||||
backup.backupSite(sys.argv[2], sys.argv[3])
|
||||
backup = backupTools(cron_info = {'echo':sys.argv[4]})
|
||||
backup.backupSite(sys.argv[2], sys.argv[3],echo_id)
|
||||
elif type == 'path':
|
||||
backup.backupPath(sys.argv[2],sys.argv[3])
|
||||
backup = backupTools(cron_info = {'echo':sys.argv[4]})
|
||||
backup.backupPath(sys.argv[2],sys.argv[3],echo_id)
|
||||
elif type == 'database':
|
||||
if sys.argv[2] == 'ALL':
|
||||
backup.backupDatabaseAll(sys.argv[3])
|
||||
backup.backupDatabaseAll(sys.argv[3],echo_id)
|
||||
else:
|
||||
backup.backupDatabase(sys.argv[2], sys.argv[3])
|
||||
|
||||
backup = backupTools(cron_info = {'echo':sys.argv[4]})
|
||||
backup.backupDatabase(sys.argv[2], sys.argv[3],echo_id)
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
#coding: utf-8
|
||||
import sys,os,time
|
||||
os.chdir('/www/server/panel/')
|
||||
sys.path.insert(0,"class/")
|
||||
import public
|
||||
import http_requests
|
||||
http_requests.DEFAULT_TYPE = 'src'
|
||||
os.environ['BT_TASK'] = '1'
|
||||
|
||||
import panelMessage
|
||||
import re
|
||||
msgObj = panelMessage.panelMessage()
|
||||
data = msgObj.get_messages()
|
||||
for x in data:
|
||||
if x['level'] in ['danger', 'error'] and not x['send'] and x['retry_num'] < 5:
|
||||
msg = '服务器IP【{}】: {}'.format(
|
||||
public.GetLocalIp(), re.sub(',?<a\s*.+</a>', '', x['msg']))
|
||||
is_send = False
|
||||
|
||||
ret = public.return_is_send_info()
|
||||
for key in ret:
|
||||
if ret[key]:
|
||||
ret = public.send_body_words(key, '宝塔消息提醒', msg)
|
||||
if ret:
|
||||
is_send = True
|
||||
pdata = {}
|
||||
if is_send:
|
||||
pdata['send'] = 1
|
||||
pdata['retry_num'] = 0
|
||||
else:
|
||||
pdata['send'] = 0
|
||||
pdata['retry_num'] = x['retry_num'] + 1
|
||||
|
||||
msgObj.set_send_status(x['id'], pdata)
|
||||
time.sleep(5)
|
||||
@@ -0,0 +1,25 @@
|
||||
import os, sys
|
||||
|
||||
os.chdir('/www/server/panel')
|
||||
sys.path.append('class/')
|
||||
import public
|
||||
|
||||
ftp_backup_path = public.get_backup_path() + '/pure-ftpd/'
|
||||
ftp_log_file = '/var/log/pure-ftpd.log'
|
||||
if not os.path.exists(ftp_backup_path):
|
||||
public.ExecShell('mkdir -p {}'.format(ftp_backup_path))
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
yesterday = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d")
|
||||
ftp_file = ftp_backup_path + yesterday + '_pure-ftpd.log'
|
||||
conf = ''
|
||||
if os.path.isfile(ftp_file):
|
||||
old_conf = public.readFile(ftp_file)
|
||||
conf += old_conf
|
||||
conf += '\n'
|
||||
new_conf = public.readFile(ftp_log_file)
|
||||
if new_conf: conf += new_conf
|
||||
public.writeFile(ftp_file, conf)
|
||||
public.writeFile(ftp_log_file, '')
|
||||
print('|pure-ftpd log cut completed')
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/www/server/panel/pyenv/bin/python
|
||||
#coding: utf-8
|
||||
import os,sys
|
||||
os.chdir("/www/server/panel")
|
||||
sys.path.insert(0,"class/")
|
||||
sys.path.insert(0,"/www/server/panel/")
|
||||
from projectModel.quotaModel import main
|
||||
p = main()
|
||||
p.mysql_quota_check()
|
||||
@@ -0,0 +1,114 @@
|
||||
#coding: utf-8
|
||||
# +-------------------------------------------------------------------
|
||||
# | 宝塔Linux面板
|
||||
# +-------------------------------------------------------------------
|
||||
# | Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
|
||||
# +-------------------------------------------------------------------
|
||||
# | Author: hwliang <hwl@bt.cn>
|
||||
# +-------------------------------------------------------------------
|
||||
|
||||
#--------------------------------
|
||||
# 修复polkit提权漏洞(CVE-2021-4034)
|
||||
#--------------------------------
|
||||
|
||||
import os,sys
|
||||
os.chdir("/www/server/panel")
|
||||
sys.path.insert(0,'class/')
|
||||
import public
|
||||
upgrade_log_file = '/www/server/panel/logs/upgrade_polkit.log'
|
||||
log_msg = "A polkit (CVE-2021-4034) privilege escalation vulnerability has been detected in the system and has been fixed for you!"
|
||||
|
||||
|
||||
def write_log(msg):
|
||||
global upgrade_log_file
|
||||
public.writeFile(upgrade_log_file,"[{}] - {}".format(public.format_date(),msg),'a+')
|
||||
|
||||
def is_yum():
|
||||
if os.path.exists('/usr/bin/yum'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_dnf():
|
||||
if os.path.exists('/usr/bin/dnf'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_apt():
|
||||
if os.path.exists('/usr/bin/apt'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def upgrade_by_yum():
|
||||
global upgrade_log_file,log_msg
|
||||
res = public.ExecShell("rpm -q polkit")[0]
|
||||
if res.startswith('polkit-'):
|
||||
os.system("yum -y update polkit &> {}".format(upgrade_log_file))
|
||||
res2 = public.ExecShell("rpm -q polkit")[0]
|
||||
if res == res2:
|
||||
write_log("Repair failed, please execute the command manually: yum -y update polkit")
|
||||
return False
|
||||
public.WriteLog('Vulnerability Repair',log_msg)
|
||||
return True
|
||||
return False
|
||||
|
||||
def upgrade_by_dnf():
|
||||
global upgrade_log_file,log_msg
|
||||
res = public.ExecShell("rpm -q polkit")[0]
|
||||
if res.startswith('polkit-'):
|
||||
os.system("dnf -y update polkit &> {}".format(upgrade_log_file))
|
||||
res2 = public.ExecShell("rpm -q polkit")[0]
|
||||
if res == res2:
|
||||
write_log("Repair failed, please execute the command manually: dnf -y update polkit")
|
||||
return False
|
||||
public.WriteLog('Vulnerability Repair',log_msg)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def upgrade_by_apt():
|
||||
global upgrade_log_file,log_msg
|
||||
res = public.ExecShell("dpkg -l policykit-1|grep policykit-1|awk '{print $3}'")[0]
|
||||
if res.startswith('0.105'):
|
||||
os.system("apt-get -y install policykit-1 &> {}".format(upgrade_log_file))
|
||||
res2 = public.ExecShell("dpkg -l policykit-1|grep policykit-1|awk '{print $3}'")[0]
|
||||
if res == res2:
|
||||
write_log("Repair failed, please execute the command manually: apt-get -y install policykit-1")
|
||||
return False
|
||||
public.WriteLog('Vulnerability Repair',log_msg)
|
||||
return True
|
||||
return False
|
||||
|
||||
def check():
|
||||
tip_file = '/www/server/panel/data/upgrade_polkit.pl'
|
||||
if os.path.exists(tip_file):
|
||||
return
|
||||
write_log("Fixing the privilege escalation vulnerability of polkit (CVE-2021-4034)...")
|
||||
if is_yum():
|
||||
upgrade_by_yum()
|
||||
elif is_dnf():
|
||||
upgrade_by_dnf()
|
||||
elif is_apt():
|
||||
upgrade_by_apt()
|
||||
else:
|
||||
return
|
||||
|
||||
public.writeFile(tip_file,'True')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tip_file = '/www/server/panel/data/upgrade_polkit_run.pl'
|
||||
if os.path.exists(tip_file):
|
||||
print("The program is running, exit!")
|
||||
sys.exit(1)
|
||||
|
||||
public.writeFile(tip_file,'True')
|
||||
try:
|
||||
check()
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
if os.path.exists(tip_file): os.remove(tip_file)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import sys
|
||||
import time
|
||||
import os
|
||||
import struct
|
||||
import base64
|
||||
base64.b64encode
|
||||
|
||||
os.chdir('/www/server/panel')
|
||||
if 'class/' in sys.path: sys.path.insert(0,"class/")
|
||||
@@ -18,18 +20,38 @@ import copy
|
||||
try:
|
||||
import pcap
|
||||
except ImportError:
|
||||
if os.path.exists('/usr/bin/apt'):
|
||||
os.system("apt install libpcap-dev")
|
||||
elif os.path.exists('/usr/bin/dnf'):
|
||||
os.system("dnf install libpcap-devel")
|
||||
elif os.path.exists('/usr/bin/yum'):
|
||||
os.system("yum install libpcap-devel")
|
||||
os.system("btpip install pypcap")
|
||||
try:
|
||||
import pcap
|
||||
except ImportError:
|
||||
print("pypcap module install failed.")
|
||||
sys.exit()
|
||||
# 标记只安装一次
|
||||
tip_file = '/www/server/panel/install/tip.json'
|
||||
if not os.path.exists(tip_file):
|
||||
if os.path.exists('/usr/bin/apt'):
|
||||
os.system("apt install libpcap-dev -y")
|
||||
elif os.path.exists('/usr/bin/dnf'):
|
||||
red_file = '/etc/redhat-release'
|
||||
if os.path.exists(red_file):
|
||||
f = open(red_file,'r')
|
||||
red_body = f.read()
|
||||
f.close()
|
||||
if red_body.find('CentOS Linux release 8.') != -1:
|
||||
rpm_file = '/root/libpcap-1.9.1.rpm'
|
||||
down_url = "wget -O {} https://node.aapanel.com/src/libpcap-devel-1.9.1-5.el8.x86_64.rpm --no-check-certificate -T 10".format(rpm_file)
|
||||
if os.path.exists(rpm_file):
|
||||
os.system(down_url)
|
||||
os.system("rpm -ivh {}".format(rpm_file))
|
||||
if os.path.exists(rpm_file): os.remove(rpm_file)
|
||||
else:
|
||||
os.system("dnf install libpcap-devel -y")
|
||||
else:
|
||||
os.system("dnf install libpcap-devel -y")
|
||||
elif os.path.exists('/usr/bin/yum'):
|
||||
os.system("yum install libpcap-devel -y")
|
||||
os.system("btpip install pypcap")
|
||||
# 写入标记文件
|
||||
os.system("echo True > {}".format(tip_file))
|
||||
try:
|
||||
import pcap
|
||||
except ImportError:
|
||||
print("pypcap module install failed.")
|
||||
sys.exit()
|
||||
|
||||
|
||||
class process_network_total:
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#coding: utf-8
|
||||
import sys,os,time
|
||||
os.chdir('/www/server/panel/')
|
||||
sys.path.insert(0,"class/")
|
||||
import public
|
||||
import http_requests
|
||||
http_requests.DEFAULT_TYPE = 'src'
|
||||
os.environ['BT_TASK'] = '1'
|
||||
|
||||
try:
|
||||
import panelPush
|
||||
import threading
|
||||
push = panelPush.panelPush()
|
||||
push.start()
|
||||
# os.system("echo yes,{} > /tmp/push.pl".format(time.time()))
|
||||
except Exception as e:
|
||||
pass
|
||||
# print("开启推送消息进程异常。")
|
||||
os.system("echo no,{},{} > /tmp/push.pl".format(time.time(),e))
|
||||
@@ -0,0 +1,26 @@
|
||||
#coding: utf-8
|
||||
import os,sys,time
|
||||
os.chdir('/www/server/panel/')
|
||||
sys.path.insert(0,"class/")
|
||||
import public
|
||||
import log_analysis
|
||||
la = log_analysis.log_analysis()
|
||||
site_infos = public.M('sites').field('name').select()
|
||||
if not site_infos:
|
||||
exit()
|
||||
get = public.to_dict_obj({})
|
||||
for i in site_infos:
|
||||
if public.get_webserver() == 'nginx':
|
||||
log_file = '{}.log'
|
||||
elif public.get_webserver() == 'apache':
|
||||
log_file = '{}-access_log'
|
||||
else:
|
||||
log_file = '{}_ols.access_log'
|
||||
log_file = log_file.format(i['name'])
|
||||
get.path = "/www/wwwlogs/{}".format(log_file)
|
||||
get.action = "log_analysis"
|
||||
print('==================================================================')
|
||||
print('|-Analyzing [{}] website logs...'.format(i['name']))
|
||||
la.log_analysis(get)
|
||||
print('|-Analysis of website logs completed')
|
||||
print('==================================================================')
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
is_flask1=$(/www/server/panel/pyenv/bin/pip3 list|grep 'Flask'|grep ' 1.')
|
||||
if [ "${is_flask1}" = "" ];then
|
||||
exit;
|
||||
fi
|
||||
|
||||
/www/server/panel/pyenv/bin/pip3 install flask -U
|
||||
/www/server/panel/pyenv/bin/pip3 install flask-sock
|
||||
/www/server/panel/pyenv/bin/pip3 install simple-websocket==0.10.0 -I
|
||||
|
||||
rm -f /www/server/panel/script/upgrade_flask.sh
|
||||
bash /www/server/panel/init.sh reload
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
check_gevent_version(){
|
||||
is_gevent140=$(/www/server/panel/pyenv/bin/pip3 list|grep 'gevent'|grep ' 1.4.0')
|
||||
}
|
||||
|
||||
check_gevent_version
|
||||
if [ "${is_gevent140}" = "" ];then
|
||||
exit;
|
||||
fi
|
||||
|
||||
/www/server/panel/pyenv/bin/pip3 install gevent -U
|
||||
|
||||
check_gevent_version
|
||||
if [ "${is_gevent140}" = "" ];then
|
||||
rm -f /www/server/panel/script/upgrade_gevent.sh
|
||||
bash /www/server/panel/init.sh reload
|
||||
fi
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
is_flask1=$(/www/server/panel/pyenv/bin/pip3 list|grep 'telegram'|grep '0.0.1')
|
||||
if [ "${is_flask1}" != "" ];then
|
||||
echo "Y" | /www/server/panel/pyenv/bin/pip3 uninstall telegram
|
||||
fi
|
||||
|
||||
is_flask2=$(/www/server/panel/pyenv/bin/pip3 list|grep 'python-telegram-bot'|grep '20.3' )
|
||||
if [ "${is_flask2}" = "" ];then
|
||||
/www/server/panel/pyenv/bin/pip3 install python-telegram-bot==20.3 -I
|
||||
else
|
||||
exit;
|
||||
fi
|
||||
|
||||
rm -f /www/server/panel/script/upgrade_telegram.sh
|
||||
bash /www/server/panel/init.sh reload
|
||||
@@ -0,0 +1,8 @@
|
||||
#coding: utf-8
|
||||
import os,sys
|
||||
os.chdir('/www/server/panel')
|
||||
sys.path.insert(0,'class/')
|
||||
import panelWarning,public,json
|
||||
args = public.dict_obj()
|
||||
result = panelWarning.panelWarning().get_list(args)
|
||||
print(json.dumps(result))
|
||||
Reference in New Issue
Block a user