Skip to content

Commit

Permalink
Implement raw 14a command (#282)
Browse files Browse the repository at this point in the history
Demo with reading data from gen1 cards in debug menu
  • Loading branch information
Foxushka authored Sep 27, 2023
1 parent 3888b90 commit fb0afbb
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 17 deletions.
41 changes: 41 additions & 0 deletions chameleonultragui/lib/bridge/chameleon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1041,4 +1041,45 @@ class ChameleonCommunicator {

return commands;
}

Future<Uint8List> send14ARaw(Uint8List data,
{int respTimeoutMs = 100,
int? bitLen,
bool activateRfField = true,
bool waitResponse = true,
bool appendCrc = true,
bool autoSelect = true,
bool keepRfField = false,
bool checkResponseCrc = true}) async {
bitLen ??= data.length * 8; // bits = bytes * 8(bit)
int options = 0;

if (activateRfField) {
options += 128;
}
if (waitResponse) {
options += 64;
}
if (appendCrc) {
options += 32;
}
if (autoSelect) {
options += 16;
}
if (keepRfField) {
options += 8;
}
if (checkResponseCrc) {
options += 4;
}

return (await sendCmd(ChameleonCommand.hf14ARawCommand,
data: Uint8List.fromList([
options,
...u16ToBytes(respTimeoutMs),
...u16ToBytes(bitLen),
...data
])))!
.data;
}
}
33 changes: 33 additions & 0 deletions chameleonultragui/lib/gui/page/debug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,39 @@ class DebugPage extends StatelessWidget {
]),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: () async {
var data = await appState.communicator!.send14ARaw(
Uint8List.fromList([0x40]),
bitLen: 7,
appendCrc: false,
autoSelect: false,
checkResponseCrc: false,
keepRfField: true);

if (data[0] == 0x0a) {
data = await appState.communicator!.send14ARaw(
Uint8List.fromList([0x43]),
appendCrc: false,
autoSelect: false,
checkResponseCrc: false,
keepRfField: true);
if (data[0] == 0x0a) {
for (var block = 0; block < 64; block++) {
data = await appState.communicator!.send14ARaw(
Uint8List.fromList([0x30, block]),
autoSelect: false,
keepRfField: block == 63 ? false : true);
appState.log!.d("$block : ${bytesToHexSpace(data)}");
}
}
}
},
child: Column(children: [
Text(localizations.read_gen1_card_data),
]),
),
const SizedBox(height: 10),
],
),
)));
Expand Down
3 changes: 2 additions & 1 deletion chameleonultragui/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,6 @@
"outdated_protocol_description_3": "Would you like to update firmware?",
"skip": "Skip",
"update": "Update",
"static_nested_attack": "Run Static Nested attack on card"
"static_nested_attack": "Run Static Nested attack on card",
"read_gen1_card_data": "Read Gen1 card data"
}
44 changes: 28 additions & 16 deletions chameleonultragui/untranslated_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,32 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"de": [
"ble_pairing",
"ats",
"outdated_protocol",
"outdated_protocol_description_1",
"outdated_protocol_description_2",
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"de_AT": [
"ble_pairing",
"ats",
"outdated_protocol",
"outdated_protocol_description_1",
"outdated_protocol_description_2",
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"es": [
Expand All @@ -95,7 +96,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"fr": [
Expand All @@ -110,7 +112,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"it": [
Expand All @@ -121,7 +124,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"ko": [
Expand All @@ -133,7 +137,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"nl": [
Expand Down Expand Up @@ -163,7 +168,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"pt": [
Expand All @@ -175,7 +181,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"pt_BR": [
Expand All @@ -187,7 +194,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"ro": [
Expand Down Expand Up @@ -249,7 +257,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"ru": [
Expand All @@ -260,7 +269,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"uk": [
Expand All @@ -271,7 +281,8 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
],

"zh": [
Expand All @@ -282,6 +293,7 @@
"outdated_protocol_description_3",
"skip",
"update",
"static_nested_attack"
"static_nested_attack",
"read_gen1_card_data"
]
}

0 comments on commit fb0afbb

Please sign in to comment.