-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
56 lines (50 loc) · 1.41 KB
/
main.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
package main // import "github.com/denisbrodbeck/memgrdpeek"
import (
"fmt"
"os"
"github.com/awnumar/memguard"
)
type message struct {
ID []byte // 32 byte
Recipient []byte // 32 byte
Sender []byte // 32 byte
Message *memguard.LockedBuffer // Gets 32 byte input
Meta []byte // 32 byte
}
func newMessage(id, recipient, sender, msg, meta []byte) *message {
msgBuf, err := memguard.NewImmutableFromBytes(assert32Bytes(msg))
if err != nil {
panic(err)
}
return &message{
ID: assert32Bytes(id),
Recipient: assert32Bytes(recipient),
Sender: assert32Bytes(sender),
Message: msgBuf,
Meta: assert32Bytes(meta),
}
}
func main() {
defer memguard.DestroyAll()
msg := newMessage(
[]byte("(((id | 1234567890123456 )))"),
[]byte("(((recip | bobby@spacer.com )))"),
[]byte("(((sender| eva@secretmoon.m )))"),
[]byte("(((msg | VERY SECRET VERY )))"),
[]byte("(((meta | 2017-10-21 10:26 )))"),
)
pid := os.Getpid()
fmt.Println(" ") // easier to spot message
fmt.Println("Running under PID:", pid)
fmt.Println("Press enter after running 'memory_reader.py' to exit...")
line := ""
fmt.Scanln(&line)
fmt.Printf("%T: %s\n", msg, msg)
}
// helper
func assert32Bytes(in []byte) []byte {
if len(in) != 32 {
panic("invalid length")
}
return in
}