-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
70 lines (56 loc) · 1.89 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
package main
import (
"bufio"
"flag"
"io"
"log"
"os"
"strings"
"github.com/CX330Blake/letsgo/pkg/greet"
"github.com/CX330Blake/letsgo/pkg/letsgo"
"github.com/fatih/color"
_ "embed"
)
//go:embed assets/default.txt
var defaultWordlist string
// Load payload
func loadPayloads(filePath string) ([]string, bool) {
useDefault := false
file, err := os.Open(filePath)
if err != nil {
useDefault = true
return strings.Split(defaultWordlist, "\n"), useDefault
// return nil, fmt.Errorf("cannot load the wordlist: %v", err)
}
defer file.Close()
var payloads []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
payloads = append(payloads, scanner.Text())
}
return payloads, useDefault
}
func main() {
log.SetOutput(io.Discard)
// Parse command line arguments
url := flag.String("url", "", "Target URL (e.g. http://example.com)")
param := flag.String("param", "file", "Parameter for testing (default is 'file')")
wordlistFile := flag.String("wordlist", "default.txt", "Wordlist path")
fileRoot := flag.String("root", "", "Root of the server file (e.g. https://example.com/image?filename=/var/www/images/1337.jpg, then root is `/var/www/images`, don't need to include the last `/`)")
extension := flag.String("extension", "", "File extension (e.g. jpg, png, txt, etc.), this will triger the null byte bypass mode")
flag.Parse()
if *url == "" {
color.Magenta("Basic usage: ./letsgo -url <https://example.com>")
os.Exit(1)
}
// Hack the planet
greet.Hello()
payloads, useDefault := loadPayloads(*wordlistFile)
if useDefault && *wordlistFile != "default.txt" {
color.Magenta("[*] Cannot load the wordlist, using default list now...\n")
} else if *wordlistFile == "default.txt" {
color.Magenta("[+] Using default wordlist...\n")
}
letsgo.Test(*url, *param, *fileRoot, *extension, payloads)
greet.End()
}