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!

29 August 2007

Windows Live the First Site to Move to Windows CardSpace

Filed under: WCF — Tanveer Badar @ 6:28 PM

They must be the first for others to show the way, no big deal. They have included support for Windows CardSpace while signing in to Windows Live Mail. You need to have IE 7 installed as well as .Net framework 3.0.

Clemens Vasters wrote two days ago about it. However, his post is less than what I call short and short on many accounts because no one tells you that in order to use it from non-administrator accounts, you need to add the two certificates IE 7 shows you (one issued by Microsoft to Windows Live Mail, and the second one issued by Verisign which verifies the Microsoft’s certificate) to your trust store before Windows CardSpace launches successfully.

28 August 2007

Of Paging and Buses

Filed under: Computer Theory, Fun — Tanveer Badar @ 6:20 PM

This bus has nothing to do with this bus or this. I was referring to this bus instead. So, you got up in the morning and walked to bus stop and hitched a ride to office/school/college in that public bus.

Given the messy time it is in morning, everyone very busy with themselves on the roads, people bustling here and there, buses full to bursting point, it is hard to find a seat in the bus. What means do you employ to gain hold of a seat? Pushing, feigning a sick health ( :-) ), asking someone to sit up and give you their seat, bullying as the last resort? Whatever means you use, you will surely benefit if you had read a little about how operating systems do paging.

Different algorithms used to paging have a variety of characteristics and performance guarantees associated with them. They can also help you make your decision about where to sit, what to do to grab a seat and certainly, what to avoid.

  • Perhaps the best is the one which replaces the page which won’t be needed for the longest. Analogous to this, you should seek the passenger who will leave their seat the earliest,  use whatever means to gain hold. This strategy suffers the same problem as that algorithm mentioned, you cannot know beforehand who is going to leave when, unless you employ heuristics. For example, you may consider standing near school/college students when their institute is nearing, they will leave in a hurry.

  • Then, the worst choice is FIFO. You cannot expect people to play fair and offer you a seat if they can do otherwise.

  • Try going for the least recent arrival, corresponding page replacement algorithm is LRU. The person who is sitting the longest is likely to get off in near future as compared to others.

  • Given your specific route, most people will tend to get on and off quite quickly or they may stick with you for a long time. Choose wisely. The person who get into the vehicle recently is likely to leave after a short time.

  • Pick a random seat and stand near them. Here again, you can use some heuristics. People usually start to look on the road pretty closely when they are about to get off the bus. You may want to choose such a passenger.

  • Consider assigning a certain likelihood to the nearby passengers. If they are busy reading, their stop is far from your comfort. If someone is talking non-stop, their stop is no where near their recognition of surroundings!

  • Don’t go anywhere near old people and those visibly sick. They will have higher precedence than you when a seat needs to be filled. You will waste your time and chance which would be better utilized some place else.

  • [Update: 18/09/2007] Large groups of people tend to get off the bus near community places like shopping malls, something religious, hospitals [ :) ], schools, colleges etc. Spot such a group if some community place is on your path.

  • [Update: 07/11/2007] People do not actively seek vacant seats but instead tend to stay at one place. This call for spatial locality.

  • [Update: 07/11/2007] If you regularly take a route, you can remember people’s faces and easily predict who gets off when. Hence, the temporal locality.

Man of the House

Filed under: Fun — Tanveer Badar @ 5:56 PM

Just five minutes ago, I was man of the house. Everyone senior to me was off to some other chore than sit in office and command me. Meaning, I was my own team lead, an occupational hazard of being the junior most member of a development team. :(

However, this loneliness gave me total control over many aspects of the project and I had my say in everything. This lead to me discovering four obscure, esoteric, obnoxious bugs in code and state transitions.

Totally Cool

Filed under: Fun — Tanveer Badar @ 10:14 AM


23 August 2007

How smart is your fridge?

Filed under: Fun — Tanveer Badar @ 1:32 PM

You really think that it turns off the light when you close the door? Your car doors really lock themselves when you step out? Your laptop stays off/sleeps when you lower the lid?

Think again. You may put a camera inside your fridge to see if the light really goes out. If the fridge is smart, it will know there is an observer inside and turn the light off immediately. Your attempt, failed! Next time, try measuring the power consumption with open and closed door. Your fridge is really smart, it will detect the small voltage drop across the ammeter component and will turn the light off the instant door closes. Spoiled measurements. Ha Ha Ha!

Do you recheck your car doors when stepping outside? They may only lock themselves when you check them and not otherwise. How many times we just take it granted that the car is safe.

To cap it all, your wife will only not cheat on you when you are around to watch. Isn’t that correct? You children will not date if they know you are near by.

Ever had the weird sensation of laptop battery dying out very quickly, even with the lid off? Only if you thought to catch the culprit next time, it won’t happen when you are on the watch. Your laptop is no fool and knows you are vigilant.

How would you measure the distance between two locations? Of course, with a ruler. But what really guarantees that the scale is exactly that much long that it says. You may use some other device, but who says that device is accurate in the first place.

This is not like Schrodinger’s cat at all. States collapse into one observable outcome when the box is opened. The cat is either dead or alive and does not go back to uncertain state when the box is again closed. Here, we want to measure the states without measuring.

In essence, it is not possible to verify a system from within that system. Some external component must be involved. But as soon as that component is involved, system boundary expands to include that component into the system.

20 August 2007


Filed under: Intelligence :( ?? — Tanveer Badar @ 4:30 PM

PNSC‘s building caught fire (again!) yesterday. It started on fourth floor and rapidly spread to the top floor. After a grueling fight of almost 10 hours, it was finally extinguished. Two fire-fighters were injured. One person died of cardiac failure. THE MANAGER ADMINISTRATION. VIJAY KUMAR KHATRI.

I am thinking of adding a ‘Spy’ tag to my blog. These entries are rapidly becoming a favorite of mine, it seems. A few months ago, the same incident had happened. Same place, same time, same day of week. Shipping Corporation is not dumb. They must have hired their administration manager after complete background check. But lets face it, Pakistan still does not trust even the immigrants of 1947 separation properly, India does the same to Muslims living there.

I have two co-workers who are sort of related to the dead manager, they say he was honest and died of the responsibility bestowed upon him that he had failed. But again, I don’t trust it entirely. Fire started at the same building some months ago, they do nothing to prevent the second incident. Now, the second time when the fire starts, their administration manager dies of heart attack? Doesn’t it sound like someone should die to break the chain of evidence leading to the real culprit?

Hope vs Faith

Filed under: Decontamination, Personal — Tanveer Badar @ 1:07 PM

This has nothing to do with ‘Hope and Faith‘, but about ‘Hope‘ and ‘Faith‘. Though, I got the idea from the sitcom. The word goes like:

“Never be anyone’s hope, be their faith. They are like proof and belief. Hopes aren’t meant to last, but faiths last forever.”

So, lets begin the argument of which is stronger. Why is the collision between science and religion so intense (especially from the 1600s)? One requires proof and one is based on belief. One demands events to be repeatable, verifiable and measurable, the other requires only that you believe. One promises you materialistic advancements, one gives you character refinement, way of living (at least for complete religions quite unlike Christianity or Buddhism), spiritual basis, etc. Of course, your faith in God is only meaningful if you believe and don’t want proof of existence. You may ask God to show you how He creates from nothing, but that is not proof for your faith in Him, it is just out of interest.

One of the greatest problems with proof is that you cannot disprove anything unless you exhaust all possibilities. Second law of thermodynamics cannot be proven because it is ‘negative’. Same goes for some parts of theory of relativity. But if you believe them to be true, you won’t be searching for counter-examples. Similarly, proofs walk a very fine distance from being proven wrong.

Consider parsing, their are two general methods, top-down and bottom-up. In top-down parsing, one of the most well understood method is LL(k) parsing. In bottom-up parsing, LR(k) parsing is the strongest (generally! :) ). LL parsing is more restrictive, LR parsing imposes minimal constraints on the parser. Therefore, LR parsers recognize a larger class of grammars than LL parsers.

Turning to personal examples, I watched many class-mates having mounds of different (actually indifferent) certifications. They always told me that everyone cared about how much certifications you had, but I had faith in myself that I will be able to prove myself without such supports, which turned out to be true. An expectation I would never have to nerve to fulfil if I had hoped to get a good professional position.

I don’t believe in panspermia, unless I have seen proof. I believe in creation of everything by a Higher being. If you follow the logical conclusion, you will appreciate the proof that Adam and Eve lie at the top of human hierarchy and they must have been created specially. But again, if you believe in panspermia, this proof should not shift your opinion. And, I must add, we are only humans because we have the ability to leap beyond logic which boils down to believing and not wanting proof as not everything can be proven even by science.

You can always clearly see the difference among the people who hope and who have faith in their goals. Those who hope rarely achieve, those having faith often twist the circumstances to their benefit.

15 August 2007

Don’t ‘Not Leak Information’

Filed under: Computer Theory, Fun — Tanveer Badar @ 2:02 PM

A couple of days ago, I was watching Discovery Channel. They showed some program about UK military and Apache pilots, remember the exact details.

One point that particularly stood out was how those pilots were debriefed. All personal information and pointers linking them to be an Apache pilot were stripped away. I suppose this was to prevent the [potential, totally misunderstood] enemies from finding out the details of that helicopter, in case the mission was compromised.

Now, let us puddle together into the lakes of wild guesses. I may be as right as Israeli forces attacking Lebanon last year or as wrong as freedom fighters in Kashmir and Palestine. Consider the situation where only Apache pilots have no information. Easy targets to identify, capture a foreign solider (pilot) and if he/she has no personally identifiable item, you captured an Apache pilot.

Therefore, next time your commanding officer tells you to lose everything personal before going on a mission, point him/her to this page and this entry too. Never (ever!) lose everything you have, makes you an easy target to pick out from masses. A much better strategy is to go along the path of misinformation. Lose personals and gain it from your commanding officer.

Side note to intelligence agencies. You guys should keep a keen eye out for pilots not having any identification. Chances are high they are Britons and were flying Apache helicopters in your territory. He is your priceless source of information, don’t let him escape.

13 August 2007

Priceless Devotion!

Filed under: Personal — Tanveer Badar @ 9:42 AM

I Still Love Pakistan do you

Who wouldn’t?

Older Posts »

Create a free website or blog at WordPress.com.