<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Crowdsec on slash-root.fr</title><link>https://beta.slash-root.fr/tags/crowdsec/</link><description>Recent content in Crowdsec on slash-root.fr</description><generator>Hugo -- gohugo.io</generator><language>fr-fr</language><lastBuildDate>Wed, 07 Aug 2024 11:53:52 +0200</lastBuildDate><atom:link href="https://beta.slash-root.fr/tags/crowdsec/index.xml" rel="self" type="application/rss+xml"/><item><title>CrowdSec : Avoid a Duplicate Decision / Notification</title><link>https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/</link><pubDate>Wed, 07 Aug 2024 10:52:44 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-avoid-a-duplicate-decision-notification/cover.png" alt="Featured image of post CrowdSec : Avoid a Duplicate Decision / Notification" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Prenons le cas de l'utilisation de CrowdSec pour protéger des applications web en analysant les logs du reverse-proxy.&lt;/p&gt;
&lt;p&gt;Suivant le scénario qui se déclenchera, CrowdSec prendra une décision concernant l'adresse IP concernée. Par exemple, renvoyer un code HTTP 403. Dans ce cas de figure, si l'acteur malveillant persiste, une décision sera prise à chaque fois. Si des notifications sont envoyées à chaque prise de décision, cela peut vite devenir du spam ! C'est le comportement normal puisque le profil par défaut de CrowdSec prend une décision à chaque déclenchement de scénario.&lt;/p&gt;
&lt;p&gt;Nous allons voir comment modifier la prise de décision pour vérifier au préalable si une décision identique n'a pas été prise récemment.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Toutes les commandes / manipulations présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="modification-de-la-remediation"&gt;&lt;a href="#modification-de-la-remediation" class="header-anchor"&gt;&lt;/a&gt;Modification de la Remediation
&lt;/h2&gt;&lt;p&gt;Tout va se passer dans un seul fichier : &lt;code&gt;/etc/crowdsec/profiles.yaml&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Voici un fichier classique qui &lt;strong&gt;ban&lt;/strong&gt; pendant 4h l'adresse IP qui déclenche un scénario :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#/etc/crowdsec/profiles.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default_ip_remediation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filters&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Alert.Remediation == true &amp;amp;&amp;amp; Alert.GetScope() == &amp;#34;Ip&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;decisions&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ban&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;duration&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;4h&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#duration_expr: &amp;#34;Sprintf(&amp;#39;%dh&amp;#39;, (GetDecisionsCount(Alert.GetValue()) + 1) * 4)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;on_success&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nous allons modifier le filtre pour vérifier si une décision n'a pas été prise il y a moins de 2h pour l'adresse IP concernée.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Voici le fichier modifié :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#/etc/crowdsec/profiles.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default_ip_remediation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filters&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Alert.Remediation == true &amp;amp;&amp;amp; Alert.GetScope() == &amp;#34;Ip&amp;#34; &amp;amp;&amp;amp; GetDecisionsSinceCount(Alert.GetValue(), &amp;#34;2h&amp;#34;) &amp;lt; 1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;decisions&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ban&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;duration&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;4h&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#duration_expr: &amp;#34;Sprintf(&amp;#39;%dh&amp;#39;, (GetDecisionsCount(Alert.GetValue()) + 1) * 4)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;on_success&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;break&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Pour valider la modification, redémarrez le service :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="intérêt"&gt;&lt;a href="#int%c3%a9r%c3%aat" class="header-anchor"&gt;&lt;/a&gt;Intérêt
&lt;/h2&gt;&lt;p&gt;On peut se dire : Mais pourquoi faire ça ?&lt;/p&gt;
&lt;p&gt;A chaque fois que CrowdSec prendra une décision, si les notifications sont configurées, cela en déclenchera une systématiquement.&lt;/p&gt;
&lt;p&gt;Dans mon cas, cela concernait les scans multi-ports et j'en avais marre de recevoir du spam de notification... (Effet JO 2024 ???).&lt;/p&gt;
&lt;p&gt;Voici l'output que cela donnait en moins d'une minute :&lt;/p&gt;
&lt;p&gt;&lt;img data-recalc-dims="1" decoding="async" src="01.png" alt="image-20240807104724911" /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;Maintenant, CrowdSec prendra une décision concernant l'adresse IP qui déclenchera un scénario et qui n'a pas été &lt;strong&gt;ban&lt;/strong&gt; il y a moins de 2h. Si celle-ci revient au bout de 3h et redéclenche un scénario, ça sera reparti pour 4h, etc.&lt;/p&gt;</description></item><item><title>CrowdSec : Protéger l’authentification Gitlab</title><link>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/</link><pubDate>Fri, 19 Jul 2024 11:06:58 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-proteger-lauthentification-gitlab/cover.png" alt="Featured image of post CrowdSec : Protéger l’authentification Gitlab" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Ce guide explique comment protéger l'authentification sur Gitlab contre les attaques de Bruteforce à l'aide de CrowdSec. Il est essentiel de sécuriser un portail d'authentification web. Une nouvelle collection crowdsec, comprenant 1 parser et 1 scénario, sera installée.&lt;/p&gt;
&lt;p&gt;Ce guide se base sur une installation de Gitlab sur Debian 12. La version Gitlab utilisée est la dernière en date (17.2.0).&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Une machine Debian 12 avec un accès root ou sudo. Toutes les commandes présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Une connexion internet active.&lt;/li&gt;
&lt;li&gt;Gitlab CE ou EE installé&lt;/li&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="modification-du-port-de-lapi-crowdsec"&gt;&lt;a href="#modification-du-port-de-lapi-crowdsec" class="header-anchor"&gt;&lt;/a&gt;Modification du port de l&amp;rsquo;API CrowdSec
&lt;/h2&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Très important !&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Avec une installation standard de Gitlab, le serveur PUMA (serveur web ruby faisant partie de gitlab) écoute sur le port TCP 8080. Il est donc impératif de modifier le port d'écoute de l'API de CrowdSec pour éviter tout conflit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Procédure décrite &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/#toc-10"&gt;[ici]&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Vérifiez bien que vos services crowdsec fonctionnent correctement :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="installation-de-la-collection-pour-gitlab"&gt;&lt;a href="#installation-de-la-collection-pour-gitlab" class="header-anchor"&gt;&lt;/a&gt;Installation de la collection pour gitlab
&lt;/h2&gt;&lt;p&gt;En navigant sur le hub de CrowdSec, une collection pour gitlab est disponible.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installer la collection :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli collections install timokoessler/gitlab
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ceci a pour effet d'installer 1 parser et 1 scénario.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Lister les parsers :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli parsers list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# timokoessler/gitlab-logs ✔️ enabled 0.1 /etc/crowdsec/parsers/s01-parse/gitlab-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lister les sénarios :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli scenario list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# timokoessler/gitlab-bf ✔️ enabled 0.2 /etc/crowdsec/scenarios/gitlab-bf.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="création-du-fichier-dacquisition"&gt;&lt;a href="#cr%c3%a9ation-du-fichier-dacquisition" class="header-anchor"&gt;&lt;/a&gt;Création du fichier d&amp;rsquo;acquisition
&lt;/h2&gt;&lt;p&gt;Afin que le parser Gitlab puisse être utilisé, il faut définir la méthode d'acquisition.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/gitlab.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filenames&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/var/log/gitlab/gitlab-rails/production_json.log&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;gitlab&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="redémarrage-du-service"&gt;&lt;a href="#red%c3%a9marrage-du-service" class="header-anchor"&gt;&lt;/a&gt;Redémarrage du service
&lt;/h2&gt;&lt;p&gt;A présent, le service crowdsec peut être rechargé :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl reload crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="vérification"&gt;&lt;a href="#v%c3%a9rification" class="header-anchor"&gt;&lt;/a&gt;Vérification
&lt;/h2&gt;&lt;p&gt;Nous allons vérifier le fonctionnement du parser et du nouveau scénario dédié à gitlab.&lt;/p&gt;
&lt;p&gt;Pour cela, spammez la page de login de Gitlab, puis vérifiez les résultats :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Alertes :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli alerts list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 2 │ Ip:66.66.66.66 │ timokoessler/gitlab-bf │ │ │ ban:1 │ 2024-07-19 07:56:48.649063483 +0000 UTC&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Décisions :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli decisions list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 15001 │ crowdsec │ Ip:66.66.66.66 │ timokoessler/gitlab-bf │ ban │ │ │ 6 │ 3h59m43.261827214s │ 2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;En suivant ce guide, vous avez sécurisé l'authentification de votre Gitlab contre les attaques de Bruteforce grâce à CrowdSec. &lt;/p&gt;</description></item><item><title>CrowdSec : Protéger l’authentification Proxmox</title><link>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/</link><pubDate>Thu, 18 Jul 2024 14:50:45 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-proteger-lauthentification-proxmox/cover.png" alt="Featured image of post CrowdSec : Protéger l’authentification Proxmox" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Ce guide explique comment protéger l'authentification sur Proxmox contre les attaques de Bruteforce à l'aide de CrowdSec. Suite aux dernières actualités de VMware, de nombreux utilisateurs ont migré vers Proxmox. Il est donc essentiel de sécuriser le portail d'authentification, exposé par défaut sur le port TCP 8006.&lt;/p&gt;
&lt;p&gt;Ce guide se base sur une installation de Proxmox sur Debian 12. Par défaut, &lt;code&gt;rsyslog&lt;/code&gt; n'est plus installé sur Debian 12. Nous verrons comment configurer cela avec &lt;code&gt;journald&lt;/code&gt; mais également avec &lt;code&gt;rsyslog&lt;/code&gt; si besoin.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Une machine Debian 12 avec un accès root ou sudo. Toutes les commandes présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Une connexion internet active.&lt;/li&gt;
&lt;li&gt;Proxmox installé&lt;/li&gt;
&lt;li&gt;CrowdSec installé (voir ici : &lt;a href="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/"&gt;Installation de CrowdSec&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="installation-de-la-collection-pour-proxmox"&gt;&lt;a href="#installation-de-la-collection-pour-proxmox" class="header-anchor"&gt;&lt;/a&gt;Installation de la collection pour proxmox
&lt;/h2&gt;&lt;p&gt;En navigant sur le hub de CrowdSec, une collection pour proxmox est disponible.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installer la collection :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli collections install fulljackz/proxmox
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ceci a pour effet d'installer 2 parsers et 1 scénario.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Lister les parsers :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli parsers list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# crowdsecurity/syslog-logs ✔️ enabled 0.8 /etc/crowdsec/parsers/s00-raw/syslog-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# fulljackz/proxmox-logs ✔️ enabled 0.2 /etc/crowdsec/parsers/s01-parse/proxmox-logs.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lister les sénarios :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli scenario list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# fulljackz/proxmox-bf ✔️ enabled 0.2 /etc/crowdsec/scenarios/proxmox-bf.yaml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pour que ceux-ci soient pris en compte, le service CrowdSec doit être rechargé. Nous le ferons après quelques modifications.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="modification-du-parser-proxmox"&gt;&lt;a href="#modification-du-parser-proxmox" class="header-anchor"&gt;&lt;/a&gt;Modification du parser proxmox
&lt;/h2&gt;&lt;p&gt;Le parser spécifique à proxmox se situe ici : &lt;strong&gt;/etc/crowdsec/parsers/s01-parse/proxmox-logs.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Pour qu'il soit compatible avec la dernière version de Proxmox, nous allons l'éditer et apporter les modifications suivantes :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;pattern_syntax&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;PVE_AUTH_FAIL&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;authentication failure; rhost=::ffff:%{IP:client_ip} user=%{USERNAME:source_user}@%{WORD:realm} msg=&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ajout : &lt;code&gt;::ffff:&lt;/code&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="création-du-fichier-dacquisition"&gt;&lt;a href="#cr%c3%a9ation-du-fichier-dacquisition" class="header-anchor"&gt;&lt;/a&gt;Création du fichier d&amp;rsquo;acquisition
&lt;/h2&gt;&lt;p&gt;Afin que le parser Proxmox puisse être utilisé, il faut définir la méthode d'acquisition.&lt;/p&gt;
&lt;h3 id="utilisation-avec-journald"&gt;&lt;a href="#utilisation-avec-journald" class="header-anchor"&gt;&lt;/a&gt;Utilisation avec journald
&lt;/h3&gt;&lt;p&gt;Pour utiliser le parser avec journald :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/proxmox.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;journalctl_filter&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;_SYSTEMD_UNIT=pvedaemon.service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;syslog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="utilisation-avec-rsyslog"&gt;&lt;a href="#utilisation-avec-rsyslog" class="header-anchor"&gt;&lt;/a&gt;Utilisation avec rsyslog
&lt;/h3&gt;&lt;p&gt;Si vous préférez utiliser rsyslog avec le fichier de log &lt;code&gt;/var/log/syslog&lt;/code&gt; :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Installez &lt;code&gt;rsyslog&lt;/code&gt; si ce n'est pas déjà fait :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install -y rsyslog
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Créez le fichier &lt;strong&gt;/etc/crowdsec/acquis.d/proxmox.yaml&lt;/strong&gt; avec le contenu suivant :&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;filenames&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/var/log/syslog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;labels&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pvedaemon&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="redémarrage-du-service"&gt;&lt;a href="#red%c3%a9marrage-du-service" class="header-anchor"&gt;&lt;/a&gt;Redémarrage du service
&lt;/h2&gt;&lt;p&gt;A présent, le service crowdsec peut être rechargé :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl reload crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="vérification"&gt;&lt;a href="#v%c3%a9rification" class="header-anchor"&gt;&lt;/a&gt;Vérification
&lt;/h2&gt;&lt;p&gt;Nous allons vérifier le fonctionnement des parsers et du nouveau scénario dédié à proxmox.&lt;/p&gt;
&lt;p&gt;Pour cela, spammez la page de login de Proxmox, puis vérifiez les résultats :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Alertes :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli alerts list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# | 2 │ Ip:66.66.66.66 │ fulljackz/proxmox-bf │ │ │ ban:1 │ 2024-07-18 12:13:37.498899667 +0000 UTC &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Décisions :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli decisions list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# 15001 │ crowdsec │ Ip:66.66.66.66 │ fulljackz/proxmox-bf │ ban │ │ │ 7 │ 3h59m51.44622068s │ 2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;En suivant ce guide, vous avez sécurisé l'authentification de votre Proxmox contre les attaques de Bruteforce grâce à CrowdSec. &lt;/p&gt;</description></item><item><title>CrowdSec : Installation avec Bouncer Iptables sur Debian 12</title><link>https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/</link><pubDate>Thu, 18 Jul 2024 10:28:12 +0200</pubDate><guid>https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/</guid><description>&lt;img src="https://beta.slash-root.fr/crowdsec-installation-avec-bouncer-iptables-sur-debian-12/cover.png" alt="Featured image of post CrowdSec : Installation avec Bouncer Iptables sur Debian 12" /&gt;&lt;h2 id="introduction"&gt;&lt;a href="#introduction" class="header-anchor"&gt;&lt;/a&gt;Introduction
&lt;/h2&gt;&lt;p&gt;CrowdSec est un système de cybersécurité collaboratif qui utilise des mécanismes de détection et de prévention pour protéger votre infrastructure. Ce guide vous guidera à travers l'installation de CrowdSec ainsi que de son bouncer iptables sur une machine Debian 12, avec la complétion de la commande &lt;code&gt;cscli&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="prérequis"&gt;&lt;a href="#pr%c3%a9requis" class="header-anchor"&gt;&lt;/a&gt;Prérequis
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;Une machine Debian 12 avec un accès root ou sudo. Toutes les commandes présentées ci-dessous seront à exécuter en tant que &lt;code&gt;root&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Une connexion internet active.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id="étape-1--mise-à-jour-du-système"&gt;&lt;a href="#%c3%a9tape-1--mise-%c3%a0-jour-du-syst%c3%a8me" class="header-anchor"&gt;&lt;/a&gt;Étape 1 : Mise à jour du système
&lt;/h2&gt;&lt;p&gt;Avant de commencer l'installation, assurez-vous que votre système est à jour.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt -y upgrade
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="étape-2--installation-de-crowdsec"&gt;&lt;a href="#%c3%a9tape-2--installation-de-crowdsec" class="header-anchor"&gt;&lt;/a&gt;Étape 2 : Installation de CrowdSec
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ajouter le dépôt CrowdSec&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Téléchargez et ajoutez la clé GPG pour vérifier l'intégrité du dépôt :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Installer CrowdSec&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Installez le package CrowdSec :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install -y crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vérifier l'installation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Assurez-vous que CrowdSec est correctement installé et en cours d'exécution :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl status crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="étape-3--installation-du-bouncer-iptables"&gt;&lt;a href="#%c3%a9tape-3--installation-du-bouncer-iptables" class="header-anchor"&gt;&lt;/a&gt;Étape 3 : Installation du Bouncer Iptables
&lt;/h2&gt;&lt;p&gt;Le bouncer iptables permet à CrowdSec de bloquer les adresses IP malveillantes directement au niveau du pare-feu. C'est lui qui applique les décisions prises par crowdsec.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Télécharger et installer le bouncer iptables&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install -y crowdsec-firewall-bouncer-iptables
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Configurer le bouncer&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;L'installation crée un fichier de configuration par défaut à &lt;code&gt;/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml&lt;/code&gt;. Vous pouvez vérifier et modifier ce fichier selon vos besoins.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Démarrer et activer le bouncer&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Assurez-vous que le bouncer est activé au démarrage et qu'il est en cours d'exécution :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl enable crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl start crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vérifier le bouncer&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Vérifiez que le bouncer est correctement installé et en cours d'exécution :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl status crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="étape-4--activer-la-complétion-de-la-commande-cscli"&gt;&lt;a href="#%c3%a9tape-4--activer-la-compl%c3%a9tion-de-la-commande-cscli" class="header-anchor"&gt;&lt;/a&gt;Étape 4 : Activer la complétion de la commande &lt;code&gt;cscli&lt;/code&gt;
&lt;/h2&gt;&lt;p&gt;La complétion de commande rend l'utilisation de &lt;code&gt;cscli&lt;/code&gt; plus efficace en permettant l'auto-complétion des commandes et options disponibles.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Installer les scripts de complétion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Pour &lt;code&gt;bash&lt;/code&gt;, vous pouvez utiliser le script de complétion fourni par CrowdSec. Tout d'abord, assurez-vous que &lt;code&gt;bash-completion&lt;/code&gt; est installé :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;apt install -y bash-completion
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Activer la complétion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Installez le script de complétion pour &lt;code&gt;cscli&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli completion bash &amp;gt; /etc/bash_completion.d/cscli
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Recharger la configuration de bash&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Rechargez votre configuration de bash pour que la complétion soit prise en compte :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source /etc/bash_completion.d/cscli
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vérifier la complétion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Testez la complétion automatique en tapant &lt;code&gt;cscli&lt;/code&gt; suivi de &lt;code&gt;Tab&lt;/code&gt; pour voir les options disponibles.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="étape-5--vérification-de-lintégration"&gt;&lt;a href="#%c3%a9tape-5--v%c3%a9rification-de-lint%c3%a9gration" class="header-anchor"&gt;&lt;/a&gt;Étape 5 : Vérification de l&amp;rsquo;intégration
&lt;/h2&gt;&lt;p&gt;Pour vérifier que tout fonctionne correctement, vous pouvez consulter les journaux de CrowdSec et du bouncer iptables :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;journalctl -u crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;h2 id="étape-6-option--configuration-bantime"&gt;&lt;a href="#%c3%a9tape-6-option--configuration-bantime" class="header-anchor"&gt;&lt;/a&gt;Étape 6 (Option) : Configuration bantime
&lt;/h2&gt;&lt;p&gt;Par défaut, la décision qui est appliqué par le bouncer iptables est un ban de 4h. Bien évidement, il est possible de modifier ce comportement. Exemple pour passer cette durée à 24h :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Editez le fichier /etc/crowdsec/profiles.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;decisions&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- &lt;span style="color:#f92672"&gt;type&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;ban&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;duration&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;24h&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Recharger le service crowdsec&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl reload crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="étape-7-option--enrôlement-de-la-console"&gt;&lt;a href="#%c3%a9tape-7-option--enr%c3%b4lement-de-la-console" class="header-anchor"&gt;&lt;/a&gt;Étape 7 (Option) : Enrôlement de la console
&lt;/h2&gt;&lt;p&gt;Il est possible d'enrôler CrowdSec sur &lt;a href="https://app.crowdsec.net/"&gt;https://app.crowdsec.net/&lt;/a&gt; pour avoir un jolie tableau de bord et une visualisation globale. L'autre intérêt, va être la possibilité d'ajouter des listes d'IP malveillantes maintenues par CrowdSec à nos instances. Coucou la liste disponible pour les JO 2024 🙂&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Créer un compte sur &lt;a href="https://app.crowdsec.net/"&gt;https://app.crowdsec.net/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Validez votre compte en vous authentifiant sur la plateforme&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rendez vous dans le menu &amp;quot;Security Engines&amp;quot; &amp;gt; &amp;quot;Engines&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Cliquez sur &amp;quot;Add Security Engine&amp;quot;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Exécutez la commande d'enrôlement sur votre serveur&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli console enroll -e context YOUR-ENROLL-KEY
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Dans un contexte d'automatisation, il est possible de spécifier le nom d'hôte :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cscli console enroll --name &lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;hostname&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; YOUR-ENROLL-KEY
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Voici l'aide de la commande : &lt;a href="https://docs.crowdsec.net/docs/next/cscli/cscli_console_enroll/"&gt;https://docs.crowdsec.net/docs/next/cscli/cscli_console_enroll/&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Acceptez l'enrôlement sur la plateforme web de CrowdSec&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Redémarrez le service crowdsec sur le serveur&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="modification-du-port-de-lapi"&gt;&lt;a href="#modification-du-port-de-lapi" class="header-anchor"&gt;&lt;/a&gt;Modification du port de l&amp;rsquo;API
&lt;/h2&gt;&lt;p&gt;Par défaut CrowdSec utilise le port TCP 8080 pour accéder à son API. Si ce port est déjà utilisé sur votre serveur, il est important de modifier la configuration de CrowdSec pour que l'API en utilise un autre.&lt;/p&gt;
&lt;p&gt;Exemple pour utiliser le port TCP 6660 à la place du TCP 8080 :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modifiez le fichier /etc/crowdsec/config.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;api&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;client&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#ae81ff"&gt;...]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;server&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#ae81ff"&gt;...]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;listen_uri&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;127.0.0.1&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;6660&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modifiez le fichier /etc/crowdsec/local_api_credentials.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;http://127.0.0.1:6660&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modifier le fichier /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;api_url&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;http://127.0.0.1:6660/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Redémarrez les services crowdsec&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart crowdsec
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart crowdsec-firewall-bouncer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;Vous avez maintenant installé et configuré CrowdSec avec le bouncer iptables sur votre machine Debian 12, et activé la complétion de la commande &lt;code&gt;cscli&lt;/code&gt;. Ce système devrait maintenant aider à protéger votre infrastructure contre les adresses IP malveillantes. Assurez-vous de consulter régulièrement les journaux et de maintenir votre système à jour pour garantir une protection optimale.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="ressources-supplémentaires"&gt;&lt;a href="#ressources-suppl%c3%a9mentaires" class="header-anchor"&gt;&lt;/a&gt;Ressources supplémentaires
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.crowdsec.net/"&gt;Documentation officielle de CrowdSec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/crowdsecurity/crowdsec"&gt;Dépot GitHub de CrowdSec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discourse.crowdsec.net/"&gt;Communauté CrowdSec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>