51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Builds app/assets/security/common-passwords.txt from SecLists (MIT).
|
|
|
|
Usage:
|
|
build-common-passwords.py <xato-1000000.txt> <german-top-100000.txt> <out.txt>
|
|
|
|
Inputs (SecLists commit 68bcd12457978649d41ae4f56e3b5d2db2b72560,
|
|
Passwords/Common-Credentials/):
|
|
xato-net-10-million-passwords-1000000.txt
|
|
Language-Specific/German_common-password-list-top-100000.txt
|
|
|
|
Rules: lowercase, trimmed, at least 10 code points (shorter ones are caught by
|
|
the length rule), printable, unique. First GERMAN_COUNT entries of the German
|
|
list (frequency order), then XATO_COUNT entries of the xato list.
|
|
"""
|
|
import sys
|
|
|
|
GERMAN_COUNT = 4000
|
|
XATO_COUNT = 6000
|
|
MIN_LENGTH = 10
|
|
|
|
|
|
def take(path, limit, seen):
|
|
out = []
|
|
with open(path, encoding="utf-8", errors="ignore") as handle:
|
|
for line in handle:
|
|
entry = line.strip().lower()
|
|
if (
|
|
len(entry) >= MIN_LENGTH
|
|
and entry.isprintable()
|
|
and not entry.startswith("#")
|
|
and entry not in seen
|
|
):
|
|
seen.add(entry)
|
|
out.append(entry)
|
|
if len(out) >= limit:
|
|
break
|
|
return out
|
|
|
|
|
|
def main():
|
|
xato, german, target = sys.argv[1:4]
|
|
seen = set()
|
|
entries = take(german, GERMAN_COUNT, seen) + take(xato, XATO_COUNT, seen)
|
|
with open(target, "w", encoding="utf-8", newline="\n") as handle:
|
|
handle.write("\n".join(entries) + "\n")
|
|
print(len(entries))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|