0

我正在尝试一些逆向工程,但我对如何进行内存修补感到有些困惑。我的目标二进制文件是一个简单的已签名的 Hello World 应用程序。因此,虽然我可以轻松地修补二进制文件,但看门人却崩溃了(应该如此)。

该字符串在内存中,所以我想我只是使用posix_spawn()with POSIX_SPAWN_START_SUSPENDED,用 xnumem 修补进程的内存,然后恢复它。出于某种原因,这似乎也失败了。我的测试代码;

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <spawn.h>
#include <sys/wait.h>

#include "xnumem.h"

extern char **environ;

void run_cmd(char *cmd)
{
    pid_t pid;
    char *argv[] = {NULL};
    int status;
    printf("Run command: %s\n", cmd);
    status = posix_spawn(&pid, cmd, NULL, NULL, argv, environ);
    if (status == 0) {
        printf("Child pid: %i\n", pid);
        if (waitpid(pid, &status, 0) != -1) {
            printf("Child exited with status %i\n", status);
        } else {
            perror("waitpid");
        }
    } else {
        printf("posix_spawn: %s\n", strerror(status));
    }
}

int main (int argc, const char * argv[]) {
  char *arg;
  arg = "./hello-world";
  run_cmd(arg);

    return 0;
}

我似乎没有收到任何错误,只是一个循环;

Run command: ./hello-world
Child pid: 53209
Run command: ./hello-world
Child pid: 53210
...

然后它终止。

有人可以指出我正确的方向吗?如何在挂起状态下启动进程、更改其内存并在不触发网守的情况下恢复?

4

0 回答 0