Israeli soldiers attend the Jan. 9, 2017, funeral in Tel Aviv of a comrade killed the day before in a truck attack in Jerusalem. EPA/ABIR SULTAN

The Israeli military said Wednesday that its archenemy Hamas, the militant Palestinian Islamist group that runs the Gaza Strip, used a series of fake Facebook accounts to connect with young recruits in an attempt to gain access to sensitive army information.

A senior intelligence officer, who could not be identified under Israeli army rules, told journalists that over the past few months, dozens of soldiers, mostly from combat units, were enticed into chatting with people they believed were young, attractive women in Israel and abroad.

Using Facebook as the main medium to engage the soldiers in intimate conversations, those running the fake accounts encouraged the soldiers to download a “chat” application to their cellphones.

The app, for both Android and iPhone, was used by Hamas to access vital data on the phones — contacts, personal text messages and photographs. The app also allowed Hamas operatives to listen to conversations and take covert photos, the officer said.

The officer said the army discovered the hack after several soldiers reported strangers attempting to befriend them on Facebook and lure them into intimate conversations. In one case, said the officer, a young Israeli woman discovered that her photo had been used in one of the fake Facebook accounts.

In a video released by the Israel Defense Forces, a soldier with his face blacked out said he had received a Facebook message from someone he believed was a young Israeli woman.

“She sent me a message on Facebook. We spoke a lot over a few days. She said she was a prison guard, and I told her I was in the army,” he said. “Then she asked me to download this chat app so that we could talk more. I downloaded it, but it did not work. I tried to reach her again on Facebook, but she didn’t answer.”

The soldier then described how the app was actually a gateway for Hamas into his life, collecting information about him and his activities in the army even when the phone was switched off.

Saying the information was “sensitive,” the army would not reveal any more key details of the hack, including how investigators ascertained that Hamas was behind it, or whether it emanated from Hamas operatives in Gaza or elsewhere. The intelligence officer also could not explain how those behind the scheme managed to carry out such intimate conversations, in colloquial, slang-filled Hebrew, without making grammatical mistakes.

“There is a lot of information that we cannot reveal because it is sensitive,” said the officer. “But we know it came from Hamas.”

He said the army managed to close down the fake accounts and contain the threat.

“So far, the damage is minimal, but we believe this could lead to great danger and compromise the army,” he said. “We decided the best way to deal with the threat is to raise awareness to the problem.”

The officer said the army is reevaluating social media guidelines for service members. He acknowledged, however, that because military service is mandatory for most Israelis at age 18, it is impossible to restrict social media use.

Israel has fought three wars with Hamas over the last eight years, the most recent in the summer of 2014. Hamas, which is considered a terrorist organization by both Israel and the United States, still holds the bodies of two Israeli soldiers killed during that war. Israel has the remains of 19 Hamas fighters.

Periodically, rockets are fired from Gaza into communities in southern Israel, and Israel responds with airstrikes. Skirmishes regularly break out along the border between Israel and the coastal enclave.

Hamas representatives in Gaza declined to respond to the Israeli army claims.