<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.bl4nk.kr/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https://blog.bl4nk.kr</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>
            This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It's free.
        </tabi:about_feeds>
        <tabi:visit_the_site>
            Visit website
        </tabi:visit_the_site>
        <tabi:recent_posts>
            Recent posts
        </tabi:recent_posts>
        <tabi:last_updated_on>
            Updated on $DATE
        </tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>tools</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.bl4nk.kr/skins/lavender.css?h=31ee0a710ed660d122f6" /><title>~/bl4nk - tools</title>
        <subtitle>fill in the bl4nk</subtitle>
    <link href="https://blog.bl4nk.kr/tags/tools/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.bl4nk.kr/tags/tools/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2025-12-10T00:00:00+00:00</updated><id>https://blog.bl4nk.kr/tags/tools/atom.xml</id><entry xml:lang="en">
        <title>Connecting LLM to IDA MCP Server in a Virtual Machine (feat. Gemini CLI)</title>
        <published>2025-12-10T00:00:00+00:00</published>
        <updated>2025-12-10T00:00:00+00:00</updated>
        <author>
            <name>bl4nk</name>
        </author>
        <link rel="alternate" href="https://blog.bl4nk.kr/blog/connecting-llm-to-ida-mcp-server-in-a-virtual-machine-feat-gemini-cli/" type="text/html"/>
        <id>https://blog.bl4nk.kr/blog/connecting-llm-to-ida-mcp-server-in-a-virtual-machine-feat-gemini-cli/</id>
        
            <content type="html">&lt;h2 id=&quot;0x00-introduction&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x00-introduction&quot; aria-label=&quot;Anchor link for: 0x00-introduction&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x00. Introduction&lt;/h2&gt;
&lt;p&gt;MCP (Model Context Protocol) is an open standard that enables AI models to communicate with other systems.
By using MCP, LLMs can connect to various data sources like PCs or databases, and tools like search engines or calculators to perform complex and valuable tasks.
It’s often described as a &lt;strong&gt;“USB-C port for AI.”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While there is an official plugin from Hex-Rays, this guide is based on the &lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://github.com/mrexodia/ida-pro-mcp&quot;&gt;GitHub repository&lt;/a&gt; which has more stars and community traction.
I also structured this setup using a virtual machine for the MCP Server, enabling a workflow where I can freely analyze in parallel while the agent handles its tasks.&lt;/p&gt;
&lt;h2 id=&quot;0x01-install&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x01-install&quot; aria-label=&quot;Anchor link for: 0x01-install&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x01. Install&lt;/h2&gt;
&lt;h3 id=&quot;guest&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#guest&quot; aria-label=&quot;Anchor link for: guest&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Guest&lt;/h3&gt;
&lt;p&gt;As mentioned, the MCP server will be set up inside a virtual machine.
You can use any OS that supports IDA (macOS, Linux, and Windows), but I used Windows 10 x64.&lt;/p&gt;
&lt;h4 id=&quot;python&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#python&quot; aria-label=&quot;Anchor link for: python&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Python&lt;/h4&gt;
&lt;p&gt;Python 3.11 or higher is required.
Usually, IDA installs Python if it’s missing, but older versions might install 3.10.
Since we’re running this in a VM, it’s easier to install the latest version beforehand.&lt;/p&gt;
&lt;p&gt;I personally install it in &lt;code&gt;C:\Python\Python[VER]&lt;/code&gt;. Make sure to add the following paths to your system’s &lt;code&gt;PATH&lt;/code&gt; environment variable:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;C:\Python\Python314\&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;C:\Python\Python314\Scripts\&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;ida-pro&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#ida-pro&quot; aria-label=&quot;Anchor link for: ida-pro&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
IDA Pro&lt;/h4&gt;
&lt;p&gt;The GitHub repository recommends IDA Pro 8.3 or higher, or version 9.
Note that IDA Free is not supported, but according to sources, IDA Home (the individual plan) works fine.&lt;/p&gt;
&lt;p&gt;During installation, uncheck the option to install Python so that IDA uses the version you previously installed.&lt;/p&gt;
&lt;h4 id=&quot;ida-mcp&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#ida-mcp&quot; aria-label=&quot;Anchor link for: ida-mcp&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
IDA MCP&lt;/h4&gt;
&lt;p&gt;Refer to the &lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://github.com/mrexodia/ida-pro-mcp?tab=readme-ov-file#installation&quot;&gt;GitHub installation guide&lt;/a&gt; for detailed steps.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;bat&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pip uninstall ida-pro-mcp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pip install https://github.com/mrexodia/ida-pro-mcp/archive/refs/heads/main.zip&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ida-pro-mcp --install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After installation, go to &lt;code&gt;Edit&lt;/code&gt; -&amp;gt; &lt;code&gt;Plugins&lt;/code&gt; -&amp;gt; &lt;code&gt;MCP&lt;/code&gt; in the IDA menu. If the output looks like this, the installation was successful:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[MCP] Server started:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Streamable HTTP: http://127.0.0.1:13337/mcp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  SSE: http://127.0.0.1:13337/sse&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  Config: http://127.0.0.1:13337/config.html&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since it listens on &lt;code&gt;127.0.0.1&lt;/code&gt; by default, you can set up port forwarding or simply run the following command to allow host communication:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;bat&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ida-pro-mcp --transport http://0.0.0.0:13337/sse&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;host&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#host&quot; aria-label=&quot;Anchor link for: host&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Host&lt;/h3&gt;
&lt;p&gt;While you could install the AI application on the guest OS, I preferred separating the guest and host. I use these applications frequently on my host, and it feels slightly faster.&lt;/p&gt;
&lt;p&gt;The host environment is Windows 11 with WSL, and the following steps are for WSL.&lt;/p&gt;
&lt;h4 id=&quot;gemini-cli&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#gemini-cli&quot; aria-label=&quot;Anchor link for: gemini-cli&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Gemini CLI&lt;/h4&gt;
&lt;p&gt;The demo on GitHub uses Claude Desktop, but since I subscribe to Gemini, I’ll be using the Gemini CLI.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Install nvm and Node.js (requires version &amp;gt; 20)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;curl&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;o-&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; bash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;nvm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; node&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Install Gemini CLI&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;npm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; @google/gemini-cli&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To communicate with the guest, add the MCP server information to &lt;code&gt;~/.gemini/settings.json&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;mcpServers&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;ida-vm&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;http://xxx.xxx.xxx.xxx:13337/sse&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If everything is set up correctly, running the &lt;code&gt;gemini&lt;/code&gt; command should show a log saying &lt;code&gt;Using: 1 MCP server&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;   ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;            ░░░░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░░░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;     ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;         ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ░░░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;       ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;          ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    ░░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    █████████░░██████████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ██████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░██████░█████░██████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░█████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; █████░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;   ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     ███░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    ███░███░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ██████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░██████░░███░░██████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ░█████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;     ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ███░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     ░░███░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ███░███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███░░███░░███░███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;   ░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ░░░█████░██████░░░░░███░░█████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███░░███░░███░░███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███░░░&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███░░░&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;     ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;      ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   ██████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    ███&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;   ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;         ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;         ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    █████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    ███&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;            █████████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ██████████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;         ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; █████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ███&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     █████&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  █████&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Tips&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; getting&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; started:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;1.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Ask&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; questions,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; edit&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; files,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; commands.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;2.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Be&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; specific&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; the&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; best&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; results.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;3.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Create&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; GEMINI.md&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; files&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; customize&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; your&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; interactions&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Gemini.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;4.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /help&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; more&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; information.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; Using:&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; MCP&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;│&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;   Type&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; your&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; message&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; @path/to/file&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;                                                               │&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; ~/mcp&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;                          no&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sandbox&lt;/span&gt;&lt;span&gt; (see&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /docs&lt;/span&gt;&lt;span&gt;)                           Auto (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Gemini&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 3&lt;/span&gt;&lt;span&gt;) /model&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can verify the available tools using the &lt;code&gt;/mcp&lt;/code&gt; command.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; /mcp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Configured&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; MCP&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; servers:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;🟢&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ida-vm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Ready&lt;/span&gt;&lt;span&gt; (71&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; tools,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 15&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; resources&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  Tools:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; analyze_funcs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; analyze_strings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apply_types&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  .&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  Resources:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; idb_metadata_resource&lt;/span&gt;&lt;span&gt; (ida://idb/metadata&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;application/json&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; idb_segments_resource&lt;/span&gt;&lt;span&gt; (ida://idb/segments&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;application/json&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; idb_entrypoints_resource&lt;/span&gt;&lt;span&gt; (ida://idb/entrypoints&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;application/json&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  .&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;0x02-prompt-engineering&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x02-prompt-engineering&quot; aria-label=&quot;Anchor link for: 0x02-prompt-engineering&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x02. Prompt Engineering&lt;/h2&gt;
&lt;p&gt;For better analysis results, using a well-crafted prompt is highly recommended.
Here is the default recommended prompt:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Your task is to analyze the open file in IDA Pro. You can use the MCP tools to retrieve information. In general use the following strategy:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Inspect the decompilation and add comments with your findings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Rename variables to more sensible names&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Change the variable and argument types if necessary (especially pointer and array types)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Change function names to be more descriptive&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- If more details are necessary, disassemble the function and add comments with your findings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- NEVER convert number bases yourself. Use the `int_convert` MCP tool if needed!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Do not attempt brute forcing, derive any solutions purely from the disassembly and simple python scripts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- Create a report.md with your findings and steps taken at the end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- When you find a solution, prompt to user for feedback with the password you found&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here is a more detailed prompt shared by another user (&lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://github.com/can1357&quot;&gt;@can1357&lt;/a&gt;):&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Your task is to create a complete and comprehensive reverse engineering analysis. Reference AGENTS.md to understand the project goals and ensure the analysis serves our purposes.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Use the following systematic methodology:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1. **Decompilation Analysis**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Thoroughly inspect the decompiler output&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Add detailed comments documenting your findings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Focus on understanding the actual functionality and purpose of each component (do not rely on old, incorrect comments)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2. **Improve Readability in the Database**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Rename variables to sensible, descriptive names&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Correct variable and argument types where necessary (especially pointers and array types)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Update function names to be descriptive of their actual purpose&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3. **Deep Dive When Needed**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - If more details are necessary, examine the disassembly and add comments with findings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Document any low-level behaviors that aren&amp;#39;t clear from the decompilation alone&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Use sub-agents to perform detailed analysis&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;4. **Important Constraints**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - NEVER convert number bases yourself - use the int_convert MCP tool if needed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Use MCP tools to retrieve information as necessary&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Derive all conclusions from actual analysis, not assumptions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;5. **Documentation**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Produce comprehensive RE/*.md files with your findings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Document the steps taken and methodology used&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - When asked by the user, ensure accuracy over previous analysis file&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   - Organize findings in a way that serves the project goals outlined in AGENTS.md or CLAUDE.md&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        <summary type="html">Setting up a parallel analysis workflow with IDA in a VM and Gemini CLI on Host</summary>
        </entry><entry xml:lang="en">
        <title>Windows kernel debugging</title>
        <published>2025-04-25T00:00:00+00:00</published>
        <updated>2025-04-25T00:00:00+00:00</updated>
        <author>
            <name>bl4nk</name>
        </author>
        <link rel="alternate" href="https://blog.bl4nk.kr/blog/windows-kernel-debugging/" type="text/html"/>
        <id>https://blog.bl4nk.kr/blog/windows-kernel-debugging/</id>
        
            <content type="html">&lt;h2 id=&quot;0x00-introduction&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x00-introduction&quot; aria-label=&quot;Anchor link for: 0x00-introduction&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x00. Introduction&lt;/h2&gt;
&lt;p&gt;This post covers setting up an environment for Windows kernel analysis and documents useful commands.&lt;/p&gt;
&lt;h2 id=&quot;0x01-setup&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x01-setup&quot; aria-label=&quot;Anchor link for: 0x01-setup&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x01. Setup&lt;/h2&gt;
&lt;h3 id=&quot;host-debugger&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#host-debugger&quot; aria-label=&quot;Anchor link for: host-debugger&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Host (Debugger)&lt;/h3&gt;
&lt;p&gt;Previously, the setup process was complex with Windows SDK, Virtual KD, etc. for convenience.
Now it’s much simpler with the official WinDbg release.
Just install WinDbg from the Microsoft Store and run it.&lt;/p&gt;
&lt;p&gt;From the top menu, go to File -&amp;gt; Start Debugging -&amp;gt; Attach to kernel, select COM, and configure as follows:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/windows-kernel-debugging/image.png&quot; alt=&quot;host&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After completing the configuration and clicking “OK” in the lower right, it enters debugging standby mode.&lt;/p&gt;
&lt;h3 id=&quot;guest-debuggee&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#guest-debuggee&quot; aria-label=&quot;Anchor link for: guest-debuggee&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Guest (Debuggee)&lt;/h3&gt;
&lt;p&gt;The debugging target can be set up through various programs. This post describes the configuration method when using VMware.&lt;/p&gt;
&lt;p&gt;First, start the target VM, run PowerShell with administrator privileges, and execute these commands:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bcdedit /debug on&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bcdedit /dbgsettings serial debugport:1 baudrate:115200&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then shut down the VM, select VM -&amp;gt; Settings -&amp;gt; Add from the top menu, and add a Serial Port.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/windows-kernel-debugging/image-1.png&quot; alt=&quot;guest-1&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Configure the added Serial Port as follows.
Note that selecting “The other end is a virtual machine” instead of “The other end is an application” also seems to work for connection.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/windows-kernel-debugging/image-2.png&quot; alt=&quot;guest-2&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Finally, starting the target VM connects it to the host.&lt;/p&gt;
&lt;h2 id=&quot;0x02-commands&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x02-commands&quot; aria-label=&quot;Anchor link for: 0x02-commands&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x02. Commands&lt;/h2&gt;
&lt;h3 id=&quot;modules&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#modules&quot; aria-label=&quot;Anchor link for: modules&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Modules&lt;/h3&gt;
&lt;h4 id=&quot;lm-list-modules&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#lm-list-modules&quot; aria-label=&quot;Anchor link for: lm-list-modules&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;lm&lt;/code&gt; (List Modules)&lt;/h4&gt;
&lt;p&gt;Lists loaded modules or checks information for a specific module.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; lm&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; lm m fltmgr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; lm Dvm fltmgr&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that kernel mode regions load at high addresses like &lt;code&gt;fffff800&#39;00000000&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&quot;x-examine-symbols&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#x-examine-symbols&quot; aria-label=&quot;Anchor link for: x-examine-symbols&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;x&lt;/code&gt; (eXamine symbols)&lt;/h4&gt;
&lt;p&gt;Searches symbols or finds specific symbols.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; x win32k!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; x win32k!vStr*&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;symbols&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#symbols&quot; aria-label=&quot;Anchor link for: symbols&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Symbols&lt;/h3&gt;
&lt;h4 id=&quot;sym-noisy-noisy-symbol-loading&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#sym-noisy-noisy-symbol-loading&quot; aria-label=&quot;Anchor link for: sym-noisy-noisy-symbol-loading&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;!sym noisy&lt;/code&gt; (Noisy symbol loading)&lt;/h4&gt;
&lt;p&gt;Displays detailed symbol loading process. Good for debugging loading-related issues.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !sym noisy &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;sympath-set-symbol-path&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#sympath-set-symbol-path&quot; aria-label=&quot;Anchor link for: sympath-set-symbol-path&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;!sympath&lt;/code&gt; (Set symbol path)&lt;/h4&gt;
&lt;p&gt;Sets the path to symbol server or local directory where symbol files are stored.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !sympath SRV*C:\symbols*https://msdl.microsoft.com/download/symbols&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !sympath C:\symbols &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;reload-reload-symbols&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#reload-reload-symbols&quot; aria-label=&quot;Anchor link for: reload-reload-symbols&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;.reload&lt;/code&gt; (Reload symbols)&lt;/h4&gt;
&lt;p&gt;Reloads symbols. The &lt;code&gt;/f&lt;/code&gt; option forces symbol loading.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; .reload&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; .reload /f CLFS&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;memory&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#memory&quot; aria-label=&quot;Anchor link for: memory&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Memory&lt;/h3&gt;
&lt;h4 id=&quot;db-dw-dd-dq-display-memory&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#db-dw-dd-dq-display-memory&quot; aria-label=&quot;Anchor link for: db-dw-dd-dq-display-memory&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;db&lt;/code&gt; &lt;code&gt;dw&lt;/code&gt; &lt;code&gt;dd&lt;/code&gt; &lt;code&gt;dq&lt;/code&gt; (Display memory)&lt;/h4&gt;
&lt;p&gt;Displays memory in byte, word, double word, and quad word units respectively.
You can specify the count by adding &lt;code&gt;L[Length]&lt;/code&gt;, specify range by entering the end address, or use register names to read and use values stored in registers.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; db [Address]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; dw [Address] L[Length]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; dd [Address] [Address]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; dq rsp&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;ds-du-dc-display-string&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#ds-du-dc-display-string&quot; aria-label=&quot;Anchor link for: ds-du-dc-display-string&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;ds&lt;/code&gt; &lt;code&gt;du&lt;/code&gt; &lt;code&gt;dc&lt;/code&gt; (Display string)&lt;/h4&gt;
&lt;p&gt;Displays memory as ASCII and Unicode strings respectively.
&lt;code&gt;dc&lt;/code&gt; displays both hex values and strings simultaneously.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; ds [Address]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; du [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;dps-display-pointers-and-symbols&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#dps-display-pointers-and-symbols&quot; aria-label=&quot;Anchor link for: dps-display-pointers-and-symbols&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;dps&lt;/code&gt; (Display Pointers and Symbols)&lt;/h4&gt;
&lt;p&gt;Interprets and displays pointers stored in memory based on symbol information.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; dps [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;u-ub-uf-unassemble&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#u-ub-uf-unassemble&quot; aria-label=&quot;Anchor link for: u-ub-uf-unassemble&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;u&lt;/code&gt; &lt;code&gt;ub&lt;/code&gt; &lt;code&gt;uf&lt;/code&gt; (Unassemble)&lt;/h4&gt;
&lt;p&gt;Interprets and displays instructions in memory as assembly.
Using basic &lt;code&gt;u&lt;/code&gt; together with &lt;code&gt;ub&lt;/code&gt;, which displays assembly code in reverse from the input address, is convenient for viewing instructions before and after at once.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;uf&lt;/code&gt; displays the entire function. You can input any location within the function, not just the beginning. However, symbols must be properly loaded.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; u rip&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; ub rip&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; uf [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;information&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#information&quot; aria-label=&quot;Anchor link for: information&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Information&lt;/h3&gt;
&lt;h4 id=&quot;analyze-v-analyze-crash-dump&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#analyze-v-analyze-crash-dump&quot; aria-label=&quot;Anchor link for: analyze-v-analyze-crash-dump&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;!analyze -v&lt;/code&gt; (Analyze crash dump)&lt;/h4&gt;
&lt;p&gt;When a crash occurs, it displays various information including the general cause and register states.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !analyze -v&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;k-kv-stack-trace&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#k-kv-stack-trace&quot; aria-label=&quot;Anchor link for: k-kv-stack-trace&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;k&lt;/code&gt; &lt;code&gt;kv&lt;/code&gt; (Stack trace)&lt;/h4&gt;
&lt;p&gt;Displays the current thread’s call stack. The &lt;code&gt;kv&lt;/code&gt; command also displays the values of passed arguments.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; k&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; kv &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;process-thread-process-thread-information&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#process-thread-process-thread-information&quot; aria-label=&quot;Anchor link for: process-thread-process-thread-information&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;!process&lt;/code&gt; &lt;code&gt;!thread&lt;/code&gt; (Process / Thread information)&lt;/h4&gt;
&lt;p&gt;Displays process information. Using &lt;code&gt;!process&lt;/code&gt; alone displays detailed information about the current process. Adding &lt;code&gt;0 0&lt;/code&gt; displays brief information about all processes. To check specific process information, input that process’s address.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;!thread&lt;/code&gt; displays thread information. When used alone, it displays current thread information. Inputting a specific thread address displays that thread’s information.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !process&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !process 0 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !process [Address]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !thread&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; !thread [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;debug&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#debug&quot; aria-label=&quot;Anchor link for: debug&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Debug&lt;/h3&gt;
&lt;h4 id=&quot;bp-ba-break-point&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#bp-ba-break-point&quot; aria-label=&quot;Anchor link for: bp-ba-break-point&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;bp&lt;/code&gt; &lt;code&gt;ba&lt;/code&gt; (Break Point)&lt;/h4&gt;
&lt;p&gt;Stops execution at the specified address or symbol. The &lt;code&gt;ba&lt;/code&gt; command can stop on read/write/execute operations on specific memory.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; bp 0x401000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; bp ntdll!NtCreateFile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; ba [r/w/x/rw][Length] [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&quot;p-t-pt-g-pc-flow-control&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#p-t-pt-g-pc-flow-control&quot; aria-label=&quot;Anchor link for: p-t-pt-g-pc-flow-control&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
&lt;code&gt;p&lt;/code&gt; &lt;code&gt;t&lt;/code&gt; &lt;code&gt;pt&lt;/code&gt; &lt;code&gt;g&lt;/code&gt; &lt;code&gt;pc&lt;/code&gt; (Flow control)&lt;/h4&gt;
&lt;p&gt;Various debugging flow control commands exist: &lt;code&gt;p&lt;/code&gt;(&lt;code&gt;ni&lt;/code&gt;) executes the next instruction, &lt;code&gt;t&lt;/code&gt;(&lt;code&gt;si&lt;/code&gt;) executes the next instruction and steps into functions, &lt;code&gt;pt&lt;/code&gt; executes until function completion, &lt;code&gt;g&lt;/code&gt; runs until the next breakpoint, and &lt;code&gt;pc&lt;/code&gt; runs to a specific address.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; p&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; t&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; pt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; g&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;kd&amp;gt; pc [Address]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        <summary type="html">Windows kernel debugging with WinDbg + VMware</summary>
        </entry><entry xml:lang="en">
        <title>Setting up Windows for pwnable</title>
        <published>2025-01-15T00:00:00+00:00</published>
        <updated>2025-01-15T00:00:00+00:00</updated>
        <author>
            <name>bl4nk</name>
        </author>
        <link rel="alternate" href="https://blog.bl4nk.kr/blog/setting-up-windows-for-pwnable/" type="text/html"/>
        <id>https://blog.bl4nk.kr/blog/setting-up-windows-for-pwnable/</id>
        
            <content type="html">&lt;h2 id=&quot;0x00-introduction&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x00-introduction&quot; aria-label=&quot;Anchor link for: 0x00-introduction&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x00. Introduction&lt;/h2&gt;
&lt;p&gt;After purchasing a new desktop and frequently reconfiguring the environment due to driver issues, I thought it would be nice to document the setup process for reference.
The installation environment is Windows 11 + Ubuntu(WSL).&lt;/p&gt;
&lt;p&gt;I’ll add more useful settings or tools as I discover them.&lt;/p&gt;
&lt;h2 id=&quot;0x01-windows&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x01-windows&quot; aria-label=&quot;Anchor link for: 0x01-windows&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x01. Windows&lt;/h2&gt;
&lt;h3 id=&quot;wsl&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#wsl&quot; aria-label=&quot;Anchor link for: wsl&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
WSL&lt;/h3&gt;
&lt;p&gt;In &lt;code&gt;Turn Windows Features On or Off&lt;/code&gt;, check the following items.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/setting-up-windows-for-pwnable/./image.png&quot; alt=&quot;wsl&quot; /&gt;&lt;/p&gt;
&lt;p&gt;After restarting, execute these commands in the terminal.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;powershell&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Install WSL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wsl &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Check available packages and versions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wsl &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;list &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;online&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Specific version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wsl &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;install &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;d Ubuntu&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;xx.xx&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Latest version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;wsl &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;install &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;-&lt;/span&gt;&lt;span&gt;d Ubuntu&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;visual-studio-code&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#visual-studio-code&quot; aria-label=&quot;Anchor link for: visual-studio-code&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Visual Studio Code&lt;/h3&gt;
&lt;h4 id=&quot;theme-settings&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#theme-settings&quot; aria-label=&quot;Anchor link for: theme-settings&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Theme Settings&lt;/h4&gt;
&lt;p&gt;After installing the desired theme, press &lt;code&gt;ctrl + shift + p&lt;/code&gt; -&amp;gt; &lt;code&gt;Preferences: Color Theme&lt;/code&gt; -&amp;gt; &lt;code&gt;Browse Additional Color Themes...&lt;/code&gt; to select it.&lt;/p&gt;
&lt;h4 id=&quot;keyboard-shortcuts&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#keyboard-shortcuts&quot; aria-label=&quot;Anchor link for: keyboard-shortcuts&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Keyboard Shortcuts&lt;/h4&gt;
&lt;p&gt;Press &lt;code&gt;ctrl + shift + p&lt;/code&gt; -&amp;gt; &lt;code&gt;Preferences: Open Keyboard Shortcuts(JSON)&lt;/code&gt; and paste the following.
This is good when switching between editor and terminal.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;ctrl+`&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;workbench.action.terminal.focus&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;     &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;ctrl+`&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;workbench.action.focusActiveEditorGroup&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;when&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;terminalFocus&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is more convenient when switching between multiple windows.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;json&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;ctrl+`&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;        &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;workbench.action.focusNextGroup&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;vmware&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#vmware&quot; aria-label=&quot;Anchor link for: vmware&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
VMware&lt;/h3&gt;
&lt;p&gt;You need to register on the &lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://support.broadcom.com/&quot;&gt;Broadcom official website&lt;/a&gt;.
I had trouble because the verification email didn’t arrive when I thoughtlessly used my university email, so just use &lt;code&gt;gmail.com&lt;/code&gt; to be safe.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;After logging in, select &lt;code&gt;Software&lt;/code&gt; -&amp;gt; &lt;code&gt;VMware Cloud Foundation&lt;/code&gt; -&amp;gt; &lt;code&gt;My Downloads&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Find &lt;code&gt;VMware Workstation Pro&lt;/code&gt; and select the desired release&lt;/li&gt;
&lt;li&gt;Note that you must check &lt;code&gt;I agree to the Terms and Conditions&lt;/code&gt; to enable the download button&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Fill in the address field that appears and click the download button again to complete the installation.&lt;/p&gt;
&lt;h3 id=&quot;ida-free&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#ida-free&quot; aria-label=&quot;Anchor link for: ida-free&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
IDA Free&lt;/h3&gt;
&lt;p&gt;While it only supports x86/x86-64 architectures, IDA is now available for free.
On the &lt;a class=&quot;external&quot; rel=&quot;external&quot; href=&quot;https://hex-rays.com/&quot;&gt;hex-rays official website&lt;/a&gt;, select &lt;code&gt;Products&lt;/code&gt; -&amp;gt; &lt;code&gt;IDA Free&lt;/code&gt; and receive a license through email verification.&lt;/p&gt;
&lt;p&gt;It seems fine now, but I once had an experience where it was too slow, and using a VPN to Belgium (where their headquarters is) made it much faster.&lt;/p&gt;
&lt;h3 id=&quot;shell-sendto&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#shell-sendto&quot; aria-label=&quot;Anchor link for: shell-sendto&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
shell:sendto&lt;/h3&gt;
&lt;p&gt;Typing &lt;code&gt;shell:sendto&lt;/code&gt; in the &lt;code&gt;win + r&lt;/code&gt; run window lets you register programs that appear in the &lt;code&gt;send to&lt;/code&gt; menu when right-clicking files.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blog.bl4nk.kr/blog/setting-up-windows-for-pwnable/./image-1.png&quot; alt=&quot;shell_sendto&quot; /&gt;&lt;/p&gt;
&lt;p&gt;For example, create an IDA shortcut and place it in that folder.
Then right-click a binary and select IDA from &lt;code&gt;send to&lt;/code&gt; to analyze it directly.
It’s a bit inconvenient in Windows 11 since you need to press &lt;code&gt;Show more options&lt;/code&gt; to see it, but it’s quite useful.&lt;/p&gt;
&lt;p&gt;You can apparently edit the registry to revert to the Windows 10 menu, but I skipped it to keep the new computer feeling.&lt;/p&gt;
&lt;h2 id=&quot;0x02-linux&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x02-linux&quot; aria-label=&quot;Anchor link for: 0x02-linux&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x02. Linux&lt;/h2&gt;
&lt;h3 id=&quot;packages&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#packages&quot; aria-label=&quot;Anchor link for: packages&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Packages&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; initialize&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; update&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; upgrade&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; oh my zsh&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; zsh&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; git&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sh&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;wget&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; zsh plugins&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;git&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; clone&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://github.com/zsh-users/zsh-autosuggestions&lt;/span&gt;&lt;span&gt; $&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;ZSH_CUSTOM&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;:-&lt;/span&gt;&lt;span&gt;~&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;/&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;oh-my-zsh&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;/&lt;/span&gt;&lt;span&gt;custom&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/plugins/zsh-autosuggestions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;git&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; clone&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://github.com/zsh-users/zsh-syntax-highlighting.git&lt;/span&gt;&lt;span&gt; $&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt;ZSH_CUSTOM&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;:-&lt;/span&gt;&lt;span&gt;~&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;/&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;oh-my-zsh&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;/&lt;/span&gt;&lt;span&gt;custom&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/plugins/zsh-syntax-highlighting&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sed&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;s/^plugins=(git)$/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ~/.zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; .zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; python packages&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; python3-pwntools&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; one gadget&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ruby&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; gem&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; one_gadget&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; gef&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;bash&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;wget&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://gef.blah.cat/sh&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;jekyll&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#jekyll&quot; aria-label=&quot;Anchor link for: jekyll&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
jekyll&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Install dependencies&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; apt&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ruby-full&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; build-essential&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; zlib1g-dev&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;y&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Change the file according to your shell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;# Install Ruby Gems to ~/.gems&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ~/.zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;export GEM_HOME=&amp;quot;$HOME/.gems&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ~/.zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;export PATH=&amp;quot;$HOME/.gems/bin:$PATH&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ~/.zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ~/.zshrc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Install jekyll&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;gem&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; jekyll&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bundler&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Execute in jekyll directory such as github.io repository&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; fitbl4nk.github.io&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;bundle&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;zola&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#zola&quot; aria-label=&quot;Anchor link for: zola&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
zola&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Download the latest version of zola (https://github.com/getzola/zola/releases)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;wget&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; https://github.com/getzola/zola/releases/download/v0.20.0/zola-v0.20.0-x86_64-unknown-linux-gnu.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;rm&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; zola-v0.20.0-x86_64-unknown-linux-gnu.tar.gz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; mv&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; zola&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /usr/local/bin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; Execute in zola directory such as github.io repository&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; bl4nk.kr&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;zola&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; serve&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        <summary type="html">Useful tools and settings for pwnable</summary>
        </entry><entry xml:lang="en">
        <title>Automating GDB Debugging with Pwntools</title>
        <published>2024-05-31T00:00:00+00:00</published>
        <updated>2024-05-31T00:00:00+00:00</updated>
        <author>
            <name>bl4nk</name>
        </author>
        <link rel="alternate" href="https://blog.bl4nk.kr/blog/automating-gdb-debugging-with-pwntools/" type="text/html"/>
        <id>https://blog.bl4nk.kr/blog/automating-gdb-debugging-with-pwntools/</id>
        
            <content type="html">&lt;h2 id=&quot;0x00-introduction&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x00-introduction&quot; aria-label=&quot;Anchor link for: 0x00-introduction&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x00. Introduction&lt;/h2&gt;
&lt;p&gt;When solving pwnable challenges, I primarily use &lt;code&gt;pwntools&lt;/code&gt; for scripting and &lt;code&gt;gdb&lt;/code&gt; for debugging.
Usually, you’d spawn a process and attach &lt;code&gt;gdb&lt;/code&gt; from another terminal - but with &lt;code&gt;pwntools&lt;/code&gt; and &lt;code&gt;tmux&lt;/code&gt;, we can automate all of this within the script itself.&lt;/p&gt;
&lt;h2 id=&quot;0x01-debugging-with-pwntools&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x01-debugging-with-pwntools&quot; aria-label=&quot;Anchor link for: 0x01-debugging-with-pwntools&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x01. Debugging with pwntools&lt;/h2&gt;
&lt;h3 id=&quot;spawning-process&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#spawning-process&quot; aria-label=&quot;Anchor link for: spawning-process&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Spawning Process&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;LIBRARY&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; for remote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; remote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;server&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; port&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; for local&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; process&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; env&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;LD_PRELOAD&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; LIBRARY&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use &lt;code&gt;remote&lt;/code&gt; for remote, and &lt;code&gt;process&lt;/code&gt; for local to run and connect to processes.
Especially, &lt;code&gt;remote&lt;/code&gt; is used not only when connecting to actual servers but also when connecting to locally running docker.&lt;/p&gt;
&lt;h3 id=&quot;open-debugger&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#open-debugger&quot; aria-label=&quot;Anchor link for: open-debugger&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Open Debugger&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;attach&lt;/code&gt; function from pwntools’ &lt;code&gt;gdb&lt;/code&gt; module lets you attach a debugger to a running process:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bp&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;555555555249&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;end_of_main&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;5555555552d3&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;55555555566f&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gs&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;b *&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span&gt;bp&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;continue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gdb&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;attach&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; gs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The second argument takes a gdb script, so you can automate setting breakpoints and continuing code flow.&lt;/p&gt;
&lt;p&gt;Also, you can attach debugger to a process inside of docker with &lt;code&gt;pid&lt;/code&gt;, using the following script:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;CONTAINER&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pid&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; os&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;popen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;sudo docker top &lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;CONTAINER&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -eo pid,comm | grep &lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; | awk &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;print $1&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;read&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gdb&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;attach&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;int&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;pid&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; gs&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; exe&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With this script, it is possible to minimize the difference between local and remote environment.
However, errors can occasionally occur when inside and outside of container has permissions that don’t match (see &lt;a href=&quot;https://blog.bl4nk.kr/blog/automating-gdb-debugging-with-pwntools/#permission-error&quot;&gt;Permission Error&lt;/a&gt;).&lt;/p&gt;
&lt;h3 id=&quot;set-terminal&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#set-terminal&quot; aria-label=&quot;Anchor link for: set-terminal&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Set Terminal&lt;/h3&gt;
&lt;p&gt;You need to configure where the attached debugger shows up.
Simple enough with the &lt;code&gt;context&lt;/code&gt; module’s &lt;code&gt;terminal&lt;/code&gt; variable - just pick your preferred layout:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;terminal&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;tmux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;splitw&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-h&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     #&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; split current window horizontally&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;terminal&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;tmux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;splitw&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-v&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;     #&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; split current window vertically&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;terminal&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;tmux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;splitw&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-hf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;    #&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; split entire window horizontally&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;terminal&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;tmux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;splitw&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-vf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt;    #&lt;/span&gt;&lt;span class=&quot;z-l-5 z-d-3&quot;&gt; split entire window vertically&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I know it’s pretty old-fashioned, but I’ve been using &lt;code&gt;tmux&lt;/code&gt; since it’s pretty clean.
You should also note that you’re actually running inside a &lt;code&gt;tmux&lt;/code&gt; session before executing the script (see &lt;a href=&quot;https://blog.bl4nk.kr/blog/automating-gdb-debugging-with-pwntools/#tmux-session-error&quot;&gt;Tmux Session Error&lt;/a&gt;).&lt;/p&gt;
&lt;h2 id=&quot;0x02-conclusion&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x02-conclusion&quot; aria-label=&quot;Anchor link for: 0x02-conclusion&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x02. Conclusion&lt;/h2&gt;
&lt;p&gt;Here’s the final script I use as my &lt;code&gt;exploit.py&lt;/code&gt; template:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;from&lt;/span&gt;&lt;span&gt; pwn&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; import&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; *&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;from&lt;/span&gt;&lt;span&gt; pwnlib&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;util&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;packing&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; import&lt;/span&gt;&lt;span&gt; p32&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; p64&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; u32&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; u64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;from&lt;/span&gt;&lt;span&gt; time&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; import&lt;/span&gt;&lt;span&gt; sleep&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;from&lt;/span&gt;&lt;span&gt; argparse&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; import&lt;/span&gt;&lt;span&gt; ArgumentParser&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;LIBRARY&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;CONTAINER&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;code_base&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;555555554000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;bp&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span&gt; code_base&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; +&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; 0x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;16ae&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gs&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;b *&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span&gt;bp&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;continue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;terminal&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;tmux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;splitw&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-hf&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;server&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; port&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; debug&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;    if&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;port&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        s&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; remote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;server&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; port&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;        if&lt;/span&gt;&lt;span&gt; debug&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            pid&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; os&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;popen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;sudo docker top &lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;CONTAINER&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; -eo pid,comm | grep &lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; | awk &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;{{&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;print $1&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;read&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            gdb&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;attach&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;int&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;pid&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; gs&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; exe&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;    else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        s&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; process&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; env&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;LD_PRELOAD&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt; :&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; LIBRARY&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;        if&lt;/span&gt;&lt;span&gt; debug&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            gdb&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;attach&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;s&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; gs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    elf&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; ELF&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;BINARY&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    lib&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; ELF&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;LIBRARY&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    s&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;interactive&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; __name__&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;__main__&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    parser&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; ArgumentParser&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    parser&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;add_argument&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-s&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;--server&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; type&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;str&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; default&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;0.0.0.0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    parser&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;add_argument&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-p&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; type&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;int&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    parser&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;add_argument&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-d&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;--debug&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; type&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;int&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; default&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    args&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; =&lt;/span&gt;&lt;span&gt; parser&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parse_args&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;args&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;server&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; args&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;port&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; args&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;debug&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; function takes three arguments.
If &lt;code&gt;-p&lt;/code&gt; or &lt;code&gt;--port&lt;/code&gt; is provided, it connects remotely.
Otherwise, it runs locally for debugging:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 7777&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;-port&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 7777&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you’re done debugging, pass 0 to &lt;code&gt;-d&lt;/code&gt; or &lt;code&gt;--debug&lt;/code&gt; to run without a debugger:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;-debug&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, to hit the actual server, pass the domain or IP to &lt;code&gt;-s&lt;/code&gt; or &lt;code&gt;--server&lt;/code&gt; - and definitely disable debugging:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; server.com&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;-server&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; x.x.x.x&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;-debug&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Side note: I’m already doing &lt;code&gt;from pwn import *&lt;/code&gt;, but I explicitly import the packing functions again on line 2 because vscode doesn’t seem to find them.
Otherwise it shows annoying underlines.&lt;/p&gt;
&lt;h2 id=&quot;0x03-troubleshooting&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#0x03-troubleshooting&quot; aria-label=&quot;Anchor link for: 0x03-troubleshooting&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
0x03. Troubleshooting&lt;/h2&gt;
&lt;h3 id=&quot;permission-error&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#permission-error&quot; aria-label=&quot;Anchor link for: permission-error&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Permission Error&lt;/h3&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;GEF&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; linux&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ready,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; type&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;gef&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; to start, `gef config&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; configure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;93&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; commands&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; loaded&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; and&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; functions&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; added&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; GDB&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 12.1&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 0.00ms&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; using&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Python&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; engine&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 3.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Reading&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; symbols&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; from&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; challenge...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;No&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; debugging&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; symbols&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; found&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; challenge&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Attaching&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; program:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /home/user/challenge,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; process&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 165353&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Could&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; not&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; attach&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; to&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; process.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  If&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; your&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; uid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; matches&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; the&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; uid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; of&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; the&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; target&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;process,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; check&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; the&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; setting&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; of&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /proc/sys/kernel/yama/ptrace_scope,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; try&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;again&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; as&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; the&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; root&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; user.&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  For&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; more&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; details,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; see&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /etc/sysctl.d/10-ptrace.conf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;ptrace:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Operation&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; not&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; permitted.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;/home/user/challenge/165353:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; No&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; such&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; file&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; or&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; directory.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;/tmp/pwnlib-gdbscript-kd8sfrgq.gdb:4:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; Error&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; sourced&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; command&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; file:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;The&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; program&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; is&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; not&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; being&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; run.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;gef➤&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When debugging a process inside of docker, the error above might occurs sometimes.
If we take a closer look at the error, it’s something to do with permission.
Printing out the current process list is as follows:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  ps&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;ef&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; |&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt; grep&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      165261&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  165241&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 16:01&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        00:00:00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /bin/sh&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; socat&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; TCP-LISTEN:8794,reuseaddr,fork&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; EXEC:/home/ctf/challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      165284&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  165261&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 16:01&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        00:00:00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; socat&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; TCP-LISTEN:8794,reuseaddr,fork&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; EXEC:/home/ctf/challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      165521&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  165284&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 16:05&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        00:00:00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; socat&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; TCP-LISTEN:8794,reuseaddr,fork&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; EXEC:/home/ctf/challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      165524&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  165521&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 16:05&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; ?&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;        00:00:00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /home/ctf/challenge&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;      165545&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;   66182&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;  0&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 16:05&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; pts/9&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;    00:00:00&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /usr/bin/gdb&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;q&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; challenge&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 165524&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; /tmp/pwnlib-gdbscript-webj6wb7.gdb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The debugger opened via python script is executed with &lt;code&gt;user&lt;/code&gt; permission, whereas the target process &lt;code&gt;challenge&lt;/code&gt; is executed with &lt;code&gt;root&lt;/code&gt; permission.
In this case attaching to the process fails, so the following lines should be added to &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;docker&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;RUN&lt;/span&gt;&lt;span&gt; /usr/sbin/useradd -u 1000 ctf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;USER&lt;/span&gt;&lt;span&gt; ctf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should note that the &lt;code&gt;uid&lt;/code&gt; above should be identical with the &lt;code&gt;user&lt;/code&gt;’s, who is running the python script.
In the case of Ubuntu 24.04, for example, the user &lt;code&gt;ubuntu&lt;/code&gt; is preempting &lt;code&gt;uid&lt;/code&gt; 1000, possibly causing error because a new user will have &lt;code&gt;uid&lt;/code&gt; 1001.&lt;/p&gt;
&lt;h3 id=&quot;tmux-session-error&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#tmux-session-error&quot; aria-label=&quot;Anchor link for: tmux-session-error&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;/a&gt;
Tmux Session Error&lt;/h3&gt;
&lt;p&gt;This is what greeted me when I first ran the script:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; Starting &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;local&lt;/span&gt;&lt;span&gt; process&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;./challenge&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;: &lt;/span&gt;&lt;span&gt;pid&lt;/span&gt;&lt;span&gt; 3886107&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; running in new terminal: &lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/usr/bin/gdb&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-q&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;./challenge&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;3886107&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;-x&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/tmp/pwnjmmmxq9k.gdb&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;Traceback&lt;/span&gt;&lt;span&gt; (most&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; recent&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; call&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; last&lt;/span&gt;&lt;span&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  File&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/home/user/exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 133,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;modul&lt;/span&gt;&lt;span&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  File&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/home/user/exploit.py&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 60,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    gdb.attach(s,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; gs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  File&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/home/user/.local/lib/python3.10/site-packages/pwnlib/context/__init__.py&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 1581,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; setter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;    return&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; function&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span&gt;a, &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span&gt;kw&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  File&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/home/user/.local/lib/python3.10/site-packages/pwnlib/gdb.py&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 1100,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; attach&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    gdb_pid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; misc.run_in_new_terminal&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;cmd,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; preexec_fn&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; preexec_fn&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;  File&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;/home/user/.local/lib/python3.10/site-packages/pwnlib/util/misc.py&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; line&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 413,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; in&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; run_in_new_terminal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;    pid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; int&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;out&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;ValueError:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; invalid&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; literal&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; int&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; with&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; base&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; 10:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; b&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-10&quot;&gt;*&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; Stopped process &lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;./challenge&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;pid&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-4&quot;&gt; 3886107&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The error hit at &lt;code&gt;gdb.attach(s, gs)&lt;/code&gt; with a type issue, so I spent way too long thinking it was a pid datatype mismatch.
Turns out it was something completely different.&lt;/p&gt;
&lt;p&gt;The script tries to create a terminal in a &lt;code&gt;tmux&lt;/code&gt; session - but there was no active &lt;code&gt;tmux&lt;/code&gt; session to attach to.
I naively assumed it would just create one automatically…&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  tmux&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-6 z-d-7&quot;&gt;➜&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt;  python3&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-6&quot;&gt; exploit.py&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
        <summary type="html">Automating pwnable debugging workflow by integrating pwntools, gdb, and tmux into a single exploit script</summary>
        </entry>
</feed>
