commit 3c95e159b0412ea946ace8ab53c40270ca5d1f9c
Author: Michael Constantine Dimopoulos <mk@mcdim.xyz>
Date: Wed, 22 Jun 2022 14:17:52 +0000
Updated src
Diffstat:
| A | src/Makefile | | | 9 | +++++++++ |
| A | src/charset.go | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/length.go | | | 21 | +++++++++++++++++++++ |
| A | src/passcheck.go | | | 83 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | src/words.go | | | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 files changed, 239 insertions(+), 0 deletions(-)
diff --git a/src/Makefile b/src/Makefile
@@ -0,0 +1,9 @@
+build:
+ go build -o passcheck *.go
+
+install:
+ go build -o passcheck *.go
+ sudo mv passcheck /bin
+
+uninstall:
+ rm /bin/passcheck
diff --git a/src/charset.go b/src/charset.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "fmt"
+ "unicode"
+)
+
+func charset_test(pass string) {
+
+ let := false
+ upp := false
+ low := false
+ num := false
+ sym := false
+
+ for _, r := range pass {
+
+ if (unicode.IsDigit(rune(r))) {
+ num = true
+ }
+
+ if (unicode.IsLetter(rune(r))) {
+ let = true
+
+ if (unicode.IsUpper(r)) {
+ upp = true
+ } else {
+ low = true
+ }
+ }
+
+ if (unicode.IsSymbol(rune(r))) {
+ sym = true
+ }
+ }
+
+ if (num == true) {
+ fmt.Printf(GREEN + "[+] Your password includes numbers\n" + RESET);
+ } else {
+ fmt.Printf(RED + "[!] Your password doesn't include numbers\n" + RESET);
+ }
+
+ if (sym == true) {
+ fmt.Printf(GREEN + "[+] Your password includes special symbols\n" + RESET);
+ } else {
+ fmt.Printf(RED + "[!] Your password doesn't include special symbols\n" + RESET);
+ }
+
+ if (let == true) {
+ fmt.Printf(GREEN + "[+] Your password includes letters\n" + RESET);
+
+ if (upp == true) {
+ fmt.Printf(GREEN + " [+] includes upper case letters\n" + RESET);
+ } else {
+ fmt.Printf(RED + " [!] doesn't include upper case letters\n" + RESET);
+ }
+
+ if (low == true) {
+ fmt.Printf(GREEN + " [+] includes lower case letters\n" + RESET);
+ } else {
+ fmt.Printf(RED + " [!] doesn't include lower case letters\n" + RESET);
+ }
+
+ } else {
+ fmt.Printf(RED + "[!] Your password doesn't include letters\n" + RESET);
+ }
+
+}
diff --git a/src/length.go b/src/length.go
@@ -0,0 +1,21 @@
+package main
+
+import "fmt"
+
+func length_test(pass string) {
+
+ length := len(pass);
+ fmt.Printf("Length: %d\n", length);
+
+ if (length <= 7) {
+ fmt.Printf(RED + "[!] Your password is very short! " + RESET);
+ fmt.Printf("It is vulnerable to a pure bruteforce attack\n");
+ } else if (length <= 10) {
+ fmt.Printf(RED + "[!] Your password is short. " + RESET);
+ fmt.Printf("It is vulnerable to a pure bruteforce attack\n");
+ } else if (length <= 20) {
+ fmt.Printf(GREEN + "[+] Your password is pretty long.\n" + RESET);
+ } else if (length <= 30) {
+ fmt.Printf(GREEN +"[+] Your password is very long!\n" + RESET);
+ }
+}
diff --git a/src/passcheck.go b/src/passcheck.go
@@ -0,0 +1,83 @@
+package main
+
+import "fmt"
+import "os"
+
+
+var version string = "v0.1"
+
+var RED string = "\x1b[31m"
+var YEL string = "\u001b[33m"
+var GREEN string = "\033[0;32m"
+var RESET string = "\x1b[0m"
+
+
+func help(bin string) {
+ fmt.Printf("Passcheck %s\n", version);
+ fmt.Printf("goPasscheck is a smart password analysis tool\n");
+ fmt.Printf(" -p, password argument\n");
+ fmt.Printf(" -w, words file argument\n");
+ fmt.Printf(" -h, print this panel and exit\n");
+ fmt.Printf(" -v, print version and exit\n");
+ fmt.Printf("usage: %s [password] | -h | -v\n", bin);
+ os.Exit(0)
+}
+
+func print_version() {
+ fmt.Printf("gopasscheck-%s\n", version);
+ os.Exit(0)
+}
+
+func usage(bin string) {
+ fmt.Fprintf(os.Stderr, "usage: %s [password] | -h | -v\n", os.Args[0]);
+ os.Exit(1)
+}
+
+func main() {
+
+ bin := os.Args[0]
+
+ if (len(os.Args) == 1) {
+ usage(bin)
+ }
+
+ if (os.Args[1] == "-h") { help(bin); }
+ if (os.Args[1] == "-v") { print_version(); }
+
+ var words string = ""
+ var pass string = ""
+ for i := 0; i < len(os.Args); i++ {
+ if (os.Args[i] == "-w") {
+ if (len(os.Args) >= i+1) {
+ words = os.Args[i+1]
+ } else {
+ usage(bin)
+ }
+ }
+
+ if (os.Args[i] == "-p" && len(os.Args) > i+1) {
+ if (len(os.Args) > i) {
+ pass = os.Args[i+1]
+ } else {
+ usage(bin)
+ }
+ }
+ }
+
+ if (pass == "") {
+ usage(bin)
+ }
+
+ fmt.Printf("Passcheck %s\n", version);
+ fmt.Printf("words: %s\n", words);
+ fmt.Printf("Password: %s\n\n", pass);
+
+ length_test(pass);
+ fmt.Printf("\nCharacter set:\n")
+ charset_test(pass);
+
+ if (words != "") {
+ fmt.Printf("\nWords:\n")
+ words_test(pass, words) // 0 = words file, 1 = password dictionary
+ }
+}
diff --git a/src/words.go b/src/words.go
@@ -0,0 +1,58 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+ "bufio"
+ "os"
+)
+
+func deleet(str1 string) string {
+ str2 := strings.ReplaceAll(str1, "3", "e")
+ str3 := strings.ReplaceAll(str2, "@", "a")
+ str4 := strings.ReplaceAll(str3, "1", "i")
+ str5 := strings.ReplaceAll(str4, "4", "a")
+ str6 := strings.ReplaceAll(str5, "0", "o")
+ str7 := strings.ReplaceAll(str6, "9", "g")
+ str8 := strings.ReplaceAll(str7, "6", "b")
+
+ str9 := strings.ToLower(str8)
+
+ return str9
+}
+
+func words_test(pass string, file string) {
+
+ pass1 := deleet(pass)
+
+ f, err := os.Open(file)
+
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+
+ fScanner := bufio.NewScanner(f)
+
+ fScanner.Split(bufio.ScanLines)
+
+ var found bool
+ for fScanner.Scan() {
+ line := fScanner.Text()
+ if (len(line) >= 3 && strings.Contains(pass1, line)) {
+ fmt.Printf(YEL + "[-] Password contains dictionary words - "+RESET)
+ fmt.Printf("%s : %s\n", file, line)
+ found = true
+ }
+ }
+
+ if (found) {
+ fmt.Printf(" The above is not necessarily an issue if your password\n")
+ fmt.Printf(" contains multiple distinct dictionary words, or if the\n")
+ fmt.Printf(" words are a small part of the password\n");
+ } else {
+ fmt.Printf(GREEN + "[+] Password was not found in any files\n"+RESET)
+ }
+
+ f.Close()
+}