Last active
April 3, 2026 03:17
-
-
Save brkr19/c53b06779ecd2b6e10373b74a3cb241a to your computer and use it in GitHub Desktop.
IoT CTF Aliases
This file contains hidden or 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
| hex2ascii() { | |
| tr -d "'" | xxd -r -p; printf "\n" | |
| } | |
| gattval() { | |
| cut -d":" -f2 | tr -d "'" | xxd -r -p; printf "\n" | |
| } | |
| gatt_read() { | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: gatt_read <handle>" | |
| return 1 | |
| fi | |
| if [ -z "$BDADDR" ]; then | |
| echo "Error: BDADDR environment variable is not set." | |
| return 1 | |
| fi | |
| local handle="$1" | |
| # Write the hex value to the given handle | |
| gatttool -b "$BDADDR" --char-read -a "$handle" | gattval | |
| } | |
| gatt_write() { | |
| if [ $# -lt 2 ]; then | |
| echo "Usage: gatt_write <handle> <value>" | |
| return 1 | |
| fi | |
| if [ -z "$BDADDR" ]; then | |
| echo "Error: BDADDR environment variable is not set." | |
| return 1 | |
| fi | |
| local handle="$1" | |
| local value="$2" | |
| local hex_value | |
| # Convert the ASCII value to a hex string | |
| hex_value=$(echo -n "$value" | xxd -ps) | |
| # Write the hex value to the given handle | |
| gatttool -b "$BDADDR" --char-write-req -a "$handle" -n "$hex_value" | |
| } | |
| iotctf_scoreboard() { | |
| if [ -z "$BDADDR" ]; then | |
| echo "Error: BDADDR environment variable is not set." | |
| return 1 | |
| fi | |
| gatt_read 0x002a | |
| } | |
| submit_flag() { | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: submit_flag <flag>" | |
| return 1 | |
| fi | |
| gatt_write 0x002c "$1" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment