Last active
March 29, 2023 14:03
-
-
Save yosignals/e7253df8a07ffcce02b7dc1f58751700 to your computer and use it in GitHub Desktop.
Converting those Hashcat $HEX[] results into something useful
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" | |
"encoding/hex" | |
"fmt" | |
"os" | |
"regexp" | |
"strings" | |
) | |
func main() { | |
potfilePath := "hashcat.potfile" | |
outputPath := "Hex2human.txt" | |
file, err := os.Open(potfilePath) | |
if err != nil { | |
panic(err) | |
} | |
defer file.Close() | |
outfile, err := os.Create(outputPath) | |
if err != nil { | |
panic(err) | |
} | |
defer outfile.Close() | |
scanner := bufio.NewScanner(file) | |
regex := regexp.MustCompile(`\$HEX\[(.*?)\]`) | |
for scanner.Scan() { | |
line := scanner.Text() | |
fields := strings.Split(line, ":") | |
if len(fields) > 1 { | |
matches := regex.FindStringSubmatch(fields[1]) | |
if len(matches) > 1 { | |
hexString := matches[1] | |
text, err := hex.DecodeString(hexString) | |
if err != nil { | |
fmt.Fprintf(os.Stderr, "Error decoding hex string: %s\n", err) | |
} else { | |
fmt.Fprintln(outfile, string(text)) | |
} | |
} | |
} | |
} | |
if err := scanner.Err(); err != nil { | |
panic(err) | |
} | |
fmt.Println("Conversion complete. Check", outputPath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment