
30 Days of CTF Series | Day 4: Networking Fundamentals for CTF (IP, Ports, netcat and curl)
Welcome to Day 4 of the 30 Days of CTF series.
So far, everything you did was on your own machine. You learned Linux on Day 2 and the power tools find, grep and strings on Day 3. But many CTF challenges do not give you a file. Instead, they give you something like this:
nc challenge.hacklido.com 31337
or a website link. To solve these, you need to understand how computers talk to each other over a network. That is exactly what we will learn today, in the simplest way possible.
Practice labs for Day 4:
The Big Picture in One Example
When you open a website, this is what happens in simple words:
- You type
hacklido.com in your browser.
- Your computer asks a DNS server: “What is the IP address of hacklido.com?”
- DNS replies with an IP address, like a phone number for that server.
- Your browser connects to that IP on port 443 (the HTTPS door).
- The server sends back the web page.
Four words to remember from this: IP address, DNS, port, protocol. Let’s understand each one.
1. IP Address (The Home Address)
Every device on a network has an IP address. It is like a home address, so data knows where to go.
192.168.1.10
There are two kinds you should know:
- Private IP: Used inside your home or office network. Usually starts with
192.168., 10. or 172.16. to 172.31.
- Public IP: Your address on the internet.
One special address: 127.0.0.1 (also called localhost) always means “this same computer”.
Check your own IP in Linux:
$ ip a
Look for a line that starts with inet. That is your IP address.
2. Ports (The Doors)
If the IP address is the building, ports are the doors. One server can run many services at the same time, and each service listens on its own port.
Common ports you will see in CTFs again and again:
21: FTP (file transfer)
22: SSH (remote login)
25: SMTP (email)
53: DNS
80: HTTP (website)
443: HTTPS (secure website)
3306: MySQL database
8080: often a second website or admin panel
When a CTF says nc challenge.hacklido.com 31337, it means: “connect to this server on door number 31337”. Challenge servers often use unusual port numbers like this.
3. TCP vs UDP (How Data Travels)
Data travels using a protocol, which is just a set of rules. The two most important are:
- TCP: Reliable. It checks that every piece of data arrives in the right order. Like a phone call where both sides confirm “Hello? Can you hear me?” before talking. Websites, SSH and most CTF services use TCP.
- UDP: Fast but does not check. Like shouting a message across a room and hoping it is heard. Used for DNS, video calls and gaming.
The TCP 3 way handshake is how every TCP connection starts:
You -> SYN -> Server "I want to connect"
You <- SYN-ACK <- Server "OK, I am ready"
You -> ACK -> Server "Great, let's talk"
You will see these words again when we learn port scanning with nmap tomorrow.
4. DNS (The Phone Book of the Internet)
Humans remember names like hacklido.com. Computers need IP addresses. DNS converts names into IP addresses.
$ nslookup hacklido.com
or
$ dig hacklido.com
In CTFs, DNS records sometimes hide flags. For example, a TXT record:
$ dig TXT example-ctf.com
Command 1: ping (Is it alive?)
ping checks if a machine is reachable.
$ ping -c 4 8.8.8.8
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=21.3 ms
-c 4 means send only 4 pings (otherwise it runs forever, press Ctrl + C to stop)
- If you get replies, the machine is up
Note: Some servers block ping. No reply does not always mean the machine is down.
Command 2: curl (Talk to websites from the terminal)
curl fetches a web page and shows you the raw content. This is very useful in web challenges, because you see exactly what the server sends, including things the browser hides.
$ curl http://example.com
See the response headers too:
$ curl -i http://example.com
Flags are sometimes hidden inside headers or HTML comments, so -i is a great habit.
Combine with Day 3 skills:
$ curl -s http://example.com | grep "HackCTF"
$ curl -s http://example.com | grep "<!--"
-s means silent mode (no progress bar). The second command finds HTML comments, where developers often leave secrets.
Download a file:
$ wget http://example.com/challenge.zip
Command 3: netcat (The Swiss Army Knife)
netcat, written as nc, lets you connect to any port and send or receive raw text. It is one of the most used tools in CTFs.
Connect to a challenge server:
$ nc challenge.hacklido.com 31337
Once connected, you can read what the server says and type your answers.
Check if a port is open:
$ nc -zv 192.168.1.10 80
Connection to 192.168.1.10 80 port [tcp/http] succeeded!
-z means just check, do not send data
-v means show details
Try it on your own machine (two terminals):
Terminal 1 (listen on port 4444):
$ nc -lvnp 4444
Terminal 2 (connect to it):
$ nc 127.0.0.1 4444
Now type a message in one terminal and it appears in the other. You just built a tiny chat over the network. This same idea is used later for reverse shells, which you will meet in Week 4.
Let’s Solve a Challenge Together
Imagine a challenge says:
“Our robot only talks to people who can do maths fast. Connect and find out.”
nc challenge.hacklido.com 31337
Step 1: Connect with netcat.
$ nc challenge.hacklido.com 31337
Welcome, human.
Answer my question to get the flag.
What is 25 + 17?
Step 2: Type the answer and press Enter.
42
Correct!
HackCTF{n3tc4t_t4lks_t0_s3rv3rs}
Flag captured. Many beginner CTF challenges work exactly like this: connect, read carefully, and respond correctly.
In harder versions, the server asks 100 questions in 10 seconds. A human cannot type that fast, so you write a small Python script to answer automatically. That is exactly why we learn Python on Day 6.
Try It Yourself on Hacklido
1. Linux Mastery: From Zero to Hero, module “The Networking Stack”
Open the learning path and go to the “The Networking Stack” module to practice Linux networking commands hands-on.
Link: learn.hacklido.com/learn/linux-mastery-from-zero-to-hero
2. View Source
A website claims you cannot see the flag. Open it in your browser first, then try fetching it with curl and searching the output with grep. Look for comments and JavaScript.
Link: learn.hacklido.com/challenges/view-source
3. Nmap Mastery: From Zero to Expert Network Scanner
This learning path starts with TCP/IP basics before moving to scanning. Read the first module today to strengthen your networking base. We will use the rest of it tomorrow.
Link: open learn.hacklido.com/learn and select Nmap Mastery.
Day 4 Cheat Sheet
Save this in your notes:
- IP address: the address of a device (
127.0.0.1 = your own machine)
- Port: a door for a service (22 SSH, 80 HTTP, 443 HTTPS)
- TCP: reliable, uses SYN, SYN-ACK, ACK handshake
- UDP: fast, no checking
- DNS: converts names to IP addresses
ip a: show your IP address
ping -c 4 host: check if a machine is reachable
nslookup host / dig host: DNS lookup
curl -i url: fetch a page with headers
curl -s url | grep "HackCTF": search a page for the flag
wget url: download a file
nc host port: connect to a service
nc -zv host port: check if a port is open
nc -lvnp 4444: listen for a connection
Day 4 Task
What’s Next?
In Day 5, we will learn Scanning and Enumeration with Nmap: how to find which machines are alive, which ports are open and what services are running on them. This is the first step of almost every hacking challenge and real penetration test.
See you tomorrow on Day 5. Happy hacking.