Python poplib.POP3_SSL Examples

The following are 30 code examples of poplib.POP3_SSL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module poplib , or try the search function .
Example #1
Source File: Testpop.py    From fuzzdb-collect with GNU General Public License v3.0 9 votes vote down vote up
def check(email, password):
    try:
        email = email
        password = password
        pop3_server = "pop.163.com"
        server = poplib.POP3(pop3_server)
        
        #ssl加密后使用
        #server = poplib.POP3_SSL('pop.163.com', '995')
        print(server.set_debuglevel(1)) #打印与服务器交互信息
        print(server.getwelcome()) #pop有欢迎信息
        server.user(email)
        server.pass_(password)
        print('Messages: %s. Size: %s' % server.stat())
        print(email+": successful")
    except poplib.error_proto as e:
        print(email+":fail")
        print(e) 
Example #2
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def test_context(self):
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, certfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE,
                            certfile=CERTFILE, context=ctx)

        self.client.quit()
        self.client = poplib.POP3_SSL(self.server.host, self.server.port,
                                        context=ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)
        self.assertIs(self.client.sock.context, ctx)
        self.assertTrue(self.client.noop().startswith(b'+OK')) 
Example #3
Source File: gmailpopbrute.py    From darkc0de-old-stuff with GNU General Public License v3.0 6 votes vote down vote up
def run(self):
		value, user = getword()
		user = user.replace("\n","")
		value = value.replace("\n","")
		
		try:
			print "-"*12
			print "[+] User:",user,"Password:",value
			pop = poplib.POP3_SSL(server, 995)
			pop.user(user)
			pop.pass_(value)
			print "\t\t\n\nLogin successful:",user, value
			print "\t\tMail:",pop.stat()[0],"emails"
			print "\t\tSize:",pop.stat()[1],"bytes\n\n"
			success.append(user)
			success.append(value)
			success.append(pop.stat()[0])
			success.append(pop.stat()[1])
			pop.quit()
		except (poplib.error_proto), msg: 
			#print "An error occurred:", msg
			pass 
Example #4
Source File: email_lean.py    From notes with Apache License 2.0 6 votes vote down vote up
def receive_pop_email():
    pop = poplib.POP3_SSL(host=pop_server)
    pop.set_debuglevel(1)
    pop.user(user)
    pop.pass_(password)
    # 列出邮件信息,包含邮件的大小和ID
    pop_reslut = pop.list()
    print(pop_reslut)
    print("==========")
    print(pop_reslut[2])
    pop_stat = pop.stat()
    # 第一项是代表的邮件ID
    for index in range(1, pop_stat[0]):
        print(pop.top(index, 0))
        if index > 5:
            break

    print(pop.retr(1))
    for line_content in pop.retr(1):
        print(line_content) 
Example #5
Source File: gmailpopbrute.py    From d4rkc0de with GNU General Public License v2.0 6 votes vote down vote up
def run(self):
		value, user = getword()
		user = user.replace("\n","")
		value = value.replace("\n","")
		
		try:
			print "-"*12
			print "[+] User:",user,"Password:",value
			pop = poplib.POP3_SSL(server, 995)
			pop.user(user)
			pop.pass_(value)
			print "\t\t\n\nLogin successful:",user, value
			print "\t\tMail:",pop.stat()[0],"emails"
			print "\t\tSize:",pop.stat()[1],"bytes\n\n"
			success.append(user)
			success.append(value)
			success.append(pop.stat()[0])
			success.append(pop.stat()[1])
			pop.quit()
		except (poplib.error_proto), msg: 
			#print "An error occurred:", msg
			pass 
Example #6
Source File: test_poplib.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_context(self):
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, certfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE,
                            certfile=CERTFILE, context=ctx)

        self.client.quit()
        self.client = poplib.POP3_SSL(self.server.host, self.server.port,
                                        context=ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)
        self.assertIs(self.client.sock.context, ctx)
        self.assertTrue(self.client.noop().startswith(b'+OK')) 
Example #7
Source File: mailbox_basic_params.py    From Learning-Python-Networking-Second-Edition with MIT License 6 votes vote down vote up
def main(hostname,port,user,password):

        mailbox = poplib.POP3_SSL(hostname,port)

        try:
                mailbox.user(user)
                mailbox.pass_(password)
                response, listings, octet_count = mailbox.list()
                for listing in listings:
                        number, size = listing.decode('ascii').split()
                        print("Message %s has %s bytes" % (number, size))

        except poplib.error_proto as exception:
                print("Login failed:", exception)

        finally:
                mailbox.quit() 
Example #8
Source File: POPListener.py    From flare-fakenet-ng with Apache License 2.0 6 votes vote down vote up
def test(config):

    import poplib

    logger = logging.getLogger('POPListenerTest')

    server = poplib.POP3_SSL('localhost', config.get('port', 110))

    logger.info('Authenticating.')
    server.user('username')
    server.pass_('password')

    logger.info('Listing and retrieving messages.')
    print server.list()
    print server.retr(1)
    server.quit() 
Example #9
Source File: test_poplib.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_context(self):
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, certfile=CERTFILE, context=ctx)
        self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
                            self.server.port, keyfile=CERTFILE,
                            certfile=CERTFILE, context=ctx)

        self.client.quit()
        self.client = poplib.POP3_SSL(self.server.host, self.server.port,
                                        context=ctx)
        self.assertIsInstance(self.client.sock, ssl.SSLSocket)
        self.assertIs(self.client.sock.context, ctx)
        self.assertTrue(self.client.noop().startswith(b'+OK')) 
Example #10
Source File: test_poplib.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
            self.server = DummyPOP3Server((HOST, 0))
            self.server.handler = DummyPOP3_SSLHandler
            self.server.start()
            self.client = poplib.POP3_SSL(self.server.host, self.server.port) 
Example #11
Source File: patator_ext.py    From project-black with GNU General Public License v2.0 5 votes vote down vote up
def connect(self, host, port, ssl, timeout):
    if ssl == '0':
      if not port: port = 110
      fp = POP3(host, int(port), timeout=int(timeout))
    else:
      if not port: port = 995
      fp = POP3_SSL(host, int(port)) # timeout=int(timeout)) # no timeout option in python2

    return POP_Connection(fp, fp.welcome) 
Example #12
Source File: 5_4_download_google_email_via_pop3.py    From Python-Network-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def download_email(username): 
    mailbox = poplib.POP3_SSL(GOOGLE_POP3_SERVER, '995') 
    mailbox.user(username)
    password = getpass.getpass(prompt="Enter your Google password: ") 
    mailbox.pass_(password) 
    num_messages = len(mailbox.list()[1])
    print ("Total emails: %s" %num_messages)
    print ("Getting last message")
    for msg in mailbox.retr(num_messages)[1]:
        print (msg)
    mailbox.quit() 
Example #13
Source File: 5_11_pop3_mail_client.py    From Python-Network-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def mail_client(host, port, user, password):
    Mailbox = poplib.POP3_SSL(host, port) 
    Mailbox.user(user) 
    Mailbox.pass_(password) 
    numMessages = len(Mailbox.list()[1])
    print (Mailbox.retr(1)[1])
    Mailbox.quit() 
Example #14
Source File: test_poplib.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setUp(self):
        self.server = DummyPOP3Server((HOST, 0))
        self.server.handler = DummyPOP3_SSLHandler
        self.server.start()
        self.client = poplib.POP3_SSL(self.server.host, self.server.port) 
Example #15
Source File: test_poplib.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test__all__(self):
            self.assertIn('POP3_SSL', poplib.__all__) 
Example #16
Source File: 15_11_pop3_mail_client.py    From Python-Network-Programming with MIT License 5 votes vote down vote up
def mail_client(host, port, user, password):
    Mailbox = poplib.POP3_SSL(host, port) 
    Mailbox.user(user) 
    Mailbox.pass_(password) 
    numMessages = len(Mailbox.list()[1])
    print (Mailbox.retr(1)[1])
    Mailbox.quit() 
Example #17
Source File: 15_4_download_google_email_via_pop3.py    From Python-Network-Programming with MIT License 5 votes vote down vote up
def download_email(username): 
    mailbox = poplib.POP3_SSL(GOOGLE_POP3_SERVER, '995') 
    mailbox.user(username)
    password = getpass.getpass(prompt="Enter your Google password: ") 
    mailbox.pass_(password) 
    num_messages = len(mailbox.list()[1])
    print ("Total emails: %s" %num_messages)
    print ("Getting last message")
    for msg in mailbox.retr(num_messages)[1]:
        print (msg)
    mailbox.quit() 
Example #18
Source File: Emailscan.py    From Emailscanner with GNU General Public License v3.0 5 votes vote down vote up
def pop(self, user, pwd):	
		try:
			server = poplib.POP3_SSL(self.host) if self.ssl else poplib.POP3(self.host)
			server.user(user)
			if '+OK' in server.pass_(pwd):
				print '{}[+] 发现一个用户: {}  {}{}'.format(self.G, user, pwd, self.W)
				self.result.append('[+] {}  {}'.format(user, pwd))
		except Exception as e:
			pass
		finally:
			server.quit() 
Example #19
Source File: server.py    From zmail with MIT License 5 votes vote down vote up
def _make_server(self):
        """Init Server."""
        if self.server is None:
            if self.ssl:
                self.server = poplib.POP3_SSL(self.host, self.port, timeout=self.timeout)
            else:
                self.server = poplib.POP3(self.host, self.port, timeout=self.timeout) 
Example #20
Source File: test_pop_server.py    From zmail with MIT License 5 votes vote down vote up
def test_pop_make_server(pop_server_config):
    srv = POPServer(**pop_server_config)
    srv._make_server()
    assert isinstance(srv.server, (poplib.POP3_SSL if srv.ssl else poplib.POP3)) 
Example #21
Source File: mailpillager.py    From SPF with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def connect(self, mailserver, port="995"):
        self.mailserver = mailserver
        self.port = port
        try:
            self.srv = poplib.POP3_SSL(self.mailserver, self.port)
        except:
            self.srv = None
            pass

#-----------------------------------------------------------------------------
# Wrapper Class
#----------------------------------------------------------------------------- 
Example #22
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
            self.server = DummyPOP3Server((HOST, 0))
            self.server.handler = DummyPOP3_SSLHandler
            self.server.start()
            self.client = poplib.POP3_SSL(self.server.host, self.server.port) 
Example #23
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test__all__(self):
            self.assertIn('POP3_SSL', poplib.__all__) 
Example #24
Source File: patator.py    From patator with GNU General Public License v2.0 5 votes vote down vote up
def connect(self, host, port, ssl, timeout):
    if ssl == '0':
      if not port:
        port = 110
      fp = POP3(host, int(port), timeout=int(timeout))
    else:
      if not port:
        port = 995
      fp = POP3_SSL(host, int(port)) # timeout=int(timeout)) # no timeout option in python2

    return TCP_Connection(fp, fp.welcome) 
Example #25
Source File: test_poplib.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test__all__(self):
        self.assertIn('POP3_SSL', poplib.__all__) 
Example #26
Source File: 多线程验证邮箱裤子.py    From fuzzdb-collect with GNU General Public License v3.0 5 votes vote down vote up
def getPopMail( mailDomain ):
    if mailDomain in ['163','gmali','126','qq','sina']:
        temp1 = 'pop.'+mailDomain+'.com'
        mail = poplib.POP3_SSL(temp1)   
    elif ( mailDomain == 'hotmail' ):
        mail = poplib.POP3_SSL('pop3.live.com')
    elif ( mailDomain == 'yahoo' ):
        mail = poplib.POP3_SSL('pop.mail.yahoo.com')
    return mail 
Example #27
Source File: baopo.py    From fuzzdb-collect with GNU General Public License v3.0 5 votes vote down vote up
def mailbruteforce(listuser,listpwd,type): 
    if len(listuser) < 1 or len(listpwd) < 1 : 
        print "[-] Error: An error occurred: No user or pass list\n" 
        return 1 
     
    for user in listuser: 
        for passwd in listpwd : 
            user = user.replace("\n","") 
            passwd = passwd.replace("\n","") 
             
            try: 
                print "-"*12 
                print "[+] User:",user,"Password:",passwd 
                 
#                 time.sleep(0.1)       
                if type in ['163','236']: 
                    popserver = poplib.POP3(server,110)         
                else: 
                    popserver = poplib.POP3_SSL(server,995) 
                popserver.user(user) 
                auth = popserver.pass_(passwd) 
                print auth 
                 
                if auth.split(' ')[0] == "+OK" or auth =="+OK": 
                    ret = (user,passwd,popserver.stat()[0],popserver.stat()[1]) 
                    success.append(ret) 
                    #print len(success) 
                    popserver.quit() 
                    break 
                else : 
                    popserver.quit() 
                    continue 
             
            except: 
                #print "An error occurred:", msg 
                pass 
Example #28
Source File: test_poplib.py    From BinderFilter with MIT License 5 votes vote down vote up
def setUp(self):
            self.server = DummyPOP3Server((HOST, 0))
            self.server.handler = DummyPOP3_SSLHandler
            self.server.start()
            self.client = poplib.POP3_SSL(self.server.host, self.server.port) 
Example #29
Source File: test_poplib.py    From BinderFilter with MIT License 5 votes vote down vote up
def test__all__(self):
            self.assertIn('POP3_SSL', poplib.__all__) 
Example #30
Source File: test_poplib.py    From oss-ftp with MIT License 5 votes vote down vote up
def setUp(self):
        self.server = DummyPOP3Server((HOST, 0))
        self.server.handler = DummyPOP3_SSLHandler
        self.server.start()
        self.client = poplib.POP3_SSL(self.server.host, self.server.port)