-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.js
315 lines (307 loc) · 8.07 KB
/
index.js
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
'use strict';
const WIN = require('ui/window'); // 窗口库
const LANG_T = antSword['language']['toastr']; // 通用通知提示
const path = require('path');
const {
BaseInfo
} = require('./payload');
const LANG = require('./language/'); // 插件语言库
/**
* 插件类
*/
class Plugin {
constructor(opt) {
let self = this;
self.opt = opt;
self.core = new antSword['core'][opt['type']](opt);
self.core_menu = [
// 新增模式时需要在这里添加
// id 为文件名
{
id: "ld_preload",
icon: 'file-code-o',
type: 'button',
text: "LD_PRELOAD"
},
{
id: "php_fpm",
icon: 'file-code-o',
type: 'button',
text: "Fastcgi/PHP_FPM"
},
{
id: "apache_mod_cgi",
icon: 'file-code-o',
type: 'button',
text: "Apache_mod_cgi"
},
{
id: "json_serializer_uaf",
icon: 'file-code-o',
type: 'button',
text: "JSON_Serializer_UAF"
},
{
id: "php7_gc_uaf",
icon: 'file-code-o',
type: 'button',
text: "PHP7_GC_UAF"
},
{
id: "php7_backtrace_uaf",
icon: 'file-code-o',
type: 'button',
text: "PHP7_Backtrace_UAF"
},
{
id: "php74_ffi",
icon: 'file-code-o',
type: 'button',
text: "PHP74_FFI"
},
{
id: "iconv",
icon: 'file-code-o',
type: 'button',
text: "iconv"
},
{
id: "php7_reflectionproperty_uaf",
icon: 'file-code-o',
type: 'button',
text: "PHP7_ReflectionProperty_UAF"
},
{
id: "php7_userfilter",
icon: 'file-code-o',
type: 'button',
text: "PHP7_UserFilter"
},
{
id: "php_concat_uaf",
icon: 'file-code-o',
type: 'button',
text: "PHP_Concat_UAF"
},
];
let cores = {};
self.core_menu.map((_) => {
cores[_.id] = require(`./core/${_.id}/index`);
});
self.cores = cores;
self.infodata = {
os: "",
arch: "",
ver: "",
shell_name: "", // shell 文件名
phpself: "",
temp_dir: "",
open_basedir: [],
funcs: [],
};
// 创建一个 window
self.status_check = null;
let win = new WIN({
title: `${LANG['title']}-${opt['ip']}`,
height: 500,
width: 650,
});
self.win = win;
self.createToolbar();
self.layout = win.win.attachLayout('2U');
self.config_cell = self.createConfigCell(self.layout.cells('a'));
self.status_cell = self.createStatusCell(self.layout.cells('b'));
self.core_instance = null;
self.reloadStatusCell();
self.toolbar.attachEvent('onClick', (id) => {
switch (id) {
case 'start':
self.toolbar.disableItem('start');
try {
self.core_instance.exploit();
} catch (e) {
toastr.error(JSON.stringify(e), LANG_T['error']);
}
break;
default:
if (self.cores.hasOwnProperty(id)) {
self.core_instance = new self.cores[id](self.config_cell.cell, self);
self.toolbar.enableItem('start');
}
break;
}
});
// ######### 上方是具体插件代码,由插件作者编写 ##########
}
reloadStatusCell() {
let self = this;
self.core.request({
_: BaseInfo()
}).then((_ret) => { // 处理返回数据
let res = _ret['text'];
if (res.indexOf("ERROR://") > -1) {
throw res;
} else if (res != "") {
res = antSword.unxss(res, false);
self.infodata = Object.assign(self.infodata, JSON.parse(res));
self.status_cell = self.createStatusCell(self.layout.cells('b'));
}
}).catch((err) => { // 处理异常数据
toastr.error(`${LANG['error']}: ${JSON.stringify(err)}`, LANG_T['error']);
});
}
createStatusCell(cell) {
let self = this;
cell.setWidth(220);
cell.fixSize(1, 0);
cell.setText(`<i class="fa fa-info"></i> ${LANG['status_cell']['title']}`);
let form = cell.attachForm([{
type: 'settings',
position: 'label-left',
labelWidth: 80,
}, {
type: 'block',
inputWidth: 'auto',
list: [{
type: 'settings',
blockOffset: 0,
labelAlign: "left"
},
{
type: "label",
label: `<span>${LANG['status_cell']['ver']}</span>`
},
{
type: "label",
label: `<span>${LANG['status_cell']['arch']}</span>`
},
{
type: "label",
label: `<span>${LANG['status_cell']['os']}</span>`
},
{
type: "label",
label: `<span>${LANG['status_cell']['phpself']}</span>`
},
{
type: "label",
label: `<span>${LANG['status_cell']['shell_dir']}</span>`
},
{
type: "newcolumn"
},
{
type: "label",
name: "ver",
label: `<span style='color: #000000;'>${antSword.noxss(self.infodata["ver"])}</span>`
},
{
type: "label",
name: "arch",
label: `<span style='color: #000000;'>${antSword.noxss(self.infodata["arch"])}</span>`
},
{
type: "label",
name: "os",
label: `<span style='color: #000000;'>${antSword.noxss(self.infodata["os"])}</span>`
},
{
type: "label",
name: "phpself",
label: `<span style='color: #000000;'>${antSword.noxss(self.infodata["phpself"])}</span>`
},
{
type: "label",
name: "shell_dir",
label: `<span style='color: #000000;'>${antSword.noxss(self.infodata["shell_dir"])}</span>`
},
]
},
{
type: 'fieldset',
blockOffset: 0,
label: "open_basedir",
width: "auto",
name: "open_basedir",
list: (() => {
let ret = [];
Object.keys(self.infodata.open_basedir).map((v) => {
if (self.infodata.open_basedir[v] == 1) {
ret.push({
type: "label",
label: `<span style='color: green;'>${antSword.noxss(v)}</span>`
});
} else {
ret.push({
type: "label",
label: `<span style='color: red;'>${antSword.noxss(v)}</span>`
});
}
});
return ret;
})()
},
{
type: 'fieldset',
blockOffset: 0,
label: LANG['status_cell']['func'],
width: "auto",
name: "funcs",
list: (() => {
let ret = [];
Object.keys(self.infodata.funcs).map((v) => {
let status = "";
if (self.infodata.funcs[v] == 1) {
status = "<span style='color: green;'>√</span>";
} else {
status = "<span style='color: red;'>x</span>";
}
ret.push({
type: "label",
labelWidth: 150,
label: `${antSword.noxss(v)} ${status}`
});
});
return ret;
})()
}
], true);
return {
cell: cell,
form: form,
}
}
createToolbar() {
let self = this;
let toolbar = self.win.win.attachToolbar();
toolbar.loadStruct([{
id: 'new',
type: 'buttonSelect',
icon: 'plus-circle',
openAll: true,
text: LANG['toolbar']['select_mode'],
options: self.core_menu,
}, {
id: 'start',
type: 'button',
text: LANG['toolbar']['start'],
icon: 'play',
enabled: false,
}, ]);
self.toolbar = toolbar;
}
createConfigCell(cell) {
let self = this;
cell.hideHeader();
cell.attachHTMLString(`
<div align="center" class="about">
<p style="color: #795548;margin: 30% auto;">${LANG['no_mode']}</p>
</div>
`);
return {
cell: cell,
toolbar: toolbar,
}
}
}
module.exports = Plugin;