mirror of https://github.com/CIRCL/lookyloo
new: Support for STARTTLS in the notification
parent
0505edff0e
commit
324c85cac8
|
@ -48,6 +48,13 @@
|
||||||
"confirm_message": "Message the users need to confirm before they submit a notification.",
|
"confirm_message": "Message the users need to confirm before they submit a notification.",
|
||||||
"defang_urls": true
|
"defang_urls": true
|
||||||
},
|
},
|
||||||
|
"email_smtp_auth": {
|
||||||
|
"auth": false,
|
||||||
|
"smtp_user":"johndoe@myorg.local",
|
||||||
|
"smtp_pass":"password",
|
||||||
|
"smtp_use_starttls": true,
|
||||||
|
"verify_certificate": true
|
||||||
|
},
|
||||||
"priority": {
|
"priority": {
|
||||||
"sources": {
|
"sources": {
|
||||||
"web": 10,
|
"web": 10,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import smtplib
|
import smtplib
|
||||||
|
import ssl
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import date, datetime, timezone
|
from datetime import date, datetime, timezone
|
||||||
|
@ -715,6 +716,7 @@ class Lookyloo():
|
||||||
return
|
return
|
||||||
|
|
||||||
email_config = get_config('generic', 'email')
|
email_config = get_config('generic', 'email')
|
||||||
|
smtp_auth = get_config('generic', 'email_smtp_auth')
|
||||||
redirects = ''
|
redirects = ''
|
||||||
initial_url = ''
|
initial_url = ''
|
||||||
cache = self.capture_cache(capture_uuid)
|
cache = self.capture_cache(capture_uuid)
|
||||||
|
@ -755,9 +757,18 @@ class Lookyloo():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(f'Unable to get the contacts: {e}')
|
self.logger.warning(f'Unable to get the contacts: {e}')
|
||||||
try:
|
try:
|
||||||
s = smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port'])
|
with smtplib.SMTP(email_config['smtp_host'], email_config['smtp_port']) as s:
|
||||||
|
if smtp_auth['auth']:
|
||||||
|
if smtp_auth['smtp_use_starttls']:
|
||||||
|
if smtp_auth['verify_certificate'] is False:
|
||||||
|
ssl_context = ssl.create_default_context()
|
||||||
|
ssl_context.check_hostname = False
|
||||||
|
ssl_context.verify_mode = ssl.CERT_NONE
|
||||||
|
s.starttls(context=ssl_context)
|
||||||
|
else:
|
||||||
|
s.starttls()
|
||||||
|
s.login(smtp_auth['smtp_user'], smtp_auth['smtp_pass'])
|
||||||
s.send_message(msg)
|
s.send_message(msg)
|
||||||
s.quit()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
self.logger.warning(msg.as_string())
|
self.logger.warning(msg.as_string())
|
||||||
|
|
Loading…
Reference in New Issue