While I wouldnt say the ends justify the means to me I would rather look at it as a seperation between the response one should expect (due to human nature) vs the response that is civil and follows the "rules".
The terrorist attack in OCt from Palestine cant morally be justified in isolation, neither can the genocide inflicted on them in the years leading up to this. But while their legitimately terroristic response was morally wrong, it is exactly the response one should expect when you carry out genocide on a population. That doesnt make it excusable, but it makes it understandable.
Much like how if you abuse a person enough and they eventually snap and misbehave. Their misbehavior is still wrong, and its fine to hold them accountable to it. But the abuser should have expected the response and doesnt get to play the victim now either.