수업

1/12

진태현 2024. 1. 11. 17:14

#송신자IP에서 접속한 메소드 종류별 개수

index=httplog sourcetype=httplog
| stats count(method) by src

 

#OPTIONS 요청 횟수가 10개 이상인 IP 주소만 필터링

index=httplog sourcetype=httplog
| stats count(eval(method="OPTIONS")) AS option_count by src
| where option_count > 10
| sort option_count desc

>> OPTIONS 많은 사용은 공격으로 구분할 수 있음 

 

#get, post, - 가 아닌 메소드 출력 

index=httplog sourcetype=httplog
| where NOT match(method, "(GET|POST|-)")
| stats count(src) as src_count by method
| sort - src_count

 

# 데이터 외부노출 검사

index=httplog sourcetype=httplog
(request_body_len!=0 OR response_body_len!="0") domain!="-" 
| stats sum(request_body_len) as outTotal sum(response_body_len) as inTotal by src, dst

>> IP 주소별로 인바운드와 아웃바운드 트래픽 합계 계산
| eval oMB=round(outTotal/(1024*1024),2) | eval iMB=round(inTotal/(1024*1024),2)

>>  MB 단위로 변환하고 소수점 2자리까지 반올림
| search oMB!=0 AND iMB!=0 | iplocation dst

| eval isUp=if((oMB/iMB)>1, "Yes","No") | where isUp="Yes"
| table src,dst, iMB, oMB, Country, City

 

#중요

index=httplog sourcetype=httplog resp_mime_types="application/x-dosexec" uri!="-“

>> Http 로그 분석 
| eval filename1=mvindex(split(uri,"/"),-1)
| 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

 

*Content-type

- response 

- request & response : body부분이있을 때 

 

request구조: 요청라인, 요청헤더, 공백, 본문

response 구조: 상태라인, 응답헤더 공백, 본문

 

https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=kbs   

- HTTP 도메인 : search.naver.com

- HTTP uri :  /search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=kbs   

- 파일경로: /search.naver

- DB에 질의 조건: ?~

 

index=httplog sourcetype=httplog referrer!="-" eventtype="dst_internet" status_code=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) 
| where match(resp_mime_types,"application/x-dosexec") OR match(filename,"(exe|dll|com|src)$") 
| eval URL=domain+" :: " + filename 
| stats count by src, URL 
| stats list(URL) as Target list(count) as Source by src

 

#Download by Database

index=httplog sourcetype=httplog referrer!="-" eventtype="dst_internet" status_code=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) 
| where match(resp_mime_types,"application/x-dosexec") OR match(filename,"(exe|dll|com|src)$") 
| eval URL=domain+" :: " + filename 
| stats count by src, URL 
| stats list(URL) as Target list(count) as Source by src

 

 

송신지 : 172.16.154.18

수신지 : 27.101.137.141

 

*프록시 서버 사용이유

- 보안: 서버, 클라이언트 IP를 숨기기위해 

- 트래픽 분산, 캐시, 보안

- 취약점 분석, 웹구조 파악

 

index=httplog sourcetype=httplog (uri="http://*" OR method="connect")

>> method =="connect"는 proxy서버를 쓰는 로그들을 보는 것

>> uri

| table src, domain, uri

 

*Proxy를 통해 현재 도메인에 접속했는지 파악하는 방법

- method가 connect인지

- uril :  모든 주소가 나타나는 경우

 


Endpoint

- 더이상 부착되는 시스템이 없는 부분 

- 윈도우 시스템을 사용하는 사용자 

 

sysmon

- 프로세스생성, 네트워크 연결, 파일 생성 시간 변경 등 정보를 추출

- 윈도우 이벤트 저장소에 저장 

- 이벤트 기반 정보가 아니고, 행동 기반 정보를 수집에서 이벤트 뷰어에 저장

기능

- 실행 프로세스와 부모 프로세스의 전체 명령 줄을 로그로 저장 

 

sysmon 설치

 

Splunk 저장소 경로: C:\Program Files\Splunk\var\lib\splunk

 

C:\Program Files\Splunk\etc\apps\search\local

 

#악성 실행파일 검색

index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1

(CurrentDirectory!="*Program FIles*" AND CurrentDirectory!="*system32*")
(Image!="*system32*" AND Image!="*Program FIles*" AND Image!="*SysWOW64*")
[search index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| rare CurrentDirectory limit=10 showperc=f showcount=f]
| table Image

 

*프로그램 : 하드디스크에 저장된 소스코드

프로세스: 프로그램 + CPU +RAM ==> 실행중인 프로그램

 

loading : 하드디스크에 저장되어 있는 파일이 램으로 이동하는 작업 

saving: 램에 있는 것을 하드디스크에 옮기는 작업 

 

# 삭제 명령(del)을 포함하는 프로세스 생성 이벤트를 탐지하는 명령어

index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 ParentImage="C:\\windows\\explorer.exe"
[search index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" 
 | where NOT isnull(Image) AND NOT isnull(ParentImage)
 | search CommandLine="* del *"
 | table ParentImage
 | rename ParentImage AS Image
] | table Image

 

# 의심스러운 네트워크 활동을 보이는 프로세스를 탐지하는 명령어

index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 
(Image!="C:\\Windows*" AND Image!="*Program FIles*")

>실행 관련된 로그는 제외
[search index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational"  EventCode=3
 (DestinationIp!="10.0.0.0/8" AND DestinationIp!="172.16.0.0/12" AND DestinationIp!="192.168.0.0/16")
 | stats count(DestinationIp) AS total_count dc(DestinationIp) AS uniq_count by Image
 | where total_count > 50 OR uniq_count > 20 
 | table Image]
| table Image

 

index=sysmon sourcetype="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1 
| where match(Image, "netsh.exe$")
| where NOT isnull(ParentImage)
| table ParentImage, Image, COmmandLine


IDS (시그니처와 일치하는 패킷을 로그로 새엇ㅇ)

SIEM ( 로그로 분석

즉, SIEM으로 IDS가 생성한 로그를 분석가능 

'수업' 카테고리의 다른 글

1/16  (0) 2024.01.16
1/15 - 보안관제 이해 및 실무  (0) 2024.01.15
1/11: Splunk 명령어  (0) 2024.01.11
1/10  (0) 2024.01.10
1/9  (0) 2024.01.09