### Get NTLM timestamp Source: https://docs.rs/ntlmclient/latest/ntlmclient/fn.get_ntlm_time.html Retrieves the current system time formatted as an NTLM timestamp. ```rust pub fn get_ntlm_time() -> i64 ``` -------------------------------- ### Get NTLM Timestamp Source: https://docs.rs/ntlmclient/latest/index.html Obtains the current NTLM timestamp. ```APIDOC ## get_ntlm_time ### Description Obtains the current NTLM timestamp. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters N/A (Function) ### Request Example N/A (Function) ### Response N/A (Function) ``` -------------------------------- ### Initialize Authenticated Client with NTLM Source: https://docs.rs/ntlmclient Demonstrates how to initialize an authenticated reqwest client using NTLM authentication. This involves negotiating flags, sending a negotiate message, handling the challenge, and responding with credentials. Ensure base64 and reqwest are in scope. ```rust use base64::prelude::{BASE64_STANDARD, Engine}; const EWS_URL: &str = "https://example.com/EWS/Exchange.asmx"; async fn initialize_authed_client(username: &str, password: &str, domain: &str, local_hostname: &str) -> reqwest::Client { let nego_flags = ntlmclient::Flags::NEGOTIATE_UNICODE | ntlmclient::Flags::REQUEST_TARGET | ntlmclient::Flags::NEGOTIATE_NTLM | ntlmclient::Flags::NEGOTIATE_WORKSTATION_SUPPLIED ; let nego_msg = ntlmclient::Message::Negotiate(ntlmclient::NegotiateMessage { flags: nego_flags, supplied_domain: String::new(), supplied_workstation: local_hostname.to_owned(), os_version: Default::default(), }); let nego_msg_bytes = nego_msg.to_bytes() .expect("failed to encode NTLM negotiation message"); let nego_b64 = BASE64_STANDARD.encode(&nego_msg_bytes); let client = reqwest::Client::builder() .cookie_store(true) .build() .expect("failed to build client"); let resp = client.get(EWS_URL) .header("Authorization", format!("NTLM {}", nego_b64)) .send().await .expect("failed to send challenge request to Exchange"); let challenge_header = resp.headers().get("www-authenticate") .expect("response missing challenge header"); // we might have been redirected to a specialized authentication URL let auth_url = resp.url(); let challenge_b64 = challenge_header.to_str() .expect("challenge header not a string") .split(" ") .nth(1).expect("second chunk of challenge header missing"); let challenge_bytes = BASE64_STANDARD.decode(challenge_b64) .expect("base64 decoding challenge message failed"); let challenge = ntlmclient::Message::try_from(challenge_bytes.as_slice()) .expect("decoding challenge message failed"); let challenge_content = match challenge { ntlmclient::Message::Challenge(c) => c, other => panic!("wrong challenge message: {:?}", other), }; let target_info_bytes: Vec = challenge_content.target_information .iter() .flat_map(|ie| ie.to_bytes()) .collect(); // calculate the response let creds = ntlmclient::Credentials { username: username.to_owned(), password: password.to_owned(), domain: domain.to_owned(), }; let challenge_response = ntlmclient::respond_challenge_ntlm_v2( challenge_content.challenge, &target_info_bytes, ntlmclient::get_ntlm_time(), &creds, ); // assemble the packet let auth_flags = ntlmclient::Flags::NEGOTIATE_UNICODE | ntlmclient::Flags::NEGOTIATE_NTLM ; let auth_msg = challenge_response.to_message( &creds, local_hostname, auth_flags, ); let auth_msg_bytes = auth_msg.to_bytes() .expect("failed to encode NTLM authentication message"); let auth_b64 = BASE64_STANDARD.encode(&auth_msg_bytes); client.get(auth_url.clone()) .header("Authorization", format!("NTLM {}", auth_b64)) .send().await .expect("failed to send authentication request to Exchange") .error_for_status() .expect("error response to authentication message"); // try calling again, without the auth stuff (thanks to cookies) client.get(EWS_URL) .send().await .expect("failed to send refresher request to Exchange") .error_for_status() .expect("error response to refresher message"); client } ``` -------------------------------- ### Initialize Authenticated Client Source: https://docs.rs/ntlmclient/latest/ntlmclient/index.html Demonstrates the full NTLM handshake process using reqwest to communicate with an Exchange server. ```rust use base64::prelude::{BASE64_STANDARD, Engine}; const EWS_URL: &str = "https://example.com/EWS/Exchange.asmx"; async fn initialize_authed_client(username: &str, password: &str, domain: &str, local_hostname: &str) -> reqwest::Client { let nego_flags = ntlmclient::Flags::NEGOTIATE_UNICODE | ntlmclient::Flags::REQUEST_TARGET | ntlmclient::Flags::NEGOTIATE_NTLM | ntlmclient::Flags::NEGOTIATE_WORKSTATION_SUPPLIED ; let nego_msg = ntlmclient::Message::Negotiate(ntlmclient::NegotiateMessage { flags: nego_flags, supplied_domain: String::new(), supplied_workstation: local_hostname.to_owned(), os_version: Default::default(), }); let nego_msg_bytes = nego_msg.to_bytes() .expect("failed to encode NTLM negotiation message"); let nego_b64 = BASE64_STANDARD.encode(&nego_msg_bytes); let client = reqwest::Client::builder() .cookie_store(true) .build() .expect("failed to build client"); let resp = client.get(EWS_URL) .header("Authorization", format!("NTLM {}", nego_b64)) .send().await .expect("failed to send challenge request to Exchange"); let challenge_header = resp.headers().get("www-authenticate") .expect("response missing challenge header"); // we might have been redirected to a specialized authentication URL let auth_url = resp.url(); let challenge_b64 = challenge_header.to_str() .expect("challenge header not a string") .split(" ") .nth(1).expect("second chunk of challenge header missing"); let challenge_bytes = BASE64_STANDARD.decode(challenge_b64) .expect("base64 decoding challenge message failed"); let challenge = ntlmclient::Message::try_from(challenge_bytes.as_slice()) .expect("decoding challenge message failed"); let challenge_content = match challenge { ntlmclient::Message::Challenge(c) => c, other => panic!("wrong challenge message: {:?}", other), }; let target_info_bytes: Vec = challenge_content.target_information .iter() .flat_map(|ie| ie.to_bytes()) .collect(); // calculate the response let creds = ntlmclient::Credentials { username: username.to_owned(), password: password.to_owned(), domain: domain.to_owned(), }; let challenge_response = ntlmclient::respond_challenge_ntlm_v2( challenge_content.challenge, &target_info_bytes, ntlmclient::get_ntlm_time(), &creds, ); // assemble the packet let auth_flags = ntlmclient::Flags::NEGOTIATE_UNICODE | ntlmclient::Flags::NEGOTIATE_NTLM ; let auth_msg = challenge_response.to_message( &creds, local_hostname, auth_flags, ); let auth_msg_bytes = auth_msg.to_bytes() .expect("failed to encode NTLM authentication message"); let auth_b64 = BASE64_STANDARD.encode(&auth_msg_bytes); client.get(auth_url.clone()) .header("Authorization", format!("NTLM {}", auth_b64)) .send().await .expect("failed to send authentication request to Exchange") .error_for_status() .expect("error response to authentication message"); // try calling again, without the auth stuff (thanks to cookies) client.get(EWS_URL) .send().await .expect("failed to send refresher request to Exchange") .error_for_status() .expect("error response to refresher message"); client } ``` -------------------------------- ### clone_to_uninit Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.SecurityBuffer.html This is a nightly-only experimental API that performs copy-assignment from self to dest. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description This is a nightly-only experimental API. Performs copy-assignment from `self` to `dest`. ### Method unsafe fn ### Endpoint N/A (Method implementation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ``` -------------------------------- ### Get Current NTLM Timestamp Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Obtains the current NTLM timestamp, which is based on the Windows epoch (1601-01-01) and measured in 100-nanosecond intervals. ```rust pub fn get_ntlm_time() -> i64 { let windows_epoch = NaiveDate::from_ymd_opt(1601, 1, 1) .expect("1601-01-01 is not a valid date?!") .and_hms_opt(0, 0, 0).expect("1601-01-01T00:00:00 is not a valid date-time?!") .and_utc(); let now = Utc::now(); // the requested format is "tenths of a microsecond", so multiply by 10_000_000 and read seconds let delta = (now - windows_epoch) * 10_000_000; delta.num_seconds() } ``` -------------------------------- ### Implement CloneToUninit for T Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Nightly-only experimental API for copying data to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Create Target Info Entry from String Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Creates a TargetInfo entry from a given entry type and a string. The string is encoded as UTF-16 LE bytes. ```rust pub fn from_string(entry_type: TargetInfoType, string: &str) -> Self { // always Unicode, even if flags claim OEM let data: Vec = string.encode_utf16() .flat_map(|b| b.to_le_bytes()) .collect(); Self { entry_type, data, } } ``` -------------------------------- ### Serialize OS Version to Bytes Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Serializes the OS version structure into a byte vector. Includes major/minor version, build number, reserved fields, and NTLM revision. ```rust impl OsVersion { /// Serializes the OS version structure into bytes. pub fn to_bytes(&self) -> Vec { let mut ret = Vec::with_capacity(8); ret.push(self.major_version); ret.push(self.minor_version); ret.extend_from_slice(&self.build_number.to_le_bytes()); ret.extend_from_slice(&self.reserved); ret.push(self.ntlm_revision); ret } } ``` -------------------------------- ### Type Conversions and Utility Methods Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.OsVersion.html This section details methods for creating owned data from borrowed data, replacing owned data with borrowed data, and performing fallible type conversions. ```APIDOC ## `to_owned` and `clone_into` ### Description Methods for creating owned data from borrowed data and for replacing owned data with borrowed data. ### Methods #### `to_owned(&self) -> T` Creates owned data from borrowed data, usually by cloning. #### `clone_into(&self, target: &mut T)` Uses borrowed data to replace owned data, usually by cloning. ``` ```APIDOC ## `TryFrom` and `TryInto` Implementations ### Description Provides fallible type conversions between types. ### Implementations #### `impl TryFrom for T where U: Into` ##### `type Error = Infallible` The type returned in the event of a conversion error. ##### `fn try_from(value: U) -> Result>::Error>` Performs the conversion. #### `impl TryInto for T where U: TryFrom` ##### `type Error = >::Error` The type returned in the event of a conversion error. ##### `fn try_into(self) -> Result>::Error>` Performs the conversion. ``` ```APIDOC ## `VZip` Implementation ### Description Provides functionality for zipping multiple lanes of data. ### Implementation #### `impl VZip for T where V: MultiLane` ##### `fn vzip(self) -> V` Zips the lanes of data. ``` -------------------------------- ### TargetInfoEntry Methods Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.TargetInfoEntry.html Methods for interacting with TargetInfoEntry, including serialization to bytes and conversion from strings. ```APIDOC ## TargetInfoEntry Methods ### Description Provides functionality to serialize, deserialize, and manipulate TargetInfoEntry objects used in NTLM authentication. ### Methods - **to_bytes() -> Vec** Serializes the target info entry into bytes. - **try_from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), ParsingError>** Attempts to deserialize a target info entry from the given byte slice. Returns the entry and the remaining bytes. - **to_string() -> Result** Attempts to convert the data within this target info entry into a string. - **from_string(entry_type: TargetInfoType, string: &str) -> Self** Creates a target info entry from an entry type and a string. ``` -------------------------------- ### OS Version Serialization Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Serializes the OS version structure into an 8-byte array. ```APIDOC ## POST /os-version/serialize ### Description Serializes the OS version structure into a fixed 8-byte array containing major version, minor version, build number, reserved bytes, and NTLM revision. ### Method POST ### Request Body - **OsVersion** (Object) - Required - The OS version structure containing version details. ### Response #### Success Response (200) - **bytes** (Array) - The 8-byte serialized OS version data. ``` -------------------------------- ### OsVersion Structure Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Defines the operating system version and NTLM revision information, including a default implementation. ```rust #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct OsVersion { pub major_version: u8, pub minor_version: u8, pub build_number: u16, pub reserved: [u8; 3], pub ntlm_revision: u8, } impl Default for OsVersion { fn default() -> Self { Self { major_version: 0, minor_version: 0, build_number: 0, reserved: [0, 0, 0], ntlm_revision: 0, } } } ``` -------------------------------- ### Create and Serialize SecurityBuffer Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Methods for initializing a security buffer from a slice and serializing it into little-endian bytes. ```rust pub fn for_slice(slice: &[u8]) -> Self { let len_u16: u16 = slice.len() .try_into().expect("buffer too long for u16 length"); Self { length: len_u16, capacity: len_u16, offset: 0, } } ``` ```rust pub fn to_bytes(&self) -> Vec { let mut ret = Vec::with_capacity(8); ret.extend_from_slice(&self.length.to_le_bytes()); ret.extend_from_slice(&self.capacity.to_le_bytes()); ret.extend_from_slice(&self.offset.to_le_bytes()); ret } ``` -------------------------------- ### Data Conversion and Cloning Methods Source: https://docs.rs/ntlmclient/latest/ntlmclient/enum.Message.html Provides details on methods for creating owned data from borrowed data and replacing owned data with borrowed data. ```APIDOC ## fn to_owned(&self) -> T ### Description Creates owned data from borrowed data, usually by cloning. ### Method N/A (Method within a trait) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Method N/A (Method within a trait) ### Endpoint N/A ### Parameters - **target** (&mut T) - Required - The mutable reference to the owned data to be replaced. ``` -------------------------------- ### Implement PartialEq for ChallengeResponse Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Enables equality comparison between ChallengeResponse instances. ```rust fn eq(&self, other: &ChallengeResponse) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Deserialize OS Version from Bytes Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Parses the OS version structure from a byte slice. Expects exactly 8 bytes and validates the length. ```rust impl TryFrom<&[u8]> for OsVersion { type Error = ParsingError; fn try_from(value: &[u8]) -> Result { if value.len() != 8 { return Err(ParsingError::ItemLengthMismatch { expected: 8, obtained: value.len() }); } let major_version = value[0]; let minor_version = value[1]; let build_number = u16::from_le_bytes(value[2..4].try_into().unwrap()); let reserved = value[4..7].try_into().unwrap(); let ntlm_revision = value[7]; Ok(OsVersion { major_version, minor_version, build_number, ``` -------------------------------- ### unsafe fn clone_to_uninit Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Experimental nightly-only API for performing copy-assignment to uninitialized memory. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from self to dest. This is a nightly-only experimental API. ### Parameters - **dest** (*mut u8) - Required - Pointer to the uninitialized destination memory. ``` -------------------------------- ### Define OsVersion Struct Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.OsVersion.html Defines the structure for OS version and NTLM revision. Includes fields for major, minor, and build numbers, a reserved field, and the NTLM revision. ```rust pub struct OsVersion { pub major_version: u8, pub minor_version: u8, pub build_number: u16, pub reserved: [u8; 3], pub ntlm_revision: u8, } ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Provides dynamic type information for any type T. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Serialize and Deserialize TargetInfoEntry Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Methods for serializing target info entries to bytes and attempting deserialization from a byte slice. ```rust pub fn to_bytes(&self) -> Vec { let mut ret = Vec::new(); // always Unicode, even if flags claim OEM let entry_type_u16: u16 = self.entry_type.into(); let bytes_len: u16 = self.data.len().try_into().expect("length of bytes does not fit into u16"); ret.extend_from_slice(&entry_type_u16.to_le_bytes()); ret.extend_from_slice(&bytes_len.to_le_bytes()); ret.extend_from_slice(&self.data); ret } ``` ```rust pub fn try_from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), ParsingError> { if bytes.len() < 4 { return Err(ParsingError::ItemMinLengthMismatch { expected_at_least: 4, obtained: bytes.len() }); } let entry_type_u16 = u16::from_le_bytes(bytes[0..2].try_into().unwrap()); ``` -------------------------------- ### Respond to NTLMv1 Challenge Source: https://docs.rs/ntlmclient/latest/index.html Calculates an NTLMv1 response to the given server challenge. ```APIDOC ## respond_challenge_ntlm_v1 ### Description Calculates an NTLMv1 response to the given server challenge. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters N/A (Function) ### Request Example N/A (Function) ### Response N/A (Function) ``` -------------------------------- ### PartialEq Implementation for ChallengeMessage Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Provides methods for equality comparison of ChallengeMessage instances. ```rust fn eq(&self, other: &ChallengeMessage) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### OsVersion Serialization Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.OsVersion.html Method to serialize the OsVersion structure into a byte vector. ```APIDOC ## fn to_bytes ### Description Serializes the OS version structure into bytes. ### Response - **Returns** (Vec) - A byte vector representation of the OsVersion struct. ``` -------------------------------- ### Implement StructuralPartialEq for ChallengeResponse Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Enables structural partial equality comparison for ChallengeResponse. ```rust impl StructuralPartialEq for ChallengeResponse ``` -------------------------------- ### Respond to NTLMv1 Challenge (No LM) Source: https://docs.rs/ntlmclient/latest/index.html Calculates an NTLMv1 response to the given server challenge without LM compatibility. ```APIDOC ## respond_challenge_ntlm_v1_no_lm ### Description Calculates an NTLMv1 response to the given server challenge. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters N/A (Function) ### Request Example N/A (Function) ### Response N/A (Function) ``` -------------------------------- ### Trait Implementations (From, Into, ToOwned) Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Standard trait implementations for data conversion and ownership management. ```APIDOC ## Trait Implementations ### From - **fn from(t: T) -> T**: Returns the argument unchanged. ### Into - **fn into(self) -> U**: Calls U::from(self). ### ToOwned - **fn to_owned(&self) -> T**: Creates owned data from borrowed data, usually by cloning. - **fn clone_into(&self, target: &mut T)**: Uses borrowed data to replace owned data, usually by cloning. ``` -------------------------------- ### PartialOrd Implementation for ChallengeMessage Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Enables partial ordering comparisons for ChallengeMessage instances. Includes `partial_cmp`, `lt`, `le`, `gt`, and `ge`. ```rust fn partial_cmp(&self, other: &ChallengeMessage) -> Option ``` ```rust fn lt(&self, other: &Rhs) -> bool ``` ```rust fn le(&self, other: &Rhs) -> bool ``` ```rust fn gt(&self, other: &Rhs) -> bool ``` ```rust fn ge(&self, other: &Rhs) -> bool ``` -------------------------------- ### Respond to Extended NTLMv1 Challenge Source: https://docs.rs/ntlmclient/latest/index.html Calculates an extended NTLMv1 response to the given server challenge. ```APIDOC ## respond_challenge_ntlm_v1_extended ### Description Calculates an extended NTLMv1 response to the given server challenge. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters N/A (Function) ### Request Example N/A (Function) ### Response N/A (Function) ``` -------------------------------- ### Define NTLM Credentials Structure Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.Credentials.html Defines the standard NTLM credentials, comprising username, password, and domain. The domain can be an empty string if not applicable. ```rust pub struct Credentials { pub username: String, pub password: String, pub domain: String, } ``` -------------------------------- ### Standard Trait Implementations Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.TargetInfoEntry.html Overview of generic trait implementations including Into, ToOwned, TryFrom, TryInto, and VZip. ```APIDOC ## Trait Implementations ### Into - **fn into(self) -> U**: Calls `U::from(self)`. ### ToOwned - **type Owned = T**: The resulting type after obtaining ownership. - **fn to_owned(&self) -> T**: Creates owned data from borrowed data, usually by cloning. - **fn clone_into(&self, target: &mut T)**: Uses borrowed data to replace owned data. ### TryFrom - **type Error = Infallible**: The type returned in the event of a conversion error. - **fn try_from(value: U) -> Result>::Error>**: Performs the conversion. ### TryInto - **type Error = >::Error**: The type returned in the event of a conversion error. - **fn try_into(self) -> Result>::Error>**: Performs the conversion. ### VZip - **fn vzip(self) -> V**: Performs vector zip operation where V: MultiLane. ``` -------------------------------- ### Serialize OsVersion to Bytes Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.OsVersion.html Serializes the OsVersion structure into a byte vector. This is useful for network transmission or storage. ```rust pub fn to_bytes(&self) -> Vec ``` -------------------------------- ### Hashing and Comparison Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.Flags.html Information on how Flags values are hashed and compared. ```APIDOC ## Hashing and Comparison for Flags ### Description This section details the implementations for `Hash`, `Eq`, `PartialEq`, `Ord`, and `PartialOrd` traits for the `Flags` type, enabling hashing and comparison operations. ### `impl Hash for Flags` #### `fn hash<__H: Hasher>(&self, state: &mut __H)` - **Description**: Feeds the `Flags` value into the given `Hasher`. - **Method**: `hash()` #### `fn hash_slice(data: &[Self], state: &mut H)` - **Description**: Feeds a slice of `Flags` values into the given `Hasher`. - **Method**: `hash_slice()` ### `impl Eq for Flags` - **Description**: Indicates that `Flags` values can be checked for equality. ### `impl PartialEq for Flags` #### `fn eq(&self, other: &Flags) -> bool` - **Description**: Tests if two `Flags` values are equal (`==`). - **Method**: `eq()` #### `fn ne(&self, other: &Rhs) -> bool` - **Description**: Tests if two `Flags` values are not equal (`!=`). - **Method**: `ne()` ### `impl Ord for Flags` #### `fn cmp(&self, other: &Flags) -> Ordering` - **Description**: Compares two `Flags` values and returns an `Ordering`. - **Method**: `cmp()` #### `fn max(self, other: Self) -> Self` - **Description**: Returns the maximum of two `Flags` values. - **Method**: `max()` #### `fn min(self, other: Self) -> Self` - **Description**: Returns the minimum of two `Flags` values. - **Method**: `min()` #### `fn clamp(self, min: Self, max: Self) -> Self` - **Description**: Restricts a `Flags` value to a certain interval. - **Method**: `clamp()` ### `impl PartialOrd for Flags` #### `fn partial_cmp(&self, other: &Flags) -> Option` - **Description**: Compares two `Flags` values and returns an optional `Ordering`. - **Method**: `partial_cmp()` #### `fn lt(&self, other: &Rhs) -> bool` - **Description**: Tests if `self` is less than `other` (`<`). - **Method**: `lt()` #### `fn le(&self, other: &Rhs) -> bool` - **Description**: Tests if `self` is less than or equal to `other` (`<=`). - **Method**: `le()` #### `fn gt(&self, other: &Rhs) -> bool` - **Description**: Tests if `self` is greater than `other` (`>`). - **Method**: `gt()` #### `fn ge(&self, other: &Rhs) -> bool` - **Description**: Tests if `self` is greater than or equal to `other` (`>=`). - **Method**: `ge()` ``` -------------------------------- ### CloneInto Method Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.NegotiateMessage.html The `clone_into` method efficiently replaces the contents of an owned `target` with data cloned from `self`. This is useful for in-place updates. ```rust fn clone_into(&self, target: &mut T) ``` -------------------------------- ### SecurityBuffer Methods Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.SecurityBuffer.html Implementation methods for the SecurityBuffer struct, including creation, serialization, and application to slices. ```APIDOC ## impl SecurityBuffer ### `pub fn for_slice(slice: &[u8]) -> Self` Generates a security buffer for the given slice of bytes. The length and capacity are set to the length of the slice, while the offset is set to 0. ### `pub fn to_bytes(&self) -> Vec` Serializes the security buffer into bytes. ### `pub fn apply_to_slice<'a>( &self, slice: &'a [u8], adjust: isize, ) -> Result<&'a [u8], ParsingError>` Applies the security buffer to a slice, extracting the data itself. The data is assumed to be located in `slice` beginning at `self.offset`. In case leading fields have been removed from `slice`, the offset may be further adjusted through `adjust`. ``` -------------------------------- ### Clone Implementation for ChallengeMessage Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Provides methods for cloning ChallengeMessage instances. Includes `clone` and `clone_from`. ```rust fn clone(&self) -> ChallengeMessage ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### OsVersion Parsing Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.OsVersion.html Method to convert a byte slice into an OsVersion structure. ```APIDOC ## fn try_from ### Description Performs the conversion from a byte slice to an OsVersion instance. ### Parameters #### Request Body - **value** (&[u8]) - Required - The byte slice to parse into an OsVersion. ### Response #### Success Response (200) - **Result** (OsVersion) - The parsed OsVersion structure. #### Error Response - **Error** (ParsingError) - Returned if the conversion fails. ``` -------------------------------- ### Implement Clone for ChallengeResponse Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Provides functionality to create a duplicate of a ChallengeResponse instance. ```rust fn clone(&self) -> ChallengeResponse ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Convert Target Info Data to String Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Converts the data within a TargetInfo entry to a UTF-16 LE string. Requires the `utf16_le_bytes_to_string` function. ```rust pub fn to_string(&self) -> Result { utf16_le_bytes_to_string(&self.data) } ``` -------------------------------- ### respond_challenge_ntlm_v1 Source: https://docs.rs/ntlmclient/latest/ntlmclient/fn.respond_challenge_ntlm_v1.html Calculates an NTLMv1 response to a given server challenge, including an LMv1 response. ```APIDOC ## respond_challenge_ntlm_v1 ### Description Calculates an NTLMv1 response to the given server challenge. An LMv1 response is also included. ### Parameters - **server_challenge** ([u8; 8]) - Required - The 8-byte server challenge. - **creds** (&Credentials) - Required - The user credentials used for the calculation. ### Response - **ChallengeResponse** - Returns a structure containing the calculated NTLMv1 and LMv1 responses. ``` -------------------------------- ### Operating System Version Structure Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Defines the structure for representing operating system version information, including the NTLM revision. ```APIDOC ## Struct OsVersion A structure representing the version of an operating system as well as the NTLM revision used. ### Fields - **major_version** (u8): The major version of the operating system. - **minor_version** (u8): The minor version of the operating system. - **build_number** (u16): The build number of the operating system. - **reserved** ([u8; 3]): Reserved bytes. - **ntlm_revision** (u8): The NTLM revision number. ### Default Implementation Provides a default `OsVersion` with all fields set to 0. ``` -------------------------------- ### clone_into Method Source: https://docs.rs/ntlmclient/latest/ntlmclient/enum.TargetInfoType.html Uses borrowed data to replace owned data, usually by cloning. ```APIDOC ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Method `clone_into` ### Parameters - **target** (&mut T) - Required - The mutable reference to the owned data to be replaced. ``` -------------------------------- ### Calculate NTLMv2 Challenge Response Source: https://docs.rs/ntlmclient/latest/ntlmclient/fn.respond_challenge_ntlm_v2.html Calculates an NTLMv2 response to a server challenge. Includes target info and time to prevent replay attacks. Requires server challenge, target info, time, and credentials. ```rust pub fn respond_challenge_ntlm_v2( server_challenge: [u8; 8], target_info: &[u8], time: i64, creds: &Credentials, ) -> ChallengeResponse ``` -------------------------------- ### Calculate NTLMv1 Challenge Response Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Calculates NTLMv1 and LMv1 responses to a server challenge, including a session key. ```rust pub fn respond_challenge_ntlm_v1(server_challenge: [u8; 8], creds: &Credentials) -> ChallengeResponse { let ntlm_key = ntlm_v1_password_func(&creds.password); let ntlm_response = Vec::from(des_long(ntlm_key, server_challenge)); let lm_key = lm_v1_password_func(&creds.password); let lm_response = Vec::from(des_long(lm_key, server_challenge)); let session_key = { let mut md4 = ::new(); md4.update(&ntlm_key); Vec::from(md4.finalize().as_slice()) }; ChallengeResponse { lm_response, ntlm_response, session_key, } } ``` -------------------------------- ### Formatting and Type Information Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.Flags.html Details on formatting Flags values and their underlying primitive type. ```APIDOC ## Formatting and Type Information for Flags ### Description This section covers the formatting implementations (`LowerHex`, `UpperHex`, `Octal`) and type information provided by the `PublicFlags` trait for the `Flags` type. ### `impl LowerHex for Flags` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` - **Description**: Formats the `Flags` value in lowercase hexadecimal. - **Method**: `fmt()` ### `impl UpperHex for Flags` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` - **Description**: Formats the `Flags` value in uppercase hexadecimal. - **Method**: `fmt()` ### `impl Octal for Flags` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` - **Description**: Formats the `Flags` value in octal. - **Method**: `fmt()` ### `impl PublicFlags for Flags` #### `type Primitive = u32` - **Description**: The underlying primitive type used for storing the flags (e.g., `u32`). #### `type Internal = InternalBitFlags` - **Description**: The internal type used for representing the flags within the implementation. ``` -------------------------------- ### respond_challenge_ntlm_v2 Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Calculates an NTLMv2 response to the given server challenge, including target info and time value to protect against replay attacks. ```APIDOC ## respond_challenge_ntlm_v2 ### Description Calculates an NTLMv2 response including target information and a timestamp to prevent replay attacks. ### Parameters - **server_challenge** ([u8; 8]) - Required - The 8-byte challenge provided by the server. - **target_info** (&[u8]) - Required - The target information blob. - **time** (i64) - Required - The timestamp for the challenge. - **creds** (Credentials) - Required - The user credentials. ### Response - **ChallengeResponse** (Object) - Returns an object containing lm_response, ntlm_response, and session_key. ``` -------------------------------- ### respond_challenge_ntlm_v2 Source: https://docs.rs/ntlmclient/latest/ntlmclient/fn.respond_challenge_ntlm_v2.html Calculates an NTLMv2 response to a server challenge to protect against replay attacks. ```APIDOC ## Function: respond_challenge_ntlm_v2 ### Description Calculates an NTLMv2 response to the given server challenge, including target info and time value to protect against replay attacks. ### Parameters - **server_challenge** ([u8; 8]) - Required - The 8-byte challenge received from the server. - **target_info** (&[u8]) - Required - The target information buffer. - **time** (i64) - Required - The timestamp value used for replay protection. - **creds** (&Credentials) - Required - The user credentials used for the response calculation. ### Response - **ChallengeResponse** - Returns a struct containing the calculated NTLMv2 response. ``` -------------------------------- ### Calculate NTLMv1 Challenge Response Source: https://docs.rs/ntlmclient/latest/ntlmclient/fn.respond_challenge_ntlm_v1.html Calculates an NTLMv1 response to a given server challenge, including an LMv1 response. Requires credentials and the server's challenge. ```rust pub fn respond_challenge_ntlm_v1( server_challenge: [u8; 8], creds: &Credentials, ) -> ChallengeResponse ``` -------------------------------- ### Construct NTLM Authenticate Message Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Constructs a full NTLM Authenticate message from challenge response data, credentials, workstation name, and flags. ```rust pub fn to_message(&self, creds: &Credentials, workstation_name: &str, flags: Flags) -> Message { Message::Authenticate(AuthenticateMessage { lm_response: self.lm_response.clone(), ntlm_response: self.ntlm_response.clone(), domain_name: creds.domain.clone(), user_name: creds.username.clone(), workstation_name: workstation_name.to_owned(), session_key: self.session_key.clone(), flags, os_version: Default::default(), }) } ``` -------------------------------- ### Credentials Struct Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.Credentials.html Represents standard NTLM credentials including username, password, and domain. ```APIDOC ## Struct Credentials ### Description Standard NTLM credentials, consisting of username, password and domain. ### Fields - **username** (String) - The username part of the credentials. - **password** (String) - The password part of the credentials. - **domain** (String) - The domain part of the credentials. Often specified in combination with the username as `\`. In credentials without a domain, the domain is an empty string. ### Request Example ```json { "username": "user", "password": "password", "domain": "DOMAIN" } ``` ### Response Example ```json { "username": "user", "password": "password", "domain": "DOMAIN" } ``` ``` -------------------------------- ### Conversion Traits (From, Into, TryFrom, TryInto) Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.AuthenticateMessage.html Standard library conversion traits implemented for generic types within the project. ```APIDOC ## Conversion Traits ### Description Provides standard conversion mechanisms between types. ### Methods - **from(t: T) -> T**: Returns the argument unchanged. - **into(self) -> U**: Calls U::from(self). - **try_from(value: U) -> Result**: Performs a fallible conversion. - **try_into(self) -> Result**: Performs a fallible conversion into a target type. ### Error Handling - **Error**: Infallible (for TryFrom/TryInto implementations). ``` -------------------------------- ### Implement Same for T Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Defines the associated type Output as Self. ```rust type Output = T ``` -------------------------------- ### Respond to NTLMv2 Challenge Source: https://docs.rs/ntlmclient/latest/index.html Calculates an NTLMv2 response to the given server challenge, including target info and time value to protect against replay attacks. ```APIDOC ## respond_challenge_ntlm_v2 ### Description Calculates an NTLMv2 response to the given server challenge, including target info and time value to protect against replay attacks. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters N/A (Function) ### Request Example N/A (Function) ### Response N/A (Function) ``` -------------------------------- ### NTLM Authentication Functions Source: https://docs.rs/ntlmclient A collection of functions for handling NTLMv1 and NTLMv2 challenge-response authentication and key derivation. ```APIDOC ## NTLM Authentication Functions ### Functions - **des_long**: Performs the NTLMv1 DES encryption to calculate the response value to the challenge. - **get_ntlm_time**: Obtains the current NTLM timestamp. - **lm_v1_password_func**: Derives the encryption key from a password according to the LMv1 scheme. - **ntlm_v1_password_func**: Derives the encryption key from a password according to the NTLMv1 scheme. - **ntlm_v2_password_func**: Derives the encryption key from a password according to the NTLMv2 scheme. - **respond_challenge_ntlm_v1**: Calculates an NTLMv1 response to the given server challenge. - **respond_challenge_ntlm_v2**: Calculates an NTLMv2 response to the given server challenge, including target info and time value to protect against replay attacks. - **respond_challenge_ntlm_v1_extended**: Calculates an extended NTLMv1 response to the given server challenge. - **respond_challenge_ntlm_v1_no_lm**: Calculates an NTLMv1 response to the given server challenge. ``` -------------------------------- ### VZip Trait Implementation Source: https://docs.rs/ntlmclient/latest/ntlmclient/enum.Message.html Details the VZip trait implementation for zipping operations. ```APIDOC ### impl VZip for T #### Description Implementation of the VZip trait for zipping operations. #### Method - **vzip**() -> V ### Description Performs a zipping operation. ### Method vzip ### Endpoint N/A ### Parameters None ### Request Example None ### Response - **V** - The result of the zipping operation. ``` -------------------------------- ### Convert ChallengeResponse to NTLM Message Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Converts the ChallengeResponse into a full NTLM Authenticate message. Requires credentials, workstation name, and flags. ```rust pub fn to_message( &self, creds: &Credentials, workstation_name: &str, flags: Flags, ) -> Message ``` -------------------------------- ### TryInto Trait Implementation Source: https://docs.rs/ntlmclient/latest/ntlmclient/enum.Message.html Details the TryInto trait implementation for converting one type into another, with error handling. ```APIDOC ### impl TryInto for T #### Description Implementation of the TryInto trait for type conversion. #### Type Alias - **Error** (>::Error) - The type returned in the event of a conversion error. #### Method - **try_into**() -> Result>::Error> ### Description Performs the conversion from type T to type U. ### Method try_into ### Endpoint N/A ### Parameters None ### Request Example None ### Response - **Ok(U)** - On successful conversion. - **Err(Error)** - On conversion failure. ``` -------------------------------- ### SecurityBuffer Trait Implementations Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.SecurityBuffer.html Overview of trait implementations for the SecurityBuffer struct, such as Clone, Debug, Default, and comparison traits. ```APIDOC ## Trait Implementations for SecurityBuffer ### `impl Clone for SecurityBuffer` Provides methods for cloning SecurityBuffer instances. ### `impl Debug for SecurityBuffer` Allows SecurityBuffer instances to be formatted for debugging. ### `impl Default for SecurityBuffer` Provides a default value for SecurityBuffer. ### `impl Hash for SecurityBuffer` Enables hashing of SecurityBuffer instances. ### `impl Ord for SecurityBuffer` Provides total ordering for SecurityBuffer instances. ### `impl PartialEq for SecurityBuffer` Enables equality comparison for SecurityBuffer instances. ### `impl PartialOrd for SecurityBuffer` Provides partial ordering for SecurityBuffer instances. ### `impl TryFrom<&[u8]> for SecurityBuffer` Allows conversion from a byte slice to a SecurityBuffer. ### `impl Eq for SecurityBuffer` Indicates that SecurityBuffer supports total equality. ### `impl StructuralPartialEq for SecurityBuffer` Indicates structural partial equality. ``` -------------------------------- ### TryFrom Trait Implementation Source: https://docs.rs/ntlmclient/latest/ntlmclient/enum.Message.html Details the TryFrom trait implementation for converting one type into another, with error handling. ```APIDOC ### impl TryFrom for T #### Description Implementation of the TryFrom trait for type conversion. #### Type Alias - **Error** (Infallible) - The type returned in the event of a conversion error. #### Method - **try_from**(value: U) -> Result>::Error> ### Description Performs the conversion from type U to type T. ### Method try_from ### Endpoint N/A ### Parameters - **value** (U) - Required - The value to convert. ### Request Example None ### Response - **Ok(T)** - On successful conversion. - **Err(Error)** - On conversion failure. ``` -------------------------------- ### Implement VZip for T Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeResponse.html Provides vector zipping functionality for types that support MultiLane. ```rust fn vzip(self) -> V ``` -------------------------------- ### Ord Implementation for ChallengeMessage Source: https://docs.rs/ntlmclient/latest/ntlmclient/struct.ChallengeMessage.html Enables ordering comparisons for ChallengeMessage instances. Includes `cmp`, `max`, `min`, and `clamp`. ```rust fn cmp(&self, other: &ChallengeMessage) -> Ordering ``` ```rust fn max(self, other: Self) -> Self where Self: Sized, ``` ```rust fn min(self, other: Self) -> Self where Self: Sized, ``` ```rust fn clamp(self, min: Self, max: Self) -> Self where Self: Sized, ``` -------------------------------- ### SecurityBuffer Operations Source: https://docs.rs/ntlmclient/latest/src/ntlmclient/lib.rs.html Methods for creating, serializing, and applying security buffers to byte slices. ```APIDOC ## SecurityBuffer::for_slice ### Description Generates a security buffer for the given slice of bytes. The length and capacity are set to the length of the slice, while the offset is set to 0. ### Parameters - **slice** (&[u8]) - Required - The byte slice to create a buffer for. ## SecurityBuffer::to_bytes ### Description Serializes the security buffer into a 8-byte vector (length, capacity, offset). ## SecurityBuffer::apply_to_slice ### Description Applies the security buffer to a slice, extracting the data itself based on the internal offset and length. ### Parameters - **slice** (&[u8]) - Required - The source byte slice. - **adjust** (isize) - Required - Adjustment value for the offset. ### Response - **Result<&[u8], ParsingError>** - The extracted data slice or a parsing error. ```