<?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 Galdadoun on Medium]]></title>
        <description><![CDATA[Stories by Galdadoun on Medium]]></description>
        <link>https://medium.com/@galdadoun_92442?source=rss-c86567b35c91------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zBo1g4i9fy5r8ERI.jpg</url>
            <title>Stories by Galdadoun on Medium</title>
            <link>https://medium.com/@galdadoun_92442?source=rss-c86567b35c91------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:35:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@galdadoun_92442/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[Analyzing Chrome extension — a less discussed vector for cyber-attack?]]></title>
            <link>https://medium.com/@galdadoun_92442/analyzing-chrome-extension-a-less-discussed-vector-for-cyber-attack-38ebaf4b48d5?source=rss-c86567b35c91------2</link>
            <guid isPermaLink="false">https://medium.com/p/38ebaf4b48d5</guid>
            <category><![CDATA[security-research]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[code-analysis]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[incident-response]]></category>
            <dc:creator><![CDATA[Galdadoun]]></dc:creator>
            <pubDate>Tue, 29 Jul 2025 09:42:43 GMT</pubDate>
            <atom:updated>2025-07-29T09:42:43.304Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analyzing Chrome extension — a less discussed vector for cyber-attack?</h3><p>It&#39;s no secret that more and more services are transitioning to web-based applications, which are slowly making web browsers the new operating system for employees. The recent surge in SaaS applications (Google Docs/Drive/Jira/Monday/Splunk/ServiceNow, and many more) emphasizes the importance of keeping that new “OS” protected.<br>As you may know, most browsers (Chromium-based, WebKit-based, and Firefox-based) support extensions in the browser, and usually, extensions are wonderful and can assist in a multitude of ways, from blocking annoying ads to analyzing the technological stack of a website for penetration testing, as well as modifying the content of the site to force it into dark mode.<br>But, as with any “OS”, there are always security concerns.<br>And downloading software to the browser (in the form of an extension) can be very dangerous, and like any software we install, we need to be cautious about what we are installing</p><p>Before examining how an extension is built and how we as a defender can analyze it, let&#39;s understand what an extension is in Chrome more broadly (for this article, I will be focusing on Chrome since it&#39;s interchangeable with Chromium and it&#39;s the most used browser, so if I refer to browser, I refer to Chromium-based browser)</p><p>The goal of this article is to act as a framework that you can refer to when you need to analyze a Chrome extension as part of a malware analysis.<br>By no means is it the only way (or the best way) to approach this specific threat, yet it&#39;s a framework I found very easy to follow and understand, and for me it always got the results I needed.</p><h3>Understanding the threat:</h3><p>So, according to Google developers&#39; website:</p><blockquote><a href="https://developer.chrome.com/docs/extensions/get-started">Chrome extensions</a> enhance the browsing experience by customizing the user interface, observing browser events, and modifying the web. Visit the <a href="https://chromewebstore.google.com/">Chrome Web Store</a> for more examples of what extensions can do.</blockquote><p>As we can understand, browser extensions have a huge potential to harm users and organizations. They can “listen” to browser events (potential data theft and credential stealing), and they can modify web content (potentially phishing), and as we know, extensions can even modify requests (for example, User-Agent/cookie editors)<br>Overall, this poses a significant risk that needs to be managed and mitigated, since it can impact organizations, especially now that the industry is shifting to cloud-based and web-based applications.</p><h3>How do we approach this investigation?</h3><p>Well, investigating an extension is pretty similar to traditional malware analysis. It is possible to analyze it both statically and dynamically. In addition, we can also use OSINT techniques that can lead us to more IOCs/IOAs.<br>However, before we start dissecting the extension, we first need to understand how it&#39;s built and what tools are at our disposal for understanding its activity.</p><h3>Understanding the layout of a browser extension:</h3><p>If we check the Chrome developer page for “<a href="https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world">build your first extension</a>”, we can see that to create an extension, the minimum requirement for an extension is the following files:</p><ul><li>Manifest.json</li><li>Service worker</li><li>Content scripts</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*bfbv_C83IcbMmmimKEOMgQ.png" /><figcaption>extension project</figcaption></figure><p>checking an existing extension on disk, and this is the structure of a random extension project. Now, let&#39;s unpack what each of them does.</p><h3>The manifest file</h3><p>The <a href="https://developer.chrome.com/docs/extensions/reference/manifest">manifest file </a>is a key file in the Chrome extension. It is responsible for the structure, behavior, and permissions of the extensions. This file must be in every extension, and it must be named “manifest.json”. It acts as the “core” of the extension.<br>When analyzing a new extension, this should be the first stop.</p><h3>The Service Worker</h3><p>A service worker in a Chrome extension is a special JavaScript file that runs in the background separately from the extension’s UI, and only when needed (event-driven). It’s like a temporary invisible background process that wakes up to handle tasks and then goes back to sleep.</p><h3>Content script</h3><p>A <strong>content script</strong> is JavaScript that <strong>runs in the context of a web page. </strong>meaning it can <strong>read and modify the content</strong> of websites the user visits. (for example, filling up credentials like 1Password in a login form for a website)<br>Unlike a service worker, which runs in the background and handles events and logic, a content script is <strong>injected into webpages</strong> to interact directly with the DOM like a user script.</p><h3>Chrome extension OSINT investigation</h3><p>Now for the interesting part.<br>We went through the layout of the extension and now have a better understanding of how the extension operates and what we need to focus on. We can start analyzing it better.</p><p>Let&#39;s start with the path on the disk in which Chrome extensions are stored:</p><pre>In Windows:<br>C:\Users\Username\AppData\Local\Google\Chrome\User Data\Default\Extensions<br><br>In linux:<br>~/.config/google-chrome/Default/Extensions/</pre><p>Once on this path, you should be able to see all the installed extensions in the browser. However, the name seems to be random letters (which associated with the ID given to them in the store)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*btoexVNp7slki_652Z6U6w.png" /><figcaption>extensions on disk</figcaption></figure><p>But why does it matter that the unique ID is related to the one on the store?<br>Well it can give us a clue as to how reliable the extension is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QA9o9cDRXQScbnkf6iQXXg.png" /><figcaption>checking the amount of downloads, rating, and reviews for an extension can help asses the risk</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmVufX7Sv5BcL_qcQx3Dug.png" /><figcaption>validate that the extension updates regularly</figcaption></figure><p>if you&#39;re suspecting a certain extension is malware, look at the email associated with the developer. If you spot a similar mail pattern across several extensions, that could mean that this particular extension is a part of a larger malware campaign.</p><p>Now we can start going through some methodologies to identify malicious activities.<br>Open up PowerShell on the path with the extension and run the following cmdlet</p><pre>get-filehash manifest.json</pre><p>This cmdlet will calculate the SHA256 of the file. do that to all the files in the /lib folder (since V2 extensions are no longer support downloading and using code from extenal sources. which means all the cod needs to be within the libraries) so we can use that knowledge to get the hash for all the code libraries in the extension and dump them on virus-total to check if the library is known. If it is known and you validate that it&#39;s benign, we can move forward to the next library.<br>However, if the hash has not been found, you may need to read through that code to understand how it works (it could be a custom library, or a known library with a malicious twist, but more on this in the static analysis side of the investigation)</p><p>What else can we check using OSINT?<br>quite a lot, here are some ideas:</p><ul><li>domains<br>If there are any associated domains in the code/email of registration /<br>You can find that information using a command like dig or nslookup<br>But you may also find the answer in DomainTools and Whois. Especially pay attention to the domain registration date as well as to the contact information (if it&#39;s reduced since the domain owner refused to give it, then it may be malicious or, at the very least, suspicious)</li><li>known hashes <br>If there are known malware that can be related to it, you may be able to find more information about it using any.run / hybrid analysis/virus total</li><li>external IP<br>If there is a hardcoded IP, you may be able to find data on it using AbuseIPDB, Shodan, or Censys.</li><li>associated phishing or malicious site<br>try to search the site on urlcheck/ urlscan / checkphish / phishtank <br>and if found anything try to the found data to pivot around it.</li><li>Noteable mentions:<br>Alienvault OTX, scamadvisor, voidURL</li></ul><blockquote>remember:<br>you should always start with as much data as possible and then narrow your scope.</blockquote><p>To give you a better example, I chose a random extension and started analyzing it.</p><p>I downloaded a Chrome extension I found intriguing. It had only one review, and it was a 5-star review; and at the time of writing it, it had fewer than 10 people downloaded it worldwide. So of course, I had to be among them 😁.<br>However, just in case this specific extension is benign, I&#39;ll do my best to keep it as vague as possible while still showing you the important stuff.</p><p>First, let’s check the extension layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*ZXJZKNCzYW34T4MUQByhPw.png" /></figure><p>We don&#39;t see the “lib” folder, so maybe it does not use known libraries such as JQuery. However, we do see the “src” directory. which likely hosts some added code. So, before diving into the code, let’s check if the file there have a known hash.</p><p>To do so, open up PowerShell in this directory (you can do that by writing PowerShell at the top of the “Explorer” window, where the path of the directory appears)</p><p>A bit confusing, but in this particular case, the src directory contained another directory called assets, which contained the actual images of the extension. And the assets directory contains more code (maybe a way to evade analysis). Another weird thing is that they have what seems like random letters in the name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*RSLvlzpGK90H8m0CxeNTpQ.png" /><figcaption>the files in the asset directory</figcaption></figure><p>As we can see, there are a few files in this directory that can be executed by a browser since they are JavaScript. Let’s calculate their hash and validate if they are known.</p><pre>Get-ChildItem -Recurse -File | ForEach-Object { Get-FileHash $_.FullName -Algorithm SHA256 | Select-Object Hash,Path }</pre><p>You can use this one-liner to calculate all the hashes in the current directory. This will output all the hashes of the files.</p><p>In this specific case, none of the hashes were found. It is possible that the files contained a modified version of known libraries or that the code was written by this particular developer. <br>And this leads us to the second step…<br>Searching all the files for URLs or hard-coded IPs</p><h3>Chrome extension static analysis</h3><p>So, how do we start analyzing a Chrome extension statically?<br>Well, first and foremost, treat the extension you&#39;re investigating as malware. This means that you should set up an isolated environment with Chrome to investigate it (VM / Windows sandbox)</p><h3>Analyzing the manifest file</h3><p>Analyzing the manifest file, the file contains several interesting things</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6FLJBXWYm7nOqOJ7tYGbqw.png" /></figure><p>As we can see, there is a plethora of things we should note in the manifest file.<br>The first is the field “action” which indicates what happens when the extension is loaded, as we can see, it activates the “index.html” file.<br>We can also learn about the content script (which, as explained previously, are the scripts that run in the context of the web page and can modify web objects such as the DOM). As we can see, there are 3 scripts with obscure names. Afterwards, we can see the field of permission, which shows what access is granted to the extension. In this case, the extension can access the context menu (right-click) and the storage (Chrome storing objects in memory)</p><p>Let&#39;s understand the permission in Chrome a bit better:</p><ul><li>Context menu<br>Provide access to the right-click menu, in some web apps, it can store sensitive information.</li><li>Storage<br>Grant access to the storage (equivalent of reading the data from Chrome DevTools -&gt; Application -&gt; Storage). This place stores a lot of information, such as session variables (theme, session storage, cookies, offline data, and so much more), which can be highly sensitive</li><li>ActiveTabs<br>Grant access to all the currently active tabs ( a malicious extension can use that to grab session information like crypto or banking.</li><li>clipboardRead / clipboardWrite<br>can modify or read the clipboard, which can be used maliciously (for example, detect a crypto wallet address and modify it to a specific crypto wallet or copy a password from the clipboard and send it to the adversary.</li></ul><p>You can read more about the extension permission <a href="https://developer.chrome.com/docs/extensions/reference/permissions-list?utm_source=chatgpt.com">here</a></p><p>Lastly, the manifest contains several files that have access to the internet<br>This can be dangerous since it can pull down a malicious script and execute it on the browser.</p><p>We can check if the permission took effect when we install the extension by right-clicking on a web page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcDkud4NLhli3J1UTbL_xA.png" /></figure><h3>Static analysis</h3><p>We won&#39;t go super in-depth into the code of this specific extension since the idea of the article is to allow you to understand the methodology of analyzing extensions.</p><p>So let&#39;s get an overview of the extension without too many details. We saw that the manifest loaded index.html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*Qr98Yzjbo_9-dTLAo9rBmw.png" /></figure><p>As we can see, there are several imports across the extension.<br>To show the flow of execution, I created the execution flow chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPQebEEEyKzz2gJ6hmvZDA.png" /><figcaption>an overview of the imports of the extension and the order of execution</figcaption></figure><p>We can follow each execution by searching methods like “import”<br>But what does that mean? Well, when a code is imported, it essentially runs on the host. Meaning when a library is loaded, all the code in it (whether it is benign or malicious) is executed by the browser.<br>This is an example of a weirdly built extension. And all the naming conventions are a bit weird, and the code inside is somewhat obfuscated<br>for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1M2NUdercRbIgnonEH2mvg.png" /><figcaption>Yep pretty overwhelming when you l ook at this, but thank god for LLMs that can help make sense of it</figcaption></figure><p>So yeah, understanding how this code behaves can be a challenging task, and similarly to any type of reverse engineering (well, more of a code review since the code is exposed), it can take a substantial amount of time to complete.</p><blockquote>What helped me analyzing malicious extensions was first creating an overview of the extension and what is being imported (as shown above), then try to follow the code logic and try to understand under what condition each part is executed and what is the purpose of each part.</blockquote><p>What else can be done? We can also look into how the extension behaves and to which website it initiates communication. More on this in the next section about dynamic analysis.</p><p>Since the code is very obscure, as shown and analyzing it will take a significant portion of time, I decided to move on from this and just give you the outlines of how I would go about it.</p><p>So, as mentioned, the first thing I&#39;ll do is to look at the manifest file. This is the “order of execution”. Then I&#39;ll look into the action and permission section, ill see what is being executed, afterwards I will check the content script and the service worker script. When going through the code, I would try to create an overview of the layout and how it works. My aim is not necessarily to understand every action the code takes at this stage, but mostly to try to understand how the code behaves, what is loaded, and when things are being executed and under what conditions.<br>Then I want to check external URLs embedded in the code (I usually search for “http” / “ajax” / “fetch” / “//:” to identify URLs or web requests.<br>Usually, I collect all that information in a file (mostly in Obsidian to make things easier), and lastly, I try to understand specific functionalities in the code in more depth while trying to answer the question “ what does this function do and why is it necessary in the context of the extension?”</p><p>Usually, that question leads to a better understanding of how the extension works. If there are functionalities that I&#39;m a bit fuzzy about, I try to load them into an LLM model (most of the time, a local LLM model)</p><h3>Dynamic analysis</h3><p>Finally, we arrive at the dynamic analysis part.<br>This is usually the most interesting part, and unlike static analysis, some parts may be missing if the extension loads data from the internet or there is a weird request going on.</p><p>So, what will we be needing?</p><ul><li>knowledge about web requests</li><li>BurpSuite / Fiddler / ZAP <strong>or any other web proxy (don&#39;t forget to install the certificate)</strong></li><li>Postman / Insomnia/proxyman or any way to generate requests (wow, you are only using cURL? so tech savvy and edgy, just like a real hacker)</li><li>Wireshark / tcpdump /tshark</li></ul><p>Since the most common HTTP proxy is Burp Suite and the most common network listener is Wireshark, those are what I&#39;ll be using.<br>As for request creation, I&#39;ll be using Insomnia since I&#39;m more comfortable using it than Postman</p><p>Remember those URLs collected from the static analysis?<br>Yeah, we are going to open them in the browser.<br>Again, make sure it&#39;s an isolated environment, such as Windows Sandbox or VirtualBox. Connect the proxy to the browser (I suggest using FoxyProxy to switch the browser proxy faster or using the built-in Chromium browser in Burp Suite). Make sure you&#39;re not capturing the request, yet the requests are showing in the HTTP history tab, and open the URL.</p><p>Another way we can inspect requests generated from our browser is by clicking on the “F12” button or “Ctrl + shift + c”, then navigating to the network tab.</p><p>So after installing the extension, we can, in the network tab, make a call to a file from the extension to be executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHpmIzcJXvIuzItCzQidbg.png" /></figure><p>This file loads three large libraries (each with more than 2000 lines of obfuscated code). However, since we already analyzed the code, at this point in the investigation, we should have an understanding of what is being executed.</p><p>Remember, we saw the permission “ContextMenu” and as explained, it grants access to the right-click menu and allows modification.<br>So I triggered it by highlighting some text and right-clicking on it and then on the icon of the extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzudCQAsuwP8M5GjdvfYFw.png" /></figure><p>Capturing the requests in Burp Suite will allow us to investigate what is being sent to the server. In this particular extension, the flow of requests is as follows:</p><ul><li>a request with a parameter, and the parameter contains the data we want to talk about with the AI chat</li><li>Auth session attempt</li><li>a request that lists what the AI chat can and cannot do</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cSlkA2w_bzPSu4oHjdyh3g.png" /></figure><ul><li>a call for the manifest.json (essentially executing the entire extension)</li><li>An attempt to issue an auth token (repeat every few requests)</li></ul><p>Why is this important?<br>We can see that once the context menu is triggered, there are several requests which one of which executes the entire extension</p><h3>Conclusions</h3><p>The browser has become an integral part of day-to-day business, and the majority of the office work is conducted through it. And as such, we must be aware of and protect it. Malicious extensions are on the rise, as documented <a href="https://thehackernews.com/2025/06/malicious-browser-extensions-infect-722.html">here</a> and <a href="https://thehackernews.com/2025/03/researchers-expose-new-polymorphic.html">here</a>.</p><p>Since the threat becomes more widespread, it is important for security teams to hone the skills needed to address the issue and verify that the extension in front of them is benign.</p><p>The framework shown above is only one of many ways to go about it; that framework is manual and time-consuming, yet it can yield very precise results. However, I recently learned that there are automated tools that help with extension incident response, such as <a href="https://github.com/GuyEldad/ShadowExtension">ShadowExtension </a>by Guy Eldad</p><p>Hope you enjoyed 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38ebaf4b48d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diving deeper into process creation — dynamic analysis of a process creation]]></title>
            <link>https://medium.com/@galdadoun_92442/diving-deeper-into-process-creation-dynamic-analysis-of-a-process-creation-1d8d68bed1fc?source=rss-c86567b35c91------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d8d68bed1fc</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[process]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[soc]]></category>
            <dc:creator><![CDATA[Galdadoun]]></dc:creator>
            <pubDate>Mon, 14 Jul 2025 19:20:06 GMT</pubDate>
            <atom:updated>2025-07-14T19:20:06.023Z</atom:updated>
            <content:encoded><![CDATA[<h3>Diving deeper into process creation — dynamic analysis of a process creation</h3><p>In the previous <a href="https://medium.com/@galdadoun_92442/what-happens-once-you-double-click-on-an-exe-file-f98bd1771fa9">post</a>, we reviewed at a high level all the activities that take place when we ask the question, “What happens when a process is created?”</p><p>Let&#39;s refresh our memory:</p><ul><li>The current shell, for example explorer.exe, calls the function ShellExecute() (which can be found in the DLLshell32.dll) to open files based on their type.</li><li>ShellExecute() resolves the file type (for example.exe) → validate how the file should be executed according to the registry, and then execute it appropriately using theCreateProcess()function from kernel32.dll.</li><li>CreateProcess() reads the PE headers, loads dependencies, and sets up the environment (PEB and TEB structures in memory as well as loads the data to the process structure).</li><li>the CreateProcess() Also calls the function ntCreateUserProcess fromntdll.dll, which issues a <strong>syscall</strong> to transition the current process context to the kernel (ring 0) on behalf of the user.</li><li>The kernel stores the data in a structure calledSystem Service Descriptor Table<strong>(SSDT)</strong> which is used to dispatch the syscall address and invoke it.</li><li>After the syscall is invoked, the Kernel allocates space for theEPROCESSstructure, and within it, it allocates space for the ETHREAD structure</li><li>Execution begins at the entry point as defined in the PE header.</li></ul><p>Great, now that we are all up to speed, let&#39;s look at how those functions work as well as how those DLLs work. <br>To do so, we need to look into the following DLLs and understand how they work:</p><ul><li>Shell32.dll<br>Why? This file contains theShellExecute() and theShellExecuteEx()functions, which are used by GUI shells (e.g., explorer.exe) to launch files.</li><li>Kernel32.dll<br>Why? This file exposes high-level Win32 API functions like CreateProcess(), which are in use when a PEB and TEB are set in the user space.</li><li>NTdll.dll<br>Why? This is the lowest part in the user-mode, and it contains low-level NT functions such as NtCreateUserProcess() and ZwCreateUserProcess()as well as syscall and interesting routines</li><li>ntoskrnl.exe</li><li>Why? This is the kernel representation; it handles SSDT logic, as well as EPROCESS and ETHREAD structure creation</li></ul><p>Ok, so now we have defined our scope, we know why we are reversing those specific files and what function within them we are looking for, and we know the process that takes place when a file is executed, so we will likely be able to connect the dots.</p><p>But before actually reversing, in this specific article, let&#39;s try to view the artifacts that a process execution leaves on the host.<br>The obvious ones are event logs as well as prefetch files. However, let&#39;s verify if there is more to it using procmon.exe from the sysinternals suite<br>In the previous blog, I talked about a super simple process that only writes a file to the disk, and the data within the file is the famous string “hello world”. I created that very same script using Python, and with PyInstaller, I “compiled” the file to a binary.<br>The script itself:</p><pre>with open(r&quot;c:\tmp\hello.txt&quot;, &quot;w&quot;) as my_file:<br>    my_file.write(&quot;Hello world \n&quot;)<br>    my_file.close()</pre><p>As we can see, the script creates a file inc:\tmp\hello.txtand write to it the data “Hello world” and then close the file.<br>Executing the file may give us some clues as to what happens</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKdGH3g6nSUoOjZuj0AZQg.png" /><figcaption>The execution of a process from explorer.exe</figcaption></figure><p>If we filter for the explore.exe (which is the shell we are using) and we also add to that filter the file we created, we can see that the explore.exe start a process creation operation with the specified file and then we can see that the process is created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hlOR06ASmQw7NZ1erD6zUg.png" /><figcaption>The creation of a process</figcaption></figure><p>this goes along with how we analyzed the workflow of how a process is executed in windows, we first saw the shell (explore.exe) getting the parameter from the host, then a process is being created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjK4AlnRBls3zkE7ywjTcQ.png" /><figcaption>The stack of the process explore.exe when the executable has been executed</figcaption></figure><p>To analyze further, I filtered to only show the associated file based on path and checked both the process of explore.exe as well as the executable itself<br>I checked the “process execution” event and viewed the stack of the process during the time of execution. As we can see, the expected DLLs as well as the corresponding functions are loaded into memory.</p><p>So, what functions were loaded, and what do they mean?</p><pre>ntoskrnl.exe RtlQueryAtomInAtomTable + 0xa86<br>ntoskrnl.exe RtlFreeAnsiString + 0x84e<br>ntoskrnl.exe SeQueryServerSiloToken + 0x1a22<br>ntoskrnl.exe setjmpex + 0x92a8 <br>ntdll.dll NtCreateUserProcess + 0x14 <br>KERNELBASE.dll CreateProcessInternalW + 0x283a<br>KERNELBASE.dll CreateProcessW + 0x66<br>KERNEL32.DLL CreateProcessW + 0x54<br>windows.storage.dll STORAGE_CreateStorageItemFromShellItem_FullTrustCaller_ForPackage + 0x24a0<br>windows.storage.dll App_IsLFNAware + 0x86e<br>windows.storage.dll Global_WindowsStorage_csIconCache + 0x2845<br>windows.storage.dll CheckSmartScreenWithAltFile + 0x21f6<br>windows.storage.dll CheckSmartScreenWithAltFile + 0x2d1d<br>windows.storage.dll CheckSmartScreenWithAltFile + 0xa7d<br>windows.storage.dll CheckSmartScreenWithAltFile + 0x781<br>windows.storage.dll CheckSmartScreenWithAltFile + 0x2f7d<br>windows.storage.dll IsProcessAnExplorer + 0x45cb<br>windows.storage.dll IsProcessAnExplorer + 0x3f92<br>SHELL32.dll SHQueryUserNotificationState + 0x4b37<br>SHELL32.dll SHQueryUserNotificationState + 0x48ce<br>SHELL32.dll SHCreateDrvExtIcon + 0xb2a2<br>SHELL32.dll SHFormatDrive + 0x4f6a<br>SHELL32.dll Ordinal895 + 0x7034<br>SHELL32.dll Ordinal895 + 0x649d <br>shcore.dll Ordinal234 + 0x22a <br>KERNEL32.DLL BaseThreadInitThunk + 0x17<br>ntdll.dll RtlUserThreadStart + 0x2c</pre><p>Since it&#39;s a stack and stacks use LIFO (Last in first out), we need to read it from the bottom to the top, so the first file to be loaded is thentdll.dll which uses the functionRtlUserThreadStartbased on <a href="https://www.subrosacyber.com/en/blog/rtluserthreadstart">this</a>, the function responsible for creating a new thread on behalf of the user</p><p>Afterwards, we see that it has kernel32.dll been loaded with the function BaseThreadInitThunk However, it seems that this function is undocumented<br>So, without reversing it directly, we can&#39;t know what it does<br>not quite sure what the shcore.dllor theOrdinal234(or any other number that appears there) However, consulting with ChatGPT suggests it&#39;s a helper function.<br>afterwardskernel32.dllloaded SHFormatDrive, which, according to <a href="https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shformatdrive">MSDN</a>, opens the Shell’s Format dialog box.</p><p>Afterwards, Shell32 ran the function SHQueryUserNotificationState, which, according to MSDN, checks the state of the computer for the current user to determine whether sending a notification is appropriate.</p><p>I tried to find some information about windows.storage.dll, but mostly found queries about the DLL missing. I did query ChatGPT, and it turned out that it can be related to a specific namespace according to <a href="https://learn.microsoft.com/en-us/uwp/api/windows.storage">MSDN</a>, and as the name suggests, it provides access to file writing<br>However, its specific function seems to be related to “smartscreen”, which is a part of Windows Defender that triggers the pop-up that we see when we execute an app without a certificate. It is used to prevent malware execution.</p><p>Afterwards, we see kernel32 executes the function CreateProcessW (<a href="https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw">MSDN Docs </a>), then kernelbase.dll executes that function (CreateProcessW), and then kernelbase.dll executes CreateProcessInternalW<br>So if they are all the same function, why do we need them to run several times?<br>Well, the kernel32 execution is the execution through the Win32API (user mode), and the kernelbase.dll is the actual implementation of what the Win32API executes. and it calls the ntdll.dll to execute the lower level syscall on behalf of the user.</p><p>ntdll.dll is loaded again and executes NtCreateUserProcess which is an undocumented function of windows yet we know that ntdll switches the process from user mode to kernel mode so it can execute a syscall for creating the process and it seems that this is exactly what this function does because afterwards it loads ntoskrnl.exe which is the kernel representation.</p><p>ntoskrnl.exe loads several functions, and for obvious reasons, they are all undocumented. However, we can infer what those specific functions are doing based on our knowledge of the process (maybe at a higher level than what we wanted, but at least we can understand the logic behind it)</p><p>So it seems that first the kernel is setting the instruction base pointer to move to a specific address, which likely holds internal kernel logic for Windows process creation, then we can see that a silo token is issued which seems to be related to the act of isolating a process and lastly we see address space being freed which can be use to store the data of the process (possibly setting the EPROCESS structure) and I&#39;m not entirely sure what happens in the RtlQueryAtomInAtomTable functions, from what I gather atom table is a system wide table that is used to store strings, I tried to drill down with chatgpt but it thinks its not directly linked to the execution either.</p><p>So let&#39;s recap what happened in the process stack:</p><ul><li>ntdll ran and executed a function that creates a new thread.</li><li>kernel32.dll ran an undocumented function, which, by its name, seems to be associated with the thread created.</li><li>shell32.dll ran some helper functions</li><li>Then shell32.dll ran a function to open a shell dialog box and another function that checks if the user can be prompted with notifications</li><li>There are a few SmartScreen checks for that file</li><li>kernel32 executes the create process, and we can also see the API call as well as the actual logic that&#39;s stored in kernelbase.dll</li><li>ntdll loads an undocumented function that switches the process mode from user mode to kernel mode.</li><li>Kernel mode uses several internal logics to set the process,s including allocating space.</li></ul><h3>But why should I care as a SOC analyst or as an IR team member?</h3><p>Well.. because it&#39;s cool 😎<br>And because if you know how a process execution works, you may be able to detect some advanced malware that hijacks the process execution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d8d68bed1fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens once you double-click on an EXE file?]]></title>
            <link>https://medium.com/@galdadoun_92442/what-happens-once-you-double-click-on-an-exe-file-f98bd1771fa9?source=rss-c86567b35c91------2</link>
            <guid isPermaLink="false">https://medium.com/p/f98bd1771fa9</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[proceso-creativo]]></category>
            <dc:creator><![CDATA[Galdadoun]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 21:01:25 GMT</pubDate>
            <atom:updated>2025-07-02T21:01:25.098Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wondered what happens when you click on an EXE file?<br>A lot is going on between the file being clicked on and the magic of the file being executed.</p><p>Recently, I started to look into how the Windows OS works behind the scenes and get a better grip on Windows internals.<br>I started developing that fascination a while back when I started investigating malware, but never got to dive deeper into os internals.</p><p>So today is the day that I&#39;m starting to build up my knowledge and share it with the community.</p><p>Note that some things may not be accurate, and I&#39;ll do my best to fact-check them, but I&#39;m still learning about it.</p><p>So without further ado, let&#39;s dive into the interesting part.<br>What we need to know first are the following terms:</p><ul><li><strong>Windows API</strong><br>windows api is a collection of functions that was exposed by Microsoft to allow further development and interaction with the kernel.<br>The goal of the api is: <br>To abstract direct hardware access<br>To provide system services to application<br>To maintain compatibility between Windows versions<br>To offer a consistent programming interface for GUI, file system, memory, threading, and more</li><li><strong>Kernel Mode</strong><br>The kernel mode is the mode in which the OS itself is working; it has direct access to the hardware of the system and can manipulate hardware (write data to disk, move data in memory, generate a web request, and so on)<br>The most common software that runs in kernel mode is the operating system, as well as drivers.<br>Since the kernel mode is using the highest privileges on the host (ring 0), it cannot be accessed directly. To access its capabilities, the user needs to initiate a request to a DLL, which stores the address of a syscall, and that syscall is used to tell the kernel what operation to do<br>During the execution of a program, the CPU switches between user mode and kernel mode constantly</li><li><strong>User Mode<br></strong>User mode can be thought of as a sandbox in which the applications are executed<br>The user mode does not have direct access to the kernel functions and thus must utilize a syscall to access specific resources.</li><li><strong>Executable<br></strong>An executable or an exe file is a binary file that can be run on the host.<br> This file contains a set of instructions that the processor can read through and execute each line.</li><li><strong>Process<br></strong>A process is an organizational unit that acts as the extension of an executable in memory. <br>All processes have the following segments:<br>Code Segment — this is where the executable instructions are stored<br>Data Segment — contains global and static variables that can be accessed from any part of the program<br>Heap — a place to dynamically allocate memory<br>Stack — contains local variables, function parameters, and is used for handling function calls<br>Registers — small, fast storage location that resides directly within the CPU and are used to hold data temporarily during the execution of the program (including the program counter and stack pointer).<br>Each process has its own separate memory address space, meaning that each process is independent of other processes in the system. Since each process is isolated, when requesting data from a separate process, the process execution needs to be switched, and it takes a bit of computing time</li><li><strong>Thread<br></strong>A unit of execution within the process, each thread is responsible for a single operation. More threads allow a process to do more operations simultaneously. Each thread has its own register and stack but the rest of the resources are shared among the threads (including data segment, stack, and heap). <br>Note that the sharing of data within threads makes it more efficient, but a failed thread can corrupt a whole process.</li><li><strong>Syscall<br></strong>low-level functions used by user-mode programs to request services from the kernel (for example: file access, memory, processes).</li><li><strong>Handles<br></strong>An abstract reference (usually a number) used by a process to access system resources like files, threads, or registry keys. It doesn’t point to the object directly, but acts as a key to it. The OS manages the actual object in kernel space and maps the handle to it securely, allowing controlled access and permissions. In essence, a handle acts as a pointer, but it does not hold the value of the actual memory address; it holds an ID that references the object, and then the kernel itself figures out the ID by searching a memory structure called `EPROCESS`</li><li>Registry<br>The registry (hive) is a database that stores a lot of Windows and user-specific configuration. For example, we can set a configuration in the registry to open all MP4 files with VLC.</li><li>DLL<br>A DLL ( Dynamic Linked Library) is a type of file that stores functionalities that can be used by an application. this file is a “library” of functions that can do certain thing to help you speed up the process of development, for example you can use it to write a file but you don&#39;t have to reinvent the process of writing a file within the host since the function of writing a file already exist in a library</li></ul><p>So now that we are all up to speed, let&#39;s dive into what happens under the hood.</p><h3>What happens after you double-click on a file up until it opens?</h3><p>In short? a lot<br>I will try to keep it as straightforward as I can and break it down to steps.<br>For the sake of convenience, we will be running the file `app.exe` from the `c:\` path.<br>And the sole purpose of the app is to create a file on the `c:\` that is called “hello.txt”</p><h3>step 1</h3><p>So you double-click on the executable. What is happening now?<br>When an executable is double-clicked/executed via a shell (yes, the explorer.exe process is considered a shell since it’s a way to interact with the host, which runs inside your session).<br>The `explore.exe` does not launch the app directly; the `explorer.exe` calls a function from the `Shell32.dll` library. The function is `ShellExecute()`, which takes as an argument the value of the file we want to run (in this case, the `app.exe`) and then parses the name to check for the extension (which in this case is an `exe` file). The extension is then being checked on how it should be executed according to the registry hive.</p><h3>step 2</h3><p>So now that the computer knows to execute the exe file by spawning a process based on the instruction given in the registry, it calls a low level function, that function is the `CreateProcess()` function which located at the `kernel32.dll` which is one of the core building blocks for how the os switches between user and kernel mode. Note that the function does not assume the extension, so the extension must be supplied, and if no relative path was supplied, it will try to execute the file from the current directory</p><h3>Step 3</h3><p>So, what happens when the `createProcess()` function is executed?<br>`createProcess()` calls ntdll.dll to change the process mode from user to kernel mode.<br>Once the shell process (for example, explorer.exe) has changed ownership, it begins building a new child process by reading the program specified (in this case, `app.exe`). It verifies that the file is indeed a valid Windows program by checking its PE headers.</p><h3>Step 4</h3><p>Once the file has been verified as a legitimate executable, `kernel32.dll` (user mode functions) calls a function from ntdll.dll (lowest part of the user mode), that specific function is called `NtCreateProcessEx()`, which is a part of the NT api functionality. And it is used to create a process in memory.</p><h3>Step 5</h3><p>Let’s look at what `ntdll.dll` does.<br>The `ntdll.dll` switches the process from user mode to kernel mode<br>Once the process is in kernel mode, it uses a `syscall`, which is a special instruction that tells the CPU to execute something on behalf of the user. Once the syscall is initiated, the process moves to ring 0, which is the most privileged level in the OS and is usually associated with `ntoskrnl.exe`.<br>We know syscalls are special instructions given to the CPU to execute a command on behalf of the user. But how does the CPU know which syscall means what? And where are those instructions stored? So syscalls have a corresponding function in user mode (specifically in ntdll.dll)<br>and a table of them in the kernel mode can be found in the `System Service Descriptor Table (SSDT)` within the kernel mode.</p><blockquote>so this begs the question why hackers arent using syscall directly? and the short answer is, you cant use syscall from a high level langauge like C/C++<br>Furthermore the syscall number changes between versions and EDR solutions detect direct syscalls.</blockquote><h3>Step 6</h3><p>So now what? Well, a syscall was initiated and it landed on the SSDT, which uses the number passed from ntdll.dll to figure out which syscall it needs to provide to the kernel for invocation.</p><h3>Step 7</h3><p>Let’s dive into what a process creation in memory looks like<br>The CPU allocates memory for the process, which means that it reserves space in the RAM to match the size of the executable (and in the case that there is not enough RAM, it may resolve the issue using memory paging). and it is doing so by creating an `EPROCESS` structure in memory.<br>Then it creates a thread by using the `ETHREAD` structure.<br>Then, a unique ID is assigned to the process as well as to each thread in the process.</p><h3>Step 8</h3><p>Once the process has been created in memory, the functions build in memory a structure called `Process Environment Block (PEB)` which stores all kinds of runtime information such as the DLLs that the app is dependent upon, command line arguments, and more.<br>Then the process execution starts at the entry point of the program.</p><p>TL;DR|<br>explorer.exe is the GUI shell and part of the user session.</p><ul><li>It calls ShellExecute() (from shell32.dll) to open files based on type.</li><li>ShellExecute() resolves .exe → executes it using CreateProcess() from kernel32.dll.</li><li>CreateProcess() reads the PE headers, loads dependencies, and sets up the environment.</li><li>It calls into ntdll.dll, which makes a <strong>syscall</strong> to the kernel (ring 0).</li><li>The <strong>System Service Descriptor Table (SSDT)</strong> is used to dispatch the syscall.</li><li>Kernel allocates EPROCESS, ETHREADsets up the memory space and PEB/TEB.</li><li>Execution begins at the entry point.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f98bd1771fa9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>