Ethical hacking, also called penetration testing or white-hat hacking, is a legitimate security practice where trained professionals test computer systems, networks, and applications with explicit permission from the owner. Unlike cybercriminals, ethical hackers follow a strict code of conduct and help organizations strengthen their defenses.

The core principle of ethical hacking is simple: find vulnerabilities before the bad guys do. Ethical hackers use the same tools and techniques as malicious hackers, but they operate within legal boundaries, have written authorization, and report all findings to help fix security problems.

Common ethical hacking techniques include:

**Reconnaissance** – Gathering information about a target system through public sources, network scanning, and social engineering research.

**Scanning and Enumeration** – Using tools to identify open ports, services, and potential entry points in a network.

**Vulnerability Assessment** – Testing for known security weaknesses in software, configurations, or protocols.

**Exploitation** – Attempting to gain unauthorized access to demonstrate how a vulnerability could be abused (only with permission).

**Reporting** – Documenting all findings and providing recommendations for remediation.

Here's a simple example of an ethical hacking technique using a common command-line tool:

```bash

# Port scanning with Nmap to identify open services

nmap -sV 192.168.1.100

```

This command scans a target IP address to discover which ports are open and what services are running. An ethical hacker would use this information to identify potential security gaps.

Another common technique is password strength testing. A secure password should resist brute-force attacks:

```python

# Simple password strength checker

import string

def check_password_strength(password):

strength = 0

if len(password) >= 8:

strength += 1

if any(char.isupper() for char in password):

strength += 1

if any(char.isdigit() for char in password):

strength += 1

if any(char in string.punctuation for char in password):

strength += 1

return strength

# A password with uppercase, digits, and special characters scores higher

print(check_password_strength('Pass123!')) # Strong

print(check_password_strength('password')) # Weak

```

Ethical hackers also test for SQL injection vulnerabilities, which occur when user input isn't properly validated. A secure approach sanitizes all input:

```python

# Vulnerable code - DO NOT USE IN PRODUCTION

query = 'SELECT * FROM users WHERE username = ' + user_input

# Secure code using parameterized queries

cursor.execute('SELECT * FROM users WHERE username = ?', (user_input,))

```

To become an ethical hacker, professionals typically pursue certifications like the Certified Ethical Hacker (CEH), CompTIA Security+, or OSCP. These programs teach both technical skills and professional ethics.

The ethical hacking industry is growing rapidly as companies recognize that proactive security testing is far cheaper than dealing with data breaches. If you're interested in cybersecurity, ethical hacking offers a rewarding career where you can use technical skills to protect organizations and their users.