<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eric Beaulieu on Medium]]></title>
        <description><![CDATA[Stories by Eric Beaulieu on Medium]]></description>
        <link>https://medium.com/@eric.beaulieu_49318?source=rss-38faaf8095b0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3VQTuuWZnB4bYSa4</url>
            <title>Stories by Eric Beaulieu on Medium</title>
            <link>https://medium.com/@eric.beaulieu_49318?source=rss-38faaf8095b0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:22:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eric.beaulieu_49318/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Casser le mot de passe d’un certificat]]></title>
            <link>https://medium.com/@eric.beaulieu_49318/casser-le-mot-de-passe-dun-certificat-4f88cb3114d6?source=rss-38faaf8095b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f88cb3114d6</guid>
            <dc:creator><![CDATA[Eric Beaulieu]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 12:23:09 GMT</pubDate>
            <atom:updated>2026-06-26T12:23:09.088Z</atom:updated>
            <content:encoded><![CDATA[<p>Dans cet article, nous allons voir comment (re)trouver le mot de passe qui protège un container pfx.</p><p>Pour rappel, un fichier pfx ou PKCS#12 est container qui contient à la fois le certificat et sa clef privée associée. On y trouve parfois également les certificats des autorités de certification associées. Il est dans la majorité des cas protégé par un mot de passe (mais pas obligatoirement).</p><h3>Génération du container pfx</h3><p>Commençons par générer le fichier PFX protégé par un mot de passe</p><pre>#Création de la clef privée :<br>$ openssl genrsa -out mykey.pem 4096<br><br>#Création du certificat auto-signé - valable 365 jours<br>$ openssl req -new -x509 -key mykey.pem -out cert.pem -days 365<br>You are about to be asked to enter information that will be incorporated<br>into your certificate request.<br>What you are about to enter is what is called a Distinguished Name or a DN.<br>There are quite a few fields but you can leave some blank<br>For some fields there will be a default value,<br>If you enter &#39;.&#39;, the field will be left blank.<br>-----<br>Country Name (2 letter code) [AU]:FR<br>State or Province Name (full name) [Some-State]:MyState<br>Locality Name (eg, city) []:MyCity<br>Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyOrg<br>Organizational Unit Name (eg, section) []:DSI<br>Common Name (e.g. server FQDN or YOUR name) []:mycert.myorg.com<br>Email Address []:mymail.myorg.com<br><br>#Création du container PFX contenant la clef privée et le certificat protégé par le mot de passe : P@55w0rd<br>$ openssl pkcs12 -export -out mycontainer.pfx -inkey mykey.pem -in cert.pem -password pass:P@55w0rd</pre><p>Maintenant que nous avons notre fichier protégé, supposons que le mot de passe a été perdu et que nous souhaitions le retrouver.</p><h3>Cassons un container (pfx) dans un container (docker)</h3><p>Dans notre exemple, nous ne chercherons pas la performance pour casser le mot de passe. C’est pourquoi pour aller au plus simple, nous n’installerons pas l&#39;outil John The Ripper, mais l’utiliserons à travers un container docker.</p><pre>$ docker run -it - hostname jtr - rm -v $(pwd):/hashes/:ro phocean/john_the_ripper_jumbo<br>root@jtr:/jtr/run# ./john<br>John the Ripper 1.9.0-jumbo-1+bleeding- OMP [linux-gnu 64-bit x86_64 AVX2 AC]<br>Copyright © 1996–2021 by Solar Designer and others<br>Homepage: https://www.openwall.com/john/</pre><p>Résolvons un petit problème de dépendance pour utiliser l&#39;outil pfx2john.py</p><pre>root@jtr:/jtr/run# apt-get update<br>root@jtr:/jtr/run# apt-get install python-pip<br></pre><p>Maintenant, il est possible d’extraire le hash du mot de passe du fichier pfx et de lancer john afin de trouver le mot de passe :</p><pre>root@jtr:/jtr/run# ./pfx2john.py /hashes/home/zebux/pfx/mycontainer.pfx &gt; pwd_pfx.hash<br>root@jtr:/jtr/run# ./john pwd_pfx.hash --wordlist=/hashes/rockyou.txt<br>Using default input encoding: UTF-8<br>Loaded 1 password hash (pfx, (.pfx, .p12) [PKCS#12 PBE (SHA1/SHA2) 256/256 AVX2 8x])<br>Cost 1 (iteration count) is 2048 for all loaded hashes<br>Cost 2 (mac-type [1:SHA1 224:SHA224 256:SHA256 384:SHA384 512:SHA512]) is 256 for all loaded hashes<br>Will run 8 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>P@55w0rd         (mycontainer.pfx)<br>1g 0:00:00:04 DONE (2025-05-26 20:05) 0.2057g/s 39190p/s 39190c/s 39190C/s becky101..556689<br>Use the &quot;--show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>En quelques secondes, john trouve le mot de passe présent dans la wordlist rockyou.</p><p>Alternative, un container avec crackpkcs12</p><p>Il existe d’autres outils permettant de casser le mot de passe d’un fichier pfx, crackpkcs12 est l’un d’entre eux.</p><p>Créons un fichier Dockerfile permettant d’installer crackpkcs12 à l’interrière d’un container docker basé sur une image Debian :</p><pre>└─$ cat Dockerfile<br>FROM debian:latest AS builder<br><br>RUN apt-get update &amp;&amp; apt-get -y upgrade &amp;&amp; apt-get install -y libssl-dev build-essential autoconf libpcap-dev<br>RUN apt-get install -y make git<br>RUN git clone https://github.com/crackpkcs12/crackpkcs12.git<br>WORKDIR /crackpkcs12/<br>RUN ./configure &amp;&amp; make &amp;&amp; make install<br><br>ENTRYPOINT [&quot;/usr/local/bin/crackpkcs12&quot;]</pre><p>On build l’image docker</p><pre>docker build . -t zebux/docker_crackpkcs12 --no-cache</pre><p>Il n’y a plus qu’à lancer l’attaque par dictionnaire avec la lige de commande :</p><pre> docker run -it --rm -v /mydict/:/dict/:ro -v /pfx/:/pfx/:ro zebux/docker_crackpkcs12 -d /dict/rockyouold.txt /pfx/mycontainer.pfx<br><br>Dictionary attack - Starting 8 threads<br><br>*********************************************************<br>Dictionary attack - Thread 4 - Password found: P@55w0rd<br>*********************************************************</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f88cb3114d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Retrouver le mot de passe d’un certificat PFX (PKCS#12)]]></title>
            <link>https://medium.com/@eric.beaulieu_49318/retrouver-le-mot-de-passe-dun-certificat-pfx-pkcs-12-6daf4743daeb?source=rss-38faaf8095b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6daf4743daeb</guid>
            <dc:creator><![CDATA[Eric Beaulieu]]></dc:creator>
            <pubDate>Mon, 26 May 2025 20:55:51 GMT</pubDate>
            <atom:updated>2025-05-26T20:55:51.981Z</atom:updated>
            <content:encoded><![CDATA[<p>Dans cet article, nous allons voir comment <strong>retrouver</strong> un mot de passe perdu protégeant un conteneur PFX. Ce type de fichier, aussi appelé <strong>PKCS#12</strong>, contient à la fois un certificat et sa clé privée. Il peut aussi inclure des certificats intermédiaires ou racines. Dans la majorité des cas, il est protégé par un mot de passe (mais pas obligatoirement).</p><h3>Génération d’un conteneur PFX</h3><p>Commençons par générer un fichier .pfx protégé par mot de passe :</p><pre>#Création de la clef privée :<br>$ openssl genrsa -out mykey.pem 4096<br><br>#Création du certificat auto-signé - valable 365 jours<br>$ openssl req -new -x509 -key mykey.pem -out cert.pem -days 365<br>You are about to be asked to enter information that will be incorporated<br>into your certificate request.<br>What you are about to enter is what is called a Distinguished Name or a DN.<br>There are quite a few fields but you can leave some blank<br>For some fields there will be a default value,<br>If you enter &#39;.&#39;, the field will be left blank.<br>-----<br>Country Name (2 letter code) [AU]:FR<br>State or Province Name (full name) [Some-State]:MyState<br>Locality Name (eg, city) []:MyCity<br>Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyOrg<br>Organizational Unit Name (eg, section) []:DSI<br>Common Name (e.g. server FQDN or YOUR name) []:mycert.myorg.com<br>Email Address []:mymail.myorg.com<br><br>#Création du container PFX contenant la clef privée et le certificat protégé par le mot de passe : P@55w0rd<br>$ openssl pkcs12 -export -out mycontainer.pfx -inkey mykey.pem -in cert.pem -password pass:P@55w0rd</pre><p>À ce stade, nous disposons d’un fichier .pfx protégé par mot de passe. Supposons maintenant que ce mot de passe soit perdu. Comment le retrouver ?</p><h3>Brute-force d’un fichier PFX avec Docker et John The Ripper</h3><p>Plutôt que d’installer John The Ripper localement, nous allons utiliser un <strong>conteneur Docker</strong> prêt à l’emploi. Ce n’est pas la méthode la plus performante, mais elle a l’avantage d’être rapide à mettre en place.</p><p>Lancer le conteneur Docker</p><pre>$ docker run -it - hostname jtr - rm -v $(pwd):/hashes/:ro phocean/john_the_ripper_jumbo<br>root@jtr:/jtr/run# ./john<br>John the Ripper 1.9.0-jumbo-1+bleeding- OMP [linux-gnu 64-bit x86_64 AVX2 AC]<br>Copyright © 1996–2021 by Solar Designer and others<br>Homepage: https://www.openwall.com/john/</pre><p>Résolvons un petit problème de dépendance pour utiliser l’outil pfx2john.py</p><pre>root@jtr:/jtr/run# apt-get update<br>root@jtr:/jtr/run# apt-get install -y python-pip</pre><p>Extraction du hash avec pfx2john</p><pre>root@jtr:/jtr/run# ./pfx2john.py /hashes/mycontainer.pfx &gt; pwd_pfx.hash</pre><p>Lancer l’attaque par dictionnaire</p><pre>root@jtr:/jtr/run# ./pfx2john.py /hashes/home/zebux/pfx/mycontainer.pfx &gt; pwd_pfx.hash<br>root@jtr:/jtr/run# ./john pwd_pfx.hash --wordlist=/hashes/rockyou.txt<br>Using default input encoding: UTF-8<br>Loaded 1 password hash (pfx, (.pfx, .p12) [PKCS#12 PBE (SHA1/SHA2) 256/256 AVX2 8x])<br>Cost 1 (iteration count) is 2048 for all loaded hashes<br>Cost 2 (mac-type [1:SHA1 224:SHA224 256:SHA256 384:SHA384 512:SHA512]) is 256 for all loaded hashes<br>Will run 8 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>P@55w0rd         (mycontainer.pfx)<br>1g 0:00:00:04 DONE (2025-05-26 20:05) 0.2057g/s 39190p/s 39190c/s 39190C/s becky101..556689<br>Use the &quot;--show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>Le mot de passe a été retrouvé en quelques secondes grâce à wordlist rockyou.txt.</p><h3>Alternative : utiliser crackpkcs12 dans un conteneur personnalisé</h3><p>Un autre outil intéressant est <a href="https://github.com/crackpkcs12/crackpkcs12">crackpkcs12</a>, spécialement conçu pour attaquer les fichiers PFX. Aussi pour faire simple, nous allons installer l’outil dans un container docker et lancer ce dernier directement depuis notre ligne de commande.</p><p>Dockerfile pour builder une image avec crackpkcs12</p><pre>└─$ cat Dockerfile<br>FROM debian:latest AS builder<br><br>RUN apt-get update &amp;&amp; apt-get -y upgrade &amp;&amp; apt-get install -y libssl-dev build-essential autoconf libpcap-dev<br>RUN apt-get install -y make git<br>RUN git clone https://github.com/crackpkcs12/crackpkcs12.git<br>WORKDIR /crackpkcs12/<br>RUN ./configure &amp;&amp; make &amp;&amp; make install<br><br>ENTRYPOINT [&quot;/usr/local/bin/crackpkcs12&quot;]</pre><p>Build l’image Docker</p><pre>docker build . -t zebux/docker_crackpkcs12 --no-cache</pre><p>Lancer l’attaque par dictionnaire</p><pre>docker run -it --rm -v /mydict/:/dict/:ro -v /pfx/:/pfx/:ro zebux/docker_crackpkcs12 -d /dict/rockyouold.txt /pfx/mycontainer.pfx<br><br>Dictionary attack - Starting 8 threads<br><br>*********************************************************<br>Dictionary attack - Thread 4 - Password found: P@55w0rd<br>*********************************************************</pre><p>Après quelques minutes, le mot de passe est trouvé par crackpkcs12.</p><h3>Conclusion</h3><p>Avec des outils comme <strong>John The Ripper</strong> ou <strong>crackpkcs12</strong>, retrouver un mot de passe PFX oublié devient faisable, surtout si vous disposez d’une bonne wordlist. Bien entendu, cela montre aussi pourquoi il est crucial de choisir des mots de passe forts et non présents dans les dictionnaires.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6daf4743daeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comment copier un fichier sur un serveur Linux sans scp, (s)ftp ou HTTP ?]]></title>
            <link>https://medium.com/@eric.beaulieu_49318/comment-copier-un-fichier-sur-un-serveur-linux-sans-scp-s-ftp-ou-http-8cb0b732fa87?source=rss-38faaf8095b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cb0b732fa87</guid>
            <dc:creator><![CDATA[Eric Beaulieu]]></dc:creator>
            <pubDate>Wed, 09 Apr 2025 20:45:17 GMT</pubDate>
            <atom:updated>2025-04-09T20:56:17.709Z</atom:updated>
            <content:encoded><![CDATA[<h3>Comment copier un fichier sur un serveur Linux sans scp, (s)ftp ou HTTP ?</h3><p>Il peut arriver qu’on ait besoin de copier un <strong>petit fichier texte (une clef SSH, un certificat, une licence…) </strong>sur un <strong>serveur Linux distant</strong> où l’on est connecté en SSH (parce que bon, Telnet, c’est fini depuis longtemps 😅).</p><p>Prenons un exemple concret : tu viens de renouveler un certificat (et sa clé privée), et tu veux les déposer rapidement sur ton serveur distant.</p><p>Depuis des années, dans ce genre de situation</p><ul><li>Soit je copie le contenue de mon fichier original, je lance un vi(m) d’un nouveau fichier texte sur le serveur distant</li><li>soit je lance un winscp.exe ou j’ouvre un second terminal afin de faire un simple scp des fichiers en question.</li></ul><p>Mais aujourd’hui, je te propose une <strong>petite astuce</strong> qui va ravir les plus flemmards d’entre nous (amis sys/net/sec admin, je vous vois 👀).</p><h3>📝 Copier un fichier texte via le presse-papiers</h3><p>Imaginons que tu veuilles copier le contenu d’un fichier texte (mon_fichier.txt) depuis ta machine locale vers le serveur.</p><ol><li><strong>Sur ta machine locale</strong>, affiche le contenu du fichier :</li></ol><pre>cat mon_fichier.txt</pre><p>2. <strong>Sélectionne</strong> le contenu et copie-le dans le presse-papiers (Ctrl+C, clic droit, molette... selon ton terminal).</p><p><strong>3. Sur le serveur distant</strong> (via SSH), tape :</p><pre>cat &gt; mon_fichier_distant.txt</pre><p><strong>4. Colle</strong> le contenu depuis ton presse-papiers (Ctrl+V, clic droit…).</p><p>Et voilà 🎉, tu peux vérifier le résultat :</p><pre>cat mon_fichier_distant.txt</pre><blockquote><em>Tu vas me dire : “Ouais, j’aurais pu faire la même chose en lançant </em><em>vim et en collant dedans le texte dedans.” C’est vrai. Mais attends, on va aller un peu plus loin...</em></blockquote><h3>🔐 Copier un fichier binaire avec la même méthode</h3><p>Et oui, cette technique peu fonctionner pour les binaires ! Mais il y a un piège : si tu tentes de copier un binaire brut via cat et le presse-papiers, le fichier sera <strong>corrompu</strong> à l’arrivée.</p><p>Alors comment faire ? 🧠</p><p><strong>1. Sur ta machine local</strong></p><p>D’abord, vérifions l’empreinte MD5 du fichier original pour s’assurer que le fichier sera identique à l’arrivé :</p><pre>md5sum mimikatz.exe<br>29efd64dd3c7fe1e2b022b7ad73a1ba5  mimikatz.exe</pre><p>Ensuite, <strong>encode le fichier en base64</strong> et copie le résultat dans le presse-papiers :</p><pre>base64 mimikatz.exe | clip.exe  </pre><blockquote>clip.exe <em>si tu es sous WSL/Windows pour copier dans ton presse papier, </em>s<em>ous Linux</em><em>xclip -selection clipboard et</em><em>pbcopy sur macOS.</em></blockquote><p><strong>2. Sur le serveur distant</strong></p><p>Toujours connecté en SSH, colle le contenu dans un nouveau fichier temporaire :</p><pre>cat &gt; mimikatz-b64.txt</pre><p>Ensuite, <strong>décodons le fichier base64</strong> pour reconstituer le fichier original :</p><pre>base64 -d mimikatz-b64.txt &gt; mimikatz.exe</pre><p>Vérifions que l’empreinte MD5 correspond :</p><pre>md5sum mimikatz.exe<br>29efd64dd3c7fe1e2b022b7ad73a1ba5  mimikatz.exe</pre><p>✅ Fichier intact, mission accomplie.</p><h3>🔚 Conclusion</h3><p>Pas besoin de scp, ftp, ou de monter un serveur HTTP pour transférer un fichier rapidement sur un serveur Linux distant. Une simple connexion SSH, un peu de base64, et ton presse-papiers suffisent ! Bien évidement, pour copier des fichiers relativement conséquents, là on préfèrera les méthodes traditionnelles telles que scp ou (s)ftp…</p><p>C’est rapide, pratique, et ça peut même dépanner dans des environnements restreints où les transferts classiques ne sont pas possibles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cb0b732fa87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quel programme a ouvert ce port réseau ?]]></title>
            <link>https://medium.com/@eric.beaulieu_49318/quel-programme-a-ouvert-ce-port-r%C3%A9seau-42025881c663?source=rss-38faaf8095b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/42025881c663</guid>
            <dc:creator><![CDATA[Eric Beaulieu]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 20:45:00 GMT</pubDate>
            <atom:updated>2025-03-21T20:45:00.965Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quel programme a ouvert ce port réseau ?</h3><p>En tant qu’administrateur système / réseau / sécurité, il peut arriver que l’on se demande quel programme ou processus a ouvert un port réseau sur notre serveur.</p><p>Dans cet article, nous allons voir comment obtenir rapidement cette information sur un serveur Windows et sur un serveur Linux.</p><p>Cette démarche peut être utile pour découvrir quel serveur web utilise le port TCP 80/443 ou quel programme a ouvert un port TCP non identifié.</p><h3>Sous Windows</h3><p>Sur un serveur Windows, ouvrir une invite de commande en mode administrateur.</p><pre>C:\&gt;netstat -ano | findstr LIST<br>TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 528<br>TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4<br>TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 1868</pre><p>Cette commande permet d’afficher les informations sur les connexions réseau. Que ce soit les connexions actives, les ports en écoute sur notre serveur TCP / UDP ou les informations de routage.</p><p>Le détail sur les commutateurs précédemment utilisés est :</p><p>- a affiche toutes les connexions et les ports en écoute,</p><p>-n permet de ne pas faire de résolution DNS ou du nom du port,</p><p>-o affiche le processus qui a initié la connexion ou ouvert le port,</p><p>| finstr LIST filtre le résultat sur la chaîne de caractère « LIST » pour n’afficher que les ports en écoute.</p><p>On peut maintenant filtrer sur un port en particulier, ici pour le port TCP 1433 (Microsoft SQL Server)</p><pre>C:\ &gt;netstat -ano | findstr 1433<br>TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 1868</pre><p>On identifie ici que le processus avec l’ID <strong>1868 </strong>est à l’origine de l’ouverture de ce port.</p><p>L’outil Task Manager permettra de rapidement identifier le programme possédant ce PID :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*7mjZ0srlLeZ1KiNaQsgwrA.png" /></figure><p>Si l’on souhaite, on peut également utiliser PowerShell :</p><pre>PS C:\Windows\system32&gt; Get-Process -Id 1868 | Format-Table Id, Name, Path<br>Id Name Path<br> - - - - - <br>1868 sqlservr C:\Program Files\Microsoft SQL Server\MSSQL.MSSQLSERVER\MSSQL\Binn\sqlservr.exe</pre><h3>Sous Linux</h3><p>Sous Linux pour identifier le processus responsable de l’ouverture d’un port réseau, plusieurs outils sont disponibles.</p><p><strong>Netstat ou ss</strong></p><p>De manière identique à windows, l’outil netstat ou son remplaçant ss permet d’afficher les informations relatives aux connexions réseau ou port ouvert :</p><pre># netstat -alntp | grep 3306<br>tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2081/mysqld<br><br># ss -alntp | grep 3306<br>LISTEN 0 50 *:3306 *:* users:((&quot;mysqld&quot;,pid=2081,fd=14))</pre><p>Un autre outil permet d’obtenir le numéro du processus ayant ouvert un port réseau, c’est lsof. Avec son commutateur -i il permet d’obtenir les informations relatives au réseau.</p><pre># lsof -i :3306<br>COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME<br>mysqld 2081 mysql 14u IPv4 27244 0t0 TCP *:mysql (LISTEN)</pre><p>Il faut ensuite utiliser l’outil ps pour avoir le détail de la commande qui a été utilisé</p><pre># ps -p 2081 -v<br>PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND<br>2081 ? Sl 1031:21 37335 12996 1159059 30436 0.7 /usr/libexec/mysqld - basedir=/usr - datadir=/var/lib/mysql - plugin-dir=/usr/lib64/mysql/plugin - log-error=/var/log/mariadb/mariadb.log - pid-file=/</pre><p>Ou avec moins de détail si on recherche dans le répertoire /proc/</p><pre># readlink -f /proc/2081/exe<br>/usr/libexec/mysqld<br><br># ls -al /proc/2081/exe<br>lrwxrwxrwx 1 mysql mysql 0 Feb 5 03:11 /proc/2081/exe -&gt; /usr/libexec/mysqld</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42025881c663" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exporter un certificat x509 marqué comme non exportable]]></title>
            <link>https://medium.com/@eric.beaulieu_49318/exporter-un-certificat-x509-marqu%C3%A9-comme-non-exportable-ecf1595065e1?source=rss-38faaf8095b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecf1595065e1</guid>
            <dc:creator><![CDATA[Eric Beaulieu]]></dc:creator>
            <pubDate>Thu, 20 Mar 2025 13:02:16 GMT</pubDate>
            <atom:updated>2025-03-20T13:02:16.430Z</atom:updated>
            <content:encoded><![CDATA[<p>En tant qu’administrateur système, il peut arriver que l’on se retrouve bloqué pour récupérer / exporter un certificat lors d’une migration ou lors de tests de sécurité.</p><p>Dans cet article, nous allons voir comment il est possible d’exporter un certificat x509 marqué comme non exportable, soit par l’administrateur de la PKI (l’autorité de certification), soit lors de son importation dans le magasin de certificats Windows.</p><h3>Création d’un certificat auto-signé</h3><p>Commençons par générer un certificat que nous marquerons explicitement comme non exportable lors de son installation :</p><pre>$ openssl req -new -x509 -sha256 -nodes -days 90 -out mycert.crt -keyout mycert.key<br>.......+.+.........+........+......+.......+++++++++++++++++++++++++++++++++++++++*....+...+++++++++++++++++++++++++++++++++++++++*........+...+.......+...............+...+........+...+......+.........+....+.....+..........+.....+......+.+...+......+......+.........+.....+.+......+..+.+............+............+........+...+......+....+..+....+.....+......+...+.+...+.....+.+.....+.+.....+...+......+......+...+...+...+.......+.....+...+....+..+.+........+......+.++++++<br>....+...+..+..........+......+..+...+.......+..+......+....+.....+......+.+......+++++++++++++++++++++++++++++++++++++++*.+.......+++++++++++++++++++++++++++++++++++++++*.......+....+..+.+............+..+.+...+.........+..+...+.+.........+......+.....+......................+..+...+.......+...............+........+.........+...+............+...+......+....+......+......+..............+...............+....+...............+..+....+.....+....+..+...+.+..+....+.....+....+..............+.+..+...+.+....................+.............+.....+.............+...+...........+...+...+.............+..+.......+......+..+............+.......+.........+......+.....+......+....+.....+.+........+....+............+...+..+...+.+.....+.......+..+......+.+........+......++++++<br>-----<br>You are about to be asked to enter information that will be incorporated<br>into your certificate request.<br>What you are about to enter is what is called a Distinguished Name or a DN.<br>There are quite a few fields but you can leave some blank<br>For some fields there will be a default value,<br>If you enter &#39;.&#39;, the field will be left blank.<br>-----<br>Country Name (2 letter code) [AU]:FR<br>State or Province Name (full name) [Some-State]:MyState<br>Locality Name (eg, city) []:MyCity<br>Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyOrg<br>Organizational Unit Name (eg, section) []:DSI<br>Common Name (e.g. server FQDN or YOUR name) []:mycert.myorg.com<br>Email Address []:mymail.myorg.org</pre><p>La commande précédente permet d’obtenir deux fichiers :</p><ul><li>la clé privée : mycert.key</li><li>le certificat auto-signé : mycert.crt</li></ul><p>Il est donc maintenant possible de créer un container PKCS12 à partir de ces deux fichiers :</p><pre>$ openssl pkcs12 -export -out mycert.pfx -inkey mycert.key -in mycert.crt<br>Enter Export Password:************<br>Verifying - Enter Export Password:************</pre><p>Si nous importons ce fichier sur un serveur Windows, sans cocher la case “Marqué comme exportable” :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*rz05RYDSEc3NyVqcB3c4jQ.png" /></figure><p>Nous n’aurons plus la possibilité lors d’un export d’obtenir le certificat ET sa clef privée :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*-h7FCQBWKJaiTWMWZxdZ2w.png" /></figure><p>On constate bien ici que l’option d’export de la clef privée est grisée. Il ne devrait donc plus être possible de récupérer la clef privée.</p><h3>Exportons la clef avec mimikatz</h3><p>Mimikatz est un outil qui sera détecté par la plupart des antivirus et EDR. Il faudra donc préalablement voir pour désactiver les outils de protection qui pourrait empêcher son bon fonctionnement.</p><pre>mimikatz # crypto::capi<br>Local CryptoAPI patched<br><br>mimikatz # crypto::certificates /systemstore:local_machine /store:my /export<br> * System Store  : &#39;local_machine&#39; (0x00020000)<br> * Store         : &#39;my&#39;<br><br> 0. example.domain.local<br>        Key Container  : example.domain.local<br>        Provider       : Microsoft Software Key Storage Provider<br>        Type           : CNG Key (0xffffffff)<br>        Exportable key : NO<br>        Key size       : 2048<br>        Public export  : OK - &#39;local_machine_my_0_example.domain.local.der&#39;<br>        Private export : OK - &#39;local_machine_my_0_example.domain.local.pfx&#39;<br><br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ONccWyH2AUUmoIClxcOVtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*cb4wFzpcSgTG7BPuVsP3ZQ.png" /><figcaption>Les fichiers exporter par mimikatz</figcaption></figure><p>On retrouve ici le certificat et un container PKSC12 contenant le certificat et la clef privée protégée par le mot de passe : mimikatz</p><pre>└─$ openssl pkcs12 -in local_machine_my_0_mycert.myorg.com-1.pfx -passin pass:mimikatz -passout pass:mimi -info<br>MAC: sha1, Iteration 2000<br>MAC length: 20, salt length: 20<br>PKCS7 Data<br>Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2000<br>Bag Attributes<br>    Microsoft Local Key set: &lt;No Values&gt;<br>    localKeyID: 01 00 00 00<br>    friendlyName: {F8663FCF-A802-4056-87BF-38EB5657F54B}<br>    Microsoft CSP Name: Microsoft Enhanced Cryptographic Provider v1.0<br>Key Attributes<br>    X509v3 Key Usage: 10<br>-----BEGIN ENCRYPTED PRIVATE KEY-----<br>MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQTOAi2IoBdbu7vLiC<br>[...]<br>Y3zvAAo7YsvahQw2Mb2j25jqAWTEqr789dFf0SAnY1PN+nyCM6xwrOgKaTZqztrO<br>fCHkxlrNqF3WdrayqjAyIKvk5yD0rOqN01z4NNZDevW/UOYAVM6U6sHInU9c/qzN<br>OHJWpWzqqddG4+WyVweEoDBkh5wsZcCG2oZrzX7dcK0W0yaX2AyEQwA=<br>-----END ENCRYPTED PRIVATE KEY-----<br>PKCS7 Encrypted data: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2000<br>Certificate bag<br>Bag Attributes<br>    localKeyID: 01 00 00 00<br>subject=C=FR, ST=MyState, L=MyCity, O=MyOrg, OU=DSI, CN=mycert.myorg.com, emailAddress=mymail.myorg.org<br>issuer=C=FR, ST=MyState, L=MyCity, O=MyOrg, OU=DSI, CN=mycert.myorg.com, emailAddress=mymail.myorg.org<br>-----BEGIN CERTIFICATE-----<br>MIIEETCCAvmgAwIBAgIUaTdSFp5KzEFYD9cIFgzh82a09zUwDQYJKoZIhvcNAQEL<br>[...]<br>SmlYUaRdXq4ig+4ttTEOoMfpfj0wkDx7beCh0gNADmugzSpR/TWriI0ct34c2FjP<br>TYs2FEPA8TU6bWqklJq2Af2nRoPcEh/7MuX1P112IDwh1HrUeA==<br>-----END CERTIFICATE-----</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecf1595065e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>