about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--abc.txt9
-rw-r--r--src/flags.go10
-rw-r--r--src/main.go114
-rw-r--r--src/structs.go38
-rw-r--r--src/wordlist.go26
5 files changed, 157 insertions, 40 deletions
diff --git a/abc.txt b/abc.txt
new file mode 100644
index 0000000..fcc2692
--- /dev/null
+++ b/abc.txt
@@ -0,0 +1,9 @@
+abc
+def
+ghi
+jkl
+vnstati_summary.png
+mno
+pqr
+stu
+vwx
diff --git a/src/flags.go b/src/flags.go
index c96a7d2..adda91d 100644
--- a/src/flags.go
+++ b/src/flags.go
@@ -20,8 +20,8 @@ var (
 	header   string
 
 	// int values
-	concurrent int
-	delay      int
+	threads int
+	delay   int
 
 	// string values defining what request to show or hide
 	hide Hide
@@ -73,9 +73,9 @@ func registerFlags() {
 
 	// Ints
 
-	concurrentUsage := "Amount of concurrent connections to use"
-	flag.IntVar(&concurrent, "concurrent", 1, concurrentUsage)
-	flag.IntVar(&concurrent, "t", 1, concurrentUsage+shortcut)
+	threadsUsage := "Amount of threads connections to use"
+	flag.IntVar(&threads, "threads", 1, threadsUsage)
+	flag.IntVar(&threads, "t", 1, threadsUsage+shortcut)
 
 	delayUsage := "Amount of delay in between the requests"
 	flag.IntVar(&delay, "delay", 0, delayUsage)
diff --git a/src/main.go b/src/main.go
index 3b6ef05..f64df59 100644
--- a/src/main.go
+++ b/src/main.go
@@ -1,42 +1,118 @@
 package main
 
 import (
-	"bufio"
 	"fmt"
 	"log"
-	"os"
+	"net/http"
+	"strings"
 )
 
 func main() {
 	// pase the command line aguments
 	registerFlags()
 
-	// read the wordlist
-	lines, err := readWordlist(wordlist)
+	fmt.Printf(red("asd"))
+	fmt.Printf(boldRed("asd"))
+	fmt.Printf(green("asd"))
+	fmt.Printf(boldGreen("asd"))
+	fmt.Printf(yellow("asd"))
+	fmt.Printf(boldYellow("asd"))
+	fmt.Printf(blue("asd"))
+	fmt.Printf(boldBlue("asd"))
+	fmt.Printf(magenta("asd"))
+	fmt.Printf(boldMagenta("asd"))
+	fmt.Printf(cyan("asd"))
+	fmt.Printf(boldCyan("asd") + "\n")
+
+	// read the wordlist from a file
+	log.Println("reading the wordlist from a file")
+	wordlist, err := readWordlist(wordlist)
 	if err != nil {
 		log.Println(err)
 	}
+	log.Println(green("[+] ") + "done reading the wordlist from a file")
+
+	// define a channel to store the wordlist in
+	wordlistChannel := make(chan string)
+
+	// define a channel in which the response gets written into from the go
+	// routines
+	printChannel := make(chan Response)
+
+	// write all the words from the wordlist into the wordlistChannel
+	go func() {
+		for _, line := range wordlist {
+			wordlistChannel <- line
+		}
+	}()
+
+	fmt.Println(url)
+
+	go func() {
+		var i int
+		for {
+			// read a response from the printChannel for further usage
+			response := <-printChannel
+
+			// define a postfix: a string attached to the end of all printed
+			// string set in the section filtering the status code cases
+			var postfix string
+			var prefix string
 
-	for i, line := range lines {
-		fmt.Printf("%d %s\n", i, string(line))
+			// define what color should be used to print the individual status
+			// codes
+			var statusCode string
+			switch response.StatusCode {
+			case 200:
+				prefix = "\r\033[K"
+				statusCode = green(fmt.Sprintf("%d", response.StatusCode))
+				postfix = "\n"
+			case 404:
+				statusCode = red(fmt.Sprintf("%d", response.StatusCode))
+				postfix = "\033[K\r"
+			}
+
+			// print the foo
+			fmt.Printf("%s%.7d:   %s    %s%s", prefix, i, statusCode, response.FuzzWord, postfix)
+			i++
+		}
+	}()
+
+	if threads > 1 {
+		fmt.Println("threaded")
+		httpRequest(wordlistChannel, printChannel)
+	} else {
+
+		// loop over all the threads starting a go routine fetching a word from
+		// the wordlistChannel, making the request and inserting the result into
+		// the printChannel
+		for i := 0; i < threads; i++ {
+			go httpRequest(wordlistChannel, printChannel)
+		}
 	}
+
 }
 
-func readWordlist(wordlistPath string) ([]string, error) {
-	file, err := os.Open(wordlistPath)
-	if err != nil {
-		return nil, err
-	}
-	defer file.Close()
+func httpRequest(wordlistChannel chan string, printChannel chan Response) {
+	for {
+		// replace the first instance of "FUZZ" in the given url by the next
+		// value from the wordlistChannel
+		fuzzWord := <-wordlistChannel
+		requestURL := strings.Replace(url, "FUZZ", fuzzWord, 1)
 
-	scanner := bufio.NewScanner(file)
-	scanner.Split(bufio.ScanLines)
+		// make the http get request
+		resp, err := http.Get("https://" + requestURL)
+		if err != nil {
+			log.Println(err)
+		}
 
-	var lines []string
+		// define the response
+		var response = Response{
+			StatusCode: resp.StatusCode,
+			FuzzWord:   fuzzWord,
+		}
 
-	for scanner.Scan() {
-		lines = append(lines, scanner.Text())
+		// insert the response into the print channel for further printing
+		printChannel <- response
 	}
-
-	return lines, nil
 }
diff --git a/src/structs.go b/src/structs.go
index 4458dc8..8ca9eb2 100644
--- a/src/structs.go
+++ b/src/structs.go
@@ -2,12 +2,12 @@ package main
 
 // Hide stores what requests to hide
 type Hide struct {
-	hideCode, hideLine, hideWord, hideChar string
+	HideCode, HideLine, HideWord, HideChar string
 }
 
 // Show stores what requests to show
 type Show struct {
-	showCode, showLine, showWord, showChar string
+	ShowCode, ShowLine, ShowWord, ShowChar string
 }
 
 // Config stores the overall config
@@ -18,18 +18,24 @@ type Config struct {
 	Hide Hide
 
 	// misc config
-	color          bool
-	verbose        bool
-	printer        string
-	dryrun         bool
-	proxy          string
-	concurrent     int
-	delay          int
-	followRedirect bool
-	url            string
-	payload        string
-	wordlist       string
-	postData       string
-	headers        string
-	basicauth      string
+	Color          bool
+	Verbose        bool
+	Printer        string
+	Dryrun         bool
+	Proxy          string
+	Concurrent     int
+	Delay          int
+	FollowRedirect bool
+	URL            string
+	Payload        string
+	Wordlist       string
+	PostData       string
+	Headers        string
+	Basicauth      string
+}
+
+// Response defines the http response
+type Response struct {
+	StatusCode int
+	FuzzWord   string
 }
diff --git a/src/wordlist.go b/src/wordlist.go
new file mode 100644
index 0000000..76df5f4
--- /dev/null
+++ b/src/wordlist.go
@@ -0,0 +1,26 @@
+package main
+
+import (
+	"bufio"
+	"os"
+)
+
+func readWordlist(wordlistPath string) ([]string, error) {
+	file, err := os.Open(wordlistPath)
+	if err != nil {
+		return nil, err
+	}
+	defer file.Close()
+
+	scanner := bufio.NewScanner(file)
+	scanner.Split(bufio.ScanLines)
+
+	var lines []string
+
+	for scanner.Scan() {
+		lines = append(lines, scanner.Text())
+	}
+
+	// return the lines, the line count and no error
+	return lines, nil
+}