words.go (1760B)
1 package main 2 3 import ( 4 "fmt" 5 "strings" 6 "bufio" 7 "os" 8 ) 9 10 func get_per(a int, b int) float64 { 11 12 return float64(a)/float64(b)*100.0 13 } 14 15 func deleet(str1 string) string { 16 17 str2 := strings.ReplaceAll(str1, "3", "e") 18 str3 := strings.ReplaceAll(str2, "@", "a") 19 str4 := strings.ReplaceAll(str3, "1", "i") 20 str5 := strings.ReplaceAll(str4, "4", "a") 21 str6 := strings.ReplaceAll(str5, "0", "o") 22 str7 := strings.ReplaceAll(str6, "9", "g") 23 str8 := strings.ReplaceAll(str7, "6", "b") 24 25 str9 := strings.ToLower(str8) 26 27 return str9 28 } 29 30 func words_test(pass string, file string) { 31 32 pass1 := deleet(pass) 33 34 f, err := os.Open(file) 35 36 if err != nil { 37 fmt.Fprintln(os.Stderr, err) 38 os.Exit(1) 39 } 40 41 fScanner := bufio.NewScanner(f) 42 43 fScanner.Split(bufio.ScanLines) 44 45 var found bool 46 for fScanner.Scan() { 47 line := fScanner.Text() 48 if (len(line) >= 3 && strings.Contains(pass1, line)) { 49 perc := get_per(len(line), len(pass1)) 50 if (perc == 100.0) { 51 fmt.Printf(RED + "[!] Password is dictionary word - %.1f%% - ", perc) 52 } else if (perc >= 70.0) { 53 fmt.Printf(RED + "[!] Password contains dictionary word - %.1f%% - ", perc) 54 } else if (perc >= 35.0) { 55 fmt.Printf(YEL + "[-] Password contains dictionary word - %.1f%% - ", perc) 56 } else { 57 fmt.Printf(BLUE + "[~] Password contains dictionary word - %.1f%% - ", perc) 58 } 59 fmt.Printf(RESET + "%s : %s\n", file, line) 60 found = true 61 } 62 } 63 64 if (found) { 65 fmt.Printf(" The above is not necessarily an issue if your password\n") 66 fmt.Printf(" contains multiple distinct dictionary words, or if the\n") 67 fmt.Printf(" words are a small part of the password\n"); 68 } else { 69 fmt.Printf(GREEN + "[+] Password does not contain words from " + RESET +"%s\n", file) 70 } 71 72 f.Close() 73 }