This step by step guide and tutorial will show you how to unlock your iPhone 3G iOS 4.0.2 using UltraSn0w 1.1-1. At the time I am writing this, it will only work with the iPhone 3G since there is no jailbreak for other devices.
Step 1: Jailbreak your iPhone 3G using RedSn0w.
Step 2: Go to Cydia and search for UltraSn0w. If it’s not there, you might have to add the following repo: repo666.ultrasn0w.com
Step 3: Install UltraSn0w.
Step 4: Reboot your iPhone.
You’re done. You should now be able to use your iPhone 3G with any carrier.