forked from hahwul/dalfox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codeview.go
38 lines (36 loc) 路 864 Bytes
/
codeview.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
package scanning
import (
"strconv"
"strings"
)
//CodeView is showing reflected code function
func CodeView(resbody, pattern string) string {
var code string
if resbody == "" {
return ""
}
bodyarr := strings.Split(resbody, "\n")
for bk, bv := range bodyarr {
if strings.Contains(bv, pattern) {
max := len(bv)
if max > 80 {
index := strings.Index(bv, pattern)
if index < 20 {
code = code + strconv.Itoa(bk+1) + " line: " + bv[:80] + "\n "
} else {
if max < index+60 {
code = code + strconv.Itoa(bk+1) + " line: " + bv[index-20:max] + "\n "
} else {
code = code + strconv.Itoa(bk+1) + " line: " + bv[index-20:index+60] + "\n "
}
}
} else {
code = code + strconv.Itoa(bk+1) + " line: " + bv + "\n "
}
}
}
if len(code) > 4 {
return code[:len(code)-5]
}
return code
}