-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
46 lines (36 loc) · 1.33 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
package main
import (
"fmt"
"syscall"
"os"
"unsafe"
"bufio"
)
func main() {
GetModuleHandleA := syscall.NewLazyDLL("kernel32").NewProc("GetModuleHandleA")
name, _ := syscall.BytePtrFromString("wininet.dll")
ProxyCall(
syscall.NewLazyDLL("kernel32").
NewProc("LoadLibraryA").Addr(), //function Address
uintptr(unsafe.Pointer(name)), //module name
)
dllAddr, _, _ := GetModuleHandleA.Call(uintptr(unsafe.Pointer(name)))
fmt.Printf("Module Address: 0x%x\n", dllAddr)
fmt.Print("Press 'Enter' to continue...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
var allocatedAddress uintptr
allocatedsize := uintptr(100)
ProxyCall(//总传参数量太多可能会报错
syscall.NewLazyDLL("ntdll.dll").
NewProc("NtAllocateVirtualMemory").Addr(), //function Address第一个参数为function的地址
uintptr(0xffffffffffffffff), //ProcessHandle第二个参数开始传入需要的参数即可
uintptr(unsafe.Pointer(&allocatedAddress)), //*BaseAddress
uintptr(0), //ZeroBits
uintptr(unsafe.Pointer(&allocatedsize)), //RegionSize
uintptr(0x00001000|0x00002000), //AllocationType
syscall.PAGE_EXECUTE_READWRITE, //Protect
)
fmt.Printf("Allocate: 0x%x\n", allocatedAddress)
fmt.Print("Press 'Enter' to continue...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
}