Class Target

Class Documentation

class Target

Represents a specific kernel target with its symbols, ROP gadgets, and other definitions.

Public Functions

Target(const std::string &distro, const std::string &release_name, const std::string &version = "")

Constructor for a Target.

Parameters:
  • distro – The distribution name.

  • release_name – The release name.

  • version – The version string (optional).

const std::string &GetDistro() const
const std::string &GetReleaseName() const
const std::string &GetVersion() const
uint32_t GetSymbolOffset(std::string symbol_name)

Get the offset of a symbol within the target.

Parameters:

symbol_name – The name of the symbol.

Throws:

ExpKitError – if the symbol is not found or has an offset of 0.

Returns:

The offset of the symbol.

std::vector<RopItem> GetRopActionItems(RopActionId id)

Get the ROP items for a specific ROP action ID.

Parameters:

id – The ROP action ID.

Throws:

ExpKitError – if the ROP action ID is not found.

Returns:

A vector of ROP items for the specified action.

const Struct &GetStruct(const std::string &name)
const Pivots &GetPivots()
std::map<std::string, uint32_t> GetAllSymbols()
void AddSymbol(const std::string &name, uint64_t value)

Add a symbol to the target.

Parameters:
  • name – The name of the symbol.

  • value – The value (offset) of the symbol without the base address.

void AddRopAction(const std::string &name, std::vector<RopItem> value)

Add a ROP Action to the target.

Parameters:
  • name – The name of the ROP Action.

  • value – The ROP Action items (array of RopItem).

void AddStruct(const Struct &value)

Add a struct definition to the target.

Parameters:

value – The struct structure

void AddStruct(const std::string &name, uint64_t size, const std::vector<StructField> &fields)

Add a struct definition to the target.

Parameters:
  • name – The name of the struct.

  • size – The size of the struct.

  • fields – A vector of StructField objects representing the fields of the struct.

void SetPivots(const Pivots &pivots)

Sets the Pivots struct for the target.

Parameters:

pivots – The pivots struct

void Merge(const Target &src)
uint64_t GetStructSize(const std::string &struct_name)
uint64_t GetFieldOffset(const std::string &struct_name, const std::string &field_name)
uint64_t GetFieldSize(const std::string &struct_name, const std::string &field_name)

Protected Attributes

std::string distro
std::string release_name
std::string version
std::map<std::string, uint32_t> symbols
std::map<std::string, std::vector<RopItem>> rop_actions
std::map<std::string, Struct> structs
Pivots pivots