修复RejoinDelay在首次尝试重连时不生效

This commit is contained in:
SerendipityR 2022-08-23 11:37:55 +08:00 committed by GitHub
parent bdc0de6a1e
commit 7ab3038e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 34 deletions

View File

@ -251,12 +251,20 @@ public class BotAttack extends IAttack {
client.getSession().addListener(new SessionListener() { client.getSession().addListener(new SessionListener() {
public void packetReceived(PacketReceivedEvent e) { public void packetReceived(PacketReceivedEvent e) {
new Thread(() -> handlePacket(e.getSession(), e.getPacket(), username)).start(); new Thread(() -> handlePacket(e.getSession(), e.getPacket(), username)).start();
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(proxy);
}
} }
public void packetReceived(Session session, Packet packet) { public void packetReceived(Session session, Packet packet) {
new Thread(() -> { new Thread(() -> {
handlePacket(session, packet, username); handlePacket(session, packet, username);
}).start(); }).start();
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(proxy);
}
} }
public void packetSending(PacketSendingEvent packetSendingEvent) { public void packetSending(PacketSendingEvent packetSendingEvent) {
@ -296,6 +304,8 @@ public class BotAttack extends IAttack {
if (msg.contains(rejoinDetect)) { if (msg.contains(rejoinDetect)) {
new Thread(() -> { new Thread(() -> {
for (int i = 0; i < ConfigUtil.RejoinCount; i++) { for (int i = 0; i < ConfigUtil.RejoinCount; i++) {
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy);
rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay));
rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay));
@ -306,8 +316,6 @@ public class BotAttack extends IAttack {
clients.add(rejoinClient); clients.add(rejoinClient);
rejoinClient.getSession().connect(false); rejoinClient.getSession().connect(false);
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) {
break; break;
} }
@ -380,10 +388,6 @@ public class BotAttack extends IAttack {
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack"); LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
joined++; joined++;
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(ProxyUtil.clientsProxy.get(session));
}
if (!alivePlayers.contains(username)) { if (!alivePlayers.contains(username)) {
alivePlayers.add(username); alivePlayers.add(username);
} }

View File

@ -280,6 +280,10 @@ public class NewBotAttack extends IAttack {
handlePacket(e.getSession(), e.getPacket(), username); handlePacket(e.getSession(), e.getPacket(), username);
} }
}).start(); }).start();
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(proxy);
}
} }
public void packetReceived(Session session, Packet packet) { public void packetReceived(Session session, Packet packet) {
@ -290,6 +294,10 @@ public class NewBotAttack extends IAttack {
handlePacket(session, packet, username); handlePacket(session, packet, username);
} }
}).start(); }).start();
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(proxy);
}
} }
public void packetSending(PacketSendingEvent packetSendingEvent) { public void packetSending(PacketSendingEvent packetSendingEvent) {
@ -335,6 +343,8 @@ public class NewBotAttack extends IAttack {
if (msg.contains(rejoinDetect)) { if (msg.contains(rejoinDetect)) {
new Thread(() -> { new Thread(() -> {
for (int i = 0; i < ConfigUtil.RejoinCount; i++) { for (int i = 0; i < ConfigUtil.RejoinCount; i++) {
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
Session rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); Session rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy);
rejoinClient.setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay));
rejoinClient.setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay));
@ -345,8 +355,6 @@ public class NewBotAttack extends IAttack {
clients.add(rejoinClient); clients.add(rejoinClient);
rejoinClient.connect(false); rejoinClient.connect(false);
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
if (rejoinClient.hasFlag("join") || rejoinClient.hasFlag("login")) { if (rejoinClient.hasFlag("join") || rejoinClient.hasFlag("login")) {
break; break;
} }
@ -419,10 +427,6 @@ public class NewBotAttack extends IAttack {
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack"); LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
joined++; joined++;
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(ProxyUtil.clientsProxy.get(session));
}
if (!alivePlayers.contains(username)) { if (!alivePlayers.contains(username)) {
alivePlayers.add(username); alivePlayers.add(username);
} }
@ -486,10 +490,6 @@ public class NewBotAttack extends IAttack {
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack"); LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
joined++; joined++;
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(ProxyUtil.clientsProxy.get(session));
}
if (!alivePlayers.contains(username)) { if (!alivePlayers.contains(username)) {
alivePlayers.add(username); alivePlayers.add(username);
} }

View File

@ -38,6 +38,7 @@ public class BotAttack extends IAttack {
public static int joined = 0; public static int joined = 0;
public static int rejoin = 0; public static int rejoin = 0;
public static int clickVerifies = 0; public static int clickVerifies = 0;
public static List<String> rejoinPlayers = new ArrayList<>();
public static List<String> alivePlayers = new ArrayList<>(); public static List<String> alivePlayers = new ArrayList<>();
public static HashMap<Session,ServerPlayerPositionRotationPacket> positionPacket = new HashMap<>(); public static HashMap<Session,ServerPlayerPositionRotationPacket> positionPacket = new HashMap<>();
protected boolean attack_motdbefore; protected boolean attack_motdbefore;
@ -81,16 +82,15 @@ public class BotAttack extends IAttack {
OtherUtils.doSleep(ConfigUtil.ChatDelay); OtherUtils.doSleep(ConfigUtil.ChatDelay);
} }
/*if (positionPacket != null) { /*ServerPlayerPositionRotationPacket positionRotationPacket = positionPacket.get(c.getSession());
if (c.getSession().isConnected() && positionRotationPacket != null) {
new Thread(() -> { new Thread(() -> {
while (c.getSession().isConnected() && positionPacket.containsKey(c.getSession())) { try {
MultiVersionPacket.sendPosPacket(c.getSession(), positionPacket.get(c.getSession()).getX() + OtherUtils.getRandomInt(-10, 10), positionPacket.get(c.getSession()).getY() + OtherUtils.getRandomInt(2, 8), positionPacket.get(c.getSession()).getZ() + OtherUtils.getRandomInt(-10, 10), OtherUtils.getRandomFloat(0.00, 1.00), OtherUtils.getRandomFloat(0.00, 1.00)); MultiVersionPacket.sendPosPacket(c.getSession(), positionRotationPacket.getX() + OtherUtils.getRandomInt(-10, 10), positionRotationPacket.getY() + OtherUtils.getRandomInt(2, 8), positionRotationPacket.getZ() + OtherUtils.getRandomInt(-10, 10), OtherUtils.getRandomFloat(0.00, 1.00), OtherUtils.getRandomFloat(0.00, 1.00));
Thread.sleep(500);
try { MultiVersionPacket.sendPosPacket(c.getSession(), positionRotationPacket.getX(), positionRotationPacket.getY(), positionRotationPacket.getZ(), OtherUtils.getRandomFloat(0.00, 1.00), OtherUtils.getRandomFloat(0.00, 1.00));
Thread.sleep(10); } catch (InterruptedException e) {
} catch (InterruptedException e) { throw new RuntimeException(e);
throw new RuntimeException(e);
}
} }
}).start(); }).start();
}*/ }*/
@ -139,7 +139,9 @@ public class BotAttack extends IAttack {
if (this.attack_tab) { if (this.attack_tab) {
tabThread = new Thread(() -> { tabThread = new Thread(() -> {
while (true) { while (true) {
for (Client c : clients) { Set<Client> cacheClients = clients;
for (Client c:cacheClients) {
if (c.getSession().isConnected() && c.getSession().hasFlag("join")) { if (c.getSession().isConnected() && c.getSession().hasFlag("join")) {
MultiVersionPacket.sendTabPacket(c.getSession(), "/"); MultiVersionPacket.sendTabPacket(c.getSession(), "/");
} }
@ -239,6 +241,10 @@ public class BotAttack extends IAttack {
new Thread(() -> { new Thread(() -> {
handlePacket(e.getSession(), e.getPacket(), username); handlePacket(e.getSession(), e.getPacket(), username);
}).start(); }).start();
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(proxy);
}
} }
public void packetSent(PacketSentEvent e) { public void packetSent(PacketSentEvent e) {
@ -262,25 +268,35 @@ public class BotAttack extends IAttack {
} }
for (String rejoinDetect:ConfigUtil.RejoinDetect) { for (String rejoinDetect:ConfigUtil.RejoinDetect) {
if (rejoinPlayers.contains(username)) {
break;
}
if (msg.contains(rejoinDetect)) { if (msg.contains(rejoinDetect)) {
new Thread(() -> { new Thread(() -> {
rejoinPlayers.add(username);
for (int i = 0; i < ConfigUtil.RejoinCount; i++) { for (int i = 0; i < ConfigUtil.RejoinCount; i++) {
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy); Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy);
rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.getSession().setReadTimeout(5000);
rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.RejoinDelay)); rejoinClient.getSession().setWriteTimeout(5000);
rejoin++; rejoin++;
LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack"); LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack");
clientName.put(rejoinClient, username); clientName.put(rejoinClient, username);
clients.add(rejoinClient); clients.add(rejoinClient);
rejoinClient.getSession().connect(false); rejoinClient.getSession().connect(false);
ProxyUtil.clientsProxy.put(client.getSession(), proxy);
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) { if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) {
rejoinPlayers.remove(username);
break; break;
} }
} }
rejoinPlayers.remove(username);
}).start(); }).start();
} }
} }
@ -290,6 +306,7 @@ public class BotAttack extends IAttack {
} }
failed++; failed++;
alivePlayers.remove(username);
} }
}); });
return client; return client;
@ -345,10 +362,6 @@ public class BotAttack extends IAttack {
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack"); LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
joined++; joined++;
if (ConfigUtil.SaveWorkingProxy) {
ProxyUtil.saveWorkingProxy(ProxyUtil.clientsProxy.get(session));
}
if (!alivePlayers.contains(username)) { if (!alivePlayers.contains(username)) {
alivePlayers.add(username); alivePlayers.add(username);
} }