"hacker" is ambiguous in modern usage. It's still used as originally intended in technical communities, but it almost exclusively is used by the media, and probably the general public, to mean some kind of malicious attacker.
"black hat" vs "white hat" are terms from the security industry; in some sense a small subset of "hackers." If you hack security issues in modern operating systems with the intent of getting them fixed and/or getting your name on research papers and/or get a job at an anti-virus company, you're a "white hat." If you're in it to steal or cause damage, you're a "black hat." The colors come from cowboy movies, according to wikipedia. (I suppose there is now additional ambiguity WRT whistle-blowers and such; the Wikileaks people probably think they are white hats, while their targets disagree. Ditto for government organizations, or whoever it was that put destructive code in Iran's nuclear fuel enhancement centrifuges.)
Here's the original definition of "hack" and "hacker", from the ARPANet jargon.txt file, circa 1980:
HACK n. 1. Originally a quick job that produces what is needed, but not well. 2. The result of that job. 3. NEAT HACK: A clever technique. Also, a brilliant practical joke, where neatness is correlated with cleverness, harmlessness, and surprise value. Example: the Caltech Rose Bowl card display switch circa 1961. 4. REAL HACK: A crock (occasionally affectionate). v. 5. With "together", to throw something together so it will work. 6. To bear emotionally or physically. "I can't hack this heat!" 7. To work on something (typically a program). In specific sense: "What are you doing?" "I'm hacking TECO." In general sense: "What do you do around here?" "I hack TECO." (The former is time-immediate, the latter time-extended.) More generally, "I hack x" is roughly equivalent to "x is my bag". "I hack solid-state physics." 8. To pull a prank on. See definition 3 and HACKER (def #6). 9. v.i. To waste time (as opposed to TOOL). "Watcha up to?" "Oh, just hacking." 10. HACK UP (ON): To hack, but generally implies that the result is meanings 1-2. 11. HACK VALUE: Term used as the reason or motivation for expending effort toward a seemingly useless goal, the point being that the accomplished goal is a hack. For example, MacLISP has code to read and print roman numerals, which was installed purely for hack value. HAPPY HACKING: A farewell. HOW'S HACKING?: A friendly greeting among hackers. HACK HACK: A somewhat pointless but friendly comment, often used as a temporary farewell. [The word HACK doesn't really have 69 different meanings. In fact, HACK has only one meaning, an extremely subtle and profound one which defies articulation. Which connotation a given HACK-token has depends in similarly profound ways on the context. Similar comments apply to a couple other hacker jargon items, most notably RANDOM. - Agre]
HACKER [originally, someone who makes furniture with an axe] n. 1. A person who enjoys learning the details of programming systems and how to stretch their capabilities, as opposed to most users who prefer to learn only the minimum necessary. 2. One who programs enthusiastically, or who enjoys programming rather than just theorizing about programming. 3. A person capable of appreciating hack value (q.v.). 4. A person who is good at programming quickly. Not everything a hacker produces is a hack. 5. An expert at a particular program, or one who frequently does work using it or on it; example: "A SAIL hacker". (Definitions 1 to 5 are correlated, and people who fit them congregate.) 6. A malicious or inquisitive meddler who tries to discover information by poking around. Hence "password hacker", "network hacker".