add space in templates for scriptlets

This commit is contained in:
n1nj4sec 2017-03-31 20:27:12 +02:00
parent 4ec9885f63
commit 620c951f19
3 changed files with 9 additions and 7 deletions

View File

@ -21,7 +21,7 @@ int linux_inject_main(int argc, char **argv);
static const char module_doc[] = "Builtins utilities for pupy";
static const char pupy_config[8192]="####---PUPY_CONFIG_COMES_HERE---####\n";
static const char pupy_config[32768]="####---PUPY_CONFIG_COMES_HERE---####\n";
static PyObject *ExecError;

View File

@ -9,7 +9,7 @@
#include "base_inject.h"
static char module_doc[] = "Builtins utilities for pupy";
char pupy_config[8192]="####---PUPY_CONFIG_COMES_HERE---####\n"; //big array to have space for more config / code run at startup
char pupy_config[32768]="####---PUPY_CONFIG_COMES_HERE---####\n"; //big array to have space for more config / code run at startup. scriptlets also takes more space !
extern const DWORD dwPupyArch;
#include "resources_library_compressed_string_txt.c"

View File

@ -29,6 +29,7 @@ import getpass
import json
ROOT=os.path.abspath(os.path.join(os.path.dirname(__file__)))
HARDCODED_CONF_SIZE=32768
def get_edit_binary(path, conf):
logging.debug("generating binary %s with conf: %s"%(path, conf))
@ -55,16 +56,17 @@ def get_edit_binary(path, conf):
new_conf = struct.pack('>II', compressed, uncompressed) + new_conf
new_conf_len = len(new_conf)
if new_conf_len > 8192:
if new_conf_len > HARDCODED_CONF_SIZE:
raise Exception(
'Error: config or offline script too long ({}/8192 bytes)'
'You need to recompile the dll with a bigger buffer'.format(new_conf_len)
'Error: config or offline script too long ({}/{} bytes)'
'You need to recompile the dll with a bigger buffer'.format(new_conf_len, HARDCODED_CONF_SIZE)
)
new_conf = new_conf + os.urandom(8192-new_conf_len)
new_conf = new_conf + os.urandom(HARDCODED_CONF_SIZE-new_conf_len)
offset = offsets[0]
binary = binary[0:offset]+new_conf+binary[offset+8192:]
binary = binary[0:offset]+new_conf+binary[offset+HARDCODED_CONF_SIZE:]
return binary
def get_raw_conf(conf, obfuscate=False):