How to Jailbreak iPhone 3G iOS 4.0.2
Step 1: Make sure you have the latest version of iTunes installed.
Step 2: Download iOS 4 (not iOS 4.0.2) for iPhone 3G to your desktop from our iPhone downloads section.
Step 3: Update your iPhone to iOS 4.0.2 via iTunes.
Step 4: Download the latest version of RedSn0w from here.
Step 5: Point RedSn0w to the iOS 4 (not 4.0.2) you downloaded in step 2.
Step 6: Select “Install Cydia”.
Step 7: Follow the onscreen instructions.
Step 8: Let RedSn0w do the hard work for you. Once jailbroken, your iPhone will reboot.
How to Unlock iPhone 3G iOS 4.0.2
Since iOS 4.0.2 didn’t update the iPhone baseband, you can still use UltraSn0w to unlock your iPhone.
Step 1: Jailbreak your iPhone using the method described above.
Step 2: Go to Cydia and search for Ultrasnow. 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.