In Shift, Egypt Warms to Iran and Hamas, Israel’s Foes