feat: Add automatic TLD updater (#10)
This commit is contained in:
35
.github/workflows/update-tlds-list.yml
vendored
Normal file
35
.github/workflows/update-tlds-list.yml
vendored
Normal file
@@ -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
|
||||||
21
tools/make_tld_list.py
vendored
Normal file
21
tools/make_tld_list.py
vendored
Normal file
@@ -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()
|
||||||
1
tools/requirements.txt
vendored
Normal file
1
tools/requirements.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
requests
|
||||||
Reference in New Issue
Block a user