check this out it may help

Sn0wbreeze 3.1.3 is now available for download which can jailbreak iPhone 2G, 3G and iPhone 3GS (old bootrom only) on iPhone OS 3.1.3. We have already published a detailed guide on how to jailbreak using Sn0wbreeze and unlock using ultrasn0w. Ultrasn0w unlock is for iPhones with baseband 04.26.08 baseband. If you are on 05.11.07 baseband, then you may use Geohot’s blacksn0w unlock which was released last year with blackra1n.

Follow the simple step by step guide below to unlock your iPhone 3G and iPhone 3GS (old bootrom only) on iPhone OS 3.1.3 using blacksn0w. iPhone 2G users should follow the guide posted here (Mac version of the guide here).

How to: Jailbreak iPhone on 3.1.3:
Step 1: Follow the guide posted here to jailbreak your iPhone 3G or 3GS using Sn0wbreeze 3.1.3 on iPhone firmware 3.1.3.