-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.go
More file actions
52 lines (41 loc) · 1.56 KB
/
template.go
File metadata and controls
52 lines (41 loc) · 1.56 KB
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
package injector
import (
"errors"
)
// Template is used to build highly customizable loader.
type Template struct {
// specify the x86 loader template.
LoaderX86 string `toml:"loader_x86" json:"loader_x86"`
// specify the x64 loader template.
LoaderX64 string `toml:"loader_x64" json:"loader_x64"`
// maximum number of loader instructions on x86.
MaxNumInstX86 int `toml:"max_num_inst_x86" json:"max_num_inst_x86"`
// maximum number of loader instructions on x64.
MaxNumInstX64 int `toml:"max_num_inst_x64" json:"max_num_inst_x64"`
// append custom integer that will be encrypted.
Integer map[string]uint32 `toml:"integer" json:"integer"`
// append custom ANSI string that will be encrypted.
ANSI map[string]string `toml:"ansi" json:"ansi"`
// append custom UTF16 string that will be encrypted.
UTF16 map[string]string `toml:"utf16" json:"utf16"`
// append custom plain-text argument for loader template.
Arguments map[string]any `toml:"arguments" json:"arguments"`
// append custom switch for if statements in template.
Switches map[string]bool `toml:"switches" json:"switches"`
}
// Check is used to check template configuration.
func (tpl *Template) Check() error {
if tpl.LoaderX86 == "" {
return errors.New("empty loader template for x86")
}
if tpl.LoaderX64 == "" {
return errors.New("empty loader template for x64")
}
if tpl.MaxNumInstX86 < 1 {
return errors.New("invalid maximum number of loader instructions for x86")
}
if tpl.MaxNumInstX64 < 1 {
return errors.New("invalid maximum number of loader instructions for x64")
}
return nil
}