mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2024-11-21 10:01:38 +01:00
Universal output coloring with colorama, fixed domain extraction bug in testDomainImpersonation
This commit is contained in:
parent
878f19a4a3
commit
08583758b0
@ -110,7 +110,7 @@
|
|||||||
# - tldextract
|
# - tldextract
|
||||||
# - packaging
|
# - packaging
|
||||||
# - dnspython
|
# - dnspython
|
||||||
# - requests
|
# - colorama
|
||||||
#
|
#
|
||||||
# Mariusz Banach / mgeeky, '21-'22
|
# Mariusz Banach / mgeeky, '21-'22
|
||||||
# <mb [at] binary-offensive.com>
|
# <mb [at] binary-offensive.com>
|
||||||
@ -123,6 +123,7 @@ import json
|
|||||||
import textwrap
|
import textwrap
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import atexit
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
from html import escape
|
from html import escape
|
||||||
@ -139,6 +140,15 @@ except ImportError:
|
|||||||
''')
|
''')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import colorama
|
||||||
|
except ImportError:
|
||||||
|
print('''
|
||||||
|
[!] You need to install colorama:
|
||||||
|
# pip3 install colorama
|
||||||
|
''')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import packaging.version
|
import packaging.version
|
||||||
|
|
||||||
@ -181,6 +191,7 @@ except ImportError:
|
|||||||
''')
|
''')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
colorama.init()
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
'debug': False,
|
'debug': False,
|
||||||
@ -217,7 +228,6 @@ class Logger:
|
|||||||
|
|
||||||
colors_dict = {
|
colors_dict = {
|
||||||
'error': colors_map['red'],
|
'error': colors_map['red'],
|
||||||
'trace': colors_map['magenta'],
|
|
||||||
'info ': colors_map['green'],
|
'info ': colors_map['green'],
|
||||||
'debug': colors_map['grey'],
|
'debug': colors_map['grey'],
|
||||||
'other': colors_map['grey'],
|
'other': colors_map['grey'],
|
||||||
@ -4405,8 +4415,9 @@ Src: https://www.cisco.com/c/en/us/td/docs/security/esa/esa11-1/user_guide/b_ESA
|
|||||||
if len(m.groups()) < 2:
|
if len(m.groups()) < 2:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
username = m.group(1)
|
username = m.group(1).replace('<', '')
|
||||||
domain = m.group(2)
|
domain = m.group(2).replace('>', '')
|
||||||
|
|
||||||
email = f'{username}@{domain}'
|
email = f'{username}@{domain}'
|
||||||
|
|
||||||
firstHop = self.received_path[1]
|
firstHop = self.received_path[1]
|
||||||
@ -4451,11 +4462,21 @@ Src: https://www.cisco.com/c/en/us/td/docs/security/esa/esa11-1/user_guide/b_ESA
|
|||||||
result += f'\t (first hop\'s domain: {self.logger.colored(firstHopDomain1, "cyan")})\n\n'
|
result += f'\t (first hop\'s domain: {self.logger.colored(firstHopDomain1, "cyan")})\n\n'
|
||||||
|
|
||||||
if firstHopDomain1.lower() != senderDomain.lower():
|
if firstHopDomain1.lower() != senderDomain.lower():
|
||||||
response = None
|
response = []
|
||||||
try:
|
try:
|
||||||
if domain.endswith('.'): domain = domain[:-1]
|
if domain.endswith('.'):
|
||||||
|
domain = domain[:-1]
|
||||||
response = dns.resolver.resolve(domain, 'TXT')
|
response = dns.resolver.resolve(domain, 'TXT')
|
||||||
|
|
||||||
|
except dns.resolver.NoAnswer as e:
|
||||||
|
response = []
|
||||||
|
|
||||||
|
except dns.resolver.NoNameservers as e:
|
||||||
|
response = []
|
||||||
|
|
||||||
|
except AttributeError as e:
|
||||||
|
response = []
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
response = []
|
response = []
|
||||||
|
|
||||||
@ -6517,3 +6538,9 @@ Use -N flag to disable console colors, or switch your console for better UI expe
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
@atexit.register
|
||||||
|
def goodbye():
|
||||||
|
colorama.deinit()
|
||||||
|
|
||||||
|
@ -2,4 +2,5 @@ python-dateutil
|
|||||||
tldextract
|
tldextract
|
||||||
packaging
|
packaging
|
||||||
dnspython
|
dnspython
|
||||||
requests
|
requests
|
||||||
|
colorama
|
Loading…
Reference in New Issue
Block a user