Skip to content

Commit 92980ba

Browse files
v1.0.0, add BestCrypt
1 parent 5bd2a81 commit 92980ba

3 files changed

Lines changed: 73 additions & 56 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
[![GitHub release](https://img.shields.io/github/release/cyclone-github/container_truncator.svg)](https://github.com/cyclone-github/container_truncator/releases)
77
[![Go Reference](https://pkg.go.dev/badge/github.com/cyclone-github/container_truncator.svg)](https://pkg.go.dev/github.com/cyclone-github/container_truncator)
88

9-
### Cyclone's Truecrypt / Veracrypt Container Truncater
10-
- Tool to process Truecrypt / Veracrypt container files to be ran with hashcat
9+
### Cyclone's Container Truncater
10+
- Tool to truncate BestCrypt / Truecrypt / Veracrypt container files
1111
- Tested on debian linux & Windows 11
12-
- Run tool in directory where Truecrypt *.tc or Veracrypt *.vc container file is located
12+
- Run tool in directory where BestCrypt *.jbc, Truecrypt *.tc or Veracrypt *.vc container file is located
1313
- Once file is selected from menu, tool will truncate container and save a new file to "truncate_filename"
14-
- "truncate_filename" can now be ran with hashcat using the appropriate mode
15-
- example: ./veracrypt_container_truncator.bin
14+
- "truncate_filename" can now be ran with hashcat using the appropriate mode (for tc/vc containers)
15+
- example: ./container_truncator.bin
1616
- 1 ) truecrypt.tc
1717
- outputs new file "truncate_truecrypt.tc"
1818
- hashcat -m 6211 -a 0 truncate_truecrypt.tc cyclone_hk_v2.txt -r cyclone_250.rule

container_truncator.go

Lines changed: 67 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,52 @@
11
package main
22

33
import (
4+
"encoding/base64"
5+
"flag"
46
"fmt"
57
"io"
68
"os"
7-
"os/exec"
89
"path/filepath"
9-
"runtime"
1010
"strings"
11-
"time"
1211
)
1312

14-
// version history
15-
var version = "v0.1.0, 2023-01-23; initial release"
16-
17-
// clear screen function
18-
func clearScreen() {
19-
switch runtime.GOOS {
20-
case "linux":
21-
cmd := exec.Command("clear")
22-
cmd.Stdout = os.Stdout
23-
cmd.Run()
24-
case "darwin":
25-
cmd := exec.Command("clear")
26-
cmd.Stdout = os.Stdout
27-
cmd.Run()
28-
fmt.Println("Note, program has not been tested on Mac OS")
29-
time.Sleep(5 * time.Second)
30-
case "windows":
31-
cmd := exec.Command("cmd", "/c", "cls")
32-
cmd.Stdout = os.Stdout
33-
cmd.Run()
34-
}
13+
// version
14+
var version = "v1.0.0, 2026-01-16\nhttps://github.com/cyclone-github/container_truncator"
15+
16+
func versionFunc() {
17+
fmt.Fprintln(os.Stderr, version)
3518
}
3619

3720
func welcome() {
38-
fmt.Println(" ----------------------- ")
39-
fmt.Println("| Cyclone's |")
40-
fmt.Println("| Truecrypt / Veracrypt |")
41-
fmt.Println("| Container Truncater |")
42-
fmt.Println(" ----------------------- ")
21+
fmt.Println(" ----------------------------------- ")
22+
fmt.Println("| Cyclone's Container Truncater |")
23+
fmt.Println("| Bestcrypt / Truecrypt / Veracrypt |")
24+
fmt.Println(" ----------------------------------- ")
4325
fmt.Println(version)
4426
fmt.Println()
45-
fmt.Println("Program will truncate a Truecrypt or Veracrypt Container")
46-
fmt.Println("and save a new file as 'truncated_orginal_filename'.")
47-
fmt.Println("You can then run this file with hashcat.")
48-
fmt.Println("Program only supports .tc & .vc container files.")
27+
fmt.Println("Program will truncate a Bestcrypt, Truecrypt or Veracrypt Container")
28+
fmt.Println("and save a new file as 'truncated_orginal_filename'")
29+
fmt.Println("You can then run .tc & .vc files with hashcat")
30+
fmt.Println("Program only supports .jbc .tc & .vc container files")
4931
fmt.Println()
5032
}
5133

5234
func truncate() {
53-
// Get all files in current directory with .tc or .vc extension
54-
files, err := filepath.Glob("*.tc")
55-
files2, err := filepath.Glob("*.vc")
56-
files = append(files, files2...)
57-
if err != nil {
58-
fmt.Println("Error:", err)
59-
return
35+
// get all supported container files in current dir
36+
extensions := []string{".jbc", ".tc", ".vc"}
37+
var files []string
38+
39+
for _, ext := range extensions {
40+
matches, err := filepath.Glob("*" + ext)
41+
if err != nil {
42+
fmt.Println("Error:", err)
43+
return
44+
}
45+
files = append(files, matches...)
6046
}
47+
6148
if len(files) == 0 {
62-
fmt.Println("No files found with extension .tc or .vc")
49+
fmt.Println("No files found with extension .jbc .tc or .vc")
6350
return
6451
}
6552

@@ -75,44 +62,51 @@ func truncate() {
7562
return
7663
}
7764

78-
// Print list of files and ask user to select one
65+
// print list of files and prompt user to select one
7966
fmt.Println("Select a container file to truncate:")
8067
for i, file := range truncatedFiles {
8168
fmt.Printf("%d) %s\n", i+1, file)
8269
}
8370
var selected int
8471
fmt.Scan(&selected)
8572

86-
// Get selected file
73+
// get selected file
8774
inputFile := truncatedFiles[selected-1]
8875

89-
// Get output file name by prepending "_truncate" to input file name
76+
// get output file name by prepending "_truncate" to input file name
9077
outputFile := "truncate_" + inputFile
9178

92-
// Check if output file already exists
79+
// check if output file already exists
9380
if _, err := os.Stat(outputFile); !os.IsNotExist(err) {
9481
fmt.Println("Error: Output file already exists.")
9582
return
9683
}
9784

98-
// Open input file
85+
// open input file
9986
in, err := os.Open(inputFile)
10087
if err != nil {
10188
fmt.Println("Error:", err)
10289
return
10390
}
10491
defer in.Close()
10592

106-
// Open output file
93+
// open output file
10794
out, err := os.Create(outputFile)
10895
if err != nil {
10996
fmt.Println("Error:", err)
11097
return
11198
}
11299
defer out.Close()
113100

114-
// Copy 512 bytes from input file to output file
115-
_, err = io.CopyN(out, in, 512)
101+
// determine header size based on container type
102+
var headerSize int64 = 512 // default for .tc / .vc
103+
if strings.HasSuffix(strings.ToLower(inputFile), ".jbc") {
104+
headerSize = 1536 // default for BestCrypt v8/9
105+
}
106+
107+
// copy header bytes from input file to output file
108+
_, err = io.CopyN(out, in, headerSize)
109+
116110
if err != nil {
117111
fmt.Println("Error:", err)
118112
} else {
@@ -121,7 +115,30 @@ func truncate() {
121115
}
122116

123117
func main() {
124-
clearScreen()
118+
version := flag.Bool("version", false, "Program version:")
119+
cyclone := flag.Bool("cyclone", false, "dev info")
120+
help := flag.Bool("help", false, "Prints help:")
121+
flag.Parse()
122+
123+
// run sanity checks for special flags
124+
if *version {
125+
versionFunc()
126+
os.Exit(0)
127+
}
128+
if *cyclone {
129+
decodedStr, err := base64.StdEncoding.DecodeString("Q29kZWQgYnkgY3ljbG9uZSA7KQo=")
130+
if err != nil {
131+
fmt.Fprintln(os.Stderr, "--> Cannot decode base64 string. <--")
132+
os.Exit(1)
133+
}
134+
fmt.Fprintln(os.Stderr, string(decodedStr))
135+
os.Exit(0)
136+
}
137+
if *help {
138+
welcome()
139+
os.Exit(0)
140+
}
141+
125142
welcome()
126143
truncate()
127144
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/cyclone-github/container_truncator
22

3-
go 1.25.2
3+
go 1.25.5

0 commit comments

Comments
 (0)