Results 1 to 1 of 1
Hello all!
I have had reports that the bellow script removed bash from their servers. I can not find how that could be possible.
Please take a look:
Code:
#!/bin/bash
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-15-2006 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 1
Script deleting bash
Hello all!
I have had reports that the bellow script removed bash from their servers. I can not find how that could be possible.
Please take a look:
The script works great fo me.Code:#!/bin/bash ### HttpdCleanUp 4.0 ## ip='123.45.678.9' #This is your server's main IP address cmts='1' #Set to '1' will remove all comment lines ####### DO NOT CHANGE ANYTHING BELOW THIS LINE ####### clear echo echo HttpdCleanUp 4.0 echo echo echo -n "Backing up httpd.conf" ct='0' max='5' while [ $ct != $max ]; do ct=`expr $ct + 1` echo -n "." sleep 1 done echo date=`date +%b%d` cd /usr/local/apache/conf cat httpd.conf > httpd.conf.$date echo echo -n "Processing httpd.conf" ct='0' max='5' while [ $ct != $max ]; do ct=`expr $ct + 1` echo -n "." sleep 1 done echo grep "$ip" httpd.conf > IpCheck if [ ! -s IpCheck ]; then echo echo "Main IP not found. Please set the ip variable in the script..." echo echo "Exiting......." echo exit fi bp=`awk 'END { print NR }' httpd.conf` if [ $cmts = '1' ]; then grep -v '^#' httpd.conf > httpd.g sleep 1 grep -v '^ #' httpd.g > httpd.h sleep 1 cat httpd.h > httpd.conf fi cat httpd.conf | grep "NameVirtualHost" | grep -v "#" | sort | uniq > httpd.a cat httpd.a | awk '{print $2}' > httpd.d replace -s ':80' '' -- httpd.d for cl in `cat httpd.d`; do grep "$cl" httpd.conf > httpd.e ct=`awk 'END { print NR }' httpd.e` if [ $ct = '1' ]; then grep -v "$cl" httpd.a > httpd.f cat httpd.f > httpd.a fi done replace -s ' ' 'XTX' -- httpd.a NVH=`cat httpd.a` sed '/NameVirtualHost/ d' <httpd.conf> httpd.b L1=`cat -n httpd.b | grep "<VirtualHost $ip" | head -n1 | awk '{print $1}'` L1=`expr $L1 - 2` a='a\' for line in $NVH; do sc=`echo $L1$a$line` sed $sc httpd.b > httpd.c cat httpd.c > httpd.b L1=`expr $L1 + 1` done x='XVX' sc=`echo $L1$a$x` sed -i $sc httpd.b replace -s 'XTX' ' ' -- httpd.b replace -s 'XVX' '' -- httpd.b cat httpd.b > httpd.conf bc=`ls -l httpd.conf | awk '{print $5}'` cat httpd.conf > httpd.i sleep 2 cat httpd.i| sed '{/^$/N;/\n$/D}' > httpd.conf ac=`ls -l httpd.conf | awk '{print $5}'` ap=`awk 'END { print NR }' httpd.conf` pp=`expr $bp - $ap` if [ $ac -lt $bc ]; then siz=`expr $bc - $ac` echo echo File is now $siz bytes smaller in size echo echo There were $pp lines removed echo echo Done... Restarting Apache....... echo else echo echo No cleanup needed at this time... echo echo Restarting Apache just because I touched it....... echo fi chmod 644 httpd.conf (/scripts/restartsrv_httpd) echo echo All done... You should make sure all is well....... echo echo Backup file is /usr/local/apache/conf/httpd.conf.$date echo test -e httpd.a && rm -rf httpd.a test -e httpd.b && rm -rf httpd.b test -e httpd.c && rm -rf httpd.c test -e httpd.d && rm -rf httpd.d test -e httpd.e && rm -rf httpd.e test -e httpd.f && rm -rf httpd.f test -e httpd.g && rm -rf httpd.g test -e httpd.h && rm -rf httpd.h test -e httpd.i && rm -rf httpd.i test -e IpCheck && rm -rf IpCheck exit


Reply With Quote
