首页 > 代码库 > [C] Re-execute itself from elf file.
[C] Re-execute itself from elf file.
Re-execute itself from elf file.
#define _GNU_SOURCE#include <sched.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <fcntl.h>#include <string.h>#include <errno.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/wait.h>extern char **environ;int main(int argc, char *argv[]){ char **ep; char *sh[] = {"/bin/sh", NULL}; char me[256], *mee[] = {me, "hello", NULL}; puts("hey~"); //execve(*sh, sh, environ); if ( argc > 1 && strcmp(argv[1], "hello") == 0 ) { printf("argv[1] : %s\n", argv[1]); puts("from execve()..."); return 0; } memset(me, 0, sizeof(me)); readlink("/proc/self/exe", me, sizeof(me) - 1); printf("[+] Found myself: ‘%s‘\n", me); execve(*mee, mee, environ); for ( ep = environ; *ep != NULL; ep++) printf("environ: %s\n", *ep);}
[C] Re-execute itself from elf file.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。