Reading Logs

Video + 11 min read · includes a lab

Visitor192.0.2.77
Web server
access.log
Evidence
GET /admin/
New log line
Reading Logs
0:00 / 4:46 · Reading Logs
Chapters and transcript

Reading Logs Someone has been poking at the company website. Did they get in? Every time someone visits a page, the web server can write a line to a log. A log is a written record of something that happened on a system. For a SOC analyst, logs are the main evidence. If it is not in the logs, it is very hard to prove it happened.

Why logs matter Logs help defenders in four ways. They detect attacks while they are happening. They investigate what an attacker did, and when. They prove what happened, to managers, customers or the law. And they improve defences, by showing which attacks are common.

Where logs come from Logs come from many places. The web server writes an access log of every request. A Linux server writes logins, sudo and SSH activity to its auth log. Windows keeps Event Logs, such as the Security log. And the firewall records allowed and blocked connections. A SIEM collects them all in one place, so analysts can search them together.

Windows Event IDs Windows gives each type of event a number, called an Event ID. Three are worth learning now. Forty-six twenty-four: an account logged on successfully. Forty-six twenty-five: an account failed to log on. Forty-seven twenty: a user account was created. A new account late at night, right after a logon from an unusual place, is worth a closer look.

Firewall logs A firewall log line shows the time, the source and destination IP, the port, the protocol, and whether the traffic was allowed or denied. Watch this IP. It tries port twenty-two. Denied. Then port thirty-three eighty-nine. Denied again. Many denied connections from one source to many ports is a sign of a port scan.

The access log Now one line from a web server access log, field by field. First, the client IP: who sent the request. Then the time it arrived. Then the request: the method, the path and the HTTP version. Then the status code, the server answer. Then the size in bytes. At the end, the user agent: the browser or tool. The client sends it, so attackers can fake it. It is a clue, not proof.

The access log Learn the common status codes. Two hundred means OK, the request worked. Three oh one and three oh two are redirects. Four oh one means not logged in, and four oh three means forbidden. Four oh four means the page was not found. And five hundred is a server error.

URL decoding Attackers often encode their input, so you need to read it. A percent sign and two hex digits stand for one character. Percent two zero is a space. Percent two seven is a single quote. Percent three D is an equals sign. Now decode this request. It becomes: id equals seven, quote, OR one equals one. That is a classic SQL injection attempt.

Signs of attacks Here are four signs of attacks in web logs. SQL injection strings, like quotes, OR one equals one, or UNION SELECT, plain or encoded. Scanner user agents, because tools like sqlmap and Nikto often announce their names. Many four oh fours from one IP, a tool guessing folder names. And a two hundred after many failures. That means the tool found something real.

Hunting in the log Let me search the access log for one suspicious IP with grep. Look at the results. Backup, not found. Old, not found. Dot git, not found. These are guesses, one second apart. But the last line is a two hundred, on the admin folder. After many misses, the tool found something real. That is the line that matters most.

Quick check Quick check. One IP requests hundreds of pages in a minute. Almost all of them return four oh four, but one request to the admin folder returns two hundred. Which line should you look at first? Take a moment, then choose.

Putting it together Let us put it together. Logs are the main evidence for an analyst. They come from web servers, Linux, Windows and firewalls. Read an access log line field by field: IP, time, request, status and user agent. Decode the URL before you judge it. And look for bursts of four oh fours, and a two hundred after many failures. Now read the lesson below, and try the lab to hunt an attacker in a real-looking log.

A log is a written record of something that happened on a system. Every time someone logs in, opens a web page or is blocked by a firewall, a line can be written to a log. For a SOC analyst, logs are the main evidence. If it is not in the logs, it is very hard to prove it happened.

Why logs matter

Logs help defenders to:

  • Detect attacks while they are happening
  • Investigate what an attacker did, and when
  • Prove what happened, for managers, customers or the law
  • Improve defences by showing which attacks are common

Common log sources

Source What it records Example location
Web server access log Every request to a website /var/log/apache2/access.log, /var/log/nginx/access.log
Linux auth log Logins, sudo use, SSH activity /var/log/auth.log (Debian, Ubuntu)
Windows Event Logs Logons, account changes, and much more Event Viewer, Security log
Firewall logs Allowed and blocked connections Firewall or SIEM

Windows Event IDs

Windows gives each type of event a number called an Event ID. A few well-known ones from the Security log:

Event ID Meaning
4624 An account successfully logged on
4625 An account failed to log on
4720 A user account was created

A new account created late at night (4720) right after a successful logon (4624) from an unusual place is worth a closer look.

Firewall logs

A firewall log line usually shows the time, source IP, destination IP, destination port, protocol and whether the traffic was allowed or denied. Many denied connections from one source IP to many ports is a sign of a port scan.

The web server access log

Apache and Nginx often use a format called the combined log format. Here is one line:

203.0.113.45 - - [12/Mar/2026:10:15:32 +0000] "GET /products.php?id=7 HTTP/1.1" 200 5120 "https://chaicorp.example/shop" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"

Field by field:

Part Value Meaning
Client IP 203.0.113.45 Who sent the request
Identity and user - - Usually empty (shown as -)
Time [12/Mar/2026:10:15:32 +0000] When the request arrived, with time zone
Request line GET /products.php?id=7 HTTP/1.1 Method, path (with query) and HTTP version
Status code 200 The server's answer (see below)
Size 5120 Bytes sent back to the client
Referrer https://chaicorp.example/shop The page the visitor came from
User agent Mozilla/5.0 (...) The browser or tool that made the request

Common status codes:

Code Meaning
200 OK, the request worked
301 / 302 Redirect to another page
401 / 403 Not logged in / forbidden
404 Page not found
500 Server error

The user agent and referrer are sent by the client, so attackers can fake them. They are useful clues, not proof.

URL decoding basics

Some characters cannot be sent directly in a URL, so they are URL-encoded: a % followed by two hexadecimal digits. Attackers often encode their input, so you need to recognise the common ones:

Encoded Character
%20 space
%27 ' (single quote)
%3D =
%22 " (double quote)
%2F /

A + in a query string is also often used to mean a space.

So this request:

GET /products.php?id=7%27%20OR%20%271%27%3D%271 HTTP/1.1

decodes to:

GET /products.php?id=7' OR '1'='1 HTTP/1.1

That is a classic SQL injection attempt.

Signs of attacks in web logs

1. SQL injection strings. Look for quotes, OR 1=1, UNION SELECT, -- or SLEEP( in URLs, both plain and encoded.

2. Scanner user agents. Many attack tools announce themselves unless the attacker changes the setting:

198.51.100.23 - - [12/Mar/2026:11:02:10 +0000] "GET /index.php?id=1%27 HTTP/1.1" 500 312 "-" "sqlmap/1.8 (https://sqlmap.org)"
198.51.100.23 - - [12/Mar/2026:11:05:44 +0000] "GET /admin/ HTTP/1.1" 404 196 "-" "Mozilla/5.00 (Nikto/2.5.0)"

3. Many 404s from one IP. A tool guessing folder and file names (called directory brute forcing) creates a burst of 404 responses:

192.0.2.77 - - [12/Mar/2026:12:00:01 +0000] "GET /backup/ HTTP/1.1" 404 196 "-" "Mozilla/5.0"
192.0.2.77 - - [12/Mar/2026:12:00:01 +0000] "GET /old/ HTTP/1.1" 404 196 "-" "Mozilla/5.0"
192.0.2.77 - - [12/Mar/2026:12:00:02 +0000] "GET /.git/ HTTP/1.1" 404 196 "-" "Mozilla/5.0"
192.0.2.77 - - [12/Mar/2026:12:00:02 +0000] "GET /admin/ HTTP/1.1" 200 2048 "-" "Mozilla/5.0"

4. A 200 after many failures. In the example above, the last line is a 200. After many misses, the tool found something real. That is the line that matters most. The same idea applies to logins: many failed attempts followed by a success can mean the attacker got in.

Useful first questions for any suspicious IP:

  • How many requests did it make, and over what time?
  • Which status codes did it receive?
  • Did any request succeed (200) on a sensitive path?
  • What user agent did it use?

In the lab, you will search a real-looking web server log and find the attacker's requests yourself.

HANDS-ON LAB

Web Log Hunt

Something attacked the shop last night. Find the IP that actually stole data.

Start the lab →

Check your understanding

Answer every question correctly to complete this lesson. If you miss one, try the quiz again.

1. In a URL, what does %27 decode to?

2. One IP address requests hundreds of different pages in a minute and almost all return 404. What is the most likely cause?

3. Which Windows Event ID records a failed logon?

Locked: answer every quiz question above correctly to complete this lesson.

Spotted a mistake or something unclear? Report a mistake