| 1 | #!/usr/bin/env python3 |
| 2 |
|
| 3 | import random |
| 4 | import sys |
| 5 | import requests |
| 6 |
|
| 7 | WORDLIST = requests.get("https://www.mit.edu/~ecprice/wordlist.10000").text.split("\n") |
| 8 | random.seed() |
| 9 | random.shuffle(WORDLIST) |
| 10 |
|
| 11 | def password(): |
| 12 | random_words = [] |
| 13 | for x in range(0,4): |
| 14 | while True: |
| 15 | random.seed() |
| 16 | random_word = WORDLIST[random.randint(0, len(WORDLIST))] |
| 17 | if len(random_word) > 6: |
| 18 | random_words.append(random_word) |
| 19 | break |
| 20 | return " ".join(random_words) |
| 21 |
|
| 22 | if __name__ == "__main__": |
| 23 | count = 1 |
| 24 | if len(sys.argv) > 1: |
| 25 | if any( |
| 26 | help_arg in sys.argv[1:] |
| 27 | for help_arg in ["--help", "-help", "-h", "-?", "help", "h", "?"] |
| 28 | ): |
| 29 | print("Usage: ./passwdgen.py [count=1]") |
| 30 | sys.exit(0) |
| 31 | try: |
| 32 | count = int(sys.argv[1]) |
| 33 | except ValueError: |
| 34 | print("Supplied argument must be int [count]") |
| 35 | sys.exit(1) |
| 36 | print("Wordlist passwords:") |
| 37 | for i in range(count): |
| 38 | print(password()) |
| 39 |
|