2013年3月5日 星期二

POP 電郵帳密測試

用python 寫了一個小工具

POP_Test.py

import os,sys,string,email,poplib   

class Test_Mail():
    def __init__(self,server,username,passwd):
        self.servername = server 
        self.username = username
        self.passwd = passwd
        self.data = []

    def connect(self):
        try:
            self.pop = poplib.POP3(self.servername,110,3)
            self.pop.set_debuglevel (1)
            self.pop.user(self.username)
            self.pop.pass_(self.passwd)
            return True
        except:
            return False

if __name__ == "__main__":

account_file = open("account.txt", "r")
passwd_file = open("pass.txt", "r")
success_log = open("success.txt","w")

account_list = account_file.readlines()
passwd_list = passwd_file.readlines()

total=len(account_list)*len(passwd_list)

start_num = 0
for account in account_list:
    for passwd in passwd_list:
        start_num = start_num + 1
        rate = float(start_num) / float(total)   
        rate_num = int(rate * 100)  
        print "Process : "+"%d%%" % (rate_num)+"        ("+str(start_num)+"/"+str(total)+")"
        pop_server_ip="127.0.0.1"
        gm =Test_Mail(pop_server_ip,account.strip(),passwd.strip()) 
        if gm.connect():
            print "Test Success!"
            success_log.write(account.strip()+"  "+passwd.strip()+'\n')
            print"========================="
    
success_log.close() 
account_file.close()
passwd_file.close()

沒有留言:

張貼留言

用APNIC找出台灣所有的IP位址