-
-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Generate JSON file with the wordlists
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Update JSON file | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update_readme_file: | ||
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: Make JSON file | ||
run: python tools/make_json.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 '[email protected]' | ||
git commit -am "chore: Automatic wordlists.json file update with accurate wordlists [skip ci]" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# This code is bad, I even lost myself in it - but it works 😎 🤓 | ||
|
||
import glob | ||
import json | ||
import os | ||
import re | ||
|
||
|
||
keywords = { | ||
"Sql": "SQL", | ||
"Jsp": "JSP", | ||
"Lfi": "LFI", | ||
"Tlds": "TLDs", | ||
"Wp": "WP", | ||
"Vpn": "VPN", | ||
"Wpa": "WPA", | ||
"Us": "US", | ||
"Uri": "URI", | ||
"Http": "HTTP", | ||
"Os": "OS", | ||
"Beos": "BeOS", | ||
"Chromeos": "ChromeOS", | ||
"Ios": "iOS", | ||
"Hp": "HP", | ||
"Openbsd": "OpenBSD", | ||
"Sunos": "SunOS", | ||
"Webos": "webOS", | ||
"Itunes": "iTunes", | ||
"Xml": "XML", | ||
"Xss": "XSS", | ||
} | ||
|
||
|
||
class Wordlist: | ||
def __init__(self, name: str, href: str, lines: int, tags: list[type[str]]): | ||
self.name = name | ||
self.href = href | ||
self.lines = lines | ||
self.tags = tags | ||
|
||
|
||
wordlists: list[type[Wordlist]] = [] | ||
|
||
for filename in glob.iglob("./wordlists/**/*", recursive=True): | ||
if os.path.isdir(filename): | ||
continue | ||
|
||
rel_path = os.path.relpath(filename) | ||
levels = rel_path.split(os.sep) | ||
folders = levels[1 : len(levels) - 1] | ||
name = levels[len(levels) - 1] | ||
name = name[: len(name) - 4].replace("_", " ").title() | ||
|
||
for keyword in keywords: | ||
name = re.sub(rf"\b{keyword}\b", keywords[keyword], name) | ||
|
||
href = "/".join(levels) | ||
|
||
lines = 0 | ||
if name == "Rockyou": # Can't count correctly for that one as it's a ZIP file | ||
lines = 14344392 | ||
else: | ||
with open(rel_path, "rb") as f: | ||
lines = sum(1 for _ in f) | ||
|
||
tags: list[type[str]] = [] | ||
for folder in folders: | ||
tags.append(folder.replace("_", "-")) | ||
|
||
wordlist = Wordlist(name, href, lines, tags) | ||
wordlists.append(wordlist) | ||
|
||
with open("wordlists.json", "w", encoding="utf-8") as f: | ||
f.write( | ||
json.dumps( | ||
[wordlist.__dict__ for wordlist in sorted(wordlists, key=lambda w: w.name)], | ||
sort_keys=True, | ||
indent=4, | ||
) | ||
) |