|
@@ -34,7 +34,6 @@ public final class SSH implements Protocol<ByteArray> {
|
|
|
SERVER_VERSION,
|
|
|
CLIENT_VERSION,
|
|
|
KEX_INIT,
|
|
|
- DH_KEX_REP,
|
|
|
CLOSED
|
|
|
}
|
|
|
|
|
@@ -108,35 +107,25 @@ public final class SSH implements Protocol<ByteArray> {
|
|
|
public List<ByteArray> processMessage(ByteArray message) {
|
|
|
List<ByteArray> response = new ArrayList<ByteArray>();
|
|
|
byte[] request = null;
|
|
|
- if(message != null) {
|
|
|
- request = message.get();
|
|
|
- System.out.println("AWDLWDAO: "+message.size());
|
|
|
- }
|
|
|
+ if(message != null) request = message.get();
|
|
|
|
|
|
switch(connectionState) {
|
|
|
case NONE:
|
|
|
response.add(new ByteArray(serverVersion + serverType + "\r\n"));
|
|
|
connectionState = STATE.SERVER_VERSION;
|
|
|
- System.out.println("NONE");
|
|
|
break;
|
|
|
case SERVER_VERSION:
|
|
|
extractType(request);
|
|
|
extractCookie(request);
|
|
|
response.add(new ByteArray(kexInit()));
|
|
|
- connectionState = STATE.KEX_INIT;
|
|
|
- System.out.println("SERVER");
|
|
|
+ connectionState = STATE.CLIENT_VERSION;
|
|
|
break;
|
|
|
case CLIENT_VERSION:
|
|
|
- connectionState = STATE.KEX_INIT;
|
|
|
- System.out.println("CLIENT");
|
|
|
- break;
|
|
|
- case KEX_INIT:
|
|
|
extractPubKey(request);
|
|
|
response.add(new ByteArray(dhKexReply()));
|
|
|
- connectionState = STATE.DH_KEX_REP;
|
|
|
- System.out.println("KEX");
|
|
|
+ connectionState = STATE.KEX_INIT;
|
|
|
break;
|
|
|
- case DH_KEX_REP:
|
|
|
+ case KEX_INIT:
|
|
|
connectionState = STATE.CLOSED;
|
|
|
break;
|
|
|
case CLOSED:
|
|
@@ -436,17 +425,5 @@ public final class SSH implements Protocol<ByteArray> {
|
|
|
(s.length > 20) ? 20 : s.length);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- public static String bytesToHex(byte[] bytes) {
|
|
|
- final char[] hexArray = "0123456789ABCDEF".toCharArray();
|
|
|
- char[] hexChars = new char[bytes.length * 2];
|
|
|
- int v;
|
|
|
- for ( int j = 0; j < bytes.length; j++ ) {
|
|
|
- v = bytes[j] & 0xFF;
|
|
|
- hexChars[j * 2] = hexArray[v >>> 4];
|
|
|
- hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
|
|
- }
|
|
|
- return new String(hexChars);
|
|
|
- }
|
|
|
+
|
|
|
}
|