Using this reasoning one could argue for the Holocaust, the ends justifies the means argument.
Answer this hypothetical question for me please, if Hamas did get eliminated from Gaza but every man woman and child in Gaza was killed, would you approve of the operation?
This is ever present hypocrisy in the Israel defenders, that the ends justifies the means and if so then if the ends are legitimate the consequences of striving for them, are morally acceptable.
One can adopt that but then so too can Hamas or Al Qaeda, or Russia, the Nazis gave clear reasons for their policies, they perceived an existential threat and that was their justification for the war and the extermination of Jews.
So those who make these kinds of arguments are - morally - not superior to the worst regimes in history so why keep pretending your moral at all?