The iPhone 3G on iOS 4.0.2 firmware could be jailbroken using the Redsn0w 0.9.5 beta 5 and you could obtain Cydia. Also the iOS 4.0.2 doesn’t update the baseband, so you could also unlock it using the Ultrasn0w 1.1-1. If you want to unlock iPhone 3G on iOS 4.0.2, then here is how to do it.
2. Now just follow the guide posted here to unlock iPhone 3G on iOS 4.0.2.
After doing the steps correctly, your iPhone 3G will be unlocked on iOS 4.0.2 firmware.