Skip to content

minority opinions

Menu
  • Home
  • 꿀팁정리 & 자기계발
  • 기술 정보 & 테크 소식
  • 이슈 뉴스 정리
  • 주식 경제
  • Tags
Menu

elasticsearch lucene Query 활용예

Posted on 12월 23, 20177월 7, 2023 by Daniel J.

Elasticsearch Query Example

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

1. 엘라스틱서치는 lucene 이라는 검색 엔진 오픈 소스를 내장하고 있음.

2. Lucene Query 문법  (몇 가지만 알고 있으면 누구나 쉽게 검색 가능)

  AND <- 그리고 

  OR   <- ~이거나 

  NOT <- 아닌것

  아래도 동일한 의미 둘중 편한것으로 사용하면됨.

  && <- AND

  ||    <-  OR

  !     <- NOT

 * null 값이 없는것 예: source.country_code2 국가코드가 없는것은 제외하고 싶을때 

   _exists_:source.country_code2

  이외에도 다양한 문법이 있으나 자세한건 http://www.lucenetutorial.com/lucene-query-syntax.html  참조.

  위에 3가지만 숙지하고 있어도 대부분의 찾고자 하는 보안이벤트 로그 검색은 가능함.

3. 사용 예 (elastic query example)

* 현재 ArcSight ->  ELK STACK  (FW,IPS,WAF,VPN 등)  모든 보안 이벤트 로그를 받고 있음

Query : source.country_code2:CN  

설명 : 전체 로그중 출발지 국가가 중국인 로그만 검색

Query : destination.country_code2:(BR OR CN OR IL) AND sourceAddress:”1.24.13.0/24″

설명 : 목적지 국가가 “브라질” 이거나 “중국” 이건 “이란” 그리고 출발지가 1.24.13.0 c클래스 IP 대역만 검색

Query : !destination.country_code2:(KR || US) AND !destinationPort:(25 || 53 || 80 || 443 || 161 || 5518)  && deviceAction:Permit && !name:”FIN Port Scan” && !deviceProduct:A01IPS

설명 : 목적지가 한국 미국이 아니며, 목적지 포트가 25, 53, 80등이 아니고 장비에서 Permit 된것만 그리고 A01IPS  가 아니며 / FIN Port Scan이 아닌것만 검색

Query : !destination.country_code2:(KR || US || JP) && deviceAction:(Permit || accept) && !destinationAddress:(“10.0.0.0/8” || “192.168.0.0/16” ||  “172.0.0.0/8”) && !destinationPort:(80 || 25 || 2048 || 53 || 161 || 443 || 445 || 137 || 123) && !transportProtocol:ICMP

설명 : 목적지가 한국,미국,일본 이 아니고 특정 대역을 제외한 특정 포트를 제외, 그리고 icmp를 제외한것만 출력.

검색 쿼리에 익숙해지면 응용 범위가 다양해지며, 보안 이슈 대응에 대한 로그 검색 시간도 단축.

4. 보안 장비별 쿼리들 

Firewall 

NAVFW01 1구역존

NAVFW02 1구역존

NAV2FW01 2구역존2차

NAV2FW02 2구역존2차

DMZFW01 DMZ1차

DMZFW02 DMZ2차

deviceHostName:(NAVFW01 || NAVFW02 || DMZFW01 || DMZFW02 || NAV2FW01 || NAV2FW02) && deviceAction:accept

deviceHostName:(NAVFW01 || NAVFW02 || DMZFW01 || DMZFW02 || NAV2FW01 || NAV2FW02) AND deviceAction:accept AND !destinationPort:(5052 OR 53 OR 110 OR 161 OR 123 OR 2048)

deviceHostName:(NAVFW01 || NAVFW02 || DMZFW01 || DMZFW02 || NAV2FW01 || NAV2FW02) AND !destination.country_code2:KR AND !destinationPort:(5052 OR 53 OR 110 OR 161 OR 123 OR 2048) AND deviceAction:accept

2구역존2차 방화벽

deviceAddress:(NAV2FW01 || NAV2FW02) && !destination.country_code2:(US OR KR) && !destinationPort:(25 || 443 || 80) && !sourceAddress:”10.0.0.0/8″ && !destinationAddress:”10.0.0.0/8″ && deviceAction:(accept || Permit)

-> 10.0.0.0/8 은 사용자 IP대역을 제외한것

사용자 PC 네트워크대역 -> 외부 통신

sourceAddress:”10.10.120.0/24″  && deviceAction:(Permit || accept) && !destinationAddress:(“10.0.0.0/8” || “192.168.0.0/16”) && !destination.country_code2:KR && !destinationPort:(80 || 443 || 53 || 6548 || 1233 || 123)


IPS

특정 서비스 구역 IPS -> IPSA xxx존 IPSB xxx존

사용자존 IPS -> UserIPS1 UserIPS2

ETC IPS  / ETCIPSA || ETCIPSB

deviceHostName:(UserIPS1 || UserIPS2) &&  deviceAction:Permit && !sourceAddress:(12.x.x.147 || 12.x.x.157)

deviceHostName:(UserIPS1 || UserIPS2) &&  deviceAction:Permit && !deviceEventClassId:(0183 || 0003 || 0014) && !sourceAddress:(12.x.x.147 || 12.x.x.157)

deviceHostName:(UserIPS1 || UserIPS2) &&  deviceAction:Permit && !name:”FIN Port Scan” && !sourceAddress:(12.x.x.147 || 12.x.x.157) && deviceEventClassId:2242

deviceHostName:(UserIPS1 || UserIPS2) &&  deviceAction:Permit && !name:”FIN Port Scan” && !sourceAddress:(12.x.x.147 || 12.x.x.157) && deviceEventClassId:2242 && !destination.country_code2:KR

deviceProduct:UserIPS && deviceSeverity:High && !destination.country_code2:(KR || US) && !sourceAddress:12.x.x.147 && !name:(SNMP* || DRDOS*)

deviceHostName:(UserIPS1 || UserIPS2) &&  deviceAction:Permit  && !deviceEventClassId:(0183 || 0014 || 0003 || 0182)

deviceVendor:TippingPoint && deviceAction:Permit && deviceAddress:11.x.x.160 && deviceHostName:ETCIPSB

deviceVendor:TippingPoint && deviceHostName:(ETCIPSA || ETCIPSB) && deviceAction:Permit && !deviceEventClassId:5683 && !source.country_code2:KR && !destinationPort:443

deviceVendor:TippingPoint && deviceHostName:(ETCIPSA || ETCIPSB) && deviceAction:Permit  && !sourceAddress:”10.0.0.0/8″ && !destinationPort:443

deviceVendor:TippingPoint && deviceHostName:(ETCIPSA || ETCIPSB) && deviceAction:Permit && destinationPort:(6548 || 3389 || 1233) && !sourceAddress:”10.0.0.0/8″

deviceVendor:TippingPoint && deviceHostName:(IPSA || IPSB) && deviceAction:Permit && !deviceEventClassId:(5873 || 5683)

deviceVendor:TippingPoint && deviceAction:Permit && !source.country_code2:(US OR KR) && !sourceAddress:(“10.0.0.0/8” || “192.16.114.0/24”)

deviceVendor:TippingPoint && deviceAction:Permit && !destination.country_code2:(US OR KR) && !sourceAddress:”10.0.0.0/8″

AA 구역존 IDC IPS / IPSA IPSB

deviceVendor:TippingPoint && deviceHostName:(IPSA || IPSB) && deviceAction:Permit  && !sourceAddress:”10.0.0.0/8″ && !destinationPort:443

deviceVendor:TippingPoint && deviceHostName:(IPSA || IPSB) && deviceAction:Permit && destinationPort:(6548 || 3389 || 1233)  && !sourceAddress:”10.0.0.0/8″

deviceVendor:TippingPoint && deviceHostName:(IPSA || IPSB) && deviceAction:Permit && !deviceEventClassId:(5873 || 5683)

!destination.country_code2:(KR || US) && deviceAction:(Permit || Detect) && !destinationPort:(161) && !destinationAddress:(“10.0.0.0/8” || “192.16.114.0/24” || “192.168.0.0/16”)


WAF

deviceHostName:(WAF_A || WAF_B) && deviceAction:Detect && !requestUrl:” /robots.txt” && !destinationAddress:(2.2.x.180 || 2.2.x.168) && oldFileName:SQL삽입차단

deviceHostName:(WAF_A || WAF_B) && deviceAction:Detect && !requestUrl:” /robots.txt” && !destinationAddress:(2.2.x.180 || 2.2.x.168) && oldFileName:SQL삽입차단 && !destinationHostName:aaa.bbb.com

deviceProduct:WEBFRONT && deviceAction:Detect && !severity:Unknown && !source.country_code2:(KR || US)

deviceHostName:(DMZWAFA || DMZWAFB) && deviceAction:Detect && !severity:Unknown


NAT IP 찾기

destinationAddress:x.x.x.97 && !sourceAddress:x.x.x.135 (소스가 nat IP가 아닌것을 찾음 real IP 찾을수 있음)

sourceTranslatedAddress:x.x.x.238 && sourceAddress:10.10.107.42 && !destination.country_code2:KR


코인 채굴(mining) 통신 관련 로그 찾기

destinationPort:(18080 || 18081 || 28080 || 28081 || 7777 || 3333) && deviceAction:(Permit || accept) && !destination.country_code2:KR && _exists_:destination.country_code2

sourceAddress:x.x.x.229 && !destinationPort:(80 || 53 || 443)

sourceAddress:x.x.x.13 && !destination.country_code2:KR

destinationPort:7777 && !destination.country_code2:KR && !sourceAddress:10.4.2.3


C&C 서버 통신 쿼리(평판 DB 로 부터 받아온 c2 서버 리스트 기준)

destinationAddress:(x.x.x.x || x.x.x.1 || x.x.x.2 || x.x.x.3 || x.x.x.4) && !sourceAddress:x.x.x.x


NAT IP로 source IP 찾기 

transip:208.xxx.x.x && destinationAddress:8.8.4.4  


APT 장비 검색 쿼리 예 

deviceHostName:APT && _exists_:source.country_code2 && !source.country_code2:KR && !applicationProtocol:(SMTP || IMAP || POP3)

– source IP 가 KR이 아니고 메일 관련 프로토콜은 제외

deviceHostName:DDI AND name:(SQL* OR MINER*) AND NOT destinationAddress:(x.x.17.162 OR x.x2.18.180)

– SQL injection OR Miner 통신 만 탐색

이 글 공유하기:

  • 페이스북에 공유하려면 클릭하세요. (새 창에서 열림) Facebook
  • 클릭하여 X에서 공유 (새 창에서 열림) X
  • 인쇄하기 (새 창에서 열림) 인쇄
  • 클릭하여 친구에게 이메일로 링크 보내기 (새 창에서 열림) 전자우편
  • Telegram에 공유하려면 클릭하세요. (새 창에서 열림) Telegram
  • WhatsApp에 공유하려면 클릭하세요. (새 창에서 열림) WhatsApp

이것이 좋아요:

좋아하기 가져오는 중...

관련

답글 남기기 응답 취소

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Category

  • Article (66)
  • Uncategorized (178)
  • 게임 소식 (13)
  • 기술 정보 & 테크 소식 (260)
  • 꿀팁정리 & 자기계발 (317)
  • 블로그 (26)
  • 사건 사고 (64)
  • 역사 (35)
  • 영화 & 드라마 & 애니메이션 (27)
  • 이슈 뉴스 정리 (207)
  • 정치 인물 사회 (122)
  • 주식 경제 (119)

Recent Posts

  • 위고비(Wegovy) 효능과 가격(1펜) 정리

    위고비(Wegovy) 효능과 가격(1펜) 정리

    2월 16, 2025
  • 도메인 URL 주소 단축하는 사이트 모음

    도메인 URL 주소 단축하는 사이트 모음

    1월 30, 2025
  • 5년전 정혜수 MBC 기상캐스터가 해고당하면서 올린 글

    5년전 정혜수 MBC 기상캐스터가 해고당하면서 올린 글

    1월 28, 2025
  • MBC 기상캐스터 오요안나 자살과 집단 괴롭힘 가해자

    MBC 기상캐스터 오요안나 자살과 집단 괴롭힘 가해자

    1월 27, 2025
  • 홍장원 전 국정원 1차장 좌파이력 정리

    홍장원 전 국정원 1차장 좌파이력 정리

    1월 22, 2025

Popular Posts

©2025 minority opinions | Design: Newspaperly WordPress Theme
%d