стартует проект
This commit is contained in:
17
scripts/1_ips_from_domains_txt.py
Normal file
17
scripts/1_ips_from_domains_txt.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import socket
|
||||
|
||||
ips = []
|
||||
|
||||
with open('ips.txt', 'w') as out:
|
||||
for line in open('domains.txt'):
|
||||
l = line.strip()
|
||||
|
||||
if l.startswith('#') or l == '':
|
||||
continue
|
||||
|
||||
ips.append(socket.gethostbyname(l))
|
||||
|
||||
ips = list(dict.fromkeys(ips))
|
||||
|
||||
for ip in ips:
|
||||
out.write(ip + '\n')
|
30
scripts/2_google_ips.py
Normal file
30
scripts/2_google_ips.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import subprocess
|
||||
|
||||
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))
|
||||
|
||||
ips = resolve_by_spf("_spf.google.com")
|
||||
|
||||
with open('ips.txt', 'a') as out:
|
||||
for ip in ips:
|
||||
out.write(ip + '\n')
|
7
scripts/z_remove_duplicates.py
Normal file
7
scripts/z_remove_duplicates.py
Normal file
@@ -0,0 +1,7 @@
|
||||
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()
|
Reference in New Issue
Block a user