2023년 5월 18일 목요일

간만에 Snort(union table)

다음은 Snort 스키마 일부.


tcp, udp, (그림에는 없지만) icmp 테이블이 따로 존재한다. 그래서 프로토콜 구분 없이 모든 데이터를 조회하려면 포트 정보를 제외한 쿼리를 사용하거나,
select a.timestamp, b.sig_name, inet_ntoa(c.ip_src), inet_ntoa(c.ip_dst), unhex(d.data_payload)
from event a, signature b, iphdr c, data d
where a.signature = b.sig_id
and a.sid = c.sid and a.cid = c.cid
and a.sid = d.sid and a.cid = d.cid

프로토콜별 조회 결과를 합쳐야 함.
select a.timestamp, b.sig_name, 
inet_ntoa(c.ip_src), inet_ntoa(c.ip_dst),
e.tcp_sport, e.tcp_dport, unhex(d.data_payload)
from event a, signature b, iphdr c, data d, tcphdr e
where a.signature = b.sig_id
and a.sid = c.sid and a.cid = c.cid
and a.sid = d.sid and a.cid = d.cid
and a.sid = e.sid and a.cid = e.cid
union all
select a.timestamp, b.sig_name,
inet_ntoa(c.ip_src), inet_ntoa(c.ip_dst),
null, null, unhex(d.data_payload)
from event a, signature b, iphdr c, data d, icmphdr e
where a.signature = b.sig_id
and a.sid = c.sid and a.cid = c.cid
and a.sid = d.sid and a.cid = d.cid
and a.sid = e.sid and a.cid = e.cid


union 쿼리 사용 시 필드 개수 맞추는 거 까먹지 말자.

관련 글

댓글 없음:

댓글 쓰기

크리에이티브 커먼즈 라이선스