runelite-proxy: updated constants and fixed packet copying
This commit is contained in:
@@ -35,14 +35,14 @@ public class Proxy
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Proxy.class);
|
||||
|
||||
public static final int REVISION = 139;
|
||||
public static final int REVISION = 140;
|
||||
|
||||
// For revision 139
|
||||
public static final BigInteger SERVER_RSA_KEY_MODULUS = new BigInteger("a0211b55eb8010fd56feae6b163a67945b2ffcb6b3cd976a477f2d88e4cafefebd7174268fa9708acf26dbb44a772d4781f41ecb812f9ae459cf23fd7dc76bd70ac5b9ddaee2c1f6de8f8a8a39750f5f4a5c784079d6e7ba39a8915a6336cd681f3ce8083a344072adf5eec02a7221a05b8fda1e4ff4cf117ea89d290ed6fb7d", 16);
|
||||
// For revision 140
|
||||
public static final BigInteger SERVER_RSA_KEY_MODULUS = new BigInteger("9cb954af0865fabe3fcee77d0a91524f62b18e71b550fa614215edb36424cc57718697e30a7f074ed8bf30c15bb2fca615790d6b322606e48445c2b3393680f56874e5ae8a9f89cd7bbab8c2dd8d2b233b3731f5bb00e9ddb3eddc7a46db157ba848e3ba5fe1e71edde7e36d0976b7ba8dd2ad6c9712ccc9c788212347c3a517", 16);
|
||||
public static final BigInteger SERVER_RSA_KEY_EXPONENT = new BigInteger("10001", 16);
|
||||
public static final int[] PACKET_LENGHTS = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 0, -1, 0, -2, 0, 5, 0, 0, 6, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, 6, -2, 8, 0, 0, 0, 0, -2, -1, 0, 0, -2, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 10, 0, 0, -2, 0, 0, 0, 0, 2, 0, 0, 3, -2, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0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, 0, -2, 0, 6, 10, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 10, 14, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 6, -2, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
public static final RSA myRsa = new RSA();
|
||||
|
||||
@@ -43,16 +43,16 @@ public class ProxyRunner extends Thread
|
||||
private final Socket client;
|
||||
private final Socket server;
|
||||
|
||||
//private RLISAACCipher clientInCipher;
|
||||
private RLISAACCipher clientInCipher;
|
||||
private RLISAACCipher clientOutCipher;
|
||||
|
||||
private RLISAACCipher serverInCipher;
|
||||
//private RLISAACCipher serverOutCipher;
|
||||
private RLISAACCipher serverOutCipher;
|
||||
|
||||
public ProxyRunner(Socket client) throws IOException
|
||||
{
|
||||
this.client = client;
|
||||
this.server = new Socket("localhost", 8080);
|
||||
this.server = new Socket("oldschool84.runescape.com", 43594);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,22 +76,19 @@ public class ProxyRunner extends Thread
|
||||
DataInputStream serverIn = new DataInputStream(server.getInputStream());
|
||||
DataOutputStream serverOut = new DataOutputStream(server.getOutputStream());
|
||||
|
||||
// For the http proxy..
|
||||
serverOut.write("CONNECT oldschool78.runescape.com:43594 HTTP/1.0\r\n\r\n".getBytes());
|
||||
System.out.println(serverIn.readLine());
|
||||
System.out.println(serverIn.readLine());
|
||||
|
||||
int handshakeType = in.read();
|
||||
logger.info("Handshake from client: {}", handshakeType);
|
||||
|
||||
if (handshakeType != 14) // login?
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Forward to server
|
||||
serverOut.write(handshakeType);
|
||||
|
||||
if (handshakeType != 14) // 14 = login, 15 = ondemand
|
||||
{
|
||||
new IOCopy("OnDemand C2S", in, serverOut).start();
|
||||
new IOCopy("OnDemand S2C", serverIn, out).start();
|
||||
return;
|
||||
}
|
||||
|
||||
int handshakeResponse = serverIn.read();
|
||||
logger.info("Handshake response from server: {}", handshakeResponse);
|
||||
|
||||
@@ -146,10 +143,16 @@ public class ProxyRunner extends Thread
|
||||
|
||||
logger.info("Xtea key is {} {} {} {}", key1, key2, key3, key4);
|
||||
|
||||
//clientInCipher = new RLISAACCipher(keys);
|
||||
clientInCipher = new RLISAACCipher(keys);
|
||||
serverOutCipher = new RLISAACCipher(keys);
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
keys[i] += 50;
|
||||
}
|
||||
|
||||
clientOutCipher = new RLISAACCipher(keys);
|
||||
serverInCipher = new RLISAACCipher(keys);
|
||||
//serverOutCipher = new RLISAACCipher(keys);
|
||||
|
||||
// Following this is xtea encrypted data
|
||||
int xteaDataLength = length - 4 - encrypedDataLength - 2; // total length - revision - rsa encrypted data - rsa encrypted data length
|
||||
@@ -181,29 +184,30 @@ public class ProxyRunner extends Thread
|
||||
return;
|
||||
}
|
||||
|
||||
int hasPreferenceValue = serverIn.read();
|
||||
logger.info("Has preference value: {}", hasPreferenceValue);
|
||||
out.write(hasPreferenceValue);
|
||||
assert hasPreferenceValue != 1;
|
||||
int isTrusted = serverIn.read();
|
||||
int trustedValue = serverIn.readInt();
|
||||
logger.info("is trusted value: {}", isTrusted);
|
||||
out.write(isTrusted);
|
||||
out.writeInt(trustedValue);
|
||||
|
||||
int byte1 = serverIn.read();
|
||||
int byte2 = serverIn.read();
|
||||
int interactingIndex = serverIn.readShort() & 0xffff;
|
||||
int byte3 = serverIn.read();
|
||||
int permission = serverIn.read();//0 = player, 1 = player_mod, 2 = jagex_mod
|
||||
int byte2 = serverIn.read();//some boolean, pushed onto intStack in script opcode 3323
|
||||
int interactingIndex = serverIn.readShort() & 0xffff;//index of player in server array
|
||||
int worldType = serverIn.read();//0 = f2p, 1 = p2p, only used for checking friends/ignores list size
|
||||
|
||||
logger.info("B1/B2/interactingIndex/B3: {}/{}/{}/{}", byte1, byte2, interactingIndex, byte3);
|
||||
logger.info("permission/B2/interactingIndex/worldType: {}/{}/{}/{}", permission, byte2, interactingIndex, worldType);
|
||||
|
||||
out.write(byte1);
|
||||
out.write(permission);
|
||||
out.write(byte2);
|
||||
out.writeShort(interactingIndex);
|
||||
out.write(byte3);
|
||||
out.write(worldType);
|
||||
|
||||
int packetOpcode = readOpcode(serverInCipher, serverIn);
|
||||
int staticMapOpcode = readOpcode(serverInCipher, serverIn);
|
||||
int packetLength = serverIn.readShort() & 0xffff;
|
||||
|
||||
logger.info("Packet opcode: {}", packetOpcode);
|
||||
logger.info("staticMap opcode: {}", staticMapOpcode);
|
||||
|
||||
writeOpcode(clientOutCipher, out, packetOpcode);
|
||||
writeOpcode(clientOutCipher, out, staticMapOpcode);
|
||||
out.writeShort(packetLength);
|
||||
|
||||
byte[] packetData = new byte[packetLength];
|
||||
@@ -211,9 +215,8 @@ public class ProxyRunner extends Thread
|
||||
assert len == packetData.length;
|
||||
out.write(packetData);
|
||||
|
||||
new IOCopy("Client to Server", in, serverOut).start();
|
||||
new IOCopy("Server to Client", serverIn, out).start();
|
||||
//new PacketCopy("Server to Client", serverIn, out, serverInCipher, clientOutCipher).start();
|
||||
new PacketCopy("Game C2S", in, serverOut, clientInCipher, serverOutCipher).start();
|
||||
new PacketCopy("Game S2C", serverIn, out, serverInCipher, clientOutCipher).start();
|
||||
}
|
||||
|
||||
public static int readOpcode(RLISAACCipher cipher, InputStream in) throws IOException
|
||||
|
||||
Reference in New Issue
Block a user