Hamas is open to an agreement to end the war in Gaza that would see all captives released and secure a five-year truce, an official said Saturday ahead of talks with mediators.