As for Iran and Russia, they both have long histories of using terror and regard the US as their enemy. Only the threat of devastating punishment keeps them from attacking the US.
The rules of war would have identified Khalid Sheikh Mohammad as an enemy soldier out of uniform and he would have been shot at sunrise instead of consuming free meals and free legal advice for the past 23 years.
“Terrorism” is not a legal problem. It is an act of war and should be treated as such.