Skip to content

Commit

Permalink
removed "setStatusCode" flag, as it was unnecessary and complicated t…
Browse files Browse the repository at this point in the history
…hings
  • Loading branch information
m10x committed Apr 27, 2022
1 parent a190547 commit 6f0890a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 0 additions & 2 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type (
ContentType string
QuerySeperator string
CacheBuster string
StatusCode int
TimeOut int
DeclineCookies bool
Force bool
Expand Down Expand Up @@ -97,7 +96,6 @@ func ReadConfigFile() ConfigStruct {
ContentType: "",
QuerySeperator: "",
CacheBuster: "",
StatusCode: 0,
TimeOut: 0,
DeclineCookies: false,
Urls: nil,
Expand Down
2 changes: 0 additions & 2 deletions pkg/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ func ParseFlags(vers string) {
"post", "post", false, "Do a POST request instead of a GET request")
appendString(&requestOptions, &Config.ContentType,
"contenttype", "ct", "application/x-www-form-urlencoded", "Set the contenttype for a POST Request. Default is application/x-www-form-urlencoded. If you don't want a content-type to be used at all use -ct ''")
appendInt(&requestOptions, &Config.StatusCode,
"statuscode", "status", -1, "Expected status code of the responses. If not specified it takes the status code of the first response")
appendString(&requestOptions, &Config.QuerySeperator,
"parameterseperator", "ps", "&", "Specify the seperator for parameters. The default value is &")
appendBoolean(&requestOptions, &userAgentChrome,
Expand Down
14 changes: 4 additions & 10 deletions pkg/recon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -1207,7 +1206,8 @@ func GetWebsite(requrl string, setStatusCode bool, cacheBuster bool) (WebsiteStr
waitLimiter(errorString)
resp, err := http.DefaultClient.Do(req)
if err != nil {
msg := fmt.Sprintf("%s: http.DefaultClient.Do: %s", errorString, err.Error())
msg := fmt.Sprintf("%s: http.DefaultClient.Do: %s", errorString, err.Error()) // Error: context deadline exceeded -> panic; runtime error

Print(msg+"\n", Red)
return web, errors.New(msg)
}
Expand All @@ -1228,22 +1228,16 @@ func GetWebsite(requrl string, setStatusCode bool, cacheBuster bool) (WebsiteStr
return web, errors.New(msg)
}

tempStatusCode := Config.StatusCode
Print("vorher:"+strconv.Itoa(Config.Website.StatusCode)+"\n", Red)
if Config.Website.StatusCode != 0 {
tempStatusCode = Config.Website.StatusCode
}
tempStatusCode := Config.Website.StatusCode
// Only overwrite statuscode if 1. it wasn't set via flag 2. its the first and only request or the second of two requests
if setStatusCode && tempStatusCode == -1 && tempStatusCode != resp.StatusCode {
Print("temp"+strconv.Itoa(tempStatusCode)+"resp"+strconv.Itoa(resp.StatusCode)+"\n", Red)
if setStatusCode && tempStatusCode != resp.StatusCode {
tempStatusCode = resp.StatusCode

cache = Config.Website.Cache

msg := fmt.Sprintf("The default status code was set to %d\n", tempStatusCode)
Print(msg, Cyan)
}
Print("nachher:"+strconv.Itoa(Config.Website.StatusCode)+"\n", Red)

// if retrieveCookies is false, only the specified cookies will be used
// otherwise the by the server given cookies AND the specified cookies will be used
Expand Down
2 changes: 1 addition & 1 deletion web-cache-vulnerability-scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func runTests(rec int, u string, progress string, foundUrls *[]string, stat stri
pkg.Statistics[stat+"total"]++

// retrieve cookies, headers etc
pkg.Config.Website, err = pkg.GetWebsite(u, false, false)
pkg.Config.Website, err = pkg.GetWebsite(u, true, false)
if err != nil {
repWebsite.HasError = true
repWebsite.ErrorMessages = append(repWebsite.ErrorMessages, err.Error())
Expand Down

0 comments on commit 6f0890a

Please sign in to comment.