A former US Army soldier pleaded guilty to hacking telecommunications companies and attempting extortion, potentially facing a 20-year prison sentence.