Author Archive

Forwarding or fetching your hotmail

Posted by on Tuesday, 7 April, 2009

#!/usr/bin/perl -w
#
# You need to install this perl module below and openssl, crypt, mechanize also
use WWW::Hotmail;

my $hotmail = WWW::Hotmail->new();

$hotmail->login(‘username@hotmail.com’, “pass123”)
or die $WWW::Hotmail::errstr;

my @msgs = $hotmail->messages();
die $WWW::Hotmail::errstr if ($!);

print “You have “.scalar(@msgs).” messages\n”;

for (@msgs) {
print “message from “.$_->from.”\n”;
# retrieve the message from hotmail
my $mail = $_->retrieve;
# deliver it locally – you may wanna hash this out 🙂
$mail->accept;
# forward the message
$mail->resend(‘username@gmail.com’);
# delete it from the inbox
$_->delete;
}


Resizing images (thumbnails) in bulk

Posted by on Tuesday, 7 April, 2009

#!/bin/bash
# you need imagemagick installed for this to work
#
DIR=/path/to/images/
SMIM=/path/to/images/thumbs
SIZE=200×200

for IMG in ${DIR}
do echo Converting ${IMG}
convert -size ${SIZE} -resize ${SIZE} ${IMG} ${SMIM}/thumb-${IMG}
done
Last-Modified: 2007-03-07 19:38:50


Throttle ssh connections

Posted by on Tuesday, 7 April, 2009

Limit the number of connections a host can make to sshd (3 in 60 seconds), if the limit is exceeded new conections are dropped (for 60 seconds). This seems to stop those pesky dictionary attacks.

My iptables script is /etc/networks/iptables and is run from /etc/networks/interfaces under the eth0 section like so:

pre-up /etc/networks/iptables

iptables script snippit:

# Create SSH chain
/sbin/iptables -N SSH
/sbin/iptables -A
SSH -m state –state NEW -m recent –update \
–seconds
60 –hitcount 3 -j DROP
/sbin/iptables -A
SSH -p tcp -m state –state NEW -m recent –set
/sbin/iptables -A
SSH -p tcp -j ACCEPT

# Jump ssh trffic to SSH chain
/sbin/iptables -A INPUT -p tcp –dport 22 -j SSH

Last-Modified: 2007-03-07 19:38:50