请教一下大佬Linux服务器一键搭建游戏的shell 脚本制作思路
本帖最后由 小吉 于 2022-8-8 03:07 编辑例如这种:wget http://ja.wchunh.top/sh/xmqy/xmqy.sh && chmod +x xmqy.sh
菜鸟一枚,如果想的不专业 轻点喷{:4_181:}
看命令结构是把源代码托管到了自己的服务器上,下载的是 .sh 的执行脚本文件,并给了权限 同时执行这个脚本。
我查看了一下xmqy.sh这个文件,是属于二进制代码,以为是经过加密的shell命令,git 了几个shell 解密的程序尝试解密,发现不属于加密文件。
然后尝试了ilspy hex 等软件查看执行过程,发现还是看不懂,找不到正确的编译工具,学习不了xmqy.sh这个文件的执行过程和思路。
这个脚本至少包含了以下几个部分:
1、下载游戏代码到根目录并解压;
2、获取本服务器的ip 地址并制定文件替换;
3、检测环境,没有的执行安装;
4、我看也安装了宝塔面板,所以相对应的nginx php mysql 等软件应该也一并安装过了,但是例如一般在面板上操作的创建网页设置端口和路径,设置数据库密码,PHP可能需要的其他扩展,这些操作对应的执行代码是怎么写的;
5、下载了客户端,并进行了反编译、修改指定内容,在进行签名和封装的;
6、所有代码执行完毕后提示了宝塔面板信息,客户端下载的连接地址;
自动化到这种程度是本人非常膜拜的,不知道有没有大佬能给一份不属于汇编语言的 可读的shell 脚本学习一下{:4_181:} 本帖最后由 小吉 于 2022-8-8 03:11 编辑
也许你可以这样理解?鼓励学习但不支持破解脚本盗版,但我还是给你提供一段脚本,如下,另外如果你通过本站分享的资源或者教程完成了自己的作品,那希望在外放时加上本站的友链
#!/bin/bash
function shellhead() {
finishlogo='
============================================================
偏爱技术论坛(小吉)
一生要走多远的路程,经过多少年才能走到终点。梦想需要多少时间才能慢慢实现。只要肯期待希望就不会幻灭。
============================================================';
fwip=`curl -s http://www.paijishu.com/sh/ip.php`;
gg=`curl -s http://www.paijishu.com/sh/gg.txt`;
cw=`curl -s http://www.paijishu.com/sh/sh/cw.txt`;
yzcw=`curl -s http://www.paijishu.com/sh/sh/yzcw.txt`;
gg1=`curl -s http://www.paijishu.com/sh/gg1.txt`;
wget -P /root/ip http://www.paijishu.com/sh/cxip.php
IP=`grep -o '\{1,3\}\.\{1,3\}\.\{1,3\}\.\{1,3\}' /root/ip/cxip.php`;
IPIP=`ifconfig -a|grep -o -e 'inet \{1,3\}.\{1,3\}.\{1,3\}.\{1,3\}'|grep -v "127.0.0"|awk '{print $2}'`;
yz=`curl -s http://www.paijishu.com/sh/yz.txt`;
return 1
}
#设置信息
function w01() {
clear
echo -e '\033[33m================☆☆========================================================\033[0m'
echo -e '\033[33m'${gg1}'\033[0m'
echo -e '\033[36m '${gg}'\033[0m'
echo -e '\033[33m================☆☆========================================================\033[0m'
echo
echo -e "\033[33m即将搭建 xx游戏,请认真阅读以上信息。回车键继续。。。\033[0m"
read
return 1
}
function jc()
{
bbgx=`curl -s http://www.paijishu.com/sh/lhqy/bbgx.txt`;
if [ "${bbgx}" != 1 ];then
echo -n -e "此处为账号验证段,可自行去除"
read yz
yzyz=`curl -s http://www.paijishu.com/sh/sh/api.php?bbb=1177\&use=$yz`;
if [ "${yzyz}" != 1 ];then
echo -e '\033[33m'${yzcw}'\033[0m'
read
jc
fi
fi
#检查目录
curl -s http://www.paijishu.com/sh/sh/tj/cdks.php?use=$yz
if [ -d "/www/wwwroot" ];then
echo -e "\033[31m偏爱AI智能系统:报错代码01\033[0m"
echo -e "\033[33m一般出现此错误是因为安装有 宝塔 请先给服务器重装系统再搭建\033[0m"
echo -e "\033[33m如想继续安装回车键即可(有可能出问题)\033[0m"
read
fi
##
clear
return 1
}
function szip() {
clear
echo '=============================================='
echo -e "\033[33m 选择输入IP模式。\033[0m"
echo '1 自动检测(推荐)'
echo '2 手动输入'
read -p '请选择点(输入1或2): ' aip;
case "${aip}" in
'1')
IP=`grep -o '\{1,3\}\.\{1,3\}\.\{1,3\}\.\{1,3\}' /root/ip/cxip.php`;
IP2=`grep -o '\{1,3\}\.\{1,3\}\.\{1,3\}\.\{1,3\}' /root/ip/cxip.php`;
rm -rf /root/ip/s.txt
echo ${IP}>>/root/ip/s.txt
cd /root/ip
wss=`awk -F "" '{print NF}' s.txt`
#echo "系统检测到的IP为:"$IP" 位数"$wss",如不正确请立即停止安装,回车继续:"
echo "系统检测到的IP为:"$IP" ,如不正确请立即停止安装,回车继续:"
read
;;
'2')
echo
echo -e '\033[36m提示:输入错误请按 Ctrl键 + 退格键 进行删除\033[0m';
echo -n -e "输入你服务器IP或域名((15位数以内):"
read IP2
if [[ -z $IP2 ]]
then
IP=乱输入进不去游戏
echo -e '[\033';
else
echo -e "[\033";
fi
rm -rf /root/ip/s.txt
echo ${IP2}>>/root/ip/s.txt
cd /root/ip
wss=`awk -F "" '{print NF}' s.txt`
echo "你设置IP或域名为:"$IP2" 位数 "$wss" 如不正确请立即停止安装,回车继续:"
read
;;
*)
szip
;;
esac
echo
case "${wss}" in
'6')
wsss='/////////'
;;
'7')
wsss='////////'
;;
'8')
wsss='///////'
;;
'9')
wsss='//////'
;;
'10')
wsss='/////'
;;
'11')
wsss='////'
;;
'12')
wsss='///'
;;
'13')
wsss='//'
;;
'14')
wsss='/'
;;
'15')
wsss=''
;;
esac
return 1
}
function logo() {
clear
echo '=============================================='
echo -e "\033[33m 选择服务端和APP自动下载节点。\033[0m"
echo -e "\033[33m 正常情况请选择 1 即可,如果出问题再用2。\033[0m"
echo '1 主线'
echo '2 备用'
#echo '3 '
read -p '请选择下载节点(输入1或2): ' aa;
case "${aa}" in
'1')
host=`curl -s http://www.paijishu.com/sh/host.txt`
echo -e "\033[33m 你当前选择了主线节点\033[0m"
;;
'2')
host=`curl -s http://www.paijishu.com/sh/host2.txt`
echo -e "\033[33m 你当前选择了备用节点\033[0m"
;;
'3')
host=`curl -s http://www.paijishu.com/sh/host.txt`
;;
*)
host=`curl -s http://www.paijishu.com/sh/host.txt`
echo -e "\033[33m 不知道你乱输入什么,当前主线节点\033[0m"
;;
esac
return 1
}
function w001() {
echo -e '\033[36m提示:输入错误请按 Ctrl键 + 退格键 进行删除\033[0m';
echo -e '\033[33m如不会设置请直接回车即可!\033[0m';
echo
echo -n -e "设置GM验证码(回车默认paijishu.com):"
read gmmm
if [[ -z $gmmm ]]
then
gmmm=paijishu.com
echo -e '[\033';
else
echo -e "[\033";
fi
echo
echo
echo "信息收录完成,脚本将自动完成后续安装工作"
echo
echo -n -e '\033[34m请按下回车键开始自动安装...\033[0m'
read
return 1
}
#创建swap虚拟内存
function w02() {
fallocate -l 4048M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
#修改当内存剩余30%时开始使用swap交换空间.
echo "vm.swappiness = 30" >> /etc/sysctl.conf
sysctl -p
return 1
}
#lnmp环境环境
function w03() {
wget -O install.sh http://www.paijishu.com/sh/bt/bt2.sh && bash install.sh
sleep 3
cd /www/server/panel/install
bash install_soft.sh 1 install nginx 1.18
bash install_soft.sh 1 install mysql 5.7
bash install_soft.sh 1 install php 7.3
bash install_soft.sh 0 install memcached
bash install_soft.sh 0 install supervisor
bash install_soft.sh 3 install memcache 73
bash install_soft.sh 3 install memcached 73
#bash install_soft.sh 0 install phpmyadmin 4.4
cd /www/server/panel && python tools.py root 123456
sed -i 's#,putenv,#,#g' /www/server/php/73/etc/php.ini
sed -i 's#,proc_open,#,#g' /www/server/php/73/etc/php.ini
sed -i 's#,pcntl_alarm,#,#g' /www/server/php/73/etc/php.ini
sed -i 's#,pcntl_signal,#,#g' /www/server/php/73/etc/php.ini
sleep 3
/etc/init.d/php-fpm-73 restart
return 1
}
#服务端下载安装修改
function w04() {
cd /
wget ${host}/lhqy/lhqy.zip
if [ ! -s lhqy.zip ]||[ ! -f lhqy.zip ];then
echo -e "\033[31m警告!文件下载失败,等待6秒钟重新下载。\033[0m"
sleep 6
wget ${host}/lhqy/lhqy.zip
fi
if [ ! -s lhqy.zip ]||[ ! -f lhqy.zip ];then
echo -e "\033[33m非常抱歉!下载还是失败,建议你重装系统再搭建用 备用线路\033[0m"
echo -e "\033[33m有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
fi
unzip -o lhqy.zip
sleep 3
chmod -R 777 /opt
chmod -R 777 /data
rm -rf lhqy.zip
cd /usr/bin
wget -O paijishu.com http://www.paijishu.com/sh/lhqy/paijishu.com2
chmod -R 777 /usr/bin/paijishu.com
cd /www/server/panel/vhost
wget http://www.paijishu.com/sh/lhqy/vhost.zip
unzip -o vhost.zip
#sudo sed -i 's#81#'$szdk'#g' /www/server/panel/vhost/nginx/127.0.0.1.conf
sudo sed -i 's#106.55.158.130#'$IP2'#g' /www/server/panel/vhost/nginx/106.55.158.130.conf
/etc/init.d/nginx restart
sleep 3
cd /data
sed -i 's#66.66.66.66#'$IP2'#g' /data/admin/public/ht/user/config.php
sed -i 's#66.66.66.66#'$IP2'#g' /data/admin/storage/app/hosts/baize/server.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/admin/storage/app/hosts/cross.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/admin/storage/app/hosts/machine.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/center/s9900001/etc/sys.config
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/hosts/baize/server.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/hosts/center.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/hosts/cross.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/hosts/machine.hosts
sed -i 's#66.66.66.66#'$IP2'#g' /data/qylh/baize/server/s1000001/etc/sys.config
sed -i 's#106.55.158.130#'$IP2'#g' /data/sql/xw_admin.sql
sed -i 's#106.55.158.130#'$IP2'#g' /data/sql/xw_logs.sql
sed -i 's#66.66.66.66#'$IP2'#g' /data/admin/public/ht/user/config.php
sed -i 's#10.0.4.16#'$IPIP'#g' /data/admin/storage/app/hosts/baize/server.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/admin/storage/app/hosts/center.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/admin/storage/app/hosts/cross.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/center/s9900001/etc/sys.config
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/cross/s1/etc/sys.config
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/server/s1000001/etc/sys.config
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/server/s1000001/etc/sys.config.src
sed -i 's#10.0.8.17#'$IPIP'#g' /data/sql/xw_admin.sql
sed -i 's#10.0.4.16#'$IPIP'#g' /data/admin/public/ht/user/config.php
sed -i 's#10.0.4.16#'$IPIP'#g' /data/admin/storage/app/hosts/machine.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/hosts/baize/server.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/hosts/center.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/hosts/cross.hosts
sed -i 's#10.0.4.16#'$IPIP'#g' /data/qylh/baize/hosts/machine.hosts
sed -i 's#10.0.8.17#'$IPIP'#g' /data/sql/xw_logs.sql
sed -i 's#paijishu.com#'$gmmm'#g' /data/admin/public/ht/user/config.php
return 1
}
#设置数据库
function w05() {
mysql -uroot -p123456 << EOF
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
EOF
sleep 3
#创建数据库
cd /data
./sk
return 1
}
#启动游戏
function w07() {
cd /root
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-develunixODBC unixODBC-devel
cd /opt
tar xvf otp_src_21.2.tar.gz
cd otp_src_21.2
sleep 3
./configure --prefix=/usr/local/erlang --without-javac
sleep 3
make & make install
sleep 3
echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
sleep 2
source /etc/profile
sleep 2
ln -s /usr/local/erlang/bin/erl /usr/bin/erl
sleep 2
yum -y install epel-release
yum -y install socat
sleep 2
cd /opt
xz -d rabbitmq-server-generic-unix-3.7.10.tar.xz
tar -xvf rabbitmq-server-generic-unix-3.7.10.tar
sleep 2
echo 'export PATH=$PATH:/opt/rabbitmq_server-3.7.10/sbin' >> /etc/profile
sleep 2
source /etc/profile
sleep 2
mkdir /etc/rabbitmq
cd /opt/rabbitmq_server-3.7.10/sbin
./rabbitmq-server -detached
sleep 2
./rabbitmq-plugins enable rabbitmq_management
sleep 2
rabbitmqctl add_user xw_admin 6oU^4q9zI64u
rabbitmqctl set_user_tags xw_admin administrator
rabbitmqctl add_vhost xw_qylh
sleep 2
rabbitmqctl delete_user guest
sleep 2
rabbitmqctl set_permissions -p xw_qylh xw_admin ".*" ".*" ".*"
sleep 2
yum install crontab
sleep 2
systemctl enable crond
systemctl start crond
sleep 2
echo '* * * * * /usr/bin/php /data/admin/artisan schedule:run >> /dev/null 2>&1'>>/etc/crontab
sleep 2
crontab /etc/crontab
return 1
}
function app(){
yum install -y java
echo"开始制作APP"
echo "下载APK包"
cd /home
wget ${host}/gj/tool.zip
if [ ! -f tool.zip ]; then
echo -e "\033[31m警告!文件下载失败,等待6秒钟重新下载。\033[0m"
sleep 6
wget ${host}/gj/tool.zip
fi
if [ ! -f tool.zip ]; then
echo -e "\033[33m非常抱歉!下载还是失败,建议你重装系统再搭建用 备用线路\033[0m"
echo -e "\033[33m有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
fi
unzip -o tool.zip >/dev/null 2>&1
cd /home/tool
echo "下载APK包"
wget -O app.apk ${host}/lhqy/lhqy.apk
if [ ! -f app.apk ]; then
echo -e "\033[31m警告!文件下载失败,等待6秒钟重新下载。\033[0m"
sleep 6
wget -O app.apk ${host}/lhqy/lhqy.apk
fi
if [ ! -f app.apk ]; then
echo -e "\033[33m非常抱歉!下载还是失败,建议你重装系统再搭建用 备用线路\033[0m"
echo -e "\033[33m有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
fi
echo"开始反编译APP"
java -jar apktool.jar d -f app.apk -o /home/app -p /home/tool/framework
echo "批量替换"
sleep 2
sed -i 's#仙梦#'$appmz'#g' /home/app/res/values/strings.xml
sed -i 's#106.52.66.208#'$IP2'#g' /home/app/res/values/strings.xml
sed -i 's#106.52.66.208#'${IP2}'#g' /home/app/assets/config/local_version.xml
sed -i 's#106.52.66.208#'${IP2}'#g' /home/app/assets/config/all_platform_config.xml
sleep 2
echo"开始回编译APP"
cd /home/tool
java -jar apktool.jar b -f /home/app -o /home/app.apk -p /home/tool/framework
echo "APK生成完毕"
cd /home/tool
echo "正在签名APK....文件比较大这里可能会卡一下"
java -jar apksigner.jar -keystore debug.keystore -alias androiddebugkey -pswd android -aliaspswd android /home/app.apk >/dev/null 2>&1
mv /home/app.apk /www/wwwroot/paijishu.com/lhqy.apk
echo "正在清理临时文件...."
rm -rf /home/tool.zip
rm -rf /home/tool/app.apk
#rm -rf /home/app
return 1
}
function app2(){
cd /root
yum install -y java
echo"开始制作APP"
echo "下载APK包"
cd /home
wget ${host}/gj/tool.zip
if [ ! -f tool.zip ]; then
echo -e "\033[31m警告!文件下载失败,等待6秒钟重新下载。\033[0m"
sleep 6
wget ${host}/gj/tool.zip
fi
if [ ! -f tool.zip ]; then
echo -e "\033[33m非常抱歉!下载还是失败,建议你重装系统再搭建用 备用线路\033[0m"
echo -e "\033[33m有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
fi
unzip -o tool.zip >/dev/null 2>&1
cd /home/tool
echo "下载APK包"
wget -O app.apk ${host}/lhqy/lhqy.apk
if [ ! -s app.apk ]||[ ! -f app.apk ];then
echo -e "\033[31m警告!文件下载失败,等待6秒钟重新下载。\033[0m"
sleep 6
wget -O app.apk ${host}/lhqy/lhqy.apk
fi
if [ ! -s app.apk ]||[ ! -f app.apk ];then
echo -e "\033[33m非常抱歉!下载还是失败,建议你重装系统再搭建用 备用线路\033[0m"
echo -e "\033[33m有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
fi
##
case "${wss}" in
'6')
echo -e "\033[33m IP位数有问题 有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
;;
'7')
echo -e "\033[33m IP位数有问题 有疑问联系我:偏爱技术论坛小吉\033[0m"
exit
;;
'8')
mv '/assets/8' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'9')
mv '/assets/9' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.6#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'10')
mv '/assets/10' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.66#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'11')
mv '/assets/11' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.666#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'12')
mv '/assets/12' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.666.#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'13')
mv '/assets/13' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.666.6#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'14')
mv '/assets/14' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.666.66#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
'15')
mv '/assets/15' '/assets/lua/lua_game_config_auto.luac'
sleep 2
sed -i 's#666.666.666.666#'$IP2'#g' '/assets/lua/lua_game_config_auto.luac'
;;
esac
##
echo "稍等片刻"
zip -u '/home/tool/app.apk' '/assets/lua/lua_game_config_auto.luac'
sleep 2
cd /home/tool
echo "正在签名APK....文件比较大这里可能会卡一下"
java -jar apksigner.jar -keystore debug.keystore -alias androiddebugkey -pswd android -aliaspswd android /home/tool/app.apk >/dev/null 2>&1
mv /home/tool/app.apk /data/admin/public/lhqy.apk
echo "正在清理临时文件...."
rm -rf /home/tool.zip
rm -rf /home/tool/app.apk
rm -rf /home/lighthouse
return 1
}
#初始信息
function w08() {
echo "================☆☆=================================================
安装完成,等两分钟再进游戏。
数据库账号:root本地密码123456 xxx可开远程
安卓app:http://${IP2}/lhqy.apk
授权后台:http://${IP2}/ht/gm.php
GM码:${gmmm}
运营后台地址:http://${IP2}/admin
账号 admin 密码 123456(登录后可改密码)
RabbitMQ:http://${IP2}:15672 (不用管)
账号 xw_admin 密码6oU^4q9zI64u
注意!看里面说明不然进不去游戏https://www.paijishu.com/1177.html
注意!看里面说明不然进不去游戏https://www.paijishu.com/1177.html
游戏控制台命令:xxx
================☆☆=================================================
本资源收集于网络,共享只用于交流学习
请勿用作它途。如有侵权,请联系删除处理。
${gg}
================☆☆=================================================">>/root/info.txt
clear
echo 游戏控制台命令:xxx >> /etc/motd
systemctl stop firewalld.service
systemctl disable firewalld.service
info=`cat /root/info.txt`
echo "!"
echo -e "\033[33m${info}\033[0m"
exit;0
}
#开始
shellhead
#设置信息
w01
jc
szip
logo
w001
#创建swap虚拟内存
w02
#lnmp环境
w03
#服务端下载安装修改
w04
#设置数据库数据
w05
app2
#启动游戏
w07
#初始信息
w08
啊!这~~~简直。。。连游戏名都匹配上了{:4_200:}
非常感谢大佬,这么晚还在审帖,辛苦了
页:
[1]