Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29d6f67

Browse files
committed
minor fixes
1 parent d91a424 commit 29d6f67

File tree

1 file changed

+49
-38
lines changed

1 file changed

+49
-38
lines changed

pathBrute.go

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ func testFakePath(urlChan chan string) {
372372
atomic.AddInt32(&currentFakeCount, 1)
373373
}
374374
}
375+
func addToCompleteList(newUrl string) {
376+
completedPathList=append(completedPathList,newUrl)
377+
//fmt.Println("add "+newUrl+" "+strconv.Itoa(len(completedPathList)))
378+
}
379+
375380
func checkURL(urlChan chan string) {
376381
var tmpResultList3 []string
377382
for v := range urlChan {
@@ -708,6 +713,9 @@ func getUrlWorker(urlChan chan string) {
708713
} else if strings.Contains(err.Error(),"server gave HTTP response to HTTPS client") {
709714
fmt.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString("302"),currentListCount,totalListCount)
710715
log.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString("302"),currentListCount,totalListCount)
716+
} else if strings.Contains(err.Error(),"network is unreachablet") {
717+
fmt.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString("Unreachable"),currentListCount,totalListCount)
718+
log.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString("Unreachable"),currentListCount,totalListCount)
711719
} else {
712720
fmt.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString(err.Error()))
713721
log.Printf("%s [%s] [%d of %d]\n",newUrl, color.RedString(err.Error()))
@@ -731,10 +739,6 @@ func getUrlWorker(urlChan chan string) {
731739
finalURL := resp.Request.URL.String()
732740
var tmpTitle = ""
733741
if finalURL==newUrl {
734-
//tmpTitle1,tmpStatus:=GetHtmlTitle(string(body))
735-
//if tmpStatus==true {
736-
// tmpTitle=tmpTitle1
737-
//}
738742
tmpTitle=getPageTitle(newUrl)
739743
}
740744
if intelligentMode==true && CMSmode==false{
@@ -772,19 +776,25 @@ func getUrlWorker(urlChan chan string) {
772776
}
773777
}
774778
}
775-
if tmpStatusCode=="200"{
776-
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle,currentListCount,totalListCount)
777-
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
778-
} else if tmpStatusCode=="401"{
779-
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
780-
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
781-
} else {
782-
if initialStatusCode=="0" {
783-
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(""), lenBody, tmpTitle, currentListCount,totalListCount)
784-
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(""), lenBody, tmpTitle, currentListCount,totalListCount)
779+
if tmpFound==true {
780+
if tmpStatusCode=="200"{
781+
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle,currentListCount,totalListCount)
782+
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
783+
//addToCompleteList(newUrl)
784+
} else if tmpStatusCode=="401"{
785+
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
786+
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
787+
//addToCompleteList(newUrl)
785788
} else {
786-
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
787-
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
789+
if initialStatusCode=="0" {
790+
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(""), lenBody, tmpTitle, currentListCount,totalListCount)
791+
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(""), lenBody, tmpTitle, currentListCount,totalListCount)
792+
//addToCompleteList(newUrl)
793+
} else {
794+
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
795+
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
796+
//addToCompleteList(newUrl)
797+
}
788798
}
789799
}
790800
}
@@ -801,21 +811,26 @@ func getUrlWorker(urlChan chan string) {
801811
log.Printf("%s [%s] [%d of %d]\n",newURL2, color.RedString(initialStatusCode), currentListCount,totalListCount)
802812
var a = [][]string{{newURL2, initialStatusCode, "",""}}
803813
tmpResultList = append(tmpResultList,a...)
814+
//addToCompleteList(newUrl)
804815
} else if (resp.StatusCode!=401 && initialStatusCode=="401") {
805816
fmt.Printf("%s [%s] [%d of %d]\n",newURL2, color.RedString(initialStatusCode), currentListCount,totalListCount)
806817
log.Printf("%s [%s] [%d of %d]\n",newURL2, color.RedString(initialStatusCode), currentListCount,totalListCount)
807818
var a = [][]string{{newURL2, initialStatusCode, "",""}}
808819
tmpResultList = append(tmpResultList,a...)
820+
//addToCompleteList(newUrl)
809821
} else {
810822
if tmpStatusCode=="200"{
811823
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle,currentListCount,totalListCount)
812824
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.BlueString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
825+
//addToCompleteList(newUrl)
813826
} else if tmpStatusCode=="401"{
814827
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
815828
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.GreenString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
829+
//addToCompleteList(newUrl)
816830
} else {
817831
fmt.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
818832
log.Printf("%s [%s] [%d] [%s] [%d of %d]\n",newUrl, color.RedString(initialStatusCode), lenBody, tmpTitle, currentListCount,totalListCount)
833+
//addToCompleteList(newUrl)
819834
}
820835
}
821836
}
@@ -889,32 +904,28 @@ func getUrlWorker(urlChan chan string) {
889904
resp.Body.Close()
890905
_ = resp
891906
_ = tmpTitle
892-
}
907+
}
908+
893909
}
894910

895911
if currentListCount==totalListCount {
896-
if !stringInSlice(newUrl,completedPathList) {
897-
mu.Lock()
898-
completedPathList=append(completedPathList,newUrl)
899-
mu.Unlock()
900-
}
912+
//if !stringInSlice(newUrl,completedPathList) {
913+
//fmt.Println("a1 "+newUrl+" "+strconv.Itoa(len(completedPathList)))
914+
addToCompleteList(newUrl)
915+
//}
901916
reachedTheEnd=true
902917
} else {
903-
if !stringInSlice(newUrl,completedPathList) {
904-
mu.Lock()
905-
completedPathList=append(completedPathList,newUrl)
906-
mu.Unlock()
907-
currentListCount+=1
908-
}
909-
}
918+
addToCompleteList(newUrl)
919+
}
920+
910921
_ = err
911922
} else {
912-
if !stringInSlice(newUrl,completedPathList) {
913-
mu.Lock()
914-
completedPathList=append(completedPathList,newUrl)
915-
mu.Unlock()
916-
currentListCount+=1
917-
}
923+
//if !stringInSlice(newUrl,completedPathList) {
924+
//fmt.Println("a3 "+newUrl+" "+strconv.Itoa(len(completedPathList)))
925+
addToCompleteList(newUrl)
926+
currentListCount+=1
927+
//}
928+
//mu.Unlock()
918929
}
919930
}
920931
}
@@ -1779,9 +1790,7 @@ func main() {
17791790
} else {
17801791
for _, v := range tmpResultList {
17811792
if !stringInSlice(v[0],tmpResultList1) {
1782-
//fmt.Println("xxx ",v[0])
17831793
tmpResultList1 = append(tmpResultList1, v[0])
1784-
//tmpResultList1 = append(tmpResultList1, v[0])
17851794
}
17861795
}
17871796

@@ -1800,7 +1809,9 @@ func main() {
18001809
//Wait until all processes have been completed
18011810
for {
18021811
if len(completedPathList)!=len(finalList) {
1803-
time.Sleep(5 * time.Millisecond)
1812+
//fmt.Println("a "+strconv.Itoa(len(completedPathList))+" "+strconv.Itoa(len(finalList)))
1813+
//time.Sleep(5 * time.Millisecond)
1814+
time.Sleep(5 * time.Second)
18041815
} else {
18051816
break
18061817
}

0 commit comments

Comments
 (0)