lorawan-otaa
它能做什么
这份指南涵盖用于电表、追踪器和工业传感器的 LoRaWAN 网络的安全审查。适合运营或部署这些网络、并想检查其入网和防重放保护的团队。
适用场景
- ✓当公司运营 LoRaWAN 传感器,并想检查设备如何入网时。
- ✓当设备使用固定的会话设置,而团队想检查防重放保护时。
- ✓当网络团队想确认设备密钥被安全存储时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/iot/lorawan-otaa/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们在某个地区运营 LoRaWAN 电表。请帮我检查我们的入网流程和防重放保护是否设置正确?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体审查入网方式和密钥处理,检查帧计数器是否得到执行,并报告设置在哪些地方削弱了保护。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
LoRaWAN OTAA / ABP Security Assessment
LoRaWAN is deployed globally for smart meters, asset tracking, agriculture, and industrial sensors. OTAA (Over-The-Air Activation) derives session keys per join; ABP (Activation By Personalization) hardcodes them. Both have documented attack surface: OTAA AppKeys are often extracted from the device firmware or exposed via insecure provisioning, and ABP devices commonly disable the frame-counter check, enabling full replay.
Prerequisites
- Hardware: LILYGO TTGO T-Beam (SX1276 + GPS, programmable SDR-LoRa node), RAK831 / RAK2247 gateway concentrator, or HackRF One with gr-lora. RTL-SDR is receive-only (works for capture on EU 868 MHz).
- Software: ChirpStack (rogue gateway NS),
lorawansniffer/gr-lora, LoRaWAN Auditing Framework (LAF), Scapy-LoRa,lorawan-parser.
# Install LoRaWAN Auditing Framework:
git clone https://github.com/IOActive/laf
cd laf && pip install -r requirements.txt
# Install gr-lora (GNU Radio LoRa decoder):
git clone https://github.com/rpp0/gr-lora
cd gr-lora && mkdir build && cd build && cmake .. && make && sudo make install
# lorawan-parser for offline frame analysis:
pip install lorawan-parser
LoRaWAN Frequency Reference
| Region | Uplink (MHz) | Downlink (MHz) | Spreading Factors |
|---|---|---|---|
| EU868 | 868.1, 868.3, 868.5 | 869.525 | SF7–SF12 |
| US915 | 902.3–914.9 (8 ch) | 923.3–927.5 | SF7–SF10 |
| AU915 | 915.2–927.8 | 923.3–927.5 | SF7–SF12 |
| AS923 | 923.2, 923.4 | 923.2, 923.4 | SF7–SF12 |
Phase 1: Passive Air Capture
# RTL-SDR capture on EU868 primary channel, SF7 (fastest, most common):
rtl_sdr -f 868100000 -s 1000000 -g 40 /tmp/lora_raw.iq
# Decode with gr-lora offline:
python3 gr-lora/apps/rx_file.py --freq 868.1e6 --sf 7 --bw 125000 \
--input /tmp/lora_raw.iq --output /tmp/lora_frames.txt
# Online decode with TTGO T-Beam running LoRa sniffer firmware:
# Flash: https://github.com/claudiodangelis/lora-sniffer
# Serial output at 115200:
screen /dev/ttyUSB0 115200
LAF spectrum scan (scans all EU868 channels across SF7-SF12):
python3 laf/laf.py scan --freq 868.1,868.3,868.5 --sf all --bw 125 \
--device /dev/ttyACM0 | tee /tmp/laf_scan.txt
Phase 2: OTAA Join Analysis
OTAA JoinRequest contains DevEUI (8 bytes), AppEUI/JoinEUI (8 bytes), and DevNonce (2 bytes), all in plaintext. Only the MIC is keyed with AppKey.
# Parse a captured JoinRequest frame:
python3 - <<'EOF'
from lorawan import LoRaWANMessage
# hex of a raw captured PHY payload:
payload_hex = "00AABBCCDDEEFF001122334455667701234501"
msg = LoRaWANMessage.from_hex(payload_hex)
print(f"MType: {msg.mhdr.mtype}")
print(f"AppEUI: {msg.join_request.app_eui.hex()}")
print(f"DevEUI: {msg.join_request.dev_eui.hex()}")
print(f"DevNonce: {msg.join_request.dev_nonce.hex()}")
EOF
AppKey extraction from firmware (if binary is available):
# binwalk extracts the firmware; AppKey is a 16-byte value near DevEUI in flash.
binwalk -eM firmware.bin
# Search for DevEUI (known from OTA capture) ± 32 bytes:
python3 - <<'EOF'
import re, sys
dev_eui = bytes.fromhex("AABBCCDDEEFF0011") # from captured JoinRequest
fw = open("_firmware.bin.extracted/0.bin", "rb").read()
offset = fw.find(dev_eui)
if offset >= 0:
print(f"DevEUI at 0x{offset:08x}")
print(f"Surrounding 48 bytes: {fw[offset-16:offset+32].hex()}")
# AppKey is likely 16 bytes before or after DevEUI in the provisioning struct.
EOF
Phase 3: AppKey Brute-Force / Known-Key Verification
With a known AppKey, verify and derive session keys:
import hmac, hashlib
from Crypto.Cipher import AES
APP_KEY = bytes.fromhex("2B7E151628AED2A6ABF7158809CF4F3C") # known/extracted key
def verify_join_request_mic(phypayload: bytes, app_key: bytes) -> bool:
"""Verify MIC of LoRaWAN JoinRequest. MIC = CMAC(AppKey, MHDR||AppEUI||DevEUI||DevNonce)[0:4]"""
from Crypto.Hash import CMAC
msg = phypayload[:-4] # strip 4-byte MIC
claimed_mic = phypayload[-4:]
cobj = CMAC.new(app_key, ciphermod=AES)
cobj.update(msg)
return cobj.digest()[:4] == claimed_mic
def derive_session_keys(app_key: bytes, app_nonce: bytes, net_id: bytes, dev_nonce: bytes):
"""Derive NwkSKey and AppSKey from OTAA join-accept parameters."""
def aes_ecb(key, data):
return AES.new(key, AES.MODE_ECB).encrypt(data)
nwk_s_key = aes_ecb(app_key, b'\x01' + app_nonce + net_id + dev_nonce + b'\x00'*7)
常见问题
什么是 OTAA?
它是空中激活入网方式,设备每次入网时都会生成新的会话密钥。
什么是 ABP?
它是一种预先设置会话密钥的方式,该指南指出这可能削弱保护。
帧计数器为什么重要?
它们帮助网络拒绝被记录下来并再次发送的旧消息。
详情
作者的原始描述
LoRaWAN OTAA join-procedure analysis (DevEUI/AppEUI/AppKey extraction), frame-counter replay on ABP devices, downlink injection via rogue gateway, bit-flipping on unprotected FRMPayload, and network enumeration with ChirpStack and the LoRaWAN Auditing Framework.
热度
- GitHub 星标
- 6.5k
- 排名
- #14100
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …