Saturday, February 26, 2011

AT Commands: Mobile Messaging

I was just wondering on how to send SMS from your computer via a mobile device (or GPRS modem). I dug it up and created a small application using c++ (Netbeans IDE) which you can extend and use as per your free will.

The How??


There is a great guide here which you can use to telnet your mobile device and test sending a SMS manually. To do it via a program: read on.

Quick Start


To incorporate this library into your project all you have to do is to include the "ATCommands.h" file. This exports the following functions:

void initPort(int n);
void pokeDevice();
int getMsgIndex();
void sendSMS(char *TargetNo,char *Msg);
void closePort();

Lets dicuss their roles one at a time:
  • initPort(int n): It initializes and sets up the port for communication. The device string should be of the form /dev/ttS<n> where n is the port number (like mostly if you have only one device attached then it will be /dev/ttyS1).
  • pokeDevice(): To be used only under debug mode(explained later). It is analogous to a ping.
  • getMsgIndex(): It is a helper function for sendSMS and returns the index for the new message to be written.
  • sendSMS(char *TargetNo,char *Msg): It is the function you want to call most often and is responsible for actual sending of SMS.
  • closePort(): performs cleanup and closes open port.
Putting it all together, we have a sample test program as:

initPort(n); // Open Port and set params;
#ifdef DEBUG
pokeDevice(); // To test if connection can be made
#endif
sendSMS(argv[2],argv[3]); // actual procedure that sends message
// argv[2] is no. and argv[3] is MSG
closePort(); // Cleanup

Try running it and .... guess what... you've got SMS (You've got mail sounds more catchy or is it just me :P).

Under The Hood


The code I have written supports a DEBUG flag. All you've got to do is to include "Debug.h" which defines a macro Debug and enables logging of debug messages to stdout. If you are extending the library then you might want to use the DbgPrint( char *format, ... ) function to maintain uniformity of the debug flag.

click download link below to download the complete netbeans project and have a go at it yourself.

Download

The above code was compiled using g++4.3.2/cygwin and tested with mobile handsets of Nokia, Sony Ericsson and Sigmatel. It should also work with most GPRS modems. 

Further Improvements


  • Support for handling multiple mobile devices at once.
  • Error handling can be better.
  • Support for Queueing/Scheduling of messages.

Sunday, February 20, 2011

Rootkit.com info leak poses threat to other sites


Big news appeared on the 15th feb 2011 the famous www.rootkit.com (HBGary) was attacked and all the data in its mysql db and emails were stolen and posted online. Being a huge fan of the book Rootkits: subverting the windows kernel by Hoguland and Butler, I was an active member of the community there.

It is believed that the site http://dazzlepod.com/rootkit/ had published the username and password of all accounts in clear text (And yes mine toooo!!). As many users are in a habit of keeping the same password for all accounts like their mail or facebook etc, this posed a great risk.

The good thing is that the site has now removed the cleartext passwords stating that it has the potential to compromise people's social networking or mailing accounts. But the download to the backup of the mysql db still is available at : http://stfu.cc/rootkit_com_mysqlbackup_02_06_11.gz. Moreover, the password field in the database is hashed.

So, can you see your password (clear text) in here... Yes, it is now a DIY thing.

You will have to use the JTR (John the ripper password cracker) tool. The hash used is a vulnerable MD5 hash which can be broken given JTR has the right dictionary (http://dazzlepod.com/site_media/txt/passwords.txt).
JTR is available at : http://www.openwall.com/john/

  • Step 1: Download backup, JTR, dictionary (john is in synaptic for ubuntu users).
  • Step 2: Extract the .gz file and open the extracted file as text, search for your login name and get your password's hash (I used nano to open the file and searched for my login name. Hash is the field next to your login name). Note only the first occurence of your username as rest may be entries for comments and other stuff.
  • Step 3: Create a text file test.txt with content "mypassword:<hash>" without the "" and replace <hash> with the hash you found in step 2.
  • Step 4: Open terminal and ask jtr to do its magic using the following command :
                    john -wordlist=passwords.txt -format=raw-MD5 test.txt
That was easy.. funny part is that it took 0.00 secs to crack my password. Am thinking of increasing my password strength....

Now what???
If you or someone you know is a rootkit.com user then you must immediately change your password for all site accounts that have the same password. Go Go Go!!!

With all that being said and done, I feel that it is really unethical of someone to post such stuff online and posing a threat to other sites.However, It is our duty to stay vigilant enough and act on it as soon as possible. I am also the kind of person who likes to keep one password for all accounts (I know its not recommended but its just easier this way) and hence had to go through a lot of settings and change password pages. Thankfully, none of my accounts were compromised before I changed my password. Hope it is the same for you.:)