A former British soldier accused of passing secret information to Iran covertly gathered the names of service personnel, including those in special forces, a court has heard.

Daniel Khalife, 23, took a photo of a handwritten list of 15 soldiers, including some serving in the Special Air Service (SAS) and Special Boat Service (SBS), Woolwich Crown Court was told.

He took details from an internal spreadsheet of promotions in June 2021, sent to a WhatsApp group called Brew Room Boys, and then logged on to an internal HR system for booking leave to try to find out the soldiers’ first names, jurors heard.

Continuing the prosecution opening on Wednesday, Mark Heywood KC said: “The details on the spreadsheet included the promotion details for all sorts of units in the Army, including special forces who operated, as you might imagine, on a different basis to other parts of the armed services and ordinarily do not publish their membership or ranks or identity for very good, security-related reasons.”

Mr Heywood said Khalife went on to the HR system “as if to book leave” and then used the “approver box” to search for individuals, taking screenshots of seven of the names on the original list of 15.

None of the people had any involvement with him booking time off, the court heard.

Mr Heywood added: “He was clearly researching and gathering and recording that information.”

Jurors were shown a photograph from Khalife’s iPhone of a handwritten list of 15 soldiers that he had made, including their service number, rank, initials, surname and unit, including the SAS and SBS.

Prosecutors claim Khalife was paid in cash by the Iranian intelligence service for secret information gathered during his time in the Army.

After he was arrested over the allegations, Khalife is accused of escaping from Wandsworth Prison by strapping himself to the underside of a food delivery truck on September 6 2023.

Khalife who was brought up in Kingston, south-west London, by his Iranian mother, and joined the Army in September 2018, two weeks before his 17th birthday.

Prosecutors claim he first made contact with Iran in April 2019.

By August 2020, six months after he was posted to the 16th Signal Regiment in Stafford, messages showed he was willing to gather information “to order, for as long as they wanted”, the court heard.

On August 28 2020, Khalife spent an hour messaging a contact saved as “David Smith”, describing an internal military system which would identify service personnel.

He told the contact: “I won’t leave the military until you tell me to”, before adding: “25+ years.”

Khalife went on: “I need to go to your supervisor and ask what specific regiment or sector you’re interested in.”

Daniel Khalife’s trial is taking place at Woolwich Crown Court (Nick Ansell/PA)

It is alleged he stayed in contact with Iranian handlers while posted to Fort Hood in Texas in the US between February and April 2021, where he took a series of screenshots of systems marked “Secret”, including a password record sheet.

In April that year Khalife was granted the second highest level of Nato security, one below “cosmic top secret”.

As well as the alleged prison escape, he denies a charge of gathering, publishing or communicating information that might be useful to an enemy, namely Iranian intelligence, contrary to the Official Secrets Act between May 1 2019 and January 6 2022.

He also denies having elicited or attempted to elicit personal information about armed forces personnel that was likely to be useful to a person committing or preparing an act of terrorism from a Ministry of Defence administration system on August 2 2021.