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
58f9486c
Commit
58f9486c
authored
Mar 04, 2021
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Fix: Backend) 修复 Chunk 发包下 Download 异常问题 #272 (thx @c2xusnpq6)
parent
8a561278
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
33 deletions
+51
-33
CHANGELOG.md
CHANGELOG.md
+2
-1
request.js
modules/request.js
+49
-32
No files found.
CHANGELOG.md
View file @
58f9486c
...
...
@@ -7,7 +7,8 @@
### 后端模块
*
修改发包默认 UserAgent 为 随机 User-Agent
*
修复 Chunk 发包下 Download 异常问题 #272 (thx @c2xusnpq6)
*
修复 Download 在 chunk 和 multipart 发包模式下 asunescape 不生效的问题
## 2021/02/06 `v(2.1.10)`
### 核心
...
...
modules/request.js
View file @
58f9486c
...
...
@@ -307,45 +307,52 @@ class Request {
let
_postarr
=
[];
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
_postarr
.
push
(
`
${
key
}
=
${
_postData
[
key
]}
`
);
let
_tmp
=
encodeURIComponent
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
);
});
// 后续可能需要二次处理的在这里追加
_postarr
.
push
(
`
${
key
}
=
${
_tmp
}
`
);
}
}
let
antstream
=
new
AntRead
(
_postarr
.
join
(
"&"
),
{
'step'
:
parseInt
(
opts
[
'chunkStepMin'
]),
'stepmax'
:
parseInt
(
opts
[
'chunkStepMax'
])
});
let
_datasuccess
=
false
;
// 表示是否是 404 类shell
_request
.
proxy
(
APROXY_CONF
[
'uri'
])
.
type
(
'form'
)
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
pipe
(
through
((
chunk
)
=>
{
// 判断数据流中是否包含后截断符?长度++
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
if
(
temp
!==
-
1
)
{
indexEnd
=
Buffer
.
concat
(
tempData
)
.
length
+
temp
;
};
tempData
.
push
(
chunk
);
event
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
},
()
=>
{
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
indexStart
=
tempDataBuffer
.
indexOf
(
opts
[
'tag_s'
])
||
0
;
// 截取最后的数据
let
finalData
=
Buffer
.
from
(
tempDataBuffer
.
slice
(
indexStart
+
opts
[
'tag_s'
].
length
,
indexEnd
),
'binary'
);
// 写入文件流&&关闭
rs
.
write
(
finalData
);
rs
.
close
();
event
.
sender
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
// 删除内存数据
finalData
=
tempDataBuffer
=
tempData
=
null
;
}));
.
parse
((
res
,
callback
)
=>
{
res
.
pipe
(
through
((
chunk
)
=>
{
// 判断数据流中是否包含后截断符?长度++
let
temp
=
chunk
.
indexOf
(
opts
[
'tag_e'
]);
if
(
temp
!==
-
1
)
{
indexEnd
=
Buffer
.
concat
(
tempData
)
.
length
+
temp
;
};
tempData
.
push
(
chunk
);
event
.
sender
.
send
(
'download-progress-'
+
opts
[
'hash'
],
chunk
.
length
);
},
()
=>
{
let
tempDataBuffer
=
Buffer
.
concat
(
tempData
);
indexStart
=
tempDataBuffer
.
indexOf
(
opts
[
'tag_s'
])
||
0
;
// 截取最后的数据
let
finalData
=
Buffer
.
from
(
tempDataBuffer
.
slice
(
indexStart
+
opts
[
'tag_s'
].
length
,
indexEnd
),
'binary'
);
// 写入文件流&&关闭
rs
.
write
(
finalData
);
rs
.
close
();
event
.
sender
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
// 删除内存数据
finalData
=
tempDataBuffer
=
tempData
=
null
;
}))
})
.
on
(
'error'
,
(
err
)
=>
{
return
event
.
sender
.
send
(
'download-error-'
+
opts
[
'hash'
],
err
);
});
antstream
.
pipe
(
_request
);
}
else
{
// 通过替换函数方式来实现发包方式切换, 后续可改成别的
...
...
@@ -353,9 +360,16 @@ class Request {
let
_postarr
=
[];
if
(
opts
[
'useMultipart'
]
==
1
)
{
_request
.
send
=
_request
.
field
;
_postarr
=
_postData
;
for
(
var
key
in
_postData
)
{
if
(
_postData
.
hasOwnProperty
(
key
))
{
let
_tmp
=
(
_postData
[
key
]).
replace
(
/asunescape
\((
.+
?)\)
/g
,
function
(
$
,
$1
)
{
return
unescape
(
$1
)
});
_postarr
[
key
]
=
_tmp
;
}
}
}
else
{
if
(
opts
[
'addMassData'
]
==
1
){
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
));
}
...
...
@@ -405,7 +419,10 @@ class Request {
.
send
(
'download-'
+
opts
[
'hash'
],
finalData
.
length
);
// 删除内存数据
finalData
=
tempDataBuffer
=
tempData
=
null
;
}));
}))
.
on
(
'error'
,
(
err
)
=>
{
return
event
.
sender
.
send
(
'download-error-'
+
opts
[
'hash'
],
err
);
});;
}
}
...
...
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