From 36a1451c1a1b6f3398e0db18fceacdb05aae4efa Mon Sep 17 00:00:00 2001 From: GIL Date: Thu, 20 Sep 2018 00:18:39 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=B4=EB=8D=94=20=EA=B2=BD=EB=A1=9C?= =?UTF-8?q?=EB=A5=BC=20=EB=B0=9B=EC=95=84=20=EB=A6=AC=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GilRanClient/GilRanClient.cpp | 53 +++++++++++++++++--- GilRanClient/GilRanClient.vcxproj | 10 ++-- GilRanClient/GilRanClient.vcxproj.filters | 6 +++ GilRanClient/Utils.cpp | 60 +++++++++++++++++++++++ GilRanClient/Utils.h | 4 ++ 5 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 GilRanClient/Utils.cpp create mode 100644 GilRanClient/Utils.h diff --git a/GilRanClient/GilRanClient.cpp b/GilRanClient/GilRanClient.cpp index 8285419..33e29d6 100644 --- a/GilRanClient/GilRanClient.cpp +++ b/GilRanClient/GilRanClient.cpp @@ -2,10 +2,16 @@ #include #include #include + +#include +#include #include #include +#include +#include #include "../Common/Common.h" +#include "Utils.h" #define CLIENT_DEFAULT_REQUEST_COUNT 4 #define CLIENT_DEFAULT_THREAD_COUNT 4 @@ -14,6 +20,7 @@ typedef struct _THREAD_CONTEXT { HANDLE hCommunicationPort; HANDLE hIoCompletionPort; + std::list arrFolderPath; } THREAD_CONTEXT, *PTHREAD_CONTEXT; typedef struct _FILTER_MESSAGE { @@ -49,8 +56,6 @@ DWORD ClientWorker( break; } - printf("\n\n------------------------------ \nPID: %p\nVolumeName: %ws\nFileName: %ws\n", pFilterMessage->Request.ProcessID, pFilterMessage->Request.VolumeName, pFilterMessage->Request.FilePath); - PORT_RESPONSE Response; Response.Header.Status = 0; Response.Header.MessageId = pFilterMessage->Header.MessageId; @@ -86,7 +91,8 @@ int _cdecl main( { UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); - + + THREAD_CONTEXT ThreadContext; HANDLE hCommunicationPort; HRESULT hResult = FilterConnectCommunicationPort( PORT_NAME, @@ -106,7 +112,6 @@ int _cdecl main( CLIENT_DEFAULT_THREAD_COUNT ); - THREAD_CONTEXT ThreadContext; ThreadContext.hCommunicationPort = hCommunicationPort; ThreadContext.hIoCompletionPort = hIoCompletionPort; @@ -159,10 +164,46 @@ int _cdecl main( } } } - WaitForMultipleObjectsEx(loop, hThread, TRUE, INFINITE, FALSE); + + int Command = TRUE; + while (Command) { + std::wcout << std::endl; + std::wcout << "================================================================================" << std::endl; + std::wcout << "| GilRan Ransomware Solution v0.1a |" << std::endl; + std::wcout << "================================================================================" << std::endl; + std::wcout << "| [1] DMZ Folder -- SHOW |" << std::endl; + std::wcout << "| [2] DMZ Folder -- ADD |" << std::endl; + std::wcout << "| [0] Exit |" << std::endl; + std::wcout << "================================================================================" << std::endl; + std::wcout << "Select: "; + + std::cin >> Command; + if (!std::cin) { + std::cin.clear(); + std::cin.ignore(INT_MAX, '\n'); + Command = TRUE; + } + + switch (Command) { + case 1: + for (auto FolderPath : ThreadContext.arrFolderPath) { + std::wcout << FolderPath << std::endl; + } + break; + case 2: + PWCHAR Path = new WCHAR[MAX_PATH]; + + std::wcout << L"Input folder path to make DMZ Folder" << std::endl; + std::wcout << L">"; + std::wcin >> Path; + + ThreadContext.arrFolderPath.push_back(Path); + break; + } + } CloseHandle(hCommunicationPort); CloseHandle(hIoCompletionPort); - + return S_OK; } \ No newline at end of file diff --git a/GilRanClient/GilRanClient.vcxproj b/GilRanClient/GilRanClient.vcxproj index 22ded8d..3bc7521 100644 --- a/GilRanClient/GilRanClient.vcxproj +++ b/GilRanClient/GilRanClient.vcxproj @@ -36,9 +36,11 @@ + + {AC5C0863-C3F8-4628-94E2-4F009FB92427} @@ -127,7 +129,7 @@ MultiThreadedDebugDLL - %(AdditionalDependencies);onecoreuap.lib + %(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib @@ -135,7 +137,7 @@ WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions) - %(AdditionalDependencies);onecoreuap.lib + %(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib @@ -144,7 +146,7 @@ MultiThreadedDebugDLL - %(AdditionalDependencies);onecoreuap.lib + %(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib @@ -152,7 +154,7 @@ WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP;WINAPI_PARTITION_DESKTOP=1;WINAPI_PARTITION_SYSTEM=1;WINAPI_PARTITION_APP=1;WINAPI_PARTITION_PC_APP=1;%(PreprocessorDefinitions) - %(AdditionalDependencies);onecoreuap.lib + %(AdditionalDependencies);onecoreuap.lib;ole32.lib;shell32.lib;user32.lib diff --git a/GilRanClient/GilRanClient.vcxproj.filters b/GilRanClient/GilRanClient.vcxproj.filters index 77648e1..bfc2236 100644 --- a/GilRanClient/GilRanClient.vcxproj.filters +++ b/GilRanClient/GilRanClient.vcxproj.filters @@ -18,10 +18,16 @@ Source Files + + Source Files + Header Files + + Header Files + \ No newline at end of file diff --git a/GilRanClient/Utils.cpp b/GilRanClient/Utils.cpp new file mode 100644 index 0000000..1459c99 --- /dev/null +++ b/GilRanClient/Utils.cpp @@ -0,0 +1,60 @@ +// TODO: Dialog·Î Æú´õ °æ·Î ¹ÞÀ¸·Á ÇßÀ¸³ª, Dialog¸¦ ¿­¸é ¸ðµç Thread°¡ Á¤ÁöµÅ ½ÇÆÐ. (SHBrowseFolder, IFileDialog) +// TODK: ¹®Á¦¸¦ ÇØ°áÁö ¸øÇÏ¸é ¹®ÀÚ¿­·Î °æ·Î¸¦ ¹Þ°í ½ÇÁ¦ Æú´õ°¡ ÀÖ´ÂÁö È®ÀÎÇÑÈÄ µî·Ï. +/* +#include +#include +#include + +#include + +#include "Utils.h" + +PWCHAR GetFolderPath() { + IFileDialog *pIFileDialog = NULL; + + CoInitialize(NULL); + + CoCreateInstance( + CLSID_FileOpenDialog, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARGS(&pIFileDialog) + ); + + if (!pIFileDialog) NULL; + + pIFileDialog->SetOptions( + FOS_NOCHANGEDIR | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | + FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_DONTADDTORECENT + ); + pIFileDialog->SetTitle( + L"DMZ Folder" + ); + + HRESULT hResult = pIFileDialog->Show(NULL); + + + if (SUCCEEDED(hResult)) { + IShellItem* pIShellItem = NULL; + + if (SUCCEEDED(pIFileDialog->GetResult(&pIShellItem))) { + PIDLIST_ABSOLUTE pIDListAbsolute = NULL; + + SHGetIDListFromObject(pIShellItem, &pIDListAbsolute); + pIShellItem->Release(); + pIFileDialog->Release(); + CoUninitialize(); + + PWCHAR Path = new WCHAR[MAX_PATH]; + if (SHGetPathFromIDList(pIDListAbsolute, Path)) { + return Path; + } + delete Path; + } + } + CoUninitialize(); + pIFileDialog->Release(); + + return NULL; +} +*/ \ No newline at end of file diff --git a/GilRanClient/Utils.h b/GilRanClient/Utils.h new file mode 100644 index 0000000..9784f05 --- /dev/null +++ b/GilRanClient/Utils.h @@ -0,0 +1,4 @@ +/* +#pragma once +PWCHAR GetFolderPath(); +*/ \ No newline at end of file