If you jailbroke your iPhone using PwnageTool or if you uninstalled the BlackRa1n app from your iPhone but still want to unlock your iPhone 3.1.2 with baseband 05.11.07, then read on.
You can download BlackSn0w from Cydia and unlock your iPhone this way.
Simply add the following repo in Cydia: blackra1n.com.
Then in Cydia, look for BlackSn0w. Install the application and reboot your iPhone.
Congrats, your iPhone is now unlocked!