diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/domains.txt b/domains.txt index 95f41aa..9e98e5e 100644 --- a/domains.txt +++ b/domains.txt @@ -22,4 +22,23 @@ stackshare.io # # Gitlab # -gitlab.com \ No newline at end of file +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 \ No newline at end of file diff --git a/ips.txt b/ips.txt index fba44e7..c513299 100644 --- a/ips.txt +++ b/ips.txt @@ -1,26 +1,32 @@ -192.229.221.58/32 -34.120.25.175/32 -104.198.14.52/32 -35.244.248.76/32 -172.65.251.78/32 -35.190.247.0/24 -64.233.160.0/19 -66.102.0.0/20 -66.249.80.0/20 -72.14.192.0/18 -74.125.0.0/16 -108.177.8.0/21 -173.194.0.0/16 -209.85.128.0/17 -216.58.192.0/19 -216.239.32.0/19 -172.217.0.0/19 -172.217.32.0/20 -172.217.128.0/19 -172.217.160.0/20 -172.217.192.0/19 -172.253.56.0/21 -172.253.112.0/20 -108.177.96.0/19 -35.191.0.0/16 -130.211.0.0/22 \ No newline at end of file +192.229.221.58/32 # us.download.nvidia.com +34.120.25.175/32 # habitica.com +104.198.14.52/32 # docs.nestjs.com, nestjs.com +35.244.248.76/32 # stackshare.io +172.65.251.78/32 # gitlab.com +34.120.177.193/32 # grafana.com +216.239.35.0/32 # time.google.com, time1.google.com +216.239.35.4/32 # time2.google.com +216.239.35.8/32 # time3.google.com +216.239.35.12/32 # time4.google.com +34.117.44.137/32 # chess.com +35.190.247.0/24 # google (spf) +64.233.160.0/19 # google (spf) +66.102.0.0/20 # google (spf) +66.249.80.0/20 # google (spf) +72.14.192.0/18 # google (spf) +74.125.0.0/16 # google (spf) +108.177.8.0/21 # google (spf) +173.194.0.0/16 # google (spf) +209.85.128.0/17 # google (spf) +216.58.192.0/19 # google (spf) +216.239.32.0/19 # google (spf) +172.217.0.0/19 # google (spf) +172.217.32.0/20 # google (spf) +172.217.128.0/19 # google (spf) +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) \ No newline at end of file diff --git a/runners/1_ips_from_domains_txt.py b/runners/1_ips_from_domains_txt.py new file mode 100644 index 0000000..6ff86e7 --- /dev/null +++ b/runners/1_ips_from_domains_txt.py @@ -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') \ No newline at end of file diff --git a/scripts/2_google_ips.py b/runners/2_google_ips.py similarity index 74% rename from scripts/2_google_ips.py rename to runners/2_google_ips.py index 338b9ac..632b05b 100644 --- a/scripts/2_google_ips.py +++ b/runners/2_google_ips.py @@ -1,4 +1,5 @@ import subprocess +from utils import prettyprint def resolve_by_spf(domain): output = subprocess.run(["nslookup", "-q=TXT", domain], capture_output=True) @@ -23,8 +24,9 @@ def resolve_by_spf(domain): 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: - for ip in ips: - out.write(ip + '\n') \ No newline at end of file + with open('ips.txt', 'a') as out: + for ip in ips: + out.write(prettyprint(ip, 'google (spf)') + '\n') diff --git a/runners/z_remove_duplicates.py b/runners/z_remove_duplicates.py new file mode 100644 index 0000000..b75cb0a --- /dev/null +++ b/runners/z_remove_duplicates.py @@ -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() \ No newline at end of file diff --git a/scripts/1_ips_from_domains_txt.py b/scripts/1_ips_from_domains_txt.py deleted file mode 100644 index a0d2b1a..0000000 --- a/scripts/1_ips_from_domains_txt.py +++ /dev/null @@ -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') \ No newline at end of file diff --git a/scripts/z_remove_duplicates.py b/scripts/z_remove_duplicates.py deleted file mode 100644 index 0367950..0000000 --- a/scripts/z_remove_duplicates.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/update.py b/update.py index 7d94aac..0a2073d 100644 --- a/update.py +++ b/update.py @@ -1,10 +1,21 @@ import glob +import importlib +import os import subprocess import sys -scripts = glob.glob("./scripts/*") -scripts.sort() +RUNNER_FOLDER = 'runners' +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: - print(script) - subprocess.call([sys.executable, script]) \ No newline at end of file + runner = importlib.import_module('.' + script[:3], package=__name__) + runner.main() +''' \ No newline at end of file diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..db362d1 --- /dev/null +++ b/utils.py @@ -0,0 +1,2 @@ +def prettyprint(ip, comment): + return ip.ljust(20) + ('# ' + comment if comment != '' else '') \ No newline at end of file