Display WiFi mac addr + use my own interpreation of wifi struct

The comments are basically a copy/paste of the info provided on 3Dbrew.
This commit is contained in:
Joel 2017-07-19 02:54:19 -04:00
parent 661932e95d
commit 6dd031650f
2 changed files with 63 additions and 61 deletions

View File

@ -4,69 +4,65 @@
#include <3ds.h> #include <3ds.h>
/* /*
The things below here were found by LiquidFenrir and his Wifi Manager. (https://github.com/LiquidFenrir/WifiManager) Wifi Slot Structure constructed using the info provided here https://www.3dbrew.org/wiki/Config_Savegame#WiFi_Slot_Structure
*/ */
#define CFG_WIFI_BLKID (u32)0x00080000 #define CFG_WIFI_BLKID (u32) 0x00080000 // Configuration blocks BlkID for WiFi configuration slots
#define CFG_WIFI_SLOT_SIZE (u32)0xC00 #define CFG_WIFI_SLOT_SIZE (u32) 0xC00 // Blk size 0xC
typedef struct { typedef struct
bool exists; {
bool use; bool set; // Was the network was set or not?
bool second; bool use; // Use this network strucutre to connect?
bool isFirst; // If this structure is the first (0) or the second (1) in the larger WiFi slot structure?
u8 padding1; u8 padding1;
char SSID[0x20];
u8 SSID_length; char SSID[0x20]; // SSID of the network, without a trailing nullbyte.
u8 AP_encryption_type; u8 SSID_length; // Length of the SSID.
u8 AP_crypto_key_type;
u16 padding2; u16 padding2;
char password[0x40]; //plaintext, blank for a network set up with WPS
u8 passwordPSK[0x20]; char passphrase[0x40]; // Plaintext of the passphrase of the network, without a trailing nullbyte.
} networkStruct; u8 PBKDF2_passphrase[0x20]; // PBKDF2 of the passphrase and SSID (http://jorisvr.nl/wpapsk.html).
} networkStructure; // This is apparently used twice in the actual wifi slot structure (?) // 0xAC
typedef struct { typedef struct
bool exists; {
u8 padding1; bool set; // Was the network was set or not?
u16 checksum; //crc-16 of the next 0x410 bytes, with initval 0: https://github.com/lammertb/libcrc/blob/v2.0/src/crc16.c#L43-L76 u16 checksum; // CRC-16 checksum of the next 0x410 bytes.
//if the network is set "normally", 'use' is 1
//if the network is set by WPS, 'use' is 0
//'second' is 0
//if setting multiple networks with WPS in the same session, only the last set will have this. others will have completely 0x00 except for 'exists'
networkStruct network;
u8 padding2[0x20];
//completely 0x00 if the network was set "normally", otherwise (set by WPS) normal but 'use' and 'second' are 1
networkStruct network_WPS;
u8 padding3[0x20C];
bool auto_obtain_IP; //defaults to 1 networkStructure network; // First network structure. Only set if the network was set "normally", or was the last to be set using WPS during the session. Size 0x88
bool auto_obtain_DNS; //defaults to 1 u8 padding1[0x20];
u16 padding4;
u8 IP_address[4]; networkStructure network_WPS; // Second network structure. Only set if the network was set using WPS, otherwise 0-filled.
u8 gateway_address[4]; u8 padding2[0x20C];
u8 subnet_mask[4];
u8 primary_DNS[4]; bool auto_obtain_ip_addr; // Automatically get the IP address (use DHCP) or not, defaults to 1.
u8 secondary_DNS[4]; bool auto_obtain_DNS; // Automatically get the DNS or not, defaults to 1
u16 padding3;
// if setting multiple networks in the same session, only the last set will have these. others will have completely 0x00 u8 ip_addr[0x4]; // IP address, to use if (auto_obtain_ip_addr) is false.
u8 unk1[4]; u8 gateway_addr[0x4]; // IP address of the gateway, to use if (auto_obtain_ip_addr) is false.
u8 IP_to_use[4]; u8 subnet_mask[0x4]; // Subnetwork mask, to use if (auto_obtain_ip_addr) is false.
u8 MAC_address[6]; u8 primary_DNS[0x4]; // IP address of the primary DNS , to use if (auto_obtain_ip_addr) is false.
u8 channel; u8 secondary_DNS[0x4]; // IP address of the secondary DNS, to use if (auto_obtain_ip_addr) is false.
u8 padding5;
bool use_proxy; //defaults to 0 u8 lastSet[0x4]; // Always 0x01050000 ? Only set if the network was the last to be set during the session.
bool basic_authentication; //defaults to 0 u8 ip_to_use[0x4]; // IP address to use. Only set if the network was the last to be set during the session.
u16 port_number; //defaults to 1 u8 mac_addr[0x6]; // MAC address of the AP. Only set if the network was the last to be set during the session.
char proxy_address[0x30]; //including ending nullbyte u8 channel; // Channel. Only set if the network was the last to be set during the session.
u8 padding6[0x34]; u8 padding4; // Only set if the network was the last to be set during the session.
char proxy_username[0x20]; //including ending nullbyte
char proxy_password[0x20]; //including ending nullbyte
u16 padding7;
u16 MTU_value; //defaults to 1400, range [576;1500]
//nothing beyond this point (0x414), but each slot is 0xC00 big... bool use_proxy; // Use a proxy or not, defaults to 0.
bool basic_authentication; // Use a basic authentication for the proxy, defaults to 0.
u16 port_number; // Port to use for the proxy, defaults to 1.
char proxy_addr[0x30]; // URL/address of the proxy, including a trailing nullbyte.
u8 padding5[0x34];
char proxy_username[0x20]; // Username to use for basic authentication, including a trailing nullbyte.
char proxy_password[0x20]; // Password to use for basic authentication, including a trailing nullbyte.
u16 padding6;
u16 MTU_value; // MTU value, defaults to 1400 and ranges between 576 and 1500, inclusive.
u8 padding8[0x7EC]; u8 padding8[0x7EC];
} wifiBlock; } wifiSlotStructure;
#endif #endif

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
bool isConnected = false; bool isConnected = false;
char sdFreeSize[16], sdTotalSize[16], ctrFreeSize[16], ctrTotalSize[16], name[0x16]; char sdFreeSize[16], sdTotalSize[16], ctrFreeSize[16], ctrTotalSize[16], name[0x16];
Result ret = 0; Result ret = 0;
wifiBlock slotData; wifiSlotStructure slotData;
consoleInit(GFX_BOTTOM, NULL); consoleInit(GFX_BOTTOM, NULL);
@ -114,48 +114,54 @@ int main(int argc, char *argv[])
//=====================================================================// //=====================================================================//
ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 0, (u8*)&slotData); ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 0, (u8*)&slotData);
if ((!ret) && (slotData.exists)) if ((!ret) && (slotData.set))
{ {
if (slotData.network.use) if (slotData.network.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network.password); printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network.passphrase);
} }
else if (slotData.network_WPS.use) else if (slotData.network_WPS.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 1 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network_WPS.password); printf("\x1b[32;1m*\x1b[0m WiFi 1 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.passphrase);
} }
printf("\x1b[32;1m*\x1b[0m WiFi 1 mac address: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
} }
ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData); ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 1, (u8*)&slotData);
if ((!ret) && (slotData.exists)) if ((!ret) && (slotData.set))
{ {
if (slotData.network.use) if (slotData.network.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network.password); printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network.passphrase);
} }
else if (slotData.network_WPS.use) else if (slotData.network_WPS.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 2 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network_WPS.password); printf("\x1b[32;1m*\x1b[0m WiFi 2 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.passphrase);
} }
printf("\x1b[32;1m*\x1b[0m WiFi 2 mac address: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
} }
ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData); ret = CFG_GetConfigInfoBlk8(CFG_WIFI_SLOT_SIZE, CFG_WIFI_BLKID + 2, (u8*)&slotData);
if ((!ret) && (slotData.exists)) if ((!ret) && (slotData.set))
{ {
if (slotData.network.use) if (slotData.network.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network.password); printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network.passphrase);
} }
else if (slotData.network_WPS.use) else if (slotData.network_WPS.use)
{ {
printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID); printf("\x1b[32;1m*\x1b[0m WiFi 3 SSID: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.SSID);
printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n\n", slotData.network_WPS.password); printf("\x1b[32;1m*\x1b[0m WiFi 3 pass: \x1b[32;1m%s\x1b[0m\n", slotData.network_WPS.passphrase);
} }
printf("\x1b[32;1m*\x1b[0m WiFi 3 mac address: \x1b[32;1m%02X:%02X:%02X:%02X:%02X:%02X\x1b[0m\n\n", slotData.mac_addr[0], slotData.mac_addr[1], slotData.mac_addr[2], slotData.mac_addr[3], slotData.mac_addr[4], slotData.mac_addr[5]);
} }
printf("\x1b[32;1m> Press any key to exit =)\x1b[0m"); printf("\x1b[32;1m> Press any key to exit =)\x1b[0m");