Created
February 21, 2019 13:37
Revisions
-
capnspacehook created this gist
Feb 21, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ package main import ( "io/ioutil" "os" "os/exec" "strconv" "syscall" "unsafe" ) func main() { newFdName := "test_fd" fdName, err := syscall.BytePtrFromString(newFdName) if err != nil { panic(err) } fd, _, _ := syscall.Syscall(319, uintptr(unsafe.Pointer(fdName)), 1, 0) pid := os.Getpid() file, err := ioutil.ReadFile("/home/capnspacehook/test.bin") if err != nil { panic(err) } fdPath := "/proc/" + strconv.Itoa(pid) + "/fd/" + strconv.Itoa(int(fd)) err = ioutil.WriteFile(fdPath, file, 0755) if err != nil { panic(err) } println(fdPath) fdCmd := exec.Command(fdPath) fdCmd.Stdout = os.Stdout fdCmd.Stderr = os.Stderr err = fdCmd.Run() if err != nil { panic(err) } }