TLDR: Probably neither, but they certainly don't strongly oppose it.
It would be very difficult to determine if Hamas terrorists participating in the 2023-10-7 raid were given specific instructions to engage in sexual assault, mutilation and similar, especially since these could have been "wink wink, nudge nudge" instructions, but doing so would not be necessary.
It's a well known and eminently foreseeable part of human nature that combatants get angry and emotional and want to take revenge against individual members of the enemy society (military or civilian) of the enemy for deaths and suffering they've seen inflicted by the enemy. This is not anything to do with ideology or beliefs; all humans get angry especially when they see perceived injustices against their compatriots. This is why professional militaries concerned about human rights not only have strict rules against such behaviour, but make at least some effort to discover such behaviour and punish it.
We've seen this time and time again in situations where soldiers had much less investment in the conflict and its result, such as American soldiers in Vietnam or many different western soldiers in Afghanistan. One would expect this frustration to arise to an even greater degree in combatant groups such as Hamas, where they feel themselves (with significant justification) to be harshly oppressed by Israel and Israelis.
Thus, if Hamas leadership didn't give express orders not to commit such atrocities, and implement some sort of discipline to enforce this, that's clearly negligent, and nearly as bad as giving orders to engage in such behaviour.
I have seen no evidence that Hamas condemned any of their combatants who engaged in such activities.
That said, this does not necessarily make such actions part of Hamas' ideology, except perhaps to the degree that they don't care much about violations of the human rights of Israeli civilians (or soldiers, for that matter),