수업

1/11: Splunk 명령어

진태현 2024. 1. 11. 11:24

Splunk

DNS 로그 실습환경 구성

- 로그들의 필드 지정 

- 데이터 추가 

- URL Tool 설치 

 

splunk에서 index

- 업로드 되는 로그들의 저장소

 

인덱스 추가

저장소 생성

 

DNS log

- 구성: tcp/ip 헤더 + query 헤더 + dns response header

 

필드 추가

- source type에서 필드명 지정

 

데이터 추가

- 지정한 소스타입 지정


분석 툴 설치 

- 앱 관리에서 URL Toolbox 설치 

 

*dns 설치구간

- DMZ구간, 인트라넷 사내망에 설치 가능 

- 사내망 직원들의 로그 분석은 DNS로그 분석으로 가장 좋은 데이터 소스

- 악성코드에 감염된 내부망PC 활동 분석 가능 > 공격자 찾아내는 용도로 사용가능 

 

1, Top10 도메인 현황

- 10분 동안 60번씩 요청할 경우 자동화된 조작으로 유추 가능 

 

index=dnslog sourcetype=dnslog domain!="-"
| eval list = "mozila"         >>변수명 지정 
| `ut_parse(domain,list)`    >> 
| table ut_netloc, ut_domain, ut_subdomain, ut_domain_without_tld, ut_tld
| dedup ut_netloc

 

사용자들이 가장 많이 접속한 도메인 10개를 검색
index=dnslog sourcetype=dnslog dpt=53 

domain!="*.arpa"  >> 역방향 조회는 전부 제외

domain!="-" >> 도메인 명이 명시 되지 않음 

- dnslog저장소에서 필드타입이 dnslog 중에서 수신지포트가 53
역방향 레코드는 제외하고 도메인명이 정상적이지 않은 로그들은 보지 않음
| eval list="mozilla" >> list에 mozilla값 부여 
| `ut_parse(domain, list)`>> 분할한 조건 중에서 
| top showperc=f limit=10 ut_netloc >> 상위 10개 출력 (* 기본적으로 10개) 

 

*teredo.ipv6.microsoft.com

- subdomain : teredo.ipv6

- domain : microsoft.com

- tld : com

- netloc : teredo.ipv6.microsoft.com

 

*dns, mail, web 서버 구축 해보기  

 

index=dnslog sourcetype=dnslog dpt=53 domain!="*.arpa" domain!="-"
| eval list="mozilla"
| `ut_parse(domain,list)`
| top showperc=f src, ut_netloc >> 수신지 ip 상위 10개 출력 

 

 

#좀비PC 여부 확인 명령어

index=dnslog sourcetype=dnslog domain!="-" rcode_name= "NXDomain"
| top showperc=f src, domain

 

index=dnslog sourcetype=dnslog domain!="-" 
| where NOT cidrmatch(domain, "0.0.0.0/0") >> 역방향 조회한 도메인은 검색하지 않음 ( 텍스트 주소 만 검색) 
| eval list="Mozilla"
| `ut_parse(domain, list)`
| where NOT match(domain,"(microsoft.com|akamaized.net| amazonaws.com)$") 

>> 도메인 주소 중에서 가상화를 지원해주는 사이트는 검색 대상에서 제외
| eval sub_len=len(ut_subdomain) >> 서브도메인길이
| search sub_len > 20 >> 서브도메인길이가 스무자 이상
| table ut_domain, ut_subdomain, sub_len, sut_netloc

 

#외부 DNS 사용 여부 확인 

index=dnslog sourcetype=dnslog (dst!="172.16.142.11" AND dst!="172.16.142.12") (src!="172.16.142.11" AND src!="172.16.142.12") 

>> DNS 로그 중에서 서버 DNS 로그는 제외
| stats count by dst >> 수신지 IP 
| sort - count

 


HTTP 네트워크 현황분석과 이상징후 분석

 

Splunk

1, 인덱스 설정

2, 데이터 추가 시에 설정한 인덱스 연결

 

index=httplog sourcetype=httplog domain!="(empty)" 
| iplocation dst 
| where NOT cidrmatch("0.0.0.0/0", domain) >> 텍스트 주소만 검색
| stats sum(request_body_len) as "Outbound", sum(response_body_len) as "Inbound" by domain, Country 

>> 도메인에 따라서 request body와 response 길이 총합

| eval Outbound=round(Outbound/(1024*1024),2)
| eval Inbound=round(Inbound/(1024*1024),2) 
| sort Outbound desc 
| head 10

 

* uri : / 

- index.html