Telephony tapsrv Arbitrary DWORD Write to RCE (TAPI Server Mode)
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
When the Windows Telephony service (TapiSrv, tapisrv.dll) is configured as a TAPI server, it exposes the tapsrv MSRPC interface over the \pipe\tapsrv named pipe to authenticated SMB clients. A design bug in the asynchronous event delivery for remote clients lets an attacker turn a mailslot handle into a controlled 4-byte write to any pre-existing file writable by NETWORK SERVICE. That primitive can be chained to overwrite the Telephony admin list and abuse an admin-only arbitrary DLL load to execute code as NETWORK SERVICE.
๊ณต๊ฒฉ ํ๋ฉด
- ์๊ฒฉ ๋
ธ์ถ์ ํ์ฑํ๋ ๊ฒฝ์ฐ์๋ง:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Server\DisableSharing๊ฐ ๊ณต์ ๋ฅผ ํ์ฉํด์ผ ํจ(๋๋TapiMgmt.msc/tcmsetup /c <server>๋ก ๊ตฌ์ฑ). ๊ธฐ๋ณธ์ ์ผ๋กtapsrv๋ ๋ก์ปฌ ์ ์ฉ์. - ์ธํฐํ์ด์ค: MS-TRP (
tapsrv)๊ฐ SMB named pipe๋ฅผ ํตํด ์ ๊ณต๋๋ฏ๋ก ๊ณต๊ฒฉ์๋ ์ ํจํ SMB ์ธ์ฆ์ด ํ์ํจ. - ์๋น์ค ๊ณ์ :
NETWORK SERVICE(์๋ ์์, ์จ๋๋งจ๋).
์์ ๊ธฐ๋ฅ: Mailslot ๊ฒฝ๋ก ํผ๋ โ ์์ DWORD ์ฐ๊ธฐ
ClientAttach(pszDomainUser, pszMachine, ...)๋ ๋น๋๊ธฐ ์ด๋ฒคํธ ์ ๋ฌ์ ์ด๊ธฐํํจ. pull ๋ชจ๋์์ ์๋น์ค๋ ๋ค์์ ์ํ:
CreateFileW(pszDomainUser, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
pszDomainUser๊ฐ mailslot ๊ฒฝ๋ก(\\*\MAILSLOT\...)์ธ์ง ๊ฒ์ฆํ์ง ์์. NETWORK SERVICE๋ก ์ฐ๊ธฐ๊ฐ ๊ฐ๋ฅํ ๊ธฐ์กด ํ์ผ ์์คํ
๊ฒฝ๋ก๋ผ๋ฉด ๋ชจ๋ ํ์ฉ๋จ.
- ๊ฐ ๋น๋๊ธฐ ์ด๋ฒคํธ ์ฐ๊ธฐ๋ ์ด๋ฆฐ ํธ๋ค์ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ๋จ์ผ
DWORD=InitContext(์ดํInitialize์์ฒญ์์ ์ ์ด ๊ฐ๋ฅ)๋ฅผ ์ ์ฅํ๋ฏ๋ก **write-what/write-where (4 bytes)**๊ฐ ๋ฐ์ํจ.
๊ฒฐ์ ์ ์ฐ๊ธฐ ๊ฐ์ ๋ฐฉ๋ฒ
- ๋์ ํ์ผ ์ด๊ธฐ:
ClientAttach๋ฅผpszDomainUser = <existing writable path>(์:C:\Windows\TAPI\tsec.ini)๋ก ํธ์ถ. - ๊ฐ
DWORD๋ฅผ ์ฐ๋ ค๋ฉดClientRequest์ ๋ํด ๋ค์ RPC ์ํ์ค๋ฅผ ์คํ:
Initialize(Req_Func 47):InitContext = <4-byte value>์pszModuleName = DIALER.EXE(๋๋ per-user priority ๋ฆฌ์คํธ์ ์์ ํญ๋ชฉ) ์ค์ .LRegisterRequestRecipient(Req_Func 61):dwRequestMode = LINEREQUESTMODE_MAKECALL,bEnable = 1(๋ผ์ธ ์ฑ ๋ฑ๋ก, ์ต๊ณ ์ฐ์ ์์ ์ ์ฌ๊ณ์ฐ).TRequestMakeCall(Req_Func 121):NotifyHighestPriorityRequestRecipient๋ฅผ ๊ฐ์ ํ์ฌ ๋น๋๊ธฐ ์ด๋ฒคํธ ์์ฑ.GetAsyncEvents(Req_Func 0): ํ์์ ๊บผ๋ด์ด/์๋ฃํ์ฌ ์ฐ๊ธฐ ์คํ.- ๋ค์
LRegisterRequestRecipient๋ฅผbEnable = 0์ผ๋ก(๋ฑ๋ก ํด์ ). Shutdown(Req_Func 86)์ผ๋ก ๋ผ์ธ ์ฑ ์ข ๋ฃ.- ์ฐ์ ์์ ์ ์ด: โhighest priorityโ ์์ ์๋
pszModuleName์HKCU\Software\Microsoft\Windows\CurrentVersion\Telephony\HandoffPriorities\RequestMakeCall๊ณผ ๋น๊ตํ์ฌ ์ ํ(ํด๋ผ์ด์ธํธ๋ก ์์(impersonate)ํ ์ํ์์ ์ฝ์). ํ์์LSetAppPriority(Req_Func 69)๋ก ๋ชจ๋ ์ด๋ฆ์ ์ฝ์ . - ํ์ผ์
OPEN_EXISTING์ ์ฌ์ฉํ๋ฏ๋ก ์ด๋ฏธ ์กด์ฌํด์ผ ํจ.NETWORK SERVICE๋ก ์ฐ๊ธฐ๊ฐ ๊ฐ๋ฅํ ์ผ๋ฐ ํ๋ณด:C:\Windows\System32\catroot2\dberr.txt,C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\MpCmdRun.log,...\MpSigStub.log.
DWORD ์ฐ๊ธฐ์์ TapiSrv ๋ด๋ถ RCE๋ก
- ์๊ธฐ ์์ ์๊ฒ Telephony โadminโ ๊ถํ ๋ถ์ฌ:
C:\Windows\TAPI\tsec.ini๋ฅผ ๋ชฉํ๋ก ํ๊ณ ์์ 4๋ฐ์ดํธ ์ฐ๊ธฐ๋ฅผ ์ด์ฉํด[TapiAdministrators]\r\n<DOMAIN\\user>=1์ ์ถ๊ฐ. ์๋น์ค๊ฐ INI๋ฅผ ๋ค์ ์ฝ๊ณ ๊ณ์ ์ ๋ํดptClient->dwFlags |= 9์ ์ค์ ํ๋๋ก ์๋ก์ด ์ธ์ (ClientAttach)์ ์์. - ๊ด๋ฆฌ์ ์ ์ฉ DLL ๋ก๋ ์ค์ฉ:
GetUIDllName์dwObjectType = TUISPIDLL_OBJECT_PROVIDERID๋ก ๋ณด๋ด๊ณdwProviderFilenameOffset๋ก ๊ฒฝ๋ก๋ฅผ ์ ๊ณต. ๊ด๋ฆฌ์๋ผ๋ฉด ์๋น์ค๋LoadLibrary(path)๋ฅผ ํธ์ถํ ๋ค ๋ด๋ณด๋ธ ํจ์TSPI_providerUIIdentify๋ฅผ ํธ์ถ:
- UNC ๊ฒฝ๋ก๋ก ์ค์ Windows SMB ๊ณต์ ๋ฅผ ๊ฐ๋ฆฌํค๋ฉด ๋์; ์ผ๋ถ ๊ณต๊ฒฉ์ SMB ์๋ฒ๋
ERROR_SMB_GUEST_LOGON_BLOCKED๋ก ์คํจํจ. - ๋์: ๋์ผํ 4๋ฐ์ดํธ ์ฐ๊ธฐ ์์ ๊ธฐ๋ฅ์ ์ฌ์ฉํด ๋ก์ปฌ์ DLL์ ์ฒ์ฒํ ์์ฑํ ๋ค ๋ก๋.
- ํ์ด๋ก๋: ํด๋น export๋
NETWORK SERVICE๊ถํ์ผ๋ก ์คํ๋จ. ์ต์ํ์ DLL์cmd.exe /c whoami /all > C:\Windows\Temp\poc.txt๋ฅผ ์คํํ๊ณ ์๋น์ค๊ฐ DLL์ ์ธ๋ก๋ํ๋๋ก ๋น์(้0) ๊ฐ์ ๋ฐํ(์:0x1337)ํ๋ฉด ์คํ ํ์ธ ๊ฐ๋ฅ.
ํ๋๋ / ํ์ง ๋ฉ๋ชจ
- ํ์ํ์ง ์๋ค๋ฉด TAPI server ๋ชจ๋๋ฅผ ๋นํ์ฑํ;
\pipe\tapsrv์ ๋ํ ์๊ฒฉ ์ ๊ทผ ์ฐจ๋จ. - ํด๋ผ์ด์ธํธ๊ฐ ์ ๊ณตํ ๊ฒฝ๋ก๋ฅผ ์ด๊ธฐ ์ ์ mailslot ๋ค์์คํ์ด์ค ๊ฒ์ฆ(
\\*\MAILSLOT\)์ ์ ์ฉ. C:\Windows\TAPI\tsec.iniACL์ ์ ๊ทธ๊ณ ๋ณ๊ฒฝ์ ๋ชจ๋ํฐ๋ง; ๊ธฐ๋ณธ ๊ฒฝ๋ก๊ฐ ์๋ ๊ฒฝ๋ก๋ก ๋ก๋ํ๋GetUIDllNameํธ์ถ์ ๋ํด ๊ฒฝ๊ณ .
References
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


