From b049265321f171fd6db3fa2db09927200d2708c0 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 12 May 2015 21:05:57 +0200 Subject: Add OutputDriver decrypter --- enc/enc.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 enc/enc.go (limited to 'enc/enc.go') diff --git a/enc/enc.go b/enc/enc.go new file mode 100644 index 0000000..3b89dfd --- /dev/null +++ b/enc/enc.go @@ -0,0 +1,43 @@ +// Decrypt Graphtec files +package main + +import ( + "bytes" + "crypto/cipher" + "crypto/des" + "flag" + "fmt" + "io/ioutil" + "log" +) + +var ( + magic = []byte{0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99} + key = []byte{0x32, 0x5d, 0xbc, 0x97, 0xa8, 0xa1, 0x26, 0x08} + zero = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + file = flag.String("file", "Graphtec.enc", "file name") +) + +func main() { + flag.Parse() + + f, err := ioutil.ReadFile(*file) + if err != nil { + log.Fatal(err) + } + + if !bytes.Equal(f[:8], magic) { + log.Fatal("bad magic") + } + + block, err := des.NewCipher(key) + if err != nil { + log.Fatal(err) + } + + data := f[0x88:] + mode := cipher.NewCBCDecrypter(block, zero) + mode.CryptBlocks(data, data) + + fmt.Print(string(data)) +} -- cgit v1.2.3