Python poplib.POP3 Examples

The following are 30 code examples of poplib.POP3(). 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: popbrute_random.py    From d4rkc0de with GNU General Public License v2.0 6 votes vote down vote up
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			pop = poplib.POP3(ipaddr[0])
			pop.user(user[:-1])
			pop.pass_(value)
			print "\t\nLogin successful:",value, user
			print pop.stat()
			pop.quit()
			work.join()
			sys.exit(2)
		except(poplib.error_proto, socket.gaierror, socket.error, socket.herror), msg: 
			#print "An error occurred:", msg
			pass 
Example #3
Source File: popbrute_iprange.py    From d4rkc0de with GNU General Public License v2.0 6 votes vote down vote up
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			pop = poplib.POP3(ip)
			pop.user(user[:-1])
			pop.pass_(value)
			print "\t\nLogin successful:",value, user
			print pop.stat()
			pop.quit()
			work.join()
			sys.exit(2)
		except(poplib.error_proto), msg: 
			#print "An error occurred:", msg
			pass 
Example #4
Source File: checker.py    From root-2015-tasks with GNU General Public License v3.0 6 votes vote down vote up
def get_pop3(server, user, sender):
    result = FAIL
    try:
        box = poplib.POP3(server)
        box.user(user[0])
        box.pass_(user[1])
        response, lst, octets = box.list()
        for msgnum, msgsize in [i.split() for i in lst]:
            resp, lines, octets = box.retr(msgnum)
            msgtext = " ".join(lines)
            if content.format(sender[0]) in msgtext:
                result = OK
            box.dele(msgnum)

        box.quit()
        return result
    except Exception as e:
        print "Error while recivieng mail"
        print e
        return FAIL 
Example #5
Source File: mailpillager.py    From SPF with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def pillage(self, username, password, server, port, domain, outputdir="."):

        print("%s, %s, %s, %s" % (username, password, server, domain))
        mail = None
        if (port == 993):
            mail = IMAPS(outputdir=outputdir)
        elif (port == 143):
            mail = IMAP(outputdir=outputdir)
        elif (port == 995):
            mail = POP3S(outputdir=outputdir)
        elif (port == 110):
            mail = POP3(outputdir=outputdir)
        else:
            print("ERROR, unknown port provided")
            return

        mail.connect(server)
        t = Thread(target=self.tworker, args=(mail, username, password, domain, server, port,))
        t.start()
        
#-----------------------------------------------------------------------------
# main test code
#----------------------------------------------------------------------------- 
Example #6
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def testTimeoutNone(self):
        self.assertTrue(socket.getdefaulttimeout() is None)
        socket.setdefaulttimeout(30)
        try:
            pop = poplib.POP3(HOST, self.port, timeout=None)
        finally:
            socket.setdefaulttimeout(None)
        self.assertTrue(pop.sock.gettimeout() is None)
        pop.sock.close() 
Example #7
Source File: popbrute.py    From darkc0de-old-stuff with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
		value, user = getword()
		try:
			print "-"*12
			print "User:",user,"Password:",value
			pop = poplib.POP3(sys.argv[1])
			pop.user(user)
			pop.pass_(value)
			print "\t\nLogin successful:",value, user
			print pop.stat()
			pop.quit()
			work.join()
			sys.exit(2)
		except (poplib.error_proto), msg: 
			#print "An error occurred:", msg
			pass 
Example #8
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 #9
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.start()
        self.client = poplib.POP3(self.server.host, self.server.port) 
Example #10
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="110"):
        self.mailserver = mailserver
        self.port = port
        try:
            self.srv = poplib.POP3(self.mailserver, self.port)
        except:
            self.srv = None
            pass 
Example #11
Source File: mailpillager.py    From SPF with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def getMessages(self):
        if (not self.srv):
            return

        if (not self.msg_list):
            (numMsgs, totalSize) = self.srv.stat()
            self.msg_list = []
            for i in range(numMsgs):
                self.msg_list.append(self.srv.retr(i+1))

#-----------------------------------------------------------------------------
# POP3S subclass of POP3 Class
#----------------------------------------------------------------------------- 
Example #12
Source File: mailpillager.py    From SPF with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, outputdir="."):
        POP3.__init__(self, outputdir) 
Example #13
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def found_terminator(self):
        line = ''.join(self.in_buffer)
        self.in_buffer = []
        cmd = line.split(' ')[0].lower()
        space = line.find(' ')
        if space != -1:
            arg = line[space + 1:]
        else:
            arg = ""
        if hasattr(self, 'cmd_' + cmd):
            method = getattr(self, 'cmd_' + cmd)
            method(arg)
        else:
            self.push('-ERR unrecognized POP3 command "%s".' %cmd) 
Example #14
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def testTimeoutValue(self):
        pop = poplib.POP3(HOST, self.port, timeout=30)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #15
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def testTimeoutValue(self):
        pop = poplib.POP3(HOST, self.port, timeout=30)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #16
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="993"):
        self.mailserver = mailserver
        self.port = port
        try:
            self.srv = imaplib.IMAP4_SSL(self.mailserver, self.port)
        except:
            self.srv = None
            pass

#-----------------------------------------------------------------------------
# POP3 subclass of Pillager Class
#----------------------------------------------------------------------------- 
Example #17
Source File: test_poplib.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def testTimeoutDefault(self):
        self.assertTrue(socket.getdefaulttimeout() is None)
        socket.setdefaulttimeout(30)
        try:
            pop = poplib.POP3(HOST, self.port)
        finally:
            socket.setdefaulttimeout(None)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #18
Source File: popbrute_random.py    From darkc0de-old-stuff with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			pop = poplib.POP3(ipaddr[0])
			pop.user(user[:-1])
			pop.pass_(value)
			print "\t\nLogin successful:",value, user
			print pop.stat()
			pop.quit()
			work.join()
			sys.exit(2)
		except(poplib.error_proto, socket.gaierror, socket.error, socket.herror), msg: 
			#print "An error occurred:", msg
			pass 
Example #19
Source File: popbrute_iprange.py    From darkc0de-old-stuff with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
		value = getword()
		try:
			print "-"*12
			print "User:",user[:-1],"Password:",value
			pop = poplib.POP3(ip)
			pop.user(user[:-1])
			pop.pass_(value)
			print "\t\nLogin successful:",value, user
			print pop.stat()
			pop.quit()
			work.join()
			sys.exit(2)
		except(poplib.error_proto), msg: 
			#print "An error occurred:", msg
			pass 
Example #20
Source File: test_poplib.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def found_terminator(self):
        line = ''.join(self.in_buffer)
        self.in_buffer = []
        cmd = line.split(' ')[0].lower()
        space = line.find(' ')
        if space != -1:
            arg = line[space + 1:]
        else:
            arg = ""
        if hasattr(self, 'cmd_' + cmd):
            method = getattr(self, 'cmd_' + cmd)
            method(arg)
        else:
            self.push('-ERR unrecognized POP3 command "%s".' %cmd) 
Example #21
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def testTimeoutDefault(self):
        self.assertIsNone(socket.getdefaulttimeout())
        socket.setdefaulttimeout(30)
        try:
            pop = poplib.POP3(HOST, self.port)
        finally:
            socket.setdefaulttimeout(None)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #22
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.server = DummyPOP3Server((HOST, PORT))
        self.server.start()
        self.client = poplib.POP3(self.server.host, self.server.port, timeout=3)
        self.client.stls() 
Example #23
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_stls_context(self):
        expected = b'+OK Begin TLS negotiation'
        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
        ctx.load_verify_locations(CAFILE)
        ctx.verify_mode = ssl.CERT_REQUIRED
        ctx.check_hostname = True
        with self.assertRaises(ssl.CertificateError):
            resp = self.client.stls(context=ctx)
        self.client = poplib.POP3("localhost", self.server.port, timeout=3)
        resp = self.client.stls(context=ctx)
        self.assertEqual(resp, expected) 
Example #24
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.server = DummyPOP3Server((HOST, PORT))
        self.server.start()
        self.client = poplib.POP3(self.server.host, self.server.port, timeout=3) 
Example #25
Source File: test_poplib.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def found_terminator(self):
        line = b''.join(self.in_buffer)
        line = str(line, 'ISO-8859-1')
        self.in_buffer = []
        cmd = line.split(' ')[0].lower()
        space = line.find(' ')
        if space != -1:
            arg = line[space + 1:]
        else:
            arg = ""
        if hasattr(self, 'cmd_' + cmd):
            method = getattr(self, 'cmd_' + cmd)
            method(arg)
        else:
            self.push('-ERR unrecognized POP3 command "%s".' %cmd) 
Example #26
Source File: test_poplib.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testTimeoutValue(self):
        pop = poplib.POP3(HOST, self.port, timeout=30)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #27
Source File: test_poplib.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testTimeoutNone(self):
        self.assertIsNone(socket.getdefaulttimeout())
        socket.setdefaulttimeout(30)
        try:
            pop = poplib.POP3(HOST, self.port, timeout=None)
        finally:
            socket.setdefaulttimeout(None)
        self.assertIsNone(pop.sock.gettimeout())
        pop.sock.close() 
Example #28
Source File: test_poplib.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def testTimeoutDefault(self):
        self.assertIsNone(socket.getdefaulttimeout())
        socket.setdefaulttimeout(30)
        try:
            pop = poplib.POP3(HOST, self.port)
        finally:
            socket.setdefaulttimeout(None)
        self.assertEqual(pop.sock.gettimeout(), 30)
        pop.sock.close() 
Example #29
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.start()
        self.client = poplib.POP3(self.server.host, self.server.port) 
Example #30
Source File: test_poplib.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def found_terminator(self):
        line = ''.join(self.in_buffer)
        self.in_buffer = []
        cmd = line.split(' ')[0].lower()
        space = line.find(' ')
        if space != -1:
            arg = line[space + 1:]
        else:
            arg = ""
        if hasattr(self, 'cmd_' + cmd):
            method = getattr(self, 'cmd_' + cmd)
            method(arg)
        else:
            self.push('-ERR unrecognized POP3 command "%s".' %cmd)