3 # crackpop - a pattern-generated-dictionary pop3 password cracker
5 # Copyright (C) 2013 Antonio Ospite <ospite@studenti.unina.it>
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 __description = "crackpop is a pattern-generated-dictionary pop3 password cracker"
26 __author_info = "Antonio Ospite"
29 def generate_passwords(password_pattern, dry_run=False):
30 passwords = list(exrex.generate(password_pattern))
33 print "Generated %d passwords." % len(passwords)
41 def crackpop(host, port, user, passwords):
42 print "Testing %d passwords." % len(passwords)
44 # TODO maybe the same connection can be reused for more than one try,
45 # but some logic needs to be added to detect the maximum allowed
46 # authentication attempts or a disconnection from the server.
47 pop3 = poplib.POP3(host, port)
52 print e.message, "(password: %s)" % p
56 print "Found! (password: %s)" % p
61 usage = "usage: %(prog)s [options]"
63 parser = argparse.ArgumentParser(
65 description=__description,
67 version='%(prog)s ' + __version)
70 '-H', '--host', metavar="<host>",
71 dest='host', required=True,
72 help='the host where the pop3 server is')
75 '-P', '--port', metavar="<port>",
76 dest='port', default=110,
77 help='the port the pop3 server is listening on')
80 '-u', '--user', metavar="<user>",
81 dest='user', required=True,
82 help='username of the pop3 account')
85 '-p', '--pattern', metavar="<password_pattern>",
86 dest='password_pattern', required=True,
87 help='the regular expression describing the pattern of the password')
91 dest='dry_run', action='store_const', const=True,
92 help='only print out the passwords, do not connect to the pop3 server')
97 if __name__ == "__main__":
98 parser = option_parser()
99 args = parser.parse_args()
101 passwords = generate_passwords(args.password_pattern, args.dry_run)
102 crackpop(args.host, args.port, args.user, passwords)