├── .gitattributes ├── .gitignore ├── CodeInjection ├── CodeInjection.sln └── injector │ ├── injector.cpp │ ├── injector.vcxproj │ └── injector.vcxproj.filters └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /CodeInjection/CodeInjection.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "injector", "injector\injector.vcxproj", "{B6713E4F-9340-40D4-8A97-A0942E6B95B1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Debug|x64.ActiveCfg = Debug|x64 17 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Debug|x64.Build.0 = Debug|x64 18 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Debug|x86.ActiveCfg = Debug|Win32 19 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Debug|x86.Build.0 = Debug|Win32 20 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Release|x64.ActiveCfg = Release|x64 21 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Release|x64.Build.0 = Release|x64 22 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Release|x86.ActiveCfg = Release|Win32 23 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CodeInjection/injector/injector.cpp: -------------------------------------------------------------------------------- 1 | //exec 2 | //injector 3 | 4 | //using WinExec() 5 | 6 | #include 7 | #include 8 | 9 | char path[MAX_PATH]; 10 | 11 | typedef struct _param { 12 | FARPROC pFunc; 13 | char szParam[MAX_PATH]; 14 | UINT uiParam; 15 | 16 | }*pParam, PARAM; 17 | 18 | typedef FARPROC (WINAPI *pWinExec)(LPCSTR, UINT); 19 | 20 | DWORD WINAPI 21 | ThreadProc(LPVOID lParam) { 22 | pParam p = (pParam)lParam; 23 | ((pWinExec)(p->pFunc))((LPCSTR)p->szParam,p->uiParam); 24 | return 0; 25 | } 26 | 27 | BOOL 28 | InjectCode(DWORD pID) { 29 | PARAM param; 30 | HMODULE hMod = GetModuleHandleA("kernel32.dll"); 31 | param.pFunc = GetProcAddress(hMod, "WinExec"); 32 | strcpy(param.szParam, path); 33 | param.uiParam = SW_SHOWNORMAL; 34 | 35 | HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID); 36 | if (hProcess == NULL) { 37 | printf("Open process error.\n"); 38 | return FALSE; 39 | } 40 | 41 | DWORD bufSize = sizeof(_param); 42 | DWORD bytesWritten = 0; 43 | LPVOID pRemoteParam = VirtualAllocEx(hProcess, NULL, bufSize, MEM_COMMIT, PAGE_READWRITE); 44 | if (pRemoteParam == NULL) { 45 | printf("Memory allocation at remote process failed.\n"); 46 | CloseHandle(hProcess); 47 | return FALSE; 48 | } 49 | if (WriteProcessMemory(hProcess, pRemoteParam, (LPVOID)¶m, bufSize, &bytesWritten) == 0 || bytesWritten != bufSize) { 50 | printf("Write remote process memory error.\n"); 51 | CloseHandle(hProcess); 52 | return FALSE; 53 | } 54 | 55 | bufSize = 100; 56 | bytesWritten = 0; 57 | LPVOID pRemoteProc = VirtualAllocEx(hProcess, NULL, bufSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 58 | if (pRemoteParam == NULL) { 59 | printf("Memory allocation at remote process failed.\n"); 60 | CloseHandle(hProcess); 61 | return FALSE; 62 | } 63 | if (WriteProcessMemory(hProcess, pRemoteProc, (LPVOID)ThreadProc, bufSize, &bytesWritten) == 0 || bytesWritten != bufSize) { 64 | printf("Write remote process memory error.\n"); 65 | CloseHandle(hProcess); 66 | return FALSE; 67 | } 68 | 69 | HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pRemoteProc, pRemoteParam, 0, NULL); 70 | if (hThread == NULL) { 71 | printf("Create remote thread failed.\n"); 72 | CloseHandle(hProcess); 73 | return FALSE; 74 | } 75 | 76 | WaitForSingleObject(hThread, INFINITE); 77 | CloseHandle(hThread); 78 | CloseHandle(hProcess); 79 | 80 | return TRUE; 81 | } 82 | 83 | int 84 | main(int argc, char *argv[]) { 85 | if (argc != 3) { 86 | if (argc != 1) printf("Wrong parameters.\n\n"); 87 | printf("Usage:injector.exe \n"); 88 | } 89 | 90 | strcpy(path, argv[2]); 91 | int pID = atoi(argv[1]); 92 | 93 | if (InjectCode(pID)) { 94 | printf("Injection complete successfully.\n"); 95 | return 0; 96 | } 97 | else { 98 | printf("Inject failed.\n"); 99 | return -1; 100 | } 101 | } -------------------------------------------------------------------------------- /CodeInjection/injector/injector.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 | {B6713E4F-9340-40D4-8A97-A0942E6B95B1} 23 | Win32Proj 24 | injector 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 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 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | 100 | 101 | Level3 102 | Disabled 103 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | 105 | 106 | Console 107 | true 108 | 109 | 110 | 111 | 112 | Level3 113 | 114 | 115 | MaxSpeed 116 | true 117 | true 118 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 119 | 120 | 121 | Console 122 | true 123 | true 124 | true 125 | 126 | 127 | 128 | 129 | Level3 130 | 131 | 132 | MaxSpeed 133 | true 134 | true 135 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 136 | 137 | 138 | Console 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /CodeInjection/injector/injector.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;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 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeInjection 2 | refer to ReverseCore 3 | successfully run on windows 7 32bit 4 | 5 | Usage: 6 | injector.exe ProcessID ExcutableFilePath 7 | 8 | Please compile this program using the release mode. --------------------------------------------------------------------------------