A Frenchman and a Moroccan received heavy prison terms on appeal Friday for an attack plot that was foiled after an intelligence agent posing as a jihadi infiltrated their cyber network.

Yassine Bousseria, 42, was sentenced to 24 years in prison for participation in a terrorist conspiracy to prepare terrorist acts, the same term he had been handed by a lower court in February.

The other man, Hicham El-Hanafi, 31, was sentenced to 30 years in prison, also in line with the lower court ruling.

A third person convicted in the case, Frenchman Hicham Makran, was sentenced to 22 years in jail in February and did not appeal.

The three were tried on charges of joining a terror group with a view to carrying out attacks.

An agent from France’s DGSI domestic intelligence service, using the codename Ulysse, had infiltrated communication networks of Islamic State (IS) group in a ruse that led to the arrest of the three.

The case began in 2016. After intelligence indicating the IS group was seeking to obtain weapons for a “violent action” on French soil, the DGSI agent penetrated an encrypted Telegram messaging loop and make contact with an IS “emir” in Syria, nicknamed Sayyaf.

Sayyaf said the jihadis needed munitions including four Kalashnikovs, which Ulysse said he could supply.

In June 2016, Sayyaf sent Ulysse $16,000 in cash.

With this money, Ulysse then told Sayyaf that he had bought weapons and hid them in a forest north of Paris. The surroundings were then equipped with surveillance cameras.

French intelligence then received information that the two French citizens, who had been around the Turkish-Syrian border, had come home.

They were arrested and found to have a USB key encrypted with the coordinates of the arms cache.