mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
24 lines
436 B
Go
24 lines
436 B
Go
// Phase 17 (Track L.15) — chi benign control fixture.
|
|
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"os/exec"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func Run(w http.ResponseWriter, r *http.Request) {
|
|
cmd := r.URL.Query().Get("cmd")
|
|
allow := map[string]string{"ls": "ls", "ps": "ps"}
|
|
if safe, ok := allow[cmd]; ok {
|
|
_ = exec.Command(safe).Run()
|
|
}
|
|
_, _ = w.Write([]byte("ok"))
|
|
}
|
|
|
|
func main() {
|
|
r := chi.NewRouter()
|
|
r.Get("/run", Run)
|
|
_ = r
|
|
}
|