A prison librarian used sophisticated software to mask his identity as he searched the “dark web” for a handgun and bullets, the Old Bailey heard.

Dwain Osborne, 26, ordered a Glock 19mm pistol and 100 rounds of ammunition to be delivered to his home in Penge, which he was using as a base for a drug-dealing operation.

He had downloaded the Tor internet browser that enabled him to search anonymously on the dark web on sites including Black Market Reloaded, where weapons and drugs are sold. 

However, the dealer who offered to sell him the gun and ammunition was a US agent and his home was raided by National Crime Agency officers in October last year. 

Osborne, who earned £22,000 a year as a librarian at HMP Brixton, was released on bail and in a second raid on his home in February this year, 10 wraps of cocaine weighing 3.75g, a further 13.8g of cocaine, scales and £735 in cash were found.

Prosecutor Tom Forster said Osborne claimed the drugs were for personal use, but his browsing history revealed searches including “how to buy a kilo of cocaine in Peru”. 

“His iPhone and linked laptop both had uploaded a software programme called Tor browser, which allows someone using it to browse the internet anonymously, so they can use the dark web and protect their identity while doing so,” said Mr Forster. “All tending to suggest a committed interest in cocaine and large amounts of it.”

He said officers had found a memory card with “details of over 1,000 prisoners in the prison system”, although a charge of illegally accessing computer files was dropped. 

Osborne claimed the extent of his supply of class A drugs was buying them for a friend. However, Judge Gerald Gordon said on Friday: “I’m satisfied the defendant did benefit commercially, at the very least to the extent necessary to fund his own habit. It’s likely it was more than that.”

Osborne admitted attempted possession of a firearm with intent to endanger life, attempted possession of ammunition with intent to endanger life, attempted purchase of a firearm, attempted purchase of ammunition, possession of false identity documents, possession of class B drugs and possession of class A drugs with intent to supply.

He faces a lengthy prison term and was remanded in custody until he is sentenced on June 17.