BEIJING—A four-month-long cyberattack on the New York Times originating from China — detailed by the newspaper Thursday — may be part of a shift by Chinese hackers to apply the same sophisticated infiltration techniques on foreign media that they have used in recent years to steal proprietary data from U.S.