masks.go (3488B)
1 package main 2 3 import ( 4 "fmt" 5 "regexp" 6 ) 7 8 func must_match(regex string, pass string) bool { 9 match, _ := regexp.MatchString(regex, pass) 10 return match 11 } 12 13 14 func mask_test(pass string) { // according to pipal 15 16 str := " Password matches common mask " 17 var found bool 18 19 if (must_match("^[A-Za-z]{1,}$", pass)) { 20 fmt.Printf(RED + "[!]" + str + "^alpha{1,}$ (only letters)\n" + RESET) 21 found = true 22 } 23 24 if (must_match("^[0-9]{1,}$", pass)) { 25 fmt.Printf(RED + "[!]" + str + "^num{1,}$ (only numbers)\n" + RESET) 26 found = true 27 } 28 29 if (must_match("^[A-Za-z]{1,}[0-9]{1,}$", pass)) { 30 fmt.Printf(YEL + "[-]" + str + "^alpha{1,}num{1,}$\n" + RESET) 31 found = true 32 } 33 34 if (must_match("^[0-9]{1,}[A-Za-z]{1,}$", pass)) { 35 fmt.Printf(YEL + "[-]" + str + "^num{1,}alpha{1,}$\n" + RESET) 36 found = true 37 } 38 39 if (must_match("^[0-9]{1,}[^A-Za-z0-9]{1,}$", pass)) { 40 fmt.Printf(YEL + "[-]" + str + "^num{1,}symbol{1,}$\n" + RESET) 41 found = true 42 } 43 44 if (must_match("^[A-Za-z]{1,}[0-9]{1,}[^A-Za-z0-9]{1,}$", pass)) { 45 fmt.Printf(YEL + "[-]" + str + "^alpha{1,}num{1,}symbol{1,}$\n" + RESET) 46 found = true 47 } 48 49 if (must_match("[^A-Za-z0-9]{1,}$", pass)) { 50 fmt.Printf(BLUE + "[~]" + str + "any{1,}symbol{1,}$\n" + RESET) 51 found = true 52 } 53 54 if (must_match("^[A-Za-z]{1,}\\.[0-9]{1,}$", pass)) { 55 fmt.Printf(BLUE + "[~]" + str + "^letter{1,}\\.num{1,}$\n" + RESET) 56 found = true 57 } 58 59 if (must_match("^[0-9]{1,}\\.[A-Za-z]{1,}$", pass)) { 60 fmt.Printf(BLUE + "[~]" + str + "^num{1,}\\.char{1,}$\n" + RESET) 61 found = true 62 } 63 64 if (must_match("^[0-9]{1,}\\.[^A-Za-z0-9]{1,}$", pass)) { 65 fmt.Printf(BLUE + "[~]" + str + "^num{1,}\\.symbol{1,}$\n" + RESET) 66 found = true 67 } 68 69 if (must_match("^[^A-Za-z0-9]{1,}\\.[0-9]{1,}$", pass)) { 70 fmt.Printf(BLUE + "[~]" + str + "^num{1,}\\.symbol{1,}$\n" + RESET) 71 found = true 72 } 73 74 if (must_match("^[A-Za-z]{1,}123$", pass)) { 75 fmt.Printf(YEL + "[-]" + str + "^alpha{1,}123$\n" + RESET) 76 found = true 77 } 78 79 if (must_match("[A-Za-z]{1,}1$", pass)) { 80 fmt.Printf(BLUE + "[~]" + str + "*1$\n" + RESET) 81 found = true 82 } 83 84 if (must_match("123$", pass)) { 85 fmt.Printf(BLUE + "[~]" + str + "*123$\n" + RESET) 86 found = true 87 } 88 89 if (!found) { 90 fmt.Printf(GREEN + "[+] Password does not match any common mask\n" + RESET) 91 } 92 } 93 94 func popular_characters_test(pass string) { //according to lykan 95 96 var found bool 97 98 if (must_match("^[^A-Za-z]*[Aa][^A-Za-z]*$", pass)) { 99 fmt.Printf(YEL + "[-] Passowrd's only letter is the most common letter in passwords\n" + RESET) 100 found = true 101 } 102 103 if (must_match("^[^A-Za-z]*[Ee][^A-Za-z]*$", pass)) { 104 fmt.Printf(YEL + "[-] Passowrd's only letter is the second most common letter in passwords\n" + RESET) 105 found = true 106 } 107 108 if (must_match("^[^0-9]*1[^0-9]*$", pass)) { 109 fmt.Printf(YEL + "[-] Passowrd's only number is the most common number in passwords\n" + RESET) 110 found = true 111 } 112 113 if (must_match("^[^0-9]*0[^0-9]*$", pass)) { 114 fmt.Printf(YEL + "[-] Passowrd's only number is the second most common number in passwords\n" + RESET) 115 found = true 116 } 117 118 if (must_match("^[A-Za-z0-9]*\\.[A-Za-z0-9]*$", pass)) { 119 fmt.Printf(YEL + "[-] Passowrd's only symbol is the most common symbol in passwords\n" + RESET) 120 found = true 121 } 122 123 if (must_match("^[A-Za-z0-9]*-[A-Za-z0-9]*$", pass)) { 124 fmt.Printf(YEL + "[-] Passowrd's only symbol is the second most common symbol in passwords\n" + RESET) 125 found = true 126 } 127 128 if (!found) { 129 fmt.Printf(GREEN + "[+] Password does not overuse popular characters\n" + RESET) 130 } 131 }