diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 048afbe5a7f..cd75d43933d 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -245,8 +245,7 @@ pub unsafe extern "C" fn SCTxDataUpdateFileFlags(txd: &mut AppLayerTxData, state #[macro_export] macro_rules!export_tx_data_get { ($name:ident, $type:ty) => { - #[no_mangle] - pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void) + unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void) -> *mut $crate::applayer::AppLayerTxData { let tx = &mut *(tx as *mut $type); @@ -272,8 +271,7 @@ impl AppLayerStateData { #[macro_export] macro_rules!export_state_data_get { ($name:ident, $type:ty) => { - #[no_mangle] - pub unsafe extern "C" fn $name(state: *mut std::os::raw::c_void) + unsafe extern "C" fn $name(state: *mut std::os::raw::c_void) -> *mut $crate::applayer::AppLayerStateData { let state = &mut *(state as *mut $type); diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 9a23ee683f5..9f706a74bba 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -349,8 +349,8 @@ unsafe extern "C" fn rs_template_tx_get_alstate_progress(tx: *mut c_void, _direc return 0; } -export_tx_data_get!(rs_template_get_tx_data, TemplateTransaction); -export_state_data_get!(rs_template_get_state_data, TemplateState); +export_tx_data_get!(template_get_tx_data, TemplateTransaction); +export_state_data_get!(template_get_state_data, TemplateState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"template\0"; @@ -390,8 +390,8 @@ pub unsafe extern "C" fn rs_template_register_parser() { get_tx_iterator: Some( applayer::state_get_tx_iterator::, ), - get_tx_data: rs_template_get_tx_data, - get_state_data: rs_template_get_state_data, + get_tx_data: template_get_tx_data, + get_state_data: template_get_state_data, apply_tx_config: None, flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS, get_frame_id_by_name: None, diff --git a/rust/src/bittorrent_dht/bittorrent_dht.rs b/rust/src/bittorrent_dht/bittorrent_dht.rs index 33c4c51f449..812625b3deb 100644 --- a/rust/src/bittorrent_dht/bittorrent_dht.rs +++ b/rust/src/bittorrent_dht/bittorrent_dht.rs @@ -140,8 +140,8 @@ impl BitTorrentDHTState { // C exports. -export_tx_data_get!(rs_bittorrent_dht_get_tx_data, BitTorrentDHTTransaction); -export_state_data_get!(rs_bittorrent_dht_get_state_data, BitTorrentDHTState); +export_tx_data_get!(bittorrent_dht_get_tx_data, BitTorrentDHTTransaction); +export_state_data_get!(bittorrent_dht_get_state_data, BitTorrentDHTState); #[no_mangle] pub extern "C" fn rs_bittorrent_dht_state_new( @@ -280,8 +280,8 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(rs_bittorrent_dht_state_get_tx_iterator), - get_tx_data: rs_bittorrent_dht_get_tx_data, - get_state_data: rs_bittorrent_dht_get_state_data, + get_tx_data: bittorrent_dht_get_tx_data, + get_state_data: bittorrent_dht_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: None, diff --git a/rust/src/detect/transforms/casechange.rs b/rust/src/detect/transforms/casechange.rs index c719ef15469..f081aa2d9a0 100644 --- a/rust/src/detect/transforms/casechange.rs +++ b/rust/src/detect/transforms/casechange.rs @@ -27,7 +27,6 @@ use std::ptr; static mut G_TRANSFORM_TOLOWER_ID: c_int = 0; static mut G_TRANSFORM_TOUPPER_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn tolower_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -40,7 +39,6 @@ fn tolower_transform_do(input: &[u8], output: &mut [u8]) { } } -#[no_mangle] unsafe extern "C" fn tolower_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -61,7 +59,6 @@ unsafe extern "C" fn tolower_transform(buffer: *mut c_void, _ctx: *mut c_void) { InspectionBufferTruncate(buffer, input_len); } -#[no_mangle] unsafe extern "C" fn tolower_validate(content: *const u8, len: u16, _ctx: *mut c_void) -> bool { let input = build_slice!(content, len as usize); for &c in input { @@ -90,7 +87,6 @@ pub unsafe extern "C" fn DetectTransformToLowerRegister() { } } -#[no_mangle] unsafe extern "C" fn toupper_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -103,7 +99,6 @@ fn toupper_transform_do(input: &[u8], output: &mut [u8]) { } } -#[no_mangle] unsafe extern "C" fn toupper_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -124,7 +119,6 @@ unsafe extern "C" fn toupper_transform(buffer: *mut c_void, _ctx: *mut c_void) { InspectionBufferTruncate(buffer, input_len); } -#[no_mangle] unsafe extern "C" fn toupper_validate(content: *const u8, len: u16, _ctx: *mut c_void) -> bool { let input = build_slice!(content, len as usize); for &c in input { diff --git a/rust/src/detect/transforms/compress_whitespace.rs b/rust/src/detect/transforms/compress_whitespace.rs index 3e97e46c183..d985fa43191 100644 --- a/rust/src/detect/transforms/compress_whitespace.rs +++ b/rust/src/detect/transforms/compress_whitespace.rs @@ -26,7 +26,6 @@ use std::ptr; static mut G_TRANSFORM_COMPRESS_WHITESPACE_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn compress_whitespace_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -50,7 +49,6 @@ fn compress_whitespace_transform_do(input: &[u8], output: &mut [u8]) -> u32 { return nb as u32; } -#[no_mangle] unsafe extern "C" fn compress_whitespace_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -86,7 +84,6 @@ fn compress_whitespace_validate_do(input: &[u8]) -> bool { return true; } -#[no_mangle] unsafe extern "C" fn compress_whitespace_validate( content: *const u8, len: u16, _ctx: *mut c_void, ) -> bool { diff --git a/rust/src/detect/transforms/dotprefix.rs b/rust/src/detect/transforms/dotprefix.rs index 56e927226ec..60cbf8859db 100644 --- a/rust/src/detect/transforms/dotprefix.rs +++ b/rust/src/detect/transforms/dotprefix.rs @@ -26,7 +26,6 @@ use std::ptr; static mut G_TRANSFORM_DOT_PREFIX_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn dot_prefix_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -42,7 +41,6 @@ fn dot_prefix_transform_do(input: &[u8], output: &mut [u8]) { output[0] = b'.'; } -#[no_mangle] unsafe extern "C" fn dot_prefix_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input_len = InspectionBufferLength(buffer); if input_len == 0 { diff --git a/rust/src/detect/transforms/hash.rs b/rust/src/detect/transforms/hash.rs index 1b947178030..d040258a65e 100644 --- a/rust/src/detect/transforms/hash.rs +++ b/rust/src/detect/transforms/hash.rs @@ -35,7 +35,6 @@ static mut G_TRANSFORM_SHA256_ID: c_int = 0; const SC_MD5_LEN: usize = 16; -#[no_mangle] unsafe extern "C" fn md5_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -50,7 +49,6 @@ fn md5_transform_do(input: &[u8], output: &mut [u8]) { Md5::new().chain(input).finalize_into(output.into()); } -#[no_mangle] unsafe extern "C" fn md5_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -89,7 +87,6 @@ pub unsafe extern "C" fn DetectTransformMd5Register() { } } -#[no_mangle] unsafe extern "C" fn sha1_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -104,7 +101,6 @@ fn sha1_transform_do(input: &[u8], output: &mut [u8]) { Sha1::new().chain(input).finalize_into(output.into()); } -#[no_mangle] unsafe extern "C" fn sha1_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -143,7 +139,6 @@ pub unsafe extern "C" fn DetectTransformSha1Register() { } } -#[no_mangle] unsafe extern "C" fn sha256_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -158,7 +153,6 @@ fn sha256_transform_do(input: &[u8], output: &mut [u8]) { Sha256::new().chain(input).finalize_into(output.into()); } -#[no_mangle] unsafe extern "C" fn sha256_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); diff --git a/rust/src/detect/transforms/http_headers.rs b/rust/src/detect/transforms/http_headers.rs index de40c83198c..77fa17a0d46 100644 --- a/rust/src/detect/transforms/http_headers.rs +++ b/rust/src/detect/transforms/http_headers.rs @@ -27,7 +27,6 @@ use std::ptr; static mut G_TRANSFORM_HEADER_LOWER_ID: c_int = 0; static mut G_TRANSFORM_STRIP_PSEUDO_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn header_lowersetup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -53,7 +52,6 @@ fn header_lowertransform_do(input: &[u8], output: &mut [u8]) { } } -#[no_mangle] unsafe extern "C" fn header_lowertransform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -92,7 +90,6 @@ pub unsafe extern "C" fn DetectTransformHeaderLowercaseRegister() { } } -#[no_mangle] unsafe extern "C" fn strip_pseudo_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -117,7 +114,6 @@ fn strip_pseudo_transform_do(input: &[u8], output: &mut [u8]) -> u32 { return nb as u32; } -#[no_mangle] unsafe extern "C" fn strip_pseudo_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); diff --git a/rust/src/detect/transforms/strip_whitespace.rs b/rust/src/detect/transforms/strip_whitespace.rs index bb8c095cae4..79d9373b7f0 100644 --- a/rust/src/detect/transforms/strip_whitespace.rs +++ b/rust/src/detect/transforms/strip_whitespace.rs @@ -26,7 +26,6 @@ use std::ptr; static mut G_TRANSFORM_STRIP_WHITESPACE_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn strip_whitespace_setup( _de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char, ) -> c_int { @@ -47,7 +46,6 @@ fn strip_whitespace_transform_do(input: &[u8], output: &mut [u8]) -> u32 { return nb as u32; } -#[no_mangle] unsafe extern "C" fn strip_whitespace_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); @@ -68,7 +66,6 @@ unsafe extern "C" fn strip_whitespace_transform(buffer: *mut c_void, _ctx: *mut InspectionBufferTruncate(buffer, output_len); } -#[no_mangle] unsafe extern "C" fn strip_whitespace_validate( content: *const u8, len: u16, _ctx: *mut c_void, ) -> bool { diff --git a/rust/src/detect/transforms/urldecode.rs b/rust/src/detect/transforms/urldecode.rs index 6359382d72c..82c1a307bd9 100644 --- a/rust/src/detect/transforms/urldecode.rs +++ b/rust/src/detect/transforms/urldecode.rs @@ -26,7 +26,6 @@ use std::ptr; static mut G_TRANSFORM_URL_DECODE_ID: c_int = 0; -#[no_mangle] unsafe extern "C" fn url_decode_setup( _de: *mut c_void, s: *mut c_void, _opt: *const std::os::raw::c_char, ) -> c_int { @@ -87,7 +86,6 @@ fn url_decode_transform_do(input: &[u8], output: &mut [u8]) -> u32 { return nb as u32; } -#[no_mangle] unsafe extern "C" fn url_decode_transform(buffer: *mut c_void, _ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); diff --git a/rust/src/detect/transforms/xor.rs b/rust/src/detect/transforms/xor.rs index 6fae23e8f65..a9e204551a9 100644 --- a/rust/src/detect/transforms/xor.rs +++ b/rust/src/detect/transforms/xor.rs @@ -58,7 +58,6 @@ unsafe fn xor_parse(raw: *const std::os::raw::c_char) -> *mut c_void { return std::ptr::null_mut(); } -#[no_mangle] unsafe extern "C" fn xor_setup( de: *mut c_void, s: *mut c_void, opt_str: *const std::os::raw::c_char, ) -> c_int { @@ -81,7 +80,6 @@ fn xor_transform_do(input: &[u8], output: &mut [u8], ctx: &DetectTransformXorDat } } -#[no_mangle] unsafe extern "C" fn xor_transform(buffer: *mut c_void, ctx: *mut c_void) { let input = InspectionBufferPtr(buffer); let input_len = InspectionBufferLength(buffer); diff --git a/rust/src/dhcp/detect.rs b/rust/src/dhcp/detect.rs index 7c458da4e92..9c8fe581d47 100644 --- a/rust/src/dhcp/detect.rs +++ b/rust/src/dhcp/detect.rs @@ -29,7 +29,7 @@ use crate::detect::{ }; use std::os::raw::{c_int, c_void}; -fn rs_dhcp_tx_get_time(tx: &DHCPTransaction, code: u8) -> Option { +fn dhcp_tx_get_time(tx: &DHCPTransaction, code: u8) -> Option { for option in &tx.message.options { if option.code == code { if let DHCPOptionWrapper::TimeValue(ref time_value) = option.option { @@ -78,7 +78,7 @@ unsafe extern "C" fn dhcp_detect_leasetime_match( ) -> c_int { let tx = cast_pointer!(tx, DHCPTransaction); let ctx = cast_pointer!(ctx, DetectUintData); - if let Some(val) = rs_dhcp_tx_get_time(tx, DHCP_OPT_ADDRESS_TIME) { + if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_ADDRESS_TIME) { return rs_detect_u64_match(val, ctx); } return 0; @@ -121,7 +121,7 @@ unsafe extern "C" fn dhcp_detect_rebindingtime_match( ) -> c_int { let tx = cast_pointer!(tx, DHCPTransaction); let ctx = cast_pointer!(ctx, DetectUintData); - if let Some(val) = rs_dhcp_tx_get_time(tx, DHCP_OPT_REBINDING_TIME) { + if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_REBINDING_TIME) { return rs_detect_u64_match(val, ctx); } return 0; @@ -158,14 +158,14 @@ unsafe extern "C" fn dhcp_detect_renewaltime_match( ) -> c_int { let tx = cast_pointer!(tx, DHCPTransaction); let ctx = cast_pointer!(ctx, DetectUintData); - if let Some(val) = rs_dhcp_tx_get_time(tx, DHCP_OPT_RENEWAL_TIME) { + if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_RENEWAL_TIME) { return rs_detect_u64_match(val, ctx); } return 0; } #[no_mangle] -pub unsafe extern "C" fn ScDetectDHCPRegister() { +pub unsafe extern "C" fn SCDetectDHCPRegister() { let kw = SCSigTableElmt { name: b"dhcp.leasetime\0".as_ptr() as *const libc::c_char, desc: b"match DHCP leasetime\0".as_ptr() as *const libc::c_char, diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 28f6f261379..96553537502 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -16,7 +16,7 @@ */ use crate::applayer::{self, *}; -use crate::core::{ALPROTO_UNKNOWN, AppProto, IPPROTO_UDP}; +use crate::core::{AppProto, ALPROTO_UNKNOWN, IPPROTO_UDP}; use crate::dhcp::parser::*; use crate::flow::Flow; use std; @@ -127,7 +127,7 @@ impl DHCPState { } pub fn parse(&mut self, input: &[u8]) -> bool { - match dhcp_parse(input) { + match parse_dhcp(input) { Ok((_, message)) => { let malformed_options = message.malformed_options; let truncated_options = message.truncated_options; @@ -177,13 +177,9 @@ impl DHCPState { } } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_probing_parser(_flow: *const Flow, - _direction: u8, - input: *const u8, - input_len: u32, - _rdir: *mut u8) -> AppProto -{ +unsafe extern "C" fn dhcp_probing_parser( + _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, +) -> AppProto { if input_len < DHCP_MIN_FRAME_LEN || input.is_null() { return ALPROTO_UNKNOWN; } @@ -199,16 +195,16 @@ pub unsafe extern "C" fn rs_dhcp_probing_parser(_flow: *const Flow, } } -#[no_mangle] -pub extern "C" fn rs_dhcp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void, - _direction: u8) -> std::os::raw::c_int { +extern "C" fn dhcp_tx_get_alstate_progress( + _tx: *mut std::os::raw::c_void, _direction: u8, +) -> std::os::raw::c_int { // As this is a stateless parser, simply use 1. return 1; } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_state_get_tx(state: *mut std::os::raw::c_void, - tx_id: u64) -> *mut std::os::raw::c_void { +unsafe extern "C" fn dhcp_state_get_tx( + state: *mut std::os::raw::c_void, tx_id: u64, +) -> *mut std::os::raw::c_void { let state = cast_pointer!(state, DHCPState); match state.get_tx(tx_id) { Some(tx) => { @@ -220,19 +216,15 @@ pub unsafe extern "C" fn rs_dhcp_state_get_tx(state: *mut std::os::raw::c_void, } } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { +unsafe extern "C" fn dhcp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { let state = cast_pointer!(state, DHCPState); return state.tx_id; } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_parse(_flow: *const Flow, - state: *mut std::os::raw::c_void, - _pstate: *mut std::os::raw::c_void, - stream_slice: StreamSlice, - _data: *const std::os::raw::c_void, - ) -> AppLayerResult { +unsafe extern "C" fn dhcp_parse( + _flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void, + stream_slice: StreamSlice, _data: *const std::os::raw::c_void, +) -> AppLayerResult { let state = cast_pointer!(state, DHCPState); if state.parse(stream_slice.as_slice()) { return AppLayerResult::ok(); @@ -240,64 +232,60 @@ pub unsafe extern "C" fn rs_dhcp_parse(_flow: *const Flow, return AppLayerResult::err(); } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_state_tx_free( - state: *mut std::os::raw::c_void, - tx_id: u64) -{ +pub unsafe extern "C" fn dhcp_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { let state = cast_pointer!(state, DHCPState); state.free_tx(tx_id); } -#[no_mangle] -pub extern "C" fn rs_dhcp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { +extern "C" fn dhcp_state_new( + _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto, +) -> *mut std::os::raw::c_void { let state = DHCPState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub unsafe extern "C" fn rs_dhcp_state_free(state: *mut std::os::raw::c_void) { +unsafe extern "C" fn dhcp_state_free(state: *mut std::os::raw::c_void) { std::mem::drop(Box::from_raw(state as *mut DHCPState)); } -export_tx_data_get!(rs_dhcp_get_tx_data, DHCPTransaction); -export_state_data_get!(rs_dhcp_get_state_data, DHCPState); +export_tx_data_get!(dhcp_get_tx_data, DHCPTransaction); +export_state_data_get!(dhcp_get_state_data, DHCPState); const PARSER_NAME: &[u8] = b"dhcp\0"; #[no_mangle] -pub unsafe extern "C" fn rs_dhcp_register_parser() { +pub unsafe extern "C" fn SCRegisterDhcpParser() { SCLogDebug!("Registering DHCP parser."); let ports = CString::new("[67,68]").unwrap(); let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, - default_port : ports.as_ptr(), - ipproto : IPPROTO_UDP, - probe_ts : Some(rs_dhcp_probing_parser), - probe_tc : Some(rs_dhcp_probing_parser), - min_depth : 0, - max_depth : 16, - state_new : rs_dhcp_state_new, - state_free : rs_dhcp_state_free, - tx_free : rs_dhcp_state_tx_free, - parse_ts : rs_dhcp_parse, - parse_tc : rs_dhcp_parse, - get_tx_count : rs_dhcp_state_get_tx_count, - get_tx : rs_dhcp_state_get_tx, - tx_comp_st_ts : 1, - tx_comp_st_tc : 1, - tx_get_progress : rs_dhcp_tx_get_alstate_progress, - get_eventinfo : Some(DHCPEvent::get_event_info), - get_eventinfo_byid : Some(DHCPEvent::get_event_info_by_id), - localstorage_new : None, - localstorage_free : None, - get_tx_files : None, - get_tx_iterator : Some(applayer::state_get_tx_iterator::), - get_tx_data : rs_dhcp_get_tx_data, - get_state_data : rs_dhcp_get_state_data, - apply_tx_config : None, - flags : 0, + default_port: ports.as_ptr(), + ipproto: IPPROTO_UDP, + probe_ts: Some(dhcp_probing_parser), + probe_tc: Some(dhcp_probing_parser), + min_depth: 0, + max_depth: 16, + state_new: dhcp_state_new, + state_free: dhcp_state_free, + tx_free: dhcp_state_tx_free, + parse_ts: dhcp_parse, + parse_tc: dhcp_parse, + get_tx_count: dhcp_state_get_tx_count, + get_tx: dhcp_state_get_tx, + tx_comp_st_ts: 1, + tx_comp_st_tc: 1, + tx_get_progress: dhcp_tx_get_alstate_progress, + get_eventinfo: Some(DHCPEvent::get_event_info), + get_eventinfo_byid: Some(DHCPEvent::get_event_info_by_id), + localstorage_new: None, + localstorage_free: None, + get_tx_files: None, + get_tx_iterator: Some(applayer::state_get_tx_iterator::), + get_tx_data: dhcp_get_tx_data, + get_state_data: dhcp_get_state_data, + apply_tx_config: None, + flags: 0, get_frame_id_by_name: None, get_frame_name_by_id: None, }; diff --git a/rust/src/dhcp/logger.rs b/rust/src/dhcp/logger.rs index a9d8d983b6c..37b66d0b1d1 100644 --- a/rust/src/dhcp/logger.rs +++ b/rust/src/dhcp/logger.rs @@ -18,10 +18,10 @@ use std; use std::os::raw::c_void; +use crate::conf::ConfNode; use crate::dhcp::dhcp::*; -use crate::dhcp::parser::{DHCPOptionWrapper,DHCPOptGeneric}; +use crate::dhcp::parser::{DHCPOptGeneric, DHCPOptionWrapper}; use crate::dns::log::dns_print_addr; -use crate::conf::ConfNode; use crate::jsonbuilder::{JsonBuilder, JsonError}; pub struct DHCPLogger { @@ -29,11 +29,10 @@ pub struct DHCPLogger { } impl DHCPLogger { - pub fn new(conf: ConfNode) -> Self { return Self { extended: conf.get_child_bool("extended"), - } + }; } fn get_type(&self, tx: &DHCPTransaction) -> Option { @@ -42,7 +41,8 @@ impl DHCPLogger { let code = option.code; #[allow(clippy::single_match)] match &option.option { - DHCPOptionWrapper::Generic(option) => { + DHCPOptionWrapper::Generic(option) => + { #[allow(clippy::single_match)] match code { DHCP_OPT_TYPE => { @@ -61,7 +61,7 @@ impl DHCPLogger { pub fn do_log(&self, tx: &DHCPTransaction) -> bool { if !self.extended { - if let Some(DHCP_TYPE_ACK) = self.get_type(tx){ + if let Some(DHCP_TYPE_ACK) = self.get_type(tx) { return true; } return false; @@ -86,101 +86,86 @@ impl DHCPLogger { js.set_string("type", "")?; } } - + js.set_uint("id", header.txid as u64)?; - js.set_string("client_mac", - &format_addr_hex(&header.clienthw))?; + js.set_string("client_mac", &format_addr_hex(&header.clienthw))?; js.set_string("assigned_ip", &dns_print_addr(&header.yourip))?; if self.extended { js.set_string("client_ip", &dns_print_addr(&header.clientip))?; if header.opcode == BOOTP_REPLY { - js.set_string("relay_ip", - &dns_print_addr(&header.giaddr))?; - js.set_string("next_server_ip", - &dns_print_addr(&header.serverip))?; + js.set_string("relay_ip", &dns_print_addr(&header.giaddr))?; + js.set_string("next_server_ip", &dns_print_addr(&header.serverip))?; } } - + for option in options { let code = option.code; match option.option { DHCPOptionWrapper::ClientId(ref clientid) => { - js.set_string("client_id", - &format_addr_hex(&clientid.data))?; + js.set_string("client_id", &format_addr_hex(&clientid.data))?; } - DHCPOptionWrapper::TimeValue(ref time_value) => { - match code { - DHCP_OPT_ADDRESS_TIME => { - if self.extended { - js.set_uint("lease_time", - time_value.seconds as u64)?; - } - } - DHCP_OPT_REBINDING_TIME => { - if self.extended { - js.set_uint("rebinding_time", - time_value.seconds as u64)?; - } - } - DHCP_OPT_RENEWAL_TIME => { - js.set_uint("renewal_time", - time_value.seconds as u64)?; + DHCPOptionWrapper::TimeValue(ref time_value) => match code { + DHCP_OPT_ADDRESS_TIME => { + if self.extended { + js.set_uint("lease_time", time_value.seconds as u64)?; } - _ => {} } - } - DHCPOptionWrapper::Generic(ref option) => { - match code { - DHCP_OPT_SUBNET_MASK => { - if self.extended { - js.set_string("subnet_mask", - &dns_print_addr(&option.data))?; - } + DHCP_OPT_REBINDING_TIME => { + if self.extended { + js.set_uint("rebinding_time", time_value.seconds as u64)?; } - DHCP_OPT_HOSTNAME => { - if !option.data.is_empty() { - js.set_string_from_bytes("hostname", - &option.data)?; - } + } + DHCP_OPT_RENEWAL_TIME => { + js.set_uint("renewal_time", time_value.seconds as u64)?; + } + _ => {} + }, + DHCPOptionWrapper::Generic(ref option) => match code { + DHCP_OPT_SUBNET_MASK => { + if self.extended { + js.set_string("subnet_mask", &dns_print_addr(&option.data))?; } - DHCP_OPT_TYPE => { - self.log_opt_type(js, option)?; + } + DHCP_OPT_HOSTNAME => { + if !option.data.is_empty() { + js.set_string_from_bytes("hostname", &option.data)?; } - DHCP_OPT_REQUESTED_IP => { - if self.extended { - js.set_string("requested_ip", - &dns_print_addr(&option.data))?; - } + } + DHCP_OPT_TYPE => { + self.log_opt_type(js, option)?; + } + DHCP_OPT_REQUESTED_IP => { + if self.extended { + js.set_string("requested_ip", &dns_print_addr(&option.data))?; } - DHCP_OPT_PARAMETER_LIST => { - if self.extended { - self.log_opt_parameters(js, option)?; - } + } + DHCP_OPT_PARAMETER_LIST => { + if self.extended { + self.log_opt_parameters(js, option)?; } - DHCP_OPT_DNS_SERVER => { - if self.extended { - self.log_opt_dns_server(js, option)?; - } + } + DHCP_OPT_DNS_SERVER => { + if self.extended { + self.log_opt_dns_server(js, option)?; } - DHCP_OPT_ROUTERS => { - if self.extended { - self.log_opt_routers(js, option)?; - } + } + DHCP_OPT_ROUTERS => { + if self.extended { + self.log_opt_routers(js, option)?; } - DHCP_OPT_VENDOR_CLASS_ID => { - if self.extended && !option.data.is_empty(){ - js.set_string_from_bytes("vendor_class_identifier", - &option.data)?; - } + } + DHCP_OPT_VENDOR_CLASS_ID => { + if self.extended && !option.data.is_empty() { + js.set_string_from_bytes("vendor_class_identifier", &option.data)?; } - _ => {} } - } + _ => {} + }, _ => {} } } - + js.close()?; return Ok(()); @@ -197,14 +182,16 @@ impl DHCPLogger { DHCP_TYPE_NAK => "nak", DHCP_TYPE_RELEASE => "release", DHCP_TYPE_INFORM => "inform", - _ => "unknown" + _ => "unknown", }; js.set_string("dhcp_type", dhcp_type)?; } Ok(()) } - fn log_opt_parameters(&self, js: &mut JsonBuilder, option: &DHCPOptGeneric) -> Result<(), JsonError> { + fn log_opt_parameters( + &self, js: &mut JsonBuilder, option: &DHCPOptGeneric, + ) -> Result<(), JsonError> { js.open_array("params")?; for i in &option.data { let param = match *i { @@ -216,7 +203,7 @@ impl DHCPLogger { DHCP_PARAM_NTP_SERVER => "ntp_server", DHCP_PARAM_TFTP_SERVER_NAME => "tftp_server_name", DHCP_PARAM_TFTP_SERVER_IP => "tftp_server_ip", - _ => "" + _ => "", }; if !param.is_empty() { js.append_string(param)?; @@ -225,8 +212,10 @@ impl DHCPLogger { js.close()?; Ok(()) } - - fn log_opt_dns_server(&self, js: &mut JsonBuilder, option: &DHCPOptGeneric) -> Result<(), JsonError> { + + fn log_opt_dns_server( + &self, js: &mut JsonBuilder, option: &DHCPOptGeneric, + ) -> Result<(), JsonError> { js.open_array("dns_servers")?; for i in 0..(option.data.len() / 4) { let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4]); @@ -235,8 +224,10 @@ impl DHCPLogger { js.close()?; Ok(()) } - - fn log_opt_routers(&self, js: &mut JsonBuilder, option: &DHCPOptGeneric) -> Result<(), JsonError> { + + fn log_opt_routers( + &self, js: &mut JsonBuilder, option: &DHCPOptGeneric, + ) -> Result<(), JsonError> { js.open_array("routers")?; for i in 0..(option.data.len() / 4) { let val = dns_print_addr(&option.data[(i * 4)..(i * 4) + 4]); @@ -245,41 +236,38 @@ impl DHCPLogger { js.close()?; Ok(()) } - } fn format_addr_hex(input: &[u8]) -> String { - let parts: Vec = input.iter() - .map(|b| format!("{:02x}", b)) - .collect(); + let parts: Vec = input.iter().map(|b| format!("{:02x}", b)).collect(); return parts.join(":"); } #[no_mangle] -pub extern "C" fn rs_dhcp_logger_new(conf: *const c_void) -> *mut std::os::raw::c_void { +pub extern "C" fn SCDhcpLoggerNew(conf: *const c_void) -> *mut std::os::raw::c_void { let conf = ConfNode::wrap(conf); let boxed = Box::new(DHCPLogger::new(conf)); return Box::into_raw(boxed) as *mut _; } #[no_mangle] -pub unsafe extern "C" fn rs_dhcp_logger_free(logger: *mut std::os::raw::c_void) { +pub unsafe extern "C" fn SCDhcpLoggerFree(logger: *mut std::os::raw::c_void) { std::mem::drop(Box::from_raw(logger as *mut DHCPLogger)); } #[no_mangle] -pub unsafe extern "C" fn rs_dhcp_logger_log(logger: *mut std::os::raw::c_void, - tx: *mut std::os::raw::c_void, - js: &mut JsonBuilder) -> bool { +pub unsafe extern "C" fn SCDhcpLoggerLog( + logger: *mut std::os::raw::c_void, tx: *mut std::os::raw::c_void, js: &mut JsonBuilder, +) -> bool { let logger = cast_pointer!(logger, DHCPLogger); let tx = cast_pointer!(tx, DHCPTransaction); logger.log(tx, js).is_ok() } #[no_mangle] -pub unsafe extern "C" fn rs_dhcp_logger_do_log(logger: *mut std::os::raw::c_void, - tx: *mut std::os::raw::c_void) - -> bool { +pub unsafe extern "C" fn SCDhcpLoggerDoLog( + logger: *mut std::os::raw::c_void, tx: *mut std::os::raw::c_void, +) -> bool { let logger = cast_pointer!(logger, DHCPLogger); let tx = cast_pointer!(tx, DHCPTransaction); logger.do_log(tx) diff --git a/rust/src/dhcp/mod.rs b/rust/src/dhcp/mod.rs index fd783d961ff..50c99347919 100644 --- a/rust/src/dhcp/mod.rs +++ b/rust/src/dhcp/mod.rs @@ -17,7 +17,7 @@ //! DHCP parser, detection and logger module. +pub mod detect; pub mod dhcp; -pub mod parser; pub mod logger; -pub mod detect; +pub mod parser; diff --git a/rust/src/dhcp/parser.rs b/rust/src/dhcp/parser.rs index 698462f301a..c5de4fd24af 100644 --- a/rust/src/dhcp/parser.rs +++ b/rust/src/dhcp/parser.rs @@ -195,7 +195,7 @@ pub fn parse_option(i: &[u8]) -> IResult<&[u8], DHCPOption> { } } -pub fn dhcp_parse(input: &[u8]) -> IResult<&[u8], DHCPMessage> { +pub fn parse_dhcp(input: &[u8]) -> IResult<&[u8], DHCPMessage> { match parse_header(input) { Ok((rem, header)) => { let mut options = Vec::new(); @@ -242,7 +242,7 @@ mod tests { let pcap = include_bytes!("discover.pcap"); let payload = &pcap[24 + 16 + 42..]; - let (_rem, message) = dhcp_parse(payload).unwrap(); + let (_rem, message) = parse_dhcp(payload).unwrap(); let header = message.header; assert_eq!(header.opcode, BOOTP_REQUEST); assert_eq!(header.htype, 1); diff --git a/rust/src/enip/enip.rs b/rust/src/enip/enip.rs index daccd011e38..d58efde5b00 100644 --- a/rust/src/enip/enip.rs +++ b/rust/src/enip/enip.rs @@ -580,8 +580,8 @@ pub enum EnipFrameType { EnipItem, } -export_tx_data_get!(rs_enip_get_tx_data, EnipTransaction); -export_state_data_get!(SCEnipTxGetState_data, EnipState); +export_tx_data_get!(enip_get_tx_data, EnipTransaction); +export_state_data_get!(enip_tx_get_state_data, EnipState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"enip\0"; @@ -613,8 +613,8 @@ pub unsafe extern "C" fn SCEnipRegisterParsers() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_enip_get_tx_data, - get_state_data: SCEnipTxGetState_data, + get_tx_data: enip_get_tx_data, + get_state_data: enip_tx_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(EnipFrameType::ffi_id_from_name), diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index f6625fc7860..fd5cf12abd3 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -1389,8 +1389,8 @@ pub unsafe extern "C" fn SCDoH2GetDnsTx( std::ptr::null_mut() } -export_tx_data_get!(rs_http2_get_tx_data, HTTP2Transaction); -export_state_data_get!(rs_http2_get_state_data, HTTP2State); +export_tx_data_get!(http2_get_tx_data, HTTP2Transaction); +export_state_data_get!(http2_get_state_data, HTTP2State); /// C entry point for a probing parser. #[no_mangle] @@ -1564,8 +1564,8 @@ pub unsafe extern "C" fn rs_http2_register_parser() { localstorage_free: None, get_tx_files: Some(rs_http2_getfiles), get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_http2_get_tx_data, - get_state_data: rs_http2_get_state_data, + get_tx_data: http2_get_tx_data, + get_state_data: http2_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(Http2FrameType::ffi_id_from_name), diff --git a/rust/src/ike/ike.rs b/rust/src/ike/ike.rs index aed45f644d7..297b01f61c4 100644 --- a/rust/src/ike/ike.rs +++ b/rust/src/ike/ike.rs @@ -392,8 +392,8 @@ static mut ALPROTO_IKE: AppProto = ALPROTO_UNKNOWN; const PARSER_NAME: &[u8] = b"ike\0"; const PARSER_ALIAS: &[u8] = b"ikev2\0"; -export_tx_data_get!(rs_ike_get_tx_data, IKETransaction); -export_state_data_get!(rs_ike_get_state_data, IKEState); +export_tx_data_get!(ike_get_tx_data, IKETransaction); +export_state_data_get!(ike_get_state_data, IKEState); #[no_mangle] pub unsafe extern "C" fn rs_ike_register_parser() { @@ -422,8 +422,8 @@ pub unsafe extern "C" fn rs_ike_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_ike_get_tx_data, - get_state_data: rs_ike_get_state_data, + get_tx_data: ike_get_tx_data, + get_state_data: ike_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: None, diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index d2f384a81c1..9d90cdd992a 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -575,8 +575,8 @@ pub unsafe extern "C" fn rs_krb5_parse_response_tcp(_flow: *const Flow, AppLayerResult::ok() } -export_tx_data_get!(rs_krb5_get_tx_data, KRB5Transaction); -export_state_data_get!(rs_krb5_get_state_data, KRB5State); +export_tx_data_get!(krb5_get_tx_data, KRB5Transaction); +export_state_data_get!(krb5_get_state_data, KRB5State); const PARSER_NAME : &[u8] = b"krb5\0"; @@ -607,8 +607,8 @@ pub unsafe extern "C" fn rs_register_krb5_parser() { localstorage_free : None, get_tx_files : None, get_tx_iterator : Some(applayer::state_get_tx_iterator::), - get_tx_data : rs_krb5_get_tx_data, - get_state_data : rs_krb5_get_state_data, + get_tx_data : krb5_get_tx_data, + get_state_data : krb5_get_state_data, apply_tx_config : None, flags : 0, get_frame_id_by_name: None, diff --git a/rust/src/ldap/ldap.rs b/rust/src/ldap/ldap.rs index 1aa2e08bbcb..3223fc8bf9f 100644 --- a/rust/src/ldap/ldap.rs +++ b/rust/src/ldap/ldap.rs @@ -533,8 +533,7 @@ fn probe(input: &[u8], direction: Direction, rdir: *mut u8) -> AppProto { } } -#[no_mangle] -unsafe extern "C" fn SCLdapProbingParser( +unsafe extern "C" fn ldap_probing_parser( _flow: *const Flow, direction: u8, input: *const u8, input_len: u32, rdir: *mut u8, ) -> AppProto { if input_len > 1 && !input.is_null() { @@ -544,26 +543,22 @@ unsafe extern "C" fn SCLdapProbingParser( return ALPROTO_UNKNOWN; } -#[no_mangle] -extern "C" fn SCLdapStateNew(_orig_state: *mut c_void, _orig_proto: AppProto) -> *mut c_void { +extern "C" fn ldap_state_new(_orig_state: *mut c_void, _orig_proto: AppProto) -> *mut c_void { let state = LdapState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut c_void; } -#[no_mangle] -unsafe extern "C" fn SCLdapStateFree(state: *mut c_void) { +unsafe extern "C" fn ldap_state_free(state: *mut c_void) { std::mem::drop(Box::from_raw(state as *mut LdapState)); } -#[no_mangle] -unsafe extern "C" fn SCLdapStateTxFree(state: *mut c_void, tx_id: u64) { +unsafe extern "C" fn ldap_state_tx_free(state: *mut c_void, tx_id: u64) { let state = cast_pointer!(state, LdapState); state.free_tx(tx_id); } -#[no_mangle] -unsafe extern "C" fn SCLdapParseRequest( +unsafe extern "C" fn ldap_parse_request( flow: *const Flow, state: *mut c_void, pstate: *mut c_void, stream_slice: StreamSlice, _data: *const c_void, ) -> AppLayerResult { @@ -584,8 +579,7 @@ unsafe extern "C" fn SCLdapParseRequest( AppLayerResult::ok() } -#[no_mangle] -unsafe extern "C" fn SCLdapParseResponse( +unsafe extern "C" fn ldap_parse_response( flow: *const Flow, state: *mut c_void, pstate: *mut c_void, stream_slice: StreamSlice, _data: *const c_void, ) -> AppLayerResult { @@ -605,8 +599,7 @@ unsafe extern "C" fn SCLdapParseResponse( AppLayerResult::ok() } -#[no_mangle] -unsafe extern "C" fn SCLdapParseRequestUDP( +unsafe extern "C" fn ldap_parse_request_udp( flow: *const Flow, state: *mut c_void, _pstate: *mut c_void, stream_slice: StreamSlice, _data: *const c_void, ) -> AppLayerResult { @@ -614,8 +607,7 @@ unsafe extern "C" fn SCLdapParseRequestUDP( state.parse_request_udp(flow, stream_slice) } -#[no_mangle] -unsafe extern "C" fn SCLdapParseResponseUDP( +unsafe extern "C" fn ldap_parse_response_udp( flow: *const Flow, state: *mut c_void, _pstate: *mut c_void, stream_slice: StreamSlice, _data: *const c_void, ) -> AppLayerResult { @@ -623,8 +615,7 @@ unsafe extern "C" fn SCLdapParseResponseUDP( state.parse_response_udp(flow, stream_slice) } -#[no_mangle] -unsafe extern "C" fn SCLdapStateGetTx(state: *mut c_void, tx_id: u64) -> *mut c_void { +unsafe extern "C" fn ldap_state_get_tx(state: *mut c_void, tx_id: u64) -> *mut c_void { let state = cast_pointer!(state, LdapState); match state.get_tx(tx_id) { Some(tx) => { @@ -636,14 +627,12 @@ unsafe extern "C" fn SCLdapStateGetTx(state: *mut c_void, tx_id: u64) -> *mut c_ } } -#[no_mangle] -unsafe extern "C" fn SCLdapStateGetTxCount(state: *mut c_void) -> u64 { +unsafe extern "C" fn ldap_state_get_tx_count(state: *mut c_void) -> u64 { let state = cast_pointer!(state, LdapState); return state.tx_id; } -#[no_mangle] -unsafe extern "C" fn SCLdapTxGetAlstateProgress(tx: *mut c_void, _direction: u8) -> c_int { +unsafe extern "C" fn ldap_tx_get_alstate_progress(tx: *mut c_void, _direction: u8) -> c_int { let tx = cast_pointer!(tx, LdapTransaction); if tx.complete { return 1; @@ -651,8 +640,8 @@ unsafe extern "C" fn SCLdapTxGetAlstateProgress(tx: *mut c_void, _direction: u8) return 0; } -export_tx_data_get!(SCLdapGetTxData, LdapTransaction); -export_state_data_get!(SCLdapGetStateData, LdapState); +export_tx_data_get!(ldap_get_tx_data, LdapTransaction); +export_state_data_get!(ldap_get_state_data, LdapState); const PARSER_NAME: &[u8] = b"ldap\0"; @@ -663,28 +652,28 @@ pub unsafe extern "C" fn SCRegisterLdapTcpParser() { name: PARSER_NAME.as_ptr() as *const c_char, default_port: default_port.as_ptr(), ipproto: IPPROTO_TCP, - probe_ts: Some(SCLdapProbingParser), - probe_tc: Some(SCLdapProbingParser), + probe_ts: Some(ldap_probing_parser), + probe_tc: Some(ldap_probing_parser), min_depth: 0, max_depth: 16, - state_new: SCLdapStateNew, - state_free: SCLdapStateFree, - tx_free: SCLdapStateTxFree, - parse_ts: SCLdapParseRequest, - parse_tc: SCLdapParseResponse, - get_tx_count: SCLdapStateGetTxCount, - get_tx: SCLdapStateGetTx, + state_new: ldap_state_new, + state_free: ldap_state_free, + tx_free: ldap_state_tx_free, + parse_ts: ldap_parse_request, + parse_tc: ldap_parse_response, + get_tx_count: ldap_state_get_tx_count, + get_tx: ldap_state_get_tx, tx_comp_st_ts: 1, tx_comp_st_tc: 1, - tx_get_progress: SCLdapTxGetAlstateProgress, + tx_get_progress: ldap_tx_get_alstate_progress, get_eventinfo: Some(LdapEvent::get_event_info), get_eventinfo_byid: Some(LdapEvent::get_event_info_by_id), localstorage_new: None, localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: SCLdapGetTxData, - get_state_data: SCLdapGetStateData, + get_tx_data: ldap_get_tx_data, + get_state_data: ldap_get_state_data, apply_tx_config: None, flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS, get_frame_id_by_name: Some(LdapFrameType::ffi_id_from_name), @@ -720,28 +709,28 @@ pub unsafe extern "C" fn SCRegisterLdapUdpParser() { name: PARSER_NAME.as_ptr() as *const c_char, default_port: default_port.as_ptr(), ipproto: IPPROTO_UDP, - probe_ts: Some(SCLdapProbingParser), - probe_tc: Some(SCLdapProbingParser), + probe_ts: Some(ldap_probing_parser), + probe_tc: Some(ldap_probing_parser), min_depth: 0, max_depth: 16, - state_new: SCLdapStateNew, - state_free: SCLdapStateFree, - tx_free: SCLdapStateTxFree, - parse_ts: SCLdapParseRequestUDP, - parse_tc: SCLdapParseResponseUDP, - get_tx_count: SCLdapStateGetTxCount, - get_tx: SCLdapStateGetTx, + state_new: ldap_state_new, + state_free: ldap_state_free, + tx_free: ldap_state_tx_free, + parse_ts: ldap_parse_request_udp, + parse_tc: ldap_parse_response_udp, + get_tx_count: ldap_state_get_tx_count, + get_tx: ldap_state_get_tx, tx_comp_st_ts: 1, tx_comp_st_tc: 1, - tx_get_progress: SCLdapTxGetAlstateProgress, + tx_get_progress: ldap_tx_get_alstate_progress, get_eventinfo: Some(LdapEvent::get_event_info), get_eventinfo_byid: Some(LdapEvent::get_event_info_by_id), localstorage_new: None, localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: SCLdapGetTxData, - get_state_data: SCLdapGetStateData, + get_tx_data: ldap_get_tx_data, + get_state_data: ldap_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(LdapFrameType::ffi_id_from_name), diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index d280664604e..697d2ef266c 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -761,8 +761,8 @@ pub unsafe extern "C" fn rs_mqtt_tx_set_logged( // Parser name as a C style string. const PARSER_NAME: &[u8] = b"mqtt\0"; -export_tx_data_get!(rs_mqtt_get_tx_data, MQTTTransaction); -export_state_data_get!(rs_mqtt_get_state_data, MQTTState); +export_tx_data_get!(mqtt_get_tx_data, MQTTTransaction); +export_state_data_get!(mqtt_get_state_data, MQTTState); #[no_mangle] pub unsafe extern "C" fn SCMqttRegisterParser() { @@ -791,8 +791,8 @@ pub unsafe extern "C" fn SCMqttRegisterParser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(crate::applayer::state_get_tx_iterator::), - get_tx_data: rs_mqtt_get_tx_data, - get_state_data: rs_mqtt_get_state_data, + get_tx_data: mqtt_get_tx_data, + get_state_data: mqtt_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(MQTTFrameType::ffi_id_from_name), diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index a899210214a..576e1b6fc80 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -19,9 +19,9 @@ extern crate ntp_parser; use self::ntp_parser::*; -use crate::core; -use crate::core::{AppProto,ALPROTO_UNKNOWN,ALPROTO_FAILED}; use crate::applayer::{self, *}; +use crate::core; +use crate::core::{AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN}; use crate::direction::Direction; use crate::flow::Flow; use std; @@ -31,7 +31,7 @@ use nom7::Err; #[derive(AppLayerEvent)] pub enum NTPEvent { - UnsolicitedResponse , + UnsolicitedResponse, MalformedData, NotRequest, NotResponse, @@ -90,7 +90,7 @@ impl NTPState { /// Returns 0 if successful, or -1 on error fn parse(&mut self, i: &[u8], direction: Direction) -> i32 { match parse_ntp(i) { - Ok((_,ref msg)) => { + Ok((_, ref msg)) => { // SCLogDebug!("parse_ntp: {:?}",msg); let (mode, ref_id) = match msg { NtpPacket::V3(pkt) => (pkt.mode, pkt.ref_id), @@ -103,17 +103,17 @@ impl NTPState { self.transactions.push(tx); } 0 - }, + } Err(Err::Incomplete(_)) => { SCLogDebug!("Insufficient data while parsing NTP data"); self.set_event(NTPEvent::MalformedData); -1 - }, + } Err(_) => { SCLogDebug!("Error while parsing NTP data"); self.set_event(NTPEvent::MalformedData); -1 - }, + } } } @@ -160,8 +160,9 @@ impl NTPTransaction { } /// Returns *mut NTPState -#[no_mangle] -pub extern "C" fn rs_ntp_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { +extern "C" fn ntp_state_new( + _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto, +) -> *mut std::os::raw::c_void { let state = NTPState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; @@ -169,139 +170,119 @@ pub extern "C" fn rs_ntp_state_new(_orig_state: *mut std::os::raw::c_void, _orig /// Params: /// - state: *mut NTPState as void pointer -#[no_mangle] -pub extern "C" fn rs_ntp_state_free(state: *mut std::os::raw::c_void) { - let mut ntp_state = unsafe{ Box::from_raw(state as *mut NTPState) }; +extern "C" fn ntp_state_free(state: *mut std::os::raw::c_void) { + let mut ntp_state = unsafe { Box::from_raw(state as *mut NTPState) }; ntp_state.free(); } -#[no_mangle] -pub unsafe extern "C" fn rs_ntp_parse_request(_flow: *const Flow, - state: *mut std::os::raw::c_void, - _pstate: *mut std::os::raw::c_void, - stream_slice: StreamSlice, - _data: *const std::os::raw::c_void, - ) -> AppLayerResult { - let state = cast_pointer!(state,NTPState); +unsafe extern "C" fn ntp_parse_request( + _flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void, + stream_slice: StreamSlice, _data: *const std::os::raw::c_void, +) -> AppLayerResult { + let state = cast_pointer!(state, NTPState); if state.parse(stream_slice.as_slice(), Direction::ToServer) < 0 { return AppLayerResult::err(); } AppLayerResult::ok() } -#[no_mangle] -pub unsafe extern "C" fn rs_ntp_parse_response(_flow: *const Flow, - state: *mut std::os::raw::c_void, - _pstate: *mut std::os::raw::c_void, - stream_slice: StreamSlice, - _data: *const std::os::raw::c_void, - ) -> AppLayerResult { - let state = cast_pointer!(state,NTPState); +unsafe extern "C" fn ntp_parse_response( + _flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void, + stream_slice: StreamSlice, _data: *const std::os::raw::c_void, +) -> AppLayerResult { + let state = cast_pointer!(state, NTPState); if state.parse(stream_slice.as_slice(), Direction::ToClient) < 0 { return AppLayerResult::err(); } AppLayerResult::ok() } -#[no_mangle] -pub unsafe extern "C" fn rs_ntp_state_get_tx(state: *mut std::os::raw::c_void, - tx_id: u64) - -> *mut std::os::raw::c_void -{ - let state = cast_pointer!(state,NTPState); +unsafe extern "C" fn ntp_state_get_tx( + state: *mut std::os::raw::c_void, tx_id: u64, +) -> *mut std::os::raw::c_void { + let state = cast_pointer!(state, NTPState); match state.get_tx_by_id(tx_id) { Some(tx) => tx as *const _ as *mut _, - None => std::ptr::null_mut(), + None => std::ptr::null_mut(), } } -#[no_mangle] -pub unsafe extern "C" fn rs_ntp_state_get_tx_count(state: *mut std::os::raw::c_void) - -> u64 -{ - let state = cast_pointer!(state,NTPState); +unsafe extern "C" fn ntp_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { + let state = cast_pointer!(state, NTPState); state.tx_id } -#[no_mangle] -pub unsafe extern "C" fn rs_ntp_state_tx_free(state: *mut std::os::raw::c_void, - tx_id: u64) -{ - let state = cast_pointer!(state,NTPState); +unsafe extern "C" fn ntp_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { + let state = cast_pointer!(state, NTPState); state.free_tx(tx_id); } -#[no_mangle] -pub extern "C" fn rs_ntp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void, - _direction: u8) - -> std::os::raw::c_int -{ +extern "C" fn ntp_tx_get_alstate_progress( + _tx: *mut std::os::raw::c_void, _direction: u8, +) -> std::os::raw::c_int { 1 } -static mut ALPROTO_NTP : AppProto = ALPROTO_UNKNOWN; +static mut ALPROTO_NTP: AppProto = ALPROTO_UNKNOWN; -#[no_mangle] -pub extern "C" fn ntp_probing_parser(_flow: *const Flow, - _direction: u8, - input:*const u8, input_len: u32, - _rdir: *mut u8) -> AppProto -{ +extern "C" fn ntp_probing_parser( + _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, +) -> AppProto { if input.is_null() { return ALPROTO_UNKNOWN; } let slice: &[u8] = unsafe { std::slice::from_raw_parts(input as *mut u8, input_len as usize) }; - let alproto = unsafe{ ALPROTO_NTP }; + let alproto = unsafe { ALPROTO_NTP }; match parse_ntp(slice) { Ok((_, _)) => { // parse_ntp already checks for supported version (3 or 4) return alproto; - }, + } Err(Err::Incomplete(_)) => { return ALPROTO_UNKNOWN; - }, + } Err(_) => { return ALPROTO_FAILED; - }, + } } } -export_tx_data_get!(rs_ntp_get_tx_data, NTPTransaction); -export_state_data_get!(rs_ntp_get_state_data, NTPState); +export_tx_data_get!(ntp_get_tx_data, NTPTransaction); +export_state_data_get!(ntp_get_state_data, NTPState); -const PARSER_NAME : &[u8] = b"ntp\0"; +const PARSER_NAME: &[u8] = b"ntp\0"; #[no_mangle] pub unsafe extern "C" fn rs_register_ntp_parser() { let default_port = CString::new("123").unwrap(); let parser = RustParser { - name : PARSER_NAME.as_ptr() as *const std::os::raw::c_char, - default_port : default_port.as_ptr(), - ipproto : core::IPPROTO_UDP, - probe_ts : Some(ntp_probing_parser), - probe_tc : Some(ntp_probing_parser), - min_depth : 0, - max_depth : 16, - state_new : rs_ntp_state_new, - state_free : rs_ntp_state_free, - tx_free : rs_ntp_state_tx_free, - parse_ts : rs_ntp_parse_request, - parse_tc : rs_ntp_parse_response, - get_tx_count : rs_ntp_state_get_tx_count, - get_tx : rs_ntp_state_get_tx, - tx_comp_st_ts : 1, - tx_comp_st_tc : 1, - tx_get_progress : rs_ntp_tx_get_alstate_progress, - get_eventinfo : Some(NTPEvent::get_event_info), - get_eventinfo_byid : Some(NTPEvent::get_event_info_by_id), - localstorage_new : None, - localstorage_free : None, - get_tx_files : None, - get_tx_iterator : Some(applayer::state_get_tx_iterator::), - get_tx_data : rs_ntp_get_tx_data, - get_state_data : rs_ntp_get_state_data, - apply_tx_config : None, - flags : 0, + name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, + default_port: default_port.as_ptr(), + ipproto: core::IPPROTO_UDP, + probe_ts: Some(ntp_probing_parser), + probe_tc: Some(ntp_probing_parser), + min_depth: 0, + max_depth: 16, + state_new: ntp_state_new, + state_free: ntp_state_free, + tx_free: ntp_state_tx_free, + parse_ts: ntp_parse_request, + parse_tc: ntp_parse_response, + get_tx_count: ntp_state_get_tx_count, + get_tx: ntp_state_get_tx, + tx_comp_st_ts: 1, + tx_comp_st_tc: 1, + tx_get_progress: ntp_tx_get_alstate_progress, + get_eventinfo: Some(NTPEvent::get_event_info), + get_eventinfo_byid: Some(NTPEvent::get_event_info_by_id), + localstorage_new: None, + localstorage_free: None, + get_tx_files: None, + get_tx_iterator: Some(applayer::state_get_tx_iterator::), + get_tx_data: ntp_get_tx_data, + get_state_data: ntp_get_state_data, + apply_tx_config: None, + flags: 0, get_frame_id_by_name: None, get_frame_name_by_id: None, }; @@ -319,7 +300,6 @@ pub unsafe extern "C" fn rs_register_ntp_parser() { } } - #[cfg(test)] mod tests { use super::*; @@ -327,13 +307,11 @@ mod tests { #[test] fn test_ntp_parse_request_valid() { // A UDP NTP v4 request, in client mode - const REQ : &[u8] = &[ - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x57, 0xab, 0xc3, 0x4a, 0x5f, 0x2c, 0xfe + const REQ: &[u8] = &[ + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x57, + 0xab, 0xc3, 0x4a, 0x5f, 0x2c, 0xfe, ]; let mut state = NTPState::new(); diff --git a/rust/src/pgsql/pgsql.rs b/rust/src/pgsql/pgsql.rs index 56eaba56335..4054eac0c3c 100644 --- a/rust/src/pgsql/pgsql.rs +++ b/rust/src/pgsql/pgsql.rs @@ -623,8 +623,7 @@ fn pgsql_tx_get_res_state(tx: *mut std::os::raw::c_void) -> PgsqlTxProgress { // C exports. /// C entry point for a probing parser. -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlProbingParserTS( +unsafe extern "C" fn probing_parser_ts( _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, ) -> AppProto { if input_len >= 1 && !input.is_null() { @@ -649,8 +648,7 @@ pub unsafe extern "C" fn SCPgsqlProbingParserTS( } /// C entry point for a probing parser. -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlProbingParserTC( +unsafe extern "C" fn probing_parser_tc( _flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8, ) -> AppProto { if input_len >= 1 && !input.is_null() { @@ -678,8 +676,7 @@ pub unsafe extern "C" fn SCPgsqlProbingParserTC( return ALPROTO_UNKNOWN; } -#[no_mangle] -pub extern "C" fn SCPgsqlStateNew( +extern "C" fn state_new( _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto, ) -> *mut std::os::raw::c_void { let state = PgsqlState::new(); @@ -687,23 +684,17 @@ pub extern "C" fn SCPgsqlStateNew( return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub extern "C" fn SCPgsqlStateFree(state: *mut std::os::raw::c_void) { +extern "C" fn state_free(state: *mut std::os::raw::c_void) { // Just unbox... std::mem::drop(unsafe { Box::from_raw(state as *mut PgsqlState) }); } -#[no_mangle] -pub extern "C" fn SCPgsqlStateTxFree(state: *mut std::os::raw::c_void, tx_id: u64) { - let state_safe: &mut PgsqlState; - unsafe { - state_safe = cast_pointer!(state, PgsqlState); - } +unsafe extern "C" fn state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) { + let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState); state_safe.free_tx(tx_id); } -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlParseRequest( +unsafe extern "C" fn parse_request( flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void, stream_slice: StreamSlice, _data: *const std::os::raw::c_void, ) -> AppLayerResult { @@ -726,8 +717,7 @@ pub unsafe extern "C" fn SCPgsqlParseRequest( AppLayerResult::ok() } -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlParseResponse( +unsafe extern "C" fn parse_response( flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void, stream_slice: StreamSlice, _data: *const std::os::raw::c_void, ) -> AppLayerResult { @@ -749,8 +739,7 @@ pub unsafe extern "C" fn SCPgsqlParseResponse( AppLayerResult::ok() } -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlStateGetTx( +unsafe extern "C" fn state_get_tx( state: *mut std::os::raw::c_void, tx_id: u64, ) -> *mut std::os::raw::c_void { let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState); @@ -764,17 +753,12 @@ pub unsafe extern "C" fn SCPgsqlStateGetTx( } } -#[no_mangle] -pub extern "C" fn SCPgsqlStateGetTxCount(state: *mut std::os::raw::c_void) -> u64 { - let state_safe: &mut PgsqlState; - unsafe { - state_safe = cast_pointer!(state, PgsqlState); - } +unsafe extern "C" fn state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 { + let state_safe: &mut PgsqlState = cast_pointer!(state, PgsqlState); return state_safe.tx_id; } -#[no_mangle] -pub unsafe extern "C" fn SCPgsqlTxGetALStateProgress( +unsafe extern "C" fn tx_get_al_state_progress( tx: *mut std::os::raw::c_void, direction: u8, ) -> std::os::raw::c_int { if direction == Direction::ToServer as u8 { @@ -785,8 +769,8 @@ pub unsafe extern "C" fn SCPgsqlTxGetALStateProgress( pgsql_tx_get_res_state(tx) as i32 } -export_tx_data_get!(rs_pgsql_get_tx_data, PgsqlTransaction); -export_state_data_get!(rs_pgsql_get_state_data, PgsqlState); +export_tx_data_get!(pgsql_get_tx_data, PgsqlTransaction); +export_state_data_get!(pgsql_get_state_data, PgsqlState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"pgsql\0"; @@ -799,20 +783,20 @@ pub unsafe extern "C" fn SCRegisterPgsqlParser() { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: default_port.as_ptr(), ipproto: IPPROTO_TCP, - probe_ts: Some(SCPgsqlProbingParserTS), - probe_tc: Some(SCPgsqlProbingParserTC), + probe_ts: Some(probing_parser_ts), + probe_tc: Some(probing_parser_tc), min_depth: 0, max_depth: 16, - state_new: SCPgsqlStateNew, - state_free: SCPgsqlStateFree, - tx_free: SCPgsqlStateTxFree, - parse_ts: SCPgsqlParseRequest, - parse_tc: SCPgsqlParseResponse, - get_tx_count: SCPgsqlStateGetTxCount, - get_tx: SCPgsqlStateGetTx, + state_new, + state_free, + tx_free: state_tx_free, + parse_ts: parse_request, + parse_tc: parse_response, + get_tx_count: state_get_tx_count, + get_tx: state_get_tx, tx_comp_st_ts: PgsqlTxProgress::TxDone as i32, tx_comp_st_tc: PgsqlTxProgress::TxDone as i32, - tx_get_progress: SCPgsqlTxGetALStateProgress, + tx_get_progress: tx_get_al_state_progress, get_eventinfo: None, get_eventinfo_byid: None, localstorage_new: None, @@ -821,8 +805,8 @@ pub unsafe extern "C" fn SCRegisterPgsqlParser() { get_tx_iterator: Some( crate::applayer::state_get_tx_iterator::, ), - get_tx_data: rs_pgsql_get_tx_data, - get_state_data: rs_pgsql_get_state_data, + get_tx_data: pgsql_get_tx_data, + get_state_data: pgsql_get_state_data, apply_tx_config: None, flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS, get_frame_id_by_name: None, diff --git a/rust/src/quic/quic.rs b/rust/src/quic/quic.rs index 3b0e1f65f30..442cfc944a6 100644 --- a/rust/src/quic/quic.rs +++ b/rust/src/quic/quic.rs @@ -471,8 +471,8 @@ pub unsafe extern "C" fn rs_quic_state_get_tx_iterator( } } -export_tx_data_get!(rs_quic_get_tx_data, QuicTransaction); -export_state_data_get!(rs_quic_get_state_data, QuicState); +export_tx_data_get!(quic_get_tx_data, QuicTransaction); +export_state_data_get!(quic_get_state_data, QuicState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"quic\0"; @@ -504,8 +504,8 @@ pub unsafe extern "C" fn rs_quic_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(rs_quic_state_get_tx_iterator), - get_tx_data: rs_quic_get_tx_data, - get_state_data: rs_quic_get_state_data, + get_tx_data: quic_get_tx_data, + get_state_data: quic_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: None, diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index 732f246c09b..b5684aa248a 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -454,8 +454,8 @@ pub unsafe extern "C" fn rs_rdp_parse_tc( return state.parse_tc(buf); } -export_tx_data_get!(rs_rdp_get_tx_data, RdpTransaction); -export_state_data_get!(rs_rdp_get_state_data, RdpState); +export_tx_data_get!(rdp_get_tx_data, RdpTransaction); +export_state_data_get!(rdp_get_state_data, RdpState); // // registration @@ -490,8 +490,8 @@ pub unsafe extern "C" fn rs_rdp_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_rdp_get_tx_data, - get_state_data: rs_rdp_get_state_data, + get_tx_data: rdp_get_tx_data, + get_state_data: rdp_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: None, diff --git a/rust/src/rfb/rfb.rs b/rust/src/rfb/rfb.rs index 5c2132dc782..6901c973dd7 100644 --- a/rust/src/rfb/rfb.rs +++ b/rust/src/rfb/rfb.rs @@ -836,8 +836,8 @@ pub unsafe extern "C" fn rs_rfb_tx_get_alstate_progress( // Parser name as a C style string. const PARSER_NAME: &[u8] = b"rfb\0"; -export_tx_data_get!(rs_rfb_get_tx_data, RFBTransaction); -export_state_data_get!(rs_rfb_get_state_data, RFBState); +export_tx_data_get!(rfb_get_tx_data, RFBTransaction); +export_state_data_get!(rfb_get_state_data, RFBState); #[no_mangle] pub unsafe extern "C" fn SCRfbRegisterParser() { @@ -865,8 +865,8 @@ pub unsafe extern "C" fn SCRfbRegisterParser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_rfb_get_tx_data, - get_state_data: rs_rfb_get_state_data, + get_tx_data: rfb_get_tx_data, + get_state_data: rfb_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(RFBFrameType::ffi_id_from_name), diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index 54274656739..1743953f1f3 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -546,8 +546,8 @@ fn register_pattern_probe(proto: u8) -> i8 { } } -export_tx_data_get!(rs_sip_get_tx_data, SIPTransaction); -export_state_data_get!(rs_sip_get_state_data, SIPState); +export_tx_data_get!(sip_get_tx_data, SIPTransaction); +export_state_data_get!(sip_get_state_data, SIPState); const PARSER_NAME: &[u8] = b"sip\0"; @@ -577,8 +577,8 @@ pub unsafe extern "C" fn rs_sip_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_sip_get_tx_data, - get_state_data: rs_sip_get_state_data, + get_tx_data: sip_get_tx_data, + get_state_data: sip_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(SIPFrameType::ffi_id_from_name), diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 64846eaf307..a30e182aefb 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -372,8 +372,8 @@ pub unsafe extern "C" fn rs_snmp_probing_parser(_flow: *const Flow, } } -export_tx_data_get!(rs_snmp_get_tx_data, SNMPTransaction); -export_state_data_get!(rs_snmp_get_state_data, SNMPState); +export_tx_data_get!(snmp_get_tx_data, SNMPTransaction); +export_state_data_get!(snmp_get_state_data, SNMPState); const PARSER_NAME : &[u8] = b"snmp\0"; @@ -404,8 +404,8 @@ pub unsafe extern "C" fn rs_register_snmp_parser() { localstorage_free : None, get_tx_files : None, get_tx_iterator : Some(applayer::state_get_tx_iterator::), - get_tx_data : rs_snmp_get_tx_data, - get_state_data : rs_snmp_get_state_data, + get_tx_data : snmp_get_tx_data, + get_state_data : snmp_get_state_data, apply_tx_config : None, flags : 0, get_frame_id_by_name: None, diff --git a/rust/src/ssh/detect.rs b/rust/src/ssh/detect.rs index a8ba19ffa83..aa8d0f56f18 100644 --- a/rust/src/ssh/detect.rs +++ b/rust/src/ssh/detect.rs @@ -20,7 +20,7 @@ use crate::direction::Direction; use std::ptr; #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_protocol( +pub unsafe extern "C" fn SCSshTxGetProtocol( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); @@ -49,7 +49,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_protocol( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_software( +pub unsafe extern "C" fn SCSshTxGetSoftware( tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); @@ -78,11 +78,8 @@ pub unsafe extern "C" fn rs_ssh_tx_get_software( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_hassh( - tx: *mut std::os::raw::c_void, - buffer: *mut *const u8, - buffer_len: *mut u32, - direction: u8, +pub unsafe extern "C" fn SCSshTxGetHassh( + tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); match direction.into() { @@ -110,11 +107,8 @@ pub unsafe extern "C" fn rs_ssh_tx_get_hassh( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_hassh_string( - tx: *mut std::os::raw::c_void, - buffer: *mut *const u8, - buffer_len: *mut u32, - direction: u8, +pub unsafe extern "C" fn SCSshTxGetHasshString( + tx: *mut std::os::raw::c_void, buffer: *mut *const u8, buffer_len: *mut u32, direction: u8, ) -> u8 { let tx = cast_pointer!(tx, SSHTransaction); match direction.into() { diff --git a/rust/src/ssh/logger.rs b/rust/src/ssh/logger.rs index bee6693c898..138ba0c4949 100644 --- a/rust/src/ssh/logger.rs +++ b/rust/src/ssh/logger.rs @@ -25,9 +25,17 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result } if !tx.cli_hdr.protover.is_empty() { js.open_object("client")?; - js.set_string_from_bytes_limited("proto_version", &tx.cli_hdr.protover, SSH_MAX_BANNER_LEN)?; + js.set_string_from_bytes_limited( + "proto_version", + &tx.cli_hdr.protover, + SSH_MAX_BANNER_LEN, + )?; if !tx.cli_hdr.swver.is_empty() { - js.set_string_from_bytes_limited("software_version", &tx.cli_hdr.swver, SSH_MAX_BANNER_LEN)?; + js.set_string_from_bytes_limited( + "software_version", + &tx.cli_hdr.swver, + SSH_MAX_BANNER_LEN, + )?; } if !tx.cli_hdr.hassh.is_empty() || !tx.cli_hdr.hassh_string.is_empty() { js.open_object("hassh")?; @@ -43,9 +51,17 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result } if !tx.srv_hdr.protover.is_empty() { js.open_object("server")?; - js.set_string_from_bytes_limited("proto_version", &tx.srv_hdr.protover, SSH_MAX_BANNER_LEN)?; + js.set_string_from_bytes_limited( + "proto_version", + &tx.srv_hdr.protover, + SSH_MAX_BANNER_LEN, + )?; if !tx.srv_hdr.swver.is_empty() { - js.set_string_from_bytes_limited("software_version", &tx.srv_hdr.swver, SSH_MAX_BANNER_LEN)?; + js.set_string_from_bytes_limited( + "software_version", + &tx.srv_hdr.swver, + SSH_MAX_BANNER_LEN, + )?; } if !tx.srv_hdr.hassh.is_empty() || !tx.srv_hdr.hassh_string.is_empty() { js.open_object("hassh")?; @@ -64,7 +80,7 @@ fn log_ssh(tx: &SSHTransaction, js: &mut JsonBuilder) -> Result } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_log_json(tx: *mut std::os::raw::c_void, js: &mut JsonBuilder) -> bool { +pub unsafe extern "C" fn SCSshLogJson(tx: *mut std::os::raw::c_void, js: &mut JsonBuilder) -> bool { let tx = cast_pointer!(tx, SSHTransaction); if let Ok(x) = log_ssh(tx, js) { return x; diff --git a/rust/src/ssh/parser.rs b/rust/src/ssh/parser.rs index f3403cf25df..90d6ad3229e 100644 --- a/rust/src/ssh/parser.rs +++ b/rust/src/ssh/parser.rs @@ -30,18 +30,18 @@ use std::fmt; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum MessageCode { - Disconnect, - Ignore, - Unimplemented, - Debug, - ServiceRequest, - ServiceAccept, - Kexinit, - NewKeys, - KexdhInit, - KexdhReply, - - Undefined(u8), + Disconnect, + Ignore, + Unimplemented, + Debug, + ServiceRequest, + ServiceAccept, + Kexinit, + NewKeys, + KexdhInit, + KexdhReply, + + Undefined(u8), } impl MessageCode { @@ -79,9 +79,8 @@ pub fn ssh_parse_line(i: &[u8]) -> IResult<&[u8], &[u8]> { } terminated( take_while(is_not_lineend), - alt(( tag("\n"), tag("\r\n"), parser - )) - )(i) + alt((tag("\n"), tag("\r\n"), parser)), + )(i) } #[derive(PartialEq, Eq)] @@ -340,100 +339,111 @@ mod tests { } #[test] fn test_parse_key_exchange() { - let client_key_exchange = [0x18 ,0x70 ,0xCB ,0xA4 ,0xA3 ,0xD4 ,0xDC ,0x88 ,0x6F - ,0xFD ,0x76 ,0x06 ,0xCF ,0x36 ,0x1B ,0xC6 ,0x00 ,0x00 ,0x01 ,0x0D ,0x63 ,0x75 ,0x72 ,0x76 - ,0x65 ,0x32 ,0x35 ,0x35 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,0x00 ,0x00 ,0x00 ,0x00]; - let cookie = [0x18, 0x70, 0xcb, 0xa4, 0xa3, 0xd4, 0xdc, 0x88, 0x6f, 0xfd, 0x76, 0x06, 0xcf, 0x36, 0x1b, 0xc6]; + let client_key_exchange = [ + 0x18, 0x70, 0xCB, 0xA4, 0xA3, 0xD4, 0xDC, 0x88, 0x6F, 0xFD, 0x76, 0x06, 0xCF, 0x36, + 0x1B, 0xC6, 0x00, 0x00, 0x01, 0x0D, 0x63, 0x75, 0x72, 0x76, 0x65, 0x32, 0x35, 0x35, + 0x31, 0x39, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x63, 0x75, 0x72, 0x76, + 0x65, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, + 0x6C, 0x69, 0x62, 0x73, 0x73, 0x68, 0x2E, 0x6F, 0x72, 0x67, 0x2C, 0x65, 0x63, 0x64, + 0x68, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, + 0x36, 0x2C, 0x65, 0x63, 0x64, 0x68, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, + 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2C, 0x65, 0x63, 0x64, 0x68, 0x2D, 0x73, 0x68, + 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2C, 0x64, 0x69, + 0x66, 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, + 0x72, 0x6F, 0x75, 0x70, 0x2D, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x2D, + 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2D, + 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, 0x6F, 0x75, 0x70, 0x31, + 0x36, 0x2D, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2C, 0x64, 0x69, 0x66, 0x66, 0x69, + 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, 0x6F, 0x75, + 0x70, 0x31, 0x38, 0x2D, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2C, 0x64, 0x69, 0x66, + 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, + 0x6F, 0x75, 0x70, 0x31, 0x34, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x64, + 0x69, 0x66, 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, + 0x67, 0x72, 0x6F, 0x75, 0x70, 0x31, 0x34, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x2C, 0x65, + 0x78, 0x74, 0x2D, 0x69, 0x6E, 0x66, 0x6F, 0x2D, 0x63, 0x00, 0x00, 0x01, 0x66, 0x65, + 0x63, 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, + 0x70, 0x32, 0x35, 0x36, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, + 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, + 0x33, 0x38, 0x34, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, 0x64, + 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, + 0x32, 0x31, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, + 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, 0x64, 0x73, + 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, + 0x36, 0x2C, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, + 0x69, 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2C, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2D, + 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2C, + 0x73, 0x73, 0x68, 0x2D, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2D, 0x63, 0x65, + 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, + 0x35, 0x31, 0x32, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x72, 0x73, 0x61, + 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2D, 0x63, 0x65, 0x72, 0x74, + 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, + 0x6F, 0x6D, 0x2C, 0x73, 0x73, 0x68, 0x2D, 0x72, 0x73, 0x61, 0x2D, 0x63, 0x65, 0x72, + 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x2C, 0x73, 0x73, 0x68, 0x2D, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, + 0x39, 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, + 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2C, + 0x73, 0x73, 0x68, 0x2D, 0x72, 0x73, 0x61, 0x00, 0x00, 0x00, 0x6C, 0x63, 0x68, 0x61, + 0x63, 0x68, 0x61, 0x32, 0x30, 0x2D, 0x70, 0x6F, 0x6C, 0x79, 0x31, 0x33, 0x30, 0x35, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, + 0x39, 0x32, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, + 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x67, 0x63, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, 0x67, 0x63, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0x6C, 0x63, 0x68, 0x61, + 0x63, 0x68, 0x61, 0x32, 0x30, 0x2D, 0x70, 0x6F, 0x6C, 0x79, 0x31, 0x33, 0x30, 0x35, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, + 0x39, 0x32, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, + 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x67, 0x63, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, 0x67, 0x63, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0xD5, 0x75, 0x6D, 0x61, + 0x63, 0x2D, 0x36, 0x34, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, + 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, + 0x38, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, + 0x32, 0x35, 0x36, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, + 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, + 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, + 0x68, 0x61, 0x31, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, + 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, + 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, + 0x2D, 0x32, 0x35, 0x36, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, + 0x2D, 0x35, 0x31, 0x32, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, + 0x00, 0x00, 0x00, 0xD5, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x2D, 0x65, 0x74, + 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, + 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, + 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2D, 0x65, 0x74, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, + 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2D, 0x65, + 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, + 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x2D, 0x65, 0x74, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, + 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x1A, 0x6E, 0x6F, 0x6E, + 0x65, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x00, 0x00, 0x00, 0x1A, 0x6E, + 0x6F, 0x6E, 0x65, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, + 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + let cookie = [ + 0x18, 0x70, 0xcb, 0xa4, 0xa3, 0xd4, 0xdc, 0x88, 0x6f, 0xfd, 0x76, 0x06, 0xcf, 0x36, + 0x1b, 0xc6, + ]; let key_exchange = SshPacketKeyExchange { cookie: &cookie, kex_algs: b"curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c", @@ -457,102 +467,110 @@ mod tests { #[test] fn test_parse_hassh() { - let client_key_exchange = [0x18 ,0x70 ,0xCB ,0xA4 ,0xA3 ,0xD4 ,0xDC ,0x88 ,0x6F - ,0xFD ,0x76 ,0x06 ,0xCF ,0x36 ,0x1B ,0xC6 ,0x00 ,0x00 ,0x01 ,0x0D ,0x63 ,0x75 ,0x72 ,0x76 - ,0x65 ,0x32 ,0x35 ,0x35 ,0x31 ,0x39 ,0x2D ,0x73 ,0x68 ,0x61 ,0x32 ,0x35 ,0x36 ,0x2C ,0x63 - ,0x75 ,0x72 ,0x76 ,0x65 ,0x32 ,0x35 ,0x35 ,0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 + 0x18, 0x70, 0xCB, 0xA4, 0xA3, 0xD4, 0xDC, 0x88, 0x6F, 0xFD, 0x76, 0x06, 0xCF, 0x36, + 0x1B, 0xC6, 0x00, 0x00, 0x01, 0x0D, 0x63, 0x75, 0x72, 0x76, 0x65, 0x32, 0x35, 0x35, + 0x31, 0x39, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x63, 0x75, 0x72, 0x76, + 0x65, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, + 0x6C, 0x69, 0x62, 0x73, 0x73, 0x68, 0x2E, 0x6F, 0x72, 0x67, 0x2C, 0x65, 0x63, 0x64, + 0x68, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, + 0x36, 0x2C, 0x65, 0x63, 0x64, 0x68, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, + 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2C, 0x65, 0x63, 0x64, 0x68, 0x2D, 0x73, 0x68, + 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2C, 0x64, 0x69, + 0x66, 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, + 0x72, 0x6F, 0x75, 0x70, 0x2D, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x2D, + 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2D, + 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, 0x6F, 0x75, 0x70, 0x31, + 0x36, 0x2D, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2C, 0x64, 0x69, 0x66, 0x66, 0x69, + 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, 0x6F, 0x75, + 0x70, 0x31, 0x38, 0x2D, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2C, 0x64, 0x69, 0x66, + 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, 0x67, 0x72, + 0x6F, 0x75, 0x70, 0x31, 0x34, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2C, 0x64, + 0x69, 0x66, 0x66, 0x69, 0x65, 0x2D, 0x68, 0x65, 0x6C, 0x6C, 0x6D, 0x61, 0x6E, 0x2D, + 0x67, 0x72, 0x6F, 0x75, 0x70, 0x31, 0x34, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x2C, 0x65, + 0x78, 0x74, 0x2D, 0x69, 0x6E, 0x66, 0x6F, 0x2D, 0x63, 0x00, 0x00, 0x01, 0x66, 0x65, + 0x63, 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, + 0x70, 0x32, 0x35, 0x36, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, + 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, + 0x33, 0x38, 0x34, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, 0x64, + 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, + 0x32, 0x31, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, + 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x65, 0x63, 0x64, 0x73, + 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, + 0x36, 0x2C, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, + 0x69, 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2C, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2D, + 0x73, 0x68, 0x61, 0x32, 0x2D, 0x6E, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2C, + 0x73, 0x73, 0x68, 0x2D, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2D, 0x63, 0x65, + 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, + 0x35, 0x31, 0x32, 0x2D, 0x63, 0x65, 0x72, 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x72, 0x73, 0x61, + 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2D, 0x63, 0x65, 0x72, 0x74, + 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, + 0x6F, 0x6D, 0x2C, 0x73, 0x73, 0x68, 0x2D, 0x72, 0x73, 0x61, 0x2D, 0x63, 0x65, 0x72, + 0x74, 0x2D, 0x76, 0x30, 0x31, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x2C, 0x73, 0x73, 0x68, 0x2D, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, + 0x39, 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, + 0x2C, 0x72, 0x73, 0x61, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2C, + 0x73, 0x73, 0x68, 0x2D, 0x72, 0x73, 0x61, 0x00, 0x00, 0x00, 0x6C, 0x63, 0x68, 0x61, + 0x63, 0x68, 0x61, 0x32, 0x30, 0x2D, 0x70, 0x6F, 0x6C, 0x79, 0x31, 0x33, 0x30, 0x35, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, + 0x39, 0x32, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, + 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x67, 0x63, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, 0x67, 0x63, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0x6C, 0x63, 0x68, 0x61, + 0x63, 0x68, 0x61, 0x32, 0x30, 0x2D, 0x70, 0x6F, 0x6C, 0x79, 0x31, 0x33, 0x30, 0x35, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, + 0x39, 0x32, 0x2D, 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, + 0x63, 0x74, 0x72, 0x2C, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2D, 0x67, 0x63, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x61, + 0x65, 0x73, 0x32, 0x35, 0x36, 0x2D, 0x67, 0x63, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0xD5, 0x75, 0x6D, 0x61, + 0x63, 0x2D, 0x36, 0x34, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, + 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, + 0x38, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, + 0x32, 0x35, 0x36, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, + 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, + 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, + 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, + 0x68, 0x61, 0x31, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, + 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, + 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, + 0x2D, 0x32, 0x35, 0x36, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, + 0x2D, 0x35, 0x31, 0x32, 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, + 0x00, 0x00, 0x00, 0xD5, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x2D, 0x65, 0x74, + 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, + 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x2D, 0x65, 0x74, 0x6D, 0x40, 0x6F, + 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, 0x61, + 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2D, 0x65, 0x74, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, + 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2D, 0x65, + 0x74, 0x6D, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, + 0x2C, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x2D, 0x65, 0x74, 0x6D, + 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, + 0x6D, 0x61, 0x63, 0x2D, 0x36, 0x34, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x75, 0x6D, 0x61, 0x63, 0x2D, 0x31, 0x32, 0x38, 0x40, + 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x32, 0x35, 0x36, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x32, 0x2D, 0x35, 0x31, 0x32, 0x2C, 0x68, 0x6D, + 0x61, 0x63, 0x2D, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x1A, 0x6E, 0x6F, 0x6E, + 0x65, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, 0x73, 0x68, + 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x00, 0x00, 0x00, 0x1A, 0x6E, + 0x6F, 0x6E, 0x65, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x40, 0x6F, 0x70, 0x65, 0x6E, 0x73, + 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x2C, 0x7A, 0x6C, 0x69, 0x62, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + let mut hassh_string: Vec = vec![]; + let mut hassh: Vec = vec![]; + if let Ok((_, key_exchange)) = ssh_parse_key_exchange(&client_key_exchange) { key_exchange.generate_hassh(&mut hassh_string, &mut hassh, &true); } @@ -564,164 +582,191 @@ mod tests { umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,\ hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,\ hmac-sha2-256,hmac-sha2-512,hmac-sha1;none,zlib@openssh.com,zlib".as_bytes().to_vec()); - - assert_eq!(hassh, "ec7378c1a92f5a8dde7e8b7a1ddf33d1".as_bytes().to_vec()); + + assert_eq!( + hassh, + "ec7378c1a92f5a8dde7e8b7a1ddf33d1".as_bytes().to_vec() + ); } #[test] fn test_parse_hassh_server() { - let server_key_exchange = [0x7d, 0x76, 0x4f, 0x78, 0x81, 0x9e, 0x10, 0xfa, 0x23, 0x72, - 0xb5, 0x15, 0x56, 0xba, 0xf9, 0x46, 0x00, 0x00, 0x01, 0x02, 0x63, 0x75, 0x72, 0x76, 0x65, 0x32, - 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x63, 0x75, 0x72, 0x76, - 0x65, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, 0x6c, 0x69, - 0x62, 0x73, 0x73, 0x68, 0x2e, 0x6f, 0x72, 0x67, 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, - 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, 0x65, 0x63, 0x64, 0x68, - 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2c, 0x65, - 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, - 0x31, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, - 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2d, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, - 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, - 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x36, 0x2d, 0x73, 0x68, - 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, - 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x38, 0x2d, 0x73, 0x68, 0x61, 0x35, - 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, - 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, - 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x41, - 0x73, 0x73, 0x68, 0x2d, 0x72, 0x73, 0x61, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, - 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, - 0x36, 0x2c, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, - 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, 0x73, 0x73, 0x68, 0x2d, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, - 0x39, 0x00, 0x00, 0x00, 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, - 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, - 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, - 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, - 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, - 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x00, 0x00, 0x00, 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, - 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, - 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, - 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, - 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, - 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, - 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, - 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, - 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, - 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, - 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, - 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, - 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, - 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, - 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, - 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, - 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, - 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, - 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, - 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, - 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, - 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, - 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, - 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, - 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, - 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, - 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x15, 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x15, - 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; - let mut hassh_server_string: Vec = vec!(); - let mut hassh_server: Vec = vec!(); - if let Ok((_, key_exchange)) = ssh_parse_key_exchange(&server_key_exchange){ + let server_key_exchange = [ + 0x7d, 0x76, 0x4f, 0x78, 0x81, 0x9e, 0x10, 0xfa, 0x23, 0x72, 0xb5, 0x15, 0x56, 0xba, + 0xf9, 0x46, 0x00, 0x00, 0x01, 0x02, 0x63, 0x75, 0x72, 0x76, 0x65, 0x32, 0x35, 0x35, + 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x63, 0x75, 0x72, 0x76, + 0x65, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, + 0x6c, 0x69, 0x62, 0x73, 0x73, 0x68, 0x2e, 0x6f, 0x72, 0x67, 0x2c, 0x65, 0x63, 0x64, + 0x68, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, + 0x36, 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, + 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, + 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2c, 0x64, 0x69, + 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2d, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, + 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, + 0x36, 0x2d, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, + 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x31, 0x38, 0x2d, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, + 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, + 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, + 0x00, 0x41, 0x73, 0x73, 0x68, 0x2d, 0x72, 0x73, 0x61, 0x2c, 0x72, 0x73, 0x61, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, + 0x73, 0x73, 0x68, 0x2d, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x00, 0x00, 0x00, + 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, 0x6c, 0x79, + 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, + 0x61, 0x65, 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, + 0x32, 0x35, 0x36, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, + 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, + 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, + 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, 0x6c, 0x79, + 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, + 0x61, 0x65, 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, + 0x32, 0x35, 0x36, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, + 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, + 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, + 0xd5, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, + 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, + 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, + 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, + 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, + 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, + 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, + 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, + 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, + 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, + 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, + 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, + 0x34, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, + 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, + 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, + 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, + 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, + 0x31, 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, + 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, + 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, + 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, + 0x31, 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, + 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, + 0x32, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, + 0x15, 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, + 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x15, 0x6e, 0x6f, + 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, + 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + let mut hassh_server_string: Vec = vec![]; + let mut hassh_server: Vec = vec![]; + if let Ok((_, key_exchange)) = ssh_parse_key_exchange(&server_key_exchange) { key_exchange.generate_hassh(&mut hassh_server_string, &mut hassh_server, &true); } - assert_eq!(hassh_server, "b12d2871a1189eff20364cf5333619ee".as_bytes().to_vec()); + assert_eq!( + hassh_server, + "b12d2871a1189eff20364cf5333619ee".as_bytes().to_vec() + ); } - + #[test] fn test_parse_hassh_server_malicious() { - let server_key_exchange = [0x7d, 0x76, 0x4f, 0x78, 0x81, 0x9e, 0x10, 0xfa, 0x23, 0x72, - 0xb5, 0x15, 0x56, 0xba, 0xf9, 0x46, 0x00, 0x00, 0x01, 0x02, 0x75, 0x72, 0x76, 0x65, 0x32, - 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x63, 0x75, 0x72, 0x76, - 0x65, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, 0x6c, 0x69, - 0x62, 0x73, 0x73, 0x68, 0x2e, 0x6f, 0x72, 0x67, 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, - 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, 0x65, 0x63, 0x64, 0x68, - 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x33, 0x38, 0x34, 0x2c, 0x65, - 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, - 0x31, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, - 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2d, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, - 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, - 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x36, 0x2d, 0x73, 0x68, - 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, - 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x38, 0x2d, 0x73, 0x68, 0x61, 0x35, - 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, - 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, - 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x41, - 0x73, 0x73, 0x68, 0x2d, 0x72, 0x73, 0x61, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, - 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, - 0x36, 0x2c, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, - 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, 0x73, 0x73, 0x68, 0x2d, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, - 0x39, 0x00, 0x00, 0x00, 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, - 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, - 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, - 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, - 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, - 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x00, 0x00, 0x00, 0x6c, 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, - 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, - 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, - 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, - 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, - 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, - 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, - 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, - 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, - 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, - 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, - 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, - 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, - 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, - 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, - 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, - 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, - 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, - 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, - 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, - 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, - 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, - 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, - 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, - 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, - 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, - 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, - 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, - 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x15, 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, - 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x15, - 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, - 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + let server_key_exchange = [ + 0x7d, 0x76, 0x4f, 0x78, 0x81, 0x9e, 0x10, 0xfa, 0x23, 0x72, 0xb5, 0x15, 0x56, 0xba, + 0xf9, 0x46, 0x00, 0x00, 0x01, 0x02, 0x75, 0x72, 0x76, 0x65, 0x32, 0x35, 0x35, 0x31, + 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x63, 0x75, 0x72, 0x76, 0x65, + 0x32, 0x35, 0x35, 0x31, 0x39, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x40, 0x6c, + 0x69, 0x62, 0x73, 0x73, 0x68, 0x2e, 0x6f, 0x72, 0x67, 0x2c, 0x65, 0x63, 0x64, 0x68, + 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, 0x36, + 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, + 0x74, 0x70, 0x33, 0x38, 0x34, 0x2c, 0x65, 0x63, 0x64, 0x68, 0x2d, 0x73, 0x68, 0x61, + 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x35, 0x32, 0x31, 0x2c, 0x64, 0x69, 0x66, + 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x2d, 0x65, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, + 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x31, 0x36, + 0x2d, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, 0x69, 0x65, + 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x31, 0x38, 0x2d, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x2c, 0x64, 0x69, 0x66, 0x66, + 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x2c, 0x64, 0x69, + 0x66, 0x66, 0x69, 0x65, 0x2d, 0x68, 0x65, 0x6c, 0x6c, 0x6d, 0x61, 0x6e, 0x2d, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x31, 0x34, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, + 0x41, 0x73, 0x73, 0x68, 0x2d, 0x72, 0x73, 0x61, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x72, 0x73, 0x61, 0x2d, 0x73, 0x68, + 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x65, 0x63, 0x64, 0x73, 0x61, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x6e, 0x69, 0x73, 0x74, 0x70, 0x32, 0x35, 0x36, 0x2c, 0x73, + 0x73, 0x68, 0x2d, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x00, 0x00, 0x00, 0x6c, + 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, 0x6c, 0x79, 0x31, + 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, + 0x65, 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, + 0x35, 0x36, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, + 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, + 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x6c, + 0x63, 0x68, 0x61, 0x63, 0x68, 0x61, 0x32, 0x30, 0x2d, 0x70, 0x6f, 0x6c, 0x79, 0x31, + 0x33, 0x30, 0x35, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, + 0x65, 0x73, 0x31, 0x39, 0x32, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x32, + 0x35, 0x36, 0x2d, 0x63, 0x74, 0x72, 0x2c, 0x61, 0x65, 0x73, 0x31, 0x32, 0x38, 0x2d, + 0x67, 0x63, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x61, 0x65, 0x73, 0x32, 0x35, 0x36, 0x2d, 0x67, 0x63, 0x6d, 0x40, 0x6f, + 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0xd5, + 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, + 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, + 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, + 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, + 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, + 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, + 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, + 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, + 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, + 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, + 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, + 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, + 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, + 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, + 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0xd5, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, + 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, + 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, 0x32, 0x38, 0x2d, 0x65, 0x74, + 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, + 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, 0x2d, + 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, + 0x32, 0x2d, 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, + 0x63, 0x6f, 0x6d, 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x2d, + 0x65, 0x74, 0x6d, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, + 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x36, 0x34, 0x40, 0x6f, 0x70, 0x65, 0x6e, + 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x2c, 0x75, 0x6d, 0x61, 0x63, 0x2d, 0x31, + 0x32, 0x38, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, + 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x32, 0x35, 0x36, + 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x32, 0x2d, 0x35, 0x31, 0x32, + 0x2c, 0x68, 0x6d, 0x61, 0x63, 0x2d, 0x73, 0x68, 0x61, 0x31, 0x00, 0x00, 0x00, 0x15, + 0x6e, 0x6f, 0x6e, 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, 0x6e, + 0x73, 0x73, 0x68, 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x15, 0x6e, 0x6f, 0x6e, + 0x65, 0x2c, 0x7a, 0x6c, 0x69, 0x62, 0x40, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x73, 0x68, + 0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; if let Err(e) = ssh_parse_key_exchange(&server_key_exchange) { assert_eq!(e, Err::Incomplete(Needed::new(15964))); - } - else { + } else { panic!("ssh_parse_key_exchange() parsed malicious key_exchange"); } -} + } } diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index c0a7677d42f..e0c4ecc7c0c 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -20,10 +20,10 @@ use crate::applayer::*; use crate::core::*; use crate::direction::Direction; use crate::flow::Flow; +use crate::frames::Frame; use nom7::Err; use std::ffi::CString; use std::sync::atomic::{AtomicBool, Ordering}; -use crate::frames::Frame; static mut ALPROTO_SSH: AppProto = ALPROTO_UNKNOWN; static HASSH_ENABLED: AtomicBool = AtomicBool::new(false); @@ -189,8 +189,14 @@ impl SSHState { parser::MessageCode::Kexinit if hassh_is_enabled() => { //let endkex = SSH_RECORD_HEADER_LEN + head.pkt_len - 2; let endkex = input.len() - rem.len(); - if let Ok((_, key_exchange)) = parser::ssh_parse_key_exchange(&input[SSH_RECORD_HEADER_LEN..endkex]) { - key_exchange.generate_hassh(&mut hdr.hassh_string, &mut hdr.hassh, &resp); + if let Ok((_, key_exchange)) = parser::ssh_parse_key_exchange( + &input[SSH_RECORD_HEADER_LEN..endkex], + ) { + key_exchange.generate_hassh( + &mut hdr.hassh_string, + &mut hdr.hassh, + &resp, + ); } } parser::MessageCode::NewKeys => { @@ -200,15 +206,15 @@ impl SSHState { AppLayerParserStateSetFlag( pstate, APP_LAYER_PARSER_NO_INSPECTION - | APP_LAYER_PARSER_NO_REASSEMBLY - | APP_LAYER_PARSER_BYPASS_READY, + | APP_LAYER_PARSER_NO_REASSEMBLY + | APP_LAYER_PARSER_BYPASS_READY, ); } } } _ => {} } - + input = rem; //header and complete data (not returned) } @@ -244,7 +250,7 @@ impl SSHState { let remlen = rem.len() as u32; hdr.record_left = head.pkt_len - 2 - remlen; //header with rem as incomplete data - match head.msg_code { + match head.msg_code { parser::MessageCode::NewKeys => { hdr.flags = SSHConnectionState::SshStateFinished; } @@ -256,10 +262,9 @@ impl SSHState { hdr.record_left_msg = parser::MessageCode::Kexinit; return AppLayerResult::incomplete( (il - rem.len()) as u32, - head.pkt_len - 2 + head.pkt_len - 2, ); - } - else { + } else { SCLogDebug!("SSH buffer is bigger than maximum reassembled packet size"); self.set_event(SSHEvent::LongKexRecord); } @@ -295,8 +300,8 @@ impl SSHState { } fn parse_banner( - &mut self, input: &[u8], resp: bool, pstate: *mut std::os::raw::c_void, - flow: *const Flow, stream_slice: &StreamSlice, + &mut self, input: &[u8], resp: bool, pstate: *mut std::os::raw::c_void, flow: *const Flow, + stream_slice: &StreamSlice, ) -> AppLayerResult { let hdr = if !resp { &mut self.transaction.cli_hdr @@ -388,31 +393,28 @@ impl SSHState { // C exports. -export_tx_data_get!(rs_ssh_get_tx_data, SSHTransaction); -export_state_data_get!(rs_ssh_get_state_data, SSHState); +export_tx_data_get!(ssh_get_tx_data, SSHTransaction); +export_state_data_get!(ssh_get_state_data, SSHState); -#[no_mangle] -pub extern "C" fn rs_ssh_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void { +extern "C" fn ssh_state_new( + _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto, +) -> *mut std::os::raw::c_void { let state = SSHState::new(); let boxed = Box::new(state); return Box::into_raw(boxed) as *mut _; } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_state_free(state: *mut std::os::raw::c_void) { +unsafe extern "C" fn ssh_state_free(state: *mut std::os::raw::c_void) { std::mem::drop(Box::from_raw(state as *mut SSHState)); } -#[no_mangle] -pub extern "C" fn rs_ssh_state_tx_free(_state: *mut std::os::raw::c_void, _tx_id: u64) { +extern "C" fn ssh_state_tx_free(_state: *mut std::os::raw::c_void, _tx_id: u64) { //do nothing } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_parse_request( +unsafe extern "C" fn rs_ssh_parse_request( flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void, - stream_slice: StreamSlice, - _data: *const std::os::raw::c_void + stream_slice: StreamSlice, _data: *const std::os::raw::c_void, ) -> AppLayerResult { let state = &mut cast_pointer!(state, SSHState); let buf = stream_slice.as_slice(); @@ -425,11 +427,9 @@ pub unsafe extern "C" fn rs_ssh_parse_request( } } -#[no_mangle] -pub unsafe extern "C" fn rs_ssh_parse_response( +unsafe extern "C" fn ssh_parse_response( flow: *const Flow, state: *mut std::os::raw::c_void, pstate: *mut std::os::raw::c_void, - stream_slice: StreamSlice, - _data: *const std::os::raw::c_void + stream_slice: StreamSlice, _data: *const std::os::raw::c_void, ) -> AppLayerResult { let state = &mut cast_pointer!(state, SSHState); let buf = stream_slice.as_slice(); @@ -443,20 +443,19 @@ pub unsafe extern "C" fn rs_ssh_parse_response( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_state_get_tx( +pub unsafe extern "C" fn SCSshStateGetTx( state: *mut std::os::raw::c_void, _tx_id: u64, ) -> *mut std::os::raw::c_void { let state = cast_pointer!(state, SSHState); return &state.transaction as *const _ as *mut _; } -#[no_mangle] -pub extern "C" fn rs_ssh_state_get_tx_count(_state: *mut std::os::raw::c_void) -> u64 { +extern "C" fn ssh_state_get_tx_count(_state: *mut std::os::raw::c_void) -> u64 { return 1; } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_flags( +pub unsafe extern "C" fn SCSshTxGetFlags( tx: *mut std::os::raw::c_void, direction: u8, ) -> SSHConnectionState { let tx = cast_pointer!(tx, SSHTransaction); @@ -468,7 +467,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_flags( } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_alstate_progress( +pub unsafe extern "C" fn SCSshTxGetAlStateProgress( tx: *mut std::os::raw::c_void, direction: u8, ) -> std::os::raw::c_int { let tx = cast_pointer!(tx, SSHTransaction); @@ -494,7 +493,7 @@ pub unsafe extern "C" fn rs_ssh_tx_get_alstate_progress( const PARSER_NAME: &[u8] = b"ssh\0"; #[no_mangle] -pub unsafe extern "C" fn rs_ssh_register_parser() { +pub unsafe extern "C" fn SCRegisterSshParser() { let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: std::ptr::null(), @@ -504,24 +503,24 @@ pub unsafe extern "C" fn rs_ssh_register_parser() { probe_tc: None, min_depth: 0, max_depth: 0, - state_new: rs_ssh_state_new, - state_free: rs_ssh_state_free, - tx_free: rs_ssh_state_tx_free, + state_new: ssh_state_new, + state_free: ssh_state_free, + tx_free: ssh_state_tx_free, parse_ts: rs_ssh_parse_request, - parse_tc: rs_ssh_parse_response, - get_tx_count: rs_ssh_state_get_tx_count, - get_tx: rs_ssh_state_get_tx, + parse_tc: ssh_parse_response, + get_tx_count: ssh_state_get_tx_count, + get_tx: SCSshStateGetTx, tx_comp_st_ts: SSHConnectionState::SshStateFinished as i32, tx_comp_st_tc: SSHConnectionState::SshStateFinished as i32, - tx_get_progress: rs_ssh_tx_get_alstate_progress, + tx_get_progress: SCSshTxGetAlStateProgress, get_eventinfo: Some(SSHEvent::get_event_info), get_eventinfo_byid: Some(SSHEvent::get_event_info_by_id), localstorage_new: None, localstorage_free: None, get_tx_files: None, get_tx_iterator: None, - get_tx_data: rs_ssh_get_tx_data, - get_state_data: rs_ssh_get_state_data, + get_tx_data: ssh_get_tx_data, + get_state_data: ssh_get_state_data, apply_tx_config: None, flags: 0, get_frame_id_by_name: Some(SshFrameType::ffi_id_from_name), @@ -544,27 +543,28 @@ pub unsafe extern "C" fn rs_ssh_register_parser() { } #[no_mangle] -pub extern "C" fn rs_ssh_enable_hassh() { +pub extern "C" fn SCSshEnableHassh() { HASSH_ENABLED.store(true, Ordering::Relaxed) } #[no_mangle] -pub extern "C" fn rs_ssh_hassh_is_enabled() -> bool { +pub extern "C" fn SCSshHasshIsEnabled() -> bool { hassh_is_enabled() } #[no_mangle] -pub unsafe extern "C" fn rs_ssh_tx_get_log_condition( tx: *mut std::os::raw::c_void) -> bool { +pub unsafe extern "C" fn SCSshTxGetLogCondition(tx: *mut std::os::raw::c_void) -> bool { let tx = cast_pointer!(tx, SSHTransaction); - - if rs_ssh_hassh_is_enabled() { - if tx.cli_hdr.flags == SSHConnectionState::SshStateFinished && - tx.srv_hdr.flags == SSHConnectionState::SshStateFinished { - return true; + + if SCSshHasshIsEnabled() { + if tx.cli_hdr.flags == SSHConnectionState::SshStateFinished + && tx.srv_hdr.flags == SSHConnectionState::SshStateFinished + { + return true; } - } - else if tx.cli_hdr.flags == SSHConnectionState::SshStateBannerDone && - tx.srv_hdr.flags == SSHConnectionState::SshStateBannerDone { + } else if tx.cli_hdr.flags == SSHConnectionState::SshStateBannerDone + && tx.srv_hdr.flags == SSHConnectionState::SshStateBannerDone + { return true; } return false; diff --git a/rust/src/telnet/telnet.rs b/rust/src/telnet/telnet.rs index 1d67059bcb5..01f0e38c9ab 100644 --- a/rust/src/telnet/telnet.rs +++ b/rust/src/telnet/telnet.rs @@ -501,8 +501,8 @@ pub unsafe extern "C" fn rs_telnet_tx_get_alstate_progress( return 0; } -export_tx_data_get!(rs_telnet_get_tx_data, TelnetTransaction); -export_state_data_get!(rs_telnet_get_state_data, TelnetState); +export_tx_data_get!(telnet_get_tx_data, TelnetTransaction); +export_state_data_get!(telnet_get_state_data, TelnetState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"telnet\0"; @@ -534,8 +534,8 @@ pub unsafe extern "C" fn rs_telnet_register_parser() { localstorage_free: None, get_tx_files: None, get_tx_iterator: Some(applayer::state_get_tx_iterator::), - get_tx_data: rs_telnet_get_tx_data, - get_state_data: rs_telnet_get_state_data, + get_tx_data: telnet_get_tx_data, + get_state_data: telnet_get_state_data, apply_tx_config: None, flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS, get_frame_id_by_name: Some(TelnetFrameType::ffi_id_from_name), diff --git a/rust/src/websocket/websocket.rs b/rust/src/websocket/websocket.rs index 1138ab759ab..3f49efbc19e 100644 --- a/rust/src/websocket/websocket.rs +++ b/rust/src/websocket/websocket.rs @@ -329,8 +329,8 @@ unsafe extern "C" fn rs_websocket_tx_get_alstate_progress( return 1; } -export_tx_data_get!(rs_websocket_get_tx_data, WebSocketTransaction); -export_state_data_get!(rs_websocket_get_state_data, WebSocketState); +export_tx_data_get!(websocket_get_tx_data, WebSocketTransaction); +export_state_data_get!(websocket_get_state_data, WebSocketState); // Parser name as a C style string. const PARSER_NAME: &[u8] = b"websocket\0"; @@ -363,8 +363,8 @@ pub unsafe extern "C" fn rs_websocket_register_parser() { get_tx_iterator: Some( applayer::state_get_tx_iterator::, ), - get_tx_data: rs_websocket_get_tx_data, - get_state_data: rs_websocket_get_state_data, + get_tx_data: websocket_get_tx_data, + get_state_data: websocket_get_state_data, apply_tx_config: None, flags: 0, // do not accept gaps as there is no good way to resync get_frame_id_by_name: Some(WebSocketFrameType::ffi_id_from_name), diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index af98c6cbe2f..7e25a25a9d7 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -626,7 +626,7 @@ static AppProto AppLayerProtoDetectPPGetProto(Flow *f, const uint8_t *buf, uint3 else if (pp_port_sp) mask = pp_port_sp->alproto_mask; - if (alproto_masks[0] == mask) { + if ((alproto_masks[0] & mask) == mask) { FLOW_SET_PP_DONE(f, dir); SCLogDebug("%s, mask is now %08x, needed %08x, so done", (dir == STREAM_TOSERVER) ? "toserver":"toclient", diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 6285b67d256..ec263aeb785 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1747,7 +1747,7 @@ void AppLayerParserRegisterProtocolParsers(void) RegisterTFTPParsers(); RegisterIKEParsers(); rs_register_krb5_parser(); - rs_dhcp_register_parser(); + SCRegisterDhcpParser(); rs_register_snmp_parser(); rs_sip_register_parser(); rs_quic_register_parser(); diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index b2bf22a5314..472ef7b040e 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -1699,7 +1699,7 @@ static AppProto SMTPServerProbingParser( return ALPROTO_UNKNOWN; } AppProto r = ALPROTO_UNKNOWN; - if (f->todstbytecnt > 4 && f->alproto_ts == ALPROTO_UNKNOWN) { + if (f->todstbytecnt > 4 && (f->alproto_ts == ALPROTO_UNKNOWN || f->alproto_ts == ALPROTO_TLS)) { // Only validates SMTP if client side is unknown // despite having received bytes. r = ALPROTO_SMTP; diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 71bc786ad6b..276e0fbee38 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -73,7 +73,7 @@ static int SSHRegisterPatternsForProtocolDetection(void) bool SSHTxLogCondition(ThreadVars *tv, const Packet *p, void *state, void *tx, uint64_t tx_id) { - return rs_ssh_tx_get_log_condition(tx); + return SCSshTxGetLogCondition(tx); } /** \brief Function to register the SSH protocol parsers and other functions @@ -101,13 +101,12 @@ void RegisterSSHParsers(void) } if (RunmodeIsUnittests() || enable_hassh) { - rs_ssh_enable_hassh(); + SCSshEnableHassh(); } } SCLogDebug("Registering Rust SSH parser."); - rs_ssh_register_parser(); - + SCRegisterSshParser(); #ifdef UNITTESTS AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_SSH, SSHParserRegisterTests); @@ -126,7 +125,7 @@ static int SSHParserTestUtilCheck(const char *protoexp, const char *softexp, voi const uint8_t *software = NULL; uint32_t s_len = 0; - if (rs_ssh_tx_get_protocol(tx, &protocol, &p_len, flags) != 1) { + if (SCSshTxGetProtocol(tx, &protocol, &p_len, flags) != 1) { printf("Version string not parsed correctly return: "); return 1; } @@ -145,7 +144,7 @@ static int SSHParserTestUtilCheck(const char *protoexp, const char *softexp, voi } if (softexp != NULL) { - if (rs_ssh_tx_get_software(tx, &software, &s_len, flags) != 1) + if (SCSshTxGetSoftware(tx, &software, &s_len, flags) != 1) return 1; if (software == NULL) return 1; @@ -192,8 +191,8 @@ static int SSHParserTest01(void) goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -242,9 +241,9 @@ static int SSHParserTest02(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -292,17 +291,17 @@ static int SSHParserTest03(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) == SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) == SshStateBannerDone) { printf("Client version string parsed? It's not a valid string: "); goto end; } const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - if (rs_ssh_tx_get_protocol(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) + if (SCSshTxGetProtocol(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) goto end; - if (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) + if (SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOSERVER) != 0) goto end; result = 1; @@ -344,9 +343,9 @@ static int SSHParserTest04(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -394,9 +393,9 @@ static int SSHParserTest05(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone) { printf("Client version string not parsed: "); goto end; } @@ -444,17 +443,17 @@ static int SSHParserTest06(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); + void *tx = SCSshStateGetTx(ssh_state, 0); - if ( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) == SshStateBannerDone ) { + if (SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) == SshStateBannerDone) { printf("Client version string parsed? It's not a valid string: "); goto end; } const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - if (rs_ssh_tx_get_protocol(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) + if (SCSshTxGetProtocol(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) goto end; - if (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) + if (SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0) goto end; @@ -507,8 +506,8 @@ static int SSHParserTest07(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -558,8 +557,8 @@ static int SSHParserTest08(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOSERVER) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOSERVER) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -608,8 +607,8 @@ static int SSHParserTest09(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -659,8 +658,8 @@ static int SSHParserTest10(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_alstate_progress(tx, STREAM_TOCLIENT) != SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetAlStateProgress(tx, STREAM_TOCLIENT) != SshStateBannerDone); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -709,8 +708,8 @@ static int SSHParserTest11(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -772,8 +771,8 @@ static int SSHParserTest12(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -833,8 +832,8 @@ static int SSHParserTest13(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -892,8 +891,8 @@ static int SSHParserTest14(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -950,8 +949,8 @@ static int SSHParserTest15(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOSERVER)); @@ -1006,8 +1005,8 @@ static int SSHParserTest16(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -1063,8 +1062,8 @@ static int SSHParserTest17(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "MySSHClient-0.5.1", tx, STREAM_TOCLIENT)); @@ -1130,8 +1129,8 @@ static int SSHParserTest18(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(!(AppLayerParserStateIssetFlag(f->alparser, APP_LAYER_PARSER_NO_INSPECTION))); @@ -1196,8 +1195,8 @@ static int SSHParserTest19(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); sshbuf3[sizeof(sshbuf3) - 2] = 0; FAIL_IF(SSHParserTestUtilCheck("2.0", (char *)sshbuf3, tx, STREAM_TOCLIENT)); @@ -1265,8 +1264,8 @@ static int SSHParserTest20(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", NULL, tx, STREAM_TOCLIENT)); @@ -1332,8 +1331,8 @@ static int SSHParserTest21(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", NULL, tx, STREAM_TOCLIENT)); @@ -1428,8 +1427,8 @@ static int SSHParserTest22(void) void *ssh_state = f->alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOCLIENT) != SshStateFinished ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOCLIENT) != SshStateFinished); FAIL_IF(SSHParserTestUtilCheck("2.0", "libssh", tx, STREAM_TOCLIENT)); @@ -1504,8 +1503,8 @@ static int SSHParserTest24(void) printf("no ssh state: "); goto end; } - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - if ( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) != SshStateBannerDone ) { + void *tx = SCSshStateGetTx(ssh_state, 0); + if (SCSshTxGetFlags(tx, STREAM_TOSERVER) != SshStateBannerDone) { printf("Didn't detect the msg code of new keys (ciphered data starts): "); goto end; } @@ -1545,11 +1544,11 @@ static int SSHParserTest25(void) void *ssh_state = f.alstate; FAIL_IF_NULL(ssh_state); - void * tx = rs_ssh_state_get_tx(ssh_state, 0); - FAIL_IF( rs_ssh_tx_get_flags(tx, STREAM_TOSERVER) == SshStateBannerDone ); + void *tx = SCSshStateGetTx(ssh_state, 0); + FAIL_IF(SCSshTxGetFlags(tx, STREAM_TOSERVER) == SshStateBannerDone); const uint8_t *dummy = NULL; uint32_t dummy_len = 0; - FAIL_IF (rs_ssh_tx_get_software(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0); + FAIL_IF(SCSshTxGetSoftware(tx, &dummy, &dummy_len, STREAM_TOCLIENT) != 0); AppLayerParserThreadCtxFree(alp_tctx); StreamTcpFreeConfig(true); diff --git a/src/decode-tcp.h b/src/decode-tcp.h index c0ce5c20d26..b3e23840557 100644 --- a/src/decode-tcp.h +++ b/src/decode-tcp.h @@ -105,35 +105,35 @@ #define TCP_GET_SACK_CNT(p) (p)->l4.vars.tcp.sack_cnt #define TCP_GET_MSS(p) (p)->l4.vars.tcp.mss -#define TCP_GET_OFFSET(p) TCP_GET_RAW_OFFSET((p)->tcph) -#define TCP_GET_X2(p) TCP_GET_RAW_X2((p)->tcph) +#define TCP_GET_OFFSET(p) TCP_GET_RAW_OFFSET((p)->l4.hdrs.tcph) +#define TCP_GET_X2(p) TCP_GET_RAW_X2((p)->l4.hdrs.tcph) #define TCP_GET_HLEN(p) ((uint8_t)(TCP_GET_OFFSET((p)) << 2)) -#define TCP_GET_SRC_PORT(p) TCP_GET_RAW_SRC_PORT((p)->tcph) -#define TCP_GET_DST_PORT(p) TCP_GET_RAW_DST_PORT((p)->tcph) -#define TCP_GET_SEQ(p) TCP_GET_RAW_SEQ((p)->tcph) -#define TCP_GET_ACK(p) TCP_GET_RAW_ACK((p)->tcph) -#define TCP_GET_WINDOW(p) TCP_GET_RAW_WINDOW((p)->tcph) -#define TCP_GET_URG_POINTER(p) TCP_GET_RAW_URG_POINTER((p)->tcph) -#define TCP_GET_SUM(p) TCP_GET_RAW_SUM((p)->tcph) -#define TCP_GET_FLAGS(p) (p)->tcph->th_flags - -#define TCP_ISSET_FLAG_RAW_FIN(p) ((tcph)->th_flags & TH_FIN) -#define TCP_ISSET_FLAG_RAW_SYN(p) ((tcph)->th_flags & TH_SYN) -#define TCP_ISSET_FLAG_RAW_RST(p) ((tcph)->th_flags & TH_RST) -#define TCP_ISSET_FLAG_RAW_PUSH(p) ((tcph)->th_flags & TH_PUSH) -#define TCP_ISSET_FLAG_RAW_ACK(p) ((tcph)->th_flags & TH_ACK) -#define TCP_ISSET_FLAG_RAW_URG(p) ((tcph)->th_flags & TH_URG) -#define TCP_ISSET_FLAG_RAW_RES2(p) ((tcph)->th_flags & TH_RES2) -#define TCP_ISSET_FLAG_RAW_RES1(p) ((tcph)->th_flags & TH_RES1) - -#define TCP_ISSET_FLAG_FIN(p) ((p)->tcph->th_flags & TH_FIN) -#define TCP_ISSET_FLAG_SYN(p) ((p)->tcph->th_flags & TH_SYN) -#define TCP_ISSET_FLAG_RST(p) ((p)->tcph->th_flags & TH_RST) -#define TCP_ISSET_FLAG_PUSH(p) ((p)->tcph->th_flags & TH_PUSH) -#define TCP_ISSET_FLAG_ACK(p) ((p)->tcph->th_flags & TH_ACK) -#define TCP_ISSET_FLAG_URG(p) ((p)->tcph->th_flags & TH_URG) -#define TCP_ISSET_FLAG_RES2(p) ((p)->tcph->th_flags & TH_RES2) -#define TCP_ISSET_FLAG_RES1(p) ((p)->tcph->th_flags & TH_RES1) +#define TCP_GET_SRC_PORT(p) TCP_GET_RAW_SRC_PORT((p)->l4.hdrs.tcph) +#define TCP_GET_DST_PORT(p) TCP_GET_RAW_DST_PORT((p)->l4.hdrs.tcph) +#define TCP_GET_SEQ(p) TCP_GET_RAW_SEQ((p)->l4.hdrs.tcph) +#define TCP_GET_ACK(p) TCP_GET_RAW_ACK((p)->l4.hdrs.tcph) +#define TCP_GET_WINDOW(p) TCP_GET_RAW_WINDOW((p)->l4.hdrs.tcph) +#define TCP_GET_URG_POINTER(p) TCP_GET_RAW_URG_POINTER((p)->l4.hdrs.tcph) +#define TCP_GET_SUM(p) TCP_GET_RAW_SUM((p)->l4.hdrs.tcph) +#define TCP_GET_FLAGS(p) (p)->l4.hdrs.tcph->th_flags + +#define TCP_ISSET_FLAG_RAW_FIN(tcph) ((tcph)->th_flags & TH_FIN) +#define TCP_ISSET_FLAG_RAW_SYN(tcph) ((tcph)->th_flags & TH_SYN) +#define TCP_ISSET_FLAG_RAW_RST(tcph) ((tcph)->th_flags & TH_RST) +#define TCP_ISSET_FLAG_RAW_PUSH(tcph) ((tcph)->th_flags & TH_PUSH) +#define TCP_ISSET_FLAG_RAW_ACK(tcph) ((tcph)->th_flags & TH_ACK) +#define TCP_ISSET_FLAG_RAW_URG(tcph) ((tcph)->th_flags & TH_URG) +#define TCP_ISSET_FLAG_RAW_RES2(tcph) ((tcph)->th_flags & TH_RES2) +#define TCP_ISSET_FLAG_RAW_RES1(tcph) ((tcph)->th_flags & TH_RES1) + +#define TCP_ISSET_FLAG_FIN(p) ((p)->l4.hdrs.tcph->th_flags & TH_FIN) +#define TCP_ISSET_FLAG_SYN(p) ((p)->l4.hdrs.tcph->th_flags & TH_SYN) +#define TCP_ISSET_FLAG_RST(p) ((p)->l4.hdrs.tcph->th_flags & TH_RST) +#define TCP_ISSET_FLAG_PUSH(p) ((p)->l4.hdrs.tcph->th_flags & TH_PUSH) +#define TCP_ISSET_FLAG_ACK(p) ((p)->l4.hdrs.tcph->th_flags & TH_ACK) +#define TCP_ISSET_FLAG_URG(p) ((p)->l4.hdrs.tcph->th_flags & TH_URG) +#define TCP_ISSET_FLAG_RES2(p) ((p)->l4.hdrs.tcph->th_flags & TH_RES2) +#define TCP_ISSET_FLAG_RES1(p) ((p)->l4.hdrs.tcph->th_flags & TH_RES1) typedef struct TCPOpt_ { uint8_t type; diff --git a/src/detect-engine-register.c b/src/detect-engine-register.c index b9faff49bae..9bf86f64b75 100644 --- a/src/detect-engine-register.c +++ b/src/detect-engine-register.c @@ -731,7 +731,7 @@ void SigTableSetup(void) DetectVlanLayersRegister(); ScDetectSNMPRegister(); - ScDetectDHCPRegister(); + SCDetectDHCPRegister(); ScDetectWebsocketRegister(); ScDetectEnipRegister(); ScDetectMqttRegister(); diff --git a/src/detect-ssh-hassh-server-string.c b/src/detect-ssh-hassh-server-string.c index 6aefc39682d..45e67edb3c8 100644 --- a/src/detect-ssh-hassh-server-string.c +++ b/src/detect-ssh-hassh-server-string.c @@ -69,7 +69,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh_string(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHasshString(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh string is not set"); @@ -103,10 +103,10 @@ static int DetectSshHasshServerStringSetup(DetectEngineCtx *de_ctx, Signature *s return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_SERVER_STRING)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh-server.c b/src/detect-ssh-hassh-server.c index 487ea92f141..da511885386 100644 --- a/src/detect-ssh-hassh-server.c +++ b/src/detect-ssh-hassh-server.c @@ -70,7 +70,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hasshServer = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh(txv, &hasshServer, &b_len, flow_flags) != 1) + if (SCSshTxGetHassh(txv, &hasshServer, &b_len, flow_flags) != 1) return NULL; if (hasshServer == NULL || b_len == 0) { SCLogDebug("SSH hassh not set"); @@ -104,10 +104,10 @@ static int DetectSshHasshServerSetup(DetectEngineCtx *de_ctx, Signature *s, cons return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_SERVER)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh-string.c b/src/detect-ssh-hassh-string.c index 9b268ee96c3..346e94d74b9 100644 --- a/src/detect-ssh-hassh-string.c +++ b/src/detect-ssh-hassh-string.c @@ -69,7 +69,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh_string(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHasshString(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh string is not set"); @@ -103,10 +103,10 @@ static int DetectSshHasshStringSetup(DetectEngineCtx *de_ctx, Signature *s, cons return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH_STRING)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-hassh.c b/src/detect-ssh-hassh.c index d8309c265cb..ec78519b907 100644 --- a/src/detect-ssh-hassh.c +++ b/src/detect-ssh-hassh.c @@ -70,7 +70,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *hassh = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_hassh(txv, &hassh, &b_len, flow_flags) != 1) + if (SCSshTxGetHassh(txv, &hassh, &b_len, flow_flags) != 1) return NULL; if (hassh == NULL || b_len == 0) { SCLogDebug("SSH hassh not set"); @@ -104,10 +104,10 @@ static int DetectSshHasshSetup(DetectEngineCtx *de_ctx, Signature *s, const char return -1; /* try to enable Hassh */ - rs_ssh_enable_hassh(); + SCSshEnableHassh(); /* Check if Hassh is disabled */ - if (!RunmodeIsUnittests() && !rs_ssh_hassh_is_enabled()) { + if (!RunmodeIsUnittests() && !SCSshHasshIsEnabled()) { if (!SigMatchSilentErrorEnabled(de_ctx, DETECT_SSH_HASSH)) { SCLogError("hassh support is not enabled"); } diff --git a/src/detect-ssh-proto.c b/src/detect-ssh-proto.c index 5d53881abc1..5ed0cdfb54a 100644 --- a/src/detect-ssh-proto.c +++ b/src/detect-ssh-proto.c @@ -67,7 +67,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *protocol = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_protocol(txv, &protocol, &b_len, flow_flags) != 1) + if (SCSshTxGetProtocol(txv, &protocol, &b_len, flow_flags) != 1) return NULL; if (protocol == NULL || b_len == 0) { SCLogDebug("SSH protocol not set"); diff --git a/src/detect-ssh-software.c b/src/detect-ssh-software.c index c7b89b5ea18..d7cb872523c 100644 --- a/src/detect-ssh-software.c +++ b/src/detect-ssh-software.c @@ -67,7 +67,7 @@ static InspectionBuffer *GetSshData(DetectEngineThreadCtx *det_ctx, const uint8_t *software = NULL; uint32_t b_len = 0; - if (rs_ssh_tx_get_software(txv, &software, &b_len, flow_flags) != 1) + if (SCSshTxGetSoftware(txv, &software, &b_len, flow_flags) != 1) return NULL; if (software == NULL || b_len == 0) { SCLogDebug("SSH software version not set"); diff --git a/src/output-json-dhcp.c b/src/output-json-dhcp.c index a4a4a29990e..b2bccc7999f 100644 --- a/src/output-json-dhcp.c +++ b/src/output-json-dhcp.c @@ -61,7 +61,7 @@ static int JsonDHCPLogger(ThreadVars *tv, void *thread_data, LogDHCPLogThread *thread = thread_data; LogDHCPFileCtx *ctx = thread->dhcplog_ctx; - if (!rs_dhcp_logger_do_log(ctx->rs_logger, tx)) { + if (!SCDhcpLoggerDoLog(ctx->rs_logger, tx)) { return TM_ECODE_OK; } @@ -70,7 +70,7 @@ static int JsonDHCPLogger(ThreadVars *tv, void *thread_data, return TM_ECODE_FAILED; } - rs_dhcp_logger_log(ctx->rs_logger, tx, js); + SCDhcpLoggerLog(ctx->rs_logger, tx, js); OutputJsonBuilderBuffer(tv, p, p->flow, js, thread->thread); jb_free(js); @@ -81,7 +81,7 @@ static int JsonDHCPLogger(ThreadVars *tv, void *thread_data, static void OutputDHCPLogDeInitCtxSub(OutputCtx *output_ctx) { LogDHCPFileCtx *dhcplog_ctx = (LogDHCPFileCtx *)output_ctx->data; - rs_dhcp_logger_free(dhcplog_ctx->rs_logger); + SCDhcpLoggerFree(dhcplog_ctx->rs_logger); SCFree(dhcplog_ctx); SCFree(output_ctx); } @@ -105,7 +105,7 @@ static OutputInitResult OutputDHCPLogInitSub(ConfNode *conf, output_ctx->data = dhcplog_ctx; output_ctx->DeInit = OutputDHCPLogDeInitCtxSub; - dhcplog_ctx->rs_logger = rs_dhcp_logger_new(conf); + dhcplog_ctx->rs_logger = SCDhcpLoggerNew(conf); AppLayerParserRegisterLogger(IPPROTO_UDP, ALPROTO_DHCP); diff --git a/src/output.c b/src/output.c index 6af423fb474..b86e3d483c8 100644 --- a/src/output.c +++ b/src/output.c @@ -866,7 +866,7 @@ void OutputRegisterRootLoggers(void) // ALPROTO_SMTP special: uses state RegisterSimpleJsonApplayerLogger(ALPROTO_TLS, JsonTlsLogJSONExtended, NULL); // no cast here but done in rust for SSHTransaction - RegisterSimpleJsonApplayerLogger(ALPROTO_SSH, rs_ssh_log_json, NULL); + RegisterSimpleJsonApplayerLogger(ALPROTO_SSH, SCSshLogJson, NULL); // ALPROTO_SMB special: uses state // ALPROTO_DCERPC special: uses state RegisterSimpleJsonApplayerLogger(ALPROTO_DNS, AlertJsonDns, NULL); diff --git a/src/util-lua-hassh.c b/src/util-lua-hassh.c index f4c5216e5c3..752a178de7a 100644 --- a/src/util-lua-hassh.c +++ b/src/util-lua-hassh.c @@ -64,8 +64,8 @@ static int GetHasshServerString(lua_State *luastate, const Flow *f) const uint8_t *hassh_server_string = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh_string(tx, &hassh_server_string, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHasshString(tx, &hassh_server_string, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server hassh string"); if (hassh_server_string == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server hassh string"); @@ -99,8 +99,8 @@ static int GetHasshServer(lua_State *luastate, const Flow *f) const uint8_t *hassh_server = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh(tx, &hassh_server, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHassh(tx, &hassh_server, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server hassh"); if (hassh_server == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server hassh"); @@ -134,8 +134,8 @@ static int GetHasshString(lua_State *luastate, const Flow *f) const uint8_t *hassh_string = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh_string(tx, &hassh_string, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHasshString(tx, &hassh_string, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client hassh_string"); if (hassh_string == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client hassh_string"); @@ -169,8 +169,8 @@ static int GetHassh(lua_State *luastate, const Flow *f) const uint8_t *hassh = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_hassh(tx, &hassh, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetHassh(tx, &hassh, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client hassh"); if (hassh == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client hassh"); diff --git a/src/util-lua-ssh.c b/src/util-lua-ssh.c index f8d6e30ccd2..a2d6d2edaf2 100644 --- a/src/util-lua-ssh.c +++ b/src/util-lua-ssh.c @@ -64,8 +64,8 @@ static int GetServerProtoVersion(lua_State *luastate, const Flow *f) const uint8_t *protocol = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_protocol(tx, &protocol, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetProtocol(tx, &protocol, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server proto version"); if (protocol == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server proto version"); @@ -99,8 +99,8 @@ static int GetServerSoftwareVersion(lua_State *luastate, const Flow *f) const uint8_t *software = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOCLIENT) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetSoftware(tx, &software, &b_len, STREAM_TOCLIENT) != 1) return LuaCallbackError(luastate, "error: no server software version"); if (software == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no server software version"); @@ -134,8 +134,8 @@ static int GetClientProtoVersion(lua_State *luastate, const Flow *f) const uint8_t *protocol = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_protocol(tx, &protocol, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetProtocol(tx, &protocol, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client proto version"); if (protocol == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client proto version"); @@ -169,8 +169,8 @@ static int GetClientSoftwareVersion(lua_State *luastate, const Flow *f) const uint8_t *software = NULL; uint32_t b_len = 0; - void *tx = rs_ssh_state_get_tx(state, 0); - if (rs_ssh_tx_get_software(tx, &software, &b_len, STREAM_TOSERVER) != 1) + void *tx = SCSshStateGetTx(state, 0); + if (SCSshTxGetSoftware(tx, &software, &b_len, STREAM_TOSERVER) != 1) return LuaCallbackError(luastate, "error: no client software version"); if (software == NULL || b_len == 0) { return LuaCallbackError(luastate, "error: no client software version");