A penetration test is an agreed-upon simulated, offensive cybersecurity engagement that tests for vulnerabilities in the target’s systems. The red team is the offensive team and the defenders are the blue team. The organization being tested is looking for weaknesses in their systems. (Optionally, an organization may set up a purple team to support the engagement.)
In order to do a penetration test you need written permission with specific rules of engagement. You cannot deviate from the plan that is agreed upon. Even scanning the ports of the target system can throw up red flags for the responsible organization and can lead to legal trouble for you if not documented.
Though many red-team/blue-team exercises use in-house teams for both, an outside hacker can actually make some good money doing this. Some hackers make a career out of it. I’ve heard of a contract tester making $50,000 for one engagement; though in-house team members can make $140,000. There’s even two certifications specifically for penetration testing, the Certified Ethical Hacker and PenTest+ certs.
Halo’s red team/blue team borrows from this concept: Spartan Showdown: Blue Team vs Red Team – YouTube