Friday, October 14, 2005

Blacklist SSH Bruteforce Fools

If you run OpenBSD. Add this to your pf.conf
#table of bad-guys
table <fsckers> persist file "/var/db/fsckers.txt"
#Block Blacklisted IPs
block in on $external from <fsckers> to any
/var/db/fsckers.txt is a plaintext file with each blacklisted ip / ip-block on a seperate line. Lines starting with # are considered comments.

Then I wrote this little script that I run hourly via cron to update my blacklist table based on failed password attempts.
#!/bin/sh
echo "Started on: $(date)"
for each in $(grep 'Failed password' /var/log/authlog | sed 's/^.*from //;s/port.*$//' | uniq)
do
echo -n "$each\t\t--->"
pfctl -t fsckers -T add $each 2>&1
done
I guess I also need to extend this so that it also adds it to /var/db/fsckers.txt, but that is trivial. The text file in only needed when initially loading the list.

To view the current list of blacklisted ip, type:
pfctl -t fsckers -T show
EDIT: here is my script to dump the current blacklist to fsckers.txt
#!/bin/sh
pfctl -t fsckers -T show | sed 's/^ //' > /var/db/fsckers.txt

Thursday, October 13, 2005

...and darn it, people like you.

"Happiness is not achieved by the conscious pursuit of happiness; it is generally the by-product of other activities."
- Aldous Huxley

Wednesday, October 12, 2005

Create and burn DVD's from the command line.

One of the more annoying "features" of Linux burning software are the innumerable parameters and switches. After doing a "man growisofs" too many times, I decided to take matters into my own hands. Once again, bash comes to the rescue.
I rarely create data dvds. I am usually creating my own dvd video or burning backups of my dvds. So these scripts are specifically for creating and burning dvd video .iso files. They depend on 3 programs. The first is growisofs which is provided by dvdrtools (http://www.nongnu.org/dvdrtools/). Second is dvdimgcmp (ftp://sunsite.unc.edu/pub/linux/apps/video/dvdimagecmp-0.3.tgz). It will verify a burned image is the same as the original .iso . The last program is mkisofs which is provided by cdrtools (http://cdrecord.berlios.de/old/private/cdrecord.html). The only thing I think that you probably need to install is dvdimgcmp (or comment out that portion of the script). Anyway, here are the scripts. I've only tested it on my gentoo machine. So as always, I take no responsibility if it breaks your machine or makes your mother cry. And if it doesn't work for you, don't use it :) .

http://www.mercymachines.net/scripts/burndvd
(edit ${DVD_BURNER} so that it points to your burning device)

http://www.mercymachines.net/scripts/mkdvdiso

Monday, October 10, 2005

Backup your Firefox profile.

Here is a little script I wrote to backup one's firefox profile. It won't handle multiple profiles, so be warned.

http://www.mercymachines.net/scripts/backup-firefox