Aug 21

Simple Bluetooth connection with Android

In this post I’ll describe how I got a simple bluetooth connection set up with an Android phone and Windows 8. You’d think it would work out of the box fairly easily but for me it sure didn’t, probably because I’m using a cheap BT dongle.

First of all, go check out this Android bluetooth code bit, that will allow you to connect and send/receive data over the communication channel. Make sure to edit the following line of code

  // MAC-address of Bluetooth module (you must edit this line)
  private static String address = "00:15:FF:F2:19:5F";

Here you will need to fill in the MAC address of your Bluetooth module in your PC (or if your PC doesn’t have BT built in, a Bluetooth dongle). For some reason I could not find it easily on Windows 8, googling said you could find it in the Address field of the Bluetooth module in Device Manager, mine showed “00000002” which obviously is not a MAC address.

To find it I enabled visibility of my BT dongle (easiest way to do this is to go to Control Panel and search for “Bluetooth”). Select “Change Bluetooth settings” and tick the “Allow Bluetooth devices to find this computer”. Apply the changes and turn to your Android phone. Now search for discoverable devices while you have logcat active (e.g. in Eclipse). Once the pairing is done, check your logcat log and voila, the MAC address will be somewhere in the log lines. I know this is a very stupid approach on getting your BT MAC but I couldn’t be bothered to dig through Windows 8’s multitude of (hidden) menus and options.

Bluetooth Settings

Bluetooth Settings

After this you should be able to “hide” your Bluetooth radio again as the Android app will be able to connect without any problems now it has the MAC address.

Next up you probably want to be able to receive data from your phone to your PC, this requires a serial port (COM Port). In the Bluetooth Settings window, go to the COM Ports tab and click “Add”. Select “Incoming” and hit OK. Your computer will assign a COM port for you.

In my case it was COM4. To easily test communications, you can download ComTestSerial. It looks a bit funky but don’t worry, it works great. Once installed, run the program and hit the “Serial Port” button in the bottom right of the program. In the dialog that appears make sure the COM port that was created earlier is checked. I left the baud rate and other options as default. Lastly, click the “Serial port (COM X)” button with a red LED next to it (X being the number of the COM port). and your connection will be open.

Finally, run the Android app and hit the buttons, you’ll see 0’s and 1’s being received by your computer.

COM Test

COM Test

And there you have it, simple serial port communication over a wireless channel. Now you can create your own software on your computer that connects with your phone and transform your phone in a full fledged remote control!

p.s. If you happen to find an easier way to get the Bluetooth MAC on Windows 8, please let me know in the comments and I’ll update this post as it seems this really depends on what Bluetooth hardware you have.

Mar 31

Crank up your password security!

Inspired by ArsTechnica I decided to spend a good part of my Saturday seeing how easy it would be to crack some passwords. As stated in the article it has become ridiculously easy to do. Following the article  somewhat I started off by getting myself a copy of HashCat and its GUI (I know, I know, I should use the cmd line but I’d rather not spend the entire day memorizing commands).

Next up is a list of password hashes I wanted to have something to crack. MD5Decrypter has a list available for downloading but I just did a Google search, hopped onto a forum and grabbed a file someone had requested help cracking with. Now I had my list and I was ready to get crackin’! But wait, there was still one more thing I needed which was a wordlist/dictionary to compare all these precious hashes with. Easy enough, just get the RockYou password file which can be found pretty quickly nowadays.

The moment of truth! I opened up Hashcat, pointed it to the uncracked hash file, added the RockYou password list to the Wordlists made sure Mode was set to Straight and hit the “Power of the Atom” button. In less than a minute it managed to decrypt 1036 of the 31275 files, which isn’t that much but considering it took so little time one starts to wonder how long it takes to crack your own passwords.

Hashcat Result

Hashcat Result

Next up I added the best64.rule which came with Hashcat and let it run again. After some time it came up with the following result.

Hashcat w/ rules

Hashcat with rules applied

Next I tried a Combination attack but that seemed to take an awful lot of time so I stopped that continuing with a brute-force attack using a mix of alpha numeric characters. The estimation said 45 minutes, take note that this takes this long because it’s running on my laptop (i7 with 8 threads @ 1.66GHz), using a more powerful computer or using a distributed network this can probably be done in a few minutes at most. But what would you expect if you need to check 56,800,235,584 words!

After 25 minutes I stopped the operation as it was obvious this was not a good way to get passwords quickly. Only 370 or 0.1% had been found using this technique.

Hashcat Brute Force

Hashcat Brute Force

Following these it was time to try my own passwords, I ran them through the SHA1 hashing algorithm and started an attack. I was really curious if they were going to fall or not… success! Not a single one got cracked, I guess I can feel a tiny bit safer on the web now, then again a lot depends on how these passwords are stored on the plethora of websites (plaintext *horror*, hashed with MD5, hashed with SHA1, with or without salts, …).

And ending this cracking fun I exported a column of hashed md5 passwords from a database I own and ran an attack using the best64 rule. After a merely ten minutes 15% of all passwords were cracked. Looking at them it seems a lot people couldn’t care less about the strength of their password. Lastly because I really wanted to know how many passwords would fall when taking the time like a dedicated cracker I applied the d3ad0ne rule and ran the attack again. This would take a handful of hours so I left it running in the background, and went on with my day. After a good fifteen hours it managed to get a little less than 2000 passwords, which is an amazingly scary large amount.

To conclude, as stated on various websites the concept of passwords is outdated. With current technologies and computing power any person who wants to cause havoc or be evil can do so in less than one day. I didn’t know anything about hacking or cracking passwords but seeing how simple it is using Hashcat makes me think of strengthening my passwords nonetheless especially since a person with no prior knowledge can discover someone’s password with a little bit of patience. One might argue that the two-way authentication should be the norm nowadays. Luckily Google already gave people the option to use it.

Mar 05

The Last Chapter

Being back for almost a week now and I figured I should post a closing blog thing here.

A last look at the exams perhaps: I passed all my four exams (20, 22, 28 and 30 on 30), now I still need to get the “Transcript of Records” with those grades so I can officially present them to Group T. Mailing the incoming office of PoliTO asking for it is all you have to do… if all your professors have registered your grades already, which one of mine hasn’t done yet. Typically Italian-style, no rush ;)

There have been a lot of rumors about the exams at PoliTO, I can’t confirm them but ‘my sources’ tell me 90% of the people cheat on their exam and they easily get away with it! Such a thing is completely unthinkable in Belgium but scenarios such as “Please put away your slides, if I see them when I pass next time, you’ll get minus 4” aren’t uncommon. People texting, taking photos and collaborating, it’s pretty insane if you ask me.

I’m not generalizing of course but I’ve heard this from a lot of different people so it must be a thing. Italians are so focused on getting 28 or higher as companies expect nothing less than those grades. I’ve seen people retake their exam with a 25 out of 30 because they thought it was a “low” grade.

Retaking at PoliTO isn’t really hard, so failing the first time is not a big issue. You can send an email to your professor asking to delete the ‘bad’ grade and register for the second time which is usually about two weeks later. If you still haven’t passed then you’ll have to come back in another exam period (February, July or September).

That was it for me, Erasmus has been such a great experience you can only believe it if you have experienced it yourself. And so I close this Erasmus segment of my blog, feel free to ask me questions about Torino or PoliTO in case something is not clear for you, I’ll be happy to help you!