* | eval ip1="10.10.0.100", ip2="100.10.0.100"
| eval network1=if(cidrmatch("10.10.0.0/24", ip1),"local", "external"),
network2=if(cidrmatch("10.10.0.0/24", ip2),"local", "external")
| table ip1, network1, ip2, network2
match(filename, “malicious.exe”)
match(filename, “(.jpg|.gif|.png)$”)
NOT match(method, "(GET|POST|-)")
=> method가 GET, POST, - 인지 검사하고, method가 해당 문자열들을 가진다면 False, 가지지 않는다면 True 반환.
index=httplog sourcetype=httplog
| where NOT match(method, "(GET|POST|-)")
| stats count(src) as src_count by method
| sort - src_count
=> method가 GET, POST, - 가 아닌 것들 에서 + 송신지 주소의 개수를 count, count 개수를 src_count에 저장한다 + 저장된 src_count 값을 가준으로 내림차순 정렬한다.
사이트별로 분할되는 값이 각자 다르다. 보통 끝자락에서 사용자가 입력한 내용이 담길 수 있기에 mvindex를 사용한다. 즉, 사이트별 분할된 문자열이 각자 다르지만, 보통 사용자의 입력값이 분할된 문자열의 끝쪽에 위치하므로 이를 확인하기 위해 mvindex사용한다.
*| eval passwd_str="lightdm:x:107:117:Light Display M a n a g e r :/var/lib/lightdm:/bin/false"
| eval uid=mvindex(split(passwd_str,":"),0)
| eval subuid1=substr(uid,2)
| eval subuid2=substr(uid,2,4)
| table uid, subuid1, subuid2
Splunk에서 DNS 로그를 분석하기 위해 DNS 로그를 추가하고, 검색 한다.
splunk 로그인 - 우측 상단 설정 - 서버 설정 - 일반설정에서 웹 포트 지정 가능.
인덱스 설정 확인
업로드되는 로그 저장소를 확인한다.
인덱스 추가
dnslog 인덱스 추가.
인덱싱이란? 효율적 데이터를 관리하기 위해 데이터에 일련의 키나 번호를 할당하는 과정
$SPLUNK_DB\dnslog\db 경로는 C:\Program Files\Splunk\var\lib\splunk 경로에 존재한다. (Splunk를 C드라이브 설치 시)
ts,uid,src,spt,dst,dpt,proto,trans_id,rtt,domain,qclass,qclass_name,qtype,qtype_name,rcode,rcode_name,AA,TC,RD,RA,Z,answers,TTLs,rejected 추가
Splunk Source type & 인덱스 추가 목적
SourceType : 로그를 분류하는 필드 추가
인덱스 : 데이터에 키/번호를 할당
splunk에서는 로그 추가 시, SourceType, 인덱스를 직접 설정해 로그 검색 효율성 증가시켜준다.
<<URL Toolbox가 지원하는 매크로>>
- ut_netloc : 전체 도메인을 보여줌
- ut_domain : 서브도메인을 제외한 도메인 명을 보여줌
- ut_subdomain : 서버 도메인만 보여줌
- ut_tld: 도메인에서 utl값만 보여줌
네트워크 접속 행위 분석 목적으로 DNS 로그를 분석한다.
C&C(Command and Control) 서버를 사용해 악성코드에 감염된 PC를 공격자가 조정한다.
C&C(Command and Control) 서버 : 악성 소프트웨어로 명령, 제어하는 중앙 서버
많은 접속 도메인 == 1.다수의 많은 접속. 2.소수 많은 접속.
두번째 경우 : 자동화된 프로그램사용 추측.
-> 현황 분석으로 이상 징후 유추.
현황 분석은 숫자를 보여준다, 해당 숫자로부터 이상 징후 유추.
domain!="*.arpa" domain!="-" : Reverse 도메인 제외 또는 Domain 필드가 공백(-)인 경우 제외
| eval list="mozilla"
| `ut_parse(domain,list)` : mozilla에서 지정한 형식으로 도메인을 파싱한다.
| top showperc=f limit=10 ut_netloc : 10개 도메인을 추출해 전체 도메인(ut_netloc)을 보여준다. 이때, 데이터 점유 비율을 숨긴다(showperc=f)
TLD(List of Internet top-level domains) 목록은 mozilla에서 지정한다
index=dnslog sourcetype=dnslog domain!="-"
| eval list="mozilla"
| `ut_parse(domain,list)`
| table ut_netloc, ut_domain, ut_subdomain, ut_domain, ut_domain_without_tld, ut_tld
| dedup ut_netloc : 중복성 제거, 대표적 1개만 추출
검색문 사용
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
| eval Outbound=round(Outbound/(1024*1024),2)
| eval Inbound=round(Inbound/(1024*1024),2)
| sort Outbound desc
| head 10
round(Outbound/(1024*1024),2) : 소수 2번째 자리까지 MB 단위로 반환
uri : index.html 을 의미한다. 무시한다는 의미
index=httplog sourcetype=httplog uri!="-" uri!="/"
(status_code >=400 AND status_code < 500)
| top domain, status_code limit=10 showperc=f
index=httplog sourcetype=httplog resp_mime_types="application/x-dosexec" uri!="-“ : 전송파일 mime type이 application/x-dosexec이고, uri가 공백이 아닌 것들을 대상으로 수집
| eval filename1=mvindex(split(uri,"/"),-1) : url를 "/" 기준으로 나눈 후, -1번째 값을 반환 -> 마지막 uri 만 가져와 filename1에 지정
| eval filename=if(like(filename1,"%?%"), mvindex(split(filename1,"?"),0),filename1)
| eval filetype=if(match(filename,"(.exe|.bat|.ps1|.dll|.ocx)$"), "PE", "Not_PE")
| table domain, uri, filename, filetype, resp_mime_types
| where filetype=="Not_PE"
| dedup filename
세부내용
| eval filename1=mvindex(split(uri,"/"),-1)
| eval filename=if(like(filename1,"%?%"), mvindex(split(filename1,"?"),0),filename1)
두 조건이 끝나면, filename에 파일명 검출 (test.txt, test.exe, 등)
HTTP uri & 질의 조건
공격자가 DBD 공격을 수행했다는 가정 하에 피해자는 정상적인 사이트 경로로 접속한다. 이때 악성 스크립트로 인해 중계지를 거쳐 유포지로 리다이렉트. 이후 실행파일 다운로드 실행한다. 이때 이 다운로드 로그 기록을 검색한다.
경유지는 referer 필드로 인덱싱 된다.
첨부된 파일이 실행파일이라면 exe
|dll
|com
|src
중 하나를 match한다.
splunk 검색 명령어
index=httplog sourcetype=httplog referrer!="-" status_code=200 : referrer(Host 접속 시 경유주소) 공백이 아니고 상태코드가 200 출력
| eval filename1=mvindex(split(uri,"/"),-1)
| eval filename=if(like(filename1,"%?%"), mvindex(split(filename1,"?"),0),filename1)
| where cidrmatch("0.0.0.0/0",domain) : domain이 0.0.0.0/0 범위에 포함되면 참 (참 인 것들만 사용)
| where match(resp_mime_types,"application/x-dosexec") OR match(filename,"(exe|dll|com|src)$") : Mine type 또는 실행파일인 경우에만 참
| eval URL=domain+" :: " + filename
| stats count by src, URL
| stats list(URL) as Target list(count) as Source by src
검색결과
해당 이벤트 확인
이걸 또 볼줄이야