package main import ( "fmt" "io" "os/exec" "strconv" "strings" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/projectdiscovery/retryablehttp-go" ) func main() { e := echo.New() e.Use(middleware.Recover()) e.Use(middleware.Logger()) e.GET("/", indexHandler) e.GET("/info", infoHandler) e.GET("/redirect", redirectHandler) e.GET("/request", requestHandler) e.GET("/email", emailHandler) e.GET("/permissions", permissionsHandler) if err := e.Start("localhost:8082"); err != nil { panic(err) } } var bodyTemplate = ` Fuzz Playground %s ` func indexHandler(ctx echo.Context) error { return ctx.HTML(200, fmt.Sprintf(bodyTemplate, `

Fuzzing Playground


`)) } func infoHandler(ctx echo.Context) error { return ctx.HTML(200, fmt.Sprintf(bodyTemplate, fmt.Sprintf("Name of user: %s%s%s", ctx.QueryParam("name"), ctx.QueryParam("another"), ctx.QueryParam("random")))) } func redirectHandler(ctx echo.Context) error { url := ctx.QueryParam("redirect_url") return ctx.Redirect(302, url) } func requestHandler(ctx echo.Context) error { url := ctx.QueryParam("url") data, err := retryablehttp.DefaultClient().Get(url) if err != nil { return ctx.HTML(500, err.Error()) } defer data.Body.Close() body, _ := io.ReadAll(data.Body) return ctx.HTML(200, fmt.Sprintf(bodyTemplate, string(body))) } func emailHandler(ctx echo.Context) error { text := ctx.QueryParam("text") if strings.Contains(text, "{{") { trimmed := strings.SplitN(strings.Trim(text[strings.Index(text, "{"):], "{}"), "*", 2) if len(trimmed) < 2 { return ctx.HTML(500, "invalid template") } first, _ := strconv.Atoi(trimmed[0]) second, _ := strconv.Atoi(trimmed[1]) text = strconv.Itoa(first * second) } return ctx.HTML(200, fmt.Sprintf(bodyTemplate, fmt.Sprintf("Text: %s", text))) } func permissionsHandler(ctx echo.Context) error { command := ctx.QueryParam("cmd") fields := strings.Fields(command) cmd := exec.Command(fields[0], fields[1:]...) data, _ := cmd.CombinedOutput() return ctx.HTML(200, fmt.Sprintf(bodyTemplate, string(data))) }