fix pesky bug preventing v0 from working

This commit is contained in:
red binder 2026-08-08 05:33:34 +02:00
commit 7e507c7f68
2 changed files with 13 additions and 13 deletions

View file

@ -1,5 +1,3 @@
use bytemuck::from_bytes;
pub mod encryption;
pub mod kerberos;
pub mod socket_addr;
@ -8,9 +6,11 @@ pub mod types_flags;
pub mod virtual_port;
fn read_buffer(data: &[u8]) -> Option<(Vec<u8>, &[u8])> {
let len: u32 = *from_bytes(data.get(..4)?);
let len_bytes: [u8; 4] = data.get(..4)?.try_into().ok()?;
let buf = data.get(4..4 + len as usize)?;
let len = u32::from_ne_bytes(len_bytes) as usize;
Some((buf.into(), data.get(4 + len as usize..).unwrap_or_default()))
let buf = data.get(4..4 + len)?;
Some((buf.to_vec(), data.get(4 + len..).unwrap_or_default()))
}

View file

@ -28,21 +28,21 @@ pub fn read_secure_connection_data(
rc4.apply_keystream(ticket_data);
let ticket_data: &TicketInternalData = match bytemuck::try_from_bytes(ticket_data) {
Ok(v) => v,
Err(e) => {
error!("unable to read internal ticket data: {}", e);
if ticket_data.len() < std::mem::size_of::<TicketInternalData>() {
error!("ticket_data buffer too small for TicketInternalData");
return None;
}
};
// todo: add ticket expiration
let ticket_data_struct: TicketInternalData = bytemuck::pod_read_unaligned(
&ticket_data[..std::mem::size_of::<TicketInternalData>()],
);
let TicketInternalData {
session_key,
pid: ticket_source_pid,
issued_time,
} = *ticket_data;
} = ticket_data_struct;
// todo: add checking if tickets are signed with a valid md5-hmac
let request_data_length = request_data.len();