<?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 maasta on Medium]]></title>
        <description><![CDATA[Stories by maasta on Medium]]></description>
        <link>https://medium.com/@zodfinder?source=rss-2b5b1ff2cd44------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7h_LrW2catw7ZVfQ.jpg</url>
            <title>Stories by maasta on Medium</title>
            <link>https://medium.com/@zodfinder?source=rss-2b5b1ff2cd44------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:15:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zodfinder/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[[NDH Quals 2017 — Matriochka 2] Write-up]]></title>
            <link>https://medium.com/@zodfinder/ndh-quals-2017-matriochka-2-write-up-9d78356b7565?source=rss-2b5b1ff2cd44------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d78356b7565</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ndhquals]]></category>
            <dc:creator><![CDATA[maasta]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 15:09:32 GMT</pubDate>
            <atom:updated>2017-04-24T16:02:06.658Z</atom:updated>
            <content:encoded><![CDATA[<p>I had the chance to participate to NDH Quals 2017 and i spent almost all my day on a reverse engineering chall. I did not find the flag within the 24hours of the CTF, but I did not surrend and found the solution after :)</p><p>This challenge is a simple binary which ask you to pass the password as an argument</p><pre>[~|maasta]$ ./step2.bin giveMeTheFlag Try again :(</pre><p>Let’s analyse it with peda-gdb and radare2. First, there’s an anti-debugging protection at the start of the interesting part.</p><pre>0x004007c9 488b06 mov rax,[rsi] <br>0x004007cc 80382e cmp byte [rax], 0x2e <br>0x004007cf 0f85e7010000 jnz dword 0x4009bc [2] <br>0x004007d5 8078012f cmp byte [rax+0x1], 0x2f <br>0x004007d9 0f85dd010000 jnz dword 0x4009bc [3] <br>0x004007df 80780273 cmp byte [rax+0x2], 0x73 <br>0x004007e3 0f85d3010000 jnz dword 0x4009bc [4] <br>0x004007e9 80780374 cmp byte [rax+0x3], 0x74 <br>0x004007ed 0f85c9010000 jnz dword 0x4009bc [5] <br>0x004007f3 80780465 cmp byte [rax+0x4], 0x65 <br>0x004007f7 0f85bf010000 jnz dword 0x4009bc [6] <br>0x004007fd 80780570 cmp byte [rax+0x5], 0x70 <br>0x00400801 0f85b5010000 jnz dword 0x4009bc [7] <br>0x00400807 80780632 cmp byte [rax+0x6], 0x32 <br>0x0040080b 0f85ab010000 jnz dword 0x4009bc [8] <br>0x00400811 8078072e cmp byte [rax+0x7], 0x2e <br>0x00400815 0f85a1010000 jnz dword 0x4009bc [9] <br>0x0040081b 80780862 cmp byte [rax+0x8], 0x62 <br>0x0040081f 0f8597010000 jnz dword 0x4009bc [?] <br>0x00400825 80780969 cmp byte [rax+0x9], 0x69 <br>0x00400829 0f858d010000 jnz dword 0x4009bc [?] <br>0x0040082f 80780a6e cmp byte [rax+0xa], 0x6e <br>0x00400833 0f8583010000 jnz dword 0x4009bc [?] <br>0x00400839 80780b00 cmp byte [rax+0xb], 0x0</pre><p>All thoses lines compare argv[0] (which is at the address inside rax) to “./step2.bin”. If you’re in a debugger, argv[0] will be /step2.bin (which is not equal to “./step2.bin”), and then you will jump to 0x4009bc.</p><p>What’s at 0x4009bc ? The function which print “Try again :(“. So let’s skip this part by jumping just after</p><pre>(peda-gdb) b * 0x00400843 (peda-gdb) jump * 0x00400843</pre><p>Just after, the program start to start to inspect what’s in argv[1]</p><pre>0x00400843 488b5608 mov rdx, [rsi+0x8] <br>0x00400847 31c0 xor eax, eax <br>0x00400849 4883c9ff or rcx, 0xffffffffffffffff <br>0x0040084d 4889d7 mov rdi, rdx <br>0x00400850 f2ae repne scasb <br>0x00400852 4883f9de cmp rcx, 0xde <br>0x00400856 0f8560010000 jnz dword 0x4009bc [?] <br>0x0040085c 803a57 cmp byte [rdx], 0x57 <br>0x0040085f 0f8557010000 jnz dword 0x4009bc</pre><p>The first part is weird, but it just check the length of argv[1], which must be equal to 32. The second part compare argv[1][0] to 0x57 which is the char ‘W’.</p><p>So we know that the the flag is 32-chars long and start with a W. Let’s continue. Just after, the most interesting part:</p><pre>0x00400879 488d5801 lea rbx, [rax+0x1] <br>0x0040087d 4c8d6821 lea r13, [rax+0x21] <br>0x00400881 488d7c2410 lea rdi, [rsp+0x10] <br>0x00400886 e8e5feffff call dword imp.sigfillset <br>0x0040088b f643ff01 test byte [rbx-0x1], 0x1 <br>0x0040088f bac60a4000 mov edx, 0x400ac6 <br>0x00400894 b8d00a4000 mov eax, 0x400ad0 <br>0x00400899 488d742408 lea rsi, [rsp+0x8] <br>0x0040089e bf05000000 mov edi, 0x5 <br>0x004008a3 c78424900000000. mov dword [rsp+0x90], <br>0x10000000 0x004008ae 48891d032e2300 mov [rip+0x232e03], rbx <br>0x004008b5 480f44c2 cmovz rax, rdx <br>0x004008b9 31d2 xor edx, edx <br>0x004008bb 4889442408 mov [rsp+0x8], rax <br>0x004008c0 e83bfeffff call dword imp.sigaction <br>0x004008c5 8a53ff mov dl, [rbx-0x1] <br>0x004008c8 31c0 xor eax, eax <br>0x004008ca 38d0 cmp al, dl <br>0x004008cc 7405 jz 0x4008d3 <br>0x004008ce cc int3 <br>0x004008cf ffc0 inc eax <br>0x004008d1 ebf7 jmp 0x4008ca <br>0x004008d3 48ffc3 inc rbx <br>0x004008d6 4c39eb cmp rbx, r13 <br>0x004008d9 75a6 jnz 0x400881 </pre><p>First, the program call sigfillset(), which initialiaze a sigset_t object. Then, it call sigaction(). Let’s see its arguments: At 0x40088b, the program test the byte in [rbx-0x1] with 0x1. This is a bitwise between [rbx-1] and 1. At the address inside rbx-1, there’s our argv[1]. So test byte [rbx-1] , 0x1 means <em>“Check the parity of the first char of the string passed as an argument.”</em> If it’s even, then zf is set to 1. If not, it’s set to 0. Then the program save the address of two functions (0x400ac6 and 0x400ad0) in edx and eax. Those two functions are just inc([rip+0x232beb]) and dec([rip+0x232be1]). Then, edi is set to 5. And rax is set to the pointer to the function inc() if ZF flag is set. Finally, sigaction() is call. It means that when the signal SIGTRAP (signal 5, in edi) is received, the program call the function in rax.</p><p>Let’s assume that, and continue. In that part, we compare a counter (starting from 0) to our first byte of argv[1], if it’s not equal, the programm call int3, then increase the counter and repeat until counter = char. That int3 is the most important part, because it will interrupt the program, and call the function the program set with sigaction. And that function increase or decrease the value of the second char of argv[1]. So that action will be repeated N times, where N is the ASCII value of bytes [rbx-1], which is our W. Then, the program increase rbx (pointer on the chars of the argument), and repeat all that part.</p><p>So let’s resume quickly:</p><p>The program accept an argument. It must be 32-char long and start with W. Then, for each char at position K in the argument, the program compute the value of the char at K + 1 following thoses rules:</p><blockquote><em>ord(K) is the ASCII value of char in position K</em></blockquote><blockquote><em>Add ord(K) to ord(K+1) if ord(K) is even</em></blockquote><blockquote><em>Substract ord(K) to ord(K+1) if ord(K) is odd</em></blockquote><p>Let’s analyse the next part.</p><pre>0x004008db 31d2 xor edx, edx <br>0x004008dd b9efbeadde mov ecx, 0xdeadbeef <br>0x004008e2 b001 mov al, 0x1 <br>0x004008e4 31f6 xor esi, esi <br>0x004008e6 41334c1401 xor ecx, [r12+rdx+0x1] <br>0x004008eb 3b8a40356300 cmp ecx, [rdx+0x633540] <br>0x004008f1 0f45c6 cmovnz eax, esi <br>0x004008f4 4883c204 add rdx, 0x4 <br>0x004008f8 4883fa20 cmp rdx, 0x20 <br>0x004008fc 75e8 jnz 0x4008e6 <br>0x004008fe fec8 dec al <br>0x00400900 0f85b6000000 jnz dword 0x4009bc <br>0x00400906 bf16104000 mov edi, str.Welldone <br>0x0040090b e8e0fdffff call dword imp.puts</pre><p>In that part, the program XOR the 4-first-bytes with 0xdeadbeef, and compare it with the value in [rdx+0x633540]. That value become the new key, and this operation is done 8 times (4 bytes at a time, for the 32 chars of the password).</p><p>If all those comparison are true, then the program prints “Welldone”.</p><p>So let’s write a little program which first calculate the string to pass all comparison, then reverse the algorithm of increase/decrease.</p><p>Here is the program i wrote, in perl6</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cdbef2442b3d1afbb40b29ac99f6540/href">https://medium.com/media/2cdbef2442b3d1afbb40b29ac99f6540/href</a></iframe><p>We run it:</p><pre>[~|maasta]$ perl6 findFlag.p6 <br>(W h e n _ i _ g r o w _ u p , _ I _ w i l l _ b e _ a _ f l a g )</pre><p>Here it is !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d78356b7565" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptocat && attaque sur stream cipher]]></title>
            <link>https://medium.com/@zodfinder/cryptocat-attaque-sur-stream-cipher-c9143b64cb64?source=rss-2b5b1ff2cd44------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9143b64cb64</guid>
            <category><![CDATA[stream-cipher]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[courscrypto]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[cryptocat]]></category>
            <dc:creator><![CDATA[maasta]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 14:51:43 GMT</pubDate>
            <atom:updated>2017-04-24T16:03:04.059Z</atom:updated>
            <content:encoded><![CDATA[<p>J’ai récemment découvert <a href="https://crypto.cat/">Cryptocat</a>, un petit logiciel très pratique, qui permet de communiquer de manière sécurisée. Toutes les communications sont chiffrées et son plus gros avantage réside dans l’envoi de fichier volumineux (jusqu’à 200Mb !). L’utilisation est simple, et le design m’a particulièrement plu :). Ça donne envie de lâcher le mail, et de ne communiquer avec ses “buddies” qu’avec Cryptocat.</p><p>C’est grâce à ce logiciel que j’ai découvert <a href="https://twitter.com/kaepora">kaepora</a>, qui est tout simplement la personne à l’origine de Cryptocat. Vous pouvez découvrir ses autres projets sur sa <a href="https://nadim.computer/">page personnelle</a>, qui tournent tous autour de la cryptographie, et implicitement de la protection de la vie privée. Cette même personne a initié des cours de cryptographie pour grands débutants au Loop, en 2015 (les cours ont été arrêtés plus tôt que prévu, mais je recommande grandement d’aller regarder les 3 vidéos <a href="https://www.courscrypto.org/">ici</a>).</p><p>Les cours comporte des TPs, et je profite de cet article pour présenter la résolution du TP du cours Chiffrement de flux que je trouve intéressante. Voilà l’énoncé :</p><blockquote><em>Voici sept textes chiffrés avec un chiffrement de flux en utilisant la même clé. Trouvez le message clair de un de ces textes chiffrés (vous pouvez choisir lequel vous voulez.) Il est désormais possible de craquer le chiffrement de tous les messages.</em></blockquote><blockquote><em>Les textes chiffrées sont représentés en hexadécimal:</em></blockquote><blockquote><em>01001e631c6e0965631c0014651e0c0600651900731e00000c711110000b0811000415</em></blockquote><blockquote><em>1e03776614071100151e040f6d160b1772061c04750961020771130c6e6f0712060366</em></blockquote><blockquote><em>18017775010709691009650a6173060f1703740f751e150269041b000009020e1c6369</em></blockquote><blockquote><em>1b0e7763071715740c0b1707701b0c067200071100180f671d030006001c140a1f0c69</em></blockquote><blockquote><em>1b0a776d1a00016563091612001417021c0174086104126708040616696f1d021b0413</em></blockquote><blockquote><em>071d1874100d11690c026509621f0c0413111b0c720861030c71030a741d0867191802</em></blockquote><blockquote><em>071d18631d0f0c6e630f0a1372007f63110d1d03661f040a0c1f0165640a6d05030204</em></blockquote><p>Ici, la méthode de résolution qui vient à l’esprit est de XORer les ciphers entre eux, afin d’obtenir les messages XORés entre eux (cette propriété vient du fait que la même clé a été utilisée pour chiffrer les messages). En effet:</p><blockquote><em>Cipher1 = Message1 XOR Clé</em></blockquote><blockquote><em>Cipher2 = Message2 XOR Clé</em></blockquote><p>Et donc:</p><blockquote><em>Cipher1 XOR Cipher2 = Message1 XOR Clé XOR Clé XOR Message2 = Message1 XOR Message2</em></blockquote><p>Une fois qu’on a récupéré tous les messages XORés deux à deux, on peux essayer de faire du <a href="http://crypto.stackexchange.com/questions/2249/how-does-one-attack-a-two-time-pad-i-e-one-time-pad-with-key-reuse/2250#2250">Crib-dragging</a>, afin de deviner la clé au fur et à mesure, et ainsi déchiffrer tous les messages.</p><p>Une autre méthode, qui me semble plus intéressante, est de générer pour chaque octets toutes les clés possibles et de ne garder que les clés pour lesquelles le XOR renvoie une lettre pour les 7 ciphers. Je m’explique. Tous les messages en clair ne contiennent que des caractères ASCII correspondant soit à des lettres en majuscule, soit à des lettres en minuscule, soit à des espaces, soit à des points. Pour chaque byte, on teste les 256 possibilités de clé, et on ne garde que celle(s) qui donne un de ces caractères lorsque on la XOR avec le cipher.</p><p>J’ai écris un petit script qui essaie cela. Ce n’est pas très performant, mais cela permet d’avoir un bon aperçu de la méthode de résolution. Le code est disponible <a href="https://github.com/m44st4/Crypto/blob/master/CoursCrypto/TP1CoursCrypto.pl">ici</a> et produit en sortie les ciphers XORés avec la clé la plus probable.</p><p>On obtient:</p><blockquote><em>IDIcM IE XETEMSER MASTAGE SU DEVHIR</em></blockquote><blockquote><em>VG fEIQ VZAOMETT CHEUC EN QIN JUNN!</em></blockquote><blockquote><em>PE uPIIISM JA YLEF NUTTE UYE FOIT..</em></blockquote><blockquote><em>SJ cVYUTOORGPHSE ESP RN TRBC SYMWA.</em></blockquote><blockquote><em>SN mKNAE MSR GHAND IANS AUDSI PESIT</em></blockquote><blockquote><em>OYOtACQIOF IBLSGATOMRB DE AOTRE QUE</em></blockquote><blockquote><em>OYOcLALN KOSRS CHIBFUEMENC DE BKOC</em></blockquote><p>La quatrième ligne attire notre attention, on arrive presque à lire</p><blockquote><em>CRYPTOGRAPHIE EST UN TRUC SYMPA</em></blockquote><p>On essaye… On remplace la clé de manière à obtenir ce message là en sortie, et on essaie de déchiffrer les autres. Voilà le résultat:</p><blockquote><em>VOICI LE PEREMIER MESSAGE DU DEVOIR</em></blockquote><blockquote><em>IL FAIT VRAIMENT CHAUD EN FIN JUIN!</em></blockquote><blockquote><em>ON UTILISE LA CLEF JUSTE UNE FOIS..</em></blockquote><blockquote><em>LA CRYPTOGRAPHIE EST UN TRUC SYMPA.</em></blockquote><blockquote><em>LE MONDE EST GRAND MAIS AUSSI PETIT</em></blockquote><blockquote><em>PROTECTION OBLIGATOIRE DE VOTRE VUE</em></blockquote><blockquote><em>PROCHAIN COURS: CHIFFREMENT DE BLOC</em></blockquote><p>Et voilà :)</p><p>Salut !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9143b64cb64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Initiation au reverse engineering]]></title>
            <link>https://medium.com/@zodfinder/initiation-au-reverse-engineering-1c3a25fdd908?source=rss-2b5b1ff2cd44------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c3a25fdd908</guid>
            <category><![CDATA[reverse]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[maasta]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 14:50:20 GMT</pubDate>
            <atom:updated>2017-04-24T16:03:41.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Depuis peu, je m’intéresse au reverse engineering, notamment grâce au livre de <a href="https://beginners.re/">Dennis Yurichev</a>, “Reverse engineering for beginners”, qui est gratuit, et surtout qui part du principe que le lecteur est un débutant complet dans ce domaine (il suffit d’avoir de bonnes notions de C). Ce qui me semble intéressant dans ce livre, c’est que l’auteur retranscrit chaque bout de code en assembleur, sous les 3 architectures principales présentées (x86, ARM, MISP). De plus, à la fin de chaque chapitre, le lecteur peut se frotter à différents <a href="https://challenges.re/">challenges</a>, réalisés par l’auteur, et qui permettent de mettre en pratique les notions abordées.</p><p>Du coup, mon temps libre est maintenant occupé par la lecture de ce livre (qui fait quand même plus de 1000 pages), et par la résolution de challenges de reverse engineering sur la plateforme d’apprentissage <a href="https://root-me.org/">Root-me</a>.</p><p>Le meilleur moyen de découvrir Root-me, c’est de s’inscrire et de commencer à résoudre les challenges. C’est un peu via cette plateforme que je suis entré dans le monde de la sécurité. Depuis, j’ai eu l’occasion d’essayer d’autres plateformes, notamment Zenk-secu et newbie-contest, mais je n’arrive pas à m’y attacher autant.</p><p>Root-me compte presque 250 challenges, séparés en plusieurs catégories (forensics, web, reverse engineering, cryptographie, …), et qui permettent de gagner un certain nombre de points (en fonction de leur difficulté), une fois qu’on les as résolus. En plus, la communauté est très agréable, et il y a toujours du monde pour {discuter des challenges || troller}. C’est une vrai addiction :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c3a25fdd908" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tunnel VPN et redirection TOR]]></title>
            <link>https://medium.com/@zodfinder/tunnel-vpn-et-redirection-tor-537f939acfb0?source=rss-2b5b1ff2cd44------2</link>
            <guid isPermaLink="false">https://medium.com/p/537f939acfb0</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[iptables]]></category>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[tor]]></category>
            <category><![CDATA[tunnel]]></category>
            <dc:creator><![CDATA[maasta]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 14:45:01 GMT</pubDate>
            <atom:updated>2017-04-24T16:04:07.702Z</atom:updated>
            <content:encoded><![CDATA[<p>J’ai été assez déçu de l’utilisation des applications Orbot et Orfox sous Android, mon but n’était pas de naviguer via le réseau tor grâce à Orfox, mais de rediriger tout le trafic sortant vers tor (proxifier toutes les applications). Sans les droits root, il faut préciser à chaque application d’utiliser le proxy, autant dire que ça prends du temps! Si le téléphone est rooté, une option est proposée dans les préférences d’Orbot. Malheureusement, l’option semble un peu buggée et Orbot drop souvent la connexion lors de l’acquisition des droits root, et il est finalement assez difficile d’utiliser les applications correctement.</p><p>Je me suis donc rabattu sur le classique tunnel VPN. J’avais déjà monté un OpenVpn sur un serveur personnel, mais je n’étais pas satisfait de voir le trafic sortir toujours de la même IP.</p><p>J’ai donc décidé de rediriger tout le trafic provenant de tun0 vers tor (sur le serveur personnel). Tout le traffic de mon téléphone passerai par le tunnel VPN, et sortirai via tor depuis le serveur.</p><p>Une fois qu’on a le serveur VPN de monté, les modifications à faire sont assez simple:</p><p>*On modifie son /etc/tor/torrc pour autoriser le TransparentProxy et le DNSProxy *On modifie ses iptables pour la redirection du traffic entrant du VPN (tun0), vers le TransparentProxy.</p><p>Pour le fichier de configuration tor, j’ai simplement rajouté les lignes:</p><pre>VirtualAddrNetwork 10.192.0.0/10 <br>AutomapHostsOnResolve 1 <br>Transport 10.8.0.1:9040 <br>DNSPort 10.8.0.1:5353</pre><p>Enfin, pour les iptables, on modifie la table de NAT, en ajoutant en règles de prérouting:</p><pre>iptables -t nat -A PREROUTING -i tun0 udp --dport 53 -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:53530 </pre><pre>iptables -t nat -A PREROUTING -i tun0 tcp -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:9040 </pre><pre>iptables -t nat -A PREROUTING -i tun0 udp -s 10.8.0.0/24 -j DNAT --to-destination 10.8.0.1:9040</pre><p>Pour info: les deux dernières règles permettent de tout accepter (selon si le tunnel VPN suit le protocole TCP ou UDP)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*7bqmpI0_7S9DdtcB.png" /></figure><p>It works! (Et la connexion de drop plus :))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=537f939acfb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>