Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 96f9001

Browse files
authored
Merge pull request #137 from 3arthqu4ke/v1.8.0
[1.8.0] Make a PingBypass password mandatory, fixes #136
2 parents d7d8113 + 64f473f commit 96f9001

8 files changed

Lines changed: 77 additions & 52 deletions

File tree

README.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,59 @@ wait out 2b2t's queue system.
2323

2424
To set up the 3arthh4ck proxy you need a server, I personally started out using [GCP's](https://cloud.google.com/) free
2525
trial. The location of that server should be as close as possible to the one you want to play on. That server should
26-
have an Ip and port which are reachable from the outside.
26+
have an Ip and port which are reachable from the outside. The game will run on that server. Keep in mind that no matter
27+
which account you use on your client, the Minecraft account on the server will always be used when you play.
2728

2829
### Setup with docker
2930
1. Install [docker](https://docs.docker.com/engine/install/) on your server.
31+
3032
2. Run `docker pull 3arthqu4ke/pingbypass`.
33+
3134
3. Run `docker run -i -t -p <ip>:<port>:25565 3arthqu4ke/pingbypass`.
35+
3236
4. You should now be in the shell of the docker container.
33-
5. Login to your Minecraft account via `hmc login <email>`, then enter your password.
34-
6. Launch the PingBypass server with `hmc launch 1 -id`.
37+
38+
5. Login to your Minecraft account via `hmc login <email>`, then enter your account password.
39+
40+
6. Launch the PingBypass server with `hmc launch 1 -id --jvm -Dpb.password=<some password>`.
41+
3542
7. You are now done with the server. Use the commands from the
36-
[HMC-Specifics](https://github.com/3arthqu4ke/HMC-Specifics) to stop the game. Or just stop the container.
43+
[HMC-Specifics](https://github.com/3arthqu4ke/HMC-Specifics) to stop the game. Or just stop the container.
44+
3745
8. On your own PC just install 3arthh4ck by using its Installer or dropping it inside your mods folder.
46+
3847
9. In the MultiPlayer Menus top right corner you will see a book and a PingBypass button. Use PingBypass button to
39-
toggle it on and off and the book to enter the server's connection details.
48+
toggle it on and off and the book to enter the server's connection details, also the password you used in step 6.
49+
4050
10. You can add the PingBypass server like a normal Minecraft server, this will make it look like in the picture above.
41-
When the PingBypass button is toggled on you will join any server you click through the PingBypass proxy.
51+
When the PingBypass button is toggled on you will join any server you click through the PingBypass proxy.
52+
4253
11. There is two sets of modules, one accessible through the PB-Gui module. These modules have separate configs and
43-
represent the ones on the proxy server.
54+
represent the ones on the proxy server.
4455

4556
### Manual Setup with HeadlessMc
4657
This is just what the docker container already automates.
47-
1. Install Java 8 on the server
48-
2. Create a folder where your game will run.
49-
3. Inside that folder create two directories: `mods` and `earthhack`
50-
4. Put the 3arthh4ck jar and the [HMC-Specifics-1.12.2](https://github.com/3arthqu4ke/HMC-Specifics/releases/tag/1.0.3)
51-
jar inside the mods folder.
52-
5. Inside the earthhack directory create a file called `pingbypass.properties` filled with the following:
58+
59+
1. Install Java 8 on the server
60+
61+
2. Create a folder where your game will run.
62+
63+
3. Inside that folder create two directories: `mods` and `earthhack`
64+
65+
4. Put the 3arthh4ck jar and the [HMC-Specifics-1.12.2](https://github.com/3arthqu4ke/HMC-Specifics/releases/tag/1.0.3)
66+
jar inside the mods folder.
67+
68+
5. Inside the earthhack directory create a file called `pingbypass.properties` filled with the following:
5369
```properties
5470
pb.server=true
71+
pb.password=<password for your pingbypass proxy>
5572
pb.ip=<the aforementioned ip (definitely not 127.0.0.1>
5673
pb.port=<the aforementioned port>
5774
```
58-
6. Download [HeadlessMc](https://github.com/3arthqu4ke/HeadlessMc) and run its jar once.
59-
7. This should create a file called `HeadlessMC/config.properties`. Edit that file and add:
75+
76+
6. Download [HeadlessMc](https://github.com/3arthqu4ke/HeadlessMc) and run its jar once.
77+
78+
7. This should create a file called `HeadlessMC/config.properties`. Edit that file and add:
6079
```properties
6180
hmc.gamedir=<the directory created in step 2.>
6281
hmc.java.versions=<the directory where the java binary is located, e.g. /usr/bin/java>
@@ -65,9 +84,11 @@ jar inside the mods folder.
6584
hmc.invert.lwjgl.flag=true
6685
hmc.invert.pauls.flag=true
6786
```
68-
8. Run HeadlessMc again:
87+
88+
8. Run HeadlessMc again:
6989
* Login to your Microsoft account with `login <email>`, then enter your password.
7090
* Run `download 1.12.2`., then `forge 1.12.2`.
7191
* List the downloaded versions with `versions -refresh`.
7292
* Launch the game with `launch <id of the forge version> -id`.
73-
9. You are now done with the server. Just follow the steps after 7. in the docker setup.
93+
94+
9. You are now done with the server. Just follow the steps after 7. in the docker setup.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ apply plugin: 'maven'
4343

4444
mainClassName = "me.earth.earthhack.installer.main.Main"
4545
group project.modGroup //http://maven.apache.org/guides/mini/guide-naming-conventions.html
46-
project.version = '1.7.14'
46+
project.version = '1.8.0'
4747

4848
boolean VANILLA = false
4949
//noinspection GroovyUnusedAssignment

src/main/java/me/earth/earthhack/impl/Earthhack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Earthhack implements Globals
1515
{
1616
private static final Logger LOGGER = LogManager.getLogger("3arthh4ck");
1717
public static final String NAME = "3arthh4ck";
18-
public static final String VERSION = "1.7.14";
18+
public static final String VERSION = "1.8.0";
1919

2020
public static void preInit()
2121
{

src/main/java/me/earth/earthhack/pingbypass/PingBypass.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public static void init() {
6060
SplashScreenHelper.setSubStep("Loading PingBypass");
6161
Bus.EVENT_BUS.register(new PbAntiTrollListener());
6262
if (isServer()) {
63+
String password = CONFIG.getPassword();
64+
if (!CONFIG.noPassword() && (password == null || password.isEmpty())) {
65+
throw new IllegalStateException("Please set a password for your PingBypass!");
66+
}
67+
6368
LOGGER.info("Initializing PingBypass-Server!");
6469
// preload these LazyLoadBase because they are not really made for
6570
// concurrency (value is not volatile, not synchronized)

src/main/java/me/earth/earthhack/pingbypass/PingBypassConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public String getIp() {
1818
return getProperty("pb.ip", "127.0.0.1");
1919
}
2020

21+
public boolean noPassword() {
22+
return Boolean.parseBoolean(getProperty("pb.no.password", "false"));
23+
}
24+
2125
public String getPassword() {
2226
return getProperty("pb.password", null);
2327
}

src/main/java/me/earth/earthhack/pingbypass/nethandler/LoginHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ public void tryAcceptPlayer()
133133
this.networkManager.sendPacket(new SPacketCustomPayload(
134134
"PingBypass|Enable", new PacketBuffer(Unpooled.buffer())));
135135

136-
String password = PingBypass.CONFIG.getPassword();
137-
if (password != null && !password.isEmpty()) {
136+
if (PingBypass.CONFIG.noPassword()) {
137+
PbNetHandler.onLogin(networkManager, handshake);
138+
} else {
138139
networkManager.setNetHandler(new PasswordHandler(networkManager, handshake));
139140
networkManager.sendPacket(new S2CPasswordPacket());
140-
} else {
141-
PbNetHandler.onLogin(networkManager, handshake);
142141
}
143142
}
144143

src/main/java/me/earth/earthhack/pingbypass/nethandler/PasswordHandler.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.minecraft.util.text.TextComponentString;
1414

1515
import java.io.IOException;
16+
import java.util.Random;
1617
import java.util.concurrent.atomic.AtomicBoolean;
1718

1819
public class PasswordHandler extends BaseNetHandler
@@ -37,40 +38,35 @@ public void update() {
3738

3839
@Override
3940
public void processCustomPayload(CPacketCustomPayload packetIn) {
40-
if ("PingBypass".equalsIgnoreCase(packetIn.getChannelName())
41-
&& !connected.get()) {
42-
try {
43-
PbPacket<?> packet = factory.convert(packetIn.getBufferData());
44-
String password = PingBypass.CONFIG.getPassword();
45-
if (password == null || password.isEmpty()) {
46-
synchronized (connected) {
47-
if (!connected.getAndSet(true)) {
48-
PbNetHandler.onLogin(networkManager, handshake);
49-
}
41+
synchronized (connected) {
42+
if ("PingBypass".equalsIgnoreCase(packetIn.getChannelName()) && !connected.getAndSet(true)) {
43+
try {
44+
PbPacket<?> packet = factory.convert(packetIn.getBufferData());
45+
String password = PingBypass.CONFIG.getPassword();
46+
if (password == null || password.isEmpty()) {
47+
throw new IllegalStateException("PingBypass requires a password!");
5048
}
5149

52-
return;
53-
}
54-
55-
if (packet instanceof C2SPasswordPacket) {
56-
if (password.equals(((C2SPasswordPacket) packet).getString())) {
57-
synchronized (connected) {
58-
if (!connected.getAndSet(true)) {
59-
PbNetHandler.onLogin(networkManager, handshake);
60-
}
50+
if (packet instanceof C2SPasswordPacket) {
51+
if (password.equals(((C2SPasswordPacket) packet).getString())) {
52+
PbNetHandler.onLogin(networkManager, handshake);
53+
return;
6154
}
6255

63-
return;
56+
Thread.sleep(1 + new Random().nextInt(10)); // timing attacks idk
57+
this.disconnect(new TextComponentString("Wrong password!"));
58+
} else {
59+
this.disconnect(new TextComponentString("Unexpected PingBypass packet: " + packet.getClass()));
6460
}
65-
66-
this.disconnect(new TextComponentString("Wrong password!"));
67-
} else {
68-
this.disconnect(new TextComponentString("Unexpected PingBypass packet: " + packet.getClass()));
61+
} catch (InterruptedException e) {
62+
e.printStackTrace();
63+
Thread.currentThread().interrupt();
64+
this.disconnect(new TextComponentString(e.getMessage()));
65+
} catch (IOException e) {
66+
this.disconnect(new TextComponentString(e.getMessage()));
67+
} finally {
68+
packetIn.getBufferData().release();
6969
}
70-
} catch (IOException e) {
71-
this.disconnect(new TextComponentString(e.getMessage()));
72-
} finally {
73-
packetIn.getBufferData().release();
7470
}
7571
}
7672
}

src/main/resources/mcmod.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"modid": "earthhack",
44
"name": "3arthh4ck",
55
"description": "A 1.12.2 Anarchy Client.",
6-
"version": "1.7.14",
6+
"version": "1.8.0",
77
"mcversion": "1.12.2",
88
"url": "",
99
"updateUrl": "",

0 commit comments

Comments
 (0)