Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion privacyscanner/scanmodules/testsslsh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ class TestsslshMailScanModule(TestsslshScanModuleBase):
target_parameters = [Parameter.STARTTLS, 'smtp']

def _get_host(self, result):
return result['mail']['domain'] + ':25'
host = result['mail']['domain']
try:
mailhost = result['dns'][host]['MX'][0]['host'] # might raise a keyerror on domains without an MX record
resolved = result['dns'][mailhost].get('A', None)
if not resolved or len(resolved) == 0: # fallback to ipv6 mailserver
resolved = result['dns'][mailhost].get('AAAA', None)
return resolved[0]['ip'] + ':25'
except KeyError:
return result['mail']['domain'] + ':25'

def _can_run(self, result):
# If the mail host is not reachable, the has_starttls key is
Expand Down