Handy password recovery script

Tags:

This little program runs as a temporary server, possibly on your local machine or wherever you can run it, and shows you in plaintext what it receives thru FTP or POP3... in order to recover passwords saved in a program.

#!/usr/bin/perl

# Program to recover lost FTP or Mail (POP3) passwords # -f recover

ftp password # -m recover mail password # -p use specified port #

use strict; use IO::Socket; use Getopt::Std;

getopts("fmp:");

if (!$::opt_f && !$::opt_m) { print "Must specify -f for FTP or -m for mail recovery.n"; die; }

my $port = $::opt_p || $::opt_f * 21 || 110 ;

print "[[$port]]n";

my $listener = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => $port, Proto => 'tcp',

notice the next two attributes # of the Socket::INET parameters

Listen => 1, Reuse => 1, ) or die "Could not create socket: $!n";

Display to STDOUT of the server window print "Waiting for

connection...n";

Wait for connections (initialize the socket server) my $SOCKET =

$listener->accept();

Display to STDOUT of the server window print "Got connection...n";

my ($command, $password); # Tell the client to send a command print $SOCKET $::opt_f ? "220 FTP fake readyn" : "+OK MailFake 1.0 at localhost readyn";

Read a command string from the client $command = <$socket>;

print "<< $commandn";

print $SOCKET $::opt_f ? "331 Enter your password, suckern" : "+OKn"; $password = <$socket>; print "PASSWORD: $passwordn";

Clean up the listener close($listener);

1;