Si të instaloni Suricata IDS në Ubuntu 22.04
Suricata është një softuer i analizës dhe zbulimit të kërcënimeve të rrjetit falas dhe me burim të hapur i zhvilluar nga OSIF. Mund të përdoret si një sistem zbulimi i ndërhyrjeve (IDS) dhe një sistem parandalimi i ndërhyrjeve (IPS). Ai përdor një grup rregullash dhe një gjuhë nënshkrimi për të zbuluar dhe parandaluar kërcënimet. Është një alternativë ndaj Snort dhe mund të ofrojë një pasqyrë të madhe për atë që po ndodh në rrjetin tuaj nga një këndvështrim sigurie.
Në këtë tutorial, unë do t'ju tregoj se si të instaloni Suricata në serverin Ubuntu 22.04.
Kërkesat
- Një server që ekzekuton Ubuntu 22.04.
- Një fjalëkalim rrënjësor është konfiguruar në serverin tuaj.
Fillimi
Përpara se të filloni, është mirë të përditësoni paketat e sistemit në versionin më të fundit. Ju mund t'i përditësoni të gjitha duke ekzekutuar komandën e mëposhtme:
apt update -y
apt upgrade -y
Pasi të azhurnohen të gjitha paketat, ekzekutoni komandën e mëposhtme për të instaluar të gjitha varësitë e kërkuara:
apt install libpcre3 libpcre3-dbg libpcre3-dev build-essential autoconf automake libtool libpcap-dev libnet1-dev libyaml-0-2 libyaml-dev zlib1g zlib1g-dev libcap-ng-dev libcap-ng0 make libmagic-dev libjansson-dev libjansson4 pkg-config libnspr4-dev libnss3-dev liblz4-dev rustc cargo python3-pip python3-distutils
apt install libnetfilter-queue-dev libnetfilter-queue1 libnfnetlink-dev libnfnetlink0
Pasi të keni mbaruar, mund të vazhdoni në hapin tjetër.
Instaloni Suricata nga Source
Së pari, shkarkoni versionin më të fundit të Suricata me komandën e mëposhtme:
wget https://www.openinfosecfoundation.org/download/suricata-6.0.8.tar.gz
Pasi të përfundojë shkarkimi, nxirrni skedarin e shkarkuar me komandën e mëposhtme:
tar xzf suricata-6.0.8.tar.gz
Më pas, lundroni në drejtorinë e nxjerrë dhe konfiguroni atë me komandën e mëposhtme:
cd suricata-6.0.8
./configure --enable-nfqueue --prefix=/usr --sysconfdir=/etc --localstatedir=/var
Do të merrni daljen e mëposhtme:
Host: x86_64-pc-linux-gnu
Compiler: gcc (exec name) / g++ (real)
GCC Protect enabled: no
GCC march native enabled: yes
GCC Profile enabled: no
Position Independent Executable enabled: no
CFLAGS -g -O2 -std=c11 -march=native -I${srcdir}/../rust/gen -I${srcdir}/../rust/dist
PCAP_CFLAGS -I/usr/include
SECCFLAGS
To build and install run 'make' and 'make install'.
You can run 'make install-conf' if you want to install initial configuration
files to /etc/suricata/. Running 'make install-full' will install configuration
and rules and provide you a ready-to-run suricata.
To install Suricata into /usr/bin/suricata, have the config in
/etc/suricata and use /var/log/suricata as log dir, use:
./configure --prefix=/usr/ --sysconfdir=/etc/ --localstatedir=/var/
Më pas, instaloni Suricata me komandën e mëposhtme:
make
make install-full
Do të merrni daljen e mëposhtme:
You can now start suricata by running as root something like:
/usr/bin/suricata -c /etc/suricata/suricata.yaml -i eth0
If a library like libhtp.so is not found, you can run suricata with:
LD_LIBRARY_PATH=/usr/lib /usr/bin/suricata -c /etc/suricata/suricata.yaml -i eth0
The Emerging Threats Open rules are now installed. Rules can be
updated and managed with the suricata-update tool.
For more information please see:
https://suricata.readthedocs.io/en/latest/rule-management/index.html
make[1]: Leaving directory '/root/suricata-6.0.8'
Instaloni Suricata nga Depoja e Ubuntu
Ju gjithashtu mund të instaloni Suricata nga depoja e Ubuntu. Së pari, instaloni të gjitha varësitë duke përdorur komandën e mëposhtme:
apt install gnupg2 software-properties-common curl wget git unzip -y
Tjetra, shtoni depon e Suricata me komandën e mëposhtme:
add-apt-repository ppa:oisf/suricata-stable --yes
Më pas, përditësoni cache-në e depove me komandën e mëposhtme:
apt update
Më pas, verifikoni paketën Suricata me komandën e mëposhtme:
apt-cache policy suricata
Do të merrni daljen e mëposhtme:
suricata:
Installed: (none)
Candidate: 1:6.0.4-3
Version table:
1:6.0.4-3 500
500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Së fundi, instaloni Suricata me komandën e mëposhtme:
apt install suricata jq
Tani mund të verifikoni informacionin e paketës Suricata duke përdorur komandën e mëposhtme:
suricata --build-info
Ju duhet të merrni daljen e mëposhtme:
This is Suricata version 6.0.8 RELEASE
Features: NFQ PCAP_SET_BUFF AF_PACKET HAVE_PACKET_FANOUT LIBCAP_NG LIBNET1.1 HAVE_HTP_URI_NORMALIZE_HOOK PCRE_JIT HAVE_NSS HAVE_LIBJANSSON TLS TLS_C11 MAGIC RUST
SIMD support: SSE_3
Atomic intrinsics: 1 2 4 8 16 byte(s)
64-bits, Little-endian architecture
GCC version 11.2.0, C version 201112
compiled with _FORTIFY_SOURCE=2
L1 cache line size (CLS)=64
thread local storage method: _Thread_local
compiled with LibHTP v0.5.41, linked against LibHTP v0.5.41
Suricata Configuration:
AF_PACKET support: yes
eBPF support: no
XDP support: no
PF_RING support: no
NFQueue support: yes
NFLOG support: no
IPFW support: no
Netmap support: no
DAG enabled: no
Napatech enabled: no
WinDivert enabled: no
Unix socket enabled: yes
Detection enabled: yes
Konfiguro Suricata
Më pas, modifikoni skedarin e konfigurimit Suricata dhe përcaktoni ndërfaqen dhe rrjetin tuaj të rrjetit:
nano /etc/suricata/suricata.yaml
Ndryshoni linjat e mëposhtme:
HOME_NET: "[10.0.2.0/24]"
EXTERNAL_NET: "!$HOME_NET"
af-packet:
- interface: eth0
# - sip
sip:
enabled: no
Ruani dhe mbyllni skedarin dhe më pas përditësoni konfigurimin Suricata me komandën e mëposhtme:
suricata-update
Më pas, verifikoni skedarin e konfigurimit Suricata me komandën e mëposhtme:
suricata -T -c /etc/suricata/suricata.yaml -v
Do të merrni daljen e mëposhtme:
18/10/2022 -- 13:45:14 - - fast output device (regular) initialized: fast.log
18/10/2022 -- 13:45:14 - - eve-log output device (regular) initialized: eve.json
18/10/2022 -- 13:45:14 - - stats output device (regular) initialized: stats.log
18/10/2022 -- 13:45:14 - - SSSE3 support not detected, disabling Hyperscan for SPM
18/10/2022 -- 13:45:16 - - 1 rule files processed. 28624 rules successfully loaded, 0 rules failed
18/10/2022 -- 13:45:16 - - Threshold config parsed: 0 rule(s) found
18/10/2022 -- 13:45:16 - - 28627 signatures processed. 1219 are IP-only rules, 5166 are inspecting packet payload, 22038 inspect application layer, 108 are decoder event only
18/10/2022 -- 13:45:19 - - Configuration provided was successfully loaded. Exiting.
18/10/2022 -- 13:45:19 - - cleaning up signature grouping structure... complete
Më pas, filloni dhe aktivizoni shërbimin Suricata me komandën e mëposhtme:
systemctl enable --now suricata
Ju gjithashtu mund të kontrolloni shërbimin Suricata me komandën e mëposhtme:
systemctl status suricata
Ju duhet të shihni daljen e mëposhtme:
? suricata.service - LSB: Next Generation IDS/IPS
Loaded: loaded (/etc/init.d/suricata; generated)
Active: active (running) since Tue 2022-10-18 13:38:52 UTC; 6min ago
Docs: man:systemd-sysv-generator(8)
Process: 16504 ExecStart=/etc/init.d/suricata start (code=exited, status=0/SUCCESS)
Tasks: 7 (limit: 2242)
Memory: 40.0M
CPU: 4.073s
CGroup: /system.slice/suricata.service
??16514 /usr/bin/suricata -c /etc/suricata/suricata.yaml --pidfile /var/run/suricata.pid --af-packet -D -vvv
Oct 18 13:38:52 ubuntu2204 systemd[1]: Starting LSB: Next Generation IDS/IPS...
Oct 18 13:38:52 ubuntu2204 suricata[16504]: Starting suricata in IDS (af-packet) mode... done.
Oct 18 13:38:52 ubuntu2204 systemd[1]: Started LSB: Next Generation IDS/IPS.
Ju gjithashtu mund të shihni mënyra të ndryshme ekzekutimi duke përdorur komandën e mëposhtme:
suricata --list-runmodes
Do të merrni daljen e mëposhtme:
------------------------------------- Runmodes ------------------------------------------
| RunMode Type | Custom Mode | Description
|----------------------------------------------------------------------------------------
| PCAP_DEV | single | Single threaded pcap live mode
| ---------------------------------------------------------------------
| | autofp | Multi threaded pcap live mode. Packets from each flow are assigned to a single detect thread, unlike "pcap_live_auto" where packets from the same flow can be processed by any detect thread
| ---------------------------------------------------------------------
| | workers | Workers pcap live mode, each thread does all tasks from acquisition to logging
|----------------------------------------------------------------------------------------
| PCAP_FILE | single | Single threaded pcap file mode
| ---------------------------------------------------------------------
| | autofp | Multi threaded pcap file mode. Packets from each flow are assigned to a single detect thread, unlike "pcap-file-auto" where packets from the same flow can be processed by any detect thread
|----------------------------------------------------------------------------------------
| PFRING(DISABLED) | autofp | Multi threaded pfring mode. Packets from each flow are assigned to a single detect thread, unlike "pfring_auto" where packets from the same flow can be processed by any detect thread
| ---------------------------------------------------------------------
| | single | Single threaded pfring mode
| ---------------------------------------------------------------------
| | workers | Workers pfring mode, each thread does all tasks from acquisition to logging
|----------------------------------------------------------------------------------------
Verifiko Suricata
Përpara se të verifikoni Suricata, do t'ju duhet të çaktivizoni veçoritë e shkarkimit të paketave në ndërfaqen e rrjetit.
Mund ta çaktivizoni me komandën e mëposhtme:
ethtool -K eth0 gro off lro off
Më pas, ndaloni Suricata me komandën e mëposhtme:
systemctl stop suricata
rm -rf /var/run/suricata.pid
Tjetra, ekzekutoni Suricata me dorë duke përdorur komandën e mëposhtme:
suricata -D -c /etc/suricata/suricata.yaml -i eth0
Më pas, hyni në sistemin në distancë dhe ekzekutoni komandën hping3 për të kryer një sulm të thjeshtë DDoS kundër serverit Suricata:
hping3 -S -p 80 --flood --rand-source suricata-ip -I eth0 -c 50
Më pas, kthehuni te serveri Suricata dhe kontrolloni skedarin e regjistrit Suricata:
tail -f /var/log/suricata/fast.log
Ju duhet të shihni daljen e mëposhtme:
10/18/2022-14:01:38.569298 [**] [1:2210008:2] SURICATA STREAM 3way handshake SYN resend different seq on SYN recv [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 157.32.37.21:59188 -> 209.23.10.188:80
10/18/2022-14:01:38.569304 [**] [1:2210004:2] SURICATA STREAM 3way handshake SYNACK resend with different ack [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 209.23.10.188:80 -> 157.32.37.21:59188
10/18/2022-14:01:38.569649 [**] [1:2210008:2] SURICATA STREAM 3way handshake SYN resend different seq on SYN recv [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 157.32.37.21:53343 -> 209.23.10.188:80
10/18/2022-14:01:38.569655 [**] [1:2210004:2] SURICATA STREAM 3way handshake SYNACK resend with different ack [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 209.23.10.188:80 -> 157.32.37.21:53343
10/18/2022-14:01:38.570762 [**] [1:2210008:2] SURICATA STREAM 3way handshake SYN resend different seq on SYN recv [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 157.32.37.21:62070 -> 209.23.10.188:80
10/18/2022-14:01:38.570770 [**] [1:2210004:2] SURICATA STREAM 3way handshake SYNACK resend with different ack [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 209.23.10.188:80 -> 157.32.37.21:62070
10/18/2022-14:01:38.571748 [**] [1:2210008:2] SURICATA STREAM 3way handshake SYN resend different seq on SYN recv [**] [Classification: Generic Protocol Command Decode] [Priority: 3] {TCP} 157.32.37.21:5001 -> 209.23.10.188:80
konkluzioni
Në këtë postim, mësuat se si të instaloni Suricata në Ubuntu 22.04. Tani mund të zbatoni Suricata në organizatën tuaj për të mbrojtur serverët tuaj nga sulmet DDoS. Mos ngurroni të më pyesni nëse keni ndonjë pyetje.