-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
92 lines (86 loc) · 2.53 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
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
package main
import (
"PEi/CertificateBypass"
"PEi/Tools"
"encoding/hex"
"fmt"
"os"
"time"
"github.com/urfave/cli/v2"
)
func main() {
Execute()
}
var (
filename string
outname string
shellcode string
hashcode string
xorcode string
)
func Execute() {
app := &cli.App{
Name: "PEi",
Usage: "进行PE文件的操作",
UsageText: "[No Usage]",
Version: "0.1.1",
Compiled: time.Now(),
Authors: []*cli.Author{
{
Name: "Lings",
Email: "[email protected]",
},
},
Commands: []*cli.Command{
{
Name: "CertificateBypass",
Aliases: []string{"c"},
Usage: "数字签名文件隐写",
Flags: []cli.Flag{
&cli.StringFlag{Name: "filename", Aliases: []string{"f"}, Destination: &filename, Value: "", Usage: "输入文件"},
&cli.StringFlag{Name: "outname", Aliases: []string{"o"}, Destination: &outname, Value: "", Usage: "输出文件"},
&cli.StringFlag{Name: "shellcode", Aliases: []string{"s"}, Destination: &shellcode, Value: "", Usage: "shellcode文件"},
&cli.StringFlag{Name: "hashcode", Aliases: []string{"c"}, Destination: &hashcode, Value: "", Usage: "16进制标识符 - String"},
},
Action: func(c *cli.Context) error {
if filename == "" || outname == "" || shellcode == "" {
return fmt.Errorf("参数输入不正确")
}
bytes, err := hex.DecodeString(hashcode)
if err != nil {
return err
}
CertificateBypass.Run(filename, outname, shellcode, bytes)
return nil
},
},
{
Name: "ShellCodeBypass",
Aliases: []string{"s"},
Usage: "对ShellCode进行简单的异或求反处理(先求反再异或)",
Flags: []cli.Flag{
&cli.StringFlag{Name: "filename", Aliases: []string{"f"}, Destination: &filename, Value: "", Usage: "shellcode文件"},
&cli.StringFlag{Name: "outname", Aliases: []string{"o"}, Destination: &outname, Value: "", Usage: "输出文件"},
&cli.StringFlag{Name: "xorcode", Aliases: []string{"x"}, Destination: &xorcode, Value: "", Usage: "16进制标识符 - String"},
},
Action: func(c *cli.Context) error {
if filename == "" || outname == "" || xorcode == "" {
return fmt.Errorf("参数输入不正确")
}
bytes, err := hex.DecodeString(xorcode)
if err != nil {
return err
}
fmt.Printf("ShellCodea将求反后异或: 0x%x\n", bytes[0])
Tools.ShellcodePretreatment(filename, outname, bytes[0])
return nil
},
},
},
// HideHelpCommand: true,
}
err := app.Run(os.Args)
if err != nil {
panic(err)
}
}