DARKNET: Buff packet sniffing slightly (#2485)

Refactor the sniff code so that successful sniffs for the current server
are tagged server_name:password, not just those for adjacent servers.
This commit is contained in:
David Walker
2026-02-10 08:10:33 -08:00
committed by GitHub
parent bab6280735
commit ed727d6e74

View File

@@ -20,23 +20,20 @@ export const capturePackets = (server: DarknetServer) => {
const vulnerability = server.modelId === ModelIds.packetSniffer ? 8 : 1;
const passwordInclusionChance = BASE_PASSWORD_INCLUSION_RATE * vulnerability * DIFFICULTY_MODIFIER ** difficulty;
let captureServer: DarknetServer | null = null;
if (Math.random() < passwordInclusionChance) {
const intro = Math.floor(Math.random() * 124);
return `${getRandomData(server, intro)}${server.password}${getRandomData(
server,
124 - intro - server.password.length,
)}`;
}
if (Math.random() < passwordInclusionChance) {
captureServer = server;
// eslint-disable-next-line no-dupe-else-if
} else if (Math.random() < passwordInclusionChance) {
const connectedServerName = server.serversOnNetwork[Math.floor(Math.random() * server.serversOnNetwork.length)];
const connectedServer = getDarknetServer(connectedServerName);
if (connectedServer) {
const intro = Math.floor(Math.random() * 124);
return `${getRandomData(server, intro)} ${connectedServerName}:${connectedServer.password} ${getRandomData(
server,
124 - intro - connectedServer.password.length - connectedServerName.length,
)}`;
}
captureServer = getDarknetServer(connectedServerName);
}
if (captureServer) {
const intro = Math.floor(Math.random() * 124);
return `${getRandomData(server, intro)} ${captureServer.hostname}:${captureServer.password} ${getRandomData(
server,
124 - intro - captureServer.password.length - captureServer.hostname.length,
)}`;
}
return `${getRandomData(server, 124)}`;