Former CIA director John Brennan testifies before the House Intelligence Committee in May. (Melina Mara/The Washington Post)

An aspiring hacker who harassed the CIA director and the national intelligence director, among others, in 2015 was sentenced Friday to five years in federal prison.

Justin Liverman, 23, was part of a collective dubbed "Crackas With Attitude" that exposed the private online accounts of several top law enforcement officials, including then-CIA chief John Brennan and James R. Clapper Jr., the director of national intelligence at the time.

It was a British teenager, known as "Cracka," who actually broke into those accounts by impersonating the officials or employees of their service providers. Liverman and Andrew Otto Boggs, also 23, encouraged Cracka's exploits and used the exposed information to bedevil the victims.

"These are no pranks," Judge Gerald Bruce Lee said in sentencing Liverman on Friday in federal court in Alexandria, Va. "This computer hacking, Crackas With Attitude, caused chaos. Your intent was clear, and that was to wreak havoc."

It was particularly "despicable," Lee added, that Liverman harassed the spouses and threatened the children of several targets.

Liverman, of North Carolina, chose some of the victims and drove the harassment campaigns against them. He paid for an hourly, month-long "phonebombing" campaign leaving threatening and explicit messages for former FBI deputy director Mark Giuliano. Liverman also texted Giuliano's phone, asking about his "slut wife" and warning that he would "keep a close eye on your family, especially your son!"

Giuliano and other victims are not named in court papers, but their identities have been confirmed by officials familiar with the details of the case.

Through Giuliano's credentials, Cracka got into the Law Enforcement Enterprise Portal, a computer system that gives agencies around the world access to unclassified but sensitive law enforcement information. Liverman requested personal details on Miami police officers, which he then posted online.

According to Liverman's attorneys, Boggs was directly involved in breaking into the law enforcement databases and exposing the personal information of 20,000 people.

Liverman also encouraged Cracka to call in a bomb threat to the Palm Beach County, Fla., sheriff's office, saying, "Hopefully they will have a shootout and kill each other," according to court records.

Other victims include Amy Hess, at the time the FBI executive assistant director for science and technology; Gregory Mecher, who is married to then-White House Communications Director Jen Psaki; and Harold Rosenbaum, chief executive of CIA contractor Centra Technology.

In January 2016, Liverman claimed to have compromised NASA computer systems and gotten access to sensitive flight and employee details. The space agency spent $41,300 to figure out that all of the data exposed on Liverman's Twitter account was fake or already publicly available.

Liverman said he thought at the time he was helping expose weaknesses in the private security of figures who guard the nation's secrets, according to the court filings, as well as taking a stand against government overreach.

"I thought what I was doing was right in terms of political justice," he said in court Friday. "But two years later, I realize I was completely wrong."

Boggs and Liverman pleaded guilty earlier this year. Boggs was sentenced to two years in prison in June. Cracka is being prosecuted in Britain.

Attorneys for Liverman argued that their client showed a conscience by redacting some personal information before sending stolen emails to WikiLeaks.

He was taking too much of the steroid prednisone, attorney Jay Leiderman said in court, and lacked social skills or many real-life friends.

Referencing the HBO show "Westworld," Leiderman suggested Liverman was on a journey to maturity. "He is traveling that maze," Leiderman said. "He's coming towards the center of the maze. He's coming towards self-actualization."

A computer science student, he said he hopes after his release to become a security auditor who will protect against "black hats like myself."

Ellen Nakashima contributed to this report.