<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kartik Iyer on Medium]]></title>
        <description><![CDATA[Stories by Kartik Iyer on Medium]]></description>
        <link>https://medium.com/@iyerkartik633?source=rss-1d1d7a147527------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A_UAMFxUIEGUDEHOaHpeyw.jpeg</url>
            <title>Stories by Kartik Iyer on Medium</title>
            <link>https://medium.com/@iyerkartik633?source=rss-1d1d7a147527------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:35:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iyerkartik633/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Walking the Memory Lane: Diving Deeper Into Volatility Plugins — Episode 2]]></title>
            <link>https://medium.com/@iyerkartik633/walking-the-memory-lane-diving-deeper-into-volatility-plugins-episode-2-464cadde2da3?source=rss-1d1d7a147527------2</link>
            <guid isPermaLink="false">https://medium.com/p/464cadde2da3</guid>
            <category><![CDATA[windows-internals]]></category>
            <category><![CDATA[memory-analysis]]></category>
            <category><![CDATA[plugin-writing]]></category>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[volatility-3]]></category>
            <dc:creator><![CDATA[Kartik Iyer]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 19:42:29 GMT</pubDate>
            <atom:updated>2026-03-28T19:42:29.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnA-eiBN_XemRbsWMBIYcw.png" /></figure><p>Before we begin, if you haven’t read Episode 1 yet, I strongly recommend doing so first — this episode builds directly on the concepts introduced there. You can find it here: <a href="https://medium.com/@iyerkartik633/walking-the-memory-lane-writing-your-first-volatility-plugin-episode-1-91893d6dd873">Link</a></p><h3><strong>Introduction</strong></h3><p>Welcome back to Walking the Memory Lane! In the last episode, we wrote our first two Volatility plugins from scratch — one that printed “Hello, World!” and another that accepted a custom message via a flag. Simple, but foundational.</p><p>In this episode, we’re going to take things up a notch. We’ll do something that sits at the very heart of memory forensics — enumerating the running processes from a memory dump. This is one of the most fundamental things any analyst does when they first load a memory image, and understanding how it works under the hood is what separates someone who <em>uses</em> Volatility from someone who <em>understands</em> it.</p><p>We’ll cover two different approaches to listing processes:</p><ol><li><strong>Using the </strong><strong>PsList plugin as a library</strong> — leveraging Volatility&#39;s built-in plugin infrastructure.</li><li><strong>Using </strong><strong>context.object to manually parse the </strong><strong>_EPROCESS structure</strong> — going deeper into Windows internals and walking the process list ourselves.</li></ol><p>Without further ado, let’s get into it.</p><h4><strong>A Quick Primer: Where Do Processes Live in Memory?</strong></h4><p>Before we write a single line of code, let’s talk about <em>why</em> process enumeration works the way it does in Volatility.</p><p>On a Windows system, every process is represented in kernel memory by a structure called _EPROCESS. This structure contains everything the kernel knows about a process — its name, PID, the virtual address space it owns, its parent process, loaded modules, handles, and much more.</p><p>These _EPROCESS structures are linked together in a <strong>doubly linked list</strong> called PsActiveProcessHead. Think of it like a chain — every process points to the next and the previous one (Flink and Blink), and Volatility walks this chain to enumerate processes (See Figure 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*cU4QrCcokJE8dCtSq6xkXw.png" /><figcaption>Fig. 1. Representation of the Doubly Linked List structure.</figcaption></figure><h4><strong>Approach 1: Using PsList as a Library</strong></h4><p>The first and arguably the easiest way to enumerate processes in your own plugin is to simply reuse what Volatility already provides. The windows.pslist.PsList plugin has a class method called list_processes() that does the heavy lifting for you. You don&#39;t need to reinvent the wheel — you just call it and iterate over the results.</p><h4><strong>What We’re Building</strong></h4><p>We’ll write a plugin called SimpleProcessList that lists all running processes and displays their <strong>PID</strong>, <strong>PPID</strong> (Parent Process ID), <strong>Process Name</strong>, and the number of <strong>active threads</strong>. The sample output is shown below in Figure 2.</p><p><strong>Output Preview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_p__nVB6XY1NCqA79iNbg.png" /><figcaption>Fig. 2. Process Listing as enumerated by our plugin</figcaption></figure><p>Let me first write the complete code, then I’ll explain what every line actually does in detail.</p><pre>import logging<br>from typing import List, Generator, Optional<br><br>from volatility3.framework import interfaces, renderers, constants, logging as vollog<br>from volatility3.framework.configuration import requirements<br>from volatility3.framework.renderers import format_hints<br>from volatility3.framework.symbols import windows<br>from volatility3.plugins.windows import pslist<br><br><br>class SimpleProcessList(interfaces.plugins.PluginInterface):<br>    &quot;&quot;&quot;Enumerates running processes from a memory dump using PsList.&quot;&quot;&quot;<br><br>    _required_framework_version = (2, 0, 0)<br>    _version = (1, 0, 0)<br><br>    @classmethod<br>    def get_requirements(cls) -&gt; List[interfaces.configuration.RequirementInterface]:<br>        return [<br>            requirements.ModuleRequirement(<br>                name=&quot;kernel&quot;,<br>                description=&quot;Windows kernel&quot;,<br>                architectures=[&quot;Intel32&quot;, &quot;Intel64&quot;],<br>            ),<br>            requirements.PluginRequirement(<br>                name=&quot;pslist&quot;,<br>                plugin=pslist.PsList,<br>                version=(3,0,0)<br>            )<br>        ]<br><br>    def _generator(self):<br>        kernel = self.context.modules[self.config[&quot;kernel&quot;]]<br><br>        for proc in pslist.PsList.list_processes(self.context, self.config[&#39;kernel&#39;]):<br>            yield (<br>                0,<br>                (<br>                    proc.UniqueProcessId,<br>                    proc.InheritedFromUniqueProcessId,<br>                    proc.ImageFileName.cast(&quot;string&quot;,<br>                        max_length=proc.ImageFileName.vol.count,<br>                        errors=&quot;replace&quot;),<br>                    proc.ActiveThreads,<br>                ),<br>            )<br><br>    def run(self):<br>        return renderers.TreeGrid(<br>            [<br>                (&quot;PID&quot;, int),<br>                (&quot;PPID&quot;, int),<br>                (&quot;Name&quot;, str),<br>                (&quot;Threads&quot;, int),<br>            ],<br>            self._generator(),<br>        )</pre><h4><strong>Breaking down the code</strong></h4><p>Let me walk through each piece of this carefully.</p><ol><li><strong>The </strong><strong>ModuleRequirement</strong></li></ol><pre>requirements.ModuleRequirement(<br>    name=&quot;kernel&quot;,<br>    description=&quot;Windows kernel&quot;,<br>    architectures=[&quot;Intel32&quot;, &quot;Intel64&quot;],<br>)<br>requirements.PluginRequirement(<br>    name=&quot;pslist&quot;,<br>    plugin=pslist.PsList,<br>    version=(3,0,0)<br>)</pre><p>Unlike the StringRequirement we used in Episode 1, a ModuleRequirement tells Volatility that our plugin needs access to the <strong>Windows kernel module</strong> — the heart of the memory image. Volatility will automatically resolve which kernel module is present in the dump and wire it up for us. The architectures list tells it we support both 32-bit and 64-bit memory images.</p><p>Also, since we’re borrowing PsList&#39;s list_processes() method in our plugin, we need to formally declare that dependency. That&#39;s exactly what PluginRequirement is for — it tells Volatility that our plugin <strong>depends on another plugin</strong> being present and available.</p><ul><li>name is just an internal identifier for this requirement.</li><li>plugin is the actual plugin class we&#39;re depending on — in this case pslist.PsList.</li><li>version specifies the <strong>minimum version</strong> of that plugin we need. Here we&#39;re saying we need PsList version 3.0.0 or above.</li></ul><p>Think of it like a package dependency. If the version of PsList in the framework doesn&#39;t meet this requirement, Volatility will catch it early and tell you, rather than letting your plugin crash mid-execution when it tries to call a method that doesn&#39;t exist.</p><p><strong>2. Grabbing the Kernel Module</strong></p><pre>kernel = self.context.modules[self.config[&quot;kernel&quot;]]<br>layer_name = kernel.layer_name<br>symbol_table = kernel.symbol_table_name</pre><p>This line retrieves the kernel module object from the context using the configuration value set by our ModuleRequirement. From this kernel object, we can pull two incredibly important attributes:</p><ul><li>kernel.layer_name — the <strong>physical/virtual memory layer</strong> that Volatility should read from. Think of this as telling Volatility <em>which lens</em> to look through when reading raw bytes from the dump.</li><li>kernel.symbol_table_name — the <strong>symbol table</strong> that maps structure names like _EPROCESS to their actual offsets. This is how Volatility knows where each field inside a structure is located.</li></ul><p>3. <strong>Calling </strong><strong>list_processes()</strong></p><pre>for proc in pslist.PsList.list_processes(self.context, self.config[&#39;kernel&#39;]):<br>            yield (<br>                0,<br>                (<br>                    proc.UniqueProcessId,<br>                    proc.InheritedFromUniqueProcessId,<br>                    proc.ImageFileName.cast(&quot;string&quot;,<br>                        max_length=proc.ImageFileName.vol.count,<br>                        errors=&quot;replace&quot;),<br>                    proc.ActiveThreads,<br>                ),<br>            )</pre><p>This is the core of Approach 1.list_processes() takes two things — self.context and self.config[&#39;kernel&#39;].</p><ul><li>self.context is the global Volatility context object that holds everything — the memory layers, symbol tables, and configuration. It&#39;s always available inside any plugin through self.</li><li>self.config[&#39;kernel&#39;] is the configuration value set by our ModuleRequirement. Volatility resolves the kernel module from the memory dump and stores it under this key. Passing it here tells list_processes() exactly which kernel to reference when walking the PsActiveProcessHead list.</li></ul><p>Each proc yielded by this loop is a fully resolved _EPROCESS object that you can read fields from directly — no manual offset math, no pointer chasing. list_processes() handles all of those calculations internally.</p><p>4. <strong>Reading Fields from </strong><strong>_EPROCESS</strong></p><p>The field names here are the same as the ones in the actual _EPROCESS structure (see Figure 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*214iSY6KBH01j4_vU_sf3w.png" /><figcaption>Fig. 3. Field names inside the actual _EPROCESS structure</figcaption></figure><pre>proc.UniqueProcessId,<br>proc.InheritedFromUniqueProcessId,<br>proc.ImageFileName.cast(&quot;string&quot;, max_length=..., errors=&quot;replace&quot;),<br>proc.ActiveThreads,</pre><ul><li>UniqueProcessId is the PID.</li><li>InheritedFromUniqueProcessId is the Parent PID (PPID).</li><li>ImageFileName is a fixed-length byte array inside _EPROCESS. We call .cast(&quot;string&quot;, ...) on it to convert it to a readable Python string. The errors=&quot;replace&quot; argument ensures that any unreadable bytes don&#39;t crash our plugin.</li><li>ActiveThreads gives us the number of threads the process has running.</li></ul><p>After writing the plugin, save it in &lt;Volatility3 base directory&gt;/volatility3/plugins/windows, and then you can run it using windows.SimpleProcessList.</p><h4>Approach 2: Manually Walking _EPROCESS Using <em>context.object</em></h4><p>Now let’s go deeper. Instead of relying on PsList, we&#39;re going to do what PsList does internally — manually find the _EPROCESS structure, read it, and walk the doubly linked list ourselves.</p><p>This approach gives you full control and is essential to understand when you want to access structures that no built-in plugin exposes. It’s also what you’ll be doing constantly once you start writing detection plugins for rootkits or malware.</p><h4>What We’re Building</h4><p>A plugin called EprocessWalker that manually resolves _EPROCESS and walks the active process list, printing the same fields as before — but this time from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIJ_tTPfnezdgS-2YyH39w.png" /><figcaption>Fig. 4. Using EprocessWalker plugin to list the processes.</figcaption></figure><p><strong>Complete Code:</strong></p><pre>import logging<br>from typing import List<br>from volatility3.framework import interfaces, renderers, constants, exceptions<br>from volatility3.framework.configuration import requirements<br>from volatility3.plugins.windows import pslist<br><br>class EprocessWalker(interfaces.plugins.PluginInterface):<br>    &quot;&quot;&quot;Manually walks the _EPROCESS linked list to enumerate processes.&quot;&quot;&quot;<br><br>    _required_framework_version = (2, 0, 0)<br>    _version = (1, 0, 0)<br><br>    @classmethod<br>    def get_requirements(cls) -&gt; List[interfaces.configuration.RequirementInterface]:<br>        return [<br>            requirements.ModuleRequirement(<br>                name=&quot;kernel&quot;,<br>                description=&quot;Windows kernel&quot;,<br>                architectures=[&quot;Intel32&quot;, &quot;Intel64&quot;],<br>            ),<br>        ]<br><br>    def _generator(self):<br>        kernel = self.context.modules[self.config[&quot;kernel&quot;]]<br><br>        # We need to get the virtual address of PsActiveProcessHead <br>        # from the symbol table<br>        ps_head_offset = self.context.symbol_space.get_symbol(<br>            kernel.symbol_table_name + constants.BANG + &quot;PsActiveProcessHead&quot;<br>        ).address<br><br>        # Construct a _LIST_ENTRY object at PsActiveProcessHead<br>        list_entry = self.context.object(<br>            kernel.symbol_table_name + constants.BANG + &quot;_LIST_ENTRY&quot;,<br>            layer_name=kernel.layer_name,<br>            offset=kernel.offset + ps_head_offset,<br>        )<br><br>        # Walk the doubly linked list, casting each node to _EPROCESS<br>        for eproc in list_entry.to_list(<br>            kernel.symbol_table_name + constants.BANG + &quot;_EPROCESS&quot;,<br>            &quot;ActiveProcessLinks&quot;,<br>        ):<br>            try:<br>                yield (<br>                    0,<br>                    (<br>                        eproc.UniqueProcessId,<br>                        eproc.InheritedFromUniqueProcessId,<br>                        eproc.ImageFileName.cast(<br>                            &quot;string&quot;,<br>                            max_length=eproc.ImageFileName.vol.count,<br>                            errors=&quot;replace&quot;,<br>                        ),<br>                        eproc.ActiveThreads,<br>                    ),<br>                )<br>            except exceptions.InvalidAddressException:<br>                continue<br><br>    def run(self):<br>        return renderers.TreeGrid(<br>            [<br>                (&quot;PID&quot;, int),<br>                (&quot;PPID&quot;, int),<br>                (&quot;Name&quot;, str),<br>                (&quot;Threads&quot;, int),<br>            ],<br>            self._generator(),<br>        )</pre><blockquote><strong>Note:</strong> You’ll need to add from volatility3.framework import constants to your imports for the constants.BANG separator (which is just &quot;!&quot;), used to construct fully qualified symbol names.</blockquote><p><strong>Breaking it Down</strong></p><ol><li><strong>Resolving </strong><strong>PsActiveProcessHead</strong></li></ol><pre>ps_head = self.context.symbol_space.get_symbol(<br>    symbol_table + constants.BANG + &quot;PsActiveProcessHead&quot;<br>).address</pre><p>PsActiveProcessHead is a global kernel variable — it&#39;s the head of the doubly linked list of all active processes. We look it up by name through symbol_space, which uses the PDB symbols Volatility has loaded. The constants.BANG is just &quot;!&quot;, so the full symbol name looks something like ntkrnlmp!PsActiveProcessHead.</p><blockquote><strong>Note: What are symbols?</strong></blockquote><blockquote>When Windows is compiled, the compiler generates a <strong>PDB file</strong> alongside the binary — essentially a map of every function, global variable, and structure with their exact memory offsets. Volatility downloads and uses these PDB files automatically to build its symbol table.</blockquote><blockquote>The ! separator is a convention borrowed directly from WinDbg, where you reference symbols as module!symbolname. If you want to get a feel for this, fire up WinDbg and run:</blockquote><pre>dt nt!_EPROCESS</pre><blockquote>You’ll see every field inside _EPROCESS with its offset — UniqueProcessId, ActiveProcessLinks, ImageFileName and so on. These are the exact same fields you access in your plugin via eproc.UniqueProcessId. WinDbg just lets you visualize them before you write a single line of Python.</blockquote><p><strong>2. Constructing the Object with </strong><strong>context.object</strong></p><pre>list_entry = self.context.object(<br>    symbol_table + constants.BANG + &quot;_LIST_ENTRY&quot;,<br>    layer_name=layer_name,<br>    offset=kernel.offset + ps_head,<br>)</pre><p>This is the key call. context.object() is Volatility&#39;s way of constructing a typed object at a specific offset in memory. You&#39;re telling it:</p><ul><li><strong>What type</strong> to construct (_LIST_ENTRY — the doubly linked list node structure).</li><li><strong>Which memory layer</strong> to read from (layer_name — the kernel virtual address space).</li><li><strong>Where in memory</strong> to read it from (kernel.offset + ps_head — the actual virtual address of the list head).</li></ul><p>Once you understand context.object, you can construct <em>any</em> Windows kernel structure at <em>any</em> address, as long as you know the type name and the offset.</p><p><strong>3. Walking the List with </strong><strong>to_list()</strong></p><pre>for eproc in list_entry.to_list(<br>    symbol_table + constants.BANG + &quot;_EPROCESS&quot;,<br>    &quot;ActiveProcessLinks&quot;,<br>):</pre><p>to_list() is a helper method on _LIST_ENTRY objects that walks the doubly linked list for you. You pass it:</p><ul><li>The type of object at each node (_EPROCESS).</li><li>The name of the LIST_ENTRY member <em>within</em> that structure that forms the link (&quot;ActiveProcessLinks&quot;) (See Figure 5).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*vJ8IFP9pBLKmPT5bwjpYSg.png" /><figcaption>Fig. 5. _LIST_ENTRY structure within the _EPROCESS structure</figcaption></figure><p>Internally, it calculates the correct offset to read each _EPROCESS from, and yields them one by one. This is exactly how PsList works under the hood.</p><p><strong>4. Handling </strong><strong>InvalidAddressException</strong></p><pre>except exceptions.InvalidAddressException:<br>    continue</pre><p>In real memory forensics, memory images are rarely perfect. Pages can be swapped out, structures can be partially overwritten, or malware might have tampered with the list. Wrapping your reads in a try-except for InvalidAddressException is good practice — it keeps your plugin from crashing on corrupted or incomplete data.</p><h3>Wrapping Up</h3><p>And that’s a wrap on Episode 2!</p><p>We covered a lot of ground today. We started with understanding where processes actually live in memory; the _EPROCESS structure and the PsActiveProcessHead linked list that chains them all together. Then we looked at two different ways to enumerate those processes in a plugin.</p><p>The first approach, using PsList.list_processes(), is clean and quick. You&#39;re essentially borrowing Volatility&#39;s own process enumeration logic and plugging it into your plugin. Great for when you just need the process list and want to move on to doing something more interesting with it.</p><p>The second approach, manually constructing _EPROCESS using context.object() and walking the list ourselves, is where things got genuinely interesting. This is the approach that actually teaches you how Volatility works under the hood. We learnt resolving symbols, constructing typed objects at raw memory offsets, and following linked list pointers through kernel memory. Once you&#39;re comfortable with context.object(), you can reach into virtually any kernel structure from any plugin you write. That&#39;s a powerful place to be.</p><p>We also touched on get_requirements() more seriously this time — understanding not just ModuleRequirement but also PluginRequirement, and why declaring your dependencies explicitly actually matters.</p><p>In the next episode, we’ll tackle something that a lot of beginners find confusing at first but makes total sense once it clicks — <strong>layer switching</strong>. We’ll go in depth on how Volatility manages different memory address spaces, what add_process_layer() actually does behind the scenes, and how to use it to read user-mode structures like the PEB that live inside a specific process&#39;s virtual memory. It&#39;s one of those topics that unlocks a whole new level of what you can do with a plugin.</p><p>If you have questions, suggestions, or just want to talk memory forensics, windows internals or malware analysis, feel free to reach out to me on <a href="http://www.linkedin.com/in/kartik-natarajan-iyer-796217212">LinkedIn</a>, follow along on <a href="https://github.com/KartikIyerr">GitHub</a>, or catch me on <a href="https://x.com/kartikk_iyerr">X</a>. Always happy to chat.</p><p>See you in Episode 3 of <strong>Walking The Memory Lane</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=464cadde2da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Walking the Memory Lane: Writing Your First Volatility Plugin— Episode 1]]></title>
            <link>https://medium.com/@iyerkartik633/walking-the-memory-lane-writing-your-first-volatility-plugin-episode-1-91893d6dd873?source=rss-1d1d7a147527------2</link>
            <guid isPermaLink="false">https://medium.com/p/91893d6dd873</guid>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[volatility-framework]]></category>
            <dc:creator><![CDATA[Kartik Iyer]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 09:23:40 GMT</pubDate>
            <atom:updated>2025-03-29T09:23:40.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U325bzOz0Tpofs1p.png" /></figure><h3><strong>Introduction</strong></h3><p>The Volatility Framework is one of the most widely used memory forensics suites to date. It was first introduced in August 2007 as an open-source project developed by Aaron Walters, building upon his academic research. In 2008, the Volatility Framework made its public debut with version 1.1.1, evolving from earlier tools such as FATKit and VolaTools.</p><p>While there are numerous resources available to learn about memory forensics, including one of my favorites, “<a href="https://repo.zenk-security.com/Forensic/The%20Art%20of%20Memory%20Forensics%20-%20Detecting%20Malware%20and%20Threats%20in%20Windows,%20Linux,%20and%20Mac%20Memory%20(2014).pdf">The Art of Memory Forensics</a>,” there is a noticeable shortage of tutorials on how to write a Volatility plugin from scratch. In today’s episode, we will create our first Volatility plugin from the ground up. We will explore the basic structure of a plugin, examine each component in detail, and then write our own Volatility plugin.</p><h3>Pre-Requisites</h3><p>Download the latest version of the Volatility 3 Framework from this <a href="https://github.com/volatilityfoundation/volatility3">link</a>. It is essential to have a basic understanding of the Python programming language, as the plugin will be written in Python.</p><h3>Understanding Volatility 3 Plugin Structure.</h3><p>Plugins are simply add-ons to the framework that enhance its capabilities for detecting large amounts of information from memory dumps. Each plugin has its own specific area of functionality. For example, if you navigate to the volatility3/framework/plugins/windows/ directory, you’ll find multiple plugins located there (see figure 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQit3QFPvMT6imgWioVWGw.png" /><figcaption>Fig. 1. Listing various core volatility 3 plugins.</figcaption></figure><p>We will not be adding our plugins to this directory, as it is reserved for core plugins created by the developers and maintainers of this framework. For custom plugins to be recognized by Volatility, developers have designated a separate location. Please navigate to the volatility3/plugins/windows<strong><em> </em></strong>directory (see figure 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PrVk2UQpkBX9BRZVeXTSew.png" /><figcaption>Fig. 2. Custom plugins should be stored here.</figcaption></figure><p>Now, when you store your custom-written plugin in this directory, Volatility will recognize and list it among its available plugins. Use the command below to display the various plugins recognized by Volatility 3.</p><pre>python3 vol.py -f &lt;MEMORY_DUMP&gt; --help</pre><h3>Creating Our First Plugin</h3><p>Below is a common structure used in most Volatility plugins. You’ll notice three key methods that form the foundation of a plugin. While not all of them are strictly required for the simplest plugins (and we won’t use all of them in our first example), they are essential in most real-world plugins. Understanding these methods will help you build more advanced plugins as you progress.</p><pre>import volatility3.framework.interfaces.plugins as interfaces<br>from volatility3.framework import renderers<br><br>class ClassName(interfaces.PluginInterface):<br>    &quot;&quot;&quot;Plugin description goes here&quot;&quot;&quot;<br><br>    _required_framework_version = (2, 0, 0)<br>    _version = (3, 0, 0)<br><br>    @classmethod<br>    def get_requirements(cls):<br>        # your requirements here<br><br>    def run(self):<br>        return renderers.TreeGrid(<br>            [(&quot;Column_Name&quot;, str)],  <br>            [(0, (&quot;Column_Value&quot;,))] <br>        )<br><br>    def _generator():<br>     # Output to be generated.</pre><p>Don’t worry, I’ll be explaining each one of the steps in detail now. Let’s start with the basics. Firstly, I will show you an output snippet of what will be displayed on the screen, and then I will provide the complete code snippet with a detailed explanation of every single line and why it is needed.</p><h4><strong><em>Output — I:</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*2O7u2heNAmxrm4PBEAP5zg.png" /><figcaption>Fig. 3. Plugin displaying output as Hello World.</figcaption></figure><h4><strong><em>Our First Volatility Plugin — Hello World:</em></strong></h4><ol><li>Importing the required libraries:</li></ol><pre>import volatility3.framework.interfaces.plugins as interfaces<br>from volatility3.framework import renderers</pre><p>a.<em> </em><em>import volatility3.framework.interfaces.plugins as interfaces </em>is required to be imported because it contains the base class PluginInterface, which all Volatility 3 plugins must inherit from.</p><p>b. <em>from volatility3.framework import renderers </em>is required to be imported as it is responsible for rendering and displaying the output on the user screen.</p><p>2. Creating a custom class that inherits from the PluginInterface base class:</p><pre>class HelloWorld(interfaces.PluginInterface):<br>    &quot;&quot;&quot;A simple Volatility 3 plugin that prints Hello, World!&quot;&quot;&quot;</pre><p>The next step is to define our class, which will serve as the core of our plugin. The name you choose here will be the official name of your plugin. In this example, I’ve named it <strong>HelloWorld</strong>.</p><p>Additionally, it’s important to inherit from interfaces.PluginInterface, as this is the base class required for all Volatility 3 plugins.</p><p>3. Defining the versions:</p><p>The next step is to define the framework and plugin versions. This is important because it ensures compatibility by specifying which version of Volatility the plugin is designed to work with. Setting these versions helps avoid errors when running the plugin on different framework updates.</p><pre>_required_framework_version = (2, 0, 0)<br>_version = (1, 0, 0)</pre><p>a. <em>_required_framework_version</em>:<em> </em>Is required to specify which version of volatility framework this plugin is compatible to work with. In our case, the plugin can work with <strong>Volatility 3 Framework 2.0.0 or above.</strong></p><p>b. <em>_version</em>: Here you specify your version of your plugin. In this case, it is <strong>HelloWorld version 1.0.0.</strong></p><p>4. Defining the run method in our plugin:</p><p>The run method is like the main function of a Volatility plugin and is one of the most important methods to implement. It serves as the entry point for execution, meaning every Volatility plugin starts running from this method.</p><pre>def run(self):<br>        return renderers.TreeGrid(<br>            [(&quot;Message&quot;, str)],<br>            [(0, (&quot;Hello, World!&quot;,))]<br>        )</pre><p>As you can see in the code snippet above, we are returning a TreeGrid, but you might be wondering—what exactly is a TreeGrid? Simply put, it does exactly what its name suggests. TreeGrid is responsible for displaying output in a structured, table-like format. It takes two main arguments: <strong>column definitions</strong> and <strong>row data</strong>.</p><p>In our case, &quot;Message&quot; is the column name, and &quot;Hello, World!&quot; is the row value. But wait—why is there a 0 before (&quot;Hello, World!&quot;)? That’s because each row is structured as a tuple, following this format:</p><pre>[(hierarchy level,(values for columns,))]</pre><p>Since our plugin is displaying just a single message, we use 0, which indicates that there is no hierarchy in the data.</p><p>We have now completed writing our first plugin. The complete code snippet is provided below. Save this file as hello.py or with whatever name your heart desires in volatility3/plugins/windows directory.</p><pre>import volatility3.framework.interfaces.plugins as interfaces<br>from volatility3.framework import renderers<br><br>class HelloWorld(interfaces.PluginInterface):<br>    &quot;&quot;&quot;A simple Volatility 3 plugin that prints Hello, World!&quot;&quot;&quot;<br><br>    _required_framework_version = (2, 0, 0)<br>    _version = (1, 0, 0)<br><br>    def run(self):<br>        return renderers.TreeGrid(<br>            [(&quot;Message&quot;, str)],  <br>            [(0, (&quot;Hello, World!&quot;,))]  <br>        )</pre><p>After completing the previous steps, use the command below to verify if our plugin is recognized by the Volatility 3 Framework. If it is detected, this means you have successfully created your first Volatility plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iz8YA5G0nmJiJpZKkTqltg.png" /><figcaption>Fig. 4. HelloWorld plugin is recognized by Volatility 3</figcaption></figure><h4>Executing our plugin</h4><p>Executing a volatility plugin is simple, you just need to follow any one of the syntax provided below:</p><pre>python3 vol.py -f &lt;MEMORY_DUMP&gt; windows.hello.HelloWorld<br>OR<br>python3 vol.py -f &lt;MEMORY_DUMP&gt; windows.hello<br>OR<br>python3 vol.py -f &lt;MEMORY_DUMP&gt; hello</pre><p>In the syntax above, hello refers to the file name we specified, while HelloWorld is the class name. There are three different syntaxes provided, and you can follow any approach that works best for you.</p><p>The output screenshot has already been provided at the beginning of the section.</p><h3>Creating Our Second Plugin</h3><p>Now that you understand how to write a simple volatility plugin and use it within the Volatility 3 Framework, we will now focus on creating another plugin with additional functionalities. This new plugin will display a custom message. We will modify our previous code to include a flag,--message &lt;OUR_MSG&gt;, which allows us to specify the desired text to display in the output. To give you a clear idea of what we aim to achieve, I will start by presenting the expected output first.</p><h4>Output — II</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HUVOoixvH8bUISQebzxYWA.png" /><figcaption>Fig. 5. Custom display of the text “Forensics” in the output.</figcaption></figure><p>Every step mentioned in the first example, from importing libraries to defining the version, remains the same. The only difference is that we need to add one extra import for handling requirements from the framework.configuration module. This import is essential because it allows us to define different types of input parameters for our plugin. There are various requirement standards that one can use:</p><ol><li>BooleanRequirement</li><li>StringRequirement</li><li>ModuleRequirement</li><li>ListRequirement</li><li>IntegerRequirement</li></ol><pre>from volatility3.framework.configuration import requirements</pre><p>As we are aiming to print a value of type string, so we will be focusing on using StringRequirement in this example.</p><ol><li>Defining the imports:</li></ol><pre>import volatility3.framework.interfaces.plugins as interfaces<br>from volatility3.framework import renderers<br>from volatility3.framework.configuration import requirements</pre><p>2. Defining the class:</p><pre>class CustomMsg(interfaces.PluginInterface):<br>    &quot;&quot;&quot;A simple Volatility 3 plugin that prints a custom message.&quot;&quot;&quot;<br>    <br>    _required_framework_version = (2, 0, 0)<br>    _version = (1, 0, 0)</pre><p>3. Defining the requirements:</p><pre>  def get_requirements(cls):<br>    return [<br>        requirements.StringRequirement(<br>                name=&quot;Name of the parameter&quot;,<br>                description=&quot;A short description of the requirement goes here.&quot;,<br>                default=&quot;Default string to be printed if no flag is given&quot;,<br>                optional=True # User don&#39;t have to mention it everytime.<br>            ),<br>        ]</pre><p>In the above code snippet, we have introduced a new method called get_requirements(cls). This method requires four parameters, which have already been explained in the above syntax snippet. Additionally, we use cls in the parentheses because this method operates on the class itself rather than an instance, as indicated by the @classmethod decorator.</p><p>The completed code for the get_requirements(cls) function is provided below:</p><pre>@classmethod<br>    def get_requirements(cls):<br>        from volatility3.framework.configuration import requirements<br>        return [<br>            requirements.StringRequirement(<br>                name=&quot;message&quot;,<br>                description=&quot;Will display the message you desire&quot;,<br>                default=&quot;Hello, World!&quot;,<br>                optional=True<br>            ),<br>        ]</pre><p>4. Defining the _generator method:</p><pre>def _generator(self):<br>        yield (0, (self.config.get(&quot;message&quot;),)) </pre><p>The _generator method is responsible for yielding data, which is then passed to the TreeGrid<strong> </strong>renderer in the run method. The TreeGrid method itself doesn’t generate the data; it only formats and displays the data produced by _generator or the data that we explicitly define.</p><p>The yield method is used to submit data that will be processed and displayed by the TreeGrid. But wait! what exactly is self.config.get(&quot;message&quot;)? Well, it&#39;s simply a way to get the value you pass to the --message &lt;MESSAGE&gt; parameter, which in this case is a string. So, if you use --message HELLO, it will grab that value, &quot;HELLO&quot; and then it will be passed on to the TreeGrid method.</p><p>5. Defining the run method:</p><pre>def run(self):<br>        return renderers.TreeGrid(<br>            [(&quot;Message&quot;, str)],  <br>            self._generator()<br>        )</pre><p>This function was already explained in the previous example. The only difference here is the use of the self._generator() method, which allows the string value provided by the user to be passed to this function and displayed in a structured format.</p><p>Below is the complete code snippet for the plugin:</p><pre>import volatility3.framework.interfaces.plugins as interfaces<br>from volatility3.framework import renderers<br><br>class CustomMsg(interfaces.PluginInterface):<br>    &quot;&quot;&quot;A simple Volatility 3 plugin that prints a custom message.&quot;&quot;&quot;<br>    <br>    # Use a direct version tuple<br>    _required_framework_version = (2, 0, 0)<br>    _version = (1, 0, 0)<br>    <br>    @classmethod<br>    def get_requirements(cls):<br>        from volatility3.framework.configuration import requirements<br>        return [<br>            requirements.StringRequirement(<br>                name=&quot;message&quot;,<br>                description=&quot;Will display the message you desire&quot;,<br>                default=&quot;Hello, World!&quot;,<br>                optional=True<br>            ),<br>        ]<br>    <br>    def _generator(self):<br>        yield (0, (self.config.get(&quot;message&quot;),))  <br>    <br>    def run(self):<br>        return renderers.TreeGrid(<br>            [(&quot;Message&quot;, str)],  <br>            self._generator()<br>        )</pre><p>That wraps up this episode! In the next one, we’ll dive into more advanced examples, such as extracting and displaying the processes running from a memory dump, along with other interesting use cases. Stay tuned for the next episode of “Walking The Memory Lane”, where we continue our journey into memory forensics and Malware Analysis!</p><h4>References</h4><ol><li>LinkedIn: <a href="http://www.linkedin.com/in/kartik-natarajan-iyer-796217212">www.linkedin.com/in/kartik-natarajan-iyer-796217212</a></li><li>GitHub: <a href="https://github.com/KartikIyerr">https://github.com/KartikIyerr</a></li><li>X: <a href="https://x.com/kartikk_iyerr?t=Z1qTL0TGokeLRvdsj7hAuA&amp;s=08">https://x.com/kartikk_iyerr?t=Z1qTL0TGokeLRvdsj7hAuA&amp;s=08</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91893d6dd873" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>