Pretty much having troubles converting hyperion to 484. Stuck at getting correct login request data (username & password obviously)
Hyperion login:
Code:
case STATE_PRECRYPTED:
if(in.remaining() >= 2) {
/*
* We read the type of login.
*
* 16 = normal
* 18 = reconnection
*/
final int loginOpcode = in.get() & 0xFF;
if(loginOpcode != 16 && loginOpcode != 18) {
logger.info("Invalid login opcode : " + loginOpcode);
session.close(false);
in.rewind();
return false;
}
/*
* We read the size of the login packet.
*/
final int loginSize = in.get() & 0xFF;
/*
* And calculated how long the encrypted block will be.
*/
final int loginEncryptSize = loginSize - (36 + 1 + 1 + 2);
/*
* This could be invalid so if it is we ignore it.
*/
if (loginEncryptSize <= 0) {
logger.info("Encrypted packet size zero or negative : " + loginEncryptSize);
session.close(false);
in.rewind();
return false;
}
session.setAttribute("state", STATE_CRYPTED);
session.setAttribute("size", loginSize);
session.setAttribute("encryptSize", loginEncryptSize);
return true;
}
break;
case STATE_CRYPTED:
int size = (Integer) session.getAttribute("size");
int encryptSize = (Integer) session.getAttribute("encryptSize");
if (in.remaining() >= size) {
/*
* We now read a short which is the client version and
* check if it equals 484.
*/
final int version = in.getInt();
if(version != Server.VERSION) {
logger.info("Incorrect version : " + version);
session.close(false);
in.rewind();
return false;
}
/*
* Is the player using a low memory version of the game?
*/
boolean lowMemoryVersion = (in.get() & 0xFF) == 1;
/*
* The cache indexes.
*/
for (int a = 0; a < 24; a++) {
final int cacheIndexes = in.get();
}
/*
* Gathers up all the junk integers.
*/
for (int b = 0; b < 16; b++) {
final int junk = in.getInt();
}
/*
* The encrypted size includes the size byte which we don't
* need.
*/
encryptSize--;
/*
* We now read the encrypted block opcode (although in most
* 317 clients and this server the RSA is disabled) and
* check it is equal to 10.
*/
final int blockOpcode = in.get() & 0xFF;
if (blockOpcode != 10) {
logger.info("Invalid login block opcode : " + blockOpcode);
session.close(false);
in.rewind();
return false;
}
/*
* We read the client's session key.
*/
long clientKey = in.getLong();
/*
* And verify it has the correct server session key.
*/
long serverKey = (Long) session.getAttribute("serverKey");
long reportedServerKey = in.getLong();
if (reportedServerKey != serverKey) {
logger.info("Server key mismatch (expected : " + serverKey + ", reported : " + reportedServerKey + ")");
session.close(false);
in.rewind();
return false;
}
/*
* We read and format the name and passwords.
*/
final String name = NameUtils.longToName(in.getLong());
final String pass = IoBufferUtils.getRS2String(in);
logger.info("Login request : username=" + name + " password=" + pass);
/*
* And setup the ISAAC cipher which is used to encrypt and
* decrypt opcodes.
*
* However, without RSA, this is rendered useless anyway.
*/
int[] sessionKey = new int[4];
sessionKey[0] = (int) (clientKey >> 32);
sessionKey[1] = (int) clientKey;
sessionKey[2] = (int) (serverKey >> 32);
sessionKey[3] = (int) serverKey;
session.removeAttribute("state");
session.removeAttribute("serverKey");
session.removeAttribute("size");
session.removeAttribute("encryptSize");
ISAACCipher inCipher = new ISAACCipher(sessionKey);
for(int i = 0; i < 4; i++) {
sessionKey[i] += 50;
}
ISAACCipher outCipher = new ISAACCipher(sessionKey);
/*
* Now, the login has completed, and we do the appropriate
* things to fire off the chain of events which will load
* and check the saved games etc.
*/
session.getFilterChain().remove("protocol");
session.getFilterChain().addFirst("protocol", new ProtocolCodecFilter(RS2CodecFactory.GAME));
PlayerDetails pd = new PlayerDetails(session, name, pass, inCipher, outCipher);
//World.getWorld().load(pd);
}
break;
RS2HD login:
Code:
case 1: // here's where we get the username and
// password
@SuppressWarnings("unused")
int loginType = -1,
loginPacketSize = -1;
if (3 <= in.remaining()) {
loginType = in.get() & 0xff; // should
// be
// 16
// or
// 18
loginPacketSize = in.get() & 0xff;
// Logger.log("loginType="+loginType);
} else {
in.rewind();
return false;
}
if (loginPacketSize <= in.remaining()) {
byte[] payload = new byte[loginPacketSize];
in.get(payload);
Packet p = new Packet(session, -1, payload);
@SuppressWarnings("unused")
int loginEncryptPacketSize = loginPacketSize - (36 + 1 + 1 + 2); // can't
// be
// negative
int clientVersion = p.readInt();
if (clientVersion != 484) {
logger.warning("Client is using wrong revision: " + clientVersion + "!");
}
@SuppressWarnings("unused")
int lowMemoryVersion = p.readByte() & 0xff;
for (int n = 0; n < 24; n++) {
@SuppressWarnings("unused")
int cachIDX = p.readByte();
}
for (int n = 0; n < 16; n++) {
@SuppressWarnings("unused")
int junk = p.readInt();
}
int tmpEncryptPacketSize = p.readByte() & 0xff; // hopefully
// same as
// (--loginEncryptPacketSize)
if (tmpEncryptPacketSize != 10) {
@SuppressWarnings("unused")
int encryptPacketId = p.readByte() & 0xff; // hopefully
// 10
}
long clientSessionKey = p.readLong();
long serverSessionKey = p.readLong();
// int uid = p.readInt();
// //unique identifier for this
// session i think ?
String user = Misc.longToPlayerName(p.readLong()), // given
// username
pass = p.readRS2String(); // given
// password
int sessionKey[] = new int[4];
sessionKey[0] = (int) (clientSessionKey >> 32);
sessionKey[1] = (int) clientSessionKey;
sessionKey[2] = (int) (serverSessionKey >> 32);
sessionKey[3] = (int) serverSessionKey;
// session.setAttribute("ISAAC_IN",
// new
// ISAACCipher(sessionKey));
for (int i = 0; i < 4; i++) {
sessionKey[i] += 50;
}
// session.setAttribute("ISAAC_OUT",
// new
// ISAACCipher(sessionKey));
session.removeAttribute("LOGIN_STAGE");
/**
* Here's where we add the user
* to the login queue, and if
* the login is accepted, we
* change their session filter
* to a standard
* RS2ProtocolCodec.
*/
logger.debug("Login request: [username = " + user + ",password = " + pass + "].");
PlayerDetails d = new PlayerDetails(user, pass, session);
workerThread.loadPlayer(d);
session.setIdleTime(IdleStatus.BOTH_IDLE, Constants.SESSION_IDLE_TIME);
session.getFilterChain().remove("protocolFilter");
session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(new CodecFactory()));
return true;
} else {
in.rewind();
return false;
}
Debug login request hyperion:
Code:
19-feb-2011 14:49:29 org.espeon.rs2.net.codec.RS2LoginDecoder doDecode
INFO: Login request : username=lol password=lol[]
HALP