Communitygithub.com

Linux 감사 로그 분석을 통한 침입 탐지

Linux Audit 프레임워크(auditd)와 ausearch, aureport 유틸리티를 사용하여 침입 징후를 분석합니다.

Linux 감사 로그 분석을 통한 침입 탐지란 무엇인가요?

이 스킬은 Linux Audit 프레임워크(auditd)를 활용하여 호스트 기반 침입 탐지를 수행하는 방법을 상세히 설명합니다. 시스템 관리자, 보안 분석가 및 침해 대응 담당자가 의심스러운 접근, 권한 상승, 악성 코드 설치, 지속성 메커니즘 등 침입 징후를 식별할 수 있도록 안내합니다. Claude Code, Cursor, Codex와 같은 AI 에이전트 플랫폼에서 실행 가능하며, auditd 상태 확인, 침입 탐지 감사 규칙 배포, ausearch를 이용한 이벤트 검색, aureport를 통한 요약 리포트 생성, 공격 타임라인 재구성, 그리고 SIEM으로의 로그 전달에 이르기까지 전체 워크플로우를 제공합니다. 또한 취약점 스캐너와 달리 커널 수준에서 시스템 콜을 모니터링하는 감사 시스템의 특성을 강조하며, 실제 침해 사고 대응 시 체계적으로 증거를 수집하고 분석할 수 있는 실용적인 명령어와 기법을 제시합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-linux-audit-logs-for-intrusion

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Analyzing Linux Audit Logs for Intrusion (Linux 감사 로그 분석을 통한 침입 탐지)

사용 시점

  • Linux 호스트에서 의심스러운 무단 접근 또는 권한 상승이 의심될 때
  • 익스플로잇, 백도어 설치 또는 지속성 메커니즘의 증거를 추적할 때
  • 시스템 콜 모니터링을 요구하는 보안 기준(CIS, STIG, PCI-DSS) 준수 여부를 감사할 때
  • 침해 대응 과정에서 공격자의 행동 타임라인을 재구성할 때
  • /etc/passwd, /etc/shadow 또는 SSH 키와 같은 중요 시스템 파일의 변조를 탐지할 때

네트워크 수준 침입 탐지에는 사용하지 마십시오. 네트워크 트래픽 분석은 Suricata 또는 Zeek를 사용하십시오. auditd는 개별 호스트의 커널 수준에서 작동합니다.

사전 요구 사항

  • auditd 패키지가 설치되고 감사 데몬이 실행 중인 Linux 시스템 (systemctl status auditd 확인)
  • 감사 규칙을 구성하고 로그를 조회할 수 있는 root 또는 sudo 액세스 권한
  • /etc/audit/rules.d/*.rules를 통해 배포되었거나 auditctl로 로드된 감사 규칙
  • 권장 사항: 포괄적인 기준 범위를 위해 GitHub의 Neo23x0/auditd 규칙 세트
  • Linux 시스템 콜(execve, open, connect, ptrace 등)에 대한 이해
  • 충분한 보존 기간을 가진 로그 저장소 (기본 위치: /var/log/audit/audit.log)

워크플로우

1단계: 감사 데몬 상태 및 구성 확인

감사 시스템이 실행 중인지 확인하고 현재 규칙 세트를 확인합니다:

# auditd 서비스 상태 확인
systemctl status auditd

# 커널에 로드된 현재 감사 규칙 표시
auditctl -l

# 감사 데몬 구성 표시
cat /etc/audit/auditd.conf | grep -E "log_file|max_log_file|num_logs|space_left_action"

# 감사 백로그 초과 여부 확인 (이벤트 누락)
auditctl -s

백로그 한도에 도달하는 경우 증가시킵니다:

auditctl -b 8192

2단계: 침입 탐지 중심 감사 규칙 배포

일반적인 침입 지표를 대상으로 하는 규칙을 추가합니다. /etc/audit/rules.d/intrusion.rules 파일에 배치합니다:

# 자격 증명 파일의 무단 읽기 또는 수정 모니터링
-w /etc/passwd -p wa -k credential_access
-w /etc/shadow -p rwa -k credential_access
-w /etc/gshadow -p rwa -k credential_access
-w /etc/sudoers -p wa -k privilege_escalation
-w /etc/sudoers.d/ -p wa -k privilege_escalation

# SSH 구성 및 인증 키 모니터링
-w /etc/ssh/sshd_config -p wa -k sshd_config_change
-w /root/.ssh/authorized_keys -p wa -k ssh_key_tampering

# 사용자 및 그룹 관리 명령 모니터링
-w /usr/sbin/useradd -p x -k user_management
-w /usr/sbin/usermod -p x -k user_management
-w /usr/sbin/groupadd -p x -k user_management

# ptrace를 통한 프로세스 인젝션 탐지
-a always,exit -F arch=b64 -S ptrace -F a0=0x4 -k process_injection
-a always,exit -F arch=b64 -S ptrace -F a0=0x5 -k process_injection
-a always,exit -F arch=b64 -S ptrace -F a0=0x6 -k process_injection

# 비정상적인 디렉토리에서 프로그램 실행 모니터링
-a always,exit -F arch=b64 -S execve -F exe=/tmp -k exec_from_tmp
-a always,exit -F arch=b64 -S execve -F exe=/dev/shm -k exec_from_shm

# 커널 모듈 로딩 탐지 (루트킷 설치)
-a always,exit -F arch=b64 -S init_module -S finit_module -k kernel_module_load
-a always,exit -F arch=b64 -S delete_module -k kernel_module_remove
-w /sbin/insmod -p x -k kernel_module_tool
-w /sbin/modprobe -p x -k kernel_module_tool

# 리버스 셸을 위한 네트워크 소켓 생성 모니터링
-a always,exit -F arch=b64 -S socket -F a0=2 -k network_socket_created
-a always,exit -F arch=b64 -S connect -F a0=2 -k network_connection

# cron 작업 수정 탐지 (지속성)
-w /etc/crontab -p wa -k cron_persistence
-w /etc/cron.d/ -p wa -k cron_persistence
-w /var/spool/cron/ -p wa -k cron_persistence

# 로그 삭제 또는 변조 모니터링
-w /var/log/ -p wa -k log_tampering

편집 후 규칙을 다시 로드합니다:

augenrules --load
auditctl -l | wc -l   # 규칙 개수 확인

3단계: ausearch로 침입 지표 검색

ausearch를 사용하여 특정 이벤트에 대한 감사 로그를 조회합니다:

# 지난 24시간 동안의 모든 실패한 로그인 시도 검색
ausearch -m USER_LOGIN --success no -ts recent

# 특정 사용자가 실행한 명령 검색
ausearch -ua 1001 -m EXECVE -ts today

# /etc/shadow에 대한 모든 파일 액세스 이벤트 검색
ausearch -f /etc/shadow -ts this-week

# sudo를 통한 권한 상승 검색
ausearch -m USER_CMD -ts today

# 커널 모듈 로딩 이벤트 검색
ausearch -k kernel_module_load -ts this-month

# /tmp에서 실행된 프로세스 검색 (일반적인 공격 스테이징)
ausearch -k exec_from_tmp -ts this-week

# SSH 키 수정 검색
ausearch -k ssh_key_tampering -ts this-month

# 특정 감사 이벤트 ID로 이벤트 검색
ausearch -a 12345

# 특정 시간 범위 내 이벤트 검색
ausearch -ts 03/15/2026 08:00:00 -te 03/15/2026 18:00:00

# 시스템 콜 번호 해석 및 읽기 쉬운 형식으로 출력
ausearch -k credential_access -i -ts today

4단계: aureport로 요약 리포트 생성

aureport를 사용하여 심사 분석을 위한 집계 요약을 생성합니다:

# 모든 인증 이벤트 요약
aureport -au -ts this-week --summary

# 모든 실패한 이벤트 보고서 (로그인, 액세스 등)
aureport --failed --summary -ts today

# 실행 파일 실행 보고서
aureport -x --summary -ts today

# 모든 이상 징후 이벤트 보고서 (세그폴트, 프라미스큐어스 모드 등)
aureport --anomaly -ts this-week

# 파일 액세스 이벤트 보고서
aureport -f --summary -ts today

# 키별 모든 이벤트 보고서 (사용자 정의 규칙 키에 매핑)
aureport -k --summary -ts this-month

# 모든 시스템 콜 보고서
aureport -s --summary -ts today

# 사용자별로 그룹화된 이벤트 보고서
aureport -u --summary -ts this-week

# 타임라인 구축을 위한 상세 시간 기반 이벤트 보고서
aureport -ts 03/15/2026 08:00:00 -te 03/15/2026 18:00:00 --summary

5단계: 공격 타임라인 재구성

ausearch 쿼리를 결합하여 시간순 내러티브를 구축합니다:

# 5a단계: 초기 액세스 타임스탬프 식별
ausearch -m USER_LOGIN -ua 0 --success yes -ts this-week -i | head -50

# 5b단계: 공격자가 액세스 후 수행한 작업 추적
# 침해된 계정의 사고 시간대 내 모든 이벤트 가져오기
ausearch -ua <UID> -ts "03/15/2026 14:00:00" -te "03/15/2026 18:00:00" -i \
  | aureport -f -i

# 5c단계: 사고 시간대에 실행된 모든 명령 추출
ausearch -m EXECVE -ts "03/15/2026 14:00:00" -te "03/15/2026 18:00:00" -i

# 5d단계: 설치된 지속성 메커니즘 확인
ausearch -k cron_persistence -ts "03/15/2026 14:00:00" -i
ausearch -k ssh_key_tampering -ts "03/15/2026 14:00:00" -i

# 5e단계: 측면 이동 확인 (아웃바운드 연결)
ausearch -k network_connection -ts "03/15/2026 14:00:00" -i

6단계: 감사 로그를 SIEM으로 전달

audisp-remote 또는 auditbeat를 구성하여 로그를 중앙 SIEM으로 전송하여 상관 분석을 수행합니다:

# 옵션 A: audisp-remote 플러그인 사용
# /etc/audit/plugins.d/au-remote.conf 편집
active = yes
direction = out
path = /sbin/audisp-remote
type = always

# /etc/audit/audisp-remote.conf에서 원격 대상 구성
remote_server = siem.internal.corp
port = 6514
transport = tcp

# 옵션 B: Elastic Auditbeat 사용
# auditbeat 설치 및 /etc/auditbeat/auditbeat.yml 구성
# Auditbeat는 커널 감사 프레임워크에서 직접 읽습니다.

주요 개념

용어설명
auditd커널로부터 감사 이벤트를 수신하여 /var/log/audit/audit.log에 기록하는 Linux 감사 데몬
auditctl감사 시스템을 제어하는 명령줄 유틸리티: 규칙 추가/제거, 상태 확인, 백로그 크기 설정
ausearch메시지 유형, 사용자, 파일, 키, 시간 범위 또는 이벤트 ID로 감사 로그를 검색하는 쿼리 도구
aureport심사 분석 및 규정 준수를 위해 감사 이벤트의 집계 요약을 생성하는 보고 도구
감사 규칙 키 (-k)감사 규칙에 첨부되는 사용자 정의 레이블로, ausearch 및 aureport를 사용한 관련 이벤트의 빠른 필터링 가능
시스템 콜 감사프로세스 및 파일 활동을 캡처하는 시스템 콜(execve, open, connect, ptrace)의 커널 수준 모니터링
augenrules/etc/audit/rules.d/의 모든 파일을 /etc/audit/audit.rules로 병합하고 커널에 로드하는 유틸리티

확인

  • auditd가 실행 중이고 규칙이 로드되었음 (auditctl -l이 예상 규칙 개수 반환)
  • 감사 백로그 오버플로우 없음 (auditctl -s에서 backlog: 0 또는 낮은 값, lost: 0 표시)
  • 각 사용자 정의 키에 대해 ausearch가 이벤트를 반환함 (ausearch -k <key> -ts today가 결과 반환)
  • aureport가 인증, 실행 파일 및 파일 이벤트에 대해 비어 있지 않은 요약을 생성함
  • 타임라인 재구성이 공격자 행동의 일관된 시간순 순서를 생성함
  • 중요 파일 감시가 테스트 수정 시 알림을 트리거함 (touch /etc/shadow가 이벤트 생성)
  • 로그가 중앙 SIEM으로 전달되고 있음 (테스트 이벤트로 확인하고 수신 확인)
  • 감사 규칙이 재부팅 후에도 유지됨 (auditctl만이 아닌 /etc/audit/rules.d/에 규칙 존재)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

관련 스킬