2019-07-11 15:58:33 +00:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
|
|
|
#include "Python-dynload.h"
|
|
|
|
|
|
|
|
#define FREE_HMODULE_AFTER_LOAD 1
|
|
|
|
#define FILE_SYSTEM_ENCODING "utf-8"
|
|
|
|
|
|
|
|
typedef void *HMODULE;
|
2019-12-22 11:05:31 +00:00
|
|
|
typedef void *(*resolve_symbol_t)(HMODULE hModule, const char *name);
|
2019-07-11 15:58:33 +00:00
|
|
|
|
|
|
|
#ifndef OPENSSL_LIB_VERSION
|
2019-12-22 11:05:31 +00:00
|
|
|
#define OPENSSL_LIB_VERSION "1.0.0"
|
2019-07-11 15:58:33 +00:00
|
|
|
#endif
|
|
|
|
|
2019-12-22 11:05:31 +00:00
|
|
|
#define DEPENDENCIES \
|
|
|
|
{ \
|
|
|
|
{ \
|
|
|
|
"libcrypto.so." OPENSSL_LIB_VERSION, \
|
|
|
|
libcrypto_c_start, \
|
|
|
|
libcrypto_c_size, \
|
|
|
|
FALSE \
|
|
|
|
}, { \
|
|
|
|
"libssl.so." OPENSSL_LIB_VERSION, \
|
|
|
|
libssl_c_start, \
|
|
|
|
libssl_c_size, \
|
|
|
|
FALSE \
|
|
|
|
}, { \
|
|
|
|
"libpython2.7.so.1.0", \
|
|
|
|
python27_c_start, \
|
|
|
|
python27_c_size, \
|
|
|
|
TRUE \
|
|
|
|
} \
|
|
|
|
}
|
2019-07-11 15:58:33 +00:00
|
|
|
|
|
|
|
#define OSLoadLibary(name) dlopen(name, RTLD_NOW)
|
|
|
|
#define OSResolveSymbol dlsym
|
|
|
|
#define OSUnmapRegion munmap
|
2019-09-07 15:51:30 +00:00
|
|
|
#define MemLoadLibrary(name, bytes, size, arg) \
|
|
|
|
memdlopen(name, bytes, size, RTLD_NOW | RTLD_GLOBAL)
|
2019-07-11 15:58:33 +00:00
|
|
|
#define MemResolveSymbol dlsym
|
|
|
|
#define CheckLibraryLoaded(name) dlopen(name, RTLD_NOW | RTLD_NOLOAD)
|
|
|
|
|
2019-12-22 11:05:31 +00:00
|
|
|
static const char *OSGetProgramName()
|
|
|
|
{
|
2019-09-07 15:51:30 +00:00
|
|
|
static BOOL is_set = FALSE;
|
2019-12-22 11:05:31 +00:00
|
|
|
static char exe[PATH_MAX] = {'\0'};
|
2019-09-07 15:51:30 +00:00
|
|
|
|
|
|
|
if (is_set)
|
|
|
|
return exe;
|
|
|
|
|
|
|
|
#if defined(Linux)
|
|
|
|
dprint("INVOCATION NAME: %s\n", program_invocation_name);
|
|
|
|
|
2019-12-22 11:05:31 +00:00
|
|
|
if (readlink("/proc/self/exe", exe, sizeof(exe)) > 0)
|
|
|
|
{
|
|
|
|
if (strstr(exe, "/memfd:"))
|
|
|
|
{
|
|
|
|
snprintf(exe, sizeof(exe), "/proc/%d/exe", getpid());
|
2019-09-07 15:51:30 +00:00
|
|
|
}
|
2019-12-22 11:05:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-07 15:51:30 +00:00
|
|
|
char *upx_env = getenv(" ");
|
2019-12-22 11:05:31 +00:00
|
|
|
if (upx_env)
|
|
|
|
{
|
2019-09-07 15:51:30 +00:00
|
|
|
snprintf(exe, sizeof(exe), "%s", upx_env);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(SunOS)
|
|
|
|
strcpy(exe, getexecname());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
is_set = TRUE;
|
|
|
|
return exe;
|
|
|
|
}
|
|
|
|
|
2019-07-11 15:58:33 +00:00
|
|
|
#include "python27.c"
|
|
|
|
#include "libcrypto.c"
|
2019-12-22 11:05:31 +00:00
|
|
|
#include "libssl.c"
|
2019-07-11 15:58:33 +00:00
|
|
|
#include "tmplibrary.h"
|