hotfix habbo.com.br encryption update

This commit is contained in:
sirjonasxx 2018-10-03 01:41:12 +02:00
parent e110a34118
commit 065504f6cd
5 changed files with 51 additions and 23 deletions

View File

@ -203,4 +203,8 @@ public class RC4 {
} }
} }
public byte[] getState () {
return state;
}
} }

View File

@ -1,11 +1,13 @@
package main.protocol.memory; package main.protocol.memory;
import main.protocol.HConnection; 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.HabboClient;
import main.protocol.memory.habboclient.HabboClientFactory; import main.protocol.memory.habboclient.HabboClientFactory;
import main.protocol.memory.habboclient.linux.LinuxHabboClient; import main.protocol.memory.habboclient.linux.LinuxHabboClient;
import main.protocol.packethandler.Handler;
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;
@ -29,59 +31,65 @@ public class Rc4Obtainer {
public void setOutgoingHandler(OutgoingHandler handler) { public void setOutgoingHandler(OutgoingHandler handler) {
outgoingHandler = handler; outgoingHandler = handler;
handler.addBufferListener((int addedbytes) -> { handler.addBufferListener((int addedbytes) -> {
if (!hashappened1 && handler.getCurrentIndex() == 3) { if (!hashappened1 && handler.isEncryptedStream()) {
hashappened1 = true; hashappened1 = true;
onSendFirstEncryptedMessage(); onSendFirstEncryptedMessage(outgoingHandler);
}
});
}
private boolean hashappened2 = false;
public void setIncomingHandler(IncomingHandler handler) {
incomingHandler = handler;
handler.addBufferListener((int addedbytes) -> {
if (!hashappened2 && handler.isEncryptedStream()) {
hashappened2 = true;
onSendFirstEncryptedMessage(incomingHandler);
} }
}); });
} }
public void setIncomingHandler(IncomingHandler handler) { private void onSendFirstEncryptedMessage(Handler handler) {
incomingHandler = handler;
}
private void onSendFirstEncryptedMessage() {
outgoingHandler.block(); outgoingHandler.block();
incomingHandler.block(); incomingHandler.block();
new Thread(() -> {
if (DEBUG) System.out.println("[+] send encrypted");
new Thread(() -> {
if (DEBUG) System.out.println("[+] send encrypted");
List<byte[]> results = client.getRC4possibilities(); List<byte[]> results = client.getRC4possibilities();
outerloop: outerloop:
for (byte[] possible : results) { for (byte[] possible : results) {
byte[] encBuffer = new byte[outgoingHandler.getEncryptedBuffer().size()]; byte[] encBuffer = new byte[handler.getEncryptedBuffer().size()];
for (int i = 0; i < encBuffer.length; i++) { for (int i = 0; i < encBuffer.length; i++) {
encBuffer[i] = outgoingHandler.getEncryptedBuffer().get(i); encBuffer[i] = handler.getEncryptedBuffer().get(i);
} }
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
// System.out.println(i);
for (int j = 0; j < 256; j++) { for (int j = 0; j < 256; j++) {
byte[] keycpy = Arrays.copyOf(possible, possible.length); byte[] keycpy = Arrays.copyOf(possible, possible.length);
RC4 rc4Tryout = new RC4(keycpy, i, j); RC4 rc4Tryout = new RC4(keycpy, i, j);
rc4Tryout.undoRc4(encBuffer); if (handler.getMessageSide() == HMessage.Side.TOSERVER) rc4Tryout.undoRc4(encBuffer);
if (rc4Tryout.couldBeFresh()) { if (rc4Tryout.couldBeFresh()) {
byte[] encDataCopy = Arrays.copyOf(encBuffer, encBuffer.length); byte[] encDataCopy = Arrays.copyOf(encBuffer, encBuffer.length);
RC4 rc4TryCopy = rc4Tryout.deepCopy(); RC4 rc4TryCopy = rc4Tryout.deepCopy();
try { try {
PayloadBuffer payloadBuffer = new PayloadBuffer(); PayloadBuffer payloadBuffer = new PayloadBuffer();
HPacket[] checker = payloadBuffer.pushAndReceive(rc4TryCopy.rc4(encDataCopy)); byte[] decoded = rc4TryCopy.rc4(encDataCopy);
HPacket[] checker = payloadBuffer.pushAndReceive(decoded);
if (payloadBuffer.peak().length == 0) { if (payloadBuffer.peak().length == 0) {
outgoingHandler.setRc4(rc4Tryout); handler.setRc4(rc4Tryout);
incomingHandler.setRc4(rc4Tryout);
break outerloop; break outerloop;
} }
} }
catch (Exception e) { catch (Exception e) {
// e.printStackTrace();
} }
} }

View File

@ -40,8 +40,14 @@ public abstract class Handler {
isDataStream = true; isDataStream = true;
} }
public boolean isEncryptedStream() {
return isEncryptedStream;
}
public abstract void act(byte[] buffer) throws IOException; public abstract void act(byte[] buffer) throws IOException;
protected void continuedAct(byte[] buffer) throws IOException { protected void continuedAct(byte[] buffer) throws IOException {
notifyBufferListeners(buffer.length);
if (!isEncryptedStream) { if (!isEncryptedStream) {
payloadBuffer.push(buffer); payloadBuffer.push(buffer);
} }
@ -58,8 +64,6 @@ public abstract class Handler {
payloadBuffer.push(tm); payloadBuffer.push(tm);
} }
notifyBufferListeners(buffer.length);
if (!isTempBlocked) { if (!isTempBlocked) {
flush(); flush();
} }
@ -130,7 +134,7 @@ public abstract class Handler {
HPacket[] hpackets = payloadBuffer.receive(); HPacket[] hpackets = payloadBuffer.receive();
for (HPacket hpacket : hpackets){ for (HPacket hpacket : hpackets){
HMessage hMessage = new HMessage(hpacket, HMessage.Side.TOCLIENT, currentIndex); HMessage hMessage = new HMessage(hpacket, getMessageSide(), currentIndex);
boolean isencrypted = isEncryptedStream; boolean isencrypted = isEncryptedStream;
if (isDataStream) { if (isDataStream) {
notifyListeners(hMessage); notifyListeners(hMessage);
@ -148,6 +152,8 @@ public abstract class Handler {
} }
} }
public abstract HMessage.Side getMessageSide();
public List<Byte> getEncryptedBuffer() { public List<Byte> getEncryptedBuffer() {
return tempEncryptedBuffer; return tempEncryptedBuffer;
} }

View File

@ -15,9 +15,9 @@ public class IncomingHandler extends Handler {
super(outputStream, listeners); super(outputStream, listeners);
((List<TrafficListener>)listeners[0]).add(message -> { ((List<TrafficListener>)listeners[0]).add(message -> {
if (isDataStream && onlyOnce && message.getPacket().length() == 261) { if (isDataStream && onlyOnce && (message.getPacket().length() == 261 || message.getPacket().length() == 517)) {
onlyOnce = false; onlyOnce = false;
isEncryptedStream = message.getPacket().readBoolean(264); isEncryptedStream = message.getPacket().readBoolean(message.getPacket().length() + 3);
} }
}); });
} }
@ -32,6 +32,11 @@ public class IncomingHandler extends Handler {
} }
} }
@Override
public HMessage.Side getMessageSide() {
return HMessage.Side.TOCLIENT;
}
@Override @Override
protected void printForDebugging(byte[] bytes) { protected void printForDebugging(byte[] bytes) {
System.out.println("-- DEBUG INCOMING -- " + new HPacket(bytes).toString() + " -- DEBUG --"); System.out.println("-- DEBUG INCOMING -- " + new HPacket(bytes).toString() + " -- DEBUG --");

View File

@ -36,6 +36,11 @@ public class OutgoingHandler extends Handler {
} }
} }
@Override
public HMessage.Side getMessageSide() {
return HMessage.Side.TOSERVER;
}
@Override @Override
protected void printForDebugging(byte[] bytes) { protected void printForDebugging(byte[] bytes) {