From 5fd208cfd01f523a5a4460eed300c5be945bbd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Koz=C5=82owski?= Date: Fri, 19 Jul 2024 11:38:43 +0200 Subject: [PATCH] Fix typos and update README --- README.md | 13 +++++++++---- memcr.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index dd6f326..8cac5f1 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,15 @@ memcr -p ``` For the list of available options, check memcr help: ``` -memcr [-h] [-p PID] [-d DIR] [-S DIR] [-l PORT|PATH] [-n] [-m] [-f] [-z] [-c] [-e] +memcr [-h] [-p PID] [-d DIR] [-S DIR] [-l PORT|PATH] [-n] [-m] [-f] [-z] [-c] [-e] [-V] options: -h --help help - -p --pid target processs pid + -p --pid target process pid -d --dir dir where memory dump is stored (defaults to /tmp) - -S --parasite-socket-dir dir where socket to communicate with parasite is created + -S --parasite-socket-dir dir where socket to communicate with parasite is created (abstract socket will be used if no path specified) + -N --parasite-socket-netns use network namespace of parasite when connecting to socket + (useful if parasite is running in a container with netns) -l --listen work as a service waiting for requests on a socket -l PORT: TCP port number to listen for requests on -l PATH: filesystem path for UNIX domain socket file (will be created) @@ -68,8 +70,11 @@ options: -z --compress compress memory dump -c --checksum enable md5 checksum for memory dump -e --encrypt enable encryption of memory dump + -t --timeout timeout in seconds for checkpoint/restore execution in service mode + -V --version print version and exit + ``` -memcr also supports client / server scenario where memcr runs as a deamon and listens for commands from a client process. The main reason for supporting this is that memcr needs rather high privileges to hijack target process and it's a good idea to keep it separate from memcr-client that can run in a container with low privileges. +memcr also supports client / server scenario where memcr runs as a daemon and listens for commands from a client process. The main reason for supporting this is that memcr needs rather high privileges to hijack target process and it's a good idea to keep it separate from memcr-client that can run in a container with low privileges. memcr daemon: ``` diff --git a/memcr.c b/memcr.c index 264912f..08c5c84 100644 --- a/memcr.c +++ b/memcr.c @@ -364,7 +364,7 @@ static void parasite_status_signal(pid_t pid, int status) else printf("[i] parasite terminated by signal %d%s\n", WTERMSIG(status), WCOREDUMP(status) ? " (code dumped)" : " "); else - printf("[-] unhandled prasite status %x\n", status); + printf("[-] unhandled parasite status %x\n", status); } static int parasite_status_wait(int *status) @@ -1891,7 +1891,7 @@ static int peek(pid_t pid, unsigned long *addr, unsigned long *dst, size_t len) { int i; - /* len must be a mutliple of CPU word size */ + /* len must be a multiple of CPU word size */ assert(len % sizeof(unsigned long) == 0); for (i = 0; i < (len / sizeof(unsigned long)); i++) { @@ -1911,7 +1911,7 @@ static int poke(pid_t pid, unsigned long *addr, unsigned long *src, size_t len) int ret; int i; - /* len must be a mutliple of CPU word size */ + /* len must be a multiple of CPU word size */ assert(len % sizeof(unsigned long) == 0); for (i = 0; i < (len / sizeof(unsigned long)); i++) { @@ -1964,7 +1964,7 @@ static unsigned long execute_blob(struct target_context *ctx, const char *blob, * there isn't much we can do about KILL handling. * * So, regardless of signo, we can simply retry after - * control returns to jboctl trap. + * control returns to jobctl trap. * * Note that if signal is delivered between syscall and the * trapping instruction in the blob, the syscall might be @@ -2509,7 +2509,7 @@ static int checkpoint_procedure_service(int checkpointSocket, int cd, int pid, i return svc_resp.resp_code; } else { fprintf(stderr, "[!] Error reading checkpoint response from worker!\n"); - // unnable to read response from worker, kill both + // unable to read response from worker, kill both kill(pid, SIGKILL); kill(worker_pid, SIGKILL); send_response_to_client(cd, MEMCR_ERROR_GENERAL); @@ -2548,7 +2548,7 @@ static void restore_procedure_service(int cd, struct service_command svc_cmd, in if (ret != sizeof(struct service_response)) { fprintf(stderr, "[-] %s() read() svc_resp failed: ret %d\n", __func__, ret); - // unnable to read response from worker, kill both + // unable to read response from worker, kill both kill(svc_cmd.pid, SIGKILL); kill(worker_pid, SIGKILL); ret = -1; @@ -2844,9 +2844,9 @@ static void usage(const char *name, int status) "%s [-h] [-p PID] [-d DIR] [-S DIR] [-l PORT|PATH] [-n] [-m] [-f] [-z] [-c] [-e] [-V]\n" \ "options:\n" \ " -h --help help\n" \ - " -p --pid target processs pid\n" \ + " -p --pid target process pid\n" \ " -d --dir dir where memory dump is stored (defaults to /tmp)\n" \ - " -S --parasite-socket-dir dir where socket to communicate with parasite is created\n" \ + " -S --parasite-socket-dir dir where socket to communicate with parasite is created\n" \ " (abstract socket will be used if no path specified)\n" \ " -N --parasite-socket-netns use network namespace of parasite when connecting to socket\n" \ " (useful if parasite is running in a container with netns)\n" \ @@ -2860,7 +2860,7 @@ static void usage(const char *name, int status) " -c --checksum enable md5 checksum for memory dump\n" \ " -e --encrypt enable encryption of memory dump\n" \ " -t --timeout timeout in seconds for checkpoint/restore execution in service mode\n" \ - " -v --version print version and exit\n", + " -V --version print version and exit\n", name); exit(status);