-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (47 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import configparser
from dmarc_analysis.analyzer import DMARCAnalyzer
from dmarc_analysis.downloader import EmailDownloader
# Load configuration
config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(__file__), 'config/config.ini'))
spamhaus_query_key = config.get('spamhaus', 'query_key')
spamhaus_domain = config.get('spamhaus', 'domain')
spamhaus_full_domain = f"{spamhaus_query_key}.{spamhaus_domain}"
imap_server = config.get('email', 'imap_server')
email_user = config.get('email', 'email_user')
email_pass = config.get('email', 'email_pass')
use_mfa = config.getboolean('email', 'use_mfa')
credentials_json = config.get('email', 'credentials_json')
token_json = config.get('email', 'token_json')
scopes = config.get('email', 'scopes')
redirect_uri = config.get('email', 'redirect_uri')
# Ask user if they want to download DMARC reports from email
download_from_email = input("Do you want to download DMARC reports from an email account? (yes/no): ").strip().lower()
if download_from_email == 'yes':
download_dir = 'dmarc_check'
os.makedirs(download_dir, exist_ok=True)
if use_mfa:
email_downloader = EmailDownloader(
imap_server,
email_user,
save_dir=download_dir,
use_mfa=use_mfa,
credentials_json=credentials_json,
token_json=token_json,
scopes=scopes,
redirect_uri=redirect_uri
)
else:
email_downloader = EmailDownloader(
imap_server,
email_user,
email_pass,
save_dir=download_dir,
use_mfa=use_mfa
)
email_downloader.download_attachments()
# Analyze DMARC reports
directory = 'dmarc_check'
dmarc_analyzer = DMARCAnalyzer(directory, spamhaus_full_domain)
dmarc_analyzer.analyze_reports()