mod base64;
pub mod caesar;
pub mod hex;
mod json;
mod pipeline;
pub mod reverse;
mod unicode_escape;
mod url;
pub mod util;
pub use base64::{base64_decode, find_base64_strings, z85_decode};
pub use hex::hex_decode;
pub use pipeline::{decode_chunk, register_decoder};
use keyhog_core::Chunk;
const MIN_DECODABLE_RUN: usize = 24;
pub(crate) fn has_decodable_payload(data: &[u8]) -> bool {
let mut run = 0usize;
for &b in data {
let encoded_byte =
b.is_ascii_alphanumeric() || matches!(b, b'+' | b'/' | b'=' | b'-' | b'_');
if encoded_byte {
run += 1;
if run >= MIN_DECODABLE_RUN {
return true;
}
} else {
run = 0;
}
}
false
}
pub trait Decoder: Send + Sync {
fn name(&self) -> &'static str;
fn decode_chunk(&self, chunk: &Chunk) -> Vec<Chunk>;
}
pub struct EncodedString {
pub value: String,
}