It goes almost without saying that general hacking and revealing, or discovering private information would be strictly prohibited (Remo CM 154:7, Shulchan Aruch HaRav CM, Hilchos Nizkei Mamon, 11)
In the words of Shu"t Benei Banim (3:17):
“Those who break into computer codes or into any protected data store or similar, who are called “hackers” – their sin is severe.”
Although, for our purposes, we need to find out if this is permissible when it is done לתועלת, for good purposes.
The answer to this may be found in an Ibn Ezra on the Torah
או שנגלה לך סוד שתוכל להצילו מן המות אם תגלהו לו, ואם לא גלית אתה כמו רוצח.
Or, if a secret was revealed to you and you can save someone from
death by revealing it to him – if you do not reveal it, you are like a
Rav Moshe Feinstein ruled (Iggeros Moshe, Y.D. 214) that in such a situation of threat to life privacy may be invaded, and Rav Moshe Shterbach (Teshuvos Ve’hanhagos, 1:869) ruled that this applies even in cases where there is
only a vague threat to general safety.
As an addition, it seems clear to me that when hacking in order to retrieve your own information, that was perhaps stolen, or information about your property which is being hidden unrightfully, you would not constitute any issue, as you are not breaching the others privacy unrightfully.
This point could be made from the following Mishna (Kesubos 75a):
ואם יש מרחץ באותה העיר אף מומין שבסתר אינו יכול לטעון מפני שהוא בודקה
If that city has a bathhouse, then the husband cannot complain about
even secret defects, because he [should have] asked those close to
We see here that the legal rights to protect the members of a purchase or marriage trump the values of