Pattern Matching: หลักการ อัลกอริทึม และการประยุกต์ใน NIDS/Research
Pattern Matching คืออะไร?
ตรวจสอบว่าข้อมูลมี Sequence ของ Characters/Tokens/Data ตรงกับ Pattern ที่กำหนดหรือไม่ ใช้ Replace Matching Pattern ด้วย Text/Code อื่นได้ ใช้ในทุก Application ที่มี Search Function
ตัวอย่าง Pattern Matching
- x*: Match x จำนวนมาก (0-n)
- [0-9]*: Match ตัวเลข 0-9 จำนวนมาก
- .*: Match อะไรก็ได้
- Regular Expression Match ทุกที่ใน String
Pattern Matching ใน IDS (NIDS)
สำคัญมากใน Network Intrusion Detection Systems Computationally Intensive ต้องมี Method รองรับ Attack Signatures มากขึ้น ที่ Packet Wire Speed
Pattern Matching ทำงานอย่างไร?
Regular Expressions (Regex) "อ่าน" Text Strings หา Pattern เรียกว่า Pattern Matching Expressions Wildcard Characters ใช้ Regex Reference แทน
Pattern Matching Technique
หาว่า Token Sequence มี Pattern Elements หรือไม่ Sequence Patterns (String) ใช้ Regex + Backtracking
Pattern Matching ใช้ประโยชน์อะไร?
Decompose/Navigate Data Structures สะดวก Compact Compiler Verify Logic ได้ดีขึ้น ฟีเจอร์ที่ดีที่สุดของภาษา
วัตถุประสงค์ของ Pattern Matching
Programming Languages/Applications: ระบุ/แทนที่ Matching Pattern ใน High-level Compilers ตรวจ Syntax Correctness ของ Source Files
Pattern Matching อัลกอริทึม 2 แบบ
- Naive Algorithm
- Finite Automata Method
ค้นหา String Pattern ใน String Text
Pattern Matching ตัวอย่าง (Code)
head (element :: list) = element Assert: First Element = Element, Return Value
Use Pattern Matching
Test Expression ว่ามี Features ตรงหรือไม่ C# Pattern Matching: Concise Test + Action เมื่อ Match 4 Scenarios
Pattern Matching ใน Case Study
Compare 2 Patterns: Match (เหมือน) หรือ Not Match (ต่าง) Central to Theory Testing Observed Pattern vs Theoretical Pattern
Pattern Matching ใน Biology
Computational Pipelines: Locate DNA Subsequences ใน Genomic Databases/DNA Sequences Pattern Elements อัปเดตตลอดใน Databases ที่ขยายเร็ว
Ways to Classify IDS
- Network IDS (NIDS)
- Host-based IDS (HIDS)
- Perimeter IDS
- VM-based IDS
Stateful Pattern Matching คืออะไร?
พิจารณา Packet Order ใน TCP Stream Inspect/Judge Packets/Flows อย่างถูกต้องและสม่ำเสมอ
IDS และประเภท
- Network IDS (NIDS)
- Host IDS (HIDS)
- Endpoint Security (Anti-virus)
- Intrusion Prevention System (IPS)
Pattern Matching ใน Research
Compare Theoretical Pattern กับ Empirical Pattern (Observed) Hammond (1966): มนุษย์ตีความความจริงโดยเปรียบเทียบ Observation กับ Mental Models