Is the iPhone currently in recovery mode, or is it still in normal mode? If the phone is in recovery mode, you could try using software such as 3utools to try to force the phone out of recovery mode.
Sounds like a possible RAM problem or a dying HDD. Did the iMac say the HDD was successfully repaired? First point of call should definitely be trying some different RAM.