From attack to defense: who sees me from the other side?
Cyber journey journal | Chapter 02
- 23 min read
- 26 terms from the glossary
In the previous session I sat in front of the terminal, ran DIRB and discovered a path that did not appear in FakeBank's menu: /bank-transfer.
At first glance, it was just an address.
But then the next task arrived, and I understood why this particular address is so interesting.
Finding a door is one thing. Discovering that it is open - that is a different story.
I opened the address in the lab's browser and, to my surprise, reached an admin interface that allows deposits to be made into bank accounts.
The task was to deposit 2,000 dollars into account number 8881. I did it - and the system confirmed that the deposit had been made.
A celebratory message appeared on the screen:
BANK-HACKED
A small moment of satisfaction. I did it!
But this time I wanted to dwell on the question hiding behind the success.
How was a user able to reach an administrative action like this at all?
As a developer, I am used to thinking about permissions on several levels. You can hide an interface from certain users. You can prevent them from opening a path. But none of this is enough if the action behind the interface is still reachable by someone who has no permission to perform it.
The server must verify that the user is allowed to perform the requested action, on the specific resource, before it makes a change.
Hiding a button is not a permission mechanism. And hiding an address is not a permission mechanism either.
The lab illustrated the risk through an action that succeeded. It did not reveal the Backend implementation to me, so I do not know exactly which permission check is missing in the code. But the principle is clear.
And then I switched sides
Until now I had been the one looking for hidden paths.
In the next room, Defensive Security Intro, I found myself facing a monitoring system that warned that someone else was doing exactly this kind of thing.
Suddenly the question was turned around.
No longer: How do I find a path?
Instead: How do I discover that someone is trying to find paths in my system?
In front of me was Security Hub - a security monitoring dashboard. One of the alerts was marked as critical.
Someone had tried to access paths such as /backup, /login and /admin.
I moved to the investigation pane and checked which paths had been tried, which address the activity came from and whether the attempts had succeeded.
After that I moved to the response stage: blocking the source of the requests, limiting the rate of requests and turning on protection against similar scanning patterns.
At the end the message appeared:
Threat Neutralised
And this time I felt a different kind of satisfaction. I had not found a way in - I had managed to stop an attempt to get in.
But who said an alert is always an attack?
Here I remembered a real case from my own work.
Legitimate requests to an API succeeded in the test environment, but in production they were blocked with a 403 error. We looked for the problem in the code and on the server, and found no trace of these requests in the Apache and PHP logs.
In the end it turned out that what had blocked them was a protection mechanism that ran in front of the application. The full story is waiting in the second part of the chapter.
It was an important lesson even before I started studying cyber in an orderly way.
Because sometimes the protection identifies suspicious activity and rightly blocks it.
And sometimes it blocks the very users we are trying to protect.
And this is where the real challenge of defensive security comes from: not only to detect and block, but to understand what is happening, to tell a real threat apart from normal activity, and to act precisely.
In this chapter we will dive into the world of alerts, logs, monitoring systems and the processes of responding to security incidents - and try to understand what the other side of the same HTTP request I sent in the terminal looks like.
Part one — what happened in the investigation, step by step
1. The first alert: someone is looking for the front door
In the Defensive Security Intro room I was given a new role: this time I am part of the defense team.
I opened an interface called Security Hub, the lab's monitoring dashboard (that is the name of the interface in the exercise; it has no connection to the AWS service with a similar name). An alert with the severity level Critical appeared on the screen:
Someone is poking at the admin pages.
In other words, someone is trying to locate admin pages on the site.
The system showed the source IP address of the traffic and a description of the suspicious activity.
I could have hurried and clicked the block button. But what exactly would I have been blocking? And what had proven to me that the activity was malicious?
I decided to investigate first.
This was my first hands-on introduction to one of the central tasks of SOC — Security Operations Center teams: receiving alerts, understanding what they say and deciding which of them require handling.
An alert is the beginning of an investigation, not necessarily its conclusion.
2. I opened Investigate - and what did I find?
I moved to the Investigate tab, which showed the list of paths that the traffic source had tried to open.
| Path | What might it represent? |
|---|---|
/backup |
A backup folder or resources saved for restore purposes |
/login |
A page or entry point to a login process |
/admin |
An admin interface or administrative functionality |
The system marked /admin as the most recent attempt.
According to the simulation's data, the same source tried to reach three pages and did not manage to get into them.
But here too you have to be careful with conclusions.
The mere fact that someone requested /admin does not prove that they are an attacker. Maybe it is an employee who tried to go to an old address? Maybe an authorized security test?
What raises suspicion is the combination of the paths that were chosen, the sequence in which the requests were sent, the identity of the source and its behavior.
The investigation begins when you connect several small details into one story.
3. Can a scan be recognized by its pace?
Here a thought came to me, following the experiment with Gobuster that I carried out in the previous session.
When I ran Gobuster against my local development environment, I limited it to a low rate with the options -t 1 --delay 1000ms: one Thread, and a pause of one second between requests.
But wait - if I set fixed intervals for the tool, the side that receives the requests may be able to see this pattern too.
Suppose a server log contains the following entries. This is an example I made up for illustration, not a log collected from my system:
22:46:01 GET /admin 404
22:46:02 GET /login 200
22:46:03 GET /api 302
22:46:04 GET /reports 403Notice: every second a request is sent to a different path.
A human user does not usually move between pages with such precise timing, especially when there is no natural navigation sequence between them.
Have we found an attacker? Not necessarily. But we have found a pattern worth checking.
A legitimate monitoring system can also run at fixed times. On the other hand, a scanning tool can send requests at varying intervals so as not to create a fixed pattern.
That is why an investigation does not rely only on the traffic rate. It also checks source addresses, types of paths, response codes, HTTP headers, activity history and context.
And here is an especially important insight:
Even activity that does not exceed the rate limit (Rate Limiting) may be suspicious.
Rate limiting is meant to control the number of requests. Detecting suspicious behavior is meant to understand what they mean.
These are two different tasks.
4. What do you do after discovering suspicious activity?
After I identified the traffic source in the lab, I moved to the Respond tab.
The system offered me three protective measures.
Block the attacker — blocking the source
I chose the IP address identified in the exercise and blocked it. This is a targeted response to a specific source.
Slow their requests — slowing down the requests
I turned on a mechanism that limits the rate of requests to the admin pages. The idea is to reduce the ability to send many requests in a short time.
Turn on protection — turning on additional protection
I turned on filtering against the activity pattern the system had identified. Unlike blocking a single IP, a rule based on the characteristics of the requests may stay relevant even if the traffic comes from another source.
After turning on all three measures, the closing message appeared:
Threat Neutralised
According to the simulation, the threat was contained before it managed to reach sensitive information.
But here an interesting question came up: if I blocked the IP address of the suspicious source, what would stop it from simply moving to another address?
The short answer: blocking the address alone will not prevent that. Blocking a source is not the same as detecting behavior, so effective protection is built from several layers that complement each other.
5. The exercise is over. The questions have only just begun.
In the lab, turning on three mechanisms was enough to get a success message.
In a real system, a Deployed status does not prove that the protection works exactly as we planned.
I would like to know:
- Were the suspicious requests really blocked?
- Which rule was triggered?
- Did the requests reach the application server anyway?
- Were legitimate users blocked too?
- Can another source continue the same activity?
This is exactly where the part I find fascinating begins: the move from “I turned on protection” to “I proved what it does”.
Part two — the professional summary
Offensive Security versus Defensive Security
| Aspect | Offensive Security | Defensive Security |
|---|---|---|
| Goal | Identifying vulnerabilities through authorized testing | Preventing harm, detecting events and responding to them |
| Point of view | How can a resource be reached or a vulnerability exploited? | What is happening in the system, and is there suspicious activity? |
| Example tools | DIRB, Gobuster and security testing tools | Logs, SIEM, EDR, WAF and alerting systems |
| Work product | Findings, evidence and recommendations for fixing | Documenting events, containment, recovery and improvement |
| Main risk | Missing a vulnerability or misinterpreting a finding | Missing a threat or blocking legitimate activity |
The two fields complement each other.
In a penetration test you try to find vulnerabilities before an attacker exploits them. A defense team tries to prevent harm and to detect unusual activity, including attempts to exploit existing vulnerabilities.
What is the difference between Event, Alert and Incident?
These are three concepts that are easy to confuse.
Event — a recorded occurrence
Something that happened in the system and was recorded. For example, an HTTP request to the path /login. Most events are not security events.
A monitoring system found an event or a pattern that meets a condition defined as suspicious. For example, an unusual number of requests to hidden paths.
An event that, according to the investigation and the relevant definitions in the organization, requires a response because harm to security has occurred or may occur.
In other words:
Not every Event is an Alert, and not every Alert is an Incident.
One of the important skills in security analysis is Triage — sorting and prioritizing alerts.
The goal is to tell apart a marginal event, a false detection and a real threat that requires a quick response.
Incident Response - how do you respond to a security incident?
When suspicious activity is discovered, a process of checking and decision-making begins.
In this chapter we will use a teaching division into six stages. It is a convenient way to understand the work in practice, and not a rigid sequence that every incident must go through in exactly the same order.
1. Preparation
Even before an incident occurs, you prepare the ability to detect it and handle it.
You set up logs, monitoring, backups, permissions, procedures, areas of responsibility and channels of communication between the teams.
2. Detection
You identify activity that requires attention, through alerts, log analysis, user reports or other sources.
3. Investigation & Triage
You examine the event: what happened, when, from which source, which systems were affected and whether there is evidence of real harm.
4. Containment
You try to stop or reduce the harm.
Depending on the case, you can isolate a system, cancel a Session suspected of being stolen, block traffic or turn on an additional protection mechanism.
5. Eradication & Recovery
You remove the cause of the problem, fix vulnerabilities and restore normal activity.
For example, if a permission vulnerability was found in an API, blocking an IP address alone is not a sufficient fix. The access control on the server has to be fixed as well.
6. Lessons Learned
You check what worked, what we missed, which alerts were missing and which changes will improve the preparation for next time.
The incident response process chart
- Preparing in advance: logs, monitoring, procedures — leads to: Detecting suspicious activity
- Detecting suspicious activity — leads to: Investigation and triage
- Investigation and triage — leads to: Does the event require handling?
- Does the event require handling? — leads to: Documentation and continued monitoring; Containing the activity
- Documentation and continued monitoring
- Containing the activity — leads to: Handling the cause and recovery
- Handling the cause and recovery — leads to: Lessons learned and improved defenses
- Lessons learned and improved defenses
Source code of the diagram (Mermaid)
flowchart TD
A[Preparing in advance: logs, monitoring, procedures] --> B[Detecting suspicious activity]
B --> C[Investigation and triage]
C --> D{Does the event require handling?}
D -->|No| E[Documentation and continued monitoring]
D -->|Yes| F[Containing the activity]
F --> G[Handling the cause and recovery]
G --> H[Lessons learned and improved defenses]The process is cyclical: the lessons flow back into the preparation, and even an event that was documented without further handling keeps feeding the monitoring.
Professional note: NIST's current publication on the subject, SP 800-61 Revision 3 from April 2025, replaced the 2012 edition. It integrates incident response into the organization's cybersecurity risk management, according to the CSF 2.0 framework, and covers preparing for incidents and the detection, response and recovery activities.
What is a WAF and what can you configure in it?
WAF — Web Application Firewall is a mechanism that inspects HTTP/HTTPS traffic intended for Web applications, and acts according to filtering rules that have been defined.
You can think of it as a guard standing on the way to the application.
Before a request reaches the Backend code, it can check certain characteristics of the request and decide whether to pass it on, block it, monitor it or challenge the client.
Examples of WAF rules
| Rule type | Example |
|---|---|
| URL path | Limiting requests to /api/admin/* |
| IP address | Blocking an address identified as a source of malicious activity |
| Geographic location | Limiting requests by the estimated country of origin |
| HTTP Method | Allowing only certain methods for a path |
| Rate Limiting | Limiting the number of requests in a time window |
| Request content | Identifying patterns typical of attempts to exploit vulnerabilities |
| Bot Detection | Identifying, filtering or challenging automated activity |
Rules can include more than one condition. For example, limiting access to an administrative path from a certain range of addresses and turning on additional rate limiting. In AWS WAF, the collection of rules attached to a protected resource is called a Web ACL.
It is important to understand: a WAF is not a substitute for permission checks in the code.
If the WAF lets a request through, the server still has to check who the user is, which action the user is asking to perform and whether the user is authorized to perform it on the relevant resource.
These are different layers of protection.
What happens when the WAF identifies a request that matches a rule?
In AWS WAF there are, among others, the following actions:
| Action | Meaning |
|---|---|
Allow |
Lets the request continue to the protected resource |
Block |
Blocks the request |
Count |
Counts the request without deciding whether to allow or block it, and continues to the next rules |
CAPTCHA |
May show the client a puzzle, to tell a person apart from a bot |
Challenge |
May run a silent check in the browser, without a puzzle, to tell a regular browser apart from a bot |
In AWS WAF, the Block action returns 403 Forbidden by default, if no custom response has been configured.
But does every 403 prove that the WAF blocked the request?
Not at all.
When the user sees a 403 - what really happened?
This is one of the important practical distinctions I learned.
A 403 Forbidden response says that the request was refused, but not necessarily who refused it.
For example, it can be produced by:
- A rule in the WAF.
- A setting in the Apache server or in another Web server.
- A permission check in Middleware.
- The application code itself.
From the user's point of view, the result may look similar.
From the investigation's point of view, the difference is huge.
This is how the layers are divided in a typical case
- User sends an HTTP request — leads to: AWS WAF / Load Balancer
- AWS WAF / Load Balancer — leads to: Does the WAF block?
- Does the WAF block? — leads to: Response to the client, for example 403; Apache / Web Server
- Response to the client, for example 403
- Apache / Web Server — leads to: Middleware
- Middleware — leads to: API / Business Logic
- API / Business Logic — leads to: Response to the client
- Response to the client
Source code of the diagram (Mermaid)
flowchart TD
U[User sends an HTTP request] --> W[AWS WAF / Load Balancer]
W --> Q{Does the WAF block?}
Q -->|Yes| X[Response to the client, for example 403]
Q -->|No| A[Apache / Web Server]
A --> M[Middleware]
M --> P[API / Business Logic]
P --> R[Response to the client]If the WAF blocked the request before it reached Apache, it will not appear in Apache's access log, nor in the PHP logs.
In contrast, the WAF logs can include the action that was taken and the details of the rule that matched the request.
In AWS WAF, when logging is turned on, the logs can be sent to services such as CloudWatch Logs, S3 or Firehose.
Where do you look for the reason for the block?
| Source | What can it reveal? |
|---|---|
| The HTTP response on the user's side | Which code was received, and sometimes headers and response details |
| AWS WAF Logs | Which action was taken and which rule decided |
| Load Balancer Access Logs | Whether the request was blocked at the infrastructure layer or passed on to the server |
| Apache Access/Error Logs | What reached the Web server and how it handled the requests |
| Application Logs | What happened inside the application, if the request reached it |
Not every one of these types of logs is necessarily turned on in every system. You need to know the architecture and the monitoring settings in practice.
From the lab to the real world: when the protection blocked us
One of the intriguing things in this learning was the connection to a case I had already experienced at work.
Certain files could not be uploaded through an API in production. In the test environment the same action succeeded, and under other circumstances production could also accept the files.
The user received a 403 error.
We started investigating.
We checked the system's behavior, compared environments and tried to find signs of the requests that had failed.
But in the Apache and PHP logs there were no traces of those requests.
This raised a hypothesis: maybe the request does not reach the Backend at all?
Further inquiry with the infrastructure team led to AWS WAF, which ran in front of the application: a size limit configured in it was blocking legitimate requests.
After the setting was adjusted, the action worked again.
What did I learn from this case?
Not every blocked request is an attack attempt.
And not every 403 error means that the user lacks permissions.
Sometimes a security mechanism identifies legitimate activity as suspicious and blocks it. This is called:
The opposite situation, dangerous activity that was not detected, is called False Negative.
That is why, when you change a security rule, it is important to verify two things:
- That the legitimate requests that are supposed to succeed really do succeed.
- That the dangerous activity the rule was meant to stop is still blocked.
This story made it clearer to me that security work is not only building walls. It is also understanding the consequences of every wall we build.
How can this be tested in practice on our own system?
On a system we own, or one we have explicit permission to test, you can build a controlled testing process:
-
Define a scenario: for example, a certain request is supposed to be blocked by a WAF rule, while another, legitimate request is supposed to continue to the server.
-
Document the expected result: which HTTP code should be received? Which rule should match? Is the request supposed to reach the Backend?
-
Run a controlled test: send test requests in an authorized test environment, with a small, defined amount of traffic.
-
Compare the sources of information: check the client's response, the WAF records and the application logs.
-
Check for wrong blocks: make sure that the rule does not block normal actions that we did not intend to restrict.
What not to do: do not decide from a 403 code alone which component blocked; do not settle for a status showing that the rule was turned on without checking what it actually does; do not treat blocking an IP address as a substitute for fixing the access control on the server; and do not send test requests to a system that there is no explicit permission to test.
The goal is not just to see a 403 error.
The goal is to know which component returned it, why it returned it, and whether this is the behavior we wanted to get.
Review questions — with answers
8 questions. Select a question to open its answer.
Question 1: What is the main difference between Offensive Security and Defensive Security?
Answer: Offensive security focuses on authorized testing to find vulnerabilities. Defensive security focuses on preventing harm, detecting suspicious activity, investigating and responding to security incidents.
Question 2: Does a large number of requests to unknown paths prove that an attack took place?
Answer: No. It is a pattern that may raise a suspicion of scanning, but it can also come from an authorized security test or from legitimate automated activity. The context needs to be checked.
Question 3: Why is it not enough to block the suspicious IP address?
Answer: Because the source of the requests can change. Detecting behavior patterns, rate limiting and additional mechanisms may provide complementary layers of protection.
Question 4: Does a 403 prove that the user failed a permission check in the application?
Answer: No. The same code may come from a WAF, from the Web server or from the application code. You need to investigate the source of the response.
Question 5: Why will a request that a WAF blocked not necessarily appear in the Apache logs?
Answer: If the WAF sits in front of Apache and rejected the request, the request never reached the Web server. In such a case you need to check the logs of the infrastructure layer.
Question 6: What is the difference between Rate Limiting and detecting suspicious activity?
Answer: Rate Limiting limits the rate of requests according to a defined policy. Detecting suspicious activity tries to understand whether the requests or the pattern of action indicate a risk. Activity may look suspicious even if it stays within the rate limit.
Question 7: What is a False Positive?
Answer: A situation in which a detection mechanism marks legitimate activity as suspicious or malicious. In a WAF this may cause users and valid requests to be blocked.
Question 8: Is every alert a security incident?
Answer: No. An Event is something that happened in the system and was recorded, an Alert is an event or pattern that met a condition defined as suspicious, and an Incident is an event that, according to the investigation, requires a response. Not every Event is an Alert, and not every Alert is an Incident.
Appendix for anyone meeting these concepts for the first time
There is no need at all to know all the technical terms in advance. Some of them sound complicated mainly because they are new.
What is an IP Address?
An IP address is an identifier used to route communication on a network.
When a monitoring system shows the source address of a request, it gives the investigator an important clue about the origin of the traffic.
But an IP address is not necessarily the identity of the person who sent the request. It can belong to a shared network, to a Proxy, to a VPN or to a server that someone else operates.
What is a Log?
A log is a record of events that happened in a system.
For example, a Web server can record when a request was received, which path it was sent to and what the response code was.
A log is raw material for an investigation. It does not necessarily explain by itself what caused each event.
What is a WAF?
A firewall designed to inspect Web requests according to security rules.
It can block activity even before it reaches the application server.
What is a SOC?
The initials of Security Operations Center.
A team or an operation responsible for monitoring, detection, investigation and response to security incidents.
What is a SIEM?
The initials of Security Information and Event Management.
A system that collects security data from different sources, helps analyze it and can generate alerts about suspicious activity.
Glossary of chapter 02
| Term | Short explanation | Why remember it |
|---|---|---|
| Defensive Security | Protecting systems against harm and threats | The new hat I put on in the lab |
| SOC | A center for security monitoring and operations | The place where alerts are investigated |
| Security Event | An event recorded in the system | The raw material of monitoring |
| Alert | A notice of activity that may need checking | The starting point of the investigation |
| Security Incident | A security incident that requires handling according to the organization's definitions | Not every alert is an incident |
| Triage | Sorting and prioritizing alerts or findings | Knowing what to handle first |
| Investigation | Investigating the event and its context | Understanding what really happened |
| Incident Response | The process of responding to a security incident | From detection to recovery |
| Containment | Containing an incident in order to limit its impact | Stopping spread or harm |
| Recovery | Restoring services and normal activity | Getting back to safe activity |
| Log | A record that documents an event in the system | A basis for investigation |
| SIEM | A system for collecting and analyzing security events | Connects information from different sources |
| EDR | A system for detecting threats on endpoints and servers, and responding to them | One of the work tools of the defensive side |
| WAF | A firewall for Web applications | Filtering requests before the application |
| Web ACL | A collection of rules for controlling Web traffic | Defining WAF policy |
| Rate Limiting | Limiting the rate of requests | Control over load and traffic |
| IP Blocking | Blocking a source address | A targeted response to a source |
| Behavior-based Detection | Detection based on behavior patterns | May detect activity even from changing sources |
| False Positive | Legitimate activity mistakenly marked as suspicious | A possible source of wrong blocks |
| False Negative | Dangerous activity that was not detected | A reminder that monitoring is not perfect |
| Application Load Balancer | A component that receives requests and routes them to targets | Part of the infrastructure architecture |
| Middleware | A layer of code that processes requests before the next components of the application | A possible place for security checks |
| HTTP 403 | A response that indicates a refusal of the request | You need to find out who returned it |
Where to next?
In the first two rooms on TryHackMe I experienced two sides of the same world.
On the offensive side I discovered a hidden path and checked what could be done through it.
On the defensive side I received an alert about similar attempts, investigated them and turned on containment measures.
But the most important message I take from both rooms is not tied to any particular tool.
It is not enough to know which command to run or which rule to turn on. You need to understand what we are checking, what our conclusion is based on, and what still requires verification.
In the next chapter I set out to discover which roles exist in the cyber world, what the difference between them is, and where my place might be.
And maybe, after everything I have learned so far, the question is no longer Is there a place for me in this world?
But rather: What place do I want to build for myself in it?
Sources for further reading and checking
An email for every new post
A short message with a link whenever a new post is published. Signing up needs a confirmation through a link sent to the address.