├── Release └── ShellcodeExec.exe ├── ShellcodeExec.sln ├── ShellcodeExec ├── ShellcodeExec.c ├── ShellcodeExec.vcxproj └── ShellcodeExec.vcxproj.filters └── x64 └── Release └── ShellcodeExec.exe /Release/ShellcodeExec.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattifestation/ShellcodeExec/1bc236017a126260dc9784d7ed0411e27cee04f0/Release/ShellcodeExec.exe -------------------------------------------------------------------------------- /ShellcodeExec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShellcodeExec", "ShellcodeExec\ShellcodeExec.vcxproj", "{2CE96621-B3EC-494B-9755-6C2F942D14FE}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Debug|Win32.Build.0 = Debug|Win32 16 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Debug|Win32.Deploy.0 = Debug|Win32 17 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Debug|x64.ActiveCfg = Debug|x64 18 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Debug|x64.Build.0 = Debug|x64 19 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Release|Win32.ActiveCfg = Release|Win32 20 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Release|Win32.Build.0 = Release|Win32 21 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Release|Win32.Deploy.0 = Release|Win32 22 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Release|x64.ActiveCfg = Release|x64 23 | {2CE96621-B3EC-494B-9755-6C2F942D14FE}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /ShellcodeExec/ShellcodeExec.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // The shellcode will be treated as a function with no arguments and no return value. 6 | typedef VOID (*SHELLCODE)(); 7 | 8 | INT _tmain( INT argc, TCHAR *argv[] ) 9 | { 10 | HANDLE hFile; 11 | BOOL bDebugBreak = FALSE; 12 | DWORD dwFileSize; 13 | DWORD dwBytesRead; 14 | BOOL bReadSuccess; 15 | PBYTE lpShellcode; 16 | SHELLCODE execShellcode; 17 | const PTCHAR syntaxMessage = TEXT("Executes shellcode from a file.\n\n%s shellcodeBinFile [/CC]\n\n /CC Prepends a debug breakpoint (INT3) to the shellcode.\n"); 18 | 19 | if ((argc < 2) || (argc > 3)) 20 | { 21 | goto error_args; 22 | } 23 | 24 | if ( argc == 3 ) 25 | { 26 | if ( _tcsicmp( argv[2], TEXT("/CC") ) == 0 ) 27 | { 28 | bDebugBreak = TRUE; 29 | } 30 | else 31 | { 32 | goto error_args; 33 | } 34 | } 35 | 36 | _tprintf( TEXT("\n") ); 37 | 38 | hFile = CreateFile( argv[1], 39 | GENERIC_READ, 40 | FILE_SHARE_READ, 41 | NULL, 42 | OPEN_EXISTING, 43 | FILE_ATTRIBUTE_NORMAL, 44 | NULL ); 45 | 46 | if ( hFile == INVALID_HANDLE_VALUE ) 47 | { 48 | _tprintf( TEXT("Error: Unable to open file.\n"), argv[1] ); 49 | return 1; 50 | } 51 | 52 | dwFileSize = GetFileSize( hFile, NULL ); 53 | 54 | if ( dwFileSize == INVALID_FILE_SIZE ) 55 | { 56 | _tprintf( TEXT("Error: Invalid file size.\n") ); 57 | goto error_fail; 58 | } 59 | 60 | lpShellcode = (PBYTE) VirtualAlloc( 0, 61 | dwFileSize + 1, 62 | MEM_COMMIT, 63 | PAGE_EXECUTE_READWRITE ); 64 | 65 | if ( lpShellcode == NULL ) 66 | { 67 | _tprintf( TEXT("Error: Unable to allocate RWX memory. (0x%08x)\n"), GetLastError() ); 68 | goto error_fail; 69 | } 70 | 71 | if ( bDebugBreak ) 72 | { 73 | *lpShellcode = 0xCC; 74 | bReadSuccess = ReadFile( hFile, (lpShellcode + 1), dwFileSize, &dwBytesRead, NULL ); 75 | } 76 | else 77 | { 78 | bReadSuccess = ReadFile( hFile, lpShellcode, dwFileSize, &dwBytesRead, NULL ); 79 | } 80 | 81 | if ( !bReadSuccess ) 82 | { 83 | _tprintf( TEXT("Error: Unable to read file. (0x%08x)\n"), GetLastError() ); 84 | goto error_fail; 85 | } 86 | 87 | if ( dwBytesRead == 0 ) 88 | { 89 | _tprintf( TEXT("Error: No bytes were read.\n") ); 90 | goto error_fail; 91 | } 92 | 93 | CloseHandle( hFile ); 94 | 95 | #pragma warning( disable : 4055 ) 96 | execShellcode = (SHELLCODE) lpShellcode; 97 | #pragma warning( default : 4055 ) 98 | 99 | _tprintf( TEXT("Executing shellcode...\n") ); 100 | 101 | execShellcode(); 102 | 103 | _tprintf( TEXT("Shellcode execution complete!\n") ); 104 | 105 | return 0; 106 | 107 | error_fail: 108 | CloseHandle(hFile); 109 | return 1; 110 | 111 | error_args: 112 | _tprintf(syntaxMessage, argv[0]); 113 | return 1; 114 | } -------------------------------------------------------------------------------- /ShellcodeExec/ShellcodeExec.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {2CE96621-B3EC-494B-9755-6C2F942D14FE} 23 | Win32Proj 24 | ShellcodeExec 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | 72 | 73 | true 74 | 75 | 76 | false 77 | 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | Level3 86 | Disabled 87 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 88 | 89 | 90 | Console 91 | false 92 | 93 | 94 | 95 | 96 | 97 | 98 | Level3 99 | Disabled 100 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 101 | 102 | 103 | Console 104 | false 105 | 106 | 107 | 108 | 109 | Level4 110 | 111 | 112 | MaxSpeed 113 | true 114 | true 115 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 116 | 117 | 118 | Console 119 | false 120 | true 121 | true 122 | 123 | 124 | 125 | 126 | Level4 127 | 128 | 129 | MaxSpeed 130 | true 131 | true 132 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 133 | 134 | 135 | Console 136 | false 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | CompileAsC 144 | CompileAsC 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /ShellcodeExec/ShellcodeExec.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;hpp;hxx;hm;inl;inc;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 | -------------------------------------------------------------------------------- /x64/Release/ShellcodeExec.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattifestation/ShellcodeExec/1bc236017a126260dc9784d7ed0411e27cee04f0/x64/Release/ShellcodeExec.exe --------------------------------------------------------------------------------