Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ RF CTF Fox code
[![Build Test All](https://github.com/rfhs/kitsune/actions/workflows/build-test-all.yaml/badge.svg)](https://github.com/rfhs/kitsune/actions/workflows/build-test-all.yaml)


|Hardware |Bluetooth iBeacon |Bluetooth Classic Discoverable |Wifi AP |Client |
|Hardware |Bluetooth iBeacon |Bluetooth Classic Discoverable |WiFi AP |WiFi Client |
|------------------- | :---------: | :------: | :-----: | :-----: |
|M5Stack Atom-lite |✅|✅|✅|✅|
|M5Stack AtomS3-lite |✅|❌|✅|✅|
|M5Stack StampS3 |✅|❌|✅|✅|
|Arduino Nano ESP32 |✅|❌|✅||
|Seeed XIAO ESP32C5 |❌|❌|✅||
|Arduino Nano ESP32 |✅|❌|✅||
|Seeed XIAO ESP32C5 |❌|❌|✅||

We will accept PRs to extend support to other platformio supported hardware.

Expand Down
12 changes: 12 additions & 0 deletions fastcat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
until ls /dev/ttyACM0 > /dev/null 2>&1 || ls /dev/ttyUSB0 > /dev/null 2>&1; do
sleep 0.1
done
if ls /dev/ttyACM0 > /dev/null 2>&1; then
stty -F /dev/ACMUSB0 115200 raw -echo
cat /dev/ttyACM0
fi
if ls /dev/ttyUSB0 > /dev/null 2>&1; then
stty -F /dev/USB0 115200 raw -echo
cat /dev/ttyUSB0
fi
3 changes: 3 additions & 0 deletions include/rfhswifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ void disableWiFi() {
WiFi.disconnect(true);
#endif
WiFi.mode(WIFI_OFF);
esp_wifi_stop();
esp_wifi_deinit();
esp_wifi_set_mode(WIFI_MODE_NULL);
}
13 changes: 11 additions & 2 deletions make_conference_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ for challenge in bluetooth/iBeacon bluetooth/classic_discoverable wifi/wifi_ap_c
fi
popd > /dev/null 2>&1
done
if [ -f "$(date +"%Y")${1}.txt" ]; then
printf '%s%s.txt already exists, please remove it or pick a different name\n' "$(date +"%Y")" "${1}"
exit 1
fi

# Safety checks complete, define functions and do the thing
threewords() {
Expand All @@ -25,8 +29,9 @@ threewords() {
exit 1
fi
dictionary='/usr/share/dict/cracklib-words'
shuf -n3 "${dictionary}" | paste -sd ' '
shuf -n3 "${dictionary}" | tr '[:lower:]' '[:upper:]' | paste -sd ' '
}
export -f threewords

for challenge in bluetooth/iBeacon bluetooth/classic_discoverable wifi/wifi_ap_client; do
pushd "${challenge}" > /dev/null 2>&1
Expand All @@ -42,7 +47,11 @@ for challenge in bluetooth/iBeacon bluetooth/classic_discoverable wifi/wifi_ap_c
popd > /dev/null 2>&1
done
printf "Seeding keys for %s%s... " "$(date +"%Y")" "${1}"
#sed -i \
# -e "/RFHS_CHALLENGE_NAME/i -\n----------------------------------------------------------------\n$(date +"%Y")${1}\n$(threewords)\n" \
# "$(date +"%Y")${1}.txt"
sed -i \
-e "/RFHS_CHALLENGE_NAME/i -\n----------------------------------------------------------------\n$(date +"%Y")${1}\n$(threewords)\n" \
-e "/RFHS_CHALLENGE_NAME/{h; s/.*/printf -- '-\\n----------------------------------------------------------------\\nConference: %s%s\\nFlag: %s\\n\\n' \"\$(date +%Y)\" \"${1}\" \"\$(threewords)\"/e; G;}" \
"$(date +"%Y")${1}.txt"
sed -i '1iSet font to "Roboto Mono' "$(date +"%Y")${1}.txt"
printf "complete\n"
4 changes: 2 additions & 2 deletions wifi/wifi_ap_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ seeed-xiao-esp32c5-hard-ap Platform upload Upload
|M5Stack Atom-lite |✅|✅|✅|
|M5Stack AtomS3-lite |✅|✅|❌|
|M5Stack StampS3 |✅|✅|❌|
|Ardunio Nano ESP32 |✅||❌|
|Seeed Xiao ESP32C5 |✅||❌|
|Ardunio Nano ESP32 |✅||❌|
|Seeed Xiao ESP32C5 |✅||❌|

To use:
- [Install PlatformIO](https://platformio.org/install/cli)
Expand Down
24 changes: 12 additions & 12 deletions wifi/wifi_ap_client/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ build_flags = ${difficulty.hard} ${mode.client}
[env:arduino-nano-esp32-easy-ap]
extends = arduino_nano_esp32
build_flags = ${difficulty.easy} ${mode.ap} ${arduino_nano_esp32.board_flags}
;[env:arduino-nano-esp32-easy-client]
;extends = arduino_nano_esp32
;build_flags = ${difficulty.easy} ${mode.client} ${arduino_nano_esp32.board_flags}
[env:arduino-nano-esp32-easy-client]
extends = arduino_nano_esp32
build_flags = ${difficulty.easy} ${mode.client} ${arduino_nano_esp32.board_flags}
[env:arduino-nano-esp32-hard-ap]
extends = arduino_nano_esp32
build_flags = ${difficulty.hard} ${mode.ap} ${arduino_nano_esp32.board_flags}
;[env:arduino-nano-esp32-hard-client]
;extends = arduino_nano_esp32
;build_flags = ${difficulty.hard} ${mode.client} ${arduino_nano_esp32.board_flags}
[env:arduino-nano-esp32-hard-client]
extends = arduino_nano_esp32
build_flags = ${difficulty.hard} ${mode.client} ${arduino_nano_esp32.board_flags}

; Client mode gets the wrong mac address, not sure why
[env:seeed-xiao-esp32c5-easy-ap]
Expand All @@ -83,18 +83,18 @@ build_flags = ${difficulty.easy} ${mode.ap} ${seeed-xiao-esp32c5.board_flags}
[env:seeed-xiao-esp32c5-fiveeasy-ap]
extends = seeed-xiao-esp32c5
build_flags = ${difficulty.easy} ${difficulty.fiveeasy} ${mode.ap} ${seeed-xiao-esp32c5.board_flags}
;[env:seeed-xiao-esp32c5-easy-client]
;extends = seeed-xiao-esp32c5
;build_flags = ${difficulty.easy} ${mode.client} ${seeed-xiao-esp32c5.board_flags}
[env:seeed-xiao-esp32c5-easy-client]
extends = seeed-xiao-esp32c5
build_flags = ${difficulty.easy} ${mode.client} ${seeed-xiao-esp32c5.board_flags}
[env:seeed-xiao-esp32c5-hard-ap]
extends = seeed-xiao-esp32c5
build_flags = ${difficulty.hard} ${mode.ap} ${seeed-xiao-esp32c5.board_flags}
[env:seeed-xiao-esp32c5-fivehard-ap]
extends = seeed-xiao-esp32c5
build_flags = ${difficulty.hard} ${difficulty.fivehard} ${mode.ap} ${seeed-xiao-esp32c5.board_flags}
;[env:seeed-xiao-esp32c5-hard-client]
;extends = seeed-xiao-esp32c5
;build_flags = ${difficulty.hard} ${mode.client} ${seeed-xiao-esp32c5.board_flags}
[env:seeed-xiao-esp32c5-hard-client]
extends = seeed-xiao-esp32c5
build_flags = ${difficulty.hard} ${mode.client} ${seeed-xiao-esp32c5.board_flags}

; known issues:
; serial isn't working
Expand Down
42 changes: 42 additions & 0 deletions wifi/wifi_ap_client/src/conferences/9999demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@
#define TIME_TO_SLEEP 45
#define TXPOWER WIFI_POWER_7dBm
#endif

#if defined(FIVEEASY)
#define RFHS_CHALLENGE_NAME "WiFi 5GHz AP Easy Fox"
// Network config
#define FSSID "Demo Rex WiFi 5GHz AP Easy Fox"
#define PSK "0123456789"
// set mac address
#define MAC_ADDR {0xF2, 0xC6, 0xB7, 0xE2, 0xE9, 0x85}
// 1-13 permitted 0 means random
#define CHANNEL 36
// 0 broadcast 1 hidden
#define SSID_HIDDEN 0
// 1-4 permitted
#define MAX_CLIENTS 1
#define TIME_TO_WAKE 15
#define TIME_TO_SLEEP 5
// checks run during startup so we want to stay
// running no longer than a few minutes to force
// checks to run and led to update
#define TXPOWER WIFI_POWER_17dBm
#endif

#if defined(FIVEHARD)
#define RFHS_CHALLENGE_NAME "WiFi 5GHz AP Hard Fox"
// Network config
#define FSSID "Demo Liberty WiFi 5GHzAPHardFox"
#define PSK "0123456789"
// set mac address
#define MAC_ADDR {0xF2, 0x81, 0x41, 0xD1, 0x30, 0xD1}
// 1-13 permitted 0 means random
#define CHANNEL 0
// 0 broadcast 1 hidden
#define SSID_HIDDEN 0
// 1-4 permitted
#define MAX_CLIENTS 1
// checks run during startup so we want to stay
// running no longer than a few minutes to force
// checks to run and led to update
#define TIME_TO_WAKE 30
#define TIME_TO_SLEEP 45
#define TXPOWER WIFI_POWER_7dBm
#endif
#endif

#if defined(CLIENT)
Expand Down
50 changes: 38 additions & 12 deletions wifi/wifi_ap_client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ void setup() {

// Initialize Wi-Fi with default configuration to set MAC address
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
WiFi.mode(WIFI_MODE_NULL);
#if defined(AP)
WiFi.mode(WIFI_AP);
#elif defined(CLIENT)
WiFi.mode(WIFI_STA);
#endif
esp_wifi_init(&cfg);
// esp_wifi_start(); // esp_wifi_set_mac() only requires Wi-Fi to be *initialized*

#if defined(AP)
// Create Wi-Fi network with SSID and password
Serial.println("Setting AP (Access Point)…");
Serial.println("Setting up AP (Access Point)…");
// Interface to set MAC address
wifi_interface_t interface = WIFI_IF_AP;
#elif defined(CLIENT)
// Connect to Wi-Fi network with SSID and password
Serial.println("Setting WiFi Fox Client…");
Serial.println("Setting up WiFi Client…");
// Interface to set MAC address
wifi_interface_t interface = WIFI_IF_STA;
#endif
Expand Down Expand Up @@ -66,7 +70,6 @@ void setup() {
snprintf(mac_str, sizeof(mac_str), "%02X:%02X:%02X:%02X:%02X:%02X",
mac_addr[0], mac_addr[1], mac_addr[2],
mac_addr[3], mac_addr[4], mac_addr[5]);
Serial.println("Requested MAC address: " + String(mac_str));
#if defined(AP)
#if CHANNEL > 0
int set_channel = CHANNEL;
Expand All @@ -81,8 +84,6 @@ void setup() {
// 128, 132, 136, 140, 144, 149, 153, 157, 161, 165
//};
*/

// All other channels were refused due to reg domain
static constexpr uint8_t CHANNEL_LIST_5G[] = {
36, 40, 44, 48, 149, 153, 157, 161, 165
};
Expand All @@ -91,29 +92,54 @@ void setup() {
uint8_t set_channel = CHANNEL_LIST_5G[random_index];
#else
// Intentionally limited to worldwide allowed channels
int set_channel = esp_random() % 11;
uint8_t set_channel = esp_random() % 11;
set_channel++;
#endif
#endif
Serial.printf("Setting channel to: %d\r\n", set_channel);
Serial.flush();
WiFi.mode(WIFI_AP);
WiFi.softAP(FSSID, PSK, set_channel, SSID_HIDDEN, MAX_CLIENTS);
delay(100); // Let AP start before we run our checks
Serial.printf("Set power status: %s\r\n", String(WiFi.setTxPower(TXPOWER)));
Serial.println("Started AP with MAC Address: " + WiFi.softAPmacAddress());
if (WiFi.softAPmacAddress() != mac_str){
Serial.println("Requested MAC address : " + String(mac_str));
Serial.println("Read MAC Address != Requested Mac Address");
Serial.flush();
disableWiFi();
rfhsledfatal();
}
uint8_t currentChannel = WiFi.channel();
Serial.printf("Operating channel: %d\r\n", currentChannel);
if (currentChannel != set_channel){
Serial.printf("Requested channel: %d\r\n", set_channel);
Serial.println("Operating channel != Requested Channel");
Serial.flush();
disableWiFi();
rfhsledfatal();
}
String currentSSID = WiFi.softAPSSID();
Serial.println("Operating SSID: " + currentSSID);
if (String(FSSID) != currentSSID){
Serial.println("Requested SSID: " FSSID);
Serial.println("Operating SSID != Requested SSID");
Serial.flush();
disableWiFi();
rfhsledfatal();
}
Serial.flush();
ledcolor(0x00ff00); // GREEN
#elif defined(CLIENT)
WiFi.mode(WIFI_STA);
WiFi.begin(FSSID, PSK);
delay(100); // Let Client start before we run our checks
Serial.println("Started Client with MAC Address: " + WiFi.macAddress());
if (WiFi.macAddress() != mac_str){
Serial.println("Read MAC Address != Requested Mac Address");
Serial.flush();
disableWiFi();
rfhsledfatal();
}
Serial.flush();
ledcolor(0xff8c00); // ORANGE
#endif

Expand All @@ -126,9 +152,9 @@ void setup() {
ledcolor(0x880000); // HALF RED
disableWiFi();
ledcolor(0xff0000); // RED
delay(75); // adjust the esp_deep_sleep if you change this
// subtract sleep time on line 91
int sleepy_tyme = uS_TO_S * TIME_TO_SLEEP - 75 ;
delay(75); // Give the led time to set before sleeping
// subtract sleep time on line 101, 134, 155
int sleepy_tyme = uS_TO_S * TIME_TO_SLEEP - 75 - 100 ;
if (sleepy_tyme < 0 ) {
sleepy_tyme = 0;
}
Expand Down