SIP (Session Initiation Protocol)
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
SIP (Session Initiation Protocol)์ IP ๋คํธ์ํฌ ์์์ ์์ฑ, ๋น๋์ค, ์ธ์คํดํธ ๋ฉ์์ง์ ํฌํจํ ๋ฉํฐ๋ฏธ๋์ด ์ธ์ ์ ์ค์ , ์์ ๋ฐ ์ข ๋ฃํ๋ ๋ฐ ๋๋ฆฌ ์ฌ์ฉ๋๋ ์ ํธ ๋ฐ ํตํ ์ ์ด ํ๋กํ ์ฝ์ ๋๋ค. **Internet Engineering Task Force (IETF)**์์ ๊ฐ๋ฐ๋์์ผ๋ฉฐ, SIP๋ RFC 3261์ ์ ์๋์ด VoIP ๋ฐ ํตํฉ ์ปค๋ฎค๋์ผ์ด์ ์ ์ฌ์ค์ ํ์ค์ด ๋์์ต๋๋ค.
SIP์ ์ฃผ์ ํน์ง์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- ํ ์คํธ ๊ธฐ๋ฐ ํ๋กํ ์ฝ: SIP๋ ํ ์คํธ ๊ธฐ๋ฐ ํ๋กํ ์ฝ๋ก ์ฌ๋์ด ์ฝ๊ธฐ ์ฝ๊ณ ๋๋ฒ๊น ํ๊ธฐ ์ฉ์ดํฉ๋๋ค. HTTP์ ์ ์ฌํ ์์ฒญ-์๋ต ๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก ํ๋ฉฐ, INVITE, ACK, BYE, CANCEL ๋ฑ์ ๋ฉ์๋๋ฅผ ์ฌ์ฉํด ํตํ ์ธ์ ์ ์ ์ดํฉ๋๋ค.
- ํ์ฅ์ฑ๊ณผ ์ ์ฐ์ฑ: SIP๋ ๋์ ํ์ฅ์ฑ์ ๊ฐ์ง๋ฉฐ ์๊ท๋ชจ ๋ฐฐํฌ๋ถํฐ ๋๊ท๋ชจ ์ํฐํ๋ผ์ด์ฆ ๋ฐ ํต์ ์ฌ์ ์๊ธ ํ๊ฒฝ๊น์ง ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋ก์ด ๊ธฐ๋ฅ์ผ๋ก ์ฝ๊ฒ ํ์ฅํ ์ ์์ด ๋ค์ํ ์ฌ์ฉ ์ฌ๋ก์ ์๊ตฌ์ฌํญ์ ์ ์ํ ์ ์์ต๋๋ค.
- ์ํธ์ด์ฉ์ฑ: SIP์ ๊ด๋ฒ์ํ ์ฑํ๊ณผ ํ์คํ๋ ๋ค์ํ ์ฅ์น, ์ ํ๋ฆฌ์ผ์ด์ , ์๋น์ค ์ ๊ณต์ ๊ฐ์ ๋ ๋์ ์ํธ์ด์ฉ์ฑ์ ๋ณด์ฅํ์ฌ ๋ค์ํ ํ๋ซํผ ๊ฐ์ ์ํํ ํต์ ์ ์ด์งํฉ๋๋ค.
- ๋ชจ๋ํ ์ค๊ณ: SIP๋ ๋ฏธ๋์ด ์ ์ก์ ์ํ RTP (Real-time Transport Protocol) ๋ฐ ๋ฉํฐ๋ฏธ๋์ด ์ธ์ ์ ์ค๋ช ํ๊ธฐ ์ํ SDP (Session Description Protocol) ๋ฑ ๋ค๋ฅธ ํ๋กํ ์ฝ๊ณผ ํจ๊ป ์๋ํฉ๋๋ค. ์ด ๋ชจ๋ํ ์ค๊ณ๋ ๋ค์ํ ๋ฏธ๋์ด ์ ํ๊ณผ ์ฝ๋ฑ๊ณผ์ ํธํ์ฑ์ ๋์ด๊ณ ์ ์ฐ์ฑ์ ์ ๊ณตํฉ๋๋ค.
- ํ๋ก์ ๋ฐ ๋ฆฌ๋ค์ด๋ ํธ ์๋ฒ: SIP๋ ํ๋ก์ ๋ฐ ๋ฆฌ๋ค์ด๋ ํธ ์๋ฒ๋ฅผ ์ฌ์ฉํ์ฌ ํตํ ๋ผ์ฐํ ์ ์ฉ์ดํ๊ฒ ํ๋ฉฐ, ์ฐฉ์ ์ ํ, ํตํ ์ ๋ฌ, ์์ฑ์ฌ์ํจ๊ณผ ๊ฐ์ ๊ณ ๊ธ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
- ํ๋ ์ฆ์ค ๋ฐ ์ธ์คํดํธ ๋ฉ์์ง: SIP๋ ์์ฑ ๋ฐ ๋น๋์ค ํต์ ์ ๊ตญํ๋์ง ์์ต๋๋ค. ํ๋ ์ฆ์ค ๋ฐ ์ธ์คํดํธ ๋ฉ์์ง์ ์ง์ํ์ฌ ๋ค์ํ ํตํฉ ์ปค๋ฎค๋์ผ์ด์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
๋ง์ ์ฅ์ ์๋ ๋ถ๊ตฌํ๊ณ , SIP๋ NAT ํต๊ณผ ๋ฐ ๋ฐฉํ๋ฒฝ ๋ฌธ์ ๋ฅผ ๋ค๋ฃฐ ๋ ํนํ ๊ตฌ์ฑ ๋ฐ ๊ด๋ฆฌ๊ฐ ๋ณต์กํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ทธ ๋ฒ์ฉ์ฑ, ํ์ฅ์ฑ ๋ฐ ์ ๊ณ ์ ๋ฐ์ ๊ด๋ฒ์ํ ์ง์์ผ๋ก ์ธํด VoIP ๋ฐ ๋ฉํฐ๋ฏธ๋์ด ํต์ ์ ์ธ๊ธฐ ์๋ ์ ํ์ ๋๋ค.
SIP ๋ฉ์๋
RFC 3261์ ์ ์๋ ํต์ฌ SIP ๋ฉ์๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- INVITE: ์ ์ธ์ (ํตํ)์ ์์ํ๊ฑฐ๋ ๊ธฐ์กด ์ธ์ ์ ์์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. INVITE ๋ฉ์๋๋ ์ ์๋ ์ธ์ ์ ์ธ๋ถ์ฌํญ(์ผ๋ฐ์ ์ผ๋ก SDP ์ฌ์ฉ)์ ์ ๋ฌํ์ฌ ์์ ์์๊ฒ ๋ฏธ๋์ด ์ ํ, ์ฝ๋ฑ ๋ฐ ์ ์ก ํ๋กํ ์ฝ๊ณผ ๊ฐ์ ์ ๋ณด๋ฅผ ์๋ฆฝ๋๋ค.
- ACK: INVITE ์์ฒญ์ ๋ํ ์ต์ข ์๋ต์ ์์ ์ ํ์ธํ๊ธฐ ์ํด ์ ์ก๋ฉ๋๋ค. ACK ๋ฉ์๋๋ ์ข ๋จ ๊ฐ ํ์ธ์ ์ ๊ณตํ์ฌ INVITE ํธ๋์ญ์ ์ ์ ๋ขฐ์ฑ์ ๋ณด์ฅํฉ๋๋ค.
- BYE: ํ๋ฆฝ๋ ์ธ์ (ํตํ)์ ์ข ๋ฃํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. BYE ๋ฉ์๋๋ ์ธ์ ์ ์ด๋ ์ชฝ์ด๋ ํตํ๋ฅผ ์ข ๋ฃํ๋ ค๋ ์์ฌ๋ฅผ ํ์ํ๊ธฐ ์ํด ์ ์ก๋ฉ๋๋ค.
- CANCEL: ์ธ์ ์ด ์ฑ๋ฆฝ๋๊ธฐ ์ ์ ๋ณด๋ฅ ์ค์ธ INVITE ์์ฒญ์ ์ทจ์ํ๊ธฐ ์ํด ์ ์ก๋ฉ๋๋ค. CANCEL ๋ฉ์๋๋ ๋ฐ์ ์๊ฐ ๋ง์์ ๋ฐ๊พธ๊ฑฐ๋ ์์ ์๋ก๋ถํฐ ์๋ต์ด ์๋ ๊ฒฝ์ฐ INVITE ํธ๋์ญ์ ์ ์ค๋จํ ์ ์๊ฒ ํฉ๋๋ค.
- OPTIONS: SIP ์๋ฒ ๋๋ ์ฌ์ฉ์ ์์ด์ ํธ์ ๊ธฐ๋ฅ์ ์ง์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. OPTIONS ๋ฉ์๋๋ ์ค์ ๋ก ์ธ์ ์ ์ฑ๋ฆฝํ์ง ์๊ณ ๋ ์ง์๋๋ ๋ฉ์๋, ๋ฏธ๋์ด ์ ํ ๋๋ ๊ธฐํ ํ์ฅ์ ๋ํ ์ ๋ณด๋ฅผ ์์ฒญํ ์ ์์ต๋๋ค.
- REGISTER: ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ SIP ๋ ์ง์คํธ๋ผ ์๋ฒ์ ํ์ฌ ์์น๋ฅผ ๋ฑ๋กํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. REGISTER ๋ฉ์๋๋ ์ฌ์ฉ์์ SIP URI์ ํ์ฌ IP ์ฃผ์ ๊ฐ์ ์ต์ ๋งคํ์ ์ ์งํ์ฌ ํตํ ๋ผ์ฐํ ๋ฐ ์ ๋ฌ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
Warning
Note that to call someone itโs not neccesary to use the REGISTER for anything.
However, itโs possible that in order to perform an INVITE the caller needs to authenticate first or he will receive a401 Unauthorizedresponse.
์ด ํต์ฌ ๋ฉ์๋๋ค ์ธ์๋ RFC ๋ฑ ๋ค๋ฅธ ๋ฌธ์๋ค์ ์ ์๋ ์ฌ๋ฌ SIP ํ์ฅ ๋ฉ์๋๊ฐ ์์ต๋๋ค:
- SUBSCRIBE: RFC 6665์ ์ ์๋ SUBSCRIBE ๋ฉ์๋๋ ์ฌ์ฉ์์ ํ๋ ์ฆ์ค๋ ํตํ ์ํ์ ๊ฐ์ ํน์ ๋ฆฌ์์ค์ ์ํ์ ๋ํ ์๋ฆผ์ ์์ฒญํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
- NOTIFY: ์ญ์ RFC 6665์ ์ ์๋ NOTIFY ๋ฉ์๋๋ ์๋ฒ๊ฐ ๊ตฌ๋ ํ ์ฌ์ฉ์ ์์ด์ ํธ์๊ฒ ๋ชจ๋ํฐ๋ง ์ค์ธ ๋ฆฌ์์ค ์ํ์ ๋ณ๊ฒฝ์ ํต์งํ๊ธฐ ์ํด ์ ์กํฉ๋๋ค.
- REFER: RFC 3515์ ์ ์๋ REFER ๋ฉ์๋๋ ์์ ์์๊ฒ ์ ๋ฌ์ ์ํํ๊ฑฐ๋ ์ 3์๋ฅผ ์ฐธ์กฐํ๋๋ก ์์ฒญํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ฃผ๋ก ํตํ ์ ๋ฌ ์๋๋ฆฌ์ค์์ ์ฌ์ฉ๋ฉ๋๋ค.
- MESSAGE: RFC 3428์ ์ ์๋ MESSAGE ๋ฉ์๋๋ SIP ์ฌ์ฉ์ ์์ด์ ํธ ๊ฐ์ ์ธ์คํดํธ ๋ฉ์์ง๋ฅผ ์ ์กํ๋ ๋ฐ ์ฌ์ฉ๋์ด SIP ํ๋ ์์ํฌ ๋ด์์ ํ ์คํธ ๊ธฐ๋ฐ ํต์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
- UPDATE: RFC 3311์ ์ ์๋ UPDATE ๋ฉ์๋๋ ๊ธฐ์กด ๋ํ์ ์ํ์ ์ํฅ์ ์ฃผ์ง ์๊ณ ์ธ์ ์ ์์ ํ ์ ์๊ฒ ํฉ๋๋ค. ์ด๋ ์งํ ์ค์ธ ํตํ ์ค์ ์ฝ๋ฑ์ด๋ ๋ฏธ๋์ด ์ ํ๊ณผ ๊ฐ์ ์ธ์ ๋งค๊ฐ๋ณ์๋ฅผ ์ ๋ฐ์ดํธํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
- PUBLISH: RFC 3903์ ์ ์๋ PUBLISH ๋ฉ์๋๋ ์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์๋ฒ์ ์ด๋ฒคํธ ์ํ ์ ๋ณด๋ฅผ ๊ฒ์ํ์ฌ ๋ค๋ฅธ ๊ด์ฌ ์๋ ๋น์ฌ์๋ค์ด ์ด์ฉํ ์ ์๊ฒ ํฉ๋๋ค.
SIP ์๋ต ์ฝ๋
- 1xx (์์ ์๋ต): ์ด๋ฌํ ์๋ต์ ์์ฒญ์ด ์์ ๋์๊ณ ์๋ฒ๊ฐ ๊ณ์ ์ฒ๋ฆฌ ์ค์์ ๋ํ๋ ๋๋ค.
- 100 Trying: ์์ฒญ์ด ์์ ๋์์ผ๋ฉฐ ์๋ฒ๊ฐ ์์ ์ค์ ๋๋ค.
- 180 Ringing: ํผํธ์ถ์์๊ฒ ์๋ฆผ์ด ๊ฐ๊ณ ์์ผ๋ฉฐ ํตํ๋ฅผ ๋ฐ์ ์ค๋น๋ฅผ ํ๊ณ ์์ต๋๋ค.
- 183 Session Progress: ํตํ์ ์งํ ์ํฉ์ ๋ํ ์ ๋ณด๋ฅผ ์ ๊ณตํฉ๋๋ค.
- 2xx (์ฑ๊ณต ์๋ต): ์ด๋ฌํ ์๋ต์ ์์ฒญ์ด ์ฑ๊ณต์ ์ผ๋ก ์์ , ์ดํด ๋ฐ ์๋ฝ๋์์์ ๋ํ๋ ๋๋ค.
- 200 OK: ์์ฒญ์ด ์ฑ๊ณต์ ์ผ๋ก ์ฒ๋ฆฌ๋์์ต๋๋ค.
- 202 Accepted: ์์ฒญ์ด ์ฒ๋ฆฌ์ฉ์ผ๋ก ์๋ฝ๋์์ง๋ง ์์ง ์๋ฃ๋์ง๋ ์์์ต๋๋ค.
- 3xx (๋ฆฌ๋ค์ด๋ ์ ์๋ต): ์ด๋ฌํ ์๋ต์ ์์ฒญ์ ์๋ฃํ๊ธฐ ์ํด ์ถ๊ฐ ์กฐ์น๊ฐ ํ์ํจ์ ๋ํ๋ด๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก ๋ค๋ฅธ ๋ฆฌ์์ค์ ์ฐ๋ฝํด์ผ ํจ์ ์๋ฏธํฉ๋๋ค.
- 300 Multiple Choices: ์ฌ์ฉ ๊ฐ๋ฅํ ์ฌ๋ฌ ์ต์ ์ด ์์ผ๋ฉฐ ์ฌ์ฉ์๋ ํด๋ผ์ด์ธํธ๊ฐ ํ๋๋ฅผ ์ ํํด์ผ ํฉ๋๋ค.
- 301 Moved Permanently: ์์ฒญ๋ ๋ฆฌ์์ค๊ฐ ์๋ก์ด ์๊ตฌ URI๋ก ํ ๋น๋์์ต๋๋ค.
- 302 Moved Temporarily: ์์ฒญ๋ ๋ฆฌ์์ค๊ฐ ์์๋ก ๋ค๋ฅธ URI์์ ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
- 305 Use Proxy: ์์ฒญ์ ์ง์ ๋ ํ๋ก์๋ก ์ ์ก๋์ด์ผ ํฉ๋๋ค.
- 4xx (ํด๋ผ์ด์ธํธ ์ค๋ฅ ์๋ต): ์ด๋ฌํ ์๋ต์ ์์ฒญ์ ์๋ชป๋ ๊ตฌ๋ฌธ์ด ํฌํจ๋์๊ฑฐ๋ ์๋ฒ๊ฐ ์์ฒญ์ ์ดํํ ์ ์์์ ๋ํ๋ ๋๋ค.
- 400 Bad Request: ์์ฒญ์ด ์๋ชป๋์๊ฑฐ๋ ์ ํจํ์ง ์์ต๋๋ค.
- 401 Unauthorized: ์์ฒญ์ ์ฌ์ฉ์ ์ธ์ฆ์ด ํ์ํฉ๋๋ค.
- 403 Forbidden: ์๋ฒ๋ ์์ฒญ์ ์ดํดํ์ง๋ง ์ด๋ฅผ ์ดํํ๊ธฐ๋ฅผ ๊ฑฐ๋ถํฉ๋๋ค.
- 404 Not Found: ์์ฒญ๋ ๋ฆฌ์์ค๋ฅผ ์๋ฒ์์ ์ฐพ์ ์ ์์ต๋๋ค.
- 408 Request Timeout: ์๋ฒ๊ฐ ๊ธฐ๋ค๋ฆด ์ค๋น๊ฐ ๋ ์๊ฐ ๋ด์ ์์ ํ ์์ฒญ์ ์์ ํ์ง ๋ชปํ์ต๋๋ค.
- 486 Busy Here: ํผํธ์ถ์๊ฐ ํ์ฌ ๋ฐ๋น ์ ์ ํ๋ฅผ ๋ฐ์ ์ ์์ต๋๋ค.
- 5xx (์๋ฒ ์ค๋ฅ ์๋ต): ์ด๋ฌํ ์๋ต์ ์๋ฒ๊ฐ ์ ํจํ ์์ฒญ์ ์ดํํ์ง ๋ชปํ์์ ๋ํ๋ ๋๋ค.
- 500 Internal Server Error: ์๋ฒ๊ฐ ์์ฒญ์ ์ฒ๋ฆฌํ๋ ๋์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
- 501 Not Implemented: ์๋ฒ๊ฐ ์์ฒญ์ ์ดํํ๋ ๋ฐ ํ์ํ ๊ธฐ๋ฅ์ ์ง์ํ์ง ์์ต๋๋ค.
- 503 Service Unavailable: ์๋ฒ๊ฐ ์ ์ง๋ณด์๋ ๊ณผ๋ถํ๋ก ์ธํด ํ์ฌ ์์ฒญ์ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
- 6xx (์ ์ญ ์คํจ ์๋ต): ์ด๋ฌํ ์๋ต์ ๋คํธ์ํฌ์ ์ด๋ค ์๋ฒ๋ ์์ฒญ์ ์ดํํ ์ ์์์ ๋ํ๋ ๋๋ค.
- 600 Busy Everywhere: ํตํ๋ฅผ ์ํ ๊ฐ๋ฅํ ๋ชจ๋ ๋ชฉ์ ์ง๊ฐ ๋ฐ์ฉ๋๋ค.
- 603 Decline: ํผํธ์ถ์๊ฐ ํตํ์ ์ฐธ์ฌํ๊ณ ์ถ์ดํ์ง ์์ต๋๋ค.
- 604 Does Not Exist Anywhere: ์์ฒญ๋ ๋ฆฌ์์ค๊ฐ ๋คํธ์ํฌ ์ด๋์๋ ์กด์ฌํ์ง ์์ต๋๋ค.
์์
SIP INVITE ์์
INVITE sip:jdoe@example.com SIP/2.0
Via: SIP/2.0/UDP pc33.example.com;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: John Doe <sip:jdoe@example.com>
From: Jane Smith <sip:jsmith@example.org>;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:jsmith@pc33.example.com>
User-Agent: ExampleSIPClient/1.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
Content-Length: 142
v=0
o=jsmith 2890844526 2890842807 IN IP4 pc33.example.com
s=-
c=IN IP4 pc33.example.com
t=0 0
m=audio 49170 RTP/AVP 0
a=rtpmap:0 PCMU/8000
๊ฐ ํ๋ผ๋ฏธํฐ ์ค๋ช
- Request-Line:
INVITE sip:jdoe@example.com SIP/2.0- ์ด ์ค์ ๋ฉ์๋(INVITE), ์์ฒญ URI (sip:jdoe@example.com) ๋ฐ SIP ๋ฒ์ (SIP/2.0)์ ๋ํ๋ ๋๋ค. - Via:
Via: SIP/2.0/UDP pc33.example.com;branch=z9hG4bK776asdhds- Via ํค๋๋ ์ ์ก ํ๋กํ ์ฝ(UDP)๊ณผ ํด๋ผ์ด์ธํธ ์ฃผ์(pc33.example.com)๋ฅผ ์ง์ ํฉ๋๋ค. โbranchโ ๋งค๊ฐ๋ณ์๋ ๋ฃจํ ๊ฐ์ง ๋ฐ ํธ๋์ญ์ ๋งค์นญ์ ์ฌ์ฉ๋ฉ๋๋ค. - Max-Forwards:
Max-Forwards: 70- ์ด ํค๋ ํ๋๋ ํ๋ก์๊ฐ ์์ฒญ์ ์ ๋ฌํ ์ ์๋ ํ์๋ฅผ ์ ํํ์ฌ ๋ฌดํ ๋ฃจํ๋ฅผ ๋ฐฉ์งํฉ๋๋ค. - To:
To: John Doe <sip:jdoe@example.com>- To ํค๋๋ ์์ ์(ํ์ ์ด๋ฆ John Doe ๋ฐ SIP URI sip:jdoe@example.com)๋ฅผ ์ง์ ํฉ๋๋ค. - From:
From: Jane Smith <sip:jsmith@example.org>;tag=1928301774- From ํค๋๋ ๋ฐ์ ์(ํ์ ์ด๋ฆ Jane Smith ๋ฐ SIP URI sip:jsmith@example.org)๋ฅผ ์ง์ ํฉ๋๋ค. โtagโ ๋งค๊ฐ๋ณ์๋ ๋ค์ด์ผ๋ก๊ทธ์์ ๋ฐ์ ์์ ์ญํ ์ ๊ณ ์ ํ๊ฒ ์๋ณํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. - Call-ID:
Call-ID: a84b4c76e66710- Call-ID ํค๋๋ ๋ ์ฌ์ฉ์ ์์ด์ ํธ ๊ฐ์ ํตํ ์ธ์ ์ ๊ณ ์ ํ๊ฒ ์๋ณํฉ๋๋ค. - CSeq:
CSeq: 314159 INVITE- CSeq ํค๋๋ ์ํ์ค ๋ฒํธ์ ์์ฒญ์ ์ฌ์ฉ๋ ๋ฉ์๋๋ฅผ ํฌํจํฉ๋๋ค. ์ด๋ ์๋ต์ ์์ฒญ์ ๋งค์นญํ๊ณ ๋ฉ์์ง์ ์์๊ฐ ์ด๊ธ๋ฌ๋์ง ๊ฐ์งํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. - Contact:
Contact: <sip:jsmith@pc33.example.com>- Contact ํค๋๋ ๋ฐ์ ์์ ๋ํ ์ง์ ๊ฒฝ๋ก๋ฅผ ์ ๊ณตํ๋ฉฐ ์ดํ์ ์์ฒญ๊ณผ ์๋ต์ ์ฌ์ฉํ ์ ์์ต๋๋ค. - User-Agent:
User-Agent: ExampleSIPClient/1.0- User-Agent ํค๋๋ ๋ฐ์ ์์ ์ํํธ์จ์ด ๋๋ ํ๋์จ์ด์ ๋ํ ์ ๋ณด(์ด๋ฆ ๋ฐ ๋ฒ์ )๋ฅผ ์ ๊ณตํฉ๋๋ค. - Allow:
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO- Allow ํค๋๋ ๋ฐ์ ์๊ฐ ์ง์ํ๋ SIP ๋ฉ์๋ ๋ชฉ๋ก์ ์ ๊ณตํฉ๋๋ค. ์ด๋ ์์ ์๊ฐ ํต์ ์ค ์ฌ์ฉํ ์ ์๋ ๋ฉ์๋๋ฅผ ์ดํดํ๋ ๋ฐ ๋์์ ์ค๋๋ค. - Content-Type:
Content-Type: application/sdp- Content-Type ํค๋๋ ๋ฉ์์ง ๋ณธ๋ฌธ์ ๋ฏธ๋์ด ์ ํ์ ์ง์ ํ๋ฉฐ, ์ด ๊ฒฝ์ฐ SDP(Session Description Protocol)์ ๋๋ค. - Content-Length:
Content-Length: 142- Content-Length ํค๋๋ ๋ฉ์์ง ๋ณธ๋ฌธ์ ๋ฐ์ดํธ ํฌ๊ธฐ๋ฅผ ํ์ํฉ๋๋ค. - Message Body: The message body contains the SDP session description, which includes information about the media types, codecs, and transport protocols for the proposed session.
v=0- Protocol version (0 for SDP)o=jsmith 2890844526 2890842807 IN IP4 pc33.example.com- Originator and session identifiers=-- Session name (a single hyphen indicates no session name)c=IN IP4 pc33.example.com- Connection information (network type, address type, and address)t=0 0- Timing information (start and stop times, 0 0 means the session is not bounded)m=audio 49170 RTP/AVP 0- Media description (media type, port number, transport protocol, and format list). In this case, it specifies an audio stream using RTP/AVP (Real-time Transport Protocol / Audio Video Profile) and format 0 (PCMU/8000).a=rtpmap:0 PCMU/8000- Attribute mapping the format (0) to the codec (PCMU) and its clock rate (8000 Hz).
SIP REGISTER ์์
The REGISTER method is used in Session Initiation Protocol (SIP) to allow a user agent (UA), such as a VoIP phone or a softphone, to register its location with a SIP registrar server. This process lets the server know where to route incoming SIP requests destined for the registered user. The registrar server is usually part of a SIP proxy server or a dedicated registration server.
Hereโs a detailed example of the SIP messages involved in a REGISTER authentication process:
- Initial REGISTER request from UA to the registrar server:
REGISTER sip:example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
Max-Forwards: 70
From: Alice <sip:alice@example.com>;tag=565656
To: Alice <sip:alice@example.com>
Call-ID: 1234567890@192.168.1.100
CSeq: 1 REGISTER
Contact: <sip:alice@192.168.1.100:5060>;expires=3600
Expires: 3600
Content-Length: 0
์ด ์ด๊ธฐ REGISTER ๋ฉ์์ง๋ UA (Alice)๊ฐ ๋ ์ง์คํธ๋ผ ์๋ฒ๋ก ์ ์กํฉ๋๋ค. ์ด ๋ฉ์์ง์๋ ์ํ๋ ๋ฑ๋ก ๊ธฐ๊ฐ (Expires), ์ฌ์ฉ์์ SIP URI (sip:alice@example.com), ๊ทธ๋ฆฌ๊ณ ์ฌ์ฉ์์ ์ฐ๋ฝ์ฒ ์ฃผ์ (sip:alice@192.168.1.100:5060)์ ๊ฐ์ ์ค์ํ ์ ๋ณด๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
- ๋ ์ง์คํธ๋ผ ์๋ฒ๋ก๋ถํฐ์ 401 Unauthorized ์๋ต:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
From: Alice <sip:alice@example.com>;tag=565656
To: Alice <sip:alice@example.com>;tag=7878744
Call-ID: 1234567890@192.168.1.100
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="example.com", nonce="abcdefghijk", algorithm=MD5, qop="auth"
Content-Length: 0
๋ ์ง์คํธ๋ผ ์๋ฒ๋ โ401 Unauthorizedโ ์๋ต์ ๋ฐํํ๋ฉฐ, ์ด ์๋ต์๋ โWWW-Authenticateโ ํค๋๊ฐ ํฌํจ๋ฉ๋๋ค. ์ด ํค๋๋ UA๊ฐ ์์ ์ ์ธ์ฆํ๋ ๋ฐ ํ์ํ ์ ๋ณด๋ฅผ ํฌํจํ๋ฉฐ, ์๋ฅผ ๋ค์ด authentication realm, nonce, and algorithm ๋ฑ์ด ์์ต๋๋ค.
- REGISTER ์์ฒญ with authentication credentials:
REGISTER sip:example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
Max-Forwards: 70
From: Alice <sip:alice@example.com>;tag=565656
To: Alice <sip:alice@example.com>
Call-ID: 1234567890@192.168.1.100
CSeq: 2 REGISTER
Contact: <sip:alice@192.168.1.100:5060>;expires=3600
Expires: 3600
Authorization: Digest username="alice", realm="example.com", nonce="abcdefghijk", uri="sip:example.com", response="65a8e2285879283831b664bd8b7f14d4", algorithm=MD5, cnonce="lmnopqrst", qop=auth, nc=00000001
Content-Length: 0
UA๋ ๋ ๋ค๋ฅธ REGISTER ์์ฒญ์ ๋ณด๋ ๋๋ค. ์ด๋ฒ์๋ ์ ๊ณต๋ ์ ๋ณด์ ์ฌ์ฉ์์ ๋น๋ฐ๋ฒํธ๋ฅผ ์ฌ์ฉํด ๊ณ์ฐ๋ ์ฌ์ฉ์ ์ด๋ฆ(username), realm, nonce ๋ฐ ์๋ต๊ฐ(response value)๊ณผ ๊ฐ์ ํ์ํ ์๊ฒฉ ์ฆ๋ช ์ ํฌํจํ โAuthorizationโ header๋ฅผ ํฌํจํฉ๋๋ค.
๋ค์์ Authorization response๊ฐ ๊ณ์ฐ๋๋ ๋ฐฉ๋ฒ์ ๋๋ค:
import hashlib
def calculate_sip_md5_response(username, password, realm, method, uri, nonce, nc, cnonce, qop):
# 1. Calculate HA1 (concatenation of username, realm, and password)
ha1_input = f"{username}:{realm}:{password}"
ha1 = hashlib.md5(ha1_input.encode()).hexdigest()
# 2. Calculate HA2 (concatenation of method and uri)
ha2_input = f"{method}:{uri}"
ha2 = hashlib.md5(ha2_input.encode()).hexdigest()
# 3. Calculate the final response value (concatenation of h1, stuff and h2)
response_input = f"{ha1}:{nonce}:{nc}:{cnonce}:{qop}:{ha2}"
response = hashlib.md5(response_input.encode()).hexdigest()
return response
# Example usage
username = "alice"
password = "mysecretpassword"
realm = "example.com"
method = "REGISTER"
uri = "sip:example.com"
nonce = "abcdefghijk"
nc = "00000001"
cnonce = "lmnopqrst"
qop = "auth"
response = calculate_sip_md5_response(username, password, realm, method, uri, nonce, nc, cnonce, qop)
print(f"MD5 response value: {response}")
- ์ฑ๊ณต์ ์ธ ๋ฑ๋ก ์๋ต (๋ ์ง์คํธ๋ผ ์๋ฒ๋ก๋ถํฐ):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK776asdhds
From: Alice <sip:alice@example.com>;tag=565656
To: Alice <sip:alice@example.com>;tag=7878744
Call-ID: 1234567890@192.168.1.100
CSeq: 2 REGISTER
Contact: <sip:alice@192.168.1.100:5060>;expires=3600
Expires: 3600
Content-Length: 0
๋ฑ๋ก ์๋ฒ๊ฐ ์ ๊ณต๋ ์๊ฒฉ ์ฆ๋ช ์ ํ์ธํ ํ, ๋ฑ๋ก์ด ์ฑ๊ณตํ์์ ์๋ฆฌ๊ธฐ ์ํด โ200 OKโ ์๋ต์ ์ ์กํฉ๋๋ค. ์๋ต์๋ ๋ฑ๋ก๋ contact ์ ๋ณด์ ๋ฑ๋ก์ ๋ง๋ฃ ์๊ฐ์ด ํฌํจ๋ฉ๋๋ค. ์ด ์์ ์์ user agent (Alice)๋ SIP registrar server์ ์ฑ๊ณต์ ์ผ๋ก ๋ฑ๋ก๋๋ฉฐ, Alice๋ก ํฅํ๋ ๋ค์ด์ค๋ SIP ์์ฒญ์ ์ ์ ํ contact ์ฃผ์๋ก ๋ผ์ฐํ ๋ ์ ์์ต๋๋ค.
Call Example
.png)
Tip
์ธ๊ธ๋์ง๋ ์์์ง๋ง, User B๋ ์ ํ๋ฅผ ๋ฐ์ ์ ์๊ธฐ ์ ์ REGISTER message to Proxy 2 ๋ฅผ ๋ณด๋์ด์ผ ํฉ๋๋ค.
SIP Security and Pentesting Notes
์ด ์น์ ์ ๋ ๊ด๋ฒ์ํ VoIP ๊ฐ์ด๋๋ผ์ธ์ ์ค๋ณตํ์ง ์์ผ๋ฉด์ ์ค์ฉ์ ์ด๊ณ ํ๋กํ ์ฝ์ ํนํ๋ ํ์ ์ถ๊ฐํฉ๋๋ค. ์ข ๋จ๊ฐ VoIP ๊ณต๊ฒฉ ๋ฐฉ๋ฒ๋ก , ๋๊ตฌ ๋ฐ ์๋๋ฆฌ์ค์ ๋ํด์๋ ๋ค์์ ์ฐธ์กฐํ์ญ์์ค:
Fingerprinting and Discovery
- OPTIONS ์์ฒญ์ ์ ์กํ๊ณ
Allow,Supported,Server๋ฐUser-Agentํค๋๋ฅผ ๊ฒํ ํ์ฌ ์ฅ์น์ ์คํ์ fingerprint ํฉ๋๋ค:
# nmap NSE (UDP 5060 by default)
sudo nmap -sU -p 5060 --script sip-methods <target>
# Minimal raw OPTIONS over UDP
printf "OPTIONS sip:<target> SIP/2.0\r\nVia: SIP/2.0/UDP attacker;branch=z9\r\nFrom: <sip:probe@attacker>;tag=1\r\nTo: <sip:probe@<target>>\r\nCall-ID: 1@attacker\r\nCSeq: 1 OPTIONS\r\nMax-Forwards: 70\r\nContact: <sip:probe@attacker>\r\nContent-Length: 0\r\n\r\n" | nc -u -w 2 <target> 5060
Username/Extension Enumeration Behavior
- ์ด๊ฑฐ๋ ์ผ๋ฐ์ ์ผ๋ก
REGISTER/INVITE์์401/407๋404/403์ ์ฐจ์ด๋ฅผ ์ ์ฉํฉ๋๋ค. ์๋ฒ๊ฐ ๊ท ์ผํ๊ฒ ์๋ตํ๋๋ก ํ์ฌ ๋ ธ์ถ์ ๋ฐฉ์งํ์ธ์. - Asterisk chan_sip: ์ผ๋ฐ ์ค์ ์ผ๋ก
alwaysauthreject=yes๋ฅผ ์ค์ ํ์ฌ ์ ํจํ ์ฌ์ฉ์๋ฅผ ๋ ธ์ถํ์ง ์๋๋ก ํ์ธ์. ์ต์ Asterisk(PJSIP)์์๋anonymousendpoint๊ฐ ์ ์๋์ง ์๋ ํ guest calling์ด ๋นํ์ฑํ๋์ด ์๊ณ ์ ์ฌํ โalways auth rejectโ ๋์์ด ๊ธฐ๋ณธ์ด์ง๋ง, ์ฌ์ ํ ๋คํธ์ํฌ ACL๊ณผ perimeter์์์ fail2ban ์ ์ฉ์ ๊ฐ์ ํ์ธ์.
SIP Digest Authentication: algorithms and cracking
- SIP๋ ์ผ๋ฐ์ ์ผ๋ก HTTP-Digest ์คํ์ผ ์ธ์ฆ์ ์ฌ์ฉํฉ๋๋ค. ์ญ์ฌ์ ์ผ๋ก MD5(๋ฐ MD5-sess)๊ฐ ๋๋ฆฌ ์ฌ์ฉ๋์๊ณ ; ์ต์ ์คํ์ RFC 8760์ ๋ฐ๋ผ SHA-256 ๋ฐ SHA-512/256์ ์ง์ํฉ๋๋ค. ์ต์ ๋ฐฐํฌ์์๋ ์ด๋ฌํ ๋ ๊ฐ๋ ฅํ ์๊ณ ๋ฆฌ์ฆ์ ์ฐ์ ์ฌ์ฉํ๊ณ ๊ฐ๋ฅํ ๊ฒฝ์ฐ MD5๋ฅผ ๋นํ์ฑํํ์ธ์.
- pcap์์์ ์คํ๋ผ์ธ ํฌ๋ํน์ MD5 ๋ค์ด์ ์คํธ์ ๋ํด ๋งค์ฐ ์ฝ์ต๋๋ค. challenge/response๋ฅผ ์ถ์ถํ ํ hashcat ๋ชจ๋ 11400 (SIP digest, MD5)์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
# Example hash format (single line)
# username:realm:method:uri:nonce:cnonce:nc:qop:response
echo 'alice:example.com:REGISTER:sip:example.com:abcdef:11223344:00000001:auth:65a8e2285879283831b664bd8b7f14d4' > sip.hash
# Crack with a wordlist
hashcat -a 0 -m 11400 sip.hash /path/to/wordlist.txt
Note
RFC 8760์ HTTP Digest(๋๋ SIP Digest)์ ๋ํด SHA-256 ๋ฐ SHA-512/256์ ์ ์ํฉ๋๋ค. ์ฑํ ์ํฉ์ ๊ท ์ผํ์ง ์์ต๋๋ค; ์ต์ PBX๋ฅผ ๋์์ผ๋ก ํ ๋ ๋๊ตฌ๋ค์ด ์ด๋ฅผ ์ฒ๋ฆฌํ๋์ง ํ์ธํ์ธ์.
SIP over TLS (SIPS) and over WebSockets
- Signaling encryption:
sips:URI์ TCP/TLS๋ ์ผ๋ฐ์ ์ผ๋ก ํฌํธ 5061์ ์ฌ์ฉํฉ๋๋ค. ์๋ํฌ์ธํธ์์์ ์ธ์ฆ์ ๊ฒ์ฆ์ ํ์ธํ์ธ์; ๋ง์ ์ฅ๋น๊ฐ self-signed ๋๋ wildcard cert๋ฅผ ํ์ฉํ์ฌ ์ฝํ ๋ฐฐํฌ์์๋ MitM์ด ๊ฐ๋ฅํด์ง๋๋ค.- WebRTC softphones๋ ์ข
์ข
RFC 7118์ ๋ฐ๋ผ SIP over WebSocket (
ws://๋๋wss://)์ ์ฌ์ฉํฉ๋๋ค. PBX๊ฐ WSS๋ฅผ ๋ ธ์ถํ๋ ๊ฒฝ์ฐ ์ธ์ฆ ๋ฐ CORS๋ฅผ ํ ์คํธํ๊ณ HTTP ํ๋ก ํธ์๋์์๋ rate limit์ด ์ ์ฉ๋๋์ง ํ์ธํ์ธ์.
DoS quick checks (protocol level)
- INVITE, REGISTER ๋๋ malformed ๋ฉ์์ง ํ๋ฌ๋ฉ์ ํธ๋์ญ์ ์ฒ๋ฆฌ๋ฅผ ์๋ชจ์ํฌ ์ ์์ต๋๋ค.
- UDP/5060์ ๋ํ ๊ฐ๋จํ rate-limiting ์์(Linux iptables hashlimit):
# Limit new SIP packets from a single IP to 20/s with burst 40
iptables -A INPUT -p udp --dport 5060 -m hashlimit \
--hashlimit-name SIP --hashlimit 20/second --hashlimit-burst 40 \
--hashlimit-mode srcip -j ACCEPT
iptables -A INPUT -p udp --dport 5060 -j DROP
Recent, relevant SIP-stack CVE to watch (Asterisk PJSIP)
- CVE-2024-35190 (published May 17, 2024): ํน์ Asterisk ๋ฆด๋ฆฌ์ค์์
res_pjsip_endpoint_identifier_ip๊ฐ ๋ฌด๋จ SIP ์์ฒญ์ ๋ก์ปฌ ์๋ํฌ์ธํธ๋ก ์๋ชป ์๋ณํ ์ ์์ด ๋ฌด๋จ ๋์ ๋๋ ์ ๋ณด ๋ ธ์ถ์ ์ด๋ํ ์ ์์ต๋๋ค. 18.23.1, 20.8.1 ๋ฐ 21.3.1์์ ์์ ๋์์ต๋๋ค. ํ ์คํธ ์ PBX ๋ฒ์ ์ ๊ฒ์ฆํ๊ณ ์ฑ ์๊ฐ ์๊ฒ ๋ณด๊ณ ํ์ธ์.
Hardening checklist (SIP-specific)
- ์ ํธ(Signaling)๋ TLS๋ฅผ ์ฐ์ ์ฌ์ฉํ๊ณ ๋ฏธ๋์ด์๋ SRTP/DTLS-SRTP๋ฅผ ์ฌ์ฉํ์ธ์; ๊ฐ๋ฅํ ๊ฒฝ์ฐ ํ๋ฌธ(cleartext)์ ๋นํ์ฑํํ์ธ์.
- ๊ฐ๋ ฅํ ๋น๋ฐ๋ฒํธ์ ๋ค์ด์ ์คํธ ์๊ณ ๋ฆฌ์ฆ(SHA-256/512-256 ์ง์ ์; MD5๋ ํผํจ)์ ์ ์ฉํ์ธ์.
- Asterisk์ ๊ฒฝ์ฐ:
- chan_sip:
alwaysauthreject=yes,allowguest=no, ์๋ํฌ์ธํธ๋ณpermit/denyCIDR ACL ์ค์ . - PJSIP: ํ์ํ์ง ์๋ค๋ฉด
anonymousendpoint๋ฅผ ์์ฑํ์ง ๋ง์ธ์; endpointacl/media_acl์ ๊ฐ์ ํ๊ณ fail2ban ๋๋ ๋๋ฑํ ๊ฒ์ ํ์ฑํํ์ธ์. - ์ ๋ณด ๋์ถ(leak)์ ์ค์ด๊ธฐ ์ํด SIP ํ๋ก์(์: outbound proxy/edge SBC)์์ ํ ํด๋ก์ง ์จ๊ธฐ๊ธฐ(topology hiding)๋ฅผ ์ ์ฉํ์ธ์.
- ์๊ฒฉํ
OPTIONS์ฒ๋ฆฌ ๋ฐ rate limit; ํ์ํ์ง ์์ ๋ฉ์๋(์:MESSAGE,PUBLISH)๋ ๋นํ์ฑํํ์ธ์.
References
- RFC 8760 โ Using SHA-256 and SHA-512/256 for HTTP Digest (applies to SIP Digest too): https://www.rfc-editor.org/rfc/rfc8760
- Asterisk GHSA advisory for CVE-2024-35190: https://github.com/asterisk/asterisk/security/advisories/GHSA-qqxj-v78h-hrf9
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


