spf_dump
spf_dump copied to clipboard
Handling the redirect modifier
Thanks for this fine script - your work is highly appreciated!
If I read the code correctly the txt record is split into tokens which are then split into key value pairs using ":" as the separator. This construct seems mishandle the redirect modifier which uses the equality sign to set a value a la "redirect=
I don't know what the right way to fix this is, but I've done an ugly workaround rewriting any token match of "redirect=" to "redirect:":
$ diff -u spf_dump.py.orig spf_dump.py
--- spf_dump.py.orig Sat Feb 6 14:46:32 2016
+++ spf_dump.py Sat Feb 6 14:47:43 2016
@@ -37,6 +37,8 @@
ranges = []
record = dig(domain,"TXT",debug)
for token in record.split():
+ if token.startswith("redirect="):
+ token = token.replace("redirect=", "redirect:")
token = token.split(':',1)
if len(token) == 2:
key = token[0].lower()
@@ -87,4 +89,4 @@
for r in set(parsed):
print r
-
+
Even though unbeautiful it does the trick. Before diff:
$ dig +short -t TXT yandex.com
"v=spf1 redirect=_spf.yandex.ru"
$ ./spf_dump.py.orig yandex.com
$
After:
$ ./spf_dump.py yandex.com
5.45.192.0/19
37.140.128.0/18
2a02:6b8:b030::/64
2a02:6b8:0:1000::/52
213.180.223.192/26
2a02:6b8:b011:900::/56
2a02:6b8:b030:1000::/64
37.9.109.0/24
93.158.136.48/28
84.201.128.0/18
87.250.224.0/19
77.88.0.0/18
141.8.132.0/24
2a02:6b8:0:1a2d::/64
95.108.192.0/18
5.255.192.0/18
2a02:6b8:0::/52
95.108.130.0/23
2a02:6b8:0: