What drove teen to attack passengers on German train?

Berlin (CNN)What drove a 17-year-old to stab five people on a train?

That’s what authorities in Germany are trying to figure out after an Afghan teen exited the bathroom of a train armed with a knife and ax and began to stab passengers, seriously injuring two.
The Saturday before the teen carried out the attack, he learned that a good friend of his was killed in Afghanistan, authorities said Tuesday.
But inside the Afghan’s room, police said they found a hand-drawn flag resembling the one used by ISIS.
The terror group claimed responsibility for the attack, and released video of a young man speaking in Pashto, waving a knife at a camera calling himself “a soldier of the caliphate.”
German authorities are investigating the ISIS connection, but ISIS didn’t really have a presence in Afghanistan until it first emerged last year in the country’s east, gaining ground often among disaffected Taliban and Afghan youth.
“We have no indications that he was already radicalized before he came to Germany,” Chief Prosecutor Erik Ohlenschlager said at a news conference Tuesday.
Bavarian Interior Minister Joachim Herrmann said at a news conference early Tuesday that the first emergency call police received mentioned an attacker calling out “Allahu Akhbar.”
Whether the attack was ISIS-inspired or organized, it still appears there was political motivation, prosecutor Lothar Kohler said.
He said the assailant posted cryptic messages on the Internet a few hours before the attack, talking about enemies of Islam.
It said, in part: “And now pray for me that I can avenge myself on the unbelievers and pray for me that I will go to heaven.”
Kohler said it was clear the attack was “politically motivated.”
“This is a big mosaic puzzle right now and we will do everything to pull information together in order to assess his motivation,” Herrmann said.

The attack

The attack took place shortly after the train left Wurzburg for Treuchtlingen.
There were about 20 to 30 people on the train, according to Alexander Gross, a police officer in Bavaria.
The train made an emergency stop short of the station at Wurzburg-Heidingsfeld and the assailant jumped out of the train, regional police spokesman Lt. Fabian Hench said.
“They (police) chased him up, confronted him, the attacker then was very aggressive and attacked the police officers with his ax,” Herrmann said. “And the police opened fire. The attacker then was shot dead.”
Video from inside the train showed extensive blood on the floor.

Many ‘in shock’ after incident

Some 14 to 25 people were classified as in shock and treated at the scene after the attack, according to Gross.
Four passengers on the train — members of the same family and tourists from Hong Kong — were injured, and one person is in critical condition, Herrmann said.
Another woman was wounded after the assailant jumped from the train and fled, prosecutors said. She is also in serious condition.

The attacker

The attacker came to Germany as an unaccompanied minor a year ago, Herrmann said, eventually settling in Ochsenfurt, Bavaria. He was taken in by a foster family two weeks ago, he said.
Besides the hand-drawn or painted flag, police found notes in Pashto written in Arabic and Latin characters in the assailants’ room, Herrmann said.
Investigators are examining the assailant’s mobile phone. Prosecutors said he had learned that a friend had been killed in Afghanistan over the weekend.
Germany absorbed more than 1 million refugees last year. Some Germans have been concerned over the presence of terror groups in the country — both the potential for attackers to slip in with migrants and the concern that they may be able to radicalize disaffected youths.
Three Syrian men were arrested last month on suspicions that they were planning to carry out a mass casualty attack in Dusseldorf.