-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 78e56ce
Showing
47 changed files
with
3,018 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build/ | ||
.gradle/ | ||
.idea/ | ||
app/lib/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# PokeMMO Packet Editor | ||
## How to Use | ||
1. Download the latest release from the releases page. | ||
2. Edit your Hosts file to redirect the PokeMMO server to your local machine. | ||
``` | ||
127.0.0.1 loginserver.pokemmo.com | ||
``` | ||
3. Run PokeMMO by clicking Game -> Start | ||
4. Start the proxy by clicking Start Server | ||
|
||
You can now use the client normally and the proxy will intercept all packets sent to the server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
plugins { | ||
id 'java' | ||
id 'com.github.johnrengelman.shadow' version '8.1.1' | ||
} | ||
|
||
group = 'de.fiereu' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
shadowJar { | ||
archiveBaseName.set('agent') | ||
archiveClassifier.set('') | ||
archiveVersion.set('') | ||
|
||
manifest { | ||
attributes( | ||
'Premain-Class': 'de.fiereu.ppe.agent.Agent' | ||
) | ||
} | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.junit:junit-bom:5.10.0') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
|
||
implementation project(':certs') | ||
|
||
// ASM | ||
implementation 'org.ow2.asm:asm:9.7' | ||
implementation 'org.ow2.asm:asm-commons:9.7' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes( | ||
'Premain-Class': 'de.fiereu.ppe.agent.Agent' | ||
) | ||
} | ||
} | ||
|
||
shadowJar { | ||
archiveBaseName.set('agent') | ||
archiveClassifier.set('') | ||
archiveVersion.set('') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.fiereu.ppe.agent; | ||
|
||
import java.lang.instrument.Instrumentation; | ||
|
||
public class Agent { | ||
|
||
private static Instrumentation instrumentation; | ||
|
||
public static void premain(String args, Instrumentation inst) { | ||
instrumentation = inst; | ||
instrumentation.addTransformer(new PpeClassFileTransformer()); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
agent/src/main/java/de/fiereu/ppe/agent/CertificatePatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.fiereu.ppe.agent; | ||
|
||
import de.fiereu.ppe.pokemmo.Certificates; | ||
import java.util.List; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.MethodVisitor; | ||
|
||
public class CertificatePatch extends ClassVisitor { | ||
|
||
private static final List<String> certificates = List.of( | ||
Certificates.lsPubKey, | ||
Certificates.gsPubKey, | ||
Certificates.csPubKey | ||
); | ||
|
||
CertificatePatch(int api, ClassVisitor classVisitor) { | ||
super(api, classVisitor); | ||
} | ||
|
||
@Override | ||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, | ||
String[] exceptions) { | ||
return new MethodVisitor(api, | ||
super.visitMethod(access, name, descriptor, signature, exceptions)) { | ||
@Override | ||
public void visitLdcInsn(Object value) { | ||
if (value instanceof String str) { | ||
if (certificates.contains(str)) { | ||
super.visitLdcInsn(Certificates.proxyPubKey); | ||
System.out.printf("Patched certificate: %s -> %s%n", str, Certificates.proxyPubKey); | ||
return; | ||
} | ||
} | ||
super.visitLdcInsn(value); | ||
} | ||
}; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
agent/src/main/java/de/fiereu/ppe/agent/PpeClassFileTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.fiereu.ppe.agent; | ||
|
||
import java.lang.instrument.ClassFileTransformer; | ||
import java.security.ProtectionDomain; | ||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.ClassWriter; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
public class PpeClassFileTransformer implements ClassFileTransformer { | ||
|
||
@Override | ||
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, | ||
ProtectionDomain protectionDomain, byte[] classfileBuffer) { | ||
try { | ||
ClassReader classReader = new ClassReader(classfileBuffer); | ||
ClassWriter classWriter = new ClassWriter(classReader, 0); | ||
ClassVisitor classVisitor = new CertificatePatch(Opcodes.ASM9, classWriter); | ||
classReader.accept(classVisitor, 0); | ||
return classWriter.toByteArray(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return classfileBuffer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
plugins { | ||
id 'java' | ||
id 'com.github.johnrengelman.shadow' version '8.1.1' | ||
} | ||
|
||
group = 'de.fiereu' | ||
version = '1.0' | ||
|
||
shadowJar { | ||
archiveBaseName.set('app') | ||
archiveClassifier.set('') | ||
archiveVersion.set('') | ||
|
||
manifest { | ||
attributes( | ||
'Main-Class': 'de.fiereu.ppe.Application' | ||
) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.junit:junit-bom:5.9.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
|
||
implementation project(':certs') | ||
|
||
// logback + slf4j | ||
implementation 'org.slf4j:slf4j-api:1.7.32' | ||
implementation 'ch.qos.logback:logback-classic:1.4.14' | ||
|
||
// FlatDev | ||
implementation 'com.formdev:flatlaf:3.4.1' | ||
implementation 'com.formdev:flatlaf-intellij-themes:3.4.1' | ||
|
||
// MigLayout | ||
implementation 'com.miglayout:miglayout-swing:11.3' | ||
|
||
// BouncyCastle | ||
implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1' | ||
|
||
implementation 'com.github.maltalex:ineter:0.3.0' | ||
|
||
implementation 'org.xerial:sqlite-jdbc:3.45.3.0' | ||
|
||
implementation 'commons-beanutils:commons-beanutils:1.9.4' | ||
implementation 'org.apache.commons:commons-configuration2:2.10.1' | ||
|
||
implementation 'org.exbin.bined:bined-swing:0.2.1' | ||
implementation 'org.exbin.auxiliary:binary_data:0.2.1' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package de.fiereu.ppe; | ||
|
||
import de.fiereu.ppe.forms.MainForm; | ||
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
import org.apache.commons.configuration2.Configuration; | ||
import org.apache.commons.configuration2.builder.fluent.Configurations; | ||
import org.apache.commons.configuration2.builder.fluent.Parameters; | ||
import org.apache.commons.configuration2.ex.ConfigurationException; | ||
|
||
public class Application { | ||
|
||
private static final String SQLITE_DB = "packets.db"; | ||
private static final String CONFIG_FILE = "config.conf"; | ||
|
||
public static void main(String[] args) { | ||
try { | ||
FlatMaterialDarkerIJTheme.setup(); | ||
} catch (Exception e) { | ||
ErrorHandler.handle(null, "Could not set Look&Feel.", e); | ||
} | ||
|
||
Configuration config = null; | ||
try { | ||
config = loadConfig(); | ||
} catch (ConfigurationException e) { | ||
ErrorHandler.handle(null, "Could not load configuration.", e); | ||
return; | ||
} catch (IOException e) { | ||
ErrorHandler.handle(null, "Could not create configuration file.", e); | ||
return; | ||
} | ||
PacketHistory packetHistory; | ||
try { | ||
packetHistory = loadPacketHistory(); | ||
} catch (IOException | SQLException e) { | ||
ErrorHandler.handle(null, "Could not load PacketHistory.", e); | ||
return; | ||
} | ||
new MainForm(config, packetHistory).setVisible(true); | ||
} | ||
|
||
private static Configuration loadConfig() throws ConfigurationException, IOException { | ||
File file = new File(CONFIG_FILE); | ||
if (!file.exists()) { | ||
if (!file.createNewFile()) { | ||
throw new IOException("Could not create configuration file."); | ||
} | ||
} | ||
Configurations configs = new Configurations(); | ||
var builder = configs.propertiesBuilder().configure( | ||
new Parameters().fileBased() | ||
.setFile(new File(CONFIG_FILE)) | ||
.setThrowExceptionOnMissing(false) | ||
); | ||
builder.setAutoSave(true); | ||
return builder.getConfiguration(); | ||
} | ||
|
||
private static PacketHistory loadPacketHistory() throws IOException, SQLException { | ||
File sqliteDB = new File(SQLITE_DB); | ||
if (!sqliteDB.exists()) { | ||
if(!sqliteDB.createNewFile()) { | ||
throw new IOException("Could not create SQLite database."); | ||
} | ||
} | ||
return new PacketHistory(new File(SQLITE_DB)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.fiereu.ppe; | ||
|
||
import java.awt.Component; | ||
import javax.swing.JOptionPane; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ErrorHandler { | ||
|
||
public static final Logger log = LoggerFactory.getLogger(ErrorHandler.class); | ||
|
||
public static void handle(Component parent, String message, Throwable t) { | ||
log.error(message, t); | ||
JOptionPane.showMessageDialog(parent, t.getMessage(), message, JOptionPane.ERROR_MESSAGE); | ||
} | ||
|
||
public static void handle(Component parent, String message) { | ||
log.error(message); | ||
JOptionPane.showMessageDialog(parent, message, "Error", JOptionPane.ERROR_MESSAGE); | ||
} | ||
} |
Oops, something went wrong.