0

I was helping someone over at Ask Ubuntu with , what should of been a simple issue of connecting a Wiimote to Ubuntu, however we ran in to a bug in the driver.

The driver would request a bluetooth pairing code for the device, the user did not have one.

The user found a post on wiibrew explaining how to extract the code with a bit of C code.

They gave

char pin[6];
pin[0] = 0x6D;
pin[1] = 0x7E;
pin[2] = 0x3B;
pin[3] = 0x35;
pin[4] = 0x1E;
pin[5] = 0x00; 

So. the user made what they thought was a valid C file

#include <stdio.h> 

int main(void) 

{
 char pin[6]; 
 pin[0] = 0x41; 
 pin[1] = 0x7D; 
 pin[2] = 0x5D;  
 pin[3] = 0x8A;
 pin[4] = 0xD2;
 pin[5] = 0x40; 

 printf("the password is:\n"); printf("%s \n", pin ); 

}

The code compiles fine, no errors, however it should produce a 6 number passcode but just displays what looks like nonsense characters,

 A}]��@

As I am not a programmer, I don't understand what is wrong with this output, why did it give this result and how can we get the actual pairing code using this ?

Community
  • 1
  • 1
Mark Kirby
  • 21
  • 2
  • 11
  • I think the above program hardcodes the *pairing code*. It has to be extracted from somewhere. – Haris Dec 08 '15 at 15:54
  • The code might be undefined behavior because something which is not a null-terminated string is passed to `%s`. – MikeCAT Dec 08 '15 at 16:32
  • 1
    These are the correct characters you are printing. See: http://www.asciitable.com/ for the conversion between them. `A`, `}`, `]` and `@` are correct but `0x8A` and `0xD2` are not valid hexidecimal characters (hence the question marks). I think this code snippet was designed to be used another way and not just printed out (maybe by *pairing* these with something else??) – Samidamaru Dec 08 '15 at 16:43
  • Thanks all for the responses, I guess we are barking up the wrong tree here, thanks for your time. – Mark Kirby Dec 09 '15 at 11:03
  • This is not the 6 digit PIN that's manually entered. This is the HCI PIN which, as your link explains, is a "binary bluetooth address", and won't be human readable. – David Schwartz Dec 09 '15 at 11:11

1 Answers1

1

It is printing fine 0x8A and 0xD2 are not valid ASCII characters. Ascii uses Hex values 0x00-0x7F.

See here

d4r3llo5
  • 112
  • 11
  • 1
    If you want to print out the value in hex, you can do `printf("%X")` to print out the actual hex values. The pin is your WiiMote's MAC address backwards (as the guide stated), so hard coding should be fine. I do not think your code needs to actually compile based on what you posted, this is more a visual demonstration from what I gather. – d4r3llo5 Dec 08 '15 at 16:46