Created
April 23, 2017 11:28
-
-
Save OwenChia/d5a7ac0f09e493c5b26e19f5e1604323 to your computer and use it in GitHub Desktop.
wordlist generator
This file contains hidden or 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
| #! /usr/bin/env hy | |
| (import argparse) | |
| (import lzma) | |
| ;; (import [pathlib [Path]]) | |
| (import [string [printable]]) | |
| ;; 36 for [0-9a-z] | |
| (def *default-charset* (get printable (slice None 36))) | |
| (def *args* (let [parse (.ArgumentParser argparse)] | |
| (.add_argument parse "-s" "--charset" :default *default-charset*) | |
| (.add_argument parse "--nmin" :default 1 :type int) | |
| (.add_argument parse "-n" "--nmax" :default 2 :type int) | |
| ;; (.add_argument parse "-o" "--output-file" :default "wordlist.lzma" :type Path) | |
| (.add_argument parse "-o" "--output-file" :default "wordlist.lzma") | |
| (.parse_args parse))) | |
| (defn wordlist-generator [cs nmin nmax] | |
| (reduce chain (genexpr | |
| (genexpr | |
| (.join "" x) | |
| [x (product cs :repeat n)]) | |
| [n (range nmin (inc nmax))]))) | |
| (defn write-to-compressed-file [data file] | |
| (with [fd (.open lzma file | |
| :mode "wt" | |
| :format (. lzma FORMAT_ALONE))] | |
| (.write fd data))) | |
| (defmain [&rest _] | |
| (setv wordlist (wordlist-generator | |
| (. *args* charset) | |
| (. *args* nmin) | |
| (. *args* nmax))) | |
| (write-to-compressed-file (.join "\n" wordlist) | |
| (. *args* output-file)) | |
| 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment