Payload

Enum Payload 

Source
pub enum Payload {
    Shellcode {
        bytes: Vec<u8>,
        metadata: PayloadMetadata,
    },
    DllFile {
        file_path: Option<PathBuf>,
        image_bytes: Option<Vec<u8>>,
        metadata: PayloadMetadata,
    },
    Executable {
        file_path: Option<PathBuf>,
        image_bytes: Option<Vec<u8>>,
        metadata: PayloadMetadata,
    },
    Script {
        language: String,
        script_code: String,
        metadata: PayloadMetadata,
    },
    Blob {
        content_type: String,
        data: Vec<u8>,
        metadata: PayloadMetadata,
    },
}
Expand description

A unified representation of the code or data to be injected.

This enum wraps the raw bytes or file paths of the payload and attaches PayloadMetadata to ensure operational context is carried throughout the injection lifecycle.

Variants§

§

Shellcode

Raw position-independent shellcode.

Fields

§bytes: Vec<u8>

The raw bytecode.

§

DllFile

A Dynamic Link Library (DLL), either as a file path or raw image bytes.

Fields

§file_path: Option<PathBuf>

The path to the DLL on disk, if available.

§image_bytes: Option<Vec<u8>>

The raw bytes of the DLL image.

§

Executable

A Portable Executable (EXE), either as a file path or raw image bytes.

Fields

§file_path: Option<PathBuf>

The path to the EXE on disk, if available.

§image_bytes: Option<Vec<u8>>

The raw bytes of the EXE image.

§

Script

A high-level script (e.g., PowerShell, Python, Bash) to be executed by an interpreter.

Fields

§language: String

The interpreter or language identifier (e.g., “ps1”, “python”).

§script_code: String

The source code of the script.

§

Blob

A generic binary blob with a specified content type.

Useful for stagers or data that does not fit standard executable formats.

Fields

§content_type: String

A MIME-type or custom identifier for the data format.

§data: Vec<u8>

The binary data.

Implementations§

Source§

impl Payload

Source

pub fn variant_name(&self) -> &'static str

Returns a string literal representing the variant name (e.g., “Shellcode”, “DllFile”).

Source

pub fn from_file( file_path: impl Into<PathBuf>, metadata: PayloadMetadata, ) -> Result<Self>

Creates a Payload from a file path, automatically detecting if it is a DLL or an EXE.

This function performs basic I/O to read the file and uses a lightweight PE header heuristic to determine the format.

§Errors

Returns an error if the file cannot be read.

Source

pub fn as_file_path(&self) -> Option<&Path>

Returns the file path if this payload is backed by a file on disk (DLL or Executable).

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Returns the raw bytes of the payload content, if available.

This is useful for techniques that require raw access, such as manual mapping or shellcode execution.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more