-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
145 lines (132 loc) · 4.47 KB
/
main_test.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package main
import (
"fmt"
"os"
"testing"
"vertesan/campus/analyser"
"vertesan/campus/network"
"vertesan/campus/network/rpc"
"vertesan/campus/octo"
"vertesan/campus/proto/papi"
"vertesan/campus/utils"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
func TestDeserializeFile(t *testing.T) {
fileName := "UserGet241209223231332.bin"
raw, err := os.ReadFile("cache/" + fileName)
if err != nil {
panic(err)
}
// captured binary
// bodyBytes := rpc.Deserialize(raw[5:])
// hooked binary
bodyBytes := rpc.Deserialize(raw)
var pb papi.UserGetResponse
if err := proto.Unmarshal(bodyBytes, &pb); err != nil {
t.Fatalf("Cannot unmarshal message. %s", err)
}
marshalOptions := protojson.MarshalOptions{
Multiline: true,
AllowPartial: false,
UseProtoNames: true,
UseEnumNumbers: true, // change this value
EmitUnpopulated: true,
EmitDefaultValues: false,
}
jsonBytes, err := marshalOptions.Marshal(&pb)
if err != nil {
panic(err)
}
if err := os.WriteFile("cache/"+fileName+".json", jsonBytes, 0644); err != nil {
panic(err)
}
}
func TestDecryptOctoManifest(t *testing.T) {
// open encrypted octo cache file
octoFs, err := os.Open(OCTO_CACHE_FILE)
if err != nil {
panic(err)
}
// keyMd5 := md5.Sum([]byte("1nuv9td1bw1udefk"))
// ivMd5 := md5.Sum([]byte("LvAUtf+tnz"))
octoDb, err := octo.DecryptOctoList(octoFs, 1)
if err != nil {
panic(err)
}
// convert protobuf object to json string
marshalOptions := &protojson.MarshalOptions{
Multiline: true,
Indent: " ",
AllowPartial: true,
UseProtoNames: true,
UseEnumNumbers: true,
}
octoJson, err := marshalOptions.Marshal(octoDb)
if err != nil {
panic(err)
}
// write manifest json file
if err := os.WriteFile("cache/octo.json", octoJson, 0644); err != nil {
panic(err)
}
}
func TestDecryptOctoList(t *testing.T) {
fs, err := os.Open("cache/octorespon.bin")
if err != nil {
panic(err)
}
db, err := octo.DecryptOctoList(fs, 0)
if err != nil {
panic(err)
}
utils.UNUSED(db)
}
func TestLogin(t *testing.T) {
manager := &network.NetworkManager{}
manager.Login()
}
func TestAnalyze(t *testing.T) {
analyser.Analyze()
}
func TestSerialize(t *testing.T) {
req := &papi.SystemCheckRequest{}
req.IdToken = "abcd1234zxcv0987"
msgBytes, err := proto.Marshal(req)
if err != nil {
t.Fatalf("Failed to marshal wired format message. %s", err)
}
raw := rpc.Serialize(msgBytes)
fmt.Printf("%X\n", raw)
desData := rpc.Deserialize(raw)
desIns := &papi.SystemCheckRequest{}
proto.Unmarshal(desData, desIns)
fmt.Printf("%s\n", desIns.IdToken)
}
func TestDeserialize(t *testing.T) {
bodyBytes := rpc.Deserialize(deserializeTestData)
var response papi.SystemCheckResponse
if err := proto.Unmarshal(bodyBytes, &response); err != nil {
t.Fatalf("Cannot unmarshal message. %s", err)
}
fmt.Print(response.OctoHost)
}
var (
deserializeTestData = []byte{
0x00, 0x00, 0x00, 0x00, 0xE8, 0x06, 0x00, 0x00, 0x04, 0x4B, 0x78, 0x62, 0x41, 0x44, 0x0D, 0xC1,
0x1C, 0x02, 0x75, 0x11, 0x5E, 0xDE, 0x6F, 0x76, 0x82, 0x10, 0xF1, 0xA0, 0x65, 0xF7, 0x16, 0x2D,
0x13, 0x4C, 0x26, 0x2A, 0x50, 0xBF, 0xCE, 0x8D, 0x83, 0xA7, 0x8A, 0xFA, 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