You can try to use "tinyUmbrella" to see if cydia has you ssh on file..tinyumbrella website
once you start the software you click the button save my ssh..
once it's done processing you can click on start tss server
This tss server will allow you to bypass itunes server which restricts downgrading firmware...
Once Tss server is running you can start itunes
once itunes detects your iphone shift + click on restore
Select the iphone 3g 4.0.1 firmware (goto http://www.felixbruns.de/iPod/firmware/
to download this)
Once it restores fully at the end it will give itunes error '1015'
Install Libusb if you dont have it..(Click here)
after installing libusb just use this program.. ih8snow
Click on "Fix recovery mode loop"
Click on yes to "do you have libusb installed??"
Select iphone 3g from the list
your iphone will reboot..
now you can first activate it ..
then you can use safari to goto Jailbreakme.com
slide the slider at the bottom...
it will download cydia
when cydia is installed you have to add "repo666.ultrasn0w.com" as a source
Its a zero "0" in the sn0w not "o"...
Search google how to add new sources.. to cydia..
Once you are done installing the application inside the repo666.ultrasn0w.com source your phone will be finally unlocked..
Of course easier way out would be to pay someone who knows how to do this..