From 862884622ff9f9e9f9851f1feb4a39c010a5fa4e Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Thu, 11 Dec 2025 01:00:07 -0500 Subject: [PATCH] Added a simple chroot jail thing, but I'm pretty sure I'm forgetting a step. --- Makefile | 4 ++-- cmd/landmine/main.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3eaac4d..12fa2ee 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,10 @@ build: clean: rm dentata landmine -run_server: +run_server: build ./dentata -run_mine: +run_mine: build ./landmine docs: diff --git a/cmd/landmine/main.go b/cmd/landmine/main.go index c92506a..f6b1e42 100644 --- a/cmd/landmine/main.go +++ b/cmd/landmine/main.go @@ -5,6 +5,7 @@ import ( "net" "log" "sync" + "syscall" ) func handleConnection(conn net.Conn) { @@ -37,6 +38,20 @@ func listener(addr string) { } } +func ChrootJailLOL() { + err := syscall.Chdir("tmp") + if err != nil { panic(err) } + + err = syscall.Chroot(".") + if err != nil { panic(err) } + + err = syscall.Setuid(1000) + if err != nil { panic(err) } + + syscall.Setgid(1000) + if err != nil { panic(err) } +} + func main() { var wg sync.WaitGroup @@ -46,5 +61,8 @@ func main() { }) } + //BUG: ain't no way this works, learn to do it right + ChrootJailLOL() + wg.Wait() }