BEIJING — For almost two years, hackers based in Shanghai went after one foreign defense contractor after another, at least 20 in all. Their target, according to an American cybersecurity company that monitored the attacks, was the technology behind the United States’ clear lead in military drones.

“I believe this is the largest campaign we’ve seen that has been focused on drone technology,” said Darien Kindlund, manager of threat intelligence at the company, FireEye, based in California. “It seems to align pretty well with the focus of the Chinese government to build up their own drone technology capabilities.”

The hacking operation, conducted by a group called “Comment Crew,” was one of the most recent signs of the ambitions of China’s drone development program. The government and military are striving to put China at the forefront of drone manufacturing, for their own use and for export, and have made an all-out push to gather domestic and international technology to support the program.

Foreign Ministry officials have said China does not sanction hacking, and is itself a victim, but another American cybersecurity company has tracked members of Comment Crew to a building of the People’s Liberation Army outside Shanghai.