You could try booting into “single user mode” or “recovery mode” in order to fix your problem. As I'm not Using vanilla Ubuntu installations that often, I'm not sure how the latest version of the recovery mode looks like, whether its shell option will ask you for a password, and if it does, whether that passwort check uses pam. So you'll have to give it a try.
If that doesn't work, as a last resort you could append
init=/bin/bash to your boot command line in grub. That will dump you into a shell very early during boot, so many services will not be available, but it won't display a login prompt either, so it should enable you to fix your pam setup unless that is on a partition which isn't mounted by that time. You'll probably have to remount your root fs writable before doing any changes:
mount / -o remount,rw.