这篇文章来自网页:http://depletionregion.blogspot.ch/2013/10/cc3000-smart-config-transmitting-ssid.html 由于我担心被删除所以赶紧备份到我的博客里来。英文不好的同学可以加我(致力于智能设备APP端的开发者)的QQ来讨论:285797382,
Initially TI clearly documented how the SSID and password were transmitted to a CC3000 enabled device in their "CC3000 First Time Configuration" document. However with release 1.10 they changed the approach to one called Smart Config and now document the API but no longer explain what is happening at the network level. Here I cover this missing information for the new approach.
So let's start at the start - we have a problem - we want to send two pieces of information, an SSID and the keyphrase, from one party that is already a member of the wifi network to an external party who can monitor all the encrypted wifi traffic but who cannot decrypt it.
Someone who cannot decrypt the wifi traffic can still see quite a lot of information, e.g. they can see the source and receiver MAC addresses of every packet sent.
They can also see the length of the data portion of the packets. The encryption affects that size of the packets sent but in a consistent manner, e.g. if one sends n bytes of data in a given packet then the encrypted packet will contain (n + x) bytes where x is constant across all packets.
So the solution to our problem is to encode the information in the size of the packets sent (the actual content is irrelevant).
The party on the secured network just sends UDP packets with particular lengths to another party on the network. That the other party is not interested in receiving the packets is not important.
The external party cannot tell directly that a packet that it is looking at contains UDP data, however the packets still include basic type information that allows many packets to be excluded from consideration, e.g. any packet that is not of 802.11 subtype "QoS data" can be excluded.
As the external party does not know in advance which wifi channel to look at or which source and receiver address pair to pay attention to one must, in addition to the underlying data, i.e. encoded SSID etc., send regular repeating patterns that allow this data to be spotted.
We convert our SSID and keyphrase into a sequence of tag values, string lengths, nibble values and separators values and then encode and transmit all these values as packet lengths.
Let's look in detail at the values sent.
We use two tags - an SSID tag with value 1399 and a keyphrase tag with value 1459 and one standard separator sequence consisting of two values - 3 followed by 23.
And we use two constants, L with value 28 and C with value 593, that we will see used below.
So for the SSID the following sequence of values are generated in this order:
Seq. | High | Low |
---|---|---|
2i | Li-1 ^ (2i % 16) | Hi |
2i+1 | Hi ^ ((2i + 1) % 16) | Li |
'M' | 'y' | 'P' | 'l' | 'a' | 'c' | 'e' | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hex: | 0x4D | 0x79 | 0x50 | 0x6C | 0x61 | 0x63 | 0x65 | |||||||
Nibbles: | 0x4 | 0xD | 0x7 | 0x9 | 0x5 | 0x0 | 0x6 | 0xC | 0x6 | 0x1 | 0x6 | 0x3 | 0x6 | 0x5 |
H0 | L0 | H1 | L1 | H2 | L2 | H3 | L3 | H4 | L4 | H5 | L5 | H6 | L6 |
C h a r |
S e q |
→ | Hi | Lo | → | Byte | Hi | Lo | → | Hi | Lo | → | Sum | → | Len |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'M' | 0 | 0x0 | H0 | 0x4D | 0x0 | 0x4 | 0x0 | 0x4 | 0x04 + 593 | 597 | |||||
1 | H0 ^ 0x1 | L0 | 0x4 ^ 0x1 | 0xD | 0x5 | 0xD | 0x5D + 593 | 686 | |||||||
'y' | 2 | L0 ^ 0x2 | H1 | 0x79 | 0xD ^ 0x2 | 0x7 | 0xF | 0x7 | 0xF7 + 593 | 840 | |||||
3 | H1 ^ 0x3 | L1 | 0x7 ^ 0x3 | 0x9 | 0x4 | 0x9 | 0x49 + 593 | 666 | |||||||
'P' | 4 | L1 ^ 0x4 | H2 | 0x50 | 0x9 ^ 0x4 | 0x5 | 0xD | 0x5 | 0xD5 + 593 | 806 | |||||
5 | H2 ^ 0x5 | L2 | 0x5 ^ 0x5 | 0x0 | 0x0 | 0x0 | 0x00 + 593 | 593 | |||||||
'l' | 6 | L2 ^ 0x6 | H3 | 0x6C | 0x0 ^ 0x6 | 0x6 | 0x6 | 0x6 | 0x66 + 593 | 695 | |||||
7 | H3 ^ 0x7 | L3 | 0x6 ^ 0x7 | 0xC | 0x1 | 0xC | 0x1C + 593 | 621 | |||||||
'a' | 8 | L3 ^ 0x8 | H4 | 0x61 | 0xC ^ 0x8 | 0x6 | 0x4 | 0x6 | 0x46 + 593 | 663 | |||||
9 | H4 ^ 0x9 | L4 | 0x6 ^ 0x9 | 0x1 | 0xF | 0x1 | 0xF1 + 593 | 834 | |||||||
'c' | 10 | L4 ^ 0xA | H5 | 0x63 | 0x1 ^ 0xA | 0x6 | 0xB | 0x6 | 0xB6 + 593 | 775 | |||||
11 | H5 ^ 0xB | L5 | 0x6 ^ 0xB | 0x3 | 0xD | 0x3 | 0xD3 + 593 | 804 | |||||||
'e' | 12 | L5 ^ 0xC | H6 | 0x65 | 0x3 ^ 0xC | 0x6 | 0xF | 0x6 | 0xF6 + 593 | 839 | |||||
13 | H6 ^ 0xD | L6 | 0x6 ^ 0xD | 0x5 | 0xB | 0x5 | 0xB5 + 593 | 774 |
1381084544.032552000 1399 <----- SSID tag 1381084544.033572000 35 <----- SSID length + 28 1381084544.033589000 3 <--+-- separator 1381084544.033594000 23 <--' 1381084544.033667000 597 <----- 'M' hi-nibble 1381084544.033675000 3 <--+-- separator 1381084544.033723000 23 <--' 1381084544.034369000 686 <----- 'M' lo-nibble 1381084544.035385000 3 <--+-- separator 1381084544.036271000 23 <--' 1381084544.036448000 840 <----- 'y' hi-nibble 1381084544.036467000 3 <--+-- separator 1381084544.036481000 23 <--' 1381084544.036541000 666 <----- 'y' lo-nibble 1381084544.037262000 3 <--+-- separator 1381084544.037271000 23 <--' 1381084544.037496000 806 <----- 'P' hi-nibble 1381084544.038019000 3 <--+-- separator 1381084544.038032000 23 <--' 1381084544.038097000 593 <----- 'P' lo-nibble 1381084544.043096000 3 <--+-- separator 1381084544.044209000 23 <--' 1381084544.044785000 695 <----- 'l' hi-nibble 1381084544.045422000 3 <--+-- separator 1381084544.045855000 23 <--' 1381084544.048359000 621 <----- 'l' lo-nibble 1381084544.049327000 3 <--+-- separator 1381084544.049347000 23 <--' 1381084544.049406000 663 <----- 'a' hi-nibble 1381084544.049412000 3 <--+-- separator 1381084544.049416000 23 <--' 1381084544.049568000 834 <----- 'a' lo-nibble 1381084544.050052000 3 <--+-- separator 1381084544.050067000 23 <--' 1381084544.050808000 775 <----- 'c' hi-nibble 1381084544.051463000 3 <--+-- separator 1381084544.052082000 23 <--' 1381084544.055415000 804 <----- 'c' lo-nibble 1381084544.056319000 3 <--+-- separator 1381084544.056334000 23 <--' 1381084544.056398000 839 <----- 'e' hi-nibble 1381084544.056404000 3 <--+-- separator 1381084544.056407000 23 <--' 1381084544.056644000 774 <----- 'e' lo-nibble 1381084544.058021000 3 <--+-- separator 1381084544.058034000 23 <--' 1381084544.059236000 1459 <----- passphrase tag 1381084544.059252000 35 <----- passphrase length + 28 1381084544.059255000 3 <--+-- separator 1381084544.059258000 23 <--' 1381084544.059261000 597 <----- 'L' hi-nibble 1381084544.059937000 3 <--+-- separator 1381084544.059949000 23 <--' 1381084544.060043000 685 <----- 'L' lo-nibble 1381084544.060723000 3 <--+-- separator 1381084544.060729000 23 <--' 1381084544.060884000 823 <----- 'e' hi-nibble 1381084544.061407000 3 <--+-- separator 1381084544.061411000 23 <--' 1381084544.061954000 678 <----- 'e' lo-nibble 1381084544.062651000 3 <--+-- separator 1381084544.062709000 23 <--' 1381084544.063217000 616 <----- 't' hi-nibble 1381084544.063696000 3 <--+-- separator 1381084544.063699000 23 <--' 1381084544.064344000 629 <----- 't' lo-nibble 1381084544.064893000 3 <--+-- separator 1381084544.064897000 23 <--' 1381084544.065561000 629 <----- 'M' hi-nibble 1381084544.066131000 3 <--+-- separator 1381084544.066221000 23 <--' 1381084544.066947000 654 <----- 'M' lo-nibble 1381084544.066955000 3 <--+-- separator 1381084544.067371000 23 <--' 1381084544.067491000 679 <----- 'e' hi-nibble 1381084544.067871000 3 <--+-- separator 1381084544.068325000 23 <--' 1381084544.069089000 838 <----- 'e' lo-nibble 1381084544.069097000 3 <--+-- separator 1381084544.069593000 23 <--' 1381084544.069711000 837 <----- 'I' hi-nibble 1381084544.070191000 3 <--+-- separator 1381084544.070656000 23 <--' 1381084544.074244000 842 <----- 'I' lo-nibble 1381084544.074259000 3 <--+-- separator 1381084544.075225000 23 <--' 1381084544.075286000 679 <----- 'n' hi-nibble 1381084544.075291000 3 <--+-- separator 1381084544.075293000 23 <--' 1381084544.075521000 783 <----- 'n' lo-nibble 1381084544.075533000 3 <--+-- separator 1381084544.076058000 23 <--' -------------------------- No delay on Android, 100ms delay with Java applet library, then repeat from start again. 1381084544.076246000 1399 <----- SSID tag 1381084544.076850000 35 <----- SSID length + 28 ...The output generated by the TI iOS and Java applet Smart Config applications is identical (except for the noted 100ms delay). However oddly the iOS Smart Config application does not interleave the separator values 3 and 23 between the characters of the SSID and keyphrase, instead it always sends out a sequence of 10 separator value pairs as shown here and then sends out the SSID and keyphrase. So here one can hardly call 3 and 23 separators but I've stuck with this name here:
1381085051.154799000 3 <--+-- separator 1 1381085051.159414000 23 <--' 1381085051.164143000 3 <--+-- separator 2 1381085051.170050000 23 <--' 1381085051.174861000 3 <--+-- separator 3 1381085051.179503000 23 <--' 1381085051.185282000 3 <--+-- separator 4 1381085051.190274000 23 <--' 1381085051.195296000 3 <--+-- separator 5 1381085051.200047000 23 <--' 1381085051.206394000 3 <--+-- separator 6 1381085051.211076000 23 <--' 1381085051.215383000 3 <--+-- separator 7 1381085051.225363500 23 <--' 1381085051.235344000 3 <--+-- separator 8 1381085051.235459000 23 <--' 1381085051.236902000 3 <--+-- separator 9 1381085051.241718000 23 <--' 1381085051.249366000 3 <--+-- separator 10 1381085051.253099000 23 <--' 1381085051.257767000 1399 <----- SSID tag 1381085051.262315500 35 <----- SSID length + 28 1381085051.266864000 597 <----- 'M' hi-nibble 1381085051.273117000 686 <----- 'M' lo-nibble 1381085051.278023500 840 <----- 'y' hi-nibble 1381085051.282930000 666 <----- 'y' lo-nibble 1381085051.291178000 806 <----- 'P' hi-nibble 1381085051.294688000 593 <----- 'P' lo-nibble 1381085051.299266000 695 <----- 'l' hi-nibble 1381085051.308603000 621 <----- 'l' lo-nibble 1381085051.311723000 663 <----- 'a' hi-nibble 1381085051.315706000 834 <----- 'a' lo-nibble 1381085051.321567000 775 <----- 'c' hi-nibble 1381085051.326156000 804 <----- 'c' lo-nibble 1381085051.332654000 839 <----- 'e' hi-nibble 1381085051.337025000 774 <----- 'e' lo-nibble 1381085051.342818000 1459 <----- passphrase tag 1381085051.346519000 35 <----- passphrase length + 28 1381085051.353083000 597 <----- 'L' hi-nibble 1381085051.359196000 685 <----- 'L' lo-nibble 1381085051.362984000 823 <----- 'e' hi-nibble 1381085051.366772000 678 <----- 'e' lo-nibble 1381085051.373192000 616 <----- 't' hi-nibble 1381085051.382117000 629 <----- 't' lo-nibble 1381085051.386131000 629 <----- 'M' hi-nibble 1381085051.390145000 654 <----- 'M' lo-nibble 1381085051.393997000 679 <----- 'e' hi-nibble 1381085051.400047000 838 <----- 'e' lo-nibble 1381085051.404880000 837 <----- 'I' hi-nibble 1381085051.412003000 842 <----- 'I' lo-nibble 1381085051.414365000 679 <----- 'n' hi-nibble 1381085051.420336000 783 <----- 'n' lo-nibble --------------------------- No delay then repeat from start again. 1381085051.432048500 3 <--+-- separator 1 1381085051.443761000 23 <--' ...
$ tshark -r output.pcap -o 'wlan.enable_decryption:TRUE' \ -Y 'wlan.fc.retry == 0 && !icmp && udp && ip.src == 192.168.1.177 && ip.dst == 192.168.1.1 && udp.dstport == 15000' -T fields -e frame.time_epoch -e data.len | head -n 512ip.src must to be changed to the IP address of the device running the Smart Config application, e.g. an iPhone, and ip.dst must be the IP address used as the gateway by the application.