Created
March 7, 2017 20:40
-
-
Save avinashbot/6041894fa40c2399f6a78e6d0d6c1434 to your computer and use it in GitHub Desktop.
Find hex keywords in MD5 hashes
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 ( | |
"bytes" | |
"crypto/md5" | |
"fmt" | |
"math" | |
) | |
var symbols = []byte{ | |
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', | |
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', | |
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', | |
'5', '6', '7', '8', '9', '!', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '{', '}', | |
';', ':', '@', '~', '#', '<', ',', '>', '.', '?', '/', '|', '`', ' ', | |
} | |
var check_strings = [][]byte{ | |
[]byte("deadbeef"), | |
} | |
func main() { | |
fmt.Printf("Checking for: %s\n", bytes.Join(check_strings, []byte(", "))) | |
hash := md5.New() | |
var sum_buf bytes.Buffer | |
for depth := 1; ; depth++ { | |
buf := make([]byte, depth) | |
for i := 0; i < int(math.Pow(float64(len(symbols)), float64(depth))); i++ { | |
for j := 0; j < depth; j++ { | |
sym := (i / int(math.Pow(float64(len(symbols)), float64(j)))) % len(symbols) | |
buf[j] = symbols[sym] | |
} | |
hash.Write(buf) | |
fmt.Fprintf(&sum_buf, "%x", hash.Sum(nil)) | |
for _, str := range check_strings { | |
if bytes.Contains(sum_buf.Bytes(), str) { | |
fmt.Printf("%s => %s\n", buf, sum_buf.Bytes()) | |
} | |
} | |
sum_buf.Reset() | |
} | |
fmt.Printf("Upping depth to %d.\n", depth + 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment