permission mods
[feisty_meow.git] / scripts / cgi / grumble_chkrootkit.cgi
1 #!/bin/bash
2
3 # checks the rootkit report file to see if anything is listed.
4
5 export CHKFILE=$TMP/test_for_rootkit_entries.txt
6 export QUIET_REPORT=/var/www/rootkit_report_quiet.txt
7 export LOUD_REPORT=/var/www/rootkit_report_expert.txt
8
9 # cgi text starting thing...
10 #not right yet
11 echo
12 echo
13
14 if [ ! -f $QUIET_REPORT ]; then
15   echo No file found for $QUIET_REPORT
16   exit 3
17 fi
18
19 grep "LKM Trojan" $QUIET_REPORT >$CHKFILE
20
21 if [ -z "$(cat $CHKFILE)" ]; then
22   echo found no content in the quiet report, skipping complaint.
23   rm $CHKFILE
24
25   exit 8
26 fi
27
28 echo found some content in the quiet report, looking up bad processes.
29
30 if [ ! -f $LOUD_REPORT ]; then
31   echo No file found for $LOUD_REPORT
32   exit 9
33 fi
34
35 grep "PID.*not in readdir output" $LOUD_REPORT >$CHKFILE
36
37 echo after the pid grep
38   
39 if [ -z "$(cat $CHKFILE)" ]; then
40   echo "didn't find our expected phrase."
41   exit 23
42 fi
43
44 export BAD_PROCESS=$(sed -e "s/^.*PID *\([0-9][0-9]*\).*$/\1/" <$CHKFILE)
45 if [ -z "$BAD_PROCESS" ]; then
46   echo "didn't find our expected phrase."
47   exit 32
48 fi
49 echo bad process number is $BAD_PROCESS
50
51 echo bad proc command line is:
52 export CMDLINE=$(cat /proc/$BAD_PROCESS/cmdline)
53 echo $CMDLINE
54
55 if [ $BAD_PROCESS -ne 1 ]; then
56
57   if [ ! -z "$(echo $CMDLINE | grep ini)" ]; then
58
59     echo "How come the process $BAD_PROCESS is called \"$CMDLINE\""
60     echo "when the init process is always supposed to be process 1?"
61
62   fi
63
64 fi
65
66
67