Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
H
hisoutensoku-terminator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
hisoutensoku-terminator
Commits
5f6228c5
Commit
5f6228c5
authored
Jun 06, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timeout
parent
969d1860
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
attacker.ts
attacker.ts
+4
-4
run.ts
run.ts
+1
-1
No files found.
attacker.ts
View file @
5f6228c5
...
...
@@ -26,7 +26,7 @@ function sendMessage(socket: any, message: number[]): Promise<any> {
});
}
function
waitForReply
(
socket
:
any
,
intervalMessage
:
number
[]):
Promise
<
boolean
>
{
function
waitForReply
(
socket
:
any
,
timeout
:
number
,
intervalMessage
:
number
[]):
Promise
<
boolean
>
{
const
intv
=
setInterval
(
sendMessage
,
500
,
socket
,
intervalMessage
);
return
new
Promise
(
done
=>
{
socket
.
once
(
"
message
"
,
(
msg
:
Buffer
,
rinfo
:
any
)
=>
{
...
...
@@ -38,11 +38,11 @@ function waitForReply(socket: any, intervalMessage: number[]): Promise<boolean>
setTimeout
(()
=>
{
clearInterval
(
intv
);
done
(
false
);
},
10000
);
},
timeout
);
});
}
export
async
function
attack
(
address
:
string
,
port
:
number
):
Promise
<
string
>
{
export
async
function
attack
(
address
:
string
,
port
:
number
,
timeout
:
number
):
Promise
<
string
>
{
const
socket
=
dgram
.
createSocket
(
"
udp4
"
);
let
err
;
err
=
await
new
Promise
(
done
=>
{
...
...
@@ -56,7 +56,7 @@ export async function attack(address: string, port: number): Promise<string> {
return
`Failed to send stage 1:
${
err
.
toString
()}
`
;
}
//console.log("Waiting for reply...");
if
(
!
await
waitForReply
(
socket
,
messageStage1
))
{
if
(
!
await
waitForReply
(
socket
,
timeout
,
messageStage1
))
{
return
`Empty reply.`
;
}
err
=
await
sendMessage
(
socket
,
messageStage2
);
...
...
run.ts
View file @
5f6228c5
...
...
@@ -39,7 +39,7 @@ async function startAttack(address: string, port: number): Promise<boolean> {
return
false
;
}
log
.
info
(
`Attack of
${
address
}
:
${
port
}
started.`
);
const
err
=
await
attack
(
address
,
port
);
const
err
=
await
attack
(
address
,
port
,
config
.
attackTimeout
);
if
(
err
)
{
log
.
warn
(
`Attack of
${
address
}
:
${
port
}
failed:
${
err
}
`
);
}
else
{
...
...
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