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

Commit

Permalink
Merge pull request #137 from 3arthqu4ke/v1.8.0
Browse files Browse the repository at this point in the history
[1.8.0] Make a PingBypass password mandatory, fixes #136
  • Loading branch information
3arthqu4ke authored Aug 23, 2022
2 parents d7d8113 + 64f473f commit 96f9001
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 52 deletions.
55 changes: 38 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,59 @@ wait out 2b2t's queue system.

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

### Setup with docker
1. Install [docker](https://docs.docker.com/engine/install/) on your server.

2. Run `docker pull 3arthqu4ke/pingbypass`.

3. Run `docker run -i -t -p <ip>:<port>:25565 3arthqu4ke/pingbypass`.

4. You should now be in the shell of the docker container.
5. Login to your Minecraft account via `hmc login <email>`, then enter your password.
6. Launch the PingBypass server with `hmc launch 1 -id`.

5. Login to your Minecraft account via `hmc login <email>`, then enter your account password.

6. Launch the PingBypass server with `hmc launch 1 -id --jvm -Dpb.password=<some password>`.

7. You are now done with the server. Use the commands from the
[HMC-Specifics](https://github.com/3arthqu4ke/HMC-Specifics) to stop the game. Or just stop the container.
[HMC-Specifics](https://github.com/3arthqu4ke/HMC-Specifics) to stop the game. Or just stop the container.

8. On your own PC just install 3arthh4ck by using its Installer or dropping it inside your mods folder.

9. In the MultiPlayer Menus top right corner you will see a book and a PingBypass button. Use PingBypass button to
toggle it on and off and the book to enter the server's connection details.
toggle it on and off and the book to enter the server's connection details, also the password you used in step 6.

10. You can add the PingBypass server like a normal Minecraft server, this will make it look like in the picture above.
When the PingBypass button is toggled on you will join any server you click through the PingBypass proxy.
When the PingBypass button is toggled on you will join any server you click through the PingBypass proxy.

11. There is two sets of modules, one accessible through the PB-Gui module. These modules have separate configs and
represent the ones on the proxy server.
represent the ones on the proxy server.

### Manual Setup with HeadlessMc
This is just what the docker container already automates.
1. Install Java 8 on the server
2. Create a folder where your game will run.
3. Inside that folder create two directories: `mods` and `earthhack`
4. Put the 3arthh4ck jar and the [HMC-Specifics-1.12.2](https://github.com/3arthqu4ke/HMC-Specifics/releases/tag/1.0.3)
jar inside the mods folder.
5. Inside the earthhack directory create a file called `pingbypass.properties` filled with the following:

1. Install Java 8 on the server

2. Create a folder where your game will run.

3. Inside that folder create two directories: `mods` and `earthhack`

4. Put the 3arthh4ck jar and the [HMC-Specifics-1.12.2](https://github.com/3arthqu4ke/HMC-Specifics/releases/tag/1.0.3)
jar inside the mods folder.

5. Inside the earthhack directory create a file called `pingbypass.properties` filled with the following:
```properties
pb.server=true
pb.password=<password for your pingbypass proxy>
pb.ip=<the aforementioned ip (definitely not 127.0.0.1>
pb.port=<the aforementioned port>
```
6. Download [HeadlessMc](https://github.com/3arthqu4ke/HeadlessMc) and run its jar once.
7. This should create a file called `HeadlessMC/config.properties`. Edit that file and add:

6. Download [HeadlessMc](https://github.com/3arthqu4ke/HeadlessMc) and run its jar once.

7. This should create a file called `HeadlessMC/config.properties`. Edit that file and add:
```properties
hmc.gamedir=<the directory created in step 2.>
hmc.java.versions=<the directory where the java binary is located, e.g. /usr/bin/java>
Expand All @@ -65,9 +84,11 @@ jar inside the mods folder.
hmc.invert.lwjgl.flag=true
hmc.invert.pauls.flag=true
```
8. Run HeadlessMc again:

8. Run HeadlessMc again:
* Login to your Microsoft account with `login <email>`, then enter your password.
* Run `download 1.12.2`., then `forge 1.12.2`.
* List the downloaded versions with `versions -refresh`.
* Launch the game with `launch <id of the forge version> -id`.
9. You are now done with the server. Just follow the steps after 7. in the docker setup.

9. You are now done with the server. Just follow the steps after 7. in the docker setup.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ apply plugin: 'maven'

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

boolean VANILLA = false
//noinspection GroovyUnusedAssignment
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/earth/earthhack/impl/Earthhack.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Earthhack implements Globals
{
private static final Logger LOGGER = LogManager.getLogger("3arthh4ck");
public static final String NAME = "3arthh4ck";
public static final String VERSION = "1.7.14";
public static final String VERSION = "1.8.0";

public static void preInit()
{
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/earth/earthhack/pingbypass/PingBypass.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public static void init() {
SplashScreenHelper.setSubStep("Loading PingBypass");
Bus.EVENT_BUS.register(new PbAntiTrollListener());
if (isServer()) {
String password = CONFIG.getPassword();
if (!CONFIG.noPassword() && (password == null || password.isEmpty())) {
throw new IllegalStateException("Please set a password for your PingBypass!");
}

LOGGER.info("Initializing PingBypass-Server!");
// preload these LazyLoadBase because they are not really made for
// concurrency (value is not volatile, not synchronized)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public String getIp() {
return getProperty("pb.ip", "127.0.0.1");
}

public boolean noPassword() {
return Boolean.parseBoolean(getProperty("pb.no.password", "false"));
}

public String getPassword() {
return getProperty("pb.password", null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ public void tryAcceptPlayer()
this.networkManager.sendPacket(new SPacketCustomPayload(
"PingBypass|Enable", new PacketBuffer(Unpooled.buffer())));

String password = PingBypass.CONFIG.getPassword();
if (password != null && !password.isEmpty()) {
if (PingBypass.CONFIG.noPassword()) {
PbNetHandler.onLogin(networkManager, handshake);
} else {
networkManager.setNetHandler(new PasswordHandler(networkManager, handshake));
networkManager.sendPacket(new S2CPasswordPacket());
} else {
PbNetHandler.onLogin(networkManager, handshake);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.util.text.TextComponentString;

import java.io.IOException;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

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

@Override
public void processCustomPayload(CPacketCustomPayload packetIn) {
if ("PingBypass".equalsIgnoreCase(packetIn.getChannelName())
&& !connected.get()) {
try {
PbPacket<?> packet = factory.convert(packetIn.getBufferData());
String password = PingBypass.CONFIG.getPassword();
if (password == null || password.isEmpty()) {
synchronized (connected) {
if (!connected.getAndSet(true)) {
PbNetHandler.onLogin(networkManager, handshake);
}
synchronized (connected) {
if ("PingBypass".equalsIgnoreCase(packetIn.getChannelName()) && !connected.getAndSet(true)) {
try {
PbPacket<?> packet = factory.convert(packetIn.getBufferData());
String password = PingBypass.CONFIG.getPassword();
if (password == null || password.isEmpty()) {
throw new IllegalStateException("PingBypass requires a password!");
}

return;
}

if (packet instanceof C2SPasswordPacket) {
if (password.equals(((C2SPasswordPacket) packet).getString())) {
synchronized (connected) {
if (!connected.getAndSet(true)) {
PbNetHandler.onLogin(networkManager, handshake);
}
if (packet instanceof C2SPasswordPacket) {
if (password.equals(((C2SPasswordPacket) packet).getString())) {
PbNetHandler.onLogin(networkManager, handshake);
return;
}

return;
Thread.sleep(1 + new Random().nextInt(10)); // timing attacks idk
this.disconnect(new TextComponentString("Wrong password!"));
} else {
this.disconnect(new TextComponentString("Unexpected PingBypass packet: " + packet.getClass()));
}

this.disconnect(new TextComponentString("Wrong password!"));
} else {
this.disconnect(new TextComponentString("Unexpected PingBypass packet: " + packet.getClass()));
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
this.disconnect(new TextComponentString(e.getMessage()));
} catch (IOException e) {
this.disconnect(new TextComponentString(e.getMessage()));
} finally {
packetIn.getBufferData().release();
}
} catch (IOException e) {
this.disconnect(new TextComponentString(e.getMessage()));
} finally {
packetIn.getBufferData().release();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "earthhack",
"name": "3arthh4ck",
"description": "A 1.12.2 Anarchy Client.",
"version": "1.7.14",
"version": "1.8.0",
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",
Expand Down

0 comments on commit 96f9001

Please sign in to comment.