-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveracrypt_container_truncator.go
129 lines (114 loc) · 2.82 KB
/
veracrypt_container_truncator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package main
import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
)
// version history
var version = "v0.1.0, 2023-01-23; initial release"
// clear screen function
func clearScreen() {
switch runtime.GOOS {
case "linux":
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
case "darwin":
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
fmt.Println("Note, program has not been tested on Mac OS")
time.Sleep(5 * time.Second)
case "windows":
cmd := exec.Command("cmd", "/c", "cls")
cmd.Stdout = os.Stdout
cmd.Run()
}
}
func welcome() {
fmt.Println(" ----------------------- ")
fmt.Println("| Cyclone's |")
fmt.Println("| Truecrypt / Veracrypt |")
fmt.Println("| Container Truncater |")
fmt.Println(" ----------------------- ")
fmt.Println(version)
fmt.Println()
fmt.Println("Program will truncate a Truecrypt or Veracrypt Container")
fmt.Println("and save a new file as 'truncated_orginal_filename'.")
fmt.Println("You can then run this file with hashcat.")
fmt.Println("Program only supports .tc & .vc container files.")
fmt.Println()
}
func truncate() {
// Get all files in current directory with .tc or .vc extension
files, err := filepath.Glob("*.tc")
files2, err := filepath.Glob("*.vc")
files = append(files, files2...)
if err != nil {
fmt.Println("Error:", err)
return
}
if len(files) == 0 {
fmt.Println("No files found with extension .tc or .vc")
return
}
// filter files that have already been truncated
var truncatedFiles []string
for _, file := range files {
if !strings.HasPrefix(file, "truncate_") {
truncatedFiles = append(truncatedFiles, file)
}
}
if len(truncatedFiles) == 0 {
fmt.Println("All files have already been truncated.")
return
}
// Print list of files and ask user to select one
fmt.Println("Select a container file to truncate:")
for i, file := range truncatedFiles {
fmt.Printf("%d) %s\n", i+1, file)
}
var selected int
fmt.Scan(&selected)
// Get selected file
inputFile := truncatedFiles[selected-1]
// Get output file name by prepending "_truncate" to input file name
outputFile := "truncate_" + inputFile
// Check if output file already exists
if _, err := os.Stat(outputFile); !os.IsNotExist(err) {
fmt.Println("Error: Output file already exists.")
return
}
// Open input file
in, err := os.Open(inputFile)
if err != nil {
fmt.Println("Error:", err)
return
}
defer in.Close()
// Open output file
out, err := os.Create(outputFile)
if err != nil {
fmt.Println("Error:", err)
return
}
defer out.Close()
// Copy 512 bytes from input file to output file
_, err = io.CopyN(out, in, 512)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("File truncated successfully.")
}
}
func main() {
clearScreen()
welcome()
truncate()
}
// end of program