← All lessons Stage 0 · Lesson 2
10 min

Ports, and why 80 and 443 matter

Stage 0 · Lesson 2 · 10 minutes · Requires Lesson 1


The one-line answer

If an IP address is the building, a port is the specific door. One machine, many doors, each running a different service.


Why you should care

"Port scanning" is the most recognisable activity in all of hacking, and it's the second step of nearly every penetration test. But it's meaningless unless you understand what a port actually is.

More importantly: every open port is a potential way in. When a security team talks about reducing attack surface, they mostly mean closing doors nobody needs open.


How it actually works

Your laptop has one IP address. But right now it might be running a web browser, a music streaming app, a messaging client and a background update service — all talking over the network simultaneously.

How does incoming data know which application it belongs to?

Ports.

A port is just a number between 0 and 65535. When data arrives at your IP address, it also carries a port number, and the operating system uses that number to hand it to the right application.

An address plus a port is called a socket, written like this:

192.168.1.14:443

That means: this machine, door number 443.

The ports you must know

There are 65,536 possible ports, but a small handful account for most of what you'll see.

PortServiceWhat it doesSecurity note
80HTTPUnencrypted web trafficEverything is readable in transit
443HTTPSEncrypted web trafficThe one you want to see
22SSHRemote shell accessPrime brute-force target
21FTPFile transferSends credentials in plaintext
25SMTPSending mailAbused for spam relay
53DNSName resolutionUsed for data exfiltration
3306MySQLDatabaseShould never face the internet
3389RDPWindows remote desktopHeavily targeted by ransomware
445SMBWindows file sharingWannaCry's entry point

Memorise 80, 443, 22, 3306, 3389 at minimum. You'll meet them constantly.

Ports 0–1023 are called well-known ports and normally require administrator privileges to bind to. Ports above that are used by everything else, including the temporary port your browser picks for each outgoing connection.

Open, closed, filtered

When you scan a port, you get one of three answers:

  • Open — something is listening. There's a service here.
  • Closed — nothing is listening, but the machine responded.
  • Filtered — a firewall silently dropped your probe. No response at all.

That distinction matters. "Closed" tells an attacker the host is alive. "Filtered" tells them less — which is why firewalls drop rather than reject.


See it yourself

See what's listening on your own machine:

  • Windows: netstat -an | findstr LISTENING
  • Mac/Linux: netstat -an | grep LISTEN or ss -tuln

You'll see a list of ports your own computer has open. Most people are surprised how many there are.

Watch a port in action:

Visit http://example.com in your browser, then https://example.com. Same site, two different doors — 80 and 443. The second one is encrypted; the first isn't.

Try connecting manually:

curl -v http://example.com

The -v flag shows the connection details. Look for the line showing which IP and port it connected to.

Important: Only scan machines you own or have written permission to test. Port scanning someone else's infrastructure is, in many jurisdictions including India, a criminal offence. Lesson 9 covers this properly. Until then: your own devices and our labs only.


How attackers abuse this

Enumeration is step one. Scan the target's IP range, find every open port, identify what's running on each. The tool you'll hear about is nmap. Every open port is a lead.

Version fingerprinting. Services often announce their exact version when you connect. OpenSSH 7.4 or Apache 2.4.29 tells an attacker precisely which known vulnerabilities to try. This is why "banner grabbing" is a standard recon step.

Services that shouldn't be public. Finding MySQL on 3306 or Redis on 6379 exposed to the internet is a serious finding. These are meant to be internal only. Misconfigured cloud security groups cause this constantly — and it's how enormous data breaches happen.

Brute force on 22 and 3389. SSH and RDP exposed to the internet get thousands of automated login attempts daily. This is how a great deal of ransomware gets its initial foothold.

Non-standard ports don't hide anything. Moving SSH to port 2222 stops lazy scanners but delays a determined one by about four seconds. Security through obscurity isn't security.


Common mistakes

"Open ports mean I'm hacked." No. Open ports are normal — your machine needs them to work. The question is whether each open port is intentional and necessary.

"Closing ports secures the service." Closing unnecessary ports reduces attack surface, which is genuinely valuable. But a service that must stay open still needs to be patched, configured and monitored.

"Port 443 means it's secure." It means the traffic is encrypted in transit. The application behind it can still have SQL injection, broken authentication and every other flaw. HTTPS protects the pipe, not the water.


Check yourself

  1. A scan shows ports 22, 80 and 3306 open on a public server. Which one should worry you most, and why?
  2. What's the practical difference between a "closed" and a "filtered" port from an attacker's point of view?
  3. A site runs only on port 80. What's the risk to someone logging in?
Answers
  1. 3306 (MySQL). A database should never be directly reachable from the internet — it should only be accessible from the application server on the internal network. 22 and 80 are expected on a public server; a public database is a serious misconfiguration.
  2. "Closed" confirms the host is alive and reachable, which is useful information. "Filtered" means a firewall dropped the probe silently, giving the attacker no confirmation and slowing enumeration.
  3. Port 80 is unencrypted HTTP. Credentials sent over it travel in plaintext, readable by anyone positioned between the user and the server — on public Wi-Fi, that's trivially easy.

Your lab

There's no browser lab for ports — real port scanning needs your own machine. Do the See it yourself steps above on your own computer instead: they are the practice for this lesson.

The next lab, Challenge 02 — Read a URL like an attacker, follows Lesson 3.


Summary in your language

தமிழ் சுருக்கம் (Tamil summary)

Port என்றால் என்ன?

IP address ஒரு கட்டிடம் என்றால், port அந்தக் கட்டிடத்தின் ஒரு குறிப்பிட்ட கதவு. ஒரே கணினியில் பல services இயங்கும் — ஒவ்வொன்றும் வேறு வேறு port-ல்.

Port என்பது 0 முதல் 65535 வரையிலான ஒரு எண். IP address-ம் port-ம் சேர்ந்தால் அது socket: 192.168.1.14:443

கட்டாயம் நினைவில் வைக்க வேண்டிய ports:

  • 80 — HTTP (encryption இல்லை, எல்லாம் வெளிப்படையாகத் தெரியும்)
  • 443 — HTTPS (encrypted)
  • 22 — SSH (remote login) — brute-force தாக்குதல்களின் இலக்கு
  • 3306 — MySQL database — இணையத்தில் ஒருபோதும் வெளிப்படக் கூடாது
  • 3389 — RDP — ransomware தாக்குதல்களின் முக்கிய இலக்கு

Scan செய்யும்போது மூன்று நிலைகள்:

  • Open — ஒரு service கேட்டுக்கொண்டிருக்கிறது
  • Closed — service இல்லை, ஆனால் கணினி பதில் சொன்னது
  • Filtered — firewall அமைதியாக block செய்தது, எந்தப் பதிலும் இல்லை

பாதுகாப்பில் ஏன் முக்கியம்?

ஒவ்வொரு open port-ம் உள்ளே நுழைய ஒரு சாத்தியமான வழி. தேவையில்லாத ports-ஐ மூடுவது attack surface-ஐ குறைக்கும். Port 443 என்றால் traffic encrypted என்று மட்டுமே அர்த்தம் — அதன் பின்னால் உள்ள application பாதுகாப்பானது என்று அர்த்தமில்லை.

எச்சரிக்கை: உங்களுக்குச் சொந்தமான அல்லது எழுத்துப்பூர்வ அனுமதி உள்ள கணினிகளை மட்டுமே scan செய்யுங்கள். மற்றவர்களின் systems-ஐ scan செய்வது இந்தியாவில் குற்றமாகலாம். Lesson 9 இதை விரிவாக விளக்குகிறது.

हिंदी सारांश (Hindi summary)

Port क्या है?

अगर IP address एक इमारत है, तो port उस इमारत का एक ख़ास दरवाज़ा है। एक ही कंप्यूटर पर कई services चलती हैं — हर एक अलग port पर।

Port 0 से 65535 तक का एक नंबर है। IP address और port मिलकर socket बनाते हैं: 192.168.1.14:443

ये ports ज़रूर याद रखें:

  • 80 — HTTP (कोई encryption नहीं, सब कुछ खुले में दिखता है)
  • 443 — HTTPS (encrypted)
  • 22 — SSH (remote login) — brute-force हमलों का निशाना
  • 3306 — MySQL database — इसे कभी इंटरनेट पर खुला नहीं होना चाहिए
  • 3389 — RDP — ransomware हमलों का बड़ा निशाना

Scan करने पर तीन नतीजे:

  • Open — कोई service सुन रही है
  • Closed — कोई service नहीं, लेकिन कंप्यूटर ने जवाब दिया
  • Filtered — firewall ने चुपचाप block कर दिया, कोई जवाब नहीं

सुरक्षा में क्यों ज़रूरी है?

हर open port अंदर घुसने का एक संभावित रास्ता है। बेकार के ports बंद करने से attack surface कम होता है। Port 443 का मतलब सिर्फ़ इतना है कि traffic encrypted है — इसका मतलब यह नहीं कि उसके पीछे की application सुरक्षित है।

चेतावनी: सिर्फ़ उन्हीं कंप्यूटरों को scan करें जो आपके अपने हैं या जिनके लिए आपके पास लिखित अनुमति है। किसी और के systems को scan करना भारत में अपराध हो सकता है। Lesson 9 इसे विस्तार से समझाता है।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

You know the address and the door. Now: what's actually said once the door opens. HTTP is the language of the web, and reading it fluently is the single most useful skill in web security.

→ Lesson 3: HTTP: the conversation behind every page