//! * x.224-spec: <https://www.itu.int/rec/T-REC-X.224-199511-I/en>
//! * x.691-spec: <https://www.itu.int/rec/T-REC-X.691/en>
-use nom::IResult;
-use nom::bytes::streaming::take;
-use nom::combinator::{opt, map_opt, map_res};
-use nom::number::streaming::{be_u16, be_u8, le_u16, le_u32, le_u8};
use crate::rdp::error::RdpError;
-use crate::rdp::util::{
- le_slice_to_string, parse_per_length_determinant, utf7_slice_to_string,
-};
+use crate::rdp::util::{le_slice_to_string, parse_per_length_determinant, utf7_slice_to_string};
use crate::rdp::windows;
+use nom::bytes::streaming::take;
+use nom::combinator::{map_opt, map_res, opt};
+use nom::number::streaming::{be_u16, be_u8, le_u16, le_u32, le_u8};
+use nom::IResult;
/// constrains dimension to a range, per spec
/// rdp-spec, section 2.2.1.3.2 Client Core Data
/// parser for t.123 and children
/// t.123-spec, section 8
pub fn parse_t123_tpkt(input: &[u8]) -> IResult<&[u8], T123Tpkt, RdpError> {
- let (i1, _version) =
- verify!(input, be_u8, |&x| x == TpktVersion::T123 as u8)?;
+ let (i1, _version) = verify!(input, be_u8, |&x| x == TpktVersion::T123 as u8)?;
let (i2, _reserved) = try_parse!(i1, be_u8);
// less u8, u8, u16
let (i3, sz) = map_opt!(i2, be_u16, |x: u16| x.checked_sub(4))?;
return Ok((i4, T123Tpkt { child }));
}
-fn take_4_4_bits(input: &[u8]) -> IResult<&[u8], (u8,u8), RdpError> {
- map!(input, be_u8, |b| (b >> 4, b & 0xf))
+fn take_4_4_bits(input: &[u8]) -> IResult<&[u8], (u8, u8), RdpError> {
+ map!(input, be_u8, |b| (b >> 4, b & 0xf))
}
/// rdp-spec, section 2.2.1.1
-fn parse_x224_connection_request(
- input: &[u8],
-) -> IResult<&[u8], X224ConnectionRequest, RdpError> {
+fn parse_x224_connection_request(input: &[u8]) -> IResult<&[u8], X224ConnectionRequest, RdpError> {
let (i1, length) = verify!(input, be_u8, |&x| x != 0xff)?; // 0xff is reserved
let (i2, cr_cdt) = take_4_4_bits(i1)?;
let _ = verify!(i1, value!(cr_cdt.0), |&x| x
- == X224Type::ConnectionRequest as u8)?;
+ == X224Type::ConnectionRequest as u8)?;
let _ = verify!(i1, value!(cr_cdt.1), |&x| x == 0 || x == 1)?;
let (i3, dst_ref) = verify!(i2, be_u16, |&x| x == 0)?;
let (i4, src_ref) = try_parse!(i3, be_u16);
}
// rdp-spec, section 2.2.1.1.1
-fn parse_negotiation_request(
- input: &[u8],
-) -> IResult<&[u8], NegotiationRequest, RdpError> {
+fn parse_negotiation_request(input: &[u8]) -> IResult<&[u8], NegotiationRequest, RdpError> {
do_parse! {
input,
_typ: verify!(
/// rdp-spec, section 2.2.1.2
/// x.224-spec, section 13.3
-fn parse_x224_connection_confirm(
- input: &[u8],
-) -> IResult<&[u8], X224ConnectionConfirm, RdpError> {
+fn parse_x224_connection_confirm(input: &[u8]) -> IResult<&[u8], X224ConnectionConfirm, RdpError> {
let (i1, length) = verify!(input, be_u8, |&x| x != 0xff)?; // 0xff is reserved
let (i2, cr_cdt) = take_4_4_bits(input)?;
let _ = verify!(i1, value!(cr_cdt.0), |&x| x
- == X224Type::ConnectionConfirm as u8)?;
+ == X224Type::ConnectionConfirm as u8)?;
let _ = verify!(i1, value!(cr_cdt.1), |&x| x == 0 || x == 1)?;
let (i3, dst_ref) = verify!(i2, be_u16, |&x| x == 0)?;
let (i4, src_ref) = try_parse!(i3, be_u16);
let (i7, data) = take!(i6, sz)?;
// it will be one of a response message or a failure message
- let opt1: Option<NegotiationFromServer> =
- match opt!(data, parse_negotiation_response) {
- Ok((_remainder, opt)) => match opt {
- Some(x) => Some(NegotiationFromServer::Response(x)),
- None => None,
- },
- Err(e) => return Err(e),
- };
+ let opt1: Option<NegotiationFromServer> = match opt!(data, parse_negotiation_response) {
+ Ok((_remainder, opt)) => match opt {
+ Some(x) => Some(NegotiationFromServer::Response(x)),
+ None => None,
+ },
+ Err(e) => return Err(e),
+ };
let opt2: Option<NegotiationFromServer> = match opt1 {
Some(x) => Some(x),
None => match opt!(data, parse_negotiation_failure) {
}
// rdp-spec, section 2.2.1.1.1
-fn parse_negotiation_response(
- input: &[u8],
-) -> IResult<&[u8], NegotiationResponse, RdpError> {
+fn parse_negotiation_response(input: &[u8]) -> IResult<&[u8], NegotiationResponse, RdpError> {
do_parse! {
input,
_typ: verify!(
}
// rdp-spec, section 2.2.1.1.1
-fn parse_negotiation_failure(
- input: &[u8],
-) -> IResult<&[u8], NegotiationFailure, RdpError> {
+fn parse_negotiation_failure(input: &[u8]) -> IResult<&[u8], NegotiationFailure, RdpError> {
do_parse! {
input,
_typ: verify!(
/// x224-spec, section 13.7
fn parse_x223_data_class_0(input: &[u8]) -> IResult<&[u8], X223Data, RdpError> {
- fn parser(input: &[u8]) -> IResult<&[u8], (u8,u8,u8), RdpError> {
+ fn parser(input: &[u8]) -> IResult<&[u8], (u8, u8, u8), RdpError> {
bits!(
input,
tuple!(
Ok((rem, opt)) => match opt {
// found CsClientCoreData
Some(core_data) => {
- children
- .push(McsConnectRequestChild::CsClientCore(core_data));
+ children.push(McsConnectRequestChild::CsClientCore(core_data));
rem
}
None => match opt!(remainder, parse_cs_net) {
None => {
match opt!(remainder, parse_cs_unknown) {
// was able to parse CsUnknown
- Ok((rem, opt)) => {
- match opt {
- Some(unknown) => {
- children.push(McsConnectRequestChild::CsUnknown(unknown));
- rem
- }
- None => {
- break;
- }
+ Ok((rem, opt)) => match opt {
+ Some(unknown) => {
+ children.push(McsConnectRequestChild::CsUnknown(unknown));
+ rem
}
- }
+ None => {
+ break;
+ }
+ },
Err(nom::Err::Incomplete(i)) => {
return Err(nom::Err::Incomplete(i))
}
- Err(nom::Err::Failure(_))
- | Err(nom::Err::Error(_)) => break,
+ Err(nom::Err::Failure(_)) | Err(nom::Err::Error(_)) => break,
}
}
},
- Err(nom::Err::Incomplete(i)) => {
- return Err(nom::Err::Incomplete(i))
- }
- Err(nom::Err::Failure(_)) | Err(nom::Err::Error(_)) => {
- break
- }
+ Err(nom::Err::Incomplete(i)) => return Err(nom::Err::Incomplete(i)),
+ Err(nom::Err::Failure(_)) | Err(nom::Err::Error(_)) => break,
},
},
- Err(nom::Err::Incomplete(i)) => {
- return Err(nom::Err::Incomplete(i))
- }
+ Err(nom::Err::Incomplete(i)) => return Err(nom::Err::Incomplete(i)),
Err(nom::Err::Failure(_)) | Err(nom::Err::Error(_)) => break,
};
if remainder.len() == 0 {
//
let (j13, post_beta2_color_depth) =
- match opt!(j12, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8],_> {
+ match opt!(j12, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j12, None),
};
let (j14, client_product_id) = match post_beta2_color_depth {
None => (j13, None),
- Some(_) => match opt!(j13, le_u16) as IResult<&[u8],_> {
+ Some(_) => match opt!(j13, le_u16) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j13, None),
},
let (j15, serial_number) = match client_product_id {
None => (j14, None),
- Some(_) => match opt!(j14, le_u32) as IResult<&[u8],_> {
+ Some(_) => match opt!(j14, le_u32) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j14, None),
},
let (j16, high_color_depth) = match serial_number {
None => (j15, None),
Some(_) => {
- match opt!(j15, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8],_> {
+ match opt!(j15, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j15, None),
}
let (j17, supported_color_depth) = match high_color_depth {
None => (j16, None),
Some(_) => {
- match opt!(j16, map_opt!(le_u16, SupportedColorDepth::from_bits)) as IResult<&[u8],_> {
+ match opt!(j16, map_opt!(le_u16, SupportedColorDepth::from_bits)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j16, None),
}
let (j18, early_capability_flags) = match supported_color_depth {
None => (j17, None),
Some(_) => {
- match opt!(j17, map_opt!(le_u16, EarlyCapabilityFlags::from_bits)) as IResult<&[u8],_> {
+ match opt!(j17, map_opt!(le_u16, EarlyCapabilityFlags::from_bits)) as IResult<&[u8], _>
+ {
Ok((rem, obj)) => (rem, obj),
_ => (j17, None),
}
let (j19, client_dig_product_id) = match early_capability_flags {
None => (j18, None),
- Some(_) => match opt(map_res(take(64usize), le_slice_to_string))(j18) as IResult<&[u8],_> {
- Ok((rem, obj)) => (rem, obj),
- _ => (j18, None),
- },
+ Some(_) => {
+ match opt(map_res(take(64usize), le_slice_to_string))(j18) as IResult<&[u8], _> {
+ Ok((rem, obj)) => (rem, obj),
+ _ => (j18, None),
+ }
+ }
};
let (j20, connection_hint) = match client_dig_product_id {
None => (j19, None),
Some(_) => {
- match opt(map_opt(le_u8, num::FromPrimitive::from_u8))(j19) as IResult<&[u8],_> {
+ match opt(map_opt(le_u8, num::FromPrimitive::from_u8))(j19) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j19, None),
}
let (j21, pad) = match connection_hint {
None => (j20, None),
- Some(_) => match opt(take(1usize))(j20) as IResult<&[u8],_> {
+ Some(_) => match opt(take(1usize))(j20) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j20, None),
},
let (j22, server_selected_protocol) = match pad {
None => (j21, None),
Some(_) => {
- match opt!(j21, map_opt!(le_u32, ProtocolFlags::from_bits)) as IResult<&[u8],_> {
+ match opt!(j21, map_opt!(le_u32, ProtocolFlags::from_bits)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j21, None),
}
let (j23, desktop_physical_width) = match server_selected_protocol {
None => (j22, None),
- Some(_) => match opt!(j22, map_opt!(le_u32, millimeters_to_opt)) as IResult<&[u8],_> {
+ Some(_) => match opt!(j22, map_opt!(le_u32, millimeters_to_opt)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j22, None),
},
let (j24, desktop_physical_height) = match desktop_physical_width {
None => (j23, None),
- Some(_) => match opt!(j23, map_opt!(le_u32, millimeters_to_opt)) as IResult<&[u8],_> {
+ Some(_) => match opt!(j23, map_opt!(le_u32, millimeters_to_opt)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j23, None),
},
let (j25, desktop_orientation) = match desktop_physical_height {
None => (j24, None),
Some(_) => {
- match opt!(j24, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8],_> {
+ match opt!(j24, map_opt!(le_u16, num::FromPrimitive::from_u16)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j24, None),
}
let (j26, desktop_scale_factor) = match desktop_orientation {
None => (j25, None),
- Some(_) => match opt!(j25, map_opt!(le_u32, desktop_scale_to_opt)) as IResult<&[u8],_> {
+ Some(_) => match opt!(j25, map_opt!(le_u32, desktop_scale_to_opt)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j25, None),
},
let (_j27, device_scale_factor) = match desktop_scale_factor {
None => (j26, None),
- Some(_) => match opt!(j26, map_opt!(le_u32, device_scale_to_opt)) as IResult<&[u8],_> {
+ Some(_) => match opt!(j26, map_opt!(le_u32, device_scale_to_opt)) as IResult<&[u8], _> {
Ok((rem, obj)) => (rem, obj),
_ => (j26, None),
},
}
// rdp-spec, section 2.2.1.4
-fn parse_mcs_connect_response(
- input: &[u8],
-) -> IResult<&[u8], McsConnectResponse, RdpError> {
+fn parse_mcs_connect_response(input: &[u8]) -> IResult<&[u8], McsConnectResponse, RdpError> {
do_parse! {
input,
_ber_type: verify!(
use crate::rdp::parser::*;
static BYTES: [u8; 37] = [
- 0x03, 0x00, 0x00, 0x25, 0x20, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43,
- 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x3a, 0x20, 0x6d, 0x73, 0x74, 0x73, 0x68,
- 0x61, 0x73, 0x68, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x31, 0x32, 0x33, 0x0d,
- 0x0a,
+ 0x03, 0x00, 0x00, 0x25, 0x20, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x6f, 0x6b,
+ 0x69, 0x65, 0x3a, 0x20, 0x6d, 0x73, 0x74, 0x73, 0x68, 0x61, 0x73, 0x68, 0x3d, 0x75, 0x73,
+ 0x65, 0x72, 0x31, 0x32, 0x33, 0x0d, 0x0a,
];
#[test]
fn test_t123_x224_cookie() {
let t123_bytes = &BYTES[..];
let t123_tpkt: T123Tpkt = T123Tpkt {
- child: T123TpktChild::X224ConnectionRequest(
- X224ConnectionRequest {
- cdt: 0,
- dst_ref: 0,
- src_ref: 0,
- class: 0,
- options: 0,
- cookie: Some(RdpCookie {
- mstshash: String::from("user123"),
- }),
- negotiation_request: None,
- data: Vec::new(),
- },
- ),
+ child: T123TpktChild::X224ConnectionRequest(X224ConnectionRequest {
+ cdt: 0,
+ dst_ref: 0,
+ src_ref: 0,
+ class: 0,
+ options: 0,
+ cookie: Some(RdpCookie {
+ mstshash: String::from("user123"),
+ }),
+ negotiation_request: None,
+ data: Vec::new(),
+ }),
};
assert_eq!(Ok((&[][..], t123_tpkt)), parse_t123_tpkt(t123_bytes));
}
use crate::rdp::parser::*;
static BYTES: [u8; 20] = [
- 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff,
];
static TPKT_BEGIN: usize = 0;
static X224_BEGIN: usize = TPKT_BEGIN + 4;
fn test_t123_x224_negotiate() {
let t123_bytes = &BYTES[TPKT_BEGIN..];
let t123_tpkt: T123Tpkt = T123Tpkt {
- child: T123TpktChild::X224ConnectionRequest(
- X224ConnectionRequest {
- cdt: 0,
- dst_ref: 0,
- src_ref: 0,
- class: 0,
- options: 0,
- cookie: None,
- negotiation_request: Some(NegotiationRequest {
- flags: NegotiationRequestFlags::empty(),
- protocols: ProtocolFlags::PROTOCOL_RDP,
- }),
- data: Vec::new(),
- },
- ),
+ child: T123TpktChild::X224ConnectionRequest(X224ConnectionRequest {
+ cdt: 0,
+ dst_ref: 0,
+ src_ref: 0,
+ class: 0,
+ options: 0,
+ cookie: None,
+ negotiation_request: Some(NegotiationRequest {
+ flags: NegotiationRequestFlags::empty(),
+ protocols: ProtocolFlags::PROTOCOL_RDP,
+ }),
+ data: Vec::new(),
+ }),
};
assert_eq!(
Ok((&BYTES[PADDING_BEGIN..][..], t123_tpkt)),
use crate::rdp::parser::*;
static BYTES: [u8; 429] = [
- 0x03, 0x00, 0x01, 0xac, 0x02, 0xf0, 0x80, 0x7f, 0x65, 0x82, 0x01, 0xa0,
- 0x04, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0xff, 0x30, 0x19, 0x02,
- 0x01, 0x22, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02,
- 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02,
- 0x30, 0x19, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02,
- 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x20,
- 0x02, 0x01, 0x02, 0x30, 0x1c, 0x02, 0x02, 0xff, 0xff, 0x02, 0x02, 0xfc,
- 0x17, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02,
- 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02, 0x04, 0x82, 0x01,
- 0x3f, 0x00, 0x05, 0x00, 0x14, 0x7c, 0x00, 0x01, 0x81, 0x36, 0x00, 0x08,
- 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x44, 0x75, 0x63, 0x61, 0x81, 0x28,
- 0x01, 0xc0, 0xd8, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x03,
- 0x01, 0xca, 0x03, 0xaa, 0x09, 0x04, 0x00, 0x00, 0x71, 0x17, 0x00, 0x00,
- 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00,
- 0x2d, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0xca, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0f, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0xc0, 0x0c, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0xc0, 0x0c, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0xc0, 0x38, 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0x64, 0x70, 0x64,
- 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x72, 0x64, 0x70, 0x73,
- 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x64, 0x72, 0x64, 0x79,
- 0x6e, 0x76, 0x63, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x63, 0x6c, 0x69, 0x70,
+ 0x03, 0x00, 0x01, 0xac, 0x02, 0xf0, 0x80, 0x7f, 0x65, 0x82, 0x01, 0xa0, 0x04, 0x01, 0x01,
+ 0x04, 0x01, 0x01, 0x01, 0x01, 0xff, 0x30, 0x19, 0x02, 0x01, 0x22, 0x02, 0x01, 0x02, 0x02,
+ 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff,
+ 0x02, 0x01, 0x02, 0x30, 0x19, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02,
+ 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x20, 0x02, 0x01, 0x02,
+ 0x30, 0x1c, 0x02, 0x02, 0xff, 0xff, 0x02, 0x02, 0xfc, 0x17, 0x02, 0x02, 0xff, 0xff, 0x02,
+ 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02,
+ 0x04, 0x82, 0x01, 0x3f, 0x00, 0x05, 0x00, 0x14, 0x7c, 0x00, 0x01, 0x81, 0x36, 0x00, 0x08,
+ 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x44, 0x75, 0x63, 0x61, 0x81, 0x28, 0x01, 0xc0, 0xd8,
+ 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x03, 0x01, 0xca, 0x03, 0xaa, 0x09, 0x04,
+ 0x00, 0x00, 0x71, 0x17, 0x00, 0x00, 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45,
+ 0x00, 0x52, 0x00, 0x2d, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xca, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0xc0, 0x0c, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0xc0, 0x0c, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x38,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0x64, 0x70, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x80, 0x72, 0x64, 0x70, 0x73, 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x64,
+ 0x72, 0x64, 0x79, 0x6e, 0x76, 0x63, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x63, 0x6c, 0x69, 0x70,
0x72, 0x64, 0x72, 0x00, 0x00, 0x00, 0xa0, 0xc0, 0xff,
];
static TPKT_BEGIN: usize = 0;
children.push(McsConnectRequestChild::CsNet(CsNet { channels }));
let t123_tpkt: T123Tpkt = T123Tpkt {
child: T123TpktChild::Data(X223Data {
- child: X223DataChild::McsConnectRequest(McsConnectRequest {
- children,
- }),
+ child: X223DataChild::McsConnectRequest(McsConnectRequest { children }),
}),
};
assert_eq!(
use crate::rdp::parser::*;
// changed offset 9 from 0x65 to 0x66 so it is no longer an mcs connect
- static BYTES: [u8; 9] =
- [0x03, 0x00, 0x00, 0x09, 0x02, 0xf0, 0x80, 0x7f, 0x66];
+ static BYTES: [u8; 9] = [0x03, 0x00, 0x00, 0x09, 0x02, 0xf0, 0x80, 0x7f, 0x66];
#[test]
fn test_x223_response() {
&[][..],
T123Tpkt {
child: T123TpktChild::Data(X223Data {
- child: X223DataChild::McsConnectResponse(
- McsConnectResponse {}
- ),
+ child: X223DataChild::McsConnectResponse(McsConnectResponse {}),
})
}
)),
use crate::rdp::parser::*;
// changed offset 4 from 0x02 to 0x03 so it is no longer an X223 data object
- static BYTES: [u8; 9] =
- [0x03, 0x00, 0x00, 0x09, 0x03, 0xf0, 0x80, 0x7f, 0x65];
+ static BYTES: [u8; 9] = [0x03, 0x00, 0x00, 0x09, 0x03, 0xf0, 0x80, 0x7f, 0x65];
#[test]
fn test_t123_raw() {
// changed offset 11 from 0x01 to 0x02 so it is not a known X224 payload type
static BYTES: [u8; 19] = [
- 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
];
#[test]
Ok((
&[][..],
T123Tpkt {
- child: T123TpktChild::X224ConnectionRequest(
- X224ConnectionRequest {
- cdt: 0,
- dst_ref: 0,
- src_ref: 0,
- class: 0,
- options: 0,
- cookie: None,
- negotiation_request: None,
- data: BYTES[11..].to_vec(),
- }
- )
+ child: T123TpktChild::X224ConnectionRequest(X224ConnectionRequest {
+ cdt: 0,
+ dst_ref: 0,
+ src_ref: 0,
+ class: 0,
+ options: 0,
+ cookie: None,
+ negotiation_request: None,
+ data: BYTES[11..].to_vec(),
+ })
}
)),
parse_t123_tpkt(t123_bytes)
use crate::rdp::parser::*;
// changed offset 9 from 0x65 to 0xff so it is no longer an mcs connect
- static BYTES: [u8; 9] =
- [0x03, 0x00, 0x00, 0x09, 0x02, 0xf0, 0x80, 0x7f, 0xff];
+ static BYTES: [u8; 9] = [0x03, 0x00, 0x00, 0x09, 0x02, 0xf0, 0x80, 0x7f, 0xff];
#[test]
fn test_x223_raw() {
#[cfg(test)]
mod tests_negotiate_incomplete_49350 {
- use nom;
use crate::rdp::parser::*;
+ use nom;
static BYTES: [u8; 19] = [
- 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x13, 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
];
static TPKT_BEGIN: usize = 0;
static X224_BEGIN: usize = TPKT_BEGIN + 4;
#[cfg(test)]
mod tests_core_incomplete_49350 {
- use nom;
use crate::rdp::parser::*;
+ use nom;
static BYTES: [u8; 428] = [
- 0x03, 0x00, 0x01, 0xac, 0x02, 0xf0, 0x80, 0x7f, 0x65, 0x82, 0x01, 0xa0,
- 0x04, 0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0xff, 0x30, 0x19, 0x02,
- 0x01, 0x22, 0x02, 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02,
- 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02,
- 0x30, 0x19, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02,
- 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x20,
- 0x02, 0x01, 0x02, 0x30, 0x1c, 0x02, 0x02, 0xff, 0xff, 0x02, 0x02, 0xfc,
- 0x17, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02,
- 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02, 0x04, 0x82, 0x01,
- 0x3f, 0x00, 0x05, 0x00, 0x14, 0x7c, 0x00, 0x01, 0x81, 0x36, 0x00, 0x08,
- 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x44, 0x75, 0x63, 0x61, 0x81, 0x28,
- 0x01, 0xc0, 0xd8, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x03,
- 0x01, 0xca, 0x03, 0xaa, 0x09, 0x04, 0x00, 0x00, 0x71, 0x17, 0x00, 0x00,
- 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00,
- 0x2d, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0xca, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0f, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x04, 0xc0, 0x0c, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0xc0, 0x0c, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0xc0, 0x38, 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0x64, 0x70, 0x64,
- 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x72, 0x64, 0x70, 0x73,
- 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x64, 0x72, 0x64, 0x79,
- 0x6e, 0x76, 0x63, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x63, 0x6c, 0x69, 0x70,
+ 0x03, 0x00, 0x01, 0xac, 0x02, 0xf0, 0x80, 0x7f, 0x65, 0x82, 0x01, 0xa0, 0x04, 0x01, 0x01,
+ 0x04, 0x01, 0x01, 0x01, 0x01, 0xff, 0x30, 0x19, 0x02, 0x01, 0x22, 0x02, 0x01, 0x02, 0x02,
+ 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff,
+ 0x02, 0x01, 0x02, 0x30, 0x19, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02,
+ 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x20, 0x02, 0x01, 0x02,
+ 0x30, 0x1c, 0x02, 0x02, 0xff, 0xff, 0x02, 0x02, 0xfc, 0x17, 0x02, 0x02, 0xff, 0xff, 0x02,
+ 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0xff, 0xff, 0x02, 0x01, 0x02,
+ 0x04, 0x82, 0x01, 0x3f, 0x00, 0x05, 0x00, 0x14, 0x7c, 0x00, 0x01, 0x81, 0x36, 0x00, 0x08,
+ 0x00, 0x10, 0x00, 0x01, 0xc0, 0x00, 0x44, 0x75, 0x63, 0x61, 0x81, 0x28, 0x01, 0xc0, 0xd8,
+ 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x05, 0x00, 0x03, 0x01, 0xca, 0x03, 0xaa, 0x09, 0x04,
+ 0x00, 0x00, 0x71, 0x17, 0x00, 0x00, 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45,
+ 0x00, 0x52, 0x00, 0x2d, 0x00, 0x58, 0x00, 0x59, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xca, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x04, 0xc0, 0x0c, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0xc0, 0x0c, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x38,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0x64, 0x70, 0x64, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x80, 0x72, 0x64, 0x70, 0x73, 0x6e, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x64,
+ 0x72, 0x64, 0x79, 0x6e, 0x76, 0x63, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x63, 0x6c, 0x69, 0x70,
0x72, 0x64, 0x72, 0x00, 0x00, 0x00, 0xa0, 0xc0,
];
static X223_BEGIN: usize = 4;