Snort là Hệ thống phát hiện và phòng ngừa xâm nhập (IDS) nguồn mở để chống lại các cuộc tấn công DDoS. Nó sử dụng các quy tắc tích hợp giúp xác định hoạt động mạng độc hại và sử dụng các quy tắc đó để tìm các gói tin khớp với chúng và tạo cảnh báo cho người dùng. Snort có thể xác định các cuộc tấn công mới nhất, nhiễm phần mềm độc hại, hệ thống bị xâm phạm và vi phạm chính sách mạng.
Tính năng
Sau khi tất cả các thành phần phụ thuộc đã được cài đặt, bạn có thể tiến hành bước tiếp theo.
Đầu tiên, tải xuống Snort DAQ từ Git bằng lệnh sau:
Sau khi tải xuống hoàn tất, hãy điều hướng đến thư mục đã tải xuống và định cấu hình bằng lệnh sau:
Bạn sẽ thấy thông tin sau đầu ra:
Tiếp theo, cài đặt bằng lệnh sau:
Sau khi tải xuống hoàn tất, hãy giải nén tệp đã tải xuống bằng lệnh sau:
Tiếp theo, điều hướng đến thư mục đã tải xuống và biên dịch nó bằng lệnh sau lệnh:
Tiếp theo, cài đặt bằng lệnh sau:
Tiếp theo, giải nén tệp đã tải xuống bằng lệnh sau:
Tiếp theo, điều hướng đến thư mục đã giải nén và định cấu hình thư mục đó bằng lệnh sau lệnh:
Bạn sẽ nhận được kết quả sau:
Tiếp theo, hãy thay đổi thư mục thành thư mục dựng và cài đặt Snort bằng lệnh sau:
Bây giờ bạn có thể xác minh phiên bản Snort bằng cách sử dụng lệnh sau lệnh:
Bạn sẽ nhận được kết quả sau:
Tiếp theo, xác minh các quy tắc bằng lệnh sau lệnh:
Bạn sẽ nhận được kết quả sau:
Tiếp theo, chạy lệnh sau để khởi động Snort trên giao diện mạng của bạn bằng cách sử dụng lệnh tùy chỉnh của bạn rules:
Tiếp theo, mở một giao diện terminal khác và ping máy chủ của bạn. Bạn sẽ thấy lỗi ICMP trên terminal đầu tiên:
Thêm các cấu hình sau:
Lưu và đóng tệp, sau đó tải lại systemd daemon bằng lệnh sau:
Tiếp theo, khởi động và kích hoạt dịch vụ Snort bằng lệnh sau:
Bây giờ bạn có thể xác minh trạng thái của Snort bằng lệnh sau lệnh:
Bạn sẽ nhận được kết quả sau:
Tính năng
- Giám sát lưu lượng theo thời gian thực.
- Ghi nhật ký gói tin. Phân tích giao thức.
- So khớp nội dung. Dấu vân tay hệ điều hành.
- Có thể cài đặt trong bất kỳ môi trường mạng nào.
- Tạo nhật ký.
Điều kiện tiên quyết
- Một máy chủ chạy Ubuntu 22.04.
- Mật khẩu gốc được cấu hình trên máy chủ.
Cài đặt các phụ thuộc bắt buộc
Trước khi bắt đầu, bạn sẽ cần cài đặt một số phụ thuộc trên máy chủ của mình. Bạn có thể cài đặt tất cả chúng bằng cách chạy lệnh sau:
Mã:
apt install build-essential libpcap-dev libpcre3-dev libnet1-dev zlib1g-dev luajit hwloc libdnet-dev libdumbnet-dev bison flex liblzma-dev openssl libssl-dev pkg-config libhwloc-dev cmake cpputest libsqlite3-dev uuid-dev libcmocka-dev libnetfilter-queue-dev libmnl-dev autotools-dev libluajit-5.1-dev libunwind-dev libfl-dev -y
Cài đặt Snort DAQ
Tiếp theo, bạn sẽ cần cài đặt thư viện Data Acquisition trên hệ thống của bạn. Theo mặc định, nó không có sẵn trong kho lưu trữ mặc định của Ubuntu. Vì vậy, bạn sẽ cần biên dịch nó từ nguồn.Đầu tiên, tải xuống Snort DAQ từ Git bằng lệnh sau:
Mã:
git clone https://github.com/snort3/libdaq.git
Mã:
cd libdaq
./bootstrap
./configure
Mã:
cc: gcc cppflags: am_cppflags: -fvisibility=hidden -Wall -Wmissing-declarations -Wpointer-arith -Wcast-align -Wcast-qual -Wformat -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wextra -Wsign-compare -Wno-unused-parameter -fno-strict-aliasing -fdiagnostics-show-option cflags: -g -O2 am_cflags: -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wnested-externs ldflags: am_ldflags: libs: code_coverage_enabled: no code_coverage_cppflags: code_coverage_cflags: code_coverage_ldflags: Build AFPacket DAQ module.. : yes Build BPF DAQ module....... : yes Build Divert DAQ module.... : no Build Dump DAQ module...... : yes Build FST DAQ module....... : yes Build netmap DAQ module.... : no Build NFQ DAQ module....... : yes Build PCAP DAQ module...... : yes Build Savefile DAQ module.. : yes Build Trace DAQ module..... : yes Build GWLB DAQ module...... : yes
Mã:
make
make install
Cài đặt Gperftools
Đầu tiên, hãy tải xuống phiên bản mới nhất của Gperftools bằng lệnh sau lệnh:
Mã:
cd
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz
Mã:
tar xzf gperftools-2.9.1.tar.gz
Mã:
cd gperftools-2.9.1/
./configure
Mã:
make
make install
Cài đặt Snort
Tiếp theo, tải xuống phiên bản Snort mới nhất bằng lệnh sau lệnh:
Mã:
cd
wget https://github.com/snort3/snort3/archive/refs/tags/3.1.43.0.tar.gz
Mã:
tar -xvzf 3.1.43.0.tar.gz
Mã:
cd snort3-3.1.43.0
./configure_cmake.sh --prefix=/usr/local --enable-tcmalloc
Mã:
snort version 3.1.43.0
Install options: prefix: /usr/local includes: /usr/local/include/snort plugins: /usr/local/lib/snort
Compiler options: CC: /usr/bin/cc CXX: /usr/bin/c++ CFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -O2 -g -DNDEBUG CXXFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -O2 -g -DNDEBUG EXE_LDFLAGS: MODULE_LDFLAGS:
Feature options: DAQ Modules: Static (afpacket;bpf;dump;fst;gwlb;nfq;pcap;savefile;trace) libatomic: System-provided Hyperscan: OFF ICONV: ON Libunwind: ON LZMA: ON RPC DB: Built-in SafeC: OFF TCMalloc: ON JEMalloc: OFF UUID: ON
-------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /root/snort3-3.1.43.0/build
Mã:
cd build
make
make install
ldconfig
Mã:
snort -V
Mã:
,,_ -*> Snort++ $HOME_NET any (msg:"ICMP connection test"; sid:1000001; rev:1;)
Mã:
snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/rules/local.rules
Mã:
search engine instances: 316 patterns: 10282 pattern chars: 166369 num states: 112212 num match states: 9885 memory scale: MB total memory: 3.42574 pattern memory: 0.550588 match list memory: 1.25256 transition memory: 1.58402 fast pattern only: 6822
--------------------------------------------------
pcap DAQ configured to passive.
Snort successfully validated the configuration (with 0 warnings).
o")~ Snort exiting
Mã:
snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/rules/local.rules -i eth0 -A alert_fast -s 65535 -k none
Mã:
10/11-16:45:23.848071 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:23.848071 [**] [1:384:8] "PROTOCOL-ICMP PING" [**] [Classification: Misc activity] [Priority: 3] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:24.323038 [**] [1:366:11] "PROTOCOL-ICMP PING Unix" [**] [Classification: Misc activity] [Priority: 3] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:24.323038 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:24.323038 [**] [1:384:8] "PROTOCOL-ICMP PING" [**] [Classification: Misc activity] [Priority: 3] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
^C** caught int signal
== stopping
10/11-16:45:25.353007 [**] [1:366:11] "PROTOCOL-ICMP PING Unix" [**] [Classification: Misc activity] [Priority: 3] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:25.353007 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
10/11-16:45:25.353007 [**] [1:384:8] "PROTOCOL-ICMP PING" [**] [Classification: Misc activity] [Priority: 3] [AppID: ICMP] {ICMP} 157.32.34.228 -> 209.23.11.18
Tạo tệp dịch vụ Systemd cho Snort
Tiếp theo, tạo tệp dịch vụ systemd để quản lý Snort thông qua systemd.
Mã:
nano /etc/systemd/system/snort3.service
Mã:
[Unit]
Description=Snort Daemon
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/snort -c /usr/local/etc/snort/snort.lua -s 65535 -k none -l /var/log/snort -D -i eth0 -m 0x1b -u root -g root
ExecStop=/bin/kill -9 $MAINPID
[Install]
WantedBy=multi-user.target
Mã:
systemctl daemon-reload
Mã:
systemctl enable --now snort3
Mã:
systemctl status snort3
Mã:
? snort3.service - Snort Daemon Loaded: loaded (/etc/systemd/system/snort3.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-10-11 16:48:28 UTC; 17s ago Main PID: 95898 (snort) Tasks: 2 (limit: 4579) Memory: 233.6M CPU: 2.007s CGroup: /system.slice/snort3.service ??95898 /usr/local/bin/snort -c /usr/local/etc/snort/snort.lua -s 65535 -k none -l /var/log/snort -D -i eth0 -m 0x1b -u root -g >
Oct 11 16:48:29 ubuntu2204 snort[95898]: num match states: 9885
Oct 11 16:48:29 ubuntu2204 snort[95898]: memory scale: MB
Oct 11 16:48:29 ubuntu2204 snort[95898]: total memory: 3.42574
Oct 11 16:48:29 ubuntu2204 snort[95898]: pattern memory: 0.550588
Oct 11 16:48:29 ubuntu2204 snort[95898]: match list memory: 1.25256
Oct 11 16:48:29 ubuntu2204 snort[95898]: transition memory: 1.58402
Oct 11 16:48:29 ubuntu2204 snort[95898]: fast pattern only: 6822
Oct 11 16:48:29 ubuntu2204 snort[95898]: --------------------------------------------------
Oct 11 16:48:29 ubuntu2204 snort[95898]: pcap DAQ configured to passive.
Oct 11 16:48:29 ubuntu2204 snort[95898]: Commencing packet processing