PWN::Plugins::YubiKey::OTP
Native Ruby OTP application commands over the selected Connection.exchange
boundary. No executable, subprocess, interpreter or network backend. HID framing
and CRC validation belong to Transport; APDU status handling belongs to
Protocol. The caller owns its transport connection.
Operations
execute(args: [...], connection: ...) accepts argv after otp.
operations lists ten leaves: info, swap, ndef, delete, yubiotp,
static, chalresp, calculate, hotp, settings. Empty args return local
metadata, not a device query. Unknown flags/commands and credential argv raise.
Typed methods: info, swap, delete_slot, configure_ndef, settings,
provision_yubiotp, provision_static, provision_hotp,
provision_challenge_response, challenge_response, calculate, help,
authors. Read runtime help for the full option contract.
Safe workflow
- Select the exact intended device using root transport selectors. Do not scan
or open real hardware in default tests. A model name does not establish its
supported/enabled applications.
- Read
info without authentication. Firmware/status observations, not guessed
credentials, gate slot operations. NDEF additionally checks actual NFC support.
- Require literal
confirm: true for every write or calculation. --force is
syntactic compatibility, not consent. Never provision to repair a vault-open
failure, stale response, wrong slot or missing device.
- Supply secrets as raw in-memory
key:, password:, private_id:,
access_code: and new_access_code:. An explicit secret_provider receives
a missing secret's Symbol. No implicit terminal reads or factory secrets.
Generated material requires secret_sink.call(field, raw_secret). The sink is
caller-controlled and must not log or publish secrets.
challenge_response(connection:, challenge:, slot: 2, confirm: true) accepts
1–64 raw bytes and returns 20 raw HMAC-SHA1 bytes. It never hex-encodes,
truncates to a TOTP or caches a response. Trailing zero challenges use distinct
padding. USB calculation requires OTP HID; smartcard calculation is NFC-only.
provision_challenge_response defaults to touch-required and performs a fresh
native OpenSSL HMAC comparison against device output after programming and
separate status readback. Its default return is :verified; details: true
returns scoped verification metadata. execute ['chalresp', '2'] returns the
metadata and follows prior CLI default
of no touch unless --touch. --totp explicitly decodes supplied Base32 key
text in memory; otherwise key_encoding defaults to raw. Keys 21–64 bytes
cannot fit this application; longer HMAC keys are SHA1-shortened per HMAC.
- Check
verification, not only verified. Other OTP credentials/settings have
no secret/config export command: their verification is programming sequence
and slot-state readback, not proof of keyboard output or secret equality.
Known 5.0–5.4.2
smartcard zero-sequence responses are labeled firmware_quirk_slot_state;
HMAC provisioning must still pass the cryptographic challenge comparison.
Never claim that state metadata proves an NFC URI's emitted value. Failed or
stale readback raises an uncertainty error; no write is automatically replayed.
Formats and device restrictions
- YubiOTP: public ID is lowercase modhex, private ID six raw bytes, AES key sixteen
raw bytes.
--serial-public-id reads the actual API serial.
- Static passwords: 1–38 characters; MODHEX, US, UK, DE, FR, IT, BEPO and NORMAN
scan-code maps. Unsupported characters fail before programming. The map data
retains Yubico's BSD license in source.
- HOTP: raw HMAC key, 6/8 digits, initial counter divisible by 16 and at most
1048560; optional modhex/BCD token identifier.
- NDEF: URI prefix compression or UTF8 English text, encoded prefix ≤54 bytes;
requires a configured slot on an NFC-capable key.
- Settings replace omitted keyboard options with defaults, as the prior command
did; they do not infer hidden previous settings. Firmware 4.3.2–4.3.5 access-code
updates are refused without any delete/reprogram fallback.
- Explicit YubiOTP
config_output appends Yubico CSV only after status readback to
an owned, mode-0600 regular file with no symlinks/hardlinks and an exclusive
lock. CSV contains secrets. --upload is retired upstream and fails without
any network call. Generated secrets still require an explicit in-memory sink.
Evidence and references
Offline specs use fake connection wire responses, real shared APDU codecs,
RFC 2202 HMAC and RFC 6238 TOTP vectors, and an independently computed fixed
52-byte configuration/CRC vector. These are not hardware interoperability tests.
Protocol provenance: official yubikey-manager 5.9.1 source (yubikit/yubiotp.py,
yubikit/core/otp.py, ykman/scancodes) and
https://developers.yubico.com/yubikey-personalization/Manuals/ykpersonalize.1.html.
Native reference header:
https://github.com/Yubico/yubikey-personalization/blob/master/ykcore/ykdef.h.
1---2name: pwn-plugins-yubikey-otp3description: Use native OTP slots with explicit consent and readback.4license: MIT5allowed-tools: [pwn, pwn_eval]6metadata:7 bundled: true8 preserve: true9 module: PWN::Plugins::YubiKey::OTP10 source: https://skillmd.com/skills/0dayinc/pwn-plugins-yubikey-otp11 upstream: pwn/plugins/yubikey/otp.rb12---1314# PWN::Plugins::YubiKey::OTP1516Native Ruby OTP application commands over the selected `Connection.exchange`17boundary. No executable, subprocess, interpreter or network backend. HID framing18and CRC validation belong to `Transport`; APDU status handling belongs to19`Protocol`. The caller owns its transport connection.2021## Operations2223`execute(args: [...], connection: ...)` accepts argv **after** `otp`.24`operations` lists ten leaves: `info`, `swap`, `ndef`, `delete`, `yubiotp`,25`static`, `chalresp`, `calculate`, `hotp`, `settings`. Empty args return local26metadata, not a device query. Unknown flags/commands and credential argv raise.2728Typed methods: `info`, `swap`, `delete_slot`, `configure_ndef`, `settings`,29`provision_yubiotp`, `provision_static`, `provision_hotp`,30`provision_challenge_response`, `challenge_response`, `calculate`, `help`,31`authors`. Read runtime `help` for the full option contract.3233## Safe workflow34351. Select the exact intended device using root transport selectors. Do not scan36 or open real hardware in default tests. A model name does not establish its37 supported/enabled applications.382. Read `info` without authentication. Firmware/status observations, not guessed39 credentials, gate slot operations. NDEF additionally checks actual NFC support.403. Require literal `confirm: true` for every write or calculation. `--force` is41 syntactic compatibility, not consent. Never provision to repair a vault-open42 failure, stale response, wrong slot or missing device.434. Supply secrets as raw in-memory `key:`, `password:`, `private_id:`,44 `access_code:` and `new_access_code:`. An explicit `secret_provider` receives45 a missing secret's Symbol. No implicit terminal reads or factory secrets.46 Generated material requires `secret_sink.call(field, raw_secret)`. The sink is47 caller-controlled and must not log or publish secrets.485. `challenge_response(connection:, challenge:, slot: 2, confirm: true)` accepts49 **1–64 raw bytes** and returns **20 raw HMAC-SHA1 bytes**. It never hex-encodes,50 truncates to a TOTP or caches a response. Trailing zero challenges use distinct51 padding. USB calculation requires OTP HID; smartcard calculation is NFC-only.526. `provision_challenge_response` defaults to touch-required and performs a fresh53 native OpenSSL HMAC comparison against device output after programming and54 separate status readback. Its default return is `:verified`; `details: true`55 returns scoped verification metadata. `execute ['chalresp', '2']` returns the56 metadata and follows prior CLI default57 of no touch unless `--touch`. `--totp` explicitly decodes supplied Base32 key58 text in memory; otherwise `key_encoding` defaults to raw. Keys 21–64 bytes59 cannot fit this application; longer HMAC keys are SHA1-shortened per HMAC.607. Check `verification`, not only `verified`. Other OTP credentials/settings have61 no secret/config export command: their verification is programming sequence62 and slot-state readback, **not proof of keyboard output or secret equality**.63 Known 5.0–5.4.264 smartcard zero-sequence responses are labeled `firmware_quirk_slot_state`;65 HMAC provisioning must still pass the cryptographic challenge comparison.66 Never claim that state metadata proves an NFC URI's emitted value. Failed or67 stale readback raises an uncertainty error; no write is automatically replayed.6869## Formats and device restrictions7071- YubiOTP: public ID is lowercase modhex, private ID six raw bytes, AES key sixteen72 raw bytes. `--serial-public-id` reads the actual API serial.73- Static passwords: 1–38 characters; MODHEX, US, UK, DE, FR, IT, BEPO and NORMAN74 scan-code maps. Unsupported characters fail before programming. The map data75 retains Yubico's BSD license in source.76- HOTP: raw HMAC key, 6/8 digits, initial counter divisible by 16 and at most77 1048560; optional modhex/BCD token identifier.78- NDEF: URI prefix compression or UTF8 English text, encoded prefix ≤54 bytes;79 requires a configured slot on an NFC-capable key.80- Settings replace omitted keyboard options with defaults, as the prior command81 did; they do not infer hidden previous settings. Firmware 4.3.2–4.3.5 access-code82 updates are refused without any delete/reprogram fallback.83- Explicit YubiOTP `config_output` appends Yubico CSV only after status readback to84 an owned, mode-0600 regular file with no symlinks/hardlinks and an exclusive85 lock. CSV contains secrets. `--upload` is retired upstream and fails without86 any network call. Generated secrets still require an explicit in-memory sink.8788## Evidence and references8990Offline specs use fake **connection wire responses**, real shared APDU codecs,91RFC 2202 HMAC and RFC 6238 TOTP vectors, and an independently computed fixed9252-byte configuration/CRC vector. These are not hardware interoperability tests.9394Protocol provenance: official yubikey-manager **5.9.1** source (`yubikit/yubiotp.py`,95`yubikit/core/otp.py`, `ykman/scancodes`) and96<https://developers.yubico.com/yubikey-personalization/Manuals/ykpersonalize.1.html>.97Native reference header:98<https://github.com/Yubico/yubikey-personalization/blob/master/ykcore/ykdef.h>.