> For the complete documentation index, see [llms.txt](https://h08.gitbook.io/undefined/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://h08.gitbook.io/undefined/custom-rule-and-active-response/1./1.1-gobuster.md).

# 1.1 공격 도구 탐지 (Gobuster)

## 1. 개요

* 웹 디렉토리 스캔 도구 Gobuster 사용을 탐지

***

## 2. 룰&#x20;

### 100420 / 100421

```xml
group name="web,attack_attempt">
 <!--detected once-->
 <rule id="100420" level="5">
 <decoded_as>apache-user-agent</decoded_as>
 <field name="user_agent" type="pcre2">(?i)gobuster</field>
 <description>[Web Scan] Gobuster tool detected in access log</descriptio
n>
 <mitre>
 <id>T1595.002</id>
 </mitre>
 </rule>
 <!--frequently detected-->
 <rule id="100421" level="12" frequency="10" timeframe="3">
 <if_matched_sid>100420</if_matched_sid>
 <description>[Web Scan] Gobuster activity repeatedly detected (10 times i
n 3s)</description>
 <mitre>
 <id>T1595.002</id>
 </mitre>
 </rule>
</group>

```

***

## 3. 환경 설정

### 3.1 Manager

* /var/ossec/etc/decoders/

  ```xml
  decoder name="apache-user-agent">
   <prematch>HTTP/1.1|Mozilla|curl|gobuster</prematch>
   <regex type="pcre2">^(\d+\.\d+\.\d+\.\d+) - - \[[^\]]+\] "\S+ (\S+) HTTP/
  \d\.\d" (\d{3}) \d+ "[^"]*" "([^"]+)"$</regex>
   <order>srcip, url, status, user_agent</order>
  </decoder>
  ```

  * User-Agent 등의 필드를 정확히 잘라내기 위한 파싱 규칙을 정의한다
  * prematch를 통해 우선순위를 높인다
* 위 xml 룰 설정

### 3.2 Agent&#x20;

* /var/ossec/etc/ossec.conf/

  ```xml
  <localfile>
    <log_format>apache</log_format>
    <location>/var/log/apache2/access.log</location>
  </localfile>

  <localfile>
    <log_format>nginx</log_format>
    <location>/var/log/nginx/access.log</location>
  </localfile>
  ```

  * Apache 웹 로그를 실시간으로 읽어서 서버로 보내도록 설정

***

## 4. 작동 원리

1. 공격 실행

* 공격자가 `Gobuster` 도구를 사용하여 웹 서버(Target)에 대량의 HTTP 요청을 전송시, 웹 서버의 접근 로그(Access Log)에는 클라이언트 정보를 식별하는 `User-Agent` 필드에 도구의 이름이 남게 된다.

  ```
  192.168.1.100 - - [05/Feb/2026:10:00:00 +0900] "GET /admin HTTP/1.1" 404 432 "-" "Gobuster/3.1.0"
  ```

2. 로그 수집

* Wazuh Agent는 실시간으로 웹 서버의 로그 파일(`/var/log/apache2/access.log`)을 모니터링한다.
* 새로운 로그가 기록되면 이를 즉시 Wazuh Manager로 전송한다

3. 단일 패턴 탐지

* Wazuh Manager는 수신된 로그를 디코딩하여 분석한다
* Rule 100420은 로그 내의 `User-Agent` 문자열을 검사하여 `Gobuster`라는 키워드가 포함되어 있는지 확인하여 매칭될 경우, 경보를 발생시킨다

4. 빈도 분석 및 임계치 초과 탐지

* 단일 탐지만으로는 오탐일 가능성이 있거나 위험도가 낮을 수 있으므로, Rule 100421이 연계 동작한다
* 동일한 소스 IP(`same_source_ip`)에서 짧은 시간(`timeframe`) 내에 Rule 100420이 설정된 횟수(`frequency`) 이상 반복해서 발생하면, 이를 본격적인 공격 시도로 간주하고 Level 12의 고위험 경보를 발생시킨다

<figure><img src="https://3550524140-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMQqlpxjtA7kpPBgieO9x%2Fuploads%2FX5qjpV1PV5gKF2zJzpsG%2Fimage.png?alt=media&amp;token=f806bd6a-52a6-4ffa-9b26-d38823e57e7d" alt=""><figcaption></figcaption></figure>
