Recover a pop3 password

This is my POP password retrieval script, it creates a TCP server on port 110 that waits for incoming connections and replies with +OK to any message, displaying both server and client messages to the console. So in order to recover a lost POP password, start this script on a machine with perl installed. Now change the POP server on settings of the client to the machine where the script is running.

Here is sample communication between a POP server and client
Server: Connected to pop.server.net (127.0.0.1).
Server: +OK hostname POP3 Server ready
Client: user myusername@domain.net
Server: +OK myusername@domain.net is a valid mailbox
Client: pass MyPasword
Server: +OK valid username and password
From the above output we can conclude that the password for that mailbox is MyPassword
#!/usr/bin/perl -w
# Author: Luis "sheep" Tavares
# Name: POP Password retrival
# Version: 1.0
# OS: Tested on Linux FC4

# Change the settings to match your system.
my $host = 'localhost';
my $port = '110';
my $proto = 'tcp';

#
# You shouldn't need to edit below this point.
#

use IO::Socket::INET;

# POP responses
my $conn_new = "+OK connected for password retrivaln";
my $conn_OK = "+OKn";

my $sock = new IO::Socket::INET->new(
        Localhost => $host,
        LocalPort => $port,
        Proto => $proto,
        Listen => 1,
        Reuse => 1
        );
die "Could not create socket: $!n" unless $sock;

print "Waiting for incomming connections on $proto/$portnPress ctrl+c to abortn";

my $new_sock = $sock->accept();
print $new_sock $conn_new; # Must print an +OK as soon the client connects.

while ( <$new_sock> )
{
        print $_; # Data from the client is displayed on the screen
        print $new_sock $conn_OK; # We are a happy bunny reply +OK to everything
}
close($sock);
Posted in KB