A few weeks ago, I wrote a step-by-step guide and tutorial that shows you how to jailbreak and unlock your iPhone 2G 3.1 using PwnageTool for Mac OS X. I could very well rewrite this tutorial again and call it “jailbreak and unlock your iPhone 2G 3.1.2 with PwnageTool” but that would be a waste of time as the steps are identical.
I suggest you check out this tutorial and follow the steps over there. The only thing that will change is that instead of using the firmware 3.1, you will have to use firmware 3.1.2 (iPhone1,1_3.1.2_7D11_Restore.ipsw). Everything else is exactly the same.