Top defence expert says the US should avoid ‘ridiculous’ prosecutions and use hackers’ skills to detect and track enemies