Bug Vanquisher

31 August 2007

Playing with GSM Modems

Filed under: Fun — Tanveer Badar @ 6:12 PM

Are you a guru of AT commands? I just started playing with them and feel myself completely at home around the AT stuff. I’ll be assuming you are familiar with hyper terminal which I use to exercise total control over poor SIM card.

The play begins with you sending AT+CGMI to the modem. The modem will greet you with its name and hyper terminal chipping in with an ‘OK’. Hyper terminal will chip in most of the time, so I’ll skip those parts. In case of some error, you get a plain ‘ERROR’, ‘NOT CONNECTED’ or some other weird error essentially telling you that you are not welcome at the moment. Do take the time to check properly that device is connected, powered up, and has a SIM inside.

Next, tinker with device status by sending AT+CPAS. In reply, you will get a number if successful which should be 0 if the device is ready. Now, mention your intention of message store you wish to inspect/modify. The relevant command in AT+CPMS? (Edited: 24/07/08). The return message upon success will look something like this: “SM”,30,30,”SM”,30,30,”SM”,30,30 or “SM”,0,30,”ME”,25,25,”SM”30,30. To interpret this cryptic line, split across every string value. SM stands for SIM memory and ME for flash memory on the device/phone. Second number is the used storage and the third number is available storage. Going the next higher level, first triplet means the inbox location, second is the flash store (not always available) and the last one is the outbox location.

Lets set that location to SIM for everything. The appropriate command is AT+CPMS=”SM”,”SM”,”SM”. Now, the first operation you would like to perform is to finding out what’s inside, won’t you? This has one small (actually, really big) problem. You may execute AT+CMGL=<your wish> to find out all messages from inbox or outbox. <your wish> can have any of these values:

Wish Interpretation
REC UNREAD Retrieves all unread messages from inbox.
REC READ Retrieves all read messages from inbox.
STO UNSENT Retrieves all unsent messages from outbox.
STO SENT Retrieves all sent messages from outbox.
ALL Retrieves all messages from inbox regardless of their status.

The hugely small problem I mentioned earlier is that retrieving a message from inbox always marks it as read. It is a destructive read.

But that problem has a twisted solution, remember everything you got on REC UNREAD and mark them UNREAD again. Your DRAM is doing that all the time! You will need this command AT+WMSC=<NN>,”REC UNREAD”. <NN> is the 1-based message index. This command can also mark a message READ by “REC READ”, but that is redundant as you can do that already by merely viewing it.

You can have your revenge on anyone by sending SMS from hyper terminal. They will be astonished by your lowly quality of attack. Just remember this command:

AT+CMGS=”<mortal enemy’s number in international format>”<CR>
blah blah, <crtl-Z>

But that blah blah portion must be limited to less than about 150 characters. We are riding the backyard alley, things are really what they seem to be. It will not accept your bickering which exceeds 150 characters in length.

If you want to hide your track, you certainly need to delete some SMS. Enter AT+CMGD. This command takes a message index to delete at that position (AT+CMGD=2). or write it like this: AT+CMGD=1,<N>. <N> has the possible values of:

N Interpretation
0 Message at location 1 is deleted. AT+CMGD always defaults to 0.
1 All READ messages are deleted.
2 All SENT messages are deleted.
3 All READ, SENT and UNSENT message are deleted.
4 All messages are deleted.

And of course, I have set the category to ‘Fun’ because I think it is fun doing this with hyper terminal instead of using some object library which issues AT commands behind the scenes without you being any the wiser, ever!

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: