I often hear of black-hat hacking discussed as if it was synonymous with illegal hacking. In other words, an act of hacking is black-hat iff it is illegal. Our own tag wiki for black-hat defines it as "the act of using computer security hacking for illegal means..." using the black hat==illegal definition, but an answer on this site mentions that participating in government-sponsored (and thus presumably not locally criminal) cyber warfare counts as black-hat.
So, strictly speaking, is black-hat work necessarily illegal, or can it describe cybersecurity work that is legal but unethical? Similarly, if certain work is illegal under local law but produces positive social value, is it black-hat because of the legality or might it be considered white-hat due to the outcome?
As an illustration of what I am talking about, let's consider the following two hypothetical scenarios:
- I am living under a despotic, human-rights violating regime that just passed a law authorizing arbitrary warrantless hacking of computers owned by minorities and political dissidents and making resisting such hacks punishable by catapult. I "join the resistance", helping my neighbors to secure their systems and even launch a DDoS against the government's surveillance center. I take care in making sure that my attacks are targeted only at the areas of the government responsible for human rights violations and nowhere else. Am I a white-hat hacker because I am doing a social good or am I black-hat because my actions are illegal and subject me to a judicial sentence of catapult?
- I am living under the despotic regime mentioned above, but I instead join the government's civil service cyber police force ("To Hack Unpersons and Protect our Fearless Leader!") and hack my neighbor Charles, who did nothing wrong but vote for the wrong candidate in the last election. My actions are considered lawful law enforcement work under local law but my family will no longer speak to me and I have been excommunicated from and damned to hell by my religious congregation. Am I a white-hat hacker because my actions are lawful or a black-hat hacker because I am participating in a social ill?
To be clear, I'm not asking this question about any specific situation, but about definitions. Is black-hat work most accurately defined as illegal hacking, unethical hacking, any hacking I don't like, or something else entirely? If there is a disagreement, what are the major positions?
As another hypothetical question to get the juices flowing, when all computers are banned, are all hackers black-hat?