Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
0786dc41
Commit
0786dc41
authored
Jul 13, 2022
by
Medicean
Committed by
Medicean
Jul 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade(Aproxy): aproxy 设置后不需要再重启了
parent
dc810641
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
249 deletions
+185
-249
request.js
modules/request.js
+144
-219
app.entry.js
source/app.entry.js
+11
-0
aproxy.js
source/modules/settings/aproxy.js
+23
-11
index.js
source/modules/shellmanager/index.js
+6
-18
index.js
source/modules/shellmanager/list/index.js
+1
-1
No files found.
modules/request.js
View file @
0786dc41
...
@@ -19,6 +19,7 @@ const {
...
@@ -19,6 +19,7 @@ const {
let
logger
;
let
logger
;
// 请求UA
// 请求UA
const
USER_AGENT
=
require
(
'random-fake-useragent'
);
const
USER_AGENT
=
require
(
'random-fake-useragent'
);
const
{
unescape
}
=
require
(
'querystring'
);
// 请求超时
// 请求超时
const
REQ_TIMEOUT
=
10000
;
const
REQ_TIMEOUT
=
10000
;
...
@@ -39,16 +40,17 @@ class Request {
...
@@ -39,16 +40,17 @@ class Request {
ipcMain
.
on
(
'aproxytest'
,
this
.
onAproxyTest
.
bind
(
this
));
ipcMain
.
on
(
'aproxytest'
,
this
.
onAproxyTest
.
bind
(
this
));
ipcMain
.
on
(
'request'
,
this
.
onRequest
.
bind
(
this
));
ipcMain
.
on
(
'request'
,
this
.
onRequest
.
bind
(
this
));
ipcMain
.
on
(
'download'
,
this
.
onDownlaod
.
bind
(
this
));
ipcMain
.
on
(
'download'
,
this
.
onDownlaod
.
bind
(
this
));
superagentProxy
(
superagent
);
}
}
/**
/**
*
加载
代理配置
*
设置全局
代理配置
* @param {Object} event ipcMain事件
* @param {Object} event ipcMain事件
* @param {Object} opts 代理配置
* @param {Object} opts 代理配置
* @return {[type]} [description]
* @return {[type]} [description]
*/
*/
onAproxy
(
event
,
opts
)
{
onAproxy
(
event
,
opts
)
{
logger
.
debug
(
'aProxy::Set Proxy Mode -'
,
APROXY_CONF
[
'mode'
]
===
'manualproxy'
?
logger
.
debug
(
'aProxy::Set
Global
Proxy Mode -'
,
APROXY_CONF
[
'mode'
]
===
'manualproxy'
?
APROXY_CONF
[
'uri'
]
:
APROXY_CONF
[
'uri'
]
:
'noproxy'
);
'noproxy'
);
...
@@ -56,11 +58,13 @@ class Request {
...
@@ -56,11 +58,13 @@ class Request {
APROXY_CONF
[
'uri'
]
=
opts
[
'aproxyuri'
];
APROXY_CONF
[
'uri'
]
=
opts
[
'aproxyuri'
];
if
(
APROXY_CONF
[
'mode'
]
===
'noproxy'
)
{
if
(
APROXY_CONF
[
'mode'
]
===
'noproxy'
)
{
return
superagent
.
Request
.
prototype
.
proxy
=
function
()
{
APROXY_CONF
[
'uri'
]
=
''
return
this
// return superagent.Request.prototype.proxy = function() {
};
// return this
// };
}
}
superagentProxy
(
superagent
);
// superagentProxy(superagent);
event
.
sender
.
send
(
'aproxy-update'
,
opts
);
}
}
/**
/**
...
@@ -76,7 +80,7 @@ class Request {
...
@@ -76,7 +80,7 @@ class Request {
.
sender
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
}
}
superagentProxy
(
superagent
);
//
superagentProxy(superagent);
superagent
superagent
.
get
(
opts
[
'url'
])
.
get
(
opts
[
'url'
])
.
set
(
'User-Agent'
,
USER_AGENT
.
getRandom
())
.
set
(
'User-Agent'
,
USER_AGENT
.
getRandom
())
...
@@ -97,6 +101,60 @@ class Request {
...
@@ -97,6 +101,60 @@ class Request {
});
});
}
}
// 设置headers
buildHeaders
(
request
,
opts
)
{
let
self
=
this
;
request
.
set
(
'User-Agent'
,
USER_AGENT
.
getRandom
());
// 自定义headers
for
(
let
_
in
opts
.
headers
)
{
if
(
_
.
toLocaleLowerCase
()
==
'content-type'
)
{
self
.
reqContentType
=
opts
.
headers
[
_
];
}
request
.
set
(
_
,
opts
.
headers
[
_
]);
}
}
/**
*
* @param {object} opts
* @returns object
*
* 根据 opts 中的配置组装 http body
*/
buildBody
(
opts
=
{})
{
let
_postData
=
Object
.
assign
({},
opts
.
body
,
opts
.
data
);
if
(
opts
[
'useRaw'
]
==
1
)
{
// raw 模式 data 部分仅发送 pwd 键下的数据
let
_tmp
=
encodeURIComponent
(
opts
.
data
[
opts
[
'pwd'
]]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
);
});
// return string
return
_tmp
;
}
else
{
let
_postarr
=
[];
if
(
opts
[
'addMassData'
]
==
1
)
{
for
(
let
i
=
0
;
i
<
randomInt
(
num_min
,
num_max
);
i
++
)
{
//将混淆流量放入到payload数组中
_postData
[
randomString
(
randomInt
(
varname_min
,
varname_max
))]
=
randomString
(
randomInt
(
data_min
,
data_max
));
}
_postData
=
randomDict
(
_postData
);
}
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
);
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
if
(
opts
[
'useMultipart'
]
==
1
)
{
// return object {k: v}
return
_postData
;
}
// return array ["k1=v1","k2=v2"]
return
_postarr
;
}
}
/**
/**
* 监听HTTP请求
* 监听HTTP请求
* @param {Object} event ipcMain事件对象
* @param {Object} event ipcMain事件对象
...
@@ -105,169 +163,97 @@ class Request {
...
@@ -105,169 +163,97 @@ class Request {
*/
*/
onRequest
(
event
,
opts
)
{
onRequest
(
event
,
opts
)
{
logger
.
debug
(
'onRequest::opts'
,
opts
);
logger
.
debug
(
'onRequest::opts'
,
opts
);
let
self
=
this
;
if
(
opts
[
'url'
].
match
(
CONF
.
urlblacklist
))
{
if
(
opts
[
'url'
].
match
(
CONF
.
urlblacklist
))
{
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
}
}
let
reqContentType
=
"form"
;
self
.
reqContentType
=
"form"
;
let
_request
=
superagent
.
post
(
opts
[
'url'
]);
let
_request
=
superagent
.
post
(
opts
[
'url'
]);
// 设置headers
self
.
buildHeaders
(
_request
,
opts
);
_request
.
set
(
'User-Agent'
,
USER_AGENT
.
getRandom
());
let
_datasuccess
=
false
;
// 表示是否是 404 类shell
// 自定义headers
_request
=
_request
for
(
let
_
in
opts
.
headers
)
{
.
proxy
(
APROXY_CONF
[
'uri'
])
if
(
_
.
toLocaleLowerCase
()
==
'content-type'
)
{
.
type
(
self
.
reqContentType
)
reqContentType
=
opts
.
headers
[
_
];
// .set('Content-Type', 'application/x-www-form-urlencoded')
}
.
timeout
(
opts
.
timeout
||
REQ_TIMEOUT
)
_request
.
set
(
_
,
opts
.
headers
[
_
]);
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
}
// 自定义body
let
_postData
=
Object
.
assign
({},
opts
.
body
,
opts
.
data
);
if
(
opts
[
'useChunk'
]
==
1
)
{
if
(
opts
[
'useChunk'
]
==
1
)
{
logger
.
debug
(
"request with Chunked"
);
logger
.
debug
(
"request with Chunked"
);
let
antstream
;
let
antstream
;
if
(
opts
[
'useRaw'
]
==
1
)
{
if
(
opts
[
'useRaw'
]
==
1
)
{
// raw 模式 data 部分仅发送 pwd 键下的数据
// raw 模式 data 部分仅发送 pwd 键下的数据
let
_tmp
=
encodeURIComponent
(
opts
.
data
[
opts
[
'pwd'
]]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
let
_tmp
=
unescape
(
self
.
buildBody
(
opts
));
return
unescape
(
$1
);
});
antstream
=
new
AntRead
(
_tmp
,
{
antstream
=
new
AntRead
(
_tmp
,
{
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
});
});
}
else
{
}
else
{
let
_postarr
=
[];
let
_postarr
=
self
.
buildBody
(
opts
);
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
);
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
antstream
=
new
AntRead
(
_postarr
.
join
(
"&"
),
{
antstream
=
new
AntRead
(
_postarr
.
join
(
"&"
),
{
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
});
});
}
}
let
_datasuccess
=
false
;
// 表示是否是 404 类shell
_request
.
parse
((
res
,
callback
)
=>
{
_request
self
.
parse
(
opts
[
'tag_s'
],
opts
[
'tag_e'
],
(
chunk
)
=>
{
.
proxy
(
APROXY_CONF
[
'uri'
])
event
.
sender
.
send
(
'request-chunk-'
+
opts
[
'hash'
],
chunk
);
.
type
(
reqContentType
)
// .set('Content-Type', 'application/x-www-form-urlencoded')
.
timeout
(
opts
.
timeout
||
REQ_TIMEOUT
)
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
parse
((
res
,
callback
)
=>
{
this
.
parse
(
opts
[
'tag_s'
],
opts
[
'tag_e'
],
(
chunk
)
=>
{
event
.
sender
.
send
(
'request-chunk-'
+
opts
[
'hash'
],
chunk
);
},
res
,
(
err
,
ret
)
=>
{
},
res
,
(
err
,
ret
)
=>
{
let
buff
=
ret
?
let
buff
=
ret
?
ret
:
Buffer
.
from
();
ret
:
Buffer
.
from
();
// 自动猜测编码
// 自动猜测编码
let
encoding
=
detectEncoding
(
buff
,
{
let
encoding
=
detectEncoding
(
buff
,
{
defaultEncoding
:
"unknown"
defaultEncoding
:
"unknown"
});
});
logger
.
debug
(
"detect encoding:"
,
encoding
);
logger
.
debug
(
"detect encoding:"
,
encoding
);
encoding
=
encoding
!=
"unknown"
?
encoding
=
encoding
!=
"unknown"
?
encoding
:
opts
[
'encode'
];
encoding
:
opts
[
'encode'
];
let
text
=
iconv
.
decode
(
buff
,
encoding
);
let
text
=
iconv
.
decode
(
buff
,
encoding
);
if
(
err
&&
text
==
""
)
{
if
(
err
&&
text
==
""
)
{
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
};
};
// 回调数据
// 回调数据
event
event
.
sender
.
send
(
'request-'
+
opts
[
'hash'
],
{
.
sender
text
:
text
,
.
send
(
'request-'
+
opts
[
'hash'
],
{
buff
:
buff
,
text
:
text
,
encoding
:
encoding
buff
:
buff
,
});
encoding
:
encoding
});
_datasuccess
=
true
;
_datasuccess
=
true
;
callback
(
null
,
ret
);
callback
(
null
,
ret
);
});
});
})
})
.
on
(
'error'
,
(
err
)
=>
{
.
on
(
'error'
,
(
err
)
=>
{
if
(
_datasuccess
==
false
)
{
if
(
_datasuccess
==
false
)
{
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
}
}
});
});
antstream
.
pipe
(
_request
);
antstream
.
pipe
(
_request
);
}
else
{
}
else
{
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const
old_send
=
_request
.
send
;
const
formdata_send
=
_request
.
send
;
let
_postarr
=
[];
let
_postarr
=
self
.
buildBody
(
opts
);
if
(
opts
[
'useRaw'
]
==
1
)
{
if
(
opts
[
'useRaw'
]
==
1
)
{
let
_tmp
=
String
(
opts
.
data
[
opts
[
'pwd'
]]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
_postarr
=
unescape
(
_postarr
);
return
unescape
(
$1
);
});
_postarr
=
_tmp
;
}
else
{
}
else
{
if
(
opts
[
'useMultipart'
]
==
1
)
{
if
(
opts
[
'useMultipart'
]
==
1
)
{
_request
.
send
=
_request
.
field
;
_request
.
send
=
_request
.
field
;
// multipart 下发送的是 Object
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
String
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
)
});
_postarr
[
key
]
=
_tmp
;
}
}
}
else
{
}
else
{
if
(
opts
[
'addMassData'
]
==
1
){
_request
.
send
=
formdata_send
;
for
(
let
i
=
0
;
i
<
randomInt
(
num_min
,
num_max
);
i
++
)
{
//将混淆流量放入到payload数组中
_postarr
=
_postarr
.
join
(
'&'
);
// form-data 发送的是 key=value 字符串
_postData
[
randomString
(
randomInt
(
varname_min
,
varname_max
))]
=
randomString
(
randomInt
(
data_min
,
data_max
));
}
_postData
=
randomDict
(
_postData
);
//logger.debug(_postData);
}
_request
.
send
=
old_send
;
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
)
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
//console.log(_postarr);
//logger.debug(_postarr);
_postarr
=
_postarr
.
join
(
'&'
);
}
}
}
}
_request
_request
.
proxy
(
APROXY_CONF
[
'uri'
])
.
type
(
reqContentType
)
// 超时
.
timeout
(
opts
.
timeout
||
REQ_TIMEOUT
)
// 忽略HTTPS
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
send
(
_postarr
)
.
send
(
_postarr
)
.
buffer
(
true
)
.
buffer
(
true
)
.
parse
((
res
,
callback
)
=>
{
.
parse
((
res
,
callback
)
=>
{
this
.
parse
(
opts
[
'tag_s'
],
opts
[
'tag_e'
],
(
chunk
)
=>
{
self
.
parse
(
opts
[
'tag_s'
],
opts
[
'tag_e'
],
(
chunk
)
=>
{
event
event
.
sender
.
send
(
'request-chunk-'
+
opts
[
'hash'
],
chunk
);
.
sender
.
send
(
'request-chunk-'
+
opts
[
'hash'
],
chunk
);
},
res
,
callback
);
},
res
,
callback
);
})
})
.
end
((
err
,
ret
)
=>
{
.
end
((
err
,
ret
)
=>
{
if
(
!
ret
)
{
if
(
!
ret
)
{
// 请求失败 TIMEOUT
// 请求失败 TIMEOUT
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
}
}
let
buff
=
ret
.
hasOwnProperty
(
'body'
)
?
let
buff
=
ret
.
hasOwnProperty
(
'body'
)
?
ret
.
body
:
Buffer
.
from
();
ret
.
body
:
Buffer
.
from
();
// 解码
// 解码
let
text
=
""
;
let
text
=
""
;
// 自动猜测编码
// 自动猜测编码
...
@@ -275,23 +261,17 @@ class Request {
...
@@ -275,23 +261,17 @@ class Request {
defaultEncoding
:
"unknown"
defaultEncoding
:
"unknown"
});
});
logger
.
debug
(
"detect encoding:"
,
encoding
);
logger
.
debug
(
"detect encoding:"
,
encoding
);
encoding
=
encoding
!=
"unknown"
?
encoding
=
encoding
!=
"unknown"
?
encoding
:
opts
[
'encode'
];
encoding
:
opts
[
'encode'
];
text
=
iconv
.
decode
(
buff
,
encoding
);
text
=
iconv
.
decode
(
buff
,
encoding
);
if
(
err
&&
text
==
""
)
{
if
(
err
&&
text
==
""
)
{
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
err
);
};
};
// 回调数据
// 回调数据
event
event
.
sender
.
send
(
'request-'
+
opts
[
'hash'
],
{
.
sender
text
:
text
,
.
send
(
'request-'
+
opts
[
'hash'
],
{
buff
:
buff
,
text
:
text
,
encoding
:
encoding
buff
:
buff
,
});
encoding
:
encoding
});
});
});
}
}
}
}
...
@@ -303,11 +283,10 @@ class Request {
...
@@ -303,11 +283,10 @@ class Request {
* @return {[type]} [description]
* @return {[type]} [description]
*/
*/
onDownlaod
(
event
,
opts
)
{
onDownlaod
(
event
,
opts
)
{
let
self
=
this
;
logger
.
debug
(
'onDownlaod'
,
opts
);
logger
.
debug
(
'onDownlaod'
,
opts
);
if
(
opts
[
'url'
].
match
(
CONF
.
urlblacklist
))
{
if
(
opts
[
'url'
].
match
(
CONF
.
urlblacklist
))
{
return
event
return
event
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
.
sender
.
send
(
'request-error-'
+
opts
[
'hash'
],
"Blacklist URL"
);
}
}
// 创建文件流
// 创建文件流
const
rs
=
fs
.
createWriteStream
(
opts
[
'path'
]);
const
rs
=
fs
.
createWriteStream
(
opts
[
'path'
]);
...
@@ -315,141 +294,89 @@ class Request {
...
@@ -315,141 +294,89 @@ class Request {
let
indexStart
=
-
1
;
let
indexStart
=
-
1
;
let
indexEnd
=
-
1
;
let
indexEnd
=
-
1
;
let
tempData
=
[];
let
tempData
=
[];
let
reqContentType
=
"form"
;
self
.
reqContentType
=
"form"
;
let
_request
=
superagent
.
post
(
opts
[
'url'
]);
let
_request
=
superagent
.
post
(
opts
[
'url'
]);
// 设置headers
// 设置headers
_request
.
set
(
'User-Agent'
,
USER_AGENT
.
getRandom
());
self
.
buildHeaders
(
_request
,
opts
);
// 自定义headers
let
_datasuccess
=
false
;
// 表示是否是 404 类shell
for
(
let
_
in
opts
.
headers
)
{
_request
=
_request
if
(
_
.
toLocaleLowerCase
()
==
'content-type'
)
{
.
proxy
(
APROXY_CONF
[
'uri'
])
reqContentType
=
opts
.
headers
[
_
];
.
type
(
self
.
reqContentType
)
}
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
_request
.
set
(
_
,
opts
.
headers
[
_
]);
// 自定义body
}
// 自定义body
let
_postData
=
Object
.
assign
({},
opts
.
body
,
opts
.
data
);
let
_postData
=
Object
.
assign
({},
opts
.
body
,
opts
.
data
);
if
(
opts
[
'useChunk'
]
==
1
)
{
if
(
opts
[
'useChunk'
]
==
1
)
{
logger
.
debug
(
"request with Chunked"
);
logger
.
debug
(
"request with Chunked"
);
let
antstream
;
let
antstream
;
if
(
opts
[
'useRaw'
]
==
1
)
{
if
(
opts
[
'useRaw'
]
==
1
)
{
// raw 模式 data 部分仅发送 pwd 键下的数据
// raw 模式 data 部分仅发送 pwd 键下的数据
let
_tmp
=
encodeURIComponent
(
opts
.
data
[
opts
[
'pwd'
]]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
let
_tmp
=
unescape
(
self
.
buildBody
(
opts
));
return
unescape
(
$1
);
});
antstream
=
new
AntRead
(
_tmp
,
{
antstream
=
new
AntRead
(
_tmp
,
{
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
});
});
}
else
{
}
else
{
let
_postarr
=
[];
let
_postarr
=
self
.
buildBody
(
opts
);
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
);
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
antstream
=
new
AntRead
(
_postarr
.
join
(
"&"
),
{
antstream
=
new
AntRead
(
_postarr
.
join
(
"&"
),
{
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
});
});
}
}
_request
_request
.
proxy
(
APROXY_CONF
[
'uri'
])
.
type
(
reqContentType
)
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
parse
((
res
,
callback
)
=>
{
.
parse
((
res
,
callback
)
=>
{
res
.
pipe
(
through
((
chunk
)
=>
{
res
.
pipe
(
through
((
chunk
)
=>
{
// 判断数据流中是否包含后截断符?长度++
// 判断数据流中是否包含后截断符?长度++
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
if
(
temp
!==
-
1
)
{
if
(
temp
!==
-
1
)
{
indexEnd
=
Buffer
indexEnd
=
Buffer
.
concat
(
tempData
).
length
+
temp
;
.
concat
(
tempData
)
.
length
+
temp
;
};
};
tempData
.
push
(
chunk
);
tempData
.
push
(
chunk
);
event
event
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
},
()
=>
{
},
()
=>
{
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
indexStart
=
tempDataBuffer
.
indexOf
(
opts
[
'tag_s'
])
||
0
;
indexStart
=
tempDataBuffer
.
indexOf
(
opts
[
'tag_s'
])
||
0
;
// 截取最后的数据
// 截取最后的数据
let
finalData
=
Buffer
.
from
(
tempDataBuffer
.
slice
(
indexStart
+
opts
[
'tag_s'
].
length
,
indexEnd
),
'binary'
);
let
finalData
=
Buffer
.
from
(
tempDataBuffer
.
slice
(
indexStart
+
opts
[
'tag_s'
].
length
,
indexEnd
),
'binary'
);
// 写入文件流&&关闭
// 写入文件流&&关闭
rs
.
write
(
finalData
);
rs
.
write
(
finalData
);
rs
.
close
();
rs
.
close
();
event
event
.
sender
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
.
sender
_datasuccess
=
true
;
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
// 删除内存数据
// 删除内存数据
finalData
=
tempDataBuffer
=
tempData
=
null
;
finalData
=
tempDataBuffer
=
tempData
=
null
;
}))
}))
})
})
.
on
(
'error'
,
(
err
)
=>
{
.
on
(
'error'
,
(
err
)
=>
{
return
event
.
sender
.
send
(
'download-error-'
+
opts
[
'hash'
],
err
);
if
(
_datasuccess
==
false
)
{
return
event
.
sender
.
send
(
'download-error-'
+
opts
[
'hash'
],
err
);
}
});
});
antstream
.
pipe
(
_request
);
antstream
.
pipe
(
_request
);
}
else
{
}
else
{
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
const
old
_send
=
_request
.
send
;
const
formdata
_send
=
_request
.
send
;
let
_postarr
=
[]
;
let
_postarr
=
self
.
buildBody
(
opts
)
;
if
(
opts
[
'useRaw'
]
==
1
)
{
if
(
opts
[
'useRaw'
]
==
1
)
{
let
_tmp
=
String
(
opts
.
data
[
opts
[
'pwd'
]]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
_postarr
=
unescape
(
_postarr
);
return
unescape
(
$1
);
});
_postarr
=
_tmp
;
}
else
{
}
else
{
if
(
opts
[
'useMultipart'
]
==
1
)
{
if
(
opts
[
'useMultipart'
]
==
1
)
{
_request
.
send
=
_request
.
field
;
_request
.
send
=
_request
.
field
;
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
String
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
)
});
_postarr
[
key
]
=
_tmp
;
}
}
}
else
{
}
else
{
if
(
opts
[
'addMassData'
]
==
1
){
_request
.
send
=
formdata_send
;
for
(
let
i
=
0
;
i
<
randomInt
(
num_min
,
num_max
);
i
++
)
{
//将混淆流量放入到payload数组中
_postData
[
randomString
(
randomInt
(
varname_min
,
varname_max
))]
=
randomString
(
randomInt
(
data_min
,
data_max
));
}
_postData
=
randomDict
(
_postData
);
//logger.debug(_postData);
}
_request
.
send
=
old_send
;
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
)
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
_postarr
=
_postarr
.
join
(
'&'
);
_postarr
=
_postarr
.
join
(
'&'
);
}
}
}
}
_request
_request
.
proxy
(
APROXY_CONF
[
'uri'
])
.
type
(
reqContentType
)
// 设置超时会导致文件过大时写入出错 .timeout(timeout) 忽略HTTPS
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
send
(
_postarr
)
.
send
(
_postarr
)
.
pipe
(
through
((
chunk
)
=>
{
.
pipe
(
through
((
chunk
)
=>
{
// 判断数据流中是否包含后截断符?长度++
// 判断数据流中是否包含后截断符?长度++
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
if
(
temp
!==
-
1
)
{
if
(
temp
!==
-
1
)
{
indexEnd
=
Buffer
indexEnd
=
Buffer
.
concat
(
tempData
).
length
+
temp
;
.
concat
(
tempData
)
.
length
+
temp
;
};
};
tempData
.
push
(
chunk
);
tempData
.
push
(
chunk
);
event
event
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
},
()
=>
{
},
()
=>
{
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
...
@@ -459,9 +386,7 @@ class Request {
...
@@ -459,9 +386,7 @@ class Request {
// 写入文件流&&关闭
// 写入文件流&&关闭
rs
.
write
(
finalData
);
rs
.
write
(
finalData
);
rs
.
close
();
rs
.
close
();
event
event
.
sender
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
.
sender
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
// 删除内存数据
// 删除内存数据
finalData
=
tempDataBuffer
=
tempData
=
null
;
finalData
=
tempDataBuffer
=
tempData
=
null
;
}))
}))
...
@@ -666,21 +591,21 @@ function randomString(length) { // 生成随机字符串
...
@@ -666,21 +591,21 @@ function randomString(length) { // 生成随机字符串
return
result
;
return
result
;
}
}
function
randomInt
(
min
,
max
)
{
//生成指定范围内的随机数
function
randomInt
(
min
,
max
)
{
//生成指定范围内的随机数
return
parseInt
(
Math
.
random
()
*
(
max
-
min
+
1
)
+
min
,
10
);
return
parseInt
(
Math
.
random
()
*
(
max
-
min
+
1
)
+
min
,
10
);
}
}
function
randomDict
(
dic
){
function
randomDict
(
dic
)
{
let
tmparray
=
[]
let
tmparray
=
[]
for
(
let
i
in
dic
)
{
for
(
let
i
in
dic
)
{
tmparray
.
push
(
i
)
tmparray
.
push
(
i
)
}
}
tmparray
=
tmparray
.
sort
((
a
,
b
)
=>
{
return
Math
.
random
()
>
0.5
?
-
1
:
1
;
})
tmparray
=
tmparray
.
sort
((
a
,
b
)
=>
{
return
Math
.
random
()
>
0.5
?
-
1
:
1
;
})
let
finaldata
=
{}
let
finaldata
=
{}
tmparray
.
forEach
(
i
=>
{
tmparray
.
forEach
(
i
=>
{
finaldata
[
i
]
=
dic
[
i
]
finaldata
[
i
]
=
dic
[
i
]
});
});
return
finaldata
return
finaldata
}
}
...
...
source/app.entry.js
View file @
0786dc41
...
@@ -362,6 +362,17 @@ ipcRenderer
...
@@ -362,6 +362,17 @@ ipcRenderer
.
setWidth
(
222
);
.
setWidth
(
222
);
},
555
);
},
555
);
})
})
.
on
(
'aproxy-update'
,
(
e
,
opt
)
=>
{
antSword
[
'aproxyauth'
]
=
(
!
opt
[
'aproxyusername'
]
||
!
opt
[
'aproxypassword'
])
?
''
:
`
${
opt
[
'aproxyusername'
]}
:
${
opt
[
'aproxypassword'
]}
`
;
antSword
[
'aproxyuri'
]
=
`
${
opt
[
'aproxyprotocol'
]}
:\/\/
${
antSword
[
'aproxyauth'
]}${
antSword
[
'aproxyauth'
]
===
''
?
''
:
'@'
}${
opt
[
'aproxyserver'
]}
:
${
opt
[
'aproxyport'
]}
`
;
antSword
[
'aproxymode'
]
=
opt
[
'aproxymode'
];
// antSword.modules.shellmanager.list.updateHeader();
antSword
.
modules
.
shellmanager
.
reloadData
({
category
:
antSword
.
modules
.
shellmanager
.
category
.
sidebar
.
getActiveItem
(),
});
})
/**
/**
* 通知提示 Loader 更新
* 通知提示 Loader 更新
* @param {[type]} 'notification-loader-update' [description]
* @param {[type]} 'notification-loader-update' [description]
...
...
source/modules/settings/aproxy.js
View file @
0786dc41
...
@@ -116,7 +116,7 @@ class AProxy {
...
@@ -116,7 +116,7 @@ class AProxy {
}]
}]
}],
true
);
}],
true
);
form
.
enableLiveValidation
(
true
);
form
.
enableLiveValidation
(
true
);
form
.
attachEvent
(
"onChange"
,
function
(
name
,
value
,
is_checked
)
{
form
.
attachEvent
(
"onChange"
,
function
(
name
,
value
,
is_checked
)
{
if
(
name
==
"aproxymode"
)
{
if
(
name
==
"aproxymode"
)
{
if
(
value
==
"manualproxy"
)
{
if
(
value
==
"manualproxy"
)
{
toolbar
.
enableItem
(
'test'
);
toolbar
.
enableItem
(
'test'
);
...
@@ -140,15 +140,27 @@ class AProxy {
...
@@ -140,15 +140,27 @@ class AProxy {
localStorage
.
setItem
(
'aproxyusername'
,
formvals
[
'username'
]);
localStorage
.
setItem
(
'aproxyusername'
,
formvals
[
'username'
]);
localStorage
.
setItem
(
'aproxypassword'
,
formvals
[
'password'
]);
localStorage
.
setItem
(
'aproxypassword'
,
formvals
[
'password'
]);
let
aproxyauth
=
(
!
formvals
[
'username'
]
||
!
formvals
[
'password'
])
?
''
:
`
${
formvals
[
'username'
]}
:
${
formvals
[
'password'
]}
`
;
let
aproxyuri
=
`
${
formvals
[
'protocol'
]}
:\/\/
${
aproxyauth
}${
aproxyauth
===
''
?
''
:
'@'
}${
formvals
[
'server'
]}
:
${
formvals
[
'port'
]}
`
;
antSword
[
'ipcRenderer'
].
send
(
'aproxy'
,
{
aproxymode
:
formvals
[
'aproxymode'
],
aproxyuri
:
aproxyuri
,
aproxyprotocol
:
formvals
[
'protocol'
],
aproxyserver
:
formvals
[
'server'
],
aproxyport
:
formvals
[
'port'
],
aproxyusername
:
formvals
[
'username'
],
aproxypassword
:
formvals
[
'password'
],
});
toastr
.
success
(
LANG
[
'success'
],
LANG_T
[
'success'
]);
toastr
.
success
(
LANG
[
'success'
],
LANG_T
[
'success'
]);
// 重启应用
// 重启应用
layer
.
confirm
(
LANG
[
'confirm'
][
'content'
],
{
//
layer.confirm(LANG['confirm']['content'], {
icon
:
2
,
//
icon: 2,
shift
:
6
,
//
shift: 6,
title
:
LANG
[
'confirm'
][
'title'
]
//
title: LANG['confirm']['title']
},
(
_
)
=>
{
//
}, (_) => {
location
.
reload
();
//
location.reload();
});
//
});
}
else
{
}
else
{
toastr
.
error
(
LANG
[
'error'
],
LANG_T
[
'error'
]);
toastr
.
error
(
LANG
[
'error'
],
LANG_T
[
'error'
]);
}
}
...
@@ -158,9 +170,9 @@ class AProxy {
...
@@ -158,9 +170,9 @@ class AProxy {
layer
layer
.
prompt
({
.
prompt
({
title
:
LANG
[
'prompt'
][
'title'
],
title
:
LANG
[
'prompt'
][
'title'
],
value
:
'http
://uyu.us
'
,
value
:
'http
s://encrypted.google.com/
'
,
formType
:
0
formType
:
0
},
function
(
testurl
,
index
)
{
},
function
(
testurl
,
index
)
{
layer
.
close
(
index
);
layer
.
close
(
index
);
var
loadindex
=
layer
.
load
(
2
,
{
var
loadindex
=
layer
.
load
(
2
,
{
time
:
6
*
1000
time
:
6
*
1000
...
@@ -188,7 +200,7 @@ class AProxy {
...
@@ -188,7 +200,7 @@ class AProxy {
toastr
.
success
(
LANG
[
'prompt'
][
'success'
],
LANG_T
[
'success'
]);
toastr
.
success
(
LANG
[
'prompt'
][
'success'
],
LANG_T
[
'success'
]);
}).
send
(
'aproxytest'
,
{
}).
send
(
'aproxytest'
,
{
hash
:
hash
,
hash
:
hash
,
url
:
testurl
||
'http
://uyu.us
'
,
url
:
testurl
||
'http
s://encrypted.google.com/
'
,
aproxyuri
:
_aproxyuri
aproxyuri
:
_aproxyuri
});
});
});
});
...
...
source/modules/shellmanager/index.js
View file @
0786dc41
...
@@ -51,9 +51,7 @@ class ShellManager {
...
@@ -51,9 +51,7 @@ class ShellManager {
*/
*/
reloadData
(
arg
=
{})
{
reloadData
(
arg
=
{})
{
if
(
this
.
searchPop
.
isVisible
())
{
if
(
this
.
searchPop
.
isVisible
())
{
let
sdata
=
this
let
sdata
=
this
.
searchForm
.
getValues
();
.
searchForm
.
getValues
();
try
{
try
{
RegExp
(
sdata
[
'searchtext'
]);
RegExp
(
sdata
[
'searchtext'
]);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -94,16 +92,10 @@ class ShellManager {
...
@@ -94,16 +92,10 @@ class ShellManager {
}
}
const
_data
=
Data
.
get
(
arg
);
const
_data
=
Data
.
get
(
arg
);
// 刷新UI::数据
// 刷新UI::数据
this
this
.
list
.
grid
.
clearAll
();
.
list
this
.
list
.
grid
.
parse
({
.
grid
'rows'
:
_data
[
'data'
]
.
clearAll
();
},
'json'
);
this
.
list
.
grid
.
parse
({
'rows'
:
_data
[
'data'
]
},
'json'
);
// 刷新UI::分类
// 刷新UI::分类
for
(
let
_
in
_data
[
'category'
])
{
for
(
let
_
in
_data
[
'category'
])
{
// 目录存在,则更新bubble
// 目录存在,则更新bubble
...
@@ -124,11 +116,7 @@ class ShellManager {
...
@@ -124,11 +116,7 @@ class ShellManager {
});
});
}
}
// 加载分类数据
// 加载分类数据
this
this
.
category
.
sidebar
.
items
(
arg
[
'category'
]
||
'default'
).
setActive
(
true
);
.
category
.
sidebar
.
items
(
arg
[
'category'
]
||
'default'
)
.
setActive
(
true
);
// 更新标题
// 更新标题
this
this
.
category
.
category
...
...
source/modules/shellmanager/list/index.js
View file @
0786dc41
...
@@ -31,7 +31,7 @@ class List {
...
@@ -31,7 +31,7 @@ class List {
*/
*/
updateHeader
(
num
=
0
)
{
updateHeader
(
num
=
0
)
{
let
proxyhint
=
""
;
let
proxyhint
=
""
;
if
(
antSword
.
aproxymode
===
"manualproxy"
)
{
if
(
antSword
.
aproxymode
===
"manualproxy"
)
{
proxyhint
=
` <i class="fa fa-paper-plane"></i> <span style="color:green;">Proxy On</span>`
;
proxyhint
=
` <i class="fa fa-paper-plane"></i> <span style="color:green;">Proxy On</span>`
;
}
}
this
this
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment