Skip to content

Commit

Permalink
Fix typos and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mkozlowski committed Jul 19, 2024
1 parent 80a676b commit 1708176
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ memcr -p <target pid>
```
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)
Expand All @@ -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:
```
Expand Down
18 changes: 9 additions & 9 deletions memcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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++) {
Expand All @@ -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++) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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" \
Expand All @@ -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);
Expand Down

0 comments on commit 1708176

Please sign in to comment.