The term "hacker" generally brings to mind a lonesome, hooded figure, operating in the dark, stealing our money or personal information. But the past decade has given us reason to rethink this stereotype.

A new type of hacker is on the rise. Called "ethical hackers" or "white hat hackers", these men and women use their skills for good by helping companies protect themselves. They work to find and report security vulnerabilities before criminal hackers can take advantage of the bugs.

As it turns out, ethical hacking can actually be much more lucrative than operating illegally. Increasingly, organizations like Google, Goldman Sachs and the Department of Defense are paying hackers for identifying vulnerabilities in their systems, in whats known as a "bug bounty program."

This has given rise to a new crop of startups, like Bugcrowd, Hackerone and Synack, which work to connect ethical hackers with companies offering bug bounties. And through these platforms, some talented hackers have struck it rich.

Here's how hackers became the good guys.