/
verify.go
58 lines (51 loc) 路 1.22 KB
/
verify.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
package verification
import (
"fmt"
"io/ioutil"
"strings"
"github.com/PuerkitoBio/goquery"
)
// VerifyReflectionWithLine is check reflected param for mining
func VerifyReflectionWithLine(body, payload string) (bool, int) {
bodyArray := strings.Split(body, "\n")
count := 0
for l, v := range bodyArray {
if strings.Contains(v, payload) {
count = count + l + 1
}
}
if count != 0 {
return true, count
}
return false, 0
}
// VerifyReflection is check reflected param for xss and mining
func VerifyReflection(body, payload string) bool {
if strings.Contains(body, payload) {
return true
}
return false
}
// VerifyDOM is check success inject on code
func VerifyDOM(s string) bool { //(body io.ReadCloser) bool {
body := ioutil.NopCloser(strings.NewReader(s)) // r type is io.ReadCloser
defer body.Close()
// Load the HTML document
doc, err := goquery.NewDocumentFromReader(body)
check := false
if err != nil {
fmt.Println(err)
return false
}
// Find the review items
doc.Find(".dalfox").Each(func(i int, s *goquery.Selection) {
check = true
})
if !check {
doc.Find("#dalfox").Each(func(i int, s *goquery.Selection) {
// For each item found, get the band and title
check = true
})
}
return check
}