Windows Service Triggers: Enumeration and Abuse
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Windows Service Triggers๋ Service Control Manager(SCM)๊ฐ ํน์ ์กฐ๊ฑด์ด ๋ฐ์ํ์ ๋(์: IP ์ฃผ์๊ฐ ์ฌ์ฉ ๊ฐ๋ฅํด์ง, named pipe ์ฐ๊ฒฐ ์๋, ETW ์ด๋ฒคํธ ๊ฒ์ ๋ฑ) ์๋น์ค๋ฅผ ์์/์ค์งํ ์ ์๊ฒ ํฉ๋๋ค. ๋์ ์๋น์ค์ ๋ํด SERVICE_START ๊ถํ์ด ์๋๋ผ๋ ํธ๋ฆฌ๊ฑฐ๊ฐ ๋ฐ๋ํ๋๋ก ์ ๋ํ๋ฉด ์๋น์ค๋ฅผ ์์ํ ์ ์์ต๋๋ค.
์ด ํ์ด์ง๋ ๊ณต๊ฒฉ์์๊ฒ ์ ๋ฆฌํ ์ด๊ฑฐ ๋ฐฉ๋ฒ๊ณผ ์ผ๋ฐ์ ์ธ ํธ๋ฆฌ๊ฑฐ๋ฅผ ํ์ฑํํ๋ ๋ฎ์ ๋ง์ฐฐ์ ๋ฐฉ๋ฒ๋ค์ ์ค์ ์ ๋ก๋๋ค.
Tip: ๊ถํ์ด ๋์ ๋นํธ์ธ ์๋น์ค(์: RemoteRegistry, WebClient/WebDAV, EFS)๋ฅผ ์์ํ๋ฉด ์๋ก์ด RPC/named-pipe ๋ฆฌ์ค๋๊ฐ ๋ ธ์ถ๋์ด ์ถ๊ฐ์ ์ธ ์ ์ฉ ์ฒด์ธ์ด ์ด๋ฆด ์ ์์ต๋๋ค.
Enumerating Service Triggers
- sc.exe (local)
- ์๋น์ค์ ํธ๋ฆฌ๊ฑฐ ๋์ด:
sc.exe qtriggerinfo <ServiceName> - Registry (local)
- ํธ๋ฆฌ๊ฑฐ๋ ๋ค์์ ์์น:
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\TriggerInfo - ์ฌ๊ท ๋คํ:
reg query HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\TriggerInfo /s - Win32 API (local)
- SERVICE_CONFIG_TRIGGER_INFO (8)๋ฅผ ์ฌ์ฉํ์ฌ QueryServiceConfig2๋ฅผ ํธ์ถํ๋ฉด SERVICE_TRIGGER_INFO๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
- Docs: QueryServiceConfig2[W/A] and SERVICE_TRIGGER/SERVICE_TRIGGER_SPECIFIC_DATA
- RPC over MSโSCMR (remote)
- SCM์ ์๊ฒฉ์ผ๋ก ์ฟผ๋ฆฌํ์ฌ ํธ๋ฆฌ๊ฑฐ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. TrustedSec์ Titanis๋ ์ด๋ฅผ ๋
ธ์ถํฉ๋๋ค:
Scm.exe qtriggers. - Impacket์ msrpc MS-SCMR์ ๊ตฌ์กฐ์ฒด๋ฅผ ์ ์ํฉ๋๋ค; ์ด๋ฅผ ์ด์ฉํด ์๊ฒฉ ์ฟผ๋ฆฌ๋ฅผ ๊ตฌํํ ์ ์์ต๋๋ค.
High-Value Trigger Types and How to Activate Them
Network Endpoint Triggers
ํด๋ผ์ด์ธํธ๊ฐ IPC ์๋ํฌ์ธํธ์ ์ ์์ ์๋ํ ๋ ์๋น์ค๋ฅผ ์์ํฉ๋๋ค. ๋ฎ์ ๊ถํ ์ฌ์ฉ์๊ฐ ์ ์ฉํ ์ด์ ๋ SCM์ด ํด๋ผ์ด์ธํธ๊ฐ ์ค์ ๋ก ์ฐ๊ฒฐํ๊ธฐ ์ ์ ์๋์ผ๋ก ์๋น์ค๋ฅผ ์์ํด์ฃผ๊ธฐ ๋๋ฌธ์ ๋๋ค.
- Named pipe trigger
- ๋์: ํด๋ผ์ด์ธํธ๊ฐ \.\pipe<PipeName>์ ์ฐ๊ฒฐ์ ์๋ํ๋ฉด, SCM์ด ํด๋น ์๋น์ค๊ฐ ๋ฆฌ์ค๋์ ์์ํ ์ ์๋๋ก ์๋น์ค๋ฅผ ์์ํฉ๋๋ค.
- Activation (PowerShell):
$pipe = new-object System.IO.Pipes.NamedPipeClientStream('.', 'PipeNameFromTrigger', [System.IO.Pipes.PipeDirection]::InOut)
try { $pipe.Connect(1000) } catch {}
$pipe.Dispose()
-
์ฐธ๊ณ : Named Pipe Client Impersonation์ ์๋น์ค ์์ ํ ์ ์ฉ์ ์ ์ฉํฉ๋๋ค.
-
RPC endpoint trigger (Endpoint Mapper)
-
๋์: ์๋น์ค์ ์ฐ๊ฒฐ๋ ์ธํฐํ์ด์ค UUID์ ๋ํด Endpoint Mapper(EPM, TCP/135)๋ฅผ ์กฐํํ๋ฉด, SCM์ด ํด๋น ์๋น์ค๊ฐ ์์ ์ ์๋ํฌ์ธํธ๋ฅผ ๋ฑ๋กํ ์ ์๋๋ก ์๋น์ค๋ฅผ ์์ํฉ๋๋ค.
-
Activation (Impacket):
# Queries local EPM; replace UUID with the service interface GUID
python3 rpcdump.py @127.0.0.1 -uuid <INTERFACE-UUID>
Custom (ETW) Triggers
์๋น์ค๋ ETW provider/event์ ๋ฐ์ธ๋ฉ๋ ํธ๋ฆฌ๊ฑฐ๋ฅผ ๋ฑ๋กํ ์ ์์ต๋๋ค. ์ถ๊ฐ์ ์ธ ํํฐ(keyword/level/binary/string)๊ฐ ์ค์ ๋์ด ์์ง ์๋ค๋ฉด, ํด๋น provider์ ์ด๋ค ์ด๋ฒคํธ๋ ์๋น์ค ์์์ ์ ๋ฐํ ์ ์์ต๋๋ค.
- ์์ (WebClient/WebDAV): provider {22B6D684-FA63-4578-87C9-EFFCBE6643C7}
- ํธ๋ฆฌ๊ฑฐ ๋์ด:
sc.exe qtriggerinfo webclient - provider๊ฐ ๋ฑ๋ก๋์ด ์๋์ง ํ์ธ:
logman query providers | findstr /I 22b6d684-fa63-4578-87c9-effcbe6643c7 - ์ผ์นํ๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํค๋ ค๋ฉด ์ผ๋ฐ์ ์ผ๋ก ํด๋น provider์ ๋ก๊น ํ๋ ์ฝ๋๊ฐ ํ์ํฉ๋๋ค; ํํฐ๊ฐ ์๋ค๋ฉด ์ด๋ค ์ด๋ฒคํธ๋ ์ถฉ๋ถํฉ๋๋ค.
Group Policy Triggers
ํ์ ์ ํ: Machine/User. ๋๋ฉ์ธ ๊ฐ์
๋ ํธ์คํธ์์ ํด๋น ์ ์ฑ
์ด ์กด์ฌํ๋ฉด ํธ๋ฆฌ๊ฑฐ๋ ๋ถํ
์ ์คํ๋ฉ๋๋ค. ๋จ์ํ gpupdate๋ง์ผ๋ก๋ ๋ณ๊ฒฝ์ด ์์ผ๋ฉด ํธ๋ฆฌ๊ฑฐ๊ฐ ๋ฐ๋ํ์ง ์์ต๋๋ค. ํ์ง๋ง:
- Activation:
gpupdate /force - ๊ด๋ จ ์ ์ฑ ์ ํ์ด ์กด์ฌํ๋ฉด, ์ด๊ฒ์ผ๋ก ํธ๋ฆฌ๊ฑฐ๊ฐ ์ ๋ขฐ์ฑ ์๊ฒ ๋ฐ๋ํ์ฌ ์๋น์ค๋ฅผ ์์์ํต๋๋ค.
IP Address Available
์ฒซ ๋ฒ์งธ IP๊ฐ ์ป์ด์ก์ ๋(๋๋ ๋ง์ง๋ง์ด ์ฌ๋ผ์ก์ ๋) ๋ฐ๋ํฉ๋๋ค. ๋ถํ ์ ์์ฃผ ํธ๋ฆฌ๊ฑฐ๋ฉ๋๋ค.
- Activation: ์ฐ๊ฒฐ์ ํ ๊ธํ์ฌ ์ฌ๋ฐ๋์ํค๊ธฐ, ์:
netsh interface set interface name="Ethernet" admin=disabled
netsh interface set interface name="Ethernet" admin=enabled
Device Interface Arrival
์ผ์นํ๋ device interface๊ฐ ๋์ฐฉํ๋ฉด ์๋น์ค๋ฅผ ์์ํฉ๋๋ค. ๋ฐ์ดํฐ ์์ดํ ์ด ์ง์ ๋์ง ์์ ๊ฒฝ์ฐ ํธ๋ฆฌ๊ฑฐ ์๋ธํ์ GUID์ ์ผ์นํ๋ ์ด๋ค ์ฅ์น๋ ํธ๋ฆฌ๊ฑฐ๋ฅผ ๋ฐ๋์ํฌ ์ ์์ต๋๋ค. ๋ถํ ์์ ํซํ๋ฌ๊ทธ ์์ ํ๊ฐ๋ฉ๋๋ค.
- Activation: ํธ๋ฆฌ๊ฑฐ ์๋ธํ์ ์ ์ง์ ๋ ํด๋์ค/ํ๋์จ์ด ID์ ์ผ์นํ๋ ์ฅ์น(๋ฌผ๋ฆฌ์ ๋๋ ๊ฐ์)๋ฅผ ์ฐ๊ฒฐ/์ฝ์ ํฉ๋๋ค.
Domain Join State
MSDN์ ํผ๋์ค๋ฌ์ด ๋ฌธ๊ตฌ์๋ ๋ถ๊ตฌํ๊ณ , ์ด๋ ๋ถํ ์ ๋๋ฉ์ธ ์ํ๋ฅผ ํ๊ฐํฉ๋๋ค:
- DOMAIN_JOIN_GUID โ ๋๋ฉ์ธ์ ๊ฐ์ ๋์ด ์์ผ๋ฉด ์๋น์ค๋ฅผ ์์
- DOMAIN_LEAVE_GUID โ ๋๋ฉ์ธ์ ๊ฐ์ ๋์ด ์์ง ์์ ๋๋ง ์๋น์ค๋ฅผ ์์
System State Change โ WNF (undocumented)
์ผ๋ถ ์๋น์ค๋ ๋ฌธ์ํ๋์ง ์์ WNF ๊ธฐ๋ฐ ํธ๋ฆฌ๊ฑฐ(SERVICE_TRIGGER_TYPE 0x7)๋ฅผ ์ฌ์ฉํฉ๋๋ค. ํ์ฑํํ๋ ค๋ฉด ๊ด๋ จ WNF ์ํ๋ฅผ publishํด์ผ ํ๋ฉฐ, ๊ตฌ์ฒด์ฌํญ์ ์ํ ์ด๋ฆ์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค. ์ฐ๊ตฌ ๋ฐฐ๊ฒฝ: Windows Notification Facility ๋ด๋ถ ๋์.
Aggregate Service Triggers (undocumented)
Windows 11์ ์ผ๋ถ ์๋น์ค(์: CDPSvc)์์ ๊ด์ฐฐ๋ฉ๋๋ค. ์ง๊ณ๋ ๊ตฌ์ฑ์ ๋ค์์ ์ ์ฅ๋ฉ๋๋ค:
- HKLM\SYSTEM\CurrentControlSet\Control\ServiceAggregatedEvents
์๋น์ค์ Trigger ๊ฐ์ GUID์ด๊ณ , ํด๋น GUID๋ฅผ ๊ฐ์ง ์๋ธํค๊ฐ ์ง๊ณ๋ ์ด๋ฒคํธ๋ฅผ ์ ์ํฉ๋๋ค. ๊ตฌ์ฑ์์ ์ด๋ฒคํธ ์ค ์ด๋ ํ๋๋ผ๋ ํธ๋ฆฌ๊ฑฐ๋๋ฉด ์๋น์ค๊ฐ ์์๋ฉ๋๋ค.
Firewall Port Event (quirks and DoS risk)
ํน์ ํฌํธ/ํ๋กํ ์ฝ์ ๋ฒ์๊ฐ ์ ํด์ง ํธ๋ฆฌ๊ฑฐ๊ฐ ๊ด์ฐฐ๋ ๋ฐ์ ๋ฐ๋ฅด๋ฉด, ์ค์ ์ง์ ๋ ํฌํธ ๋ณ๊ฒฝ๋ฟ๋ง ์๋๋ผ ๋ฐฉํ๋ฒฝ ๊ท์น์ ์๋ฌด ๋ณ๊ฒฝ(๋นํ์ฑํ/์ญ์ /์ถ๊ฐ)์๋ ์์๋ ์ ์์ต๋๋ค. ๋ ์ ํ๋๋ ๊ฒฝ์ฐ, ํ๋กํ ์ฝ ์์ด ํฌํธ๋ฅผ ๊ตฌ์ฑํ๋ฉด ์ฌ๋ถํ ์ BFE ์์์ด ์์๋์ด ์ฐ์์ ์ผ๋ก ๋ง์ ์๋น์ค๊ฐ ์คํจํ๊ณ ๋ฐฉํ๋ฒฝ ๊ด๋ฆฌ๊ฐ ๋ง๊ฐ์ง ์ ์์ต๋๋ค. ๊ทน๋๋ก ์ฃผ์ํด์ ๋ค๋ฃจ์ญ์์ค.
Practical Workflow
- ํฅ๋ฏธ๋ก์ด ์๋น์ค(RemoteRegistry, WebClient, EFS, โฆ)์ ํธ๋ฆฌ๊ฑฐ๋ฅผ ์ด๊ฑฐํฉ๋๋ค:
sc.exe qtriggerinfo <Service>reg query HKLM\SYSTEM\CurrentControlSet\Services\<Service>\TriggerInfo /s
- Network Endpoint ํธ๋ฆฌ๊ฑฐ๊ฐ ์๋ ๊ฒฝ์ฐ:
- Named pipe โ \.\pipe<PipeName>์ ๋ํ ํด๋ผ์ด์ธํธ ์คํ ์๋
- RPC endpoint โ ์ธํฐํ์ด์ค UUID์ ๋ํด Endpoint Mapper ์กฐํ ์ํ
- ETW ํธ๋ฆฌ๊ฑฐ๊ฐ ์๋ ๊ฒฝ์ฐ:
sc.exe qtriggerinfo๋ก provider ๋ฐ ํํฐ๋ฅผ ํ์ธ; ํํฐ๊ฐ ์์ผ๋ฉด ํด๋น provider์ ์ด๋ค ์ด๋ฒคํธ๋ผ๋ ์๋น์ค๋ฅผ ์์ํฉ๋๋ค
- Group Policy/IP/Device/Domain ํธ๋ฆฌ๊ฑฐ์ ๊ฒฝ์ฐ:
- ํ๊ฒฝ์ ์ด์ฉํ ์กฐ์:
gpupdate /force, NIC ํ ๊ธ, ์ฅ์น ํซํ๋ฌ๊ทธ ๋ฑ
Related
- Named Pipe ํธ๋ฆฌ๊ฑฐ๋ฅผ ํตํด ๊ถํ ๋์ ์๋น์ค๋ฅผ ์์ํ ํ์๋ ํด๋น ์๋น์ค๋ฅผ ์ํผ์จ๋ค์ด์ ํ ์ ์์ ์ ์์ต๋๋ค:
Named Pipe Client Impersonation
Quick command recap
- List triggers (local):
sc.exe qtriggerinfo <Service> - Registry view:
reg query HKLM\SYSTEM\CurrentControlSet\Services\<Service>\TriggerInfo /s - Win32 API:
QueryServiceConfig2(..., SERVICE_CONFIG_TRIGGER_INFO, ...) - RPC remote (Titanis):
Scm.exe qtriggers - ETW provider check (WebClient):
logman query providers | findstr /I 22b6d684-fa63-4578-87c9-effcbe6643c7
Detection and Hardening Notes
- ์๋น์ค ์ ๋ฐ์์ TriggerInfo์ ๋ฒ ์ด์ค๋ผ์ธ์ ๋ง๋ค๊ณ ๊ฐ์ฌํ์ญ์์ค. ๋ํ ์ง๊ณ ํธ๋ฆฌ๊ฑฐ๋ HKLM\SYSTEM\CurrentControlSet\Control\ServiceAggregatedEvents๋ฅผ ๊ฒํ ํ์ญ์์ค.
- ๊ถํ์ด ๋์ ์๋น์ค UUID์ ๋ํ ์์ฌ์ค๋ฌ์ด EPM ์กฐํ ๋ฐ ์๋น์ค ์์์ ์์ named-pipe ์ฐ๊ฒฐ ์๋๋ฅผ ๋ชจ๋ํฐ๋งํ์ญ์์ค.
- ๋๊ฐ ์๋น์ค ํธ๋ฆฌ๊ฑฐ๋ฅผ ์์ ํ ์ ์๋์ง ์ ํํ์ญ์์ค; ํธ๋ฆฌ๊ฑฐ ๋ณ๊ฒฝ ํ ์๊ธฐ์น ์์ BFE ์คํจ๋ ์์ฌ์ค๋ฌ์ด ์งํ๋ก ์ทจ๊ธํ์ญ์์ค.
References
- Thereโs More than One Way to Trigger a Windows Service (TrustedSec)
- QueryServiceConfig2 function (Win32 API)
- MS-SCMR: Service Control Manager Remote Protocol โ QueryServiceConfig2
- TrustedSec Titanis (SCM trigger enumeration)
- Cobalt Strike BOF example โ sc_qtriggerinfo
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


