Cybersecurity fundamentals come down to three areas you must be solid in before studying attack or defense: TCP/IP networking (ports, protocols, reading packets in Wireshark), Linux (command line, file permissions, system logs) and Windows (Event Log, Active Directory). A SOC alert such as "40 failed logins from one IP" only means something when you know which port the traffic used, where the logs live and which groups the account belongs to. This lesson shows you how to build a four-VM lab in VirtualBox, then generate, capture and read login traces on those machines yourself.
By the end of this lesson, you will be able to:
- Explain the TCP three-way handshake and name the ports of 10 services you will often see in logs.
- Capture packets in your lab with Wireshark, filter by IP, port and protocol, and read a TCP stream.
- Read and change Linux file permissions (640, 600) and count failed SSH logins per IP.
- Filter events 4624, 4625, 4720 and 4732 in the Windows Event Log and explain logon types.
- Build an isolated VirtualBox lab with an analysis machine, a Linux server, a Windows client and a domain controller.
Learning cybersecurity properly? This lesson is step 2 of the roadmap: networking, Linux and Windows for security. See the 9-step cybersecurity analyst roadmap to learn in the right order, from professional ethics to SIEM, incident response and entry-level certifications.
Authorized scope, minimum hardware and legal practice platforms are covered in the step 1 lesson Where to start learning cybersecurity; this lesson goes straight to the technical side.
TCP/IP through a security analyst's eyes
A network administrator asks "is the network up?". A security analyst also asks "who is talking to whom, on which port, at what time, and is that normal?".
The four TCP/IP layers and the traces each leaves
The TCP/IP model has four layers (the OSI model splits the same ideas into seven). Each layer leaves a different kind of trace.
| Layer | Protocols | What you can read | Security question |
|---|---|---|---|
| Link | Ethernet, Wi-Fi, ARP | MAC addresses, VLANs | Has an unknown device been plugged in? |
| Internet | IPv4, IPv6, ICMP | Source and destination IP | Internal or external IP? Is someone ping-sweeping? |
| Transport | TCP, UDP | Ports, TCP flags | Which service was contacted? Did the connection complete? |
| Application | DNS, HTTP, TLS, SSH, SMB | Domain names, paths, usernames | Are passwords sent in clear text? |
Not sure about subnet masks and CIDR notation such as /24? Read How to subnet IPv4 from the network administration career. A SOC analyst should see an IP and know at once whether it is private (10.x, 172.16–31.x, 192.168.x) or on the Internet.
TCP shakes hands, UDP does not
TCP is connection-oriented: the client sends SYN, the server answers SYN-ACK, the client sends ACK, and only then does data flow; the connection ends with FIN or is cut off with RST. UDP has no handshake, it just sends, which suits DNS, video and VoIP.
TCP flags tell a clear story. One IP sending hundreds of SYN packets to many ports without completing the handshake suggests a port scan. A server replying RST means the port is closed; no reply at all usually means a firewall dropped it.
Ports and services you will see in logs
A port is a number from 0 to 65535 that separates services on the same machine. Ports 0–1023 are well-known ports, and 49152–65535 are dynamic ports a client picks for itself. Do not confuse these logical ports with the physical sockets where cables plug in (Figure 1).
| Port | Service | Security note |
|---|---|---|
| 21/TCP | FTP | Clear-text passwords, replace with SFTP |
| 22/TCP | SSH | Frequent password guessing if exposed to the Internet |
| 25/TCP | SMTP | A workstation sending mail directly to the outside is suspicious |
| 53/UDP, TCP | DNS | Often abused by malware for covert communication |
| 80/TCP | HTTP | Unencrypted, content is readable |
| 88/TCP, UDP | Kerberos | Authentication in Active Directory |
| 389/TCP, UDP | LDAP | Queries to the Active Directory directory |
| 443/TCP | HTTPS | TLS encrypted, you only see the domain and traffic volume |
| 445/TCP | SMB | Windows file sharing, never expose it to the Internet |
| 3389/TCP | RDP | Remote access to Windows, a common password-guessing target |
Packet analysis with Wireshark in your lab
Wireshark is free, open-source software that captures packets on a network interface and lets you open each layer. It is the fastest way to see TCP/IP theory with your own eyes.
Capture in the right place, within your scope
Install Wireshark on the analysis machine and pick the interface attached to the lab's host-only network. You can set a capture filter such as host 192.168.56.10 to keep files small. Captures are saved as .pcapng.
Legal and safety warning: only capture packets on networks and devices you own, or when you have been given the job in writing. Capturing other people's traffic on cafe Wi-Fi, in a dormitory or on a company network without permission can violate personal privacy and break the law in Vietnam and elsewhere. A .pcapng file may contain passwords and login cookies: do not share it online and delete it when the exercise is done. Download Wireshark and any other tool only from the project's official site.
Five display filters for everyday use
ip.addr == 192.168.56.10: every packet to or from this machine.tcp.port == 22: SSH traffic.dns: name queries and answers.http.request: HTTP requests, including the paths.tcp.flags.syn == 1 && tcp.flags.ack == 0: only opening SYN packets, so you see who is trying to connect where.
Reading a stream from start to finish
Right-click a packet and choose Follow, TCP Stream to see the whole conversation. With unencrypted HTTP you can read an entire login form; with SSH or HTTPS you only see encrypted data. The Statistics menu has Conversations (who talked to whom and how many bytes), which is ideal for spotting outliers in a large capture.
Exercise: build a test HTTP login page on the Linux machine in your lab, log in from the analysis machine, then find the password again in Wireshark. You will understand why login pages must use HTTPS.
Linux for security: command line, permissions and logs
Most web servers, network devices and security tools run Linux. For broader Linux skills (systemd, disks, DNS), read Linux basics for DevOps; here we focus on the security view.
Seven commands analysts use most
| Command | Used to | Security example |
|---|---|---|
id | See which groups an account is in | Is this account in the sudo group? |
ls -l | See permissions and owner | Is a config file readable by everyone? |
ps aux | List processes | Find a strange process eating CPU |
ss -tulpn | See listening ports | Spot an unneeded service |
last | Login history | Is a 3 a.m. login normal? |
grep, awk, uniq -c | Search, split columns, count | Count failed logins per IP |
journalctl | Read systemd logs | View today's SSH logs |
Permissions: rwx and the number 640
ls -l prints a string such as -rw-r-----. Drop the first character (file type); the remaining nine form three groups: owner, group, others. Each group has r (read, 4), w (write, 2) and x (execute, 1). Add them up: rw- = 4 + 2 = 6, r-- = 4, --- = 0, so -rw-r----- is 640.
- 600: owner read/write only, for private SSH keys.
- 640: owner read/write, group read, for many log and config files.
- 644: everyone reads, only the owner writes, for public files.
- 755: programs and directories everyone can run, only the owner can change.
/etc/passwd (the account list) is world-readable; password hashes live in /etc/shadow, readable only by root. Finding /etc/shadow at 644 is a serious misconfiguration. Change permissions with chmod 640 file and ownership with chown user:group file.
Where the system logs are
Ubuntu and Debian write logins and sudo use to /var/log/auth.log, general messages to /var/log/syslog. The Red Hat family (Rocky, AlmaLinux) uses /var/log/secure. Many newer systems log to journald, read with journalctl. Figure 2 shows a familiar scene: a technician plugging a laptop in next to a server rack to read logs and check configuration.
Photo: Derrick Coetzee from Berkeley, CA, USA / Wikimedia Commons, CC0
A failed SSH login looks like Failed password for hocvien from 192.168.56.20 port 51544 ssh2; for a username that does not exist it reads Failed password for invalid user admin from .... Count failures per IP:
grep "Failed password" /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -nr
$(NF-3) is the fourth field from the end of the line, exactly where the IP sits in both formats. A common trap: rsyslog may collapse identical consecutive lines into message repeated 2 times: [ ... ], so counting in auth.log can undercount. When you need an exact number, read through journalctl, which does not collapse lines.
Windows Event Log and Active Directory
Most businesses in Vietnam run Windows workstations, and from a few dozen machines up they are usually managed centrally with Active Directory (Figure 3). Traces of attacks on Windows accounts live in the Event Log.
Open Event Viewer and read the Security log
Run eventvwr.msc and go to Windows Logs, Security. Each event has an Event ID, time, account, computer and description. In PowerShell (run as administrator), get the 20 most recent failed logins:
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 20
Some events, such as 4688 (process creation), only appear when the audit policy is enabled.
Eight Event IDs worth memorizing
| Event ID | Meaning | When it deserves attention |
|---|---|---|
| 4624 | Successful logon | Right after a run of 4625s, or at odd hours |
| 4625 | Failed logon | Many in a row |
| 4672 | Special privileges assigned to a logon | A normal account suddenly has privileges |
| 4688 | New process created | PowerShell launched from Word or Excel |
| 4720 | User account created | No request from HR |
| 4732 | Member added to a local group | Someone added to Administrators |
| 4740 | Account locked out | Many accounts locked at once |
| 1102 | Security log cleared | Almost always needs investigation |
Logon types and 4625 error codes
The Logon Type field tells you how someone logged on: 2 is at the keyboard, 3 is over the network (shared folders), 5 is a service, 7 is a screen unlock, 10 is Remote Desktop. For 4625, the Sub Status gives the reason: 0xC000006A is a wrong password, 0xC0000064 is a username that does not exist. Many 0xC0000064 events with names like admin or test usually mean someone is guessing account names.
Active Directory in five concepts
- Domain: users, computers and groups sharing one account database, for example hocvien.test in the lab.
- Domain controller (DC): a Windows Server that holds that database and authenticates logons with Kerberos.
- OU: a container that organizes users and computers by department.
- Group Policy (GPO): settings pushed to many machines, such as password length or auditing.
- Privileged groups: keep Domain Admins as small as possible; every addition needs a reason.
When investigating logons in a domain, check the logs on the DC too (for example 4771, a failed Kerberos pre-authentication), not just the workstation.
Photo: Caiguanhao / Wikimedia Commons, CC BY-SA 3.0
Building a four-VM VirtualBox lab
VirtualBox is free virtualization software that runs on Windows, macOS and Linux. This section shows how to size the lab to your RAM and keep it safely isolated.
Choosing a network mode for each machine
| Network mode | What the VM sees | When to use it |
|---|---|---|
| NAT | Internet through the host, VMs cannot see each other | Temporarily, for software updates |
| Host-only | Each other and the host, no Internet | Main lab network, 192.168.56.0/24 by default |
| Internal Network | Only VMs on the same named network | Strictest isolation |
| Bridged | Like a real machine on your home network | Do not use for a security lab |
Worked example: splitting 16 GB of RAM across four VMs
Lan has a laptop with 16 GB of RAM and a 512 GB SSD. The rule: never give all the RAM to VMs; the host should keep at least 3 GB.
| VM | Role | IP | RAM | Max virtual disk |
|---|---|---|---|---|
| Ubuntu Desktop | Analysis machine with Wireshark | 192.168.56.20 | 3 GB | 40 GB |
| Ubuntu Server | SSH and test web server | 192.168.56.10 | 2 GB | 25 GB |
| Windows Server (evaluation) | DC for hocvien.test | 192.168.56.5 | 4 GB | 60 GB |
| Windows 11 (evaluation) | Domain workstation | 192.168.56.30 | 4 GB | 64 GB |
| Total | 13 GB | 189 GB | ||
Check: 3 + 2 + 4 + 4 = 13 GB, leaving 16 − 13 = 3 GB for the host. The virtual disks, 40 + 25 + 60 + 64 = 189 GB, are maximums; with dynamically allocated disks the files grow only with real data and fit comfortably on the 512 GB SSD. With 8 GB of RAM, run the lab in pairs: analysis machine 3 GB + Ubuntu Server 2 GB = 5 GB; another day, the DC at 2 GB + Windows 11 at 4 GB = 6 GB (Windows 11 requires at least 4 GB). It will be slow but still usable for learning.
Evaluation versions of Windows Server and Windows 11 Enterprise come from the Microsoft Evaluation Center, with the time limit stated on the page. Do not use cracked Windows: many copies ship with malware.
Build order and snapshots
- Enable virtualization (Intel VT-x or AMD-V) in the BIOS and install VirtualBox from its official site.
- Create a host-only network and set static IPs as in the table.
- Install Ubuntu Server with SSH; install Ubuntu Desktop and Wireshark, then test ping and SSH to the server.
- Install Windows Server, add the Active Directory Domain Services role and promote it to a DC for hocvien.test.
- Install Windows 11 (VirtualBox 7 provides the virtual TPM it requires), point DNS to 192.168.56.5, join the domain and create two standard user accounts.
- Take a "clean" snapshot of all four VMs to return to after each exercise.
Disable shared folders, drag and drop and the shared clipboard between host and VMs when you do not need them.
Capstone exercise: tracing logins through your lab
This exercise ties networking, Linux and Windows together. You play both roles, the person creating events and the investigator, on your own lab.
Create the events
- On the analysis machine, start a Wireshark capture on the host-only interface.
- At 20:00, SSH to [email protected]. In the first connection type a wrong password 3 times (the client disconnects), in the second type it wrong twice and press Ctrl+C, and in the third type it correctly.
- At 20:10, at the Windows 11 login screen, sign in as the domain user lan.nguyen, type the wrong password 3 times, then the right one.
Investigate and reconcile the numbers
| Source | How to find it | Expected result | Events |
|---|---|---|---|
| Ubuntu Server | journalctl --since "20:00" | grep "Failed password" | Same IP 192.168.56.20 | 5 |
| Ubuntu Server | journalctl --since "20:00" | grep "Accepted password" | Account hocvien | 1 |
| Windows 11 | Event ID 4625 | Logon Type 2, Sub Status 0xC000006A | 3 |
| Windows 11 | Event ID 4624, Logon Type 2, account lan.nguyen | Around 20:10 | 1 |
| Total | 10 | ||
Check: 5 + 1 + 3 + 1 = 10, matching what you typed (6 SSH attempts, 4 Windows attempts). In Wireshark, filtering for opening SYN packets to port 22 shows 3 packets for 3 connections: the OpenSSH client asks for a password at most 3 times per connection by default, so 5 failures need 2 connections, plus 1 successful connection. You cannot read the password because SSH is encrypted, but you clearly see the time, IP, port and number of connections.
Write a five-line investigation note
Write it like a real ticket: time (20:00–20:12), source (192.168.56.20), targets (SSH on 192.168.56.10, the Windows 11 machine), behavior (5 + 3 failures followed by success), conclusion (deliberate testing in the lab). At work the conclusion will be much harder, but the structure stays the same.
Common mistakes and how to fix them
Memorizing ports without ever capturing a packet
Symptom: you know "SSH is port 22" but not what an SSH connection looks like. Fix: for each service in the port table, generate traffic in your lab and find it in Wireshark at least once.
Using Bridged mode for the whole lab
Symptom: VMs get IPs in the same range as your phone and TV. Fix: switch to host-only or an internal network; pinging a real device at home from a VM must fail.
Chmod 777 "to make it work"
Symptom: every Permission denied ends with mode 777. Fix: use ls -l and id to see why access is refused, then grant the minimum permission or add the user to the right group.
Frequently asked questions
How long does it take to learn cybersecurity fundamentals?
At about 10 hours a week, many people need 10–12 weeks for networking, Linux and Windows at the level of reading logs and packets. People with IT support experience can go faster.
Do I need CCNA before studying cybersecurity?
No. You need to understand IP, subnets, ports, basic routing, VLANs and NAT, roughly the introductory part of CCNA, which is enough for a tier-1 SOC role.
Is Wireshark legal?
Wireshark is a legal tool widely used to troubleshoot networks. What matters is where you capture: on your own network or as an assigned job is fine; eavesdropping on other people's traffic without permission is not.
How do I build an Active Directory lab on a weak machine?
With 8 GB of RAM, run only the DC at 2 GB and Windows 11 at 4 GB and keep the other VMs off. Alternatively, use a legal online lab platform with ready-made Windows environments, within the scope it allows.
Practice and self-assessment
- Build a lab of at least 2 machines on a host-only network and record IPs and RAM; total VM RAM must be at least 3 GB below the host's RAM.
- Capture one SSH session in the lab and screenshot the three-way handshake.
- On Ubuntu Server, create bao-cao.txt with mode 640 and explain the number 640.
- Do the login-tracing exercise and write the five-line investigation note.
Self-assessment criteria
- Pass: you point out the SYN, SYN-ACK and ACK packets in Wireshark and explain each one.
- Pass: your per-IP failure count matches the number of wrong passwords you typed.
- Pass: you find 4625 and 4624 and state the correct Logon Type and Sub Status.
- Not yet: any capture or login attempt on a device or network outside your own lab.
Once you can read packets, file permissions and login logs, move on to the next roadmap step: Common threats & attack models, where you study phishing via email, Zalo and SMS, ransomware and the MITRE ATT&CK framework, and see which stage of a real attack the traces you practiced today belong to.
Keep learning cybersecurity: after networking, Linux and Windows come common threats, system hardening, SOC monitoring with SIEM, web testing in a lab and incident response. See the 9-step cybersecurity analyst roadmap.






