中间人攻击.

一重装,写自动化脚本

1.#vim expectd :

#!/usr/bin/expect 

spawn mysqladmin -uroot -p password "onno799967"
expect "Enter password:"
send "onno799967\r"

interact

#chmod a+x expectd

2.vim lamp.sh:

#!/usr/bin/env bash
yum -y install httpd mariadb-server mariadb php php-mysql php-gd gd
yum -y install expect
if [ $? == 0 ];  then


        echo "$date1-----yum install packages IS OK." >> /opt/lamp.log




else
        echo "$date1-----yum install packages IS NOT OK." >> /opt/lamp.log
fi


date2=`date`


systemctl start httpd mariadb
systemctl enable httpd mariadb
if [ $? == 0 ];  then
        echo "$date2-----启动服务成功." >> /opt/lamp.log
else
        echo "$date2-----启动服务失败" >> /opt/lamp.log
fi
echo "<?php phpinfo()?>" > /var/www/html/index.php
expect /root/expectd
cat <<-EOF >/var/www/html/index.php
<?php
\$link=mysql_connect("localhost","root","onno799967"); 
if(!link)
        echo "this connect is false";
else
        echo "this connect is true";
?>
EOF

systemctl restart httpd mariadbwget -O  /root/wordpress-4.9.4-zh_CN.tar.gz  https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz

tar xf /root/wordpress-4.9.4-zh_CN.tar.gz -C /root/

mv /root/wordpress/wp-config-sample.php /root/wordpress/wp-config.php
mysql -uroot  -p"onno799967" -e "create database wordpress;"
sed -i s/username_here/root/g /root/wordpress/wp-config.php
sed -i s/database_name_here/wordpress/g /root/wordpress/wp-config.php
sed -i s/password_here/onno799967/g /root/wordpress/wp-config.php
rm -rf /var/www/html/*
cp -rf /root/wordpress/* /var/www/html/
systemctl restart httpd mariadb



猜你喜欢

转载自blog.csdn.net/weixin_42594318/article/details/81002878
今日推荐