ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i'm making a new second shell script called shell scanner
for detecting encoded shells ,
the script depends on a list of file names
that i want to execlude from the output of the script ,
but i found that the excluded file names appears in the output
here is my script (sorry for my poor shell scripting knowledge) :
#!/bin/bash
echo "ShellScan is started ..!"
find /home/*/public_html -name "*.php" -exec egrep -ri -l "@Zend|ionCube Loader|base64_decode" {} \; >> detected.txt
cat detected.txt | sed "s/.*\///" >> tocompare.txt
echo "Shell Scan will give you the report, please wait"
for i in `cat tocompare.txt`
do
if [$i = functions.php]
then
sed -i 1d detected.txt
elif [$i = attachment.php]
then
sed -i 1d detected.txt
elif [$i = cron.php]
then
sed -i 1d detected.txt
elif [$i = ads.php]
then
sed -i 1d detected.txt
elif [$i = gifimg.php]
then
sed -i 1d detected.txt
elif [$i = browse.php]
then
sed -i 1d detected.txt
elif [$i = config.php]
then
sed -i 1d detected.txt
elif [$i = wp-app.php]
then
sed -i 1d detected.txt
elif [$i = class-simplepie.php]
then
sed -i 1d detected.txt
elif [$i = class-IXR.php]
then
sed -i 1d detected.txt
elif [$i = gysn-kg.php]
then
sed -i 1d detected.txt
elif [$i = xmlrpc.php]
then
sed -i 1d detected.txt
elif [$i = ticketfunctions.php]
then
sed -i 1d detected.txt
elif [$i = pipefunctions.php]
then
sed -i 1d detected.txt
elif [$i = pipe.php]
then
sed -i 1d detected.txt
elif [$i = protxvspform.php]
then
sed -i 1d detected.txt
elif [$i = googleresponse.php]
then
sed -i 1d detected.txt
elif [$i = index.php]
then
sed -i 1d detected.txt
elif [$i = thumb.php]
then
sed -i 1d detected.txt
else
echo "Suspeciuos file detected :"
echo `head -n 1 detected.txt`
echo "Please check it urgently"
head -n 1 detected.txt >> found.txt
sed -i 1d detected.txt
fi
done
after this script is run ,
i found that the file names that i want to exclude (ex, index.php)
#!/bin/bash
echo "ShellScan is started ..!"
nice -n -20 find /home/*/public_html -name "*.php" -exec egrep -ri -l "@Zend|ionCube Loader|base64_decode" {} \; >> detected.txt
cat detected.txt | sed "s/.*\///" >> tocompare.txt
echo "Shell Scan will give you the report, please wait"
file[1]="functions.php"
file[2]="attachment.php"
file[3]="cron.php"
file[4]="ads.php"
file[5]="gifimg.php"
file[6]="browse.php"
file[7]="config.php"
file[8]="wp-app.php"
file[9]="class-simplepie.php"
file[10]="class-IXR.php"
file[11]="gysn-kg.php"
file[12]="xmlrpc.php"
file[13]="ticketfunctions.php"
file[14]="pipefunctions.php"
file[15]="pipe.php"
file[16]="protxvspform.php"
file[17]="googleresponse.php"
file[18]="index.php"
file[19]="thumb.php"
for i in `cat tocompare.txt`
do
found=1
for (j=1;j<20;++j)
do
if [ $i = $file[j] ]
then
echo $i equal $file[j]
sed -i 1d detected.txt
found=0
fi
break
done
if [ $found -eq 1 ]
then
head -n 1 detected.txt >> found.txt
sed -i 1d detected.txt
break
fi
done
Again, be aware that this is untested code.
Note: The code I suggested above only deletes the temporary files created by the program.
Last edited by PTrenholme; 06-14-2010 at 06:20 PM.
#!/bin/bash
echo "ShellScan is started ..!"
file=({functions,attachment,cron,ads,gifimg,browse,config,wp-app,class-simplepie,class-IXR,\
gysn-kg,xmlrpc,ticketfunctions,pipefunctions,pipe,protxvspform,googleresponse,index,thumb}.php)
find /home/*/public_html -name "*.php" -exec \
bash -c 'egrep -lir "@Zend|ionCube Loader|base64_decode" $1 | sed "s/.*\///"' _ {} \; > tocompare
echo "Shell Scan will give you the report, please wait"
while read i; do
for (( j=0 ; j < ${#file[@]} ; j++ )); do
if [ "${file[j]}" = "$i" ]; then
echo "$i" | tee -a found.txt
fi
done
done <tocompare.txt
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.