forked from redhuntlabs/BucketLoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.go
61 lines (55 loc) · 1.9 KB
/
input.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
package main
import (
"bufio"
"flag"
"log"
"os"
"strings"
)
func takeInput() {
slowScan = flag.Bool("slow", false, "Set slow mode for the scan")
errorLogging = flag.Bool("log-errors", false, "Log errors in final output")
fullScan = flag.Bool("full", false, "Go beyond the 1000 file scan limit [Requires additional setup!]")
flag.StringVar(&maxFileSize, "max-size", "", "Maximum file size (in bytes)")
flag.StringVar(&keywordSearch, "search", "", "Keyword(s) to look for during the scan. [Possible values -> keyword, keyword1:::keyword2, keywords.txt]")
flag.StringVar(&saveOutput, "save", "", "Save tool output, should either end with .txt or .json [Default output file name is output.json]")
flag.Parse()
args = flag.Args()
if keywordSearch != "" {
if strings.Contains(keywordSearch, ":::") {
keywords := strings.Split(keywordSearch, ":::")
for _, keyword := range keywords {
if strings.HasSuffix(keyword, ".txt") {
file, err := os.Open(keyword)
if err != nil {
log.Fatalln("[Error] Looks like the tool is facing some issue while loading the specified file. [", err.Error(), "]")
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
scanKeywords = append(scanKeywords, scanner.Text())
}
} else {
scanKeywords = append(scanKeywords, keyword)
}
}
} else {
if strings.HasSuffix(keywordSearch, ".txt") {
file, err := os.Open(keywordSearch)
if err != nil {
log.Fatalln("[Error] Looks like the tool is facing some issue while loading the specified file. [", err.Error(), "]")
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
scanKeywords = append(scanKeywords, scanner.Text())
}
} else {
scanKeywords = append(scanKeywords, keywordSearch)
}
}
}
if *fullScan {
readCredsFile()
}
}