@@ -691,64 +691,64 @@ EOL
691
691
function install_suricata() {
692
692
echo ' [+] Installing Suricata'
693
693
sudo add-apt-repository -y ppa:oisf/suricata-stable
694
- sudo apt-get -o Dpkg::Options::=" --force-confold" -o Dpkg::Options::=" --force-overwrite" install -y suricata suricata-update
694
+ sudo apt-get -o Dpkg::Options::=" --force-confold" -o Dpkg::Options::=" --force-overwrite" install -y suricata
695
695
touch /etc/suricata/threshold.config
696
696
697
697
# Download etupdate to update Emerging Threats Open IDS rules:
698
698
mkdir -p " /etc/suricata/rules"
699
699
if ! crontab -l | grep -q -F ' 15 * * * * /usr/bin/suricata-update' ; then
700
- crontab -l | { cat; echo " 15 * * * * /usr/bin/suricata-update --suricata /usr/bin/suricata --suricata-conf /etc/suricata/suricata.yaml -o /etc/suricata/rules/ && /usr/bin/suricatasc -c reload-rules /tmp/suricata-command.socket & >/dev/null" ; } | crontab -
700
+ crontab -l | { cat; echo " 15 * * * * /usr/bin/suricata-update --suricata /usr/bin/suricata --suricata-conf /etc/suricata/suricata.yaml -o /etc/suricata/rules/ &>/dev/null" ; } | crontab -
701
701
fi
702
702
if [ -d /usr/share/suricata/rules/ ]; then
703
- # copy files if rules folder contains files
703
+ # copy files if rules folder contains files
704
704
if [ " $( ls -A /var/lib/suricata/rules/) " ]; then
705
705
cp " /usr/share/suricata/rules/" * " /etc/suricata/rules/"
706
706
fi
707
707
fi
708
708
if [ -d /var/lib/suricata/rules/ ]; then
709
- # copy files if rules folder contains files
709
+ # copy files if rules folder contains files
710
710
if [ " $( ls -A /var/lib/suricata/rules/) " ]; then
711
711
cp " /var/lib/suricata/rules/" * " /etc/suricata/rules/"
712
712
fi
713
713
fi
714
714
715
- # ToDo this is not the best solution but i don't have time now to investigate proper one
716
- sed -i ' s|CapabilityBoundingSet=CAP_NET_ADMIN|#CapabilityBoundingSet=CAP_NET_ADMIN|g' /lib/systemd/system/suricata.service
717
- systemctl daemon-reload
715
+ cat > /etc/suricata/cape.yaml << EOF
716
+ %YAML 1.1
717
+ ---
718
+
719
+ default-rule-path: /etc/suricata/rules
720
+ rule-files: suricata.rules
721
+ mpm-algo: hs
722
+ stream.reassembly.depth: 0
723
+ stream.checksum-validation: none
724
+ netmap.checksum-checks: no
725
+ pcap-file.checksum-checks: no
726
+ app-layer.protocols.http.libhtp.default-config.request-body-limit: 0
727
+ app-layer.protocols.http.libhtp.default-config.response-body-limit: 0
728
+ app-layer.protocols.tls.ja3-fingerprints: yes
729
+
730
+ vars.address-groups.EXTERNAL_NET: "ANY"
731
+ # pid-file: /run/suricata.pid
732
+ # https://forum.suricata.io/t/suricata-service-crashes-with-pthread-create-is-11-error-when-processing-pcap-with-capev2/3870/5
733
+ security.limit-noproc: false
734
+
735
+ outputs.1.eve-log.enabled: yes
736
+ file-store.enabled: yes
737
+ EOF
718
738
719
- # change suricata yaml
720
- sed -i ' s|#default-rule-path: /etc/suricata/rules|default-rule-path: /etc/suricata/rules|g' /etc/default/suricata
721
- sed -i ' s|default-rule-path: /var/lib/suricata/rules|default-rule-path: /etc/suricata/rules|g' /etc/suricata/suricata.yaml
722
- sed -i ' s/#rule-files:/rule-files:/g' /etc/suricata/suricata.yaml
723
- sed -i ' s/# - suricata.rules/ - suricata.rules/g' /etc/suricata/suricata.yaml
724
- sed -i ' s/RUN=yes/RUN=no/g' /etc/default/suricata
725
- sed -i ' s/mpm-algo: ac/mpm-algo: hs/g' /etc/suricata/suricata.yaml
726
- sed -i ' s/mpm-algo: auto/mpm-algo: hs/g' /etc/suricata/suricata.yaml
727
- sed -i ' s/#run-as:/run-as:/g' /etc/suricata/suricata.yaml
728
- sed -i " s/# user: suri/ user: ${USER} /g" /etc/suricata/suricata.yaml
729
- sed -i " s/# group: suri/ group: ${USER} /g" /etc/suricata/suricata.yaml
730
- sed -i ' s/ depth: 1mb/ depth: 0/g' /etc/suricata/suricata.yaml
731
- sed -i ' s/request-body-limit: 100kb/request-body-limit: 0/g' /etc/suricata/suricata.yaml
732
- sed -i ' s/response-body-limit: 100kb/response-body-limit: 0/g' /etc/suricata/suricata.yaml
733
- sed -i ' s/EXTERNAL_NET: "!$HOME_NET"/EXTERNAL_NET: "ANY"/g' /etc/suricata/suricata.yaml
734
- sed -i ' s|#pid-file: /var/run/suricata.pid|pid-file: /tmp/suricata.pid|g' /etc/suricata/suricata.yaml
735
- sed -i ' s|#ja3-fingerprints: auto|ja3-fingerprints: yes|g' /etc/suricata/suricata.yaml
736
- # -k none
737
- sed -i ' s/#checksum-validation: none/checksum-validation: none/g' /etc/suricata/suricata.yaml
738
- sed -i ' s/checksum-checks: auto/checksum-checks: no/g' /etc/suricata/suricata.yaml
739
-
740
- # https://forum.suricata.io/t/suricata-service-crashes-with-pthread-create-is-11-error-when-processing-pcap-with-capev2/3870/5
741
- sed -i ' s|limit-noproc: true|limit-noproc: false|g' /etc/suricata/suricata.yaml
742
-
743
- # enable eve-log
744
- python3 -c " pa = '/etc/suricata/suricata.yaml';q=open(pa, 'rb').read().replace(b'eve-log:\n enabled: no\n', b'eve-log:\n enabled: yes\n');open(pa, 'wb').write(q);"
745
- python3 -c " pa = '/etc/suricata/suricata.yaml';q=open(pa, 'rb').read().replace(b'unix-command:\n enabled: auto\n #filename: custom.socket', b'unix-command:\n enabled: yes\n filename: /tmp/suricata-command.socket');open(pa, 'wb').write(q);"
746
- # file-store
747
- python3 -c " pa = '/etc/suricata/suricata.yaml';q=open(pa, 'rb').read().replace(b'file-store:\n version: 2\n enabled: no', b'file-store:\n version: 2\n enabled: yes');open(pa, 'wb').write(q);"
748
-
749
- chown ${USER} :${USER} -R /etc/suricata
750
- chown ${USER} :${USER} -R /var/log/suricata
739
+ sed -i ' $a include:\n - cape.yaml\n' /etc/suricata/suricata.yaml
740
+ usermod -aG pcap suricata
741
+ usermod -aG suricata " ${USER} "
742
+ # sudo chmod -R g+w /var/log/suricata/
743
+ # sudo chmod -R g+w /var/run/suricata/
744
+ # sudo chmod -R g+w /etc/suricata
751
745
systemctl restart suricata
746
+
747
+ # How to verify config options
748
+ # suricata --dump-config
749
+ # sudo suricata -T -c /etc/suricata/suricata.yaml
750
+ # echo "Important: For this change to take effect, you must log out and then log back in, or open a new shell with newgrp suricata."
751
+
752
752
}
753
753
754
754
function install_yara_x() {
0 commit comments