One of the most difficult forms of terrorism to deal are those that come from within. In Iraq and Afghanistan there are many instances of government officials backing away from going after terrorists because members of their own extended family have either joined the terrorists, or agreed to deliver threatening messages for the bad guys. In both countries, the role of family, clan and tribal politics plays a much larger role in national affairs than it does in Western democracies. There is also a different attitude towards what's a crime. If you can steal something from another tribe, to benefit your own family, well, that's not exactly stealing. The only obstacle to that, aside from pulling off the theft, is the potential for retaliation. Family, and tribal, feuds, are an ancient tradition. But that does not stop the attacks.
In Iraq, it's been difficult for the majority of Sunni Arabs to get behind the new government, because most of those families have members who still support the idea of having a Sunni Arab dictator, or religious leader, run the country. Thus in every family, there's a cousin, brother or son who does not agree with this democracy stuff, and is willing to kill to stop it. A typical scenario would have a cousin come to the head of a powerful Sunni Arab family, one that is getting ready to back the government, and tell the patriarch that he has been told that he knows of people who will kill any family chief who comes out for the government. The implication is that this cousin, or another one, might be the assassin, or the one who would provide useful information for the hit squad.
In Afghanistan, the same scenario plays out, except this time it's Pushtun families what believe the Taliban (an organization dominated by Pushtuns) should run the country as a religious dictatorship. The threats are made, and sometimes they work. Often they lead to a family feud, or another blood feud between families or tribes.
The most direct solution to these terror campaigns is to obtain the identities of the key terrorists, and go kill or capture them, or at least warn friendly tribal chiefs who, inside the family, is out to get them. This is what the U.S. Army Special Forces and other commandoes spend a lot of time doing. They get a major assist from new investigative and data analysis techniques used by military intelligence. The use of computers and more sensors (there are eavesdropping devices and vidcams in abundance for this) has enabled the intel people to zero in on terrorist suspects much more quickly. The use of raids to make arrests is more effective because better communications gear, computers in combat vehicles, and things like GPS, enable the raiders to be briefed and on their way a lot more quickly. The troops use new techniques, like risk analysis and statistical routines (which are presented in a straightforward fashion in software, or just checklists), to better predict how successful missions will be. But as successful as the detective work and raids are, it's still unclear how long it will take, if error, to get this assassination element out of politics in both countries.