msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

20 May 2007 Get your IP address

ifconfig eth0 | awk '/inet addr/{print $2}' | cut -d: -f2

Tags: , ,

Posted by

20 May 2007 One-line batch file renamer

If you want to batch rename a bunch of files (say “foo*.jpg” to “bar*.jpg”), you might think you could just do “mv foo*.jpg bar*.jpg” in the Terminal. However, this doesn’t work right since the shell expands each argument before the execution occurs. However, there’s a cool way to accomplish the same result with a (more complex) command line argument.
(more…)

Tags: ,

Posted by

08 May 2007 Rule-based DoS attacks prevention shell script

Dette scriptet er ikke testet samt DoS bør hindres på kernel nivå!

A simple rule-based DoS attack-prevention shell script. However, the proposed shell script is not a perfect tool for preventing DoS attacks, but a powerful tool for alleviating DoS attacks overheads of the Linux servers significantly.
(more…)

Tags: , , , , ,

Posted by

07 May 2007 Monitoring /var/log/secure for break-in attempts

date >> ssh-intruders.log ; cat /var/log/secure | grep -i "sshd.*authentication failure" | sort | awk '{FS="rhost="; print $2}' | awk '{FS="user="; print $1}' | grep ".*\..*\." | grep -v "knownhost.com" | grep -v "knownhost2.com" | sort | uniq | while read i; do counter=`grep -i "$i" /var/log/secure | wc -l` ; echo "$counter attempts by $i"; done >> ssh-intruders.log ; cat ssh-intruders.log

Tags: , , ,

Posted by

07 May 2007 Find duplicate usernames in /etc/passwd

# cat /etc/passwd | awk -F: '{print $1}' | sort | uniq -c | grep -v 1
# cat /etc/shadow | awk -F: '{print $1}' | sort | uniq -c | grep -v 1
# awk -F: '{ print $1, $5}' /etc/passwd

Tags: , ,

Posted by