THIS SHOULD NO LONGER BE USED.
PLEASE SEE THIS THREAD FOR RECOVERING YOUR IMEI - http://forum.xda-developers.com/show....php?t=1802024
I tried flashing AOKP on my S3 yesterday and had my IMEI value set to zero, a rare(ish) error that some users have been running into with AOKP and the unofficial Cyanogen builds for this phone. If your IMEI is lost and you don't have a backup, your phone is basically toasted. So, I had to get my phone replaced which wasn't much trouble.
After speaking with invisiblek we determined a way to back up the EFS partition (which is where the IMEI and MEID is stored).
You need to do this on a rooted phone, it's been tested only with root66. You need USB debugging on and adb on your computer.
adb shell su dd if=/dev/block/mmcblk0p11 of=/sdcard/efs.sbn (exit adb) adb pull /sdcard/efs.sbn
adb push efs.sbn /sdcard/efs.sbn adb shell su dd if=/sdcard/efs.sbn of=/dev/block/mmcblk0p11 reboot
My experience: When installing AOKP, my IMEI was replaced with most of my MEID, even after reverting my rom to root66. (This causes mobile data not to work). After restoring my backup and provisioning, I regained full functionality of my data and phone. I haven't had a chance to try this with a phone where the IMEI is set to 0, but I think it's safe to assume this would fix that as well.
I would HIGHLY recommend making a backup before doing anything to your phone. Making a backup is read-only is poses no chance of something going wrong.
EDIT: For clarification: If your IMEI is already messed up, this will NOT get it back. You need a backup from BEFORE it was corrupted.