One of two teenagers accused of planning a terrorist attack was only 12 when he went to a Sydney protest holding a sign saying 'Behead all those who insult the prophet', a jury has been told.

At 14, he refused to stand when the Australian national anthem was played at his school, saying: 'I will only stand for Allah', prosecutor Ian Bourke SC said on Tuesday.

He was opening the Crown case at the NSW Supreme Court trial of the two teenagers - who can't be named - who have pleaded not guilty to doing an act or acts between October 6 and October 12 in 2016 in Sydney in preparation for a terrorist act.

The schoolfriends were both aged 16 when arrested at a Bankstown Muslim prayer hall on October 12, allegedly in joint possession of two M9 bayonets and a sharpener bought for $230 cash at a nearby gun shop.

A letter pledging allegiance to ISIS was allegedly found with the boys (pictured with police)

They also had clothing capable of being used as disguises, as well as a handwritten note in Arabic and English which Mr Bourke said amounted to a pledge of allegiance to ISIS or Islamic State.

Part of it read: 'I advise you to fear God and follow the steps of the Messenger of God and pledge allegiance to the caliphate because whoever dies without pledging allegiance will die a pre-Islamic death.'

The teenagers, who both allegedly had strong, fundamentalist, extremist views, intended to use the bayonets to kill or injure a member of the public, Mr Bourke contended.

'The Crown cannot say precisely when the act was to be carried out or who the particular target was,' he said.

As well as the bayonets, the teenagers allegedly purchased two hunting knives on October 6, with one telling the gun shop assistant they were going pig hunting.

This was of 'some significance' because when the older boy was arrested he spoke to some police saying 'pigs, cowards' and 'they were going to burn in hellfire', Mr Bourke said.

The boys were arrested (pictured) after they allegedly purchased bayonets from a Sydney gun store

'The Crown and police cannot say what happened to those knives as they were not located.'

He listed a string of items accessed by the teenagers on their phones or computers before their arrest.

The eldest boy, by months, had material including an image saying: 'I am a warrior of Islam and my path is Jihad' and a comment about a man of Islamic faith described as an unbeliever because he had become a police officer.

He also allegedly accessed advice on the sort of weapon to use when carrying out a terrorist act.

The teenagers accused of planning a terrorist attack were allegedly in joint possession of two M9 bayonets (pictured, stock)

At the age of 12, he was filmed in Sydney's Hyde Park at a protest against a satirical movie about the prophet Muhammad, Mr Bourke said.

His co-accused also allegedly had similar material on his devices and in 2015 went on a holiday to Egypt with his family, during which he left his parents and visited a place close to an area associated with terrorists.

He also accessed a story on his phone called: 'Jihad John's journey from schoolboy to executioner'.

The trial continues.