-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
93 lines (79 loc) · 3.51 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/DarthCucumber/gofuzz/pkg/data"
"github.com/DarthCucumber/gofuzz/pkg/utils"
)
func main() {
var options data.Options
var session data.SessionData
var parsedNum data.FuzzData
var parsedAscii data.FuzzData
var parsedChar data.FuzzData
var parsedInput data.FuzzData
flag.BoolVar(&options.ShowHelp, "h", false, "shows usage details")
flag.StringVar(&options.TargetUrl, "u", "", "takes in URL for fuzzing")
flag.StringVar(&options.NumRange, "n", "", "takes in range of numbers for fuzzing")
flag.StringVar(&options.CharList, "c", "", "takes in range of characters for fuzzing")
flag.StringVar(&options.AsciiRange, "a", "", "takes in range of ascii values and fuzzes for corresponding character")
flag.StringVar(&options.OutputDir, "o", "./output", "set output folder to save the results")
flag.StringVar(&options.InputFile, "f", "", "file path to list of fuzz data")
flag.StringVar(&options.ExportType, "export", "json", "data format (json/txt) in which the result will be stored in the output file. (default:json)")
flag.StringVar(&options.Method, "m", "HEAD", "Request method [HEAD/GET/POST]")
flag.IntVar(&options.Timeout, "t", 30000, "takes in timeout for each requests in milliseconds. (Default: 30000 ms or 30 s)")
flag.IntVar(&options.Retries, "r", 3, "takes in how many times it will try a request if returns an error. (Default: 3 attempts for each request)")
flag.StringVar(&options.Exclude, "exclude", "", "takes in status code separated by commas to be excluded from display result, however everything is included in the result files")
flag.Parse()
//detect -h and show help options
options.DisplayHelp()
if len(options.TargetUrl) == 0 {
utils.ShowError("No URL provided for fuzzing")
utils.ShowWarning("use -h option for usage options")
os.Exit(0)
}
//parse target url
session.ParsedUrl = options.ParseUrl()
//set timeout
session.Timeout = options.Timeout
//set retries
session.Retries = options.Retries
//check for valid export type(-e)
session.ExportType = options.SetExportType()
//check for valid request method(-m)
session.Method = options.SetRequestMethod()
//set status code to be excluded from the results
session.ExcludeStatus = options.ExcludeStatusCode()
//parse option data and store 'em
parsedNum.InputData = options.ParseNumRange()
parsedAscii.InputData = options.ParseAsciiRange()
parsedChar.InputData = options.ParseCharList()
parsedInput.InputData = options.ReadFuzzFile()
//if no data exists for fuzzing then throw error
if len(parsedInput.InputData) == 0 && len(parsedNum.InputData) == 0 && len(parsedAscii.InputData) == 0 && len(parsedChar.InputData) == 0 {
utils.ShowError("No fuzzing data provided")
utils.ShowInfo("Use -h option to display usage menu")
}
//function to create output folder
session.OutDir = options.SetOutputDir()
//setting metaData to each entity
parsedNum.MetaData = session
parsedAscii.MetaData = session
parsedChar.MetaData = session
parsedInput.MetaData = session
startTime := time.Now()
session.DisplayInfo()
//begin the fuzzing process
parsedNum.BeginFuzzing("numeric")
parsedAscii.BeginFuzzing("ascii")
parsedChar.BeginFuzzing("character")
parsedInput.BeginFuzzing("file data")
utils.ShowSuccess(fmt.Sprintf("Fuzzing take %f seconds finish!", time.Since(startTime).Seconds()))
utils.ShowSuccess("Fuzzing Complete!\n")
// fmt.Printf("%+v\n", parsedNum.Result)
// fmt.Printf("%+v\n", parsedAscii.Result)
// fmt.Printf("%+v\n", parsedChar.Result)
// fmt.Printf("%+v\n", parsedInput.Result)
}