Skip to content

Commit

Permalink
fix minor linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Sto committed Nov 19, 2018
1 parent 1e7d83a commit a0e6afd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 58 deletions.
82 changes: 41 additions & 41 deletions librecursebuster/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ type OutLine struct {
Type *ConsoleWriter
}

//var gState *State
//var s *State

//SetState will assign the global state object
//func (gState *State) SetState(s *State) {
//gState = s
//func (s *State) SetState(s *State) {
//s = s
//}

//Wait will wait until all the relevant waitgroups have completed
Expand All @@ -99,12 +99,12 @@ func (s *State) Wait() {
s.wg.Wait()
}
//close all the chans to avoid leaking routines during tests
// close(gState.Chans.confirmedChan)
// close(gState.Chans.newPagesChan)
// close(gState.Chans.pagesChan)
// close(gState.Chans.printChan)
// close(gState.Chans.testChan)
// close(gState.Chans.workersChan)
// close(s.Chans.confirmedChan)
// close(s.Chans.newPagesChan)
// close(s.Chans.pagesChan)
// close(s.Chans.printChan)
// close(s.Chans.testChan)
// close(s.Chans.workersChan)
//StopUI()
}

Expand Down Expand Up @@ -331,80 +331,80 @@ type SpiderPage struct {
}

//SetupState will perform all the basic state setup functions (adding URL's to the blacklist etc)
func (gState *State) SetupState() {
func (s *State) SetupState() {

//set workers (whoops)
//gState.Chans.workersChan = make(chan struct{}, gState.Cfg.Threads)
//s.Chans.workersChan = make(chan struct{}, s.Cfg.Threads)

if gState.Cfg.Ajax {
gState.Cfg.Headers = append(gState.Cfg.Headers, "X-Requested-With:XMLHttpRequest")
if s.Cfg.Ajax {
s.Cfg.Headers = append(s.Cfg.Headers, "X-Requested-With:XMLHttpRequest")
}

for _, x := range strings.Split(gState.Cfg.Extensions, ",") {
gState.Extensions = append(gState.Extensions, x)
for _, x := range strings.Split(s.Cfg.Extensions, ",") {
s.Extensions = append(s.Extensions, x)
}

for _, x := range strings.Split(gState.Cfg.Methods, ",") {
gState.Methods = append(gState.Methods, x)
for _, x := range strings.Split(s.Cfg.Methods, ",") {
s.Methods = append(s.Methods, x)
}

for _, x := range strings.Split(gState.Cfg.BadResponses, ",") {
for _, x := range strings.Split(s.Cfg.BadResponses, ",") {
i, err := strconv.Atoi(x)
if err != nil {
fmt.Println("Bad error code supplied!")
panic(err)
}
gState.BadResponses[i] = true //this is probably a candidate for individual urls. Unsure how to config that cleanly though
s.BadResponses[i] = true //this is probably a candidate for individual urls. Unsure how to config that cleanly though
}

gState.Client = gState.ConfigureHTTPClient(false)
gState.BurpClient = gState.ConfigureHTTPClient(true)
s.Client = s.ConfigureHTTPClient(false)
s.BurpClient = s.ConfigureHTTPClient(true)

gState.Version = gState.Cfg.Version
s.Version = s.Cfg.Version

if gState.Cfg.BlacklistLocation != "" {
if s.Cfg.BlacklistLocation != "" {
readerChan := make(chan string, 100)
go LoadWords(gState.Cfg.BlacklistLocation, readerChan)
go LoadWords(s.Cfg.BlacklistLocation, readerChan)
for x := range readerChan {
gState.Blacklist[x] = true
s.Blacklist[x] = true
}
}

if gState.Cfg.BodyContent != "" {
if s.Cfg.BodyContent != "" {
readerChan := make(chan string, 100)
go LoadWords(gState.Cfg.BodyContent, readerChan)
go LoadWords(s.Cfg.BodyContent, readerChan)
lines := []string{}
for x := range readerChan {
lines = append(lines, x)
}
gState.bodyContent = strings.Join(lines, "\n")
s.bodyContent = strings.Join(lines, "\n")
}

if gState.Cfg.WhitelistLocation != "" {
if s.Cfg.WhitelistLocation != "" {
readerChan := make(chan string, 100)
go LoadWords(gState.Cfg.WhitelistLocation, readerChan)
go LoadWords(s.Cfg.WhitelistLocation, readerChan)
for x := range readerChan {
gState.Whitelist[x] = true
s.Whitelist[x] = true
}
}

if gState.Cfg.Wordlist != "" { // && gState.Cfg.MaxDirs == 1 {
if s.Cfg.Wordlist != "" { // && s.Cfg.MaxDirs == 1 {

zerod := uint32(0)
gState.DirbProgress = &zerod
s.DirbProgress = &zerod

readerChan := make(chan string, 100)
go LoadWords(gState.Cfg.Wordlist, readerChan)
go LoadWords(s.Cfg.Wordlist, readerChan)
for v := range readerChan {
gState.WordList = append(gState.WordList, v)
//atomic.AddUint32(gState.WordlistLen, 1)
s.WordList = append(s.WordList, v)
//atomic.AddUint32(s.WordlistLen, 1)
}
}
workers := uint32(gState.Cfg.Threads)
gState.workerCount = &workers
gState.StartTime = time.Now()
gState.PerSecondShort = new(uint64)
gState.PerSecondLong = new(uint64)
workers := uint32(s.Cfg.Threads)
s.workerCount = &workers
s.StartTime = time.Now()
s.PerSecondShort = new(uint64)
s.PerSecondLong = new(uint64)

}
func getURLSlice(globalState *State) []string {
Expand Down
1 change: 1 addition & 0 deletions librecursebuster/testserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func (ts *TestServer) handler(w http.ResponseWriter, r *http.Request) {
//link for basic spider test. Full spider testing (eg, collecting all link types) should be done in a unit test
}

//TestServer is a webserver instance that facilitates functional testing of code that requires the ability to send web requests
type TestServer struct {
tes *testing.T
visited map[string]bool
Expand Down
34 changes: 17 additions & 17 deletions librecursebuster/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,48 +74,48 @@ func (s *State) StartUI(uiWG *sync.WaitGroup, quitChan chan struct{}) {
}
}

func (gState *State) addWorker(g *ui.Gui, v *ui.View) error {
atomic.AddUint32(gState.workerCount, 1)
go gState.testWorker()
func (s *State) addWorker(g *ui.Gui, v *ui.View) error {
atomic.AddUint32(s.workerCount, 1)
go s.testWorker()
return nil
}

func (gState *State) stopWorker(g *ui.Gui, v *ui.View) error {
count := atomic.LoadUint32(gState.workerCount)
func (s *State) stopWorker(g *ui.Gui, v *ui.View) error {
count := atomic.LoadUint32(s.workerCount)
if count == 0 { //avoid underflow
return nil
}
count = count - 1
atomic.StoreUint32(gState.workerCount, count)
gState.Chans.lessWorkersChan <- struct{}{}
atomic.StoreUint32(s.workerCount, count)
s.Chans.lessWorkersChan <- struct{}{}
return nil
}

//StopUI should be called when closing the program. It prints out the lines in the main view buffer to stdout, and closes the ui object
func (gState *State) StopUI() {
p, _ := gState.ui.View("Main")
func (s *State) StopUI() {
p, _ := s.ui.View("Main")
lines := p.ViewBuffer()
gState.ui.Close()
s.ui.Close()
fmt.Print(lines)
}

func (gState *State) handleX(g *ui.Gui, v *ui.View) error {
func (s *State) handleX(g *ui.Gui, v *ui.View) error {
//vi, _ := g.View("Main")
//close(gState.StopDir)
//close(s.StopDir)
select { //lol dope hack to stop it blocking
case gState.StopDir <- struct{}{}:
case s.StopDir <- struct{}{}:
default:
}
//gState.StopDir <- struct{}{}
//s.StopDir <- struct{}{}
//fmt.Fprintln(v, "X!!!")
return nil
}

func (gState *State) quit(g *ui.Gui, v *ui.View) error {
func (s *State) quit(g *ui.Gui, v *ui.View) error {
return ui.ErrQuit
}

func (gState *State) layout(g *ui.Gui) error {
func (s *State) layout(g *ui.Gui) error {
mX, mY := g.Size()
v, err := g.SetView("Main", 0, 0, mX-1, mY-7)
if err != nil && err != ui.ErrUnknownView {
Expand All @@ -127,7 +127,7 @@ func (gState *State) layout(g *ui.Gui) error {
// Set autoscroll to normal again.
v.Autoscroll = true
}
v.Title = "~Recursebuster V" + gState.Version + " by C_Sto (@C__Sto)~"
v.Title = "~Recursebuster V" + s.Version + " by C_Sto (@C__Sto)~"
_, err = g.SetView("Status", 0, mY-6, mX-1, mY-1)
if err != nil && err != ui.ErrUnknownView {
return err
Expand Down

0 comments on commit a0e6afd

Please sign in to comment.