Search in sources :

Example 31 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class ServerMonitorReadyPDU method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_MONITOR_READY (1)
    0x01, //  CLIPRDR_HEADER::msgType = CB_MONITOR_READY (1)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::msgFlags = 0
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0 bytes
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    Element monitor_ready = new ServerMonitorReadyPDU("monitor_ready", state);
    Element sink = new MockSink("sink", new ByteBuffer[] {});
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, monitor_ready, sink);
    pipeline.link("source", "router >monitor_ready", "monitor_ready", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state
    if (!state.serverReady)
        throw new RuntimeException("Server monitor ready packet parsed incorrectly.");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) Pipeline(streamer.Pipeline)

Example 32 with PipelineImpl

use of streamer.PipelineImpl in project cloudstack by apache.

the class ServerNtlmsspChallenge method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    /* @formatter:off */
    byte[] packet = new byte[] { // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    (byte) 0x82, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x01, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 258 bytes
    0x02, // TAG: [0] (constructed) LEN: 3 bytes
    (byte) 0xa0, // TAG: [0] (constructed) LEN: 3 bytes
    0x03, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x02, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x01, // TAG: [UNIVERSAL 2] (primitive) "INTEGER" LEN: 1 bytes, Version: 0x3
    0x03, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0xa1, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0x81, // TAG: [1] (constructed) LEN: 250 bytes
    (byte) 0xfa, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 247 bytes
    (byte) 0xf7, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    0x30, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 16] (constructed) "SEQUENCE" LEN: 244 bytes
    (byte) 0xf4, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0xa0, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0x81, // TAG: [0] (constructed) LEN: 241 bytes
    (byte) 0xf1, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    0x04, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    (byte) 0x81, // TAG: [UNIVERSAL 4] (primitive) "OCTET STRING" LEN: 238 bytes
    (byte) 0xee, // "NTLMSSP\0"
    0x4e, // "NTLMSSP\0"
    0x54, // "NTLMSSP\0"
    0x4c, // "NTLMSSP\0"
    0x4d, // "NTLMSSP\0"
    0x53, // "NTLMSSP\0"
    0x53, // "NTLMSSP\0"
    0x50, // "NTLMSSP\0"
    0x00, // MessageType (CHALLENGE)
    0x02, // MessageType (CHALLENGE)
    0x00, // MessageType (CHALLENGE)
    0x00, // MessageType (CHALLENGE)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x1e, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x1e, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x38, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // TargetName (length: 30, allocated space: 30, offset: 56)
    0x00, // NegotiateFlags
    0x35, // NegotiateFlags
    (byte) 0x82, // NegotiateFlags
    (byte) 0x8a, // NegotiateFlags
    (byte) 0xe2, //  ServerChallenge
    0x52, //  ServerChallenge
    (byte) 0xbe, //  ServerChallenge
    (byte) 0x83, //  ServerChallenge
    (byte) 0xd1, //  ServerChallenge
    (byte) 0xf8, //  ServerChallenge
    (byte) 0x80, //  ServerChallenge
    0x16, //  ServerChallenge
    0x6a, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, //  Reserved
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    (byte) 0x98, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    (byte) 0x98, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x56, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // TargetInfo (length: 152, allocated space: 152, offset: 86)
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x06, // Version (6.3, build 9431) , NTLM current revision: 15
    0x03, // Version (6.3, build 9431) , NTLM current revision: 15
    (byte) 0xd7, // Version (6.3, build 9431) , NTLM current revision: 15
    0x24, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x00, // Version (6.3, build 9431) , NTLM current revision: 15
    0x0f, // Target name value: "WIN-LO419B2LSR0"
    0x57, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x49, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4e, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x2d, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4c, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4f, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x34, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x31, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x39, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x42, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x32, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x4c, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x53, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x52, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Target name value: "WIN-LO419B2LSR0"
    0x30, // Target name value: "WIN-LO419B2LSR0"
    0x00, // Item Type: NetBIOS domain name (0x0002, LE)
    0x02, // Item Type: NetBIOS domain name (0x0002, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, //  Item Type: NetBIOS computer name (0x0001, LE)
    0x01, //  Item Type: NetBIOS computer name (0x0001, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: DNS domain name (0x0004, LE)
    0x04, // Item Type: DNS domain name (0x0004, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: DNS computer name (0x0003, LE)
    0x03, // Item Type: DNS computer name (0x0003, LE)
    0x00, //  Item Length: 30 (LE)
    0x1e, //  Item Length: 30 (LE)
    0x00, // "WIN-LO419B2LSR0"
    0x57, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x49, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4e, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x2d, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4f, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x34, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x31, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x39, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x42, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x32, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x4c, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x53, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x52, // "WIN-LO419B2LSR0"
    0x00, // "WIN-LO419B2LSR0"
    0x30, // "WIN-LO419B2LSR0"
    0x00, // Item Type: Timestamp (0x0007, LE)
    0x07, // Item Type: Timestamp (0x0007, LE)
    0x00, //  Item Length: 8 (LE)
    0x08, //  Item Length: 8 (LE)
    0x00, // TODO
    (byte) 0x99, // TODO
    0x4f, // TODO
    0x02, // TODO
    (byte) 0xd8, // TODO
    (byte) 0xf4, // TODO
    (byte) 0xaf, // TODO
    (byte) 0xce, // TODO
    0x01, // Attribute: End of list
    0x00, 0x00, 0x00, 0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet, new byte[] { 1, 2, 3 }));
    NtlmState state = new NtlmState();
    Element ntlmssp_challenge = new ServerNtlmsspChallenge("ntlmssp_challenge", state);
    Element sink = new MockSink("sink", ByteBuffer.convertByteArraysToByteBuffers());
    Element mainSink = new MockSink("mainSink", ByteBuffer.convertByteArraysToByteBuffers(new byte[] { 1, 2, 3 }));
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, ntlmssp_challenge, sink, mainSink);
    pipeline.link("source", "ntlmssp_challenge", "mainSink");
    pipeline.link("ntlmssp_challenge >" + OTOUT, "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
    // Check state challenge
    byte[] challenge = new byte[] { 0x52, (byte) 0xbe, (byte) 0x83, (byte) 0xd1, (byte) 0xf8, (byte) 0x80, 0x16, 0x6a };
    if (state.serverChallenge == null)
        throw new RuntimeException("Challenge was not extracted from server NTLMSSP Challenge packet.");
    if (!Arrays.equals(challenge, state.serverChallenge))
        throw new RuntimeException("Challenge was extracted from server NTLMSSP Challenge packet is not equal to expected. Actual value: " + state.serverChallenge + ", expected value: " + challenge + ".");
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) Pipeline(streamer.Pipeline)

Aggregations

Pipeline (streamer.Pipeline)32 PipelineImpl (streamer.PipelineImpl)32 Element (streamer.Element)28 MockSource (streamer.debug.MockSource)25 MockSink (streamer.debug.MockSink)24 BaseElement (streamer.BaseElement)14 ByteBuffer (streamer.ByteBuffer)7 ScreenDescription (common.ScreenDescription)6 FakeSink (streamer.debug.FakeSink)3 InetSocketAddress (java.net.InetSocketAddress)2 SSLState (streamer.ssl.SSLState)2 RdpBufferedImageCanvas (com.cloud.consoleproxy.rdp.RdpBufferedImageCanvas)1 BufferedImageCanvas (common.BufferedImageCanvas)1 SizeChangeListener (common.SizeChangeListener)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 RdpClient (rdpclient.RdpClient)1 ServerBitmapUpdate (rdpclient.rdp.ServerBitmapUpdate)1