Skip to content

Commit 6875a54

Browse files
authored
Merge pull request #24 from MattKeeley/revert-23-dev
Revert "Merge pull request #22 from darcosion/main"
2 parents c4b72af + 9b08e7e commit 6875a54

File tree

3 files changed

+55
-142
lines changed

3 files changed

+55
-142
lines changed

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,3 @@ dmypy.json
130130

131131
# Pyre type checker
132132
.pyre/
133-
134-
# Xls files
135-
*.xls
136-
137-
# ignore mac os system extension
138-
.DS_Store

libs/logic-ori.py

Lines changed: 0 additions & 83 deletions
This file was deleted.

libs/logic.py

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
11
def is_spoofable(domain, p, aspf, spf_record, spf_all, spf_includes, sp, pct):
22
"""This function takes in DMARC and SPF data for a domain, as well as subdomain policy and percentage options,
3-
and determines if the domain is vulnerable to email spoofing. The function returns an integer value indicating
4-
the class of vulnerability.
5-
ID Handler:
6-
0: Indicates that spoofing is possible for the domain.
7-
1: Indicates that subdomain spoofing is possible for the domain.
8-
2: Indicates that organizational domain spoofing is possible for the domain.
9-
3: Indicates that spoofing might be possible for the domain.
10-
4: Indicates that spoofing might be possible (mailbox dependent) for the domain.
11-
5: Indicates that organizational domain spoofing may be possible for the domain.
12-
6: Indicates that subdomain spoofing might be possible (mailbox dependent) for the domain.
13-
7: Indicates that subdomain spoofing is possible, and organizational domain spoofing might be possible.
14-
8: Indicates that spoofing is not possible for the domain.
3+
and determines if the domain is vulnerable to email spoofing. The function returns an integer value indicating
4+
the class of vulnerability.
5+
ID Handler:
6+
0: Indicates that spoofing is possible for the domain.
7+
1: Indicates that subdomain spoofing is possible for the domain.
8+
2: Indicates that organizational domain spoofing is possible for the domain.
9+
3: Indicates that spoofing might be possible for the domain.
10+
4: Indicates that spoofing might be possible (mailbox dependent) for the domain.
11+
5: Indicates that organizational domain spoofing may be possible for the domain.
12+
6: Indicates that subdomain spoofing might be possible (mailbox dependent) for the domain.
13+
7: Indicates that subdomain spoofing is possible, and organizational domain spoofing might be possible.
14+
8: Indicates that spoofing is not possible for the domain.
1515
"""
1616
try:
1717
if pct and int(pct) != 100:
1818
return 3
1919
elif spf_record is None:
20-
return 0 if p is None else 8
20+
if p is None:
21+
return 0
22+
else:
23+
return 8
2124
elif spf_includes > 10 and p is None:
2225
return 0
2326
elif spf_all == "2many":
24-
return 3 if p == "none" else 8
27+
if p == "none":
28+
return 3
29+
else:
30+
return 8
2531
elif spf_all and p is None:
2632
return 0
2733
elif spf_all == "-all":
28-
if p == "none":
29-
if aspf == "r" and (sp == "reject" or sp == "quarantine"):
30-
return 2
31-
elif aspf is None and (sp == "reject" or sp == "quarantine"):
32-
return 5
33-
elif aspf is None and sp == "none":
34-
return 7
35-
elif (aspf == "r" or aspf is None) and sp is None:
36-
return 4
37-
else:
38-
return 8
39-
elif p and aspf and sp == "none":
34+
if p and aspf and sp == "none":
4035
return 1
4136
elif aspf is None and sp == "none":
4237
return 1
38+
elif p == "none" and (aspf == "r" or aspf is None) and sp is None:
39+
return 4
40+
elif p == "none" and aspf == "r" and (sp == "reject" or sp == "quarentine"):
41+
return 2
42+
elif p == "none" and aspf is None and (sp == "reject" or sp == "quarentine"):
43+
return 5
44+
elif p == "none" and aspf is None and sp == "none":
45+
return 7
4346
else:
4447
return 8
4548
elif spf_all == "~all":
46-
if p == "none":
47-
if sp == "reject" or sp == "quarantine":
48-
return 2
49-
elif sp is None:
50-
return 0
51-
elif sp == "none":
52-
return 7
53-
else:
54-
return 8
55-
elif (p == "reject" or p == "quarantine") and (aspf is None or aspf) and sp == "none":
49+
if p == "none" and sp == "reject" or sp == "quarentine":
50+
return 2
51+
elif p == "none" and sp is None:
52+
return 0
53+
elif p == "none" and sp == "none":
54+
return 7
55+
elif (p == "reject" or p == "quarentine") and aspf is None and sp == "none":
56+
return 1
57+
elif (p == "reject" or p == "quarentine") and aspf and sp == "none":
5658
return 1
5759
else:
5860
return 8
5961
elif spf_all == "?all":
60-
if p == "none":
61-
if (aspf == "r" or aspf is None) and sp is None:
62-
return 6
63-
elif aspf == "r" and sp == "none":
64-
return 7
65-
elif (aspf == "s" or aspf is None) and sp == "none":
66-
return 7
67-
elif aspf and (sp == "reject" or sp == "quarantine"):
68-
return 5
69-
elif aspf is None and sp == "reject":
70-
return 5
71-
else:
72-
return 8
73-
elif (p == "reject" or p == "quarantine") and (aspf is None or aspf) and sp == "none":
62+
if (p == "reject" or p == "quarentine") and aspf and sp == "none":
63+
return 6
64+
elif (p == "reject" or p == "quarentine") and aspf is None and sp == "none":
65+
return 6
66+
elif p == "none" and aspf == "r" and sp is None:
67+
return 0
68+
elif p == "none" and aspf == "r" and sp == "none":
69+
return 7
70+
elif p == "none" and aspf == "s" or None and sp == "none":
71+
return 7
72+
elif p == "none" and aspf == "s" or None and sp is None:
7473
return 6
74+
elif p == "none" and aspf and (sp == "reject" or sp == "quarentine"):
75+
return 5
76+
elif p == "none" and aspf is None and sp == "reject":
77+
return 5
7578
else:
7679
return 8
7780
else:
7881
return 8
79-
except Exception as e:
80-
print("An error occurred: ", e)
81-
print("Open an issue with your testcase.")
82+
except:
83+
print("If you hit this error message, Open an issue with your testcase.")

0 commit comments

Comments
 (0)