-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
180 lines (159 loc) · 5.76 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package main
import (
"flag"
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"os"
"strconv"
"github.com/Serhatcck/hidden_fuzzer/pkg/hidden_fuzzer"
)
// Custom function to print usage message
func printUsage(flagSet *flag.FlagSet) {
fmt.Println("Usage: hidden_fuzzer [options]")
fmt.Println("Options:")
flagSet.VisitAll(func(f *flag.Flag) {
name := f.Name
if f.DefValue != "" {
name += fmt.Sprintf(" (default: %s)", f.DefValue)
}
fmt.Printf(" -%-35s %s\n", name, f.Usage)
})
}
func main() {
//test()
var h bool
var options hidden_fuzzer.Options
flagSet := flag.NewFlagSet("Hidden Fuzzer", flag.ExitOnError) // Change to ContinueOnError
//TO DO create new parameter for rate limit
flagSet.BoolVar(&h, "help", false, "Show the help message")
flagSet.StringVar(&options.Wordlist, "w", "", "Wordlist file")
flagSet.StringVar(&options.Url, "u", "", "Target URL")
flagSet.StringVar(&options.Extensions, "e", "", "Extensions, e.g., \".json\". Use commas for multiple extensions")
flagSet.Var(&options.Headers, "H", "Header `\"Name: Value\"`. Use multiple -H for more headers")
flagSet.StringVar(&options.Method, "m", "GET", "HTTP method (currently only supports GET)")
flagSet.IntVar(&options.Threads, "t", 50, "Maximum number of threads")
flagSet.IntVar(&options.FailureConter, "fail-counter", 3, "Number of failures to check")
flagSet.IntVar(&options.DuplicateCounter, "dp-counter", 50, "Number of duplicates to check")
flagSet.IntVar(&options.RedirectConter, "rd-counter", 3, "Number of redirects to check")
flagSet.BoolVar(&options.Silent, "silent", false, "Suppress output")
flagSet.BoolVar(&options.OnlyWriteStats, "only-stats", false, "Only Write Stats")
flagSet.BoolVar(&options.NoInteractive, "no-interactive", false, "No Interactive Window")
flagSet.IntVar(&options.FailureCheckTimeout, "fc-tm-out", 1, "Failure check timeout (seconds)")
flagSet.IntVar(&options.TimeOut, "tm-out", 20, "HTTP response timeout (seconds)")
flagSet.IntVar(&options.Depth, "depth", 3, "Subdirectory depth")
flagSet.BoolVar(&options.ParamFuzing, "param-fuzzing", false, "For parameter fuzzing")
flagSet.StringVar(&options.ParamValue, "param-value", "test", "Value for parameter fuzzing")
flagSet.BoolVar(&options.Pipe, "pipe", false, "For pipe usage")
flagSet.StringVar(&options.FilterCode, "fc", "", "Filter response HTTP status code, only one code allowed")
flagSet.StringVar(&options.ProxyUrl, "proxy", "", "Proxy URL for all ongoing requests")
flagSet.BoolVar(&options.XFFHeader, "xff", false, "Use X-F-F headers")
flagSet.StringVar(&options.XFFValue, "xff-val", "127.0.0.1", "Value for X-F-F headers (e.g., localhost 127.0.0.1)")
flagSet.Int64Var(&options.MaxBodyLengthForCompare, "max-compare-size", 3000, "To address the CPU performance issue with the diff operation, the isSimilar() function compares the HTTP response bodies. However, comparing large HTML files negatively impacts performance. To mitigate this performance problem, a size limit has been imposed on the files to be compared. This way, large files will not undergo comparison, reducing CPU strain.")
flagSet.BoolVar(&options.Recheck, "recheck", false, "Recheck ")
flagSet.IntVar(&options.RateLimit, "rt-limit", 0, "Rate limit (for unlimited rate limit use 0)")
// Parse the flags
flagSet.Usage = func() {
printUsage(flagSet)
}
if err := flagSet.Parse(os.Args[1:]); err != nil {
printUsage(flagSet)
return
}
//
if h {
printUsage(flagSet)
return
}
var conf hidden_fuzzer.Config
err := conf.Build(options)
if err != nil {
log.Fatal(err.Error())
}
worker := hidden_fuzzer.NewWorker(&conf)
errr := worker.Start()
if errr != nil {
fmt.Println("Error: " + errr.Error())
} else {
if !options.Pipe {
fmt.Println("\nAnalze ended:")
fmt.Println("")
}
var foundUrls []hidden_fuzzer.FoundUrl
if options.FilterCode != "" {
for _, resp := range worker.FoundUrls {
if strconv.Itoa(resp.Response.StatusCode) != options.FilterCode {
foundUrls = append(foundUrls, resp)
}
}
} else {
foundUrls = worker.FoundUrls
}
for _, resp := range foundUrls {
if options.Pipe {
fmt.Println(resp.Request.URL)
} else {
if resp.IsRedirect {
//fmt.Println("RedirectedURl: " + resp.Request.URL)
fmt.Println(resp.Request.URL + " : " + strconv.Itoa(resp.Response.StatusCode))
} else {
fmt.Println(resp.Request.URL + " : " + strconv.Itoa(resp.Response.StatusCode))
}
}
}
}
}
func test() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
threadlimiter := make(chan bool, 5)
var targets = [15]string{
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
"http://localhost:8080",
}
for i, target := range targets {
threadlimiter <- true
go func(p int, t string) {
defer func() { <-threadlimiter }()
fmt.Println("Start", p, "----", t)
var conf hidden_fuzzer.Config
err := conf.Build(hidden_fuzzer.Options{
Url: t,
Wordlist: "/Users/serhatcicek/Desktop/wordlists/demo.txt",
Extensions: "",
Method: "GET",
Threads: 350,
FailureConter: 2,
DuplicateCounter: 50,
RedirectConter: 3,
Silent: true,
FailureCheckTimeout: 2,
TimeOut: 20,
Depth: 3,
RateLimit: 300,
})
if err != nil {
log.Fatal(err.Error())
}
worker := hidden_fuzzer.NewWorker(&conf)
worker.Start()
fmt.Println("Done", p, "----", t)
worker.Shutdown()
}(i, target)
}
}