From b903e6e0bbbe97d0b77b58c705fbed95e97704a9 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 2 Apr 2013 23:08:41 +0200 Subject: [PATCH] Add support for SSL connections --- crackpop.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/crackpop.py b/crackpop.py index 3c7d0f7..850b13f 100755 --- a/crackpop.py +++ b/crackpop.py @@ -38,13 +38,19 @@ def generate_passwords(password_pattern, dry_run=False): return passwords -def crackpop(host, port, user, passwords): +def crackpop(host, port, ssl, user, passwords): + if ssl: + pop3_connect = poplib.POP3_SSL + else: + pop3_connect = poplib.POP3 + print "Testing %d passwords." % len(passwords) for p in passwords: # TODO maybe the same connection can be reused for more than one try, # but some logic needs to be added to detect the maximum allowed # authentication attempts or a disconnection from the server. - pop3 = poplib.POP3(host, port) + pop3 = pop3_connect(host, port) + try: pop3.user(user) pop3.pass_(p) @@ -91,6 +97,16 @@ def option_parser(): dest='dry_run', action='store_const', const=True, help='only print out the passwords, do not connect to the pop3 server') + parser.add_argument( + '-s', '--ssl', + dest='ssl', action='store_const', const=True, + help='use SSL to connect to the pop3 server') + + parser.add_argument( + '-S', '--ssl-port', metavar="", + dest='ssl_port', default=995, + help='the port the SSL pop3 server is listening on') + return parser @@ -98,5 +114,10 @@ if __name__ == "__main__": parser = option_parser() args = parser.parse_args() + if args.ssl: + port = args.ssl_port + else: + port = args.port + passwords = generate_passwords(args.password_pattern, args.dry_run) - crackpop(args.host, args.port, args.user, passwords) + crackpop(args.host, port, args.ssl, args.user, passwords) -- 2.1.4