An emulation unit associated with a process. More...
#include <arion.hpp>
Public Member Functions | |
| ~Arion () | |
| void | set_run_bounds (std::optional< ADDR > start=std::nullopt, std::optional< ADDR > end=std::nullopt) |
| void | set_run_start (std::optional< ADDR > start) |
| void | set_run_end (std::optional< ADDR > end) |
| bool | run_current () |
| void | stop () |
| void | crash (std::exception_ptr exception) |
| void | sync_threads () |
| bool | is_running () |
| void | init_afl_mode (std::vector< int > signals) |
| void | stop_afl_mode () |
| std::shared_ptr< Arion > | copy () |
| bool | has_parent () |
| std::shared_ptr< Arion > | get_parent () |
| std::vector< std::shared_ptr< Arion > > | get_children () |
| std::vector< std::shared_ptr< Arion > > | get_pgid_children (pid_t pgid) |
| pid_t | add_child (std::shared_ptr< Arion > child) |
| bool | has_child (pid_t child_pid) |
| bool | is_child_of (pid_t parent_pid) |
| std::shared_ptr< Arion > | get_child (pid_t child_pid) |
| void | replace_child (pid_t child_pid, std::shared_ptr< Arion > child) |
| void | remove_child (pid_t child_pid) |
| void | clear_children () |
| void | execve (std::string file_path, std::vector< std::string > argv, std::vector< std::string > envp) |
| std::vector< std::string > | get_program_args () |
| std::vector< std::string > | get_program_env () |
| pid_t | get_pid () |
| void | set_pid (pid_t pid) |
| pid_t | get_pgid () |
| void | set_pgid (pid_t pgid) |
| uint32_t | get_sid () |
| void | set_sid (uint32_t sid) |
| uint32_t | get_uid () |
| void | set_uid (uint32_t uid) |
| uint32_t | get_gid () |
| void | set_gid (uint32_t gid) |
| uint32_t | get_euid () |
| void | set_euid (uint32_t euid) |
| uint32_t | get_egid () |
| void | set_egid (uint32_t egid) |
| bool | has_group () |
| std::shared_ptr< ArionGroup > | get_group () |
| void | set_group (std::shared_ptr< ArionGroup > group) |
| void | reset_group () |
| bool | is_stopped () |
| void | set_stopped () |
| void | set_resumed () |
| bool | is_zombie () |
| void | set_zombie () |
| void | send_signal (pid_t source_pid, int signo) |
| void | run_gdbserver (uint32_t port) |
Static Public Member Functions | |
| static std::shared_ptr< Arion > | new_instance (std::vector< std::string > program_args, std::string fs_path="/", std::vector< std::string > program_env=std::vector< std::string >(), std::string cwd="", std::unique_ptr< Config > config=std::move(std::make_unique< Config >())) |
| static std::shared_ptr< Arion > | new_instance (std::unique_ptr< BaremetalManager > baremetal, std::string fs_path="/", std::vector< std::string > program_env=std::vector< std::string >(), std::string cwd="", std::unique_ptr< Config > config=std::move(std::make_unique< Config >())) |
Public Attributes | |
| std::unique_ptr< ArchManager > | arch |
| ArchManager instance associated with this instance. | |
| std::unique_ptr< BaremetalManager > | baremetal |
| BaremetalManager instance associated with this instance. | |
| std::unique_ptr< MemoryManager > | mem |
| MemoryManager instance associated with this instance. | |
| std::unique_ptr< FileSystemManager > | fs |
| FileSystemManager instance associated with this instance. | |
| std::unique_ptr< SocketManager > | sock |
| SocketManager instance associated with this instance. | |
| std::unique_ptr< HooksManager > | hooks |
| HooksManager instance associated with this instance. | |
| std::unique_ptr< ThreadingManager > | threads |
| ThreadingManager instance associated with this instance. | |
| std::unique_ptr< SignalManager > | signals |
| SignalManager instance associated with this instance. | |
| std::unique_ptr< ContextManager > | context |
| ContextManager instance associated with this instance. | |
| std::unique_ptr< LinuxSyscallManager > | syscalls |
| LinuxSyscallManager instance associated with this instance. | |
| std::unique_ptr< GdtManager > | gdt_manager |
| GdtManager instance associated with this instance. | |
| std::unique_ptr< CodeTracer > | tracer |
| CodeTracer instance associated with this instance. | |
| std::unique_ptr< Logger > | logger |
| Logger instance associated with this instance. | |
| std::unique_ptr< Config > | config |
| Config instance associated with this instance. | |
| std::unique_ptr< LNX_LOADER_PARAMS > | loader_params |
| Parameters related to the loader action. | |
| std::vector< std::shared_ptr< SIGNAL > > | pending_signals |
| List of signals to be processed by this instance. | |
| uc_engine * | uc |
| Unicorn engine related to this instance. | |
| std::vector< ks_engine * > | ks |
| Keystone engine related to this instance. | |
| std::vector< csh * > | cs |
| Capstone engine related to this instance. | |
Private Member Functions | |
| void | init_engines (CPU_ARCH arch) |
| void | init_file_program (std::shared_ptr< ExecutableParser > prog_parser) |
| void | init_baremetal_program () |
| void | init_dynamic_program (std::shared_ptr< ExecutableParser > prog_parser) |
| void | init_static_program (std::shared_ptr< ExecutableParser > prog_parser) |
| void | close_engines () |
Static Private Member Functions | |
| static void | new_instance_common_init (std::shared_ptr< Arion > arion, std::string fs_path="/", std::vector< std::string > program_env=std::vector< std::string >(), std::string cwd="", std::unique_ptr< Config > config=std::move(std::make_unique< Config >())) |
| static void | new_instance_common_finish (std::shared_ptr< Arion > arion, CPU_ARCH arch) |
Private Attributes | |
| std::vector< std::string > | program_args |
| The program arguments of the emulated process, basically the "argv" array. | |
| std::vector< std::string > | program_env |
| The program environment variables of the emulated process, basically the "envp" array. | |
| std::weak_ptr< ArionGroup > | group |
| The ArionGroup this process is associated with. Arion instances are emulated together through their group. | |
| std::weak_ptr< Arion > | parent |
| The Arion instance emulating the parent process of this process. | |
| std::vector< std::weak_ptr< Arion > > | children |
| The Arion instances emulating the child processes of this process. | |
| std::exception_ptr | uc_exception = nullptr |
| An Unicorn exception that occurred during execution and needs to be rethrown. | |
| bool | afl_mode = false |
| True if this Arion instance is being run through the ArionAfl component. | |
| std::vector< int > | afl_signals |
| List of UNIX signals that must be considered as process crashes when fuzzing with ArionAfl component. | |
| std::optional< ADDR > | start = std::nullopt |
| Start address for the emulation. | |
| std::optional< ADDR > | end = std::nullopt |
| End address for the emulation. | |
| bool | running = false |
| True if this instance is currently being run by its ArionGroup. | |
| bool | sync = false |
| True if the emulation was stopped in order to synchronize the states of its threads. | |
| bool | stopped = false |
| True if the emulation is currently stopped. | |
| bool | zombie = false |
| True if the emulation has ended for this instance but not for its parent. | |
| pid_t | pid = 0 |
| The PID associated with the emulated process. | |
| pid_t | pgid = 0 |
| The PGID associated with the emulated process. | |
| uint32_t | sid = 0 |
| The SID associated with the emulated process. | |
| uint32_t | uid = 0 |
| The UID associated with the emulated process. | |
| uint32_t | gid = 0 |
| The GID associated with the emulated process. | |
| uint32_t | euid = 0 |
| The EUID associated with the emulated process. | |
| uint32_t | egid = 0 |
| The EGID associated with the emulated process. | |
An emulation unit associated with a process.
| arion::Arion::~Arion | ( | ) |
Destructor method for Arion instances, destroying related instances and engines, and releasing pointers.
| pid_t arion::Arion::add_child | ( | std::shared_ptr< Arion > | child | ) |
| void arion::Arion::clear_children | ( | ) |
Removes all processes in the "children" list of this Arion instance.
|
private |
Performs the destruction of engines related to CPU emulation, assembly and disassembly.
| std::shared_ptr< Arion > arion::Arion::copy | ( | ) |
| void arion::Arion::crash | ( | std::exception_ptr | exception | ) |
Stops emulating the process associated with this Arion instance with an exception to be rethrown.
| [in] | exception | The exception to be rethrown. |
| void arion::Arion::execve | ( | std::string | file_path, |
| std::vector< std::string > | argv, | ||
| std::vector< std::string > | envp | ||
| ) |
Replaces the image of the process associated with this Arion instance with a new one, like in the execv* syscalls.
| [in] | file_path | Path to the file of the new process (executable). |
| [in] | argv | The program arguments of the newly emulated process. |
| [in] | envp | The program environment variables of the newly emulated process. |
| std::shared_ptr< Arion > arion::Arion::get_child | ( | pid_t | child_pid | ) |
| std::vector< std::shared_ptr< Arion > > arion::Arion::get_children | ( | ) |
| uint32_t arion::Arion::get_egid | ( | ) |
Retrieves the Effective Group ID (EGID) associated with this Arion instance.
| uint32_t arion::Arion::get_euid | ( | ) |
Retrieves the Effective User ID (EUID) associated with this Arion instance.
| uint32_t arion::Arion::get_gid | ( | ) |
Retrieves the Group ID (GID) associated with this Arion instance.
| std::shared_ptr< ArionGroup > arion::Arion::get_group | ( | ) |
Retrieves the ArionGroup instance associated with this Arion instance.
| std::shared_ptr< Arion > arion::Arion::get_parent | ( | ) |
| pid_t arion::Arion::get_pgid | ( | ) |
Retrieves the Process Group ID (PGID) associated with this Arion instance.
| std::vector< std::shared_ptr< Arion > > arion::Arion::get_pgid_children | ( | pid_t | pgid | ) |
| pid_t arion::Arion::get_pid | ( | ) |
Returns the Process ID (PID) associated with this Arion instance.
| std::vector< std::string > arion::Arion::get_program_args | ( | ) |
Retrieves the program arguments associated with this Arion instance.
| std::vector< std::string > arion::Arion::get_program_env | ( | ) |
Retrieves the program environment variables associated with this Arion instance.
| uint32_t arion::Arion::get_sid | ( | ) |
Retrieves the Session ID (SID) associated with this Arion instance.
| uint32_t arion::Arion::get_uid | ( | ) |
Retrieves the User ID (UID) associated with this Arion instance.
| bool arion::Arion::has_child | ( | pid_t | child_pid | ) |
| bool arion::Arion::has_group | ( | ) |
Checks whether this Arion instance is part of an ArionGroup instance.
| bool arion::Arion::has_parent | ( | ) |
| void arion::Arion::init_afl_mode | ( | std::vector< int > | signals | ) |
Initialize this Arion instance with parameters related to AFL fuzzing.
| [in] | signals | The list of signals which will be considered as crashes during the fuzzing session. |
|
private |
Performs the initialization steps specific to a baremetal process.
|
private |
Performs the initialization steps specific to a dynamic process.
| [in] | prog_parser | The ExecutableParser instance that analyzed the program file. |
|
private |
Performs the initialization of engines related to CPU emulation, assembly and disassembly.
| [in] | The | CPU architecture to be emulated for this process. |
|
private |
Performs the initialization steps specific to a file based process (executable).
| [in] | prog_parser | The ExecutableParser instance that analyzed the program file. |
|
private |
Performs the initialization steps specific to a static process.
| [in] | prog_parser | The ExecutableParser instance that analyzed the program file. |
| bool arion::Arion::is_child_of | ( | pid_t | parent_pid | ) |
| bool arion::Arion::is_running | ( | ) |
| bool arion::Arion::is_stopped | ( | ) |
Checks whether the emulation is currently stopped.
| bool arion::Arion::is_zombie | ( | ) |
Checks whether the emulation has ended for this instance but not for its parent.
|
static |
Initialization method of Arion instances for baremetal programs.
| [in] | baremetal | A BaremetalManager instance containing parameters to initialize this Arion instance. |
| [in] | fs_path | Path to the root directory for the file system of the emulated process (optional). |
| [in] | program_env | The program environment variables of the emulated process, basically the "envp" array (optional). |
| [in] | cwd | The current working directory for the emulated process (optional). |
| [in] | config | An instance of Config associated with this Arion instance (optional). |
|
static |
Initialization method of Arion instances for file programs (executables).
| [in] | program_args | The program arguments of the emulated process, basically the "argv" array. |
| [in] | fs_path | Path to the root directory for the file system of the emulated process (optional). |
| [in] | program_env | The program environment variables of the emulated process, basically the "envp" array (optional). |
| [in] | cwd | The current working directory for the emulated process (optional). |
| [in] | config | An instance of Config associated with this Arion instance (optional). |
|
staticprivate |
Performs the final steps to initialize this Arion instance, no matter the nature of the emulated process.
| [in] | arion | The arion instance being initialized. |
| [in] | arch | The CPU architecture to be emulated for this process. |
|
staticprivate |
Performs the first steps to initialize this Arion instance, no matter the nature of the emulated process.
| [in] | arion | The Arion instance being initialized. |
| [in] | fs_path | Path to the root directory for the file system of the emulated process (optional). |
| [in] | program_env | The program environment variables of the emulated process (optional), basically the "envp" array. |
| [in] | cwd | The current working directory for the emulated process (optional). |
| [in] | config | An instance of Config associated with this Arion instance (optional). |
| void arion::Arion::remove_child | ( | pid_t | child_pid | ) |
Unmarks a process from the "children" list of the process associated with this Arion instance.
| child_pid | PID of the process to be unmarked from the "children" list of this process. |
| void arion::Arion::replace_child | ( | pid_t | child_pid, |
| std::shared_ptr< Arion > | child | ||
| ) |
| void arion::Arion::reset_group | ( | ) |
Sets this instance as part of no ArionGroup.
| bool arion::Arion::run_current | ( | ) |
Starts emulating the process associated with this Arion instance.
| void arion::Arion::run_gdbserver | ( | uint32_t | port | ) |
Starts a GDB Server session on the given port.
| [in] | port | The port. |
| void arion::Arion::send_signal | ( | pid_t | source_pid, |
| int | signo | ||
| ) |
Delivers a signal to be processed by this process.
| [in] | source_pid | The Process ID delivering the signal to the process associated with this Arion instance. |
| [in] | signo | The signal number. |
| void arion::Arion::set_egid | ( | uint32_t | egid | ) |
Defines the Effective Group ID (EGID) associated with this Arion instance.
| [in] | egid | The new EGID. |
| void arion::Arion::set_euid | ( | uint32_t | euid | ) |
Defines the Effective User ID (EUID) associated with this Arion instance.
| [in] | euid | The new EUID. |
| void arion::Arion::set_gid | ( | uint32_t | gid | ) |
Defines the Group ID (GID) associated with this Arion instance.
| [in] | gid | The new GID. |
| void arion::Arion::set_group | ( | std::shared_ptr< ArionGroup > | group | ) |
Defines the ArionGroup instance associated with this Arion instance.
| [in] | group | The new ArionGroup for this instance. |
| void arion::Arion::set_pgid | ( | pid_t | pgid | ) |
Defines the Process Group ID (PGID) associated with this Arion instance.
| [in] | pgid | The new PGID. |
| void arion::Arion::set_pid | ( | pid_t | pid | ) |
Defines the Process ID (PID) associated with this Arion instance.
| [in] | pid | The new PID. |
| void arion::Arion::set_resumed | ( | ) |
Marks the emulation as running.
| void arion::Arion::set_run_bounds | ( | std::optional< ADDR > | start = std::nullopt, |
| std::optional< ADDR > | end = std::nullopt |
||
| ) |
Used to define start and end addresses for the emulation.
| [in] | start | Start address for the emulation. |
| [in] | end | End address for the emulation. |
| void arion::Arion::set_run_end | ( | std::optional< ADDR > | end | ) |
Used to define end address for the emulation.
| [in] | end | End address for the emulation. |
| void arion::Arion::set_run_start | ( | std::optional< ADDR > | start | ) |
Used to define start address for the emulation.
| [in] | start | Start address for the emulation. |
| void arion::Arion::set_sid | ( | uint32_t | sid | ) |
Defines the Session ID (SID) associated with this Arion instance.
| [in] | sid | The new SID. |
| void arion::Arion::set_stopped | ( | ) |
Marks the emulation as stopped.
| void arion::Arion::set_uid | ( | uint32_t | uid | ) |
Defines the User ID (UID) associated with this Arion instance.
| [in] | uid | The new UID. |
| void arion::Arion::set_zombie | ( | ) |
Marks this process as a zombie (emulation stopped but parent still running).
| void arion::Arion::stop | ( | ) |
Stops emulating the process associated with this Arion instance.
| void arion::Arion::stop_afl_mode | ( | ) |
Clear out paremeters related to AFL fuzzing.
| void arion::Arion::sync_threads | ( | ) |
Stops the emulation in order to synchronize the states of its threads. Emulation will be resumed after that synchronization.
|
private |
|
private |
List of UNIX signals that must be considered as process crashes when fuzzing with ArionAfl component.
| std::unique_ptr<ArchManager> arion::Arion::arch |
ArchManager instance associated with this instance.
| std::unique_ptr<BaremetalManager> arion::Arion::baremetal |
BaremetalManager instance associated with this instance.
|
private |
The Arion instances emulating the child processes of this process.
| std::unique_ptr<ContextManager> arion::Arion::context |
ContextManager instance associated with this instance.
| std::vector<csh *> arion::Arion::cs |
Capstone engine related to this instance.
|
private |
The EGID associated with the emulated process.
|
private |
End address for the emulation.
|
private |
The EUID associated with the emulated process.
| std::unique_ptr<FileSystemManager> arion::Arion::fs |
FileSystemManager instance associated with this instance.
| std::unique_ptr<GdtManager> arion::Arion::gdt_manager |
GdtManager instance associated with this instance.
|
private |
The GID associated with the emulated process.
|
private |
The ArionGroup this process is associated with. Arion instances are emulated together through their group.
| std::unique_ptr<HooksManager> arion::Arion::hooks |
HooksManager instance associated with this instance.
| std::vector<ks_engine *> arion::Arion::ks |
Keystone engine related to this instance.
| std::unique_ptr<LNX_LOADER_PARAMS> arion::Arion::loader_params |
Parameters related to the loader action.
| std::unique_ptr<MemoryManager> arion::Arion::mem |
MemoryManager instance associated with this instance.
|
private |
The Arion instance emulating the parent process of this process.
| std::vector<std::shared_ptr<SIGNAL> > arion::Arion::pending_signals |
List of signals to be processed by this instance.
|
private |
The PGID associated with the emulated process.
|
private |
The PID associated with the emulated process.
|
private |
The program arguments of the emulated process, basically the "argv" array.
|
private |
The program environment variables of the emulated process, basically the "envp" array.
|
private |
True if this instance is currently being run by its ArionGroup.
|
private |
The SID associated with the emulated process.
| std::unique_ptr<SignalManager> arion::Arion::signals |
SignalManager instance associated with this instance.
| std::unique_ptr<SocketManager> arion::Arion::sock |
SocketManager instance associated with this instance.
|
private |
Start address for the emulation.
|
private |
True if the emulation is currently stopped.
|
private |
True if the emulation was stopped in order to synchronize the states of its threads.
| std::unique_ptr<LinuxSyscallManager> arion::Arion::syscalls |
LinuxSyscallManager instance associated with this instance.
| std::unique_ptr<ThreadingManager> arion::Arion::threads |
ThreadingManager instance associated with this instance.
| std::unique_ptr<CodeTracer> arion::Arion::tracer |
CodeTracer instance associated with this instance.
| uc_engine* arion::Arion::uc |
Unicorn engine related to this instance.
|
private |
An Unicorn exception that occurred during execution and needs to be rethrown.
|
private |
The UID associated with the emulated process.
|
private |
True if the emulation has ended for this instance but not for its parent.