|
| 1 | +COMPEL(1) |
| 2 | +========== |
| 3 | +include::footer.txt[] |
| 4 | + |
| 5 | +NAME |
| 6 | +---- |
| 7 | +compel - Execute parasitic code within another process. |
| 8 | + |
| 9 | +SYNOPSIS |
| 10 | +-------- |
| 11 | +*compel* 'hgen' ['option' ...] |
| 12 | + |
| 13 | +*compel* 'plugins' ['PLUGIN_NAME' ...] |
| 14 | + |
| 15 | +*compel* ['--compat'] 'includes' | 'cflags' | 'ldflags' |
| 16 | + |
| 17 | +*compel* ['--compat'] ['--static'] 'libs' |
| 18 | + |
| 19 | +DESCRIPTION |
| 20 | +------------ |
| 21 | +*compel* is a utility to execute arbitrary code, also called parasite code, |
| 22 | +in the context of a foreign process. The parasitic code, once compiled with |
| 23 | +compel flags and packed, can be executed in the context of other tasks. Currently |
| 24 | +there is only one way to load the parasitic blob into victim task using libcompel.a, |
| 25 | +called c-header. |
| 26 | + |
| 27 | +ARGUMENTS |
| 28 | +---------- |
| 29 | + |
| 30 | +Positional Arguments |
| 31 | +~~~~~~~~~~~~~~~~~~~~ |
| 32 | + |
| 33 | +*hgen*:: |
| 34 | + create a header from the .po file, which is the parasite binary. |
| 35 | + |
| 36 | +*plugins*:: |
| 37 | + prints the plugins available. |
| 38 | + |
| 39 | +*ldflags*:: |
| 40 | + prints the ldflags available to compel during linking of parasite code. |
| 41 | + |
| 42 | +*cflags*:: |
| 43 | + prints the compel cflags to be used during compilation of parasitic code. |
| 44 | + |
| 45 | +*includes*:: |
| 46 | + prints list of standard include directories. |
| 47 | + |
| 48 | +*libs*:: |
| 49 | + prints list of static or dynamic libraries that compel can link with. |
| 50 | + |
| 51 | +OPTIONS |
| 52 | +-------- |
| 53 | +*-f*, *--file* 'FILE':: |
| 54 | + Path to the binary file, 'FILE', which *compel* must turn into a header |
| 55 | + |
| 56 | +*-o*, *--output* 'FILE':: |
| 57 | + Path to the header file, 'FILE', where compel must write the resulting header. |
| 58 | + |
| 59 | +*-p*, *--prefix* 'NAME':: |
| 60 | + Specify prefix for var names |
| 61 | + |
| 62 | +*-l*, *--log-level* 'NUM':: |
| 63 | + Default log level of compel. |
| 64 | + |
| 65 | +*-h*, *--help*:: |
| 66 | + Prints usage and exits. |
| 67 | + |
| 68 | +*-V*, *--version*:: |
| 69 | + Prints version number of compel. |
| 70 | + |
| 71 | +SOURCE EXAMPLES |
| 72 | +---------------- |
| 73 | + |
| 74 | +Parasitic Code |
| 75 | +~~~~~~~~~~~~~~ |
| 76 | + |
| 77 | +*#include <compel/plugins/std.h>* |
| 78 | + |
| 79 | +*int parasite_trap_cmd(int cmd, void *args);* //gets called by compel_run_in_thread() |
| 80 | + |
| 81 | +*int parasite_daemon_cmd(int cmd, void *arg);* // gets called by compel_rpc_call() and compel_rpc_call_sync() |
| 82 | + |
| 83 | +*void parasite_cleanup(void);* //gets called on parasite unload by compel_cure() |
| 84 | + |
| 85 | +Infecting code |
| 86 | +~~~~~~~~~~~~~~ |
| 87 | +The parasitic code is compiled and converted to a header using *compel*, and included here. |
| 88 | + |
| 89 | +*#include <compel/compel.h>* |
| 90 | + |
| 91 | +*#include "parasite.h"* |
| 92 | + |
| 93 | +Following steps are perfomed to infect the victim process: |
| 94 | + |
| 95 | + - stop the task: *int compel_stop_task(int pid);* |
| 96 | + - prepare infection handler: *struct parasite_ctl *compel_prepare(int pid);* |
| 97 | + - execute system call: *int compel_syscall(ctl, int syscall_nr, long *ret, int arg ...);* |
| 98 | + - infect victim: *int compel_infect(ctl, nr_thread, size_of_args_area);* |
| 99 | + - cure the victim: *int compel_cure(ctl);* //ctl pointer is freed by this call |
| 100 | + - Resume victim: *int compel_resume_task(pid, orig_state, state);* |
| 101 | + |
| 102 | +*ctl* must be configured with blob information by calling *PREFIX_setup_c_header()*, with ctl as its argument. |
| 103 | +*PREFIX* is the argument given to *-p* when calling hgen, else it is deduced from file name. |
| 104 | + |
| 105 | + |
| 106 | +EXAMPLES |
| 107 | +--------- |
| 108 | +To generate a header file(.h) from a parasite binary file(.po) use: |
| 109 | + |
| 110 | +---------- |
| 111 | + compel hgen -f parasite.po -o parasite.h |
| 112 | +---------- |
| 113 | + |
| 114 | +'parasite.po' file is obtained by compiling the parasite source with compel flags and |
| 115 | +linking it with the compel plugins. |
| 116 | + |
| 117 | +AUTHOR |
| 118 | +------ |
| 119 | +The CRIU team. |
0 commit comments