Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
moccajoghurt committed Sep 19, 2018
1 parent 95f91b0 commit 0405eef
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 36 deletions.
Binary file modified AttackServices/DLLInjectionAttack/InjectedDLL.dll
Binary file not shown.
9 changes: 1 addition & 8 deletions AttackServices/SocketHookAttack/SocketHookDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ using namespace std;

void CreateConfirmationFile();
HANDLE hMutex;
BOOL unhook = FALSE;
shared_ptr<PLH::Detour> Detour_Send(new PLH::Detour);
shared_ptr<PLH::Detour> Detour_SendTo(new PLH::Detour);
shared_ptr<PLH::Detour> Detour_WSASend(new PLH::Detour);
Expand Down Expand Up @@ -94,6 +93,7 @@ int __stdcall hWSASendMsg(SOCKET Handle, LPWSAMSG lpMsg, DWORD dwFlags, LPDWORD
// return oWSASendMsg(Handle, lpMsg, dwFlags, lpNumberOfBytesSent, lpOverlapped, lpCompletionRoutine);
}

BOOL unhook = FALSE;
void CreateConfirmationFile() {
TCHAR tempPath[MAX_PATH];
GetTempPath(MAX_PATH, tempPath);
Expand All @@ -104,13 +104,6 @@ void CreateConfirmationFile() {
}

DWORD WINAPI InitializeHook(LPVOID lpParam) {

// hMutex = CreateMutex(NULL, TRUE /*initial ownership*/, NULL);
// if (hMutex == NULL) {
// MessageBoxA(NULL, "Mutex failed\n", "MemWars Framework", MB_OK | MB_TOPMOST);
// FreeLibraryAndExitThread((HMODULE)lpParam, 0);
// return 1;
// }

Detour_Send->SetupHook((BYTE*)&send,(BYTE*) &hSend);
Detour_Send->Hook();
Expand Down
Binary file modified AttackServices/SocketHookAttack/SocketHookDLL.dll
Binary file not shown.
14 changes: 0 additions & 14 deletions LuaInterface/LuaInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ extern "C" {
using namespace luabridge;
using namespace std;

// class TestClass {
// public:
// TestClass(){cout << "hi123" << endl;}
// string TestFunc(const std::string& s) {
// return "hallo";
// }
// };

int main(int argc, char* argv[]) {

if (argc != 2) {
Expand Down Expand Up @@ -85,10 +77,4 @@ int main(int argc, char* argv[]) {
}

lua_close(L);

// getGlobalNamespace(L)
// .beginClass<TestClass>("TestClass")
// .addConstructor<void(*) (void)>()
// .addFunction ("TestFunc", &TestClass::TestFunc)
// .endClass();
}
Binary file modified LuaInterface/LuaInterface.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion LuaInterface/Test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ injector:SetTargetDLL("C:/Users/Marius/git/MemWars/AttackServices/SocketHookAtta
-- injector:SetTargetDLL("C:/Users/Marius/git/MemWars/AttackServices/NetworkEncryptionDetector/DetectEncryptionDLL.dll")
injector:SetTargetProcessByName("SocketTestApp.exe")
injector:RequireConfirmationFile()
injector:SetTimeout(1000)
-- injector:SetTimeout(1000)
if injector:InjectDLL() then
print("Successfully injected the DLL in the target process")
end
Expand Down
33 changes: 21 additions & 12 deletions PenetrationRoutines/DLLInjectionProvider/DLLInjectionProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bool DLLInjectionProvider::SetTargetDLL(const string _dllPath) {
}

bool DLLInjectionProvider::InjectDLL() {
DeleteConfirmationFile(); // make sure there is no old confirmation file
if (this->dllPath == L"" || this->hProcess == NULL) {
results += "[-] InjectDLL() failed. Could not inject DLL. DLL or process is invalid.\n";
return FALSE;
Expand All @@ -53,13 +54,13 @@ bool DLLInjectionProvider::InjectDLL() {
if (ret == WAIT_TIMEOUT) {
TerminateThread(hThread, 0);
results += "[-] InjectDLL() failed. Injection timed out.\n";
DeleteConfirmationFile();
return FALSE;
} else {
GetExitCodeThread(hThread, &status);
}
}


if (status != 0 && status != 10) {
results += "[-] InjectDLL() failed. Could not inject DLL. System Error Code: ";
results += to_string(GetLastError());
Expand All @@ -80,6 +81,7 @@ bool DLLInjectionProvider::InjectDLL() {
TCHAR tempPath[MAX_PATH];
GetTempPath(MAX_PATH, tempPath);
lstrcatA(tempPath, "dllInjectionConfirmationFile");

if (status == 0) {
results += "[+] InjectDLL() was successful.\n[+] ";
results += this->processName;
Expand Down Expand Up @@ -112,18 +114,9 @@ bool DLLInjectionProvider::InjectDLL() {
return TRUE;
}

DWORD StartThreadedInjection(LPVOID param) {
INJECTION_DATA* data = (INJECTION_DATA*)param;
if (data->useShellcode) {
return LoadDll(data->hProcess, data->dllPath.c_str());
} else {
return LoadDllNoShellcode(data->hProcess, data->dllPath.c_str());
}
}


void DLLInjectionProvider::SetTimeout(int miliSeconds) {
this->timeout = miliSeconds;
void DLLInjectionProvider::SetTimeout(int milliSeconds) {
this->timeout = milliSeconds;
}

void DLLInjectionProvider::RequireConfirmationFile() {
Expand All @@ -135,6 +128,22 @@ bool DLLInjectionProvider::AssertCompatible() {
return TRUE;
}

DWORD StartThreadedInjection(LPVOID param) {
INJECTION_DATA* data = (INJECTION_DATA*)param;
if (data->useShellcode) {
return LoadDll(data->hProcess, data->dllPath.c_str());
} else {
return LoadDllNoShellcode(data->hProcess, data->dllPath.c_str());
}
}

bool DeleteConfirmationFile() {
TCHAR tempPath[MAX_PATH];
GetTempPath(MAX_PATH, tempPath);
lstrcatA(tempPath, "dllInjectionConfirmationFile");
return DeleteFile(tempPath);
}


// int main() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ struct INJECTION_DATA {
};

DWORD StartThreadedInjection(LPVOID param);
bool DeleteConfirmationFile();

class DLLInjectionProvider : public AttackProvider {
public:
DLLInjectionProvider(){}
bool SetTargetProcessByName(const string);
bool SetTargetDLL(const string);
void RequireConfirmationFile();
void SetTimeout(int miliSeconds);
void SetTimeout(int milliSeconds);
bool InjectDLL();
bool AssertCompatible(); // possible addition

Expand Down

0 comments on commit 0405eef

Please sign in to comment.