Fundamentalism and extremism thrive wherever there is injustice and tyranny, and the United States should bear that in mind when it wonders why it is unpopular and threatened. If the Americans support unpopular regime, it creates a breeding ground for terrorism.
I remember that during the days of General Zia, US ambassador Dean Hinton said in an address to students that America supports three Ds: Development, Democracy and Dialogue. I think that now a large number of Ds are associated with the Americans, not including democracy. The Ds are Dictatorship, Dictation, Double standards, Discrimination, Distrust, Destruction and Death (of innocent civilians in Iraq, Palestine, Afghanistan and Pakistan).
Instead of spending billions of dollars on security, a change of foreign policy is all that America requires to stay safe and win back respect.