A British man who gained notoriety in cybersecurity circles for helping to stop the WannaCry ransomware attack in 2017 has agreed to plead guilty in Wisconsin to unrelated hacking charges, according to papers filed in federal court on Friday.

The man, Marcus Hutchins, who was detained by U.S. authorities two years ago, has signed an agreement with prosecutors to plead guilty to two of the 10 charges that a grand jury indicted him on, according to a copy of the agreement filed in U.S. District Court in Milwaukee.

The two charges describe a conspiracy to advertise, distribute and profit from malware known as UPAS Kit and Kronos, as well as an effort to disseminate a device used primarily to surreptitiously intercept electronic communications.

“I regret these actions and accept full responsibility for my mistakes,” Hutchins said in a statement on his website. “Having grown up, I’ve since been using the same skills that I misused several years ago for constructive purposes. I will continue to devote my time to keeping people safe from malware attacks.”

A spokesman for the U.S. Attorney's Office for the Eastern District of Wisconsin declined to comment.

Hutchins, who went by “MalwareTech” online, faces up to five years in prison for each of the two counts if the plea deal is accepted by the court, though many criminal defendants receive much less than the maximum sentence allowed by law. Prosecutors have agreed to give Hutchins credit for accepting responsibility, the plea agreement says.

The plea agreement also allows for a court to require Hutchins to pay restitution.

Hutchins was detained by the FBI in August 2017 in Las Vegas, where he was among tens of thousands of hackers who had descended on the city during the annual cybersecurity conventions known as Black Hat and Def Con, Reuters reported at the time.

He sought financial donations for his legal defense, especially after prosecutors in June 2018 added additional charges to the original indictment, Ars Technica reported.

The global WannaCry ransomware attack in May 2017 struck computers in more than 150 countries, hitting institutions including Britain’s National Health Service and Germany’s railways. Last year, the U.S. Justice Department charged a North Korean spy with helping to carry out the attack and others.

Hutchins was hailed in the media and in cybersecurity circles for helping to end the attack by discovering a so-called killswitch that slowed the outbreak of the malicious code.