I had the exact same problem with my iphone 4s and despite trying all the solutions mentioned here I just couldn't get past the error 4013. As I continued to read more about this, it all seemed to be related to some sort of hardware issue. So here is what I did step by step:
1. Make sure you have the latest version of iTunes installed.
2. Run iTunes as administrator.
3. Try DFU mode
4. Try new cable
5. Try a different USB port(s)
6. Try a different computer
If still nothing works, the only part of hardware left which may be faulty is the docking port-it might just be some carbon or dust build up in the port. To clean this, the easiest solution would be to:
- insert the edge of a credit card and gently wiggle around in the dock (don't be too forceful, all you are trying to do is dislodge some of the dirt). After that just try to restore it again using iTunes.
This last step was what worked for me, so just sharing it for others out there to try and see if it works for you. Hope it helps!