-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dpc_fix' ( Issue #19 )
- Loading branch information
Showing
15 changed files
with
211 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
project (dpc_test) | ||
|
||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
|
||
set (srcs | ||
main.cpp | ||
) | ||
|
||
set (hdrs | ||
) | ||
|
||
add_executable ( ${PROJECT_NAME} ${hdrs} ${srcs}) | ||
|
||
if(PE2SHC_BUILD_TESTING) | ||
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${PROJECT_NAME} ) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
#include <Windows.h> | ||
|
||
int main() | ||
{ | ||
PROCESS_MITIGATION_DYNAMIC_CODE_POLICY dcp = {}; | ||
dcp.ProhibitDynamicCode = 1; | ||
SetProcessMitigationPolicy(ProcessDynamicCodePolicy, &dcp, sizeof(dcp)); | ||
std::cout << "PID: " << std::dec << GetCurrentProcessId() << "\n"; | ||
std::cout << "PROCESS_MITIGATION_DYNAMIC_CODE_POLICY enabled...\n"; | ||
while (true) | ||
{ | ||
Sleep(6000); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
project (injector) | ||
|
||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
|
||
set (srcs | ||
main.cpp | ||
util.cpp | ||
) | ||
|
||
set (hdrs | ||
util.h | ||
) | ||
|
||
add_executable ( ${PROJECT_NAME} ${hdrs} ${srcs}) | ||
|
||
if(PE2SHC_BUILD_TESTING) | ||
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${PROJECT_NAME} ) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <iostream> | ||
#include <Windows.h> | ||
#include "util.h" | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
if (argc < 3) { | ||
std::cout << "Args: <shellcode> <target pid>\n"; | ||
return 0; | ||
} | ||
|
||
char *path = argv[1]; | ||
int pid = atoi(argv[2]); | ||
size_t shc_size = 0; | ||
BYTE *shellcode = util::load_file(path, shc_size); | ||
if (!shellcode) { | ||
std::cerr << "Could not load the shellcode file\n"; | ||
return -1; | ||
} | ||
std::cout << "Injecting to: " << pid << "\n"; | ||
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); | ||
if (hProcess == NULL) { | ||
std::cerr << "[ERROR] Could not open process : " << std::hex << GetLastError() << std::endl; | ||
return -1; | ||
} | ||
LPVOID remote_buf = VirtualAllocEx(hProcess, NULL, shc_size, (MEM_RESERVE | MEM_COMMIT), PAGE_EXECUTE_READWRITE); | ||
if (remote_buf == NULL) { | ||
std::cerr << "[ERROR] Could not allocate a remote buffer : " << std::hex << GetLastError() << std::endl; | ||
return -1; | ||
} | ||
if (!WriteProcessMemory(hProcess, remote_buf, shellcode, shc_size, NULL)) { | ||
std::cerr << "[ERROR] WriteProcessMemory failed, status : " << std::hex << GetLastError() << std::endl; | ||
return -1; | ||
} | ||
HANDLE hMyThread = NULL; | ||
DWORD threadId = 0; | ||
if ((hMyThread = CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)remote_buf, NULL, 0, &threadId)) == NULL) { | ||
std::cerr << "[ERROR] CreateRemoteThread failed, status : " << std::hex << GetLastError() << std::endl; | ||
return -1; | ||
} | ||
std::cout << "Injected, created Thread, id = " << threadId << "\n"; | ||
CloseHandle(hMyThread); | ||
CloseHandle(hProcess); | ||
return 0; | ||
} |
Oops, something went wrong.