2015-10-03 19:16:37 +00:00
|
|
|
CC=cl.exe
|
|
|
|
|
|
|
|
PYTHONPATH=C:/Python27
|
|
|
|
PYTHON=$(PYTHONPATH)/python.exe
|
|
|
|
|
|
|
|
TEMPLATE_OUTPUT_PATH=..\..\pupy\payload_templates
|
|
|
|
ifndef ARCH
|
2015-10-11 15:32:55 +00:00
|
|
|
$(error You must specify an architecture.)
|
2015-10-03 19:16:37 +00:00
|
|
|
else
|
2015-10-11 15:32:55 +00:00
|
|
|
ifeq "$(ARCH)" "x64"
|
|
|
|
CFLAGS:=$(CFLAGS) /DWIN_X64 /D_WIN64
|
2015-10-14 15:56:58 +00:00
|
|
|
else
|
|
|
|
CFLAGS:=$(CFLAGS) /DWIN_X86
|
2015-10-11 15:32:55 +00:00
|
|
|
endif
|
2015-10-03 19:16:37 +00:00
|
|
|
endif
|
2015-10-23 17:16:11 +00:00
|
|
|
ifdef DEBUG
|
|
|
|
DEBUG_ADD:=DEBUG
|
|
|
|
CFLAGS:= $(CFLAGS) /DDEBUG
|
|
|
|
else
|
|
|
|
DEBUG_ADD:=
|
|
|
|
endif
|
2015-10-03 19:16:37 +00:00
|
|
|
|
|
|
|
PYOBJS=_memimporter.obj MyLoadLibrary.obj Python-dynload.obj pupy_load.obj pupy.obj base_inject.obj
|
|
|
|
COMMON_OBJS=resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj resources_library_compressed_string_txt.obj actctx.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj resources_msvcr90_dll.obj
|
|
|
|
|
|
|
|
all: $(TEMPLATE_OUTPUT_PATH)\pupy$(ARCH).exe $(TEMPLATE_OUTPUT_PATH)\pupy$(ARCH).dll
|
|
|
|
|
2015-10-23 17:16:11 +00:00
|
|
|
resources\library_compressed_string_$(ARCH).txt: gen_library_compressed_string.py resources\library$(ARCH).zip
|
|
|
|
$(PYTHON) gen_library_compressed_string.py
|
2015-10-03 19:16:37 +00:00
|
|
|
|
|
|
|
resources\library_compressed_string.txt: resources\library_compressed_string_$(ARCH).txt
|
|
|
|
copy $< $@
|
|
|
|
|
|
|
|
resources_library_compressed_string_txt.c: gen_resource_header.py resources\library_compressed_string.txt
|
|
|
|
$(PYTHON) $+
|
|
|
|
|
2015-10-23 17:16:11 +00:00
|
|
|
resources\bootloader.pyc: gen_python_bootloader.py ..\..\pupy\packages\all\pupyimporter.py ..\..\pupy\pp.py
|
|
|
|
$(PYTHON) gen_python_bootloader.py $(DEBUG_ADD)
|
2015-10-03 19:16:37 +00:00
|
|
|
|
|
|
|
resources_bootloader_pyc.c: gen_resource_header.py resources\bootloader.pyc
|
|
|
|
$(PYTHON) $+
|
|
|
|
|
|
|
|
resources\python27.dll: resources\python27_$(ARCH).dll
|
|
|
|
copy $< $@
|
|
|
|
|
|
|
|
resources_python27_dll.c: gen_resource_header.py resources\python27.dll
|
|
|
|
$(PYTHON) $+
|
|
|
|
|
|
|
|
resources\msvcr90.dll: resources\msvcr90_$(ARCH).dll
|
|
|
|
copy $< $@
|
|
|
|
|
|
|
|
resources_msvcr90_dll.c: gen_resource_header.py resources\msvcr90.dll
|
|
|
|
$(PYTHON) $+
|
|
|
|
|
|
|
|
$(PYOBJS): %.obj: %.c
|
|
|
|
$(CC) /c $(CFLAGS) /I$(PYTHONPATH)/include $<
|
|
|
|
|
2015-10-23 17:16:11 +00:00
|
|
|
main_exe.obj: main_exe.c
|
|
|
|
$(CC) /c $(CFLAGS) $<
|
|
|
|
|
2015-10-03 19:16:37 +00:00
|
|
|
%.obj: %.c
|
|
|
|
$(CC) /c $(CFLAGS) $<
|
|
|
|
|
|
|
|
ReflectiveLoader.obj: ReflectiveLoader.c
|
|
|
|
$(CC) /c $(CFLAGS) /DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR /O2 /Ob1 $<
|
|
|
|
|
|
|
|
$(TEMPLATE_OUTPUT_PATH)\pupy$(ARCH).exe: main_exe.obj $(PYOBJS) $(COMMON_OBJS)
|
2015-10-23 17:16:11 +00:00
|
|
|
$(CC) $(CFLAGS) $+ /Fe$@
|
2015-10-03 19:16:37 +00:00
|
|
|
|
|
|
|
$(TEMPLATE_OUTPUT_PATH)\pupy$(ARCH).dll: main_reflective.obj $(PYOBJS) ReflectiveLoader.obj $(COMMON_OBJS)
|
|
|
|
$(CC) $(CFLAGS) $+ /Fe$@ /LD
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
ifneq "$(QUICK)" "1"
|
|
|
|
.PHONY: resources\python27.dll resources\msvcr90.dll
|
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
|
|
|
del *.obj
|
|
|
|
del *.exp
|
|
|
|
del pupy$(ARCH).exe
|
|
|
|
del pupy$(ARCH).dll
|
|
|
|
del resources\bootloader.pyc
|
|
|
|
del resources\library_compressed_string.txt
|
|
|
|
del resources\library_compressed_string_x64.txt
|
|
|
|
del resources\library_compressed_string_x86.txt
|
|
|
|
del resources\python27.dll
|
2015-10-05 16:41:09 +00:00
|
|
|
del resources\msvcr90.dll
|