Sounds like hardware and not software, you're right.
Are the usb ports on the mobo (in the back) or satellites (in the front)?
Or is it a laptop, in which case depending on the model it's up for grabs?
In any case, what I would do in your situation is get alcohol. No, not for that silly
I'd use isopropyl (rubbing alcohol) and GENTLY rub the inside of the usb ports with a q-tip moist, not saturated, in the isopropyl. Be sure to use an *in and out* motion, not side to side. There's gold pins inside there, and they may be dirty, or there may be something jammed all up and in there.
If that fails, well, I'd say it's the wires / connection to the mobo. If satellites, perhaps the solder/ glue holding the wires has cracked, same with solder attatching the port(s) to the mobo.
Oya, mobo = mainboard, just in case.
Cheers! Hope all goes well.