Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. if(first) { // first packet, server sends to proxy
  2. Cipher cii = Cipher.getInstance("Blowfish/CFB64/NoPadding");
  3. Key key = new SecretKeySpec(STATIC_KEY.getBytes("ASCII"), "Blowfish");
  4. cii.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(" ".getBytes()));
  5. ByteBuffer bb = ByteBuffer.wrap(cii.doFinal(packet.array())).order(ByteOrder.LITTLE_ENDIAN);
  6.  
  7. int len = bb.getInt(11);
  8. int junkLen = bb.getInt(15);
  9. int index = 19 + junkLen;
  10. byte[] serverIV = new byte[bb.getInt(index)];
  11. index+=4;
  12. System.arraycopy(bb.array(), index, serverIV, 0, serverIV.length);
  13. index+=serverIV.length;
  14. byte[] clientIV = new byte[bb.getInt(index)];
  15. index+=4;
  16. System.arraycopy(bb.array(), index, clientIV, 0, clientIV.length);
  17. index+=clientIV.length;
  18. int strLen = bb.getInt(index);
  19. index+=4;
  20. String p = new String(bb.array(), index, strLen);
  21. index+=strLen;
  22. strLen = bb.getInt(index);
  23. index+=4;
  24. String g = new String(bb.array(), index, strLen);
  25. index+=strLen;
  26. strLen = bb.getInt(index);
  27. index+=4;
  28. String pubKey = new String(bb.array(), index, strLen);
  29. System.out.println("Client IV Len: " + clientIV.length);
  30. System.out.println("Server IV Len: " + serverIV.length);
  31. System.out.println("Key Len: " + pubKey.length());
  32.  
  33.  
  34. // key exchange shit here right
  35.  
  36.  
  37. cii.init(Cipher.ENCRYPT_MODE, key);
  38. return ByteBuffer.wrap(cii.doFinal(bb.array())); // encrypt it and send it back.
Add Comment
Please, Sign In to add comment