From a807b887daeb95ad1a9a104901f5b9b47dd906da Mon Sep 17 00:00:00 2001 From: Krypton Date: Fri, 6 Oct 2023 08:49:00 +0200 Subject: [PATCH] feat: Add automatic TLD updater (#10) --- .github/workflows/update-tlds-list.yml | 35 ++++++++++++++++++++++++++ tools/make_tld_list.py | 21 ++++++++++++++++ tools/requirements.txt | 1 + 3 files changed, 57 insertions(+) create mode 100644 .github/workflows/update-tlds-list.yml create mode 100644 tools/make_tld_list.py create mode 100644 tools/requirements.txt diff --git a/.github/workflows/update-tlds-list.yml b/.github/workflows/update-tlds-list.yml new file mode 100644 index 0000000..81fd0cf --- /dev/null +++ b/.github/workflows/update-tlds-list.yml @@ -0,0 +1,35 @@ +name: Update TLDs list + +on: + schedule: + - cron: "0 */12 * * *" + workflow_dispatch: + +jobs: + update_tlds_list: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.PAT }} + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install Python packages + run: | + python -m pip install --upgrade pip + pip install -r tools/requirements.txt + - name: Make README file + run: python tools/make_tld_list.py + - name: Check if there are any changes + id: verify_diff + run: | + git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT + - name: Update README file + if: steps.verify_diff.outputs.changed == 'true' + run: | + git config --global user.name 'Krypton' + git config --global user.email 'root@krypton.ninja' + git commit -am "chore: TLDs list update of `date +'%Y-%m-%d %H:%M:%S'` [skip ci]" + git push diff --git a/tools/make_tld_list.py b/tools/make_tld_list.py new file mode 100644 index 0000000..a494fec --- /dev/null +++ b/tools/make_tld_list.py @@ -0,0 +1,21 @@ +import requests + + +def get_content(url: str) -> str: + response = requests.get( + url=url, + headers={ + "User-Agent": "Krypton's Wordlists (https://github.com/kkrypt0nn/wordlists)" + }, + ) + return response.text + + +def main() -> None: + content = get_content("https://data.iana.org/TLD/tlds-alpha-by-domain.txt") + with open("./wordlists/discovery/tlds.txt", "w+", encoding="utf-8") as manuf_file: + manuf_file.write(content) + + +if __name__ == "__main__": + main() diff --git a/tools/requirements.txt b/tools/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/tools/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file