-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
77 lines (65 loc) · 1.38 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
package main
import (
"fmt"
"os"
"sync"
"github.com/fatih/color"
"github.com/martinvks/xssparams/args"
"github.com/martinvks/xssparams/scanner"
"github.com/martinvks/xssparams/utils"
)
func main() {
arguments, err := args.Parse()
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
client := utils.NewClient(
arguments.Headers,
arguments.RateLimit,
arguments.Timeout,
arguments.Verbose,
)
scanWG := sync.WaitGroup{}
scanChan := make(chan string)
var results []*scanner.URLResult
for i := 0; i < arguments.Threads; i++ {
scanWG.Add(1)
go func() {
defer scanWG.Done()
for url := range scanChan {
result := scanner.Scan(client, url, arguments.FilterCodes)
if result != nil {
printURLResult(result)
results = append(results, result)
}
}
}()
}
for _, url := range arguments.Urls {
scanChan <- url
}
close(scanChan)
scanWG.Wait()
if arguments.Verbose {
printSummary(results)
}
}
func printSummary(results []*scanner.URLResult) {
fmt.Println()
if len(results) == 0 {
fmt.Println("Scan completed without any findings.")
return
}
fmt.Printf("Found %d URLs potentially vulnerable to xss:\n", len(results))
for _, result := range results {
printURLResult(result)
}
}
func printURLResult(result *scanner.URLResult) {
fmt.Printf(
"%s %s\n",
result.URL,
color.MagentaString("%v", result.ParamsResults),
)
}