-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.go
47 lines (42 loc) · 1.04 KB
/
utils.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
package main
import (
"encoding/json"
"fmt"
"regexp"
"strings"
)
func patchExports(funcs []string) (out []string) {
for _, fun := range funcs {
// strip leading ':'
out = append(out, fun[1:])
}
return
}
func patchForwards(funcs []string) (out []string) {
for _, fun := range funcs {
// dbgcore.MiniDumpWriteDump....
matcher := regexp.MustCompile(`\.`)
s := matcher.ReplaceAllString(fun, ".dll!")
out = append(out, s)
}
return
}
func genPEFunctions(list []string) []PEFunction {
// incoming: ["dllname!funcName"]
funcs := []PEFunction{}
accumulatedFns := make(map[string][]string)
for _, fn := range list {
splitFn := strings.Split(fn, "!")
peName := splitFn[0]
funcName := splitFn[1]
accumulatedFns[peName] = append(accumulatedFns[peName], funcName)
}
for peName, funcSlice := range accumulatedFns {
funcs = append(funcs, PEFunction{peName, funcSlice})
}
return funcs
}
func jsPrint(report *Report) {
serialized, _ := json.Marshal(report)
fmt.Println(string(serialized))
}