mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-19 00:26:27 +01:00
progression in structure in order to make this X-platform someday
This commit is contained in:
parent
32bf26927a
commit
78d7fbf691
@ -1,18 +1,16 @@
|
|||||||
package main.protocol.memory;
|
package main.protocol.memory;
|
||||||
|
|
||||||
import main.Cacher;
|
|
||||||
import main.protocol.HConnection;
|
|
||||||
import main.protocol.HMessage;
|
|
||||||
import main.protocol.HPacket;
|
import main.protocol.HPacket;
|
||||||
import main.protocol.crypto.RC4;
|
import main.protocol.crypto.RC4;
|
||||||
|
import main.protocol.memory.habboclient.HabboClient;
|
||||||
|
import main.protocol.memory.habboclient.HabboClientFactory;
|
||||||
|
import main.protocol.memory.habboclient.linux.LinuxHabboClient;
|
||||||
import main.protocol.packethandler.IncomingHandler;
|
import main.protocol.packethandler.IncomingHandler;
|
||||||
import main.protocol.packethandler.OutgoingHandler;
|
import main.protocol.packethandler.OutgoingHandler;
|
||||||
import main.protocol.packethandler.PayloadBuffer;
|
import main.protocol.packethandler.PayloadBuffer;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class Rc4Obtainer {
|
public class Rc4Obtainer {
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ public class Rc4Obtainer {
|
|||||||
IncomingHandler incomingHandler = null;
|
IncomingHandler incomingHandler = null;
|
||||||
|
|
||||||
public Rc4Obtainer() {
|
public Rc4Obtainer() {
|
||||||
client = HabboClient.create();
|
client = HabboClientFactory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hashappened1 = false;
|
private boolean hashappened1 = false;
|
||||||
|
11
src/main/protocol/memory/habboclient/HabboClient.java
Normal file
11
src/main/protocol/memory/habboclient/HabboClient.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main.protocol.memory.habboclient;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 13/06/18.
|
||||||
|
*/
|
||||||
|
public interface HabboClient {
|
||||||
|
|
||||||
|
List<byte[]> getRC4possibilities();
|
||||||
|
}
|
19
src/main/protocol/memory/habboclient/HabboClientFactory.java
Normal file
19
src/main/protocol/memory/habboclient/HabboClientFactory.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package main.protocol.memory.habboclient;
|
||||||
|
|
||||||
|
import main.OSValidator;
|
||||||
|
import main.protocol.memory.habboclient.linux.LinuxHabboClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 13/06/18.
|
||||||
|
*/
|
||||||
|
public class HabboClientFactory {
|
||||||
|
|
||||||
|
|
||||||
|
public static HabboClient get() {
|
||||||
|
if (OSValidator.isUnix()) return new LinuxHabboClient();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
package main.protocol.memory;
|
package main.protocol.memory.habboclient.linux;
|
||||||
|
|
||||||
|
import main.protocol.memory.habboclient.HabboClient;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class HabboClient {
|
public class LinuxHabboClient implements HabboClient {
|
||||||
|
|
||||||
|
|
||||||
private static final String[] potentialProcessNames = {"--ppapi-flash-args", "plugin-container"};
|
private static final String[] potentialProcessNames = {"--ppapi-flash-args", "plugin-container"};
|
||||||
@ -14,9 +16,10 @@ public class HabboClient {
|
|||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
static HabboClient create() {
|
public LinuxHabboClient() {
|
||||||
File folder = new File("/proc");
|
File folder = new File("/proc");
|
||||||
HabboClient client = null;
|
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
File[] fileList = folder.listFiles();
|
File[] fileList = folder.listFiles();
|
||||||
@ -31,18 +34,18 @@ public class HabboClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isHabboProcess) {
|
if (isHabboProcess) {
|
||||||
client = new HabboClient();
|
this.PID = Integer.parseInt(file.getName());
|
||||||
client.PID = Integer.parseInt(file.getName());
|
this.maps = new ArrayList<>();
|
||||||
client.maps = new ArrayList<>();
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (client == null);
|
} while (!found);
|
||||||
|
|
||||||
|
if (DEBUG) System.out.println("* Found flashclient process: " + PID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (DEBUG) System.out.println("* Found flashclient process: " + client.PID);
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
private void refreshMemoryMaps() {
|
private void refreshMemoryMaps() {
|
||||||
String filename = "/proc/"+this.PID+"/maps";
|
String filename = "/proc/"+this.PID+"/maps";
|
||||||
BufferedReader reader;
|
BufferedReader reader;
|
||||||
@ -76,25 +79,25 @@ public class HabboClient {
|
|||||||
if (DEBUG) System.out.println("* Found memory maps (amount: " + maps.size() + ")");
|
if (DEBUG) System.out.println("* Found memory maps (amount: " + maps.size() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<MemorySnippet> createMemorySnippetList (List<long[]> maps) {
|
private static List<LinuxMemorySnippet> createMemorySnippetList (List<long[]> maps) {
|
||||||
List<MemorySnippet> result = new ArrayList<>();
|
List<LinuxMemorySnippet> result = new ArrayList<>();
|
||||||
|
|
||||||
for (long[] map : maps) {
|
for (long[] map : maps) {
|
||||||
long begin = map[0];
|
long begin = map[0];
|
||||||
long end = map[1];
|
long end = map[1];
|
||||||
|
|
||||||
MemorySnippet snippet = new MemorySnippet(begin, new byte[(int)(end - begin)] );
|
LinuxMemorySnippet snippet = new LinuxMemorySnippet(begin, new byte[(int)(end - begin)] );
|
||||||
result.add(snippet);
|
result.add(snippet);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchMemory(List<MemorySnippet> snippets) {
|
private void fetchMemory(List<LinuxMemorySnippet> snippets) {
|
||||||
for (MemorySnippet snippet : snippets) {
|
for (LinuxMemorySnippet snippet : snippets) {
|
||||||
fetchMemory(snippet);
|
fetchMemory(snippet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void fetchMemory(MemorySnippet snippet) {
|
private void fetchMemory(LinuxMemorySnippet snippet) {
|
||||||
String memoryPath = "/proc/" + PID + "/mem";
|
String memoryPath = "/proc/" + PID + "/mem";
|
||||||
long begin = snippet.offset;
|
long begin = snippet.offset;
|
||||||
try {
|
try {
|
||||||
@ -129,15 +132,15 @@ public class HabboClient {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<byte[]> getRC4possibilities() {
|
public List<byte[]> getRC4possibilities() {
|
||||||
int offset = 4;
|
int offset = 4;
|
||||||
|
|
||||||
List<MemorySnippet> possibilities = createMemorySnippetListForRC4();
|
List<LinuxMemorySnippet> possibilities = createMemorySnippetListForRC4();
|
||||||
fetchMemory(possibilities);
|
fetchMemory(possibilities);
|
||||||
|
|
||||||
List<byte[]> resultSet = new ArrayList<>();
|
List<byte[]> resultSet = new ArrayList<>();
|
||||||
|
|
||||||
for (MemorySnippet snippet : possibilities) {
|
for (LinuxMemorySnippet snippet : possibilities) {
|
||||||
if (snippet.getData().length >= 1024 && snippet.getData().length <= 1024+2*offset) {
|
if (snippet.getData().length >= 1024 && snippet.getData().length <= 1024+2*offset) {
|
||||||
for (int i = 0; i < (snippet.getData().length - ((256 - 1) * offset)); i+=offset) {
|
for (int i = 0; i < (snippet.getData().length - ((256 - 1) * offset)); i+=offset) {
|
||||||
byte[] wannabeRC4data = Arrays.copyOfRange(snippet.getData(), i, 1025 + i);
|
byte[] wannabeRC4data = Arrays.copyOfRange(snippet.getData(), i, 1025 + i);
|
||||||
@ -150,14 +153,14 @@ public class HabboClient {
|
|||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MemorySnippet> createMemorySnippetListForRC4() {
|
private List<LinuxMemorySnippet> createMemorySnippetListForRC4() {
|
||||||
|
|
||||||
int offset = 4;
|
int offset = 4;
|
||||||
|
|
||||||
refreshMemoryMaps();
|
refreshMemoryMaps();
|
||||||
String memoryPath = "/proc/" + PID + "/mem";
|
String memoryPath = "/proc/" + PID + "/mem";
|
||||||
|
|
||||||
List<MemorySnippet> result = new ArrayList<>();
|
List<LinuxMemorySnippet> result = new ArrayList<>();
|
||||||
for (long[] map : maps) {
|
for (long[] map : maps) {
|
||||||
long start = map[0];
|
long start = map[0];
|
||||||
long end = map[1];
|
long end = map[1];
|
||||||
@ -215,7 +218,7 @@ public class HabboClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (matchEnd < i - ((256 - 1) * offset)) {
|
if (matchEnd < i - ((256 - 1) * offset)) {
|
||||||
result.add(new MemorySnippet(start + matchStart, new byte[matchEnd - matchStart + 4]));
|
result.add(new LinuxMemorySnippet(start + matchStart, new byte[matchEnd - matchStart + 4]));
|
||||||
matchStart = i - ((256 - 1) * offset);
|
matchStart = i - ((256 - 1) * offset);
|
||||||
}
|
}
|
||||||
matchEnd = i;
|
matchEnd = i;
|
||||||
@ -224,7 +227,7 @@ public class HabboClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (matchStart != -1) {
|
if (matchStart != -1) {
|
||||||
result.add(new MemorySnippet(start + matchStart, new byte[matchEnd - matchStart + 4]));
|
result.add(new LinuxMemorySnippet(start + matchStart, new byte[matchEnd - matchStart + 4]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
@ -1,10 +1,10 @@
|
|||||||
package main.protocol.memory;
|
package main.protocol.memory.habboclient.linux;
|
||||||
|
|
||||||
public class MemorySnippet {
|
public class LinuxMemorySnippet {
|
||||||
long offset;
|
long offset;
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
|
||||||
public MemorySnippet(long offset, byte[] data) {
|
public LinuxMemorySnippet(long offset, byte[] data) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user