If you found their private key by mathematical computation or guessing, I think it will not be considered illegal. But if you got that by using malware or trojan that may be illegal.
If you hacked Nobody can expect you can claim that wallet is yours.