Unlock your iPhone 4 and 3GS running iOS 4.0.2 using ultrasn0w
The guide below will take you step by step through the unlocking process. Using Ultrasn0w, you will be able to use your iPhone with any carrier. Unlocking is technically reversible so you don’t have to worry about voiding your warranty too much. If your phones start acting weird you can restore it through iTunes and send it to be repaired, but only if you actually can restore it, that is, if it works to the point that it can be restored. Legally, you can unlock your phone, it is not protected under the DMCA agreement but it can void your warranty if the seller finds out. Also important to note is the fact that some carriers have no problem with unlocking, to be sure just call them and ask. Some even unlock the phones themselves for a fee.
Step 1: Sync and backup your iPhone with iTunes to make sure you’ll save all your important data (photos, music, documents, settings and contacts)
Step 2: Use RedSn0w v0.9.5b5-5 to Jailbreak your device.
Step 3: Go ahead and launch Cydia
Step 4: If somehow Ultrasn0w is not included with Cydia you need to add it manually. Just open up the Manage screen by tapping the the icon located at the bottom of the screen.
Step 5: Then you will have to go to Sources, Edit and Add. After this you must write down the following URL: http://repo666.ultrasn0w.com and tap Add Source
Step 6: Cydia will refresh automatically and update itself with the new sources.
Step 7: After it’s done, do a search for Ultrasn0w and install it .
Step 8: Reboot your phone and there you have it, a freshly unlocked iPhone.