-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
147 lines (133 loc) · 4.78 KB
/
types.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
146
147
package bindiff
import (
"fmt"
"time"
"github.com/shopspring/decimal"
)
type Metadata struct {
Version string
File1 int
File2 int
Description string
Created time.Time
Modified time.Time
Similarity float64
Confidence float64
}
type File struct {
ID int `gorm:"primaryKey"`
Filename string
ExeFilename string
Hash string
Functions int
LibFunctions int
Calls int
BasicBlocks int
LibBasicBlocks int
Edges int
LibEdges int
Instructions int
LibInstructions int
}
type FunctionAlgorithm int
const (
FAlgorithmNone FunctionAlgorithm = iota
FAlgorithmNameHashMatching FunctionAlgorithm = 1
FAlgorithmHashMatching FunctionAlgorithm = 2
FAlgorithmEdgesFlowgraphMdIndex FunctionAlgorithm = 3
FAlgorithmEdgesCallgraphMdIndex FunctionAlgorithm = 4
FAlgorithmMdIndexMatchingFlowgraphTopDown FunctionAlgorithm = 5
FAlgorithmMdIndexMatchingFlowgraphBottomUp FunctionAlgorithm = 6
FAlgorithmPrimeSignatureMatching FunctionAlgorithm = 7
FAlgorithmMdIndexMatchingCallGraphTopDown FunctionAlgorithm = 8
FAlgorithmMdIndexMatchingCallGraphBottomUp FunctionAlgorithm = 9
FAlgorithmRelaxedMdIndexMatching FunctionAlgorithm = 10
FAlgorithmInstructionCount FunctionAlgorithm = 11
FAlgorithmAddressSequence FunctionAlgorithm = 12
FAlgorithmStringReferences FunctionAlgorithm = 13
FAlgorithmLoopCountMatching FunctionAlgorithm = 14
FAlgorithmCallSequenceMatchingExact FunctionAlgorithm = 15
FAlgorithmCallSequenceMatchingTopology FunctionAlgorithm = 16
FAlgorithmCallSequenceMatchingSequence FunctionAlgorithm = 17
FAlgorithmCallReferenceMatching FunctionAlgorithm = 18
FAlgorithmManual FunctionAlgorithm = 19
)
type FunctionMatch struct {
ID int `gorm:"primaryKey"`
Address1 decimal.Decimal `gorm:"type:BIGINT"`
Name1 string
Address2 decimal.Decimal `gorm:"type:BIGINT"`
Name2 string
Similarity float64
Confidence float64
Flags int
Algorithm FunctionAlgorithm
Evalute bool
Commentsported bool
Basicblocks int
Edges int
Instructions int
}
func (fm FunctionMatch) String() string {
return fmt.Sprintf(
"FunctionMatch: %s (%#x) -> %s (%#x) similarity=[%.2f] confidence=[%.2f]",
fm.Name1,
uint64(fm.Address1.BigInt().Int64()),
fm.Name2,
uint64(fm.Address2.BigInt().Int64()),
fm.Similarity,
fm.Confidence,
)
}
type BasicBlockAlgorithm int
const (
BBAlgorithmNone BasicBlockAlgorithm = iota
BBAlgorithmEdgesPrimeProduct BasicBlockAlgorithm = 1
BBAlgorithmHashMatchingFourInstMin BasicBlockAlgorithm = 2
BBAlgorithmPrimeMatchingFourInstMin BasicBlockAlgorithm = 3
BBAlgorithmCallReferenceMatching BasicBlockAlgorithm = 4
BBAlgorithmStringReferencesMatching BasicBlockAlgorithm = 5
BBAlgorithmEdgesMdIndexTopDown BasicBlockAlgorithm = 6
BBAlgorithmMdIndexMatchingTopDown BasicBlockAlgorithm = 7
BBAlgorithmEdgesMdIndexBottomUp BasicBlockAlgorithm = 8
BBAlgorithmMdIndexMatchingBottomUp BasicBlockAlgorithm = 9
BBAlgorithmRelaxedMdIndexMatching BasicBlockAlgorithm = 10
BBAlgorithmPrimeMatchingNoInstMin BasicBlockAlgorithm = 11
BBAlgorithmEdgesLengauerTarjanDominated BasicBlockAlgorithm = 12
BBAlgorithmLoopEntryMatching BasicBlockAlgorithm = 13
BBAlgorithmSelfLoopMatching BasicBlockAlgorithm = 14
BBAlgorithmEntryPointMatching BasicBlockAlgorithm = 15
BBAlgorithmExitPointMatching BasicBlockAlgorithm = 16
BBAlgorithmInstructionCountMatching BasicBlockAlgorithm = 17
BBAlgorithmJumpSequenceMatching BasicBlockAlgorithm = 18
BBAlgorithmPropagationSizeOne BasicBlockAlgorithm = 19
BBAlgorithmManual BasicBlockAlgorithm = 20
)
type BasicBlockMatch struct {
ID int `gorm:"primaryKey"`
FunctionID int
Address1 decimal.Decimal `gorm:"type:BIGINT"`
Address2 decimal.Decimal `gorm:"type:BIGINT"`
Algorithm BasicBlockAlgorithm
Evalute bool
}
func (bbm BasicBlockMatch) String() string {
return fmt.Sprintf(
"BasicBlockMatch: funcID(%d) %#x -> %#x",
bbm.FunctionID,
uint64(bbm.Address1.BigInt().Int64()),
uint64(bbm.Address2.BigInt().Int64()),
)
}
type Instruction struct {
ID int `gorm:"primaryKey"`
Address1 decimal.Decimal `gorm:"type:BIGINT"`
Address2 decimal.Decimal `gorm:"type:BIGINT"`
}
func (i Instruction) String() string {
return fmt.Sprintf(
"Instruction: %#x -> %#x",
uint64(i.Address1.BigInt().Int64()),
uint64(i.Address2.BigInt().Int64()),
)
}