Skip to content

Commit 0f43eeb

Browse files
fixed #5
1 parent bbe9e03 commit 0f43eeb

File tree

3 files changed

+53
-17
lines changed

3 files changed

+53
-17
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### v2024-11-04.1445-threaded
2+
```
3+
fixed https://github.com/cyclone-github/hashgen/issues/5
4+
added CPU threaded info to -help
5+
cleaned up code and print functions
6+
```
7+
### v2024-11-01.1630-threaded
8+
```
9+
added thread flag "-t" to allow user to specity CPU threads, ex: -t 16 // fixed default to use max CPU threads
10+
added modes: sha2-224, sha2-384, sha2-512-224, sha2-512-256, keccak-256, keccak-512
11+
```
12+
### v2024-08-24.2000-threaded
13+
```
14+
added mode "morsecode" which follows ITU-R M.1677-1 standard
15+
```
16+
### v2023-11-04.1330-threaded
17+
```
18+
tweaked -m 11500
19+
tweaked HEX error correction
20+
added reporting when encountering HEX decoding errors
21+
```
22+
### v2023-11-03.2200-threaded
23+
```
24+
added hashcat -m 11500 (CRC32 w/padding)
25+
re-added CRC32 / CRC64 modes
26+
fixed stdin
27+
```
28+
### v2023-10-30.1600-threaded
29+
```
30+
rewrote code base for multi-threading support
31+
some algos have not been implemented from previous version
32+
```

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ To use hashgen, type your mode, wordlist input & hash output files with a simple
7171
- `go build -ldflags="-s -w" hashgen.go`
7272
- Compile from source code how-to:
7373
- https://github.com/cyclone-github/scripts/blob/main/intro_to_go.txt
74+
75+
### Change Log:
76+
- https://github.com/cyclone-github/hashgen/blob/main/CHANGELOG.md
7477

7578
### Mentions:
7679
- Go Package Documentation: https://pkg.go.dev/github.com/cyclone-github/hashgen

hashgen.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ v2024-08-24.2000-threaded;
5454
v2024-11-01.1630-threaded;
5555
added thread flag "-t" to allow user to specity CPU threads, ex: -t 16 // fixed default to use max CPU threads
5656
added modes: sha2-224, sha2-384, sha2-512-224, sha2-512-256, keccak-256, keccak-512
57+
v2024-11-04.1445-threaded;
58+
fixed https://github.com/cyclone-github/hashgen/issues/5
59+
added CPU threaded info to -help
60+
cleaned up code and print functions
5761
*/
5862

5963
func versionFunc() {
60-
fmt.Fprintln(os.Stderr, "Cyclone hash generator v2024-11-01.1630-threaded")
64+
fmt.Fprintln(os.Stderr, "Cyclone hash generator v2024-11-04.1445-threaded")
6165
}
6266

6367
// help function
@@ -68,9 +72,10 @@ func helpFunc() {
6872
//"./hashgen -m bcrypt -cost 8 -w wordlist.txt\n" +
6973
"cat wordlist | ./hashgen -m md5 -hashplain\n" +
7074
//"\nSupported Options:\n-m {mode} -w {wordlist} -o {output_file} -hashplain {generates hash:plain pairs} -cost {bcrypt}\n" +
71-
"\nSupported Options:\n-m {mode} -w {wordlist} -o {output_file} -hashplain {generates hash:plain pairs}\n" +
75+
"\nSupported Options:\n-m {mode} -w {wordlist} -t {cpu threads} -o {output_file} -hashplain {generates hash:plain pairs}\n" +
7276
"\nIf -w is not specified, defaults to stdin\n" +
7377
"If -o is not specified, defaults to stdout\n" +
78+
"If -t is not specified, defaults to max available CPU threads\n" +
7479
"\nModes:\t\tHashcat Mode Equivalent:\n" +
7580
//"\nargon2id (very slow!)\n" +
7681
"base64encode\n" +
@@ -311,15 +316,16 @@ func hashBytes(hashFunc string, data []byte) string {
311316
decodedBytes := make([]byte, base64.StdEncoding.DecodedLen(len(data)))
312317
n, err := base64.StdEncoding.Decode(decodedBytes, data)
313318
if err != nil {
314-
return "Invalid Base64 string"
319+
fmt.Fprintln(os.Stderr, "Invalid Base64 string")
320+
return ""
315321
}
316322
return string(decodedBytes[:n]) // convert the decoded bytes to a string
317323
case "plaintext", "plain", "99999":
318324
return string(data) // convert byte slice to string
319325
default:
320326
log.Printf("--> Invalid hash function: %s <--\n", hashFunc)
321327
helpFunc()
322-
os.Exit(0)
328+
os.Exit(1)
323329
return ""
324330
}
325331
}
@@ -396,7 +402,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
396402
break
397403
}
398404
if err != nil {
399-
fmt.Println(os.Stderr, "Error reading chunk:", err)
405+
fmt.Fprintln(os.Stderr, "Error reading chunk:", err)
400406
return
401407
}
402408
// logic to split chunks properly
@@ -440,7 +446,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
440446
if outputPath != "" {
441447
outFile, err := os.Create(outputPath)
442448
if err != nil {
443-
fmt.Println(os.Stderr, "Error creating output file:", err)
449+
fmt.Fprintln(os.Stderr, "Error creating output file:", err)
444450
return
445451
}
446452
defer outFile.Close()
@@ -489,7 +495,12 @@ func main() {
489495
os.Exit(0)
490496
}
491497
if *cyclone {
492-
funcBase64Decode("Q29kZWQgYnkgY3ljbG9uZSA7KQo=")
498+
decodedStr, err := base64.StdEncoding.DecodeString("Q29kZWQgYnkgY3ljbG9uZSA7KQo=")
499+
if err != nil {
500+
fmt.Fprintln(os.Stderr, "--> Cannot decode base64 string. <--")
501+
os.Exit(1)
502+
}
503+
fmt.Fprintln(os.Stderr, string(decodedStr))
493504
os.Exit(0)
494505
}
495506
if *help {
@@ -518,14 +529,4 @@ func main() {
518529
startProc(*hashFunc, *inputFile, *outputFile, *hashPlainOutput, numThreads)
519530
}
520531

521-
// base64 decode function used for displaying encoded messages
522-
func funcBase64Decode(line string) {
523-
str, err := base64.StdEncoding.DecodeString(line)
524-
if err != nil {
525-
fmt.Fprintln(os.Stderr, "--> Text doesn't appear to be base64 encoded. <--")
526-
os.Exit(0)
527-
}
528-
fmt.Fprintf(os.Stderr, "%s\n", str)
529-
}
530-
531532
// end code

0 commit comments

Comments
 (0)