private void handleCredSSP(ByteBuffer buf, Link link) { if (verbose) System.out.println("[" + this + "] INFO: CredSSP data received: " + buf + "."); // Store header position: will parse whole header later in BER format parser int headerPosition = buf.cursor - 1; long payloadLength = buf.readBerLength(); if (payloadLength > 10 * 1024) throw new RuntimeException( "[" + this + "] ERROR: CredSSP packets seems to be too long: " + payloadLength + "bytes. Data: " + buf + "."); // Length is the size of payload, so we need to append size of header int headerLength = buf.cursor - headerPosition; int packetLength = (int) payloadLength + headerLength; if (!cap(buf, packetLength, packetLength, link, false)) // Wait for full packet to arrive return; // Extract payload (with header) ByteBuffer outBuf = buf.slice(headerPosition, packetLength, true); buf.unref(); if (verbose) { outBuf.putMetadata("source", this); } pushDataToPad(CREDSSP_PAD, outBuf); }
private void responseToChallenge(ByteBuffer buf, Link link) { // Challenge is exactly 16 bytes long if (!cap(buf, 16, 16, link, true)) return; ByteBuffer challenge = buf.slice(buf.cursor, 16, true); buf.unref(); // Encode challenge with password ByteBuffer response; try { response = encodePassword(challenge, password); challenge.unref(); } catch (Exception e) { throw new RuntimeException( "Cannot encrypt client password to send to server: " + e.getMessage()); } if (verbose) { response.putMetadata("sender", this); } // Send encoded challenge nextStage(); pushDataToOTOut(response); }
private void handleTpkt(ByteBuffer buf, Link link) { // Reserved buf.skipBytes(1); // Read TPKT length int length = buf.readUnsignedShort(); if (!cap(buf, length, length, link, false)) // Wait for full packet to arrive return; int payloadLength = length - buf.cursor; // Extract payload ByteBuffer outBuf = buf.slice(buf.cursor, payloadLength, true); buf.unref(); if (verbose) { outBuf.putMetadata("source", this); } pushDataToPad(TPKT_PAD, outBuf); }