Something like, someone is trying hard to justify something evil.
One idiom is about a silver lining in a cloud. Such as:
"Every Cloud has a Silver Lining."
"I'm just looking for the Silver Lining."
Based on OPs comment: "Can I use this in a criticizing way?"
You can use it for criticism, but it has a different form, which varies based upon emotional state. Such as:
Polite: "You are looking for a silver lining where there isn't one?"
Angry: "You're wasting your/everyone's time searching for an imaginary silver lining. (sigh)"
Vulgar: "You're searching for a silver lining inside a turd!"
I think “grasping at straws” could work well here, it means
trying to find some way to succeed when nothing you choose is likely to work
trying to find a reason to feel hopeful in a bad situation:
While neither of these quite captures “desperately” from you question, it depends on where you get the explanation from as dictionary.com does actually use desperate in theirs:
Make a desperate attempt at saving oneself