Skip to content

Instantly share code, notes, and snippets.

@monsterxx03
Created August 29, 2019 10:05
Show Gist options
  • Save monsterxx03/f7a06db323023886495b6ff3a90c4d95 to your computer and use it in GitHub Desktop.
Save monsterxx03/f7a06db323023886495b6ff3a90c4d95 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
"strconv"
"syscall"
"unsafe"
)
// #include <sys/uio.h>
import "C"
const SYS_PROCESS_VM_READV = 310
func main() {
target := os.Args[1]
pid, err := strconv.Atoi(target)
if err != nil {
panic(err)
}
local := new(C.struct_iovec)
buf := make([]byte, 100)
local.iov_base = unsafe.Pointer(&buf)
local.iov_len = 100
remote := new(C.struct_iovec)
remote.iov_base = unsafe.Pointer(uintptr(0x20000))
remote.iov_len = 100
a, b, c := syscall.Syscall6(SYS_PROCESS_VM_READV, uintptr(pid), uintptr(unsafe.Pointer(local)), 1, uintptr(unsafe.Pointer(remote)), 1, 0)
fmt.Printf("%v, %v, %v\n", a, b, c)
fmt.Printf("%#v, %#v\n", local, remote)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment