Created
November 4, 2019 01:31
-
-
Save rarecoil/8a1aff617c1f30fa7b3697c5011f3aa5 to your computer and use it in GitHub Desktop.
Generate hashcat masks in a multithreaded fashion from a password list.
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
"runtime" | |
"strings" | |
"github.com/chrislusf/glow/flow" | |
) | |
var patterns = map[string]string{ | |
"?l": "etaoinshrdlcumwfgypbvkjxqz", | |
"?L": "ETAOINSHRDLCUMWFGYPBVKJXQZ", | |
"?d": "0123456789", | |
"?t": "~!@#$%^&*()_+", | |
"?c": "`[];',./-=\\ ", | |
"?C": ":\"<>?|{}", | |
} | |
func generateMask(password string) string { | |
var found bool | |
var mask string | |
for _, lrune := range password { | |
for patkey, pat := range patterns { | |
found = false | |
for _, prune := range pat { | |
if prune == lrune { | |
mask = mask + patkey | |
found = true | |
break | |
} | |
} | |
if found == true { | |
break | |
} | |
} | |
} | |
return mask | |
} | |
func main() { | |
outputFilePtr := flag.String("output", "./output.hcmask", "Path to output file.") | |
inputFilePtr := flag.String("input", "", "Path to input file.") | |
processesNumPtr := flag.Int("processes", runtime.NumCPU(), "Number of processes to use.") | |
flag.Parse() | |
if *inputFilePtr == "" { | |
log.Fatal("Input file required") | |
} | |
outputFile, err := os.OpenFile(*outputFilePtr, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) | |
if err != nil { | |
log.Fatal("Could not open output file") | |
} | |
defer outputFile.Close() | |
flow.New().TextFile( | |
*inputFilePtr, *processesNumPtr, | |
).Map(func(line string, ch chan string) { | |
password := strings.TrimSpace(line) | |
if password != "" { | |
ch <- generateMask(password) | |
} | |
}).Map(func(mask string) { | |
outputFile.WriteString(fmt.Sprintf("%s\n", mask)) | |
}).Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment