mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-27 20:29:39 +02:00
Dynamic (#77)
This commit is contained in:
parent
55247b7fcd
commit
991c84a1eb
1464 changed files with 225448 additions and 1985 deletions
19
tests/dynamic_fixtures/go/handler_func/benign.go
Normal file
19
tests/dynamic_fixtures/go/handler_func/benign.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Phase 15 — http.HandlerFunc, benign.
|
||||
// Echoes a fixed string; query value is discarded.
|
||||
|
||||
package entry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func Handle(w http.ResponseWriter, r *http.Request) {
|
||||
_ = r.URL.Query().Get("payload")
|
||||
cmd := exec.Command("echo", "hello")
|
||||
out, _ := cmd.CombinedOutput()
|
||||
fmt.Print(string(out))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(out)
|
||||
}
|
||||
3
tests/dynamic_fixtures/go/handler_func/go.mod
Normal file
3
tests/dynamic_fixtures/go/handler_func/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module nyx_handler_func_fixture
|
||||
|
||||
go 1.21
|
||||
21
tests/dynamic_fixtures/go/handler_func/vuln.go
Normal file
21
tests/dynamic_fixtures/go/handler_func/vuln.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Phase 15 — http.HandlerFunc, vulnerable.
|
||||
// Reads `?payload=` query value and pipes to /bin/sh -c.
|
||||
// Entry: Handle(w http.ResponseWriter, r *http.Request) Cap: CODE_EXEC
|
||||
|
||||
package entry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func Handle(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Print("__NYX_SINK_HIT__\n")
|
||||
payload := r.URL.Query().Get("payload")
|
||||
cmd := exec.Command("sh", "-c", "echo hello "+payload)
|
||||
out, _ := cmd.CombinedOutput()
|
||||
fmt.Print(string(out))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(out)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue