iOS 7


Plug it into iTunes and do a software restore, and as stated above it will only go to 6.1.3.
 

Yes, sorry, 6.1.3 for the 3GS, my bad. iTunes shouldn't try and upgrade any higher anyway. Either do a restore from iTunes or put it in DFU mode and restore.

M.