Very tricky. I have a lot more respect for the Keychain in Mac OS X after working on this. It is not simple at all. After poking around I cobbled together an Automator application (using AppleScript) that goes through the Keychain and exports the passwords to a file named keychain_passwords.txt on your Desktop. The bulk of the programming kudos goes to baltwo in the Apple Discussion Boards.
Ensure that Keychain Scripting.app is in /System/Library/ScriptingAdditions/ and that the
login.keychain is in /Users/username/Library/Keychains/.
Note that a big downside to this is that you have to click ‘Allow’ for each password access and (maybe intentionally) the popup window that asks for the permission is in a slightly different spot on the screen each time so you can’t just click madly- you have to aim and click almost every time. But this was the only thing I could find.