TEL AVIV — It usually started with a bit of cyberflirting. A direct message was sent through Facebook or another social network from an unknown woman to an Israeli soldier’s smartphone. Then, according to Israeli military officials, it developed into a chat in flawless Hebrew, heavily peppered with millennial slang.

“Good morning (smiley emoji),” one typical chat began.

“What’s up? Do we know each other?” the soldier replied.

Alluring photos soon followed. Only the correspondents were apparently not who they said they were.

Instead, senior Israeli intelligence officials said on Wednesday, they were Hamas operatives who set up fake profiles and trawled social networks, befriending naïve soldiers and enticing them to download applications that effectively turned their cellphones into tracking devices and tools for spying.

The assertions of the officials, who spoke on the condition of anonymity under Army rules, could not be independently verified. Hazem Kassem,a spokesman for Hamas, the Islamic militant group that holds sway in the Gaza Strip, declined to comment. “We do not want to respond to what some Israelis say about us,” he said.