CONCORD — A Hooksett man has admitted to hacking the computers of the Farnum Center, the Auburn Police Department and several department employees following his arrest on heroin possession charges, federal prosecutors announced.

The hacking involved rerouting a drug-help telephone number to an adult entertainment business and pop-up messages praying for the death of his arresting officer, federal prosecutors said.

Wayne Kenney Jr., 31, pleaded guilty in U.S. District Court on Wednesday to unauthorized computer access and damage of protected computers.

The hacking took place five years ago:

Kenney installed malicious software on Auburn police computers that prompted pop-up messages that read “I pray for the death of” the arresting officer.

People logging into the Farnum Center found a link to a video that depicted safer heroin injection.

The Farnum Center’s 1-800 number was directed to an adult entertainment company.

Kenney impaired the integrity of Auburn police and town government data and deleted some files.

Police Department employees lost control of email and social media accounts, which were defaced with embarrassing material such as pornography.

The attacks on the Auburn Police Department took place from February to July 2015, prosecutors said in a release. The attack against the Farnum system took place July 1, 2015.

Kenney’s lawyer said he was going through personal problems when the crimes occurred.

“He is remorseful and a different person than he was at the time,” said Concord lawyer Amy Spencer

Prosecutors say the hacking took place after Auburn police arrested Kenney in early 2015 for heroin possession. He received a suspended sentence and was ordered into drug treatment at Farnum Center.

Kenney used a customized keyboard stroke logger, computer viruses and phishing emails to accomplish the hacks. The attacks were so sensitive that prosecutors identified personal victims as John and Jane Does.

“Certainly, Easterseals learned from that circumstance,” said Nancy Rollins, chief operating officer of Easterseals NH, which runs the Farnum Center drug and alcohol treatment center.

She said such an attack would not be successful nowadays, given upgrades to the organization’s computer network security.

Calls to Auburn Police Chief Raymond Pelton were not immediately returned.

“The defendant’s vindictive scheme damaged the operations of the Town of Auburn and its Police Department and also impeded individuals from accessing emergency substance abuse treatment services,” said U.S. Attorney Scott Murray.

“Computer hacking schemes like this are serious offenses that have real victims and serious consequences.”

Kenney will return to court March 2 for sentencing.

Kenney was initially charged in December 2018. Within six months, he filed for a court-appointed lawyer.

At one point, a judge approved spending for a psychological evaluation.