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

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

160
.gitignore vendored Normal file
View File

@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

View File

@ -23,3 +23,22 @@ stackshare.io
# Gitlab # Gitlab
# #
gitlab.com gitlab.com
#
# Grafana
#
grafana.com
#
# NTP сервера Google
#
time.google.com
time1.google.com
time2.google.com
time3.google.com
time4.google.com
#
# chess.com
#
chess.com

58
ips.txt
View File

@ -1,26 +1,32 @@
192.229.221.58/32 192.229.221.58/32 # us.download.nvidia.com
34.120.25.175/32 34.120.25.175/32 # habitica.com
104.198.14.52/32 104.198.14.52/32 # docs.nestjs.com, nestjs.com
35.244.248.76/32 35.244.248.76/32 # stackshare.io
172.65.251.78/32 172.65.251.78/32 # gitlab.com
35.190.247.0/24 34.120.177.193/32 # grafana.com
64.233.160.0/19 216.239.35.0/32 # time.google.com, time1.google.com
66.102.0.0/20 216.239.35.4/32 # time2.google.com
66.249.80.0/20 216.239.35.8/32 # time3.google.com
72.14.192.0/18 216.239.35.12/32 # time4.google.com
74.125.0.0/16 34.117.44.137/32 # chess.com
108.177.8.0/21 35.190.247.0/24 # google (spf)
173.194.0.0/16 64.233.160.0/19 # google (spf)
209.85.128.0/17 66.102.0.0/20 # google (spf)
216.58.192.0/19 66.249.80.0/20 # google (spf)
216.239.32.0/19 72.14.192.0/18 # google (spf)
172.217.0.0/19 74.125.0.0/16 # google (spf)
172.217.32.0/20 108.177.8.0/21 # google (spf)
172.217.128.0/19 173.194.0.0/16 # google (spf)
172.217.160.0/20 209.85.128.0/17 # google (spf)
172.217.192.0/19 216.58.192.0/19 # google (spf)
172.253.56.0/21 216.239.32.0/19 # google (spf)
172.253.112.0/20 172.217.0.0/19 # google (spf)
108.177.96.0/19 172.217.32.0/20 # google (spf)
35.191.0.0/16 172.217.128.0/19 # google (spf)
130.211.0.0/22 172.217.160.0/20 # google (spf)
172.217.192.0/19 # google (spf)
172.253.56.0/21 # google (spf)
172.253.112.0/20 # google (spf)
108.177.96.0/19 # google (spf)
35.191.0.0/16 # google (spf)
130.211.0.0/22 # google (spf)

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')

View File

@ -1,4 +1,5 @@
import subprocess import subprocess
from utils import prettyprint
def resolve_by_spf(domain): def resolve_by_spf(domain):
output = subprocess.run(["nslookup", "-q=TXT", domain], capture_output=True) output = subprocess.run(["nslookup", "-q=TXT", domain], capture_output=True)
@ -23,8 +24,9 @@ def resolve_by_spf(domain):
return list(dict.fromkeys(result)) return list(dict.fromkeys(result))
ips = resolve_by_spf("_spf.google.com") def main():
ips = resolve_by_spf("_spf.google.com")
with open('ips.txt', 'a') as out: with open('ips.txt', 'a') as out:
for ip in ips: for ip in ips:
out.write(ip + '\n') 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()

View File

@ -1,17 +0,0 @@
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) + '/32')
ips = list(dict.fromkeys(ips))
for ip in ips:
out.write(ip + '\n')

View File

@ -1,7 +0,0 @@
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()

View File

@ -1,10 +1,21 @@
import glob import glob
import importlib
import os
import subprocess import subprocess
import sys import sys
scripts = glob.glob("./scripts/*") RUNNER_FOLDER = 'runners'
scripts.sort()
scripts = glob.glob(f"./{RUNNER_FOLDER}/*.py")
scripts.sort()
modules = [os.path.basename(x)[:-3] for x in scripts]
for m in modules:
runner = importlib.import_module('.' + m, package=RUNNER_FOLDER)
runner.main()
'''
for script in scripts: for script in scripts:
print(script) runner = importlib.import_module('.' + script[:3], package=__name__)
subprocess.call([sys.executable, script]) runner.main()
'''

2
utils.py Normal file
View File

@ -0,0 +1,2 @@
def prettyprint(ip, comment):
return ip.ljust(20) + ('# ' + comment if comment != '' else '')