From a5dc966894f905aa3352787bbc338fa8ee377e8c Mon Sep 17 00:00:00 2001 From: c_sto <7466346+C-Sto@users.noreply.github.com> Date: Tue, 20 Nov 2018 07:29:52 +0800 Subject: [PATCH] reduce complexity in some funcs --- librecursebuster/logic.go | 3 -- librecursebuster/main_test.go | 65 +++++++++++------------------------ 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/librecursebuster/logic.go b/librecursebuster/logic.go index 7c15b31..7b02166 100644 --- a/librecursebuster/logic.go +++ b/librecursebuster/logic.go @@ -40,11 +40,9 @@ func (gState *State) ManageRequests() { for _, method := range gState.Methods { if page.Result == nil && !gState.Cfg.NoBase { gState.wg.Add(1) - //go gState.testURL(method, page.URL, gState.Client) gState.Chans.workersChan <- workUnit{ Method: method, URLString: page.URL, - //Client: gState.Client, } } if gState.Cfg.Wordlist != "" && string(page.URL[len(page.URL)-1]) == "/" { //if we are testing a directory @@ -155,7 +153,6 @@ func (gState *State) testURL(method string, urlString string, client *http.Clien case gState.Chans.testChan <- method + ":" + urlString: default: //this is to prevent blocking, it doesn't _really_ matter if it doesn't get written to output } - //gState.Chans.workersChan <- struct{}{} headResp, content, good := gState.evaluateURL(method, urlString, client) if !good && !gState.Cfg.ShowAll { diff --git a/librecursebuster/main_test.go b/librecursebuster/main_test.go index 59b3534..dbc4687 100644 --- a/librecursebuster/main_test.go +++ b/librecursebuster/main_test.go @@ -55,37 +55,13 @@ func TestBasicFunctionality(t *testing.T) { //check for each specific line that should be in there.. tested := []string{} - ok200 := []string{ + ok := []string{ "/a", "/a/b", "/a/b/c", "/a/", "/spideronly", - } - for _, i := range ok200 { - tested = append(tested, i) - if x, ok := found[i]; !ok || x == nil { - t.Error("Did not find " + i) - } - } - ok300 := []string{ "/b", "/b/c", - } - for _, i := range ok300 { - tested = append(tested, i) - if x, ok := found[i]; !ok || x == nil { - t.Error("Did not find " + i) - } - } - ok400 := []string{ "/a/b/c/", "/a/b/c/d", - } - for _, i := range ok400 { - tested = append(tested, i) - if x, ok := found[i]; !ok || x == nil { - t.Error("Did not find " + i) - } - } - ok500 := []string{ "/c/d", "/c", "/c/", } - for _, i := range ok500 { + for _, i := range ok { tested = append(tested, i) if x, ok := found[i]; !ok || x == nil { t.Error("Did not find " + i) @@ -577,47 +553,46 @@ z func getDefaultConfig() *Config { return &Config{ - Version: "TEST", - ShowAll: false, - AppendDir: true, - Auth: "", - BadResponses: "404", - BadHeader: nil, //ArrayStringFlag{} // "" // "Check for presence of this header. If an exact match is found" - //BodyContent, "" + Version: "TEST", + ShowAll: false, + + Agent: "RecurseBuster/" + "TESTING", + AppendDir: true, + Auth: "", + BadHeader: nil, //ArrayStringFlag{} // "" // "Check for presence of this header. If an exact match is found" + BadResponses: "404", BlacklistLocation: "", + BurpMode: false, Canary: "", CleanOutput: false, Cookies: "", Debug: false, - //MaxDirs: 1 Extensions: "", + FollowRedirects: false, Headers: nil, // "Additional headers to include with request. Supply as key:value. Can specify multiple - eg '-headers X-Forwarded-For:127.0.01 -headers X-ATT-DeviceId:XXXXX'") HTTPS: false, InputList: "", - SSLIgnore: false, - ShowLen: false, + Localpath: "." + string(os.PathSeparator) + "busted.txt", + Methods: "GET", NoBase: false, NoGet: false, NoHead: false, NoRecursion: false, NoSpider: false, - NoStatus: false, NoStartStop: false, - NoWildcardChecks: false, + NoStatus: false, NoUI: true, - Localpath: "." + string(os.PathSeparator) + "busted.txt", - Methods: "GET", + NoWildcardChecks: false, ProxyAddr: "", Ratio404: 0.95, - FollowRedirects: false, - BurpMode: false, + ShowLen: false, + ShowVersion: false, + SSLIgnore: false, Threads: 1, Timeout: 20, - Agent: "RecurseBuster/" + "TESTING", VerboseLevel: 0, - ShowVersion: false, - Wordlist: "", WhitelistLocation: "", + Wordlist: "", URL: localURL, }