Notepad++ Plugin Autoload Persistence & Execution
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Notepad++๋ ์์ ์ plugins ํ์ ํด๋์์ ๋ฐ๊ฒฌ๋๋ ๋ชจ๋ plugin DLL์ autoloadํฉ๋๋ค. ์ฐ๊ธฐ ๊ฐ๋ฅํ Notepad++ ์ค์น ํด๋์ ์
์ฑ ํ๋ฌ๊ทธ์ธ์ ๋ฃ์ผ๋ฉด ์๋ํฐ๊ฐ ์์๋ ๋๋ง๋ค notepad++.exe ๋ด๋ถ์์ ์ฝ๋ ์คํ์ด ๋ฐ์ํ๋ฉฐ, ์ด๋ persistence, ์๋ฐํ initial execution, ๋๋ ์๋ํฐ๊ฐ elevated๋ก ์คํ๋ ๊ฒฝ์ฐ in-process loader๋ก ์
์ฉ๋ ์ ์์ต๋๋ค.
Writable plugin locations
- Standard install:
C:\Program Files\Notepad++\plugins\<PluginName>\<PluginName>.dll(์ผ๋ฐ์ ์ผ๋ก ์ฐ๋ ค๋ฉด admin ๊ถํ ํ์). - Writable options for low-privileged operators:
- Use the portable Notepad++ build in a user-writable folder.
- Copy
C:\Program Files\Notepad++to a user-controlled path (e.g.,%LOCALAPPDATA%\npp\) and runnotepad++.exefrom there. - Each plugin gets its own subfolder under
pluginsand is loaded automatically at startup; menu entries appear under Plugins.
Plugin load points (execution primitives)
Notepad++๋ ํน์ exported functions๋ฅผ ๊ธฐ๋ํฉ๋๋ค. ์ด๊ธฐํ ์ค ์ด๋ค ํจ์๊ฐ ๋ชจ๋ ํธ์ถ๋์ด ์ฌ๋ฌ ์คํ ์ง์ ์ด ์๊น๋๋ค:
DllMainโ DLL ๋ก๋ ์ฆ์ ์คํ๋ฉ๋๋ค (์ฒซ ๋ฒ์งธ ์คํ ์ง์ ).setInfo(NppData)โ ๋ก๋ ์ ํ ๋ฒ ํธ์ถ๋์ด Notepad++ ํธ๋ค์ ์ ๊ณต; ๋ณดํต ๋ฉ๋ด ํญ๋ชฉ ๋ฑ๋ก์ ์ฌ์ฉ๋ฉ๋๋ค.getName()โ ๋ฉ๋ด์ ํ์๋ ํ๋ฌ๊ทธ์ธ ์ด๋ฆ์ ๋ฐํํฉ๋๋ค.getFuncsArray(int *nbF)โ ๋ฉ๋ด ๋ช ๋ น์ ๋ฐํํฉ๋๋ค; ๋น์ด ์์ด๋ ์์ ์ ํธ์ถ๋ฉ๋๋ค.beNotified(SCNotification*)โ ํธ์ง๊ธฐ ์ด๋ฒคํธ(ํ์ผ ์ด๊ธฐ/๋ณ๊ฒฝ, UI ์ด๋ฒคํธ ๋ฑ)๋ฅผ ์์ ํ์ฌ ์ง์์ ์ธ ํธ๋ฆฌ๊ฑฐ๋ก ์ฌ์ฉ๋ฉ๋๋ค.messageProc(UINT, WPARAM, LPARAM)โ ๋ฉ์์ง ํธ๋ค๋ฌ๋ก, ๋์ฉ๋ ๋ฐ์ดํฐ ๊ตํ์ ์ ์ฉํฉ๋๋ค.isUnicode()โ ๋ก๋ ์ ํ์ธ๋๋ ํธํ์ฑ ํ๋๊ทธ์ ๋๋ค.
๋๋ถ๋ถ์ exports๋ stubs๋ก ๊ตฌํํ ์ ์์ผ๋ฉฐ; autoload ๋์ DllMain์ด๋ ์์ ์ฝ๋ฐฑ๋ค ์ด๋์์๋ ์คํ์ด ๋ฐ์ํ ์ ์์ต๋๋ค.
Minimal malicious plugin skeleton
๊ธฐ๋๋๋ exports๋ฅผ ํฌํจํ DLL์ ์ปดํ์ผํ๊ณ ์ฐ๊ธฐ ๊ฐ๋ฅํ Notepad++ ํด๋์ plugins\\MyNewPlugin\\MyNewPlugin.dll์ ๋ฐฐ์นํ์ธ์:
BOOL APIENTRY DllMain(HMODULE h, DWORD r, LPVOID) { if (r == DLL_PROCESS_ATTACH) MessageBox(NULL, TEXT("Hello from Notepad++"), TEXT("MyNewPlugin"), MB_OK); return TRUE; }
extern "C" __declspec(dllexport) void setInfo(NppData) {}
extern "C" __declspec(dllexport) const TCHAR *getName() { return TEXT("MyNewPlugin"); }
extern "C" __declspec(dllexport) FuncItem *getFuncsArray(int *nbF) { *nbF = 0; return NULL; }
extern "C" __declspec(dllexport) void beNotified(SCNotification *) {}
extern "C" __declspec(dllexport) LRESULT messageProc(UINT, WPARAM, LPARAM) { return TRUE; }
extern "C" __declspec(dllexport) BOOL isUnicode() { return TRUE; }
- DLL์ ๋น๋ํฉ๋๋ค (Visual Studio/MinGW).
plugins์๋์ plugin ํ์ ํด๋๋ฅผ ๋ง๋ค๊ณ DLL์ ๊ทธ ์์ ๋ฃ์ต๋๋ค.- Notepad++๋ฅผ ์ฌ์์ํ๋ฉด DLL์ด ์๋์ผ๋ก ๋ก๋๋์ด
DllMain๋ฐ ์ดํ ์ฝ๋ฐฑ์ด ์คํ๋ฉ๋๋ค.
Reflective loader plugin pattern
์ ์ฉ๋ plugin์ Notepad++์ reflective DLL loader๋ก ๋ง๋ค ์ ์์ต๋๋ค:
- ์ต์ํ์ UI/๋ฉ๋ด ํญ๋ชฉ์ ์ ๊ณตํฉ๋๋ค(์: โLoadDLLโ).
- ํ์ด๋ก๋ DLL์ ๊ฐ์ ธ์ค๊ธฐ ์ํด file path ๋๋ URL์ ๋ฐ์ต๋๋ค.
- DLL์ ํ์ฌ ํ๋ก์ธ์ค์ reflectively mapํ๊ณ export๋ entry point(์: ๊ฐ์ ธ์จ DLL ๋ด๋ถ์ loader function)๋ฅผ ํธ์ถํฉ๋๋ค.
- ์ด์ : ์๋ก์ด ๋ก๋๋ฅผ ์์ฑํ๋ ๋์ ์ ์์ผ๋ก ๋ณด์ด๋ GUI ํ๋ก์ธ์ค๋ฅผ ์ฌ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ํ์ด๋ก๋๋
notepad++.exe์ ๋ฌด๊ฒฐ์ฑ(๊ถํ ์์น๋ ์ปจํ ์คํธ ํฌํจ)์ ๊ณ์นํฉ๋๋ค. - ๋จ์ : ๋์คํฌ์ unsigned plugin DLL์ ๋จ์ด๋จ๋ฆฌ๋ ๊ฒ์ ์์์ด ํฌ๋ฏ๋ก, ๊ฐ๋ฅํ๋ฉด ๊ธฐ์กด์ ์ ๋ขฐ๋ ํ๋ฌ๊ทธ์ธ์ piggybackingํ๋ ๊ฒ์ ๊ณ ๋ คํ์ธ์.
ํ์ง ๋ฐ ํ๋๋ ๋ ธํธ
- writes to Notepad++ plugin directories๋ฅผ ์ฐจ๋จํ๊ฑฐ๋ ๋ชจ๋ํฐ๋งํ์ธ์(์ฌ์ฉ์ ํ๋กํ์ portable ๋ณต์ฌ๋ณธ ํฌํจ); Controlled Folder Access ๋๋ ์ ํ๋ฆฌ์ผ์ด์ allowlisting์ ํ์ฑํํ์ธ์.
plugins์๋์ new unsigned DLLs์ ๋ํด ๊ฒฝ๋ณด๋ฅผ ์ค์ ํ๊ณ ,notepad++.exe์์ ๋ฐ์ํ๋ ์ด์ํ child processes/network activity๋ฅผ ๋ชจ๋ํฐ๋งํ์ธ์.- ํ๋ฌ๊ทธ์ธ ์ค์น๋ Plugins Admin์ ํตํด์๋ง ํ์ฉํ๊ณ , ์ ๋ขฐํ ์ ์๋ ๊ฒฝ๋ก์์์ portable ๋ณต์ฌ๋ณธ ์คํ์ ์ ํํ์ธ์.
์ฐธ๊ณ ์๋ฃ
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


