Skip to content

Commit

Permalink
TLS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelBerrueta committed Oct 20, 2021
1 parent c3ae002 commit f040d33
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions scripts/smtp_authcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@ def banner():


def usage():
print("Usage: python smtp_authcheck.py --server <mail server> --port <SMTP port> --username <username> --password <password>")
print("Usage: python smtp_authcheck.py --server <mail server> --port <SMTP port> --username <username> --password <password> [--start-tls]")


def smtp_auth(server, port, username, password):
print("[+] Attempting to connect to server")
s = smtplib.SMTP(server, port)
s.starttls()

try:
#s.starttls()
if args.starttls:
print("[+] Attempting to use STARTTLS")
s.starttls()

print("[+] Attempting to say ehlo")
s.ehlo()

try:
s.login(username, password)
return "Authentication successful"

except smtplib.SMTPAuthenticationError:
return "Wrong username or password"
except:
sys.exit("Wrong username or password")

finally:
s.close()
Expand All @@ -40,7 +47,7 @@ def smtp_auth(server, port, username, password):
parser.add_argument("--port", action="store", dest='port', help="server port", type=int)
parser.add_argument("--username", action="store", dest='username', help="username")
parser.add_argument("--password", action="store", dest='password', help="password")

parser.add_argument('--start-tls', action='store_true', dest='starttls', help='run using STARTTLS')
args = parser.parse_args()
banner()
main(args)

0 comments on commit f040d33

Please sign in to comment.