Ofcourse it's illegal if the other party doesn't know about it. But then again what they won't know won't matter to them. So as long as you keep it a secret and don't rape their cpu too hard (so they won't be able to use the pc properly) then sure go ahead if you can do it in secret.
I wouldn't say "illegal." Unethical? Sure. But you could easily just add a ToS (which nobody seems to read) that notifies them, and then even if it DID go to court, I doubt anything would happen.
That said, @OP: even if you had millions of computers mining for 12 hours a day, you'd make almost nothing. You would literally earn MORE off working for $6 an hour than you would off spending the same amount of time trying to write the code to do the mining.