forked from redhuntlabs/Hunt4Spring
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
78 lines (67 loc) · 1.77 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
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strings"
)
func startCheck(url string) {
table.SetHeader([]string{"Host", "Vulnerability Possibility"})
if !strings.Contains(url, "://") {
url = fmt.Sprintf("http://%s", url)
}
if !strings.HasSuffix(url, "/") {
url = fmt.Sprintf("%s/", url)
}
isvulnerable := heuristicCheck(url)
var addnew jsondata
if !isvulnerable {
var tabledata = []string{url, "NO"}
addnew.Host = url
addnew.IsVulnerable = false
table.Append(tabledata)
} else {
var tabledata = []string{url, "YES"}
addnew.Host = url
addnew.IsVulnerable = true
table.Append(tabledata)
}
if exploitMode {
iscomplete, path := runExploit(url)
addnew.ExploitCompleted = iscomplete
addnew.PayloadPath = path
}
finalData = append(finalData, addnew)
fmt.Println("")
}
func main() {
fmt.Println(banner, "\n\n", lackOfArt, "\n ")
flag.StringVar(&url, "url", "", "Specify a single target URL.")
flag.StringVar(&targetfile, "file", "", "Specify a file containing a list of target URLs.")
flag.BoolVar(&exploitMode, "exploit", false, "Turns on exploitation mode.")
flag.StringVar(&outfile, "outfile", "hunt4spring.json", "Output file name to store results.")
flag.Parse()
if len(url) < 1 && len(targetfile) < 1 {
log.Fatalln("You need to specify a URL or a file containing URLs.")
}
if len(url) > 0 {
startCheck(url)
} else if len(targetfile) > 0 {
file, err := os.Open(targetfile)
if err != nil {
log.Fatalln("failed to open file named", targetfile)
}
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
startCheck(strings.TrimSpace(scanner.Text()))
}
}
table.Render()
if !serializeJSON(outfile) {
log.Fatalln("Could not serialize output to JSON file.")
}
}