N.S.A. Breached North Korean Networks Before Sony Attack, Officials Say