|
@@ -181,16 +181,17 @@ public class SSH implements Protocol {
|
|
|
case NONE:
|
|
|
responsePackets
|
|
|
.add(new Packet(serverVersion + serverType + "\r\n", toString()));
|
|
|
+ responsePackets.add(kexInit());
|
|
|
state = STATE.SERVER_VERSION;
|
|
|
break;
|
|
|
case SERVER_VERSION:
|
|
|
extractType(request);
|
|
|
extractPayload(request);
|
|
|
- responsePackets.add(kexInit());
|
|
|
- state = STATE.CLIENT_VERSION;
|
|
|
+ extractPubKey(request);
|
|
|
+ responsePackets.add(dhKexReply());
|
|
|
+ state = STATE.KEX_INIT;
|
|
|
break;
|
|
|
case CLIENT_VERSION:
|
|
|
- extractPubKey(request);
|
|
|
responsePackets.add(dhKexReply());
|
|
|
state = STATE.KEX_INIT;
|
|
|
break;
|
|
@@ -236,7 +237,7 @@ public class SSH implements Protocol {
|
|
|
|
|
|
@Override
|
|
|
public TALK_FIRST whoTalksFirst() {
|
|
|
- return TALK_FIRST.SERVER;
|
|
|
+ return TALK_FIRST.CLIENT;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -387,7 +388,6 @@ public class SSH implements Protocol {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
return wrapPacket(response);
|
|
|
}
|
|
|
|
|
@@ -457,10 +457,11 @@ public class SSH implements Protocol {
|
|
|
request[3 + position] });
|
|
|
int paddingLength = byteToInt(new byte[] { request[4 + position] });
|
|
|
byte[] payload = new byte[packetLength - paddingLength - 1];
|
|
|
- for (int i = 5; i < packetLength - paddingLength - 1; i++) {
|
|
|
- payload[i - 5] = request[i + position];
|
|
|
+ for (int i = 6; i < packetLength - paddingLength - 1; i++) {
|
|
|
+ payload[i - 6] = request[i + position];
|
|
|
}
|
|
|
I_C = payload;
|
|
|
+ System.out.println(HelperUtils.bytesToHexString(I_C));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -470,10 +471,15 @@ public class SSH implements Protocol {
|
|
|
* containing the clients public key
|
|
|
*/
|
|
|
private void extractPubKey(byte[] request) {
|
|
|
- e = new byte[byteToInt(new byte[] { request[6], request[7], request[8],
|
|
|
- request[9] })];
|
|
|
+ int packetLength = byteToInt(new byte[] { request[0],
|
|
|
+ request[1], request[2],
|
|
|
+ request[3] });
|
|
|
+ int paddingLength = byteToInt(new byte[] { request[4] });
|
|
|
+ byte[] len = new byte[] { request[2+packetLength + paddingLength], request[3+ packetLength + paddingLength], request[4 + paddingLength + packetLength],
|
|
|
+ request[5 + packetLength + paddingLength] };
|
|
|
+ e = new byte[byteToInt(len)];
|
|
|
for (int i = 0; i < e.length; i++) {
|
|
|
- e[i] = request[i + 10];
|
|
|
+ e[i] = request[i+packetLength + paddingLength+6];
|
|
|
}
|
|
|
}
|
|
|
|