├── .gitattributes ├── CoreProjectTemplate ├── MyTemplate.vstemplate ├── ProcInspCore.cpp ├── ProcInspCore.h ├── ProcessInspectorCore.vcxproj ├── ProcessInspectorCore.vcxproj.filters ├── __TemplateIcon.ico └── new_folder.txt ├── DLLProjectTemplate ├── MyTemplate.vstemplate ├── ProcessInspectorDLL.cpp ├── ProcessInspectorDLL.vcxproj ├── ProcessInspectorDLL.vcxproj.filters └── __TemplateIcon.ico ├── ExeProjectTemplate ├── MyTemplate.vstemplate ├── ProcessInspectorEXE.cpp ├── ProcessInspectorEXE.vcxproj ├── ProcessInspectorEXE.vcxproj.filters └── __TemplateIcon.ico ├── Libraries └── ignoreme.vstemplate ├── README.md └── Root.vstemplate /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /CoreProjectTemplate/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | CoreProjectTemplate 4 | Template for Core Project template 5 | VC 6 | 7 | 8 | 1000 9 | true 10 | CoreProjectTemplate 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | ProcessInspectorCore.vcxproj.filters 19 | ProcInspCore.cpp 20 | ProcInspCore.h 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreProjectTemplate/ProcInspCore.cpp: -------------------------------------------------------------------------------- 1 | int runme() 2 | { 3 | return 0; 4 | } -------------------------------------------------------------------------------- /CoreProjectTemplate/ProcInspCore.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int runme(); 4 | 5 | -------------------------------------------------------------------------------- /CoreProjectTemplate/ProcessInspectorCore.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {$guid1$} 24 | $safeprojectname$ 25 | 10.0.17763.0 26 | 27 | 28 | 29 | StaticLibrary 30 | true 31 | v141 32 | Unicode 33 | 34 | 35 | StaticLibrary 36 | false 37 | v141 38 | true 39 | Unicode 40 | 41 | 42 | StaticLibrary 43 | true 44 | v141 45 | Unicode 46 | 47 | 48 | StaticLibrary 49 | false 50 | v141 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | Disabled 77 | true 78 | true 79 | 80 | 81 | copy /Y $(TargetPath) $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform)\$safeprojectname$_D.lib 82 | 83 | 84 | 85 | 86 | Level3 87 | Disabled 88 | true 89 | true 90 | 91 | 92 | copy /Y $(TargetPath) $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform)\$safeprojectname$_D.lib 93 | 94 | 95 | 96 | 97 | Level3 98 | MaxSpeed 99 | true 100 | true 101 | true 102 | true 103 | 104 | 105 | true 106 | true 107 | 108 | 109 | copy /Y $(TargetPath) $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform)\$safeprojectname$.lib 110 | 111 | 112 | release build version 113 | 114 | 115 | 116 | 117 | Level3 118 | MaxSpeed 119 | true 120 | true 121 | true 122 | true 123 | 124 | 125 | true 126 | true 127 | 128 | 129 | copy /Y $(TargetPath) $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform)\$safeprojectname$.lib 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /CoreProjectTemplate/ProcessInspectorCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /CoreProjectTemplate/__TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xC0D1F1ED/cpp_vs_payload_template/535d037df2bddfc7b358a613f02a9099b1137b8c/CoreProjectTemplate/__TemplateIcon.ico -------------------------------------------------------------------------------- /CoreProjectTemplate/new_folder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xC0D1F1ED/cpp_vs_payload_template/535d037df2bddfc7b358a613f02a9099b1137b8c/CoreProjectTemplate/new_folder.txt -------------------------------------------------------------------------------- /DLLProjectTemplate/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | DLLProjectTemplate 4 | Template for DLL Project 5 | VC 6 | 7 | 8 | 1000 9 | true 10 | DLLProjectTemplate 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | ProcessInspectorDLL.vcxproj.filters 19 | ProcessInspectorDLL.cpp 20 | 21 | 22 | -------------------------------------------------------------------------------- /DLLProjectTemplate/ProcessInspectorDLL.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../$ext_safeprojectname$Core/$ext_safeprojectname$Core.h" 5 | 6 | #if defined(_DEBUG) 7 | #pragma comment (lib, "$ext_safeprojectname$Core_D.lib") 8 | #else 9 | #pragma comment (lib, "$ext_safeprojectname$Core.lib") 10 | #endif 11 | 12 | // Holds the global variables for our thread 13 | HANDLE hProjThread; 14 | DWORD threadID; 15 | 16 | // Function executed when the thread starts 17 | DWORD WINAPI Start$ext_safeprojectname$(LPVOID lpParam) { 18 | return runme(); 19 | } 20 | 21 | // Executed when the DLL is loaded (traditionally or through reflective injection) 22 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { 23 | 24 | if (ul_reason_for_call != DLL_PROCESS_ATTACH) 25 | return TRUE; 26 | 27 | DisableThreadLibraryCalls(hModule); 28 | hProjThread = CreateThread(NULL, 0, Start$ext_safeprojectname$, NULL, 0, &threadID); 29 | 30 | return TRUE; 31 | } 32 | 33 | // This is so the DLL can be started with rundll and will still function properly 34 | // It will wait for the thread to finish 35 | extern "C" __declspec(dllexport) BOOL Load(LPVOID lpUserdata, DWORD nUserdataLen) { 36 | if (hProjThread) { 37 | WaitForSingleObject(hProjThread, INFINITE); 38 | } 39 | 40 | return TRUE; 41 | }; 42 | -------------------------------------------------------------------------------- /DLLProjectTemplate/ProcessInspectorDLL.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {$guid1$} 24 | $safeprojectname$ 25 | 10.0.17763.0 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | v141 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v141 38 | true 39 | Unicode 40 | 41 | 42 | DynamicLibrary 43 | true 44 | v141 45 | Unicode 46 | 47 | 48 | DynamicLibrary 49 | false 50 | v141 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 74 | 75 | 76 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 77 | 78 | 79 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 80 | 81 | 82 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 83 | 84 | 85 | 86 | Level3 87 | Disabled 88 | true 89 | true 90 | 91 | 92 | 93 | 94 | Level3 95 | Disabled 96 | true 97 | true 98 | 99 | 100 | 101 | 102 | Level3 103 | MaxSpeed 104 | true 105 | true 106 | true 107 | true 108 | 109 | 110 | true 111 | true 112 | 113 | 114 | 115 | 116 | Level3 117 | MaxSpeed 118 | true 119 | true 120 | true 121 | true 122 | 123 | 124 | true 125 | true 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /DLLProjectTemplate/ProcessInspectorDLL.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /DLLProjectTemplate/__TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xC0D1F1ED/cpp_vs_payload_template/535d037df2bddfc7b358a613f02a9099b1137b8c/DLLProjectTemplate/__TemplateIcon.ico -------------------------------------------------------------------------------- /ExeProjectTemplate/MyTemplate.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExeProjectTemplate 4 | Template for EXE Project 5 | VC 6 | 7 | 8 | 1000 9 | true 10 | ExeProjectTemplate 11 | true 12 | Enabled 13 | true 14 | __TemplateIcon.ico 15 | 16 | 17 | 18 | ProcessInspectorEXE.vcxproj.filters 19 | ProcessInspectorEXE.cpp 20 | 21 | 22 | -------------------------------------------------------------------------------- /ExeProjectTemplate/ProcessInspectorEXE.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../$ext_safeprojectname$Core/$ext_safeprojectname$Core.h" 5 | 6 | #if defined(_DEBUG) 7 | #pragma comment (lib, "$ext_safeprojectname$Core_D.lib") 8 | #else 9 | #pragma comment (lib, "$ext_safeprojectname$Core.lib") 10 | #endif 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | return runme(); 15 | } -------------------------------------------------------------------------------- /ExeProjectTemplate/ProcessInspectorEXE.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {$guid1$} 24 | $safeprojectname$ 25 | 10.0.17763.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v141 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v141 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v141 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v141 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | $(IncludePath) 74 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 75 | 76 | 77 | $(IncludePath) 78 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 79 | 80 | 81 | $(IncludePath) 82 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 83 | 84 | 85 | $(IncludePath) 86 | $(SolutionDir)\$ext_safeprojectname$\Libraries\$(Platform);$(LibraryPath) 87 | 88 | 89 | 90 | Level3 91 | Disabled 92 | true 93 | true 94 | 95 | 96 | 97 | 98 | Level3 99 | Disabled 100 | true 101 | true 102 | 103 | 104 | 105 | 106 | Level3 107 | MaxSpeed 108 | true 109 | true 110 | true 111 | true 112 | 113 | 114 | true 115 | true 116 | 117 | 118 | 119 | 120 | Level3 121 | MaxSpeed 122 | true 123 | true 124 | true 125 | true 126 | 127 | 128 | true 129 | true 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /ExeProjectTemplate/ProcessInspectorEXE.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /ExeProjectTemplate/__TemplateIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0xC0D1F1ED/cpp_vs_payload_template/535d037df2bddfc7b358a613f02a9099b1137b8c/ExeProjectTemplate/__TemplateIcon.ico -------------------------------------------------------------------------------- /Libraries/ignoreme.vstemplate: -------------------------------------------------------------------------------- 1 | 2 | 3 | LibraryFolder 4 | Template for Library Folder 5 | VC 6 | 7 | 8 | 1000 9 | true 10 | Library 11 | true 12 | Enabled 13 | true 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpp_vs_payload_template 2 | Visual Studio (C++) Solution Template for Payloads 3 | 4 | This is a Visual Studio (C++) Solution Template intended to save some time when developing custom payloads/shellcode. This solution creates 3 projects: 5 | 6 | 1. A static library project (Core) 7 | 8 | All of your payload code goes in this project in the runme() function. Add as many headers/cpp files/references as you like, but runme() will be your entry point. 9 | 10 | 2. A dynamic library project (DLL) 11 | 12 | This project simply wraps the functionality of the static library project into a DLL skeleton. Once built, this project can be run directly using rundll32 or it can be converted to PIC shellcode using something like ConvertTo-Shellcode.ps1 from Nick Landers avaialble here: https://github.com/monoxgas/sRDI/tree/master/PowerShell 13 | 14 | 3. An application project (EXE) 15 | 16 | This project simply wraps the static library in an executable. This project can be used to debug your payload from the Visual Studio debugger and allows you to set breakpoints in the static library code. 17 | 18 | ## Use Cases 19 | 20 | I created this project for two reasons. First, it can be used to generate both an .exe and .dll payload simultaneously, saving time. Second, I grew tired of developing payloads as DLLs only to realize there would be a bug in there somewhere and dealing with the pain in the ass that is debugging a DLL file without being able to step through code line by line in VS. Rather than creating a new project w/ the buggy code as an application instead of a DLL to debug it directly from the IDE, now I have both at once. 21 | 22 | ## Instructions 23 | 24 | 1. Copy the contents of this repository to C:\Users\\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C++ Project (adjust for differences in your environment/version) 25 | 26 | 2. Open Visual Studio 27 | 28 | 3. Click on File/New/Project/VisualC++ and select "CPP Core/EXE/DLL Solution Template" 29 | 30 | 4. Name the solution, click OK 31 | 32 | 5. Select the executable project (solutionnameEXE), right-click and select "Set as startup project" 33 | 34 | 6. Select the solution at the top, right-click and select "Properties" 35 | 36 | 7. Go to Common Properties/Project Dependencies. Select the DLL project and set the Core project as a dependency. Repeat this for the EXE project. Hit Apply/OK. 37 | 38 | 8. Build your code from the runme() function in the Core project as the entry point. Select your arch/build-type and build the solution. 39 | 40 | ## Inspiration 41 | 42 | The inspiration for this template came from the way I saw Silent Break Security lay out one of their projects. I wanted a relatively painless way to replicate this layout without having to do all the manual work for each payload I write. 43 | -------------------------------------------------------------------------------- /Root.vstemplate: -------------------------------------------------------------------------------- 1 |  2 | 3 | CPP Core/EXE/DLL Solution Template 4 | Template that includes projects for static library, exe, and dll 5 | VC 6 | 7 | 8 | 1000 9 | true 10 | NewSolution 11 | true 12 | Enabled 13 | true 14 | 15 | 16 | 17 | 18 | CoreProjectTemplate\MyTemplate.vstemplate 19 | 20 | 21 | ExeProjectTemplate\MyTemplate.vstemplate 22 | 23 | 24 | DLLProjectTemplate\MyTemplate.vstemplate 25 | 26 | Libraries\ignoreme.vstemplate 27 | Libraries\ignoreme.vstemplate 28 | Libraries\ignoreme.vstemplate 29 | 30 | 31 | --------------------------------------------------------------------------------