add retro support (long connection time)

This commit is contained in:
sirjonasxx 2018-04-06 03:45:21 +02:00
parent 1629bf3cfe
commit 5c62c1d188
2 changed files with 70 additions and 45 deletions

View File

@ -64,8 +64,13 @@ public class Rc4Obtainer {
if (DEBUG) System.out.println("[+] send encrypted"); if (DEBUG) System.out.println("[+] send encrypted");
sleep(20); sleep(20);
while (pingHeader == -1) { int count = 0;
while (pingHeader == -1 && count < 500) {
sleep(50); sleep(50);
count++;
}
if (count == 500) {
System.out.println("are you connected to a retro? trying other things (might take a while)..");
} }
incomingHandler.block(); incomingHandler.block();
@ -88,21 +93,26 @@ public class Rc4Obtainer {
if (DEBUG) System.out.println("size: " + getTotalBytesLengthOfDiff(diff)); if (DEBUG) System.out.println("size: " + getTotalBytesLengthOfDiff(diff));
int i = 0; int i = 0;
while (getTotalBytesLengthOfDiff(diff) > 2000) { while (getTotalBytesLengthOfDiff(diff) > 2000) {
int am = 0; if (pingHeader != -1) {
if (i == 0 || i > 1) { int am = 0;
am = rand.nextInt(25) + 5; if (i == 0 || i > 1) {
for (int j = 0; j < am; j++) { am = rand.nextInt(25) + 5;
incomingHandler.sendToStream(new HPacket(pingHeader).toBytes()); for (int j = 0; j < am; j++) {
outgoingHandler.fakePongAlert(); incomingHandler.sendToStream(new HPacket(pingHeader).toBytes());
sleep(20); outgoingHandler.fakePongAlert();
sleep(20);
}
} }
sleep(50);
} }
sleep(50); else {
int rem = addedBytes; while (addedBytes == 0) {
if (i == 0) client.pauseProcess(); sleep(50);
}
System.out.println("making progress..");
}
diff = searchForPossibleRC4Tables(diff); diff = searchForPossibleRC4Tables(diff);
if (i == 0) client.resumeProcess();
if (DEBUG) System.out.println("size: " + getTotalBytesLengthOfDiff(diff) + " with changed bytes: " + rem + " should be: " + am * 6);
i++; i++;
} }
@ -146,15 +156,33 @@ public class Rc4Obtainer {
MemorySnippet snippet1 = new MemorySnippet(snippet.getOffset(), new byte[snippet.getData().length]); MemorySnippet snippet1 = new MemorySnippet(snippet.getOffset(), new byte[snippet.getData().length]);
client.fetchMemory(snippet1); client.fetchMemory(snippet1);
incomingHandler.sendToStream(new HPacket(pingHeader).toBytes()); if (pingHeader != -1) {
outgoingHandler.fakePongAlert(); incomingHandler.sendToStream(new HPacket(pingHeader).toBytes());
outgoingHandler.fakePongAlert();
}
sleep(70); sleep(70);
byte[] lastPongPacket = new byte[6]; byte[] lastOutgoingPacket;
List<Byte> encodedbytelistraw = outgoingHandler.getEncryptedBuffer(); if (pingHeader != -1) {
for (int i = 0; i < 6; i++) { lastOutgoingPacket = new byte[6];
lastPongPacket[i] = encodedbytelistraw.get(encodedbytelistraw.size() - 6 + i);
} }
else {
int size = outgoingHandler.getEncryptedBuffer().size();
int copy = size;
while (copy == size) {
sleep(1);
copy = outgoingHandler.getEncryptedBuffer().size();
}
lastOutgoingPacket = new byte[copy - size];
System.out.println("size: " + lastOutgoingPacket.length);
}
for (int i = 0; i < lastOutgoingPacket.length; i++) {
List<Byte> encodedbytelistraw = outgoingHandler.getEncryptedBuffer();
lastOutgoingPacket[i] = encodedbytelistraw.get(encodedbytelistraw.size() - lastOutgoingPacket.length + i);
}
int counter = 0; int counter = 0;
RC4 result = null; RC4 result = null;
@ -174,7 +202,7 @@ public class Rc4Obtainer {
} }
RC4 rc4Tryout = new RC4(copy, x, y); RC4 rc4Tryout = new RC4(copy, x, y);
HPacket tryout = new HPacket(rc4Tryout.rc4(lastPongPacket)); HPacket tryout = new HPacket(rc4Tryout.rc4(lastOutgoingPacket));
if (!tryout.isCorrupted()) { if (!tryout.isCorrupted()) {
result = rc4Tryout; result = rc4Tryout;
break outerloop; break outerloop;

View File

@ -29,29 +29,10 @@ public class Connection extends SubForm {
public void initialize() { public void initialize() {
inpPort.getEditor().textProperty().addListener(observable -> { inpPort.getEditor().textProperty().addListener(observable -> {
try { updateInputUI();
int i = Integer.parseInt(inpPort.getEditor().getText());
btnConnect.setDisable(i < 0 || i >= 256 * 256);
}
catch (Exception e) {
btnConnect.setDisable(true);
}
}); });
cbx_autodetect.selectedProperty().addListener(observable -> { cbx_autodetect.selectedProperty().addListener(observable -> {
inpPort.setDisable(cbx_autodetect.isSelected()); updateInputUI();
inpHost.setDisable(cbx_autodetect.isSelected());
if (cbx_autodetect.isSelected()) {
btnConnect.setDisable(false);
}
else {
try {
int i = Integer.parseInt(inpPort.getEditor().getText());
btnConnect.setDisable(i < 0 || i >= 256 * 256);
}
catch (Exception e) {
btnConnect.setDisable(true);
}
}
}); });
inpPort.getItems().addAll("30000", "38101"); inpPort.getItems().addAll("30000", "38101");
@ -61,19 +42,35 @@ public class Connection extends SubForm {
inpHost.getSelectionModel().selectFirst(); inpHost.getSelectionModel().selectFirst();
} }
private void updateInputUI() {
if (cbx_autodetect.isSelected()) {
btnConnect.setDisable(false);
}
else {
try {
int i = Integer.parseInt(inpPort.getEditor().getText());
btnConnect.setDisable(i < 0 || i >= 256 * 256);
}
catch (Exception e) {
btnConnect.setDisable(true);
}
}
inpHost.setDisable(getHConnection().getState() != HConnection.State.NOT_CONNECTED || cbx_autodetect.isSelected());
inpPort.setDisable(getHConnection().getState() != HConnection.State.NOT_CONNECTED || cbx_autodetect.isSelected());
}
public void onParentSet(){ public void onParentSet(){
getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(() -> { getHConnection().addStateChangeListener((oldState, newState) -> Platform.runLater(() -> {
if (newState == HConnection.State.NOT_CONNECTED) { if (newState == HConnection.State.NOT_CONNECTED) {
inpHost.setDisable(false); updateInputUI();
inpPort.setDisable(false);
lblState.setText("Not connected"); lblState.setText("Not connected");
btnConnect.setText("Connect"); btnConnect.setText("Connect");
outHost.setText(""); outHost.setText("");
outPort.setText(""); outPort.setText("");
} }
else if (oldState == HConnection.State.NOT_CONNECTED) { else if (oldState == HConnection.State.NOT_CONNECTED) {
inpHost.setDisable(true); updateInputUI();
inpPort.setDisable(true);
btnConnect.setText("Abort"); btnConnect.setText("Abort");
} }