Last active
February 15, 2021 07:21
-
-
Save itxsoumya/1c0643721d6e41de77765ec5e1c59250 to your computer and use it in GitHub Desktop.
simple md5 hash cracker
This file contains 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 ( | |
"bufio" | |
"crypto/md5" | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
) | |
// basic md5 hash cracker | |
func main() { | |
// here we are parsing command line arguments | |
var ( | |
md5hash = flag.String("hash", "", "md-5 hash") | |
wordlist = flag.String("w", "wordlist.txt", "path to wordlist") | |
) | |
flag.Parse() | |
// check if we have more than 2 arg or not | |
if len(os.Args) < 2 { | |
fmt.Println("Usage: md5HashCrack -hash <hash> -w <wordlist>") | |
return | |
} | |
// open the wordlist | |
f, err := os.Open(*wordlist) | |
check(err) | |
defer f.Close() | |
// here we created a scanner which will scan each line | |
scanner := bufio.NewScanner(f) | |
for scanner.Scan() { | |
password := scanner.Text() | |
hash := fmt.Sprintf("%x", md5.Sum([]byte(password))) // we created hash of normal password | |
// comp hash with original md5 hash | |
if hash == *md5hash { | |
fmt.Printf("[+] Password found (MD5): %s\n", password) | |
return | |
} | |
} | |
// check if we have any error in scanner | |
if err := scanner.Err(); err != nil { | |
log.Fatal(err) | |
} | |
} | |
func check(err error) { | |
if err != nil { | |
log.Fatal(err) | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment