Showing posts with label how to check policy in Linux using shell scripting. Show all posts
Showing posts with label how to check policy in Linux using shell scripting. Show all posts

Monday, 30 December 2013

Scripts to Check Policies in Linux Such as Grub BootLoader Password, Prompting Password in Single user mode

(1) CTR ALT DEL SHUTDOWN POLICY


#!/bin/bash
echo "This script Check CTR ALT DEL POLICY Working or NOT "
f="/etc/inittab"

if [ -e $f ]
then
cd /etc

echo " U R in `pwd` "
s=`cat inittab | grep "^ca::ctrlaltdel:/sbin/shutdown -t3 -r now"`

if [ ! -n "$s" ]
then
echo " POLICY not Working "

else
echo "POLICY Working Properly "

fi
fi


 output
[root@CLIENT ~]# ./CtrAltDel.sh
This script Check CTR ALT DEL POLICY Working or NOT
 U R in /etc
POLICY Working Properly






(2) PASSWORD PROTECTING GRUB


#!/bin/bash
echo "This script check grub bootloader is password protected or not"
f="/boot/grub/grub.conf"

if [ -e $f ]
then
cd /boot/grub

echo " U R in `pwd` "
s=`cat grub.conf | grep "^password --md5"`

echo " PASSWORD OF GRUB IS  $s "
if [ ! -n "$s" ]

then
echo "Not Verified"

else
echo "Password  Implemented "

fi
fi


output

[root@CLIENT ~]# ./grub.sh
This script check grub bootloader is password protected or not
 U R in /boot/grub
 PASSWORD OF GRUB IS  password --md5 $1$cnO6W1$Oc3iMBjHIVVukIGkXkeFD0
Password  Implemented


(3) PROMPTING FOR PASSWORD IN SINGLE USER MODE


#!/bin/bash
echo "This script Check Prompting Password in Singl Usrmod POLICY Working or NOT "
f="/etc/inittab"

if [ -e $f ]
then
cd /etc

echo " U R in `pwd` "
s=`cat inittab | grep "^~~:S:wait:/sbin/sulogin"`

if [ ! -n "$s" ]
then
echo " POLICY not Working "

else
echo "POLICY Working Properly "

fi
fi


output
[root@CLIENT ~]# ./singleuser.sh
This script Check Prompting Password in Singl Usrmod POLICY Working or NOT
 U R in /etc
 POLICY not Working