Socialabel

Saturday, September 11, 2010

[x] Auto Kill Ssh Double Remote Linux bash

Private Content
baris berikut untuk arsip pribadi, --



#!/bin/bash
clear
ps aux | grep priv | cut -d”:” -f4 | cut -d “[" -f1 | cut -d" " -f2 | sort > a.txt

#echo "" > proses.txt
#for user in $(cat a.txt); do
# echo "Ada" $user
#done

nama=$(cat a.txt);
proses=$(cat proses.txt | sort -u);
tanya=("?");
total=0;
nol=0;

#echo "Ini Belum di Array"
for (( i = 0 ; i < ${#nama[@]} ; i++ ))
do

#echo ${nama[0]};
nama2=( $(echo ${nama[0]};) )
done

#echo “”
#echo “Ini sudah di Array”
echo “Ini total User ” ${#nama2[@]}

#for (( i = 0 ; i < $[${#nama2[@]}-1]; i++ ))
#do

#echo ${nama2[$i]}
#echo ${nama2[$i+1]}
#done
#if ["${#nama2[@]” > 0 ]; then
#else

echo “Ini Program Cek Samo On line”
for (( i = 0 ; i < $[${#nama2[@]}-1]; i++ ))
do
C1=${nama2[$i]}
C2=${nama2[$i+1]}

if [ "$C1" = "$C2" ]; then
echo “Ada Yang Sama Yaitu ” $C1
echo $(date) ” duplikasi user ” $C1 >> log.us

for (( i = 1 ; i < 7; i++ ))
do
ps ax | grep sshd | grep priv | grep $C1 | cut -d” ” -f$i >> tmp_proses.txt

done

total=$[$total+1];

fi
done

if [ $total = $nol ]; then
echo “” > proses.txt
else
cat tmp_proses.txt | sort -u >> proses.txt

for (( x = 0 ; x < ${#proses[@]} ; x++ ))
do
proses2=( $(echo ${proses[0]};) )

done

for (( x = 0 ; x < ${#proses2[@]}; x++ ))
do
if [ ${proses2[$x]} = $tanya ]; then
echo ${proses2[$x]} “Ini Bukan ID Proses”
else
echo “Proses Dengan ID ” ${proses2[$x]} ” Telah Terbunuh”
kill ${proses2[$x]}
fi
done

echo “” > tmp_proses.txt

fi

echo “”
echo “Total Yang Harus Dibunuh ” $total

#if [ $total = $nol ]; then
# echo “” > proses.txt

#fi
#sleep 2
#echo “” > proses.txt