делает несколько правок

- добавляет комментарии к IP
- добавляет Grafana, NTP сервера Google, chess.com
- меняет логику запуска скриптов
This commit is contained in:
2022-09-15 17:54:30 +03:00
parent 33974cab70
commit 256f70e951
10 changed files with 264 additions and 59 deletions

View File

@@ -0,0 +1,21 @@
import socket
from collections import defaultdict
from utils import prettyprint
ips = []
dict = defaultdict(list)
def main():
with open('ips.txt', 'w') as out:
for line in open('domains.txt'):
l = line.strip()
if l.startswith('#') or l == '':
continue
dict[socket.gethostbyname(l) + '/32'].append(l)
ips = list(dict.keys())
for ip in ips:
out.write(prettyprint(ip, ', '.join(dict[ip])) + '\n')

32
runners/2_google_ips.py Normal file
View File

@@ -0,0 +1,32 @@
import subprocess
from utils import prettyprint
def resolve_by_spf(domain):
output = subprocess.run(["nslookup", "-q=TXT", domain], capture_output=True)
lines = output.stdout.decode().split('\n')
result = []
for line in lines:
res = line.find('v=spf')
if res == -1:
continue
values = line[res:].split()
for val in values:
if val.startswith("include:"):
result += resolve_by_spf(val[8:].strip())
if val.startswith("ip4:"):
result.append(val[4:].strip())
return list(dict.fromkeys(result))
def main():
ips = resolve_by_spf("_spf.google.com")
with open('ips.txt', 'a') as out:
for ip in ips:
out.write(prettyprint(ip, 'google (spf)') + '\n')

View File

@@ -0,0 +1,8 @@
def main():
inp = open('ips.txt', 'r')
uniqlines = list(dict.fromkeys(inp.readlines()))
inp.close()
out = open('ips.txt', 'w')
out.writelines(uniqlines)
out.truncate(out.tell()-1)
out.close()