iT邦幫忙

2025 iThome 鐵人賽

DAY 15
0

每條規則都應包含:動作(action)、協定(protocol)、來源的IP與連接埠、目的IP與連接埠,以及其他選項。

規則結構:

Rule header(必要) + Rule Options(可選)

Rule header:

Action Protocol Source IP/Port Direction Destination IP/Port

範例:

alert ICMP any any <> any any : 不論進出,任何ICMP的流量都會觸發警報

Rule options:

General Rule Options

PayloadDetection Rule Options

Non-Payload Detection RuleOptions

Post-Detection Rule Options

規則選項

Rule Header

  • action:事件觸發時要做甚麼動作
    • alert:用於IDS模式(僅有警報但不阻擋)
    • reject:用於IPS模式(有警報也會阻擋)
    • log:僅記錄封包,不產生警報
    • drop:丟棄並記錄封包
  • protocol:定義要過濾的協定類型
    • IP
    • TCP
    • UDP
    • ICMP
    • (不在這上面的可通過TCP/UDP + 特定的Port來完成過濾,如FTP = TCP + port 21)
  • source/destination IP
    • 流向:
      • -> : 單向,來源到目的
      • <> : 雙向流量
  • source/destination port
  • options
  • 一般規則選項 - General Rule Options
    • msg:規則觸發時顯示的訊息。
    • sid:規則的唯一識別碼。
      • 小於100:保留
      • 100 ~ 999999:官方內建
      • 大於等於1000000:使用者自定義
      • (每個 SID 必須要是唯一)
    • reference:附註或外部參考,如 CVE 編號。
    • rev:規則版本(每次修改都應該遞增)。
  • 有效負載規則選項 - Payload Rule Options
    • content:比對內容,可用 ASCII 或 HEX。
    • nocase:忽略大小寫。
    • fast_pattern:優化匹配速度。
  • 非負載規則選項 - Non-Payload Rule Options
    • id:比對 IP 封包的識別欄位。
    • flags:比對 TCP 封包的標誌位:
      • F - FIN
      • S - SYN
      • R - RST
      • P - PSH
      • A - ACK
      • U - URG
    • dsize:比對封包的大小
    • sameip:來源與目的 IP 相同時觸發。
  • 後偵測規則選項 - Post Detection Rule Options
    • session : 從 TCP 連線中提取使用者資料

編輯規則

要新增或修改規則時,通常的路徑為:

/etc/snort/rules/local.rules


上一篇
Side Blue - Snort 1
下一篇
Side Red - 網頁內容挖掘
系列文
30天的資訊安全讀書筆記16
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言