-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs.go
111 lines (90 loc) · 2.08 KB
/
args.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
package main
import (
"flag"
"fmt"
"os"
"strconv"
)
// headerArgs is the type used to store the header arguments
type headerArgs []string
func (h *headerArgs) Set(val string) error {
*h = append(*h, val)
return nil
}
func (h headerArgs) String() string {
return "string"
}
type saveStatusArgs []int
func (s *saveStatusArgs) Set(val string) error {
i, _ := strconv.Atoi(val)
*s = append(*s, i)
return nil
}
func (s saveStatusArgs) String() string {
return "string"
}
func (s saveStatusArgs) Includes(search int) bool {
for _, status := range s {
if status == search {
return true
}
}
return false
}
type config struct {
body string
concurrency int
delay int
headers headerArgs
followLocation bool
method string
saveStatus saveStatusArgs
timeout int
verbose bool
paths string
hosts string
output string
noHeaders bool
requester requester
}
func processArgs() config {
// default the output directory to ./out
output := flag.Arg(2)
if output == "" {
output = defaultOutputDir
}
return config{
body: body,
concurrency: concurrency,
delay: delay,
headers: headers,
followLocation: followLocation,
method: method,
saveStatus: saveStatus,
timeout: timeout,
requester: requesterFn,
verbose: verbose,
paths: paths,
hosts: hosts,
output: output,
noHeaders: noHeaders,
}
}
func init() {
flag.Usage = func() {
h := "Get file Information (i.e. Hashes, ACL's)\n\n"
h += "Usage:\n"
h += " gfi [directory|file] [outputDir]\n\n"
h += "Options:\n"
h += " -d, --directory <val> Set the target directory\n"
h += " -f, --file <val> Set the target file\n"
h += " -o, --output <method> Outputs a .txt file to specified directory.\n\n"
h += "Defaults:\n"
h += " pathsFile: ./paths\n"
h += " outputDir: ./out\n\n"
h += "Examples:\n"
h += " gfi /dir /out/output.txt\n"
h += " gfi /dir1 /dir2 /dir3 /output\n"
fmt.Fprintf(os.Stderr, h)
}
}