SAM is a free unlock solution that works with iPhone 3Gs, iPhone 4 and also iPhone 4S, regardless of baseband and iOS versions and is compatible with iOS 5.0, 5.0.1 and 5.1. For the iPhone 4S, at the moment, there is no jailbreak solution for iOS 5.1, but when will be one should unlock your iPhone 4S without problems.
This free unlock solution decodes only ONE SIM card, meaning that by following this tutorial you will unlock ONLY the SIM card you have in your iPhone. If you change the card then you have to repeat the unlock process for the new SIM card.
No matter from where you bought the iPhone, the unlock method will work, but only on GSM terminals. Also, you must have a jailbroken iPhone that can be activated in iTunes, otherwise it will not work.
Note: after the free unlock it is important to save it. Saving the unlock ensures that you will be able to recover in the future no matter what version of iOS Apple will release.
[Update] Free unlock using SAM is no longer available
It seems that as MuscleNerd, the famous jailbreak hacker, anticipated the free unlock solution, SAM, no longer works and no iPhone can be unlocked using the tutorial below. Unfortunately there’s no other method to unlock an iPhone with SAM, so we have to wait another solution from Dev Team.
Currently you can buy a Gevey card that unlock any baseband of iOS 5.x or make a permanent unlock.
Step 01: Open Cydia, go to Sources and add the repo repo.bingner.com from which you install Sat Bingner's SAM (Subscriber Artificial Module). SAM developers say that the repo must be used because that is the original version of the tweak.
Step 02: Insert in iPhone the SIM card you want to unlock and open the SAM interface using either the Settings application or the icon that you already have in Springboard.
Step 03: In the SAM menu go to Utilities section where you choose the option De-Activate iPhone. After selecting it you will notice in the More Information section that you have listed Unactivated status.
Step 04: With SAM activated go to the Method section and choose By Country and Carrier and find the carrier that you want to unlock. Some carriers use multiple ID’s for the SIM cards, and it is important to use the SIM ID otherwise iTunes will not activate if the wrong IMSI is selected.
Step 05: Go to More Information section, look in the SAM Details section and write down or copy the IMSI number in a notepad or copy it into an iOS application, then click Spoof Real SIM to SAM.
Step 06: Go to the main menu of SAM, choose the Method section and option Manual and paste or enter the IMSI number copied in the previous step.
Step 07: Now connect the iPhone to the computer and make a regular activation through iTunes. More precisely, disconnect terminal, close iTunes, reboot the terminal, open iTunes and the program should automatically activate your iPhone.
Important in this step is to check if your ICCID recognized by iTunes for your SIM card is correct. To do this you can look in the menu at the top of iTunes and you'll see listed there: terminal name, iOS version, telephone number, etc.. Using the mouse, click the phone number and see the iTunes recorded ICCD number, then check if the same ICCID is registered on your SIM card. If not you need to start over from Step 01.
Step 08: Disconnect the terminal from the computer, close iTunes, go to SAM and disable the tweak.
Step 09: Reconnect the iPhone to your computer, open iTunes and you will receive an error message saying that your phone cannot be activated. The error is perfectly normal considering that you already disabled the SAM.
Step 10: Close iTunes and open it again, everything should be OK and the terminal will have signal. Unfortunately the PUSH notifications will not work, so from the SAM menu so you must choose the option Clear Push and reconnect your terminal to iTunes.
Saving the Unlock
You unlocked the iPhone but unfortunately Apple can block this method. Following these steps you can save the unlock for that SIM card and use it whatever Apple launches a new baseband.
After the unlock process is complete connect your iPhone to computer and open a program with which you can access your system files. You can use iFunbox, iPhone Explorer or any other utility you want.
After connecting to the system files go in /var/root/Library/Lockdown/ from where you will copy all the files and save them on your computer. Those files are extremely important, because they will unlock your SIM card in the future on any version of iOS and any baseband.
That's it, but remember that if you change the SIM card you must repeat the unlock process.