Created
November 21, 2024 18:00
-
-
Save martinpaljak/1de5959012587626eb96f3a33ad06a50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
STAMP=`date +%y%m%d_%H-%M-%S` | |
pm3 -c 'hf 14a sniff' | |
pm3 -c 'trace list -t 14a -x' 2>/dev/null \ | |
| text2pcap -t "%S." -l 264 - - 2>/dev/null \ | |
| tshark -r - -T json \ | |
| tee trace_$STAMP.json \ | |
| jq -r '.[]._source.layers.iso14443."Message: I-block".data."data.data" | select(. != null)' \ | |
| tr -d ':' \ | |
| tee trace_$STAMP.txt \ | |
| awk -f <(cat - <<-'EOD' | |
{ | |
if (NR % 2) { | |
# Odd lines | |
if (length($0) < 8) { | |
print ">> " $0 | |
} else { | |
print ">> " substr($0, 1, 8) " " substr($0, 9) | |
} | |
} else { | |
# Even lines | |
if (length($0) <= 4) { | |
print "<< " $0 | |
} else { | |
print "<< " substr($0, 1, length($0) - 4) " " substr($0, length($0) - 3) | |
} | |
} | |
} | |
EOD | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment