<?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 Oğuzhan Yıldırım on Medium]]></title>
        <description><![CDATA[Stories by Oğuzhan Yıldırım on Medium]]></description>
        <link>https://medium.com/@oguzhan200318?source=rss-ede7a44dcd9e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ghqLIlp5nfgW9MUb</url>
            <title>Stories by Oğuzhan Yıldırım on Medium</title>
            <link>https://medium.com/@oguzhan200318?source=rss-ede7a44dcd9e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:52:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oguzhan200318/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[Where Is the Persistence? Examining the DarkCore RAT Statically and Dynamically]]></title>
            <link>https://medium.com/@oguzhan200318/where-is-the-persistence-examining-the-darkcore-rat-statically-and-dynamically-f83175dfc1f5?source=rss-ede7a44dcd9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f83175dfc1f5</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[dnacybersolutions]]></category>
            <dc:creator><![CDATA[Oğuzhan Yıldırım]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 16:21:00 GMT</pubDate>
            <atom:updated>2026-11-09T16:21:00.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxJb_8lGjKP9HmUPlkFV2g.png" /></figure><h3>Introduction</h3><p>The static analysis I did using the REA (Reverse Engineer Anything) repo on GitHub said “this sample adds itself to the Startup folder as a shortcut.” I ran the sample (dynamic analysis); it connected to the C2 and wrote files to disk, but it created neither a Run entry nor a shortcut. I then ran it as administrator, but the result still didn’t change. This blog post is the story of my search for the reason behind this discrepancy and of the analysis process itself.</p><p>The sample examined is a 64-bit RAT/backdoor client written in native C++, and it identifies itself as DarkCore. By the end of the post you will see:</p><p>- How I used a debugger to trace why a capability found in static analysis was not used at runtime<br>- The anti-debug checks hidden inside a TLS callback and an rdtscp timing trap<br>- How the difference between “the code can do this” and “the code did this” changes an analysis report</p><h3>Static Analysis: What to Expect?</h3><p>I did the static analysis using REA and Ghidra. The file is unpacked (entropy 6.48), unsigned, PE32+ x64. The really interesting part was the configuration: the builder patches an encrypted config into the .data2 section. The key sits inside .data, and the decryption routine (XOR + rotate) can be decompiled directly. Decrypting the config statically yielded the following:</p><p>- C2: 2.27.4.184:49812 (TCP)<br>- Mutex: Mtx_PmYU1EfxDG<br>- Persistence: a ShellExperienceHost value under HKCU Run, an OneDrive.lnk with the description “Microsoft OneDrive” in the Startup folder, plus a scheduled task</p><p>In Ghidra I found the function that creates OneDrive.lnk (IShellLink + SHGetFolderPathW(CSIDL_STARTUP)), and the flag in the config was 2, i.e. it appeared “active.” The flags for the anti-debug and anti-VM checks, however, were 0.</p><p>So when I saw these, my expectation was: when run, I should see a Run value or a shortcut.</p><h3>Lab Setup</h3><p>Since I was going to run a RAT with a live C2 address and a file-encryption path, isolation was non-negotiable:</p><p>- VirtualBox is installed on an Ubuntu host. Inside this VirtualBox there is a Windows 10 VM with FLARE-VM installed.<br>- Network is Host-only: the VM has no internet access, and on the host side traffic arriving at the vboxnet0 interface is blocked by the firewall.<br>- Defender is off, and there is a clean snapshot taken before the sample was run; I revert to this snapshot before every attempt.<br>- I did not upload the sample to any public sandbox; this could have alerted the C2 and the operator.</p><p>Tools: FakeNet-NG to catch the C2 traffic locally, Process Monitor for file and registry events, Process Explorer for process details, x64dbg for code-level tracing, and Ghidra. (FLARE-VM also includes these internally.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LB0YJCbtogpdO9eGmX39Cg.png" /><figcaption>FakeNet-NG answered the C2 traffic inside a Host-only FLARE-VM.</figcaption></figure><h3>First Run: What Happened, What Didn’t</h3><p>Here is what happened after I ran the sample:</p><p>- Network: it connected directly to 2.27.4.184:49812 without making a DNS query. On each connection it first sends 32 bytes, FakeNet reflects the same 32 bytes back, the sample sends another 32 bytes and closes the connection. The first 32 bytes were different on every connection, like a random handshake nonce. It retried roughly every 20–30 seconds.<br>- Disk: it dropped three small files named .wctg, .wctt_ok and .wctt_paths in its own folder, and a wctk.dat under %TEMP% containing only the text “WinMain enter.”</p><p>What didn’t happen: a Run value, OneDrive.lnk, a scheduled task. The sample didn’t exit; on the contrary, it kept trying to connect to the C2 in the background.</p><p>The first thing that came to mind was “it needs to run with administrator privileges.” I reverted to the snapshot and ran it again with Run as administrator. The result was the same: in the HKCU and HKLM Run keys only legitimate entries, the Startup folders empty, and among the tasks only Microsoft’s own OneDrive tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Ta_VzqJG0ECLxu1K9Q4rg.png" /><figcaption>Each connection: 32 random bytes out, FakeNet’s echo back, 32 more bytes, then close.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*dOyaB9TsG-7xf1FifpfxSg.png" /><figcaption>FakeNet-NG log: the sample (PID 5844) connects to 2.27.4.184:49812 and sends 32 bytes.</figcaption></figure><h3>Following the clues</h3><blockquote><strong>1. The Vanishing Files</strong></blockquote><p>The .wct* files I saw in Explorer on the first run were not listed by dir in PowerShell on the second run. dir -Force and attrib gave the answer:</p><p>```<br>Mode Length Name attrib<br>-a-hs- 8 .wctg A S H<br>-a-hs- 6 .wctt_ok A S H<br>-a-hs- 39 .wctt_paths A S H<br>```</p><p>The sample creates its marker files as Hidden + System. This combination hides the files in Explorer even when “show hidden files” is on; I had been able to see them on the first run because FLARE-VM also shows protected system files. Inside .wctt_ok was WCT_OK, in .wctt_paths the sample’s own path, and in .wctg 8 bytes: 00 36 C2 35 00 00 00 00.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*FRONEf53Zp7lyeNlNhoE2A.png" /><figcaption>dir -Force and attrib: the markers are Hidden + System.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*W2AhKtsKGTdBJxpEmHAWSg.png" /><figcaption>Format-Hex of the three markers: the 8-byte ID, WCT_OK and the sample’s own path.</figcaption></figure><blockquote><strong>2. A Fake CLSID</strong></blockquote><p>Procmon’s Tools → Registry Summary screen gave results much faster than scrolling through thousands of events one by one. For example, two of the three registry writes it made were here:</p><p>```<br>HKCU\Software\Classes\CLSID\{90DDBCAF-8162–1E5B-3578–190ADB384401}<br> p REG_SZ C:\Users\&lt;user&gt;\Downloads\sample.exe<br> g REG_BINARY 0036C23500000000<br>```</p><p>This doesn’t look like a COM registration: there is no InprocServer32 subkey. The sample uses a fake CLSID as a state record: p is its own path, and g is the same 8 bytes as in the .wctg file.</p><p>g was identical across two separate runs even though the snapshot was reverted in between. So it is not a time-dependent value but a machine-bound bot ID. My first guess was the disk serial number; cmd /c vol C: returned 66B7-DF2B, and that idea fell apart.</p><p>Procmon’s File Summary showed one more thing: the sample looks for .wctg / .wctt_ok next to the exes of the running tools and in every folder under AppData, and on the running exes it also checks for an alternate data stream named :$FortKnox. It seemed to be looking for a previously installed copy of itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jpNdzMt_5jB11GlYaln1oQ.png" /><figcaption>Procmon Registry Summary with write counts on the fake CLSID values g and p.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*nIx5kbsG_0Gir1Zctrx3ag.png" /><figcaption>The state record: p is the sample’s path, g the 8-byte host ID.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N_svh8qP_vJXbXzLMFlLAw.png" /><figcaption>Procmon File Summary: probes for .wctg, .wctt_ok and :$FortKnox next to running tools.</figcaption></figure><blockquote><strong>3. Opening The Debugger and The TLS Callback Surprise</strong></blockquote><p>When I ran the sample in x64dbg, the first stop was a TLS callback rather than the EntryPoint. TLS callbacks run before main and are a popular hiding spot for anti-debug checks. This was one of those:</p><p>```<br>mov rax, gs:[60] ; PEB<br>mov cl, [rax+2] ; PEB.BeingDebugged<br>setne bl ; bit 1<br>test byte [rax+BC], 70 ; PEB.NtGlobalFlag -&gt; bit 2<br>call GetThreadContext ; Dr0-Dr3 populated? -&gt; bit 4<br>rdtscp ; t1<br>rdtscp ; t2<br>cmp rax, 16E360 ; t2 — t1 &gt; 1,500,000 cycles? -&gt; bit 8<br>```</p><p>rdtscp reads the processor’s time counter. In normal execution, dozens of cycles passed between the two reads. I, however, pressed F8 and stopped between the two rdtscp instructions and fell into the trap: the difference came out as 0x231E114947, i.e. roughly 150 billion cycles, 100,000 times the threshold. Normally the sample would set the “I’m being watched” bit here.</p><p>But here’s the interesting part: the TLS callback computes this mask and returns without saving it anywhere (call → add rsp,28 → ret). The checks exist in the code and run, but in this build their result is not used. This is consistent with the “anti-analysis flags 0” finding from static analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_l9k8lFY2R43uQ3tNps5w.png" /><figcaption>Four checks build a bit mask, and the callback throws the result away.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_RRfNpIxHMawlV_8b9fAkA.png" /><figcaption>x64dbg stops in TLS Callback 1 before the entry point.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4na_awJij1M0ZhE-OStUHg.png" /><figcaption>x64dbg registers after the second RDTSCP, with RAX holding a large cycle difference.</figcaption></figure><blockquote><strong>4. Working backward from the registry write</strong></blockquote><p>I set a breakpoint on kernelbase.RegSetValueExW. At the first stop the arguments are read per the Windows x64 calling convention: RCX the key handle, RDX the value name, R9 the type (1 = REG_SZ, 3 = REG_BINARY), [rsp+28] the data. The two stops were the p and g writes.</p><p>The really valuable thing was the Call Stack tab:</p><p>```<br>__scrt_common_main_seh -&gt; WinMain (FUN_14002e9b8)<br> -&gt; FUN_14000c86c<br> -&gt; FUN_1400235e4 ; function that writes the state record<br> -&gt; RegSetValueExW<br>```</p><p>Following this chain upward in Ghidra, the following structure appeared in WinMain:</p><p>```<br>GetModuleFileNameW(NULL, path, 0x104); // p<br>id = FUN_14000e57c(); // g (bot ID)<br>…<br>FUN_14000c86c(path, id, …); // state record<br>```</p><p>I noticed that this block had an else branch. So what was in the if branch?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OiveueGpRfU-sc_D2DW_6A.png" /><figcaption>From one RegSetValueExW breakpoint back to WinMain.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oF3rN4BSm1FW4RofjfN8Ew.png" /><figcaption>x64dbg Call Stack at the RegSetValueExW breakpoint.</figcaption></figure><h3>The Solution: A One-Byte Decision</h3><p>When I looked in Ghidra at the code that jumps to the start of the else branch, I saw that the decision depended on a single byte:</p><p>```<br>14002f0f7 TEST R15B, R15B<br>14002f0fa JNZ LAB_14002f8ed ; R15B != 0 -&gt; if branch: installation and persistence<br>14002f100 … ; R15B == 0 -&gt; else branch: “already installed” path<br>```</p><p>The if branch holds the code that static analysis labeled the “installation” step: a routine related to svchost and the cleanup of the old value in the Run key with RegDeleteValueA. The else branch, on the other hand, contains everything I saw dynamically: the state record, the marker files, the search for an installed copy.</p><p>On every run — even as administrator or under an elevated debugger — the sample took the else branch. So the reason persistence was not created was not privileges but this check. The sample sees itself as an already-installed copy and skips the installation step.</p><p>Along the way, it turned out that a static label was also wrong. In static analysis, REA had named FUN_140022f20 the “installation check”; in the debugger I saw that it takes the bot ID as a parameter. The function creates shared-memory sections named Local\DCSI&lt;id&gt; and Local\DCSS&lt;id&gt;, checks whether the PID inside is alive, and waits if necessary. So it is actually a single-instance check that prevents more than one copy with the same ID from running on the same machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_n7UpPxkHBQCsSwK69L2g.png" /><figcaption>TEST R15B decides: every run took the installed-copy branch.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0ok6-uCC5VgWQ3ojChdRQ.png" /><figcaption>Ghidra listing and decompiler view of the R15B test and the else-branch.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eWyijTSLpho1060GlNUa-Q.png" /><figcaption>FUN_140022f20 receives the host ID in RCX and builds Local\DCSI / Local\DCSS names.</figcaption></figure><h3>Static and Dynamic Side By Side</h3><p>| What static analysis said | What happened on execution |<br>| — — | — — |<br>| C2 2.27.4.184:49812 | Confirmed: direct TCP without DNS, random 32-byte first message, retry roughly every 20–30 s |<br>| C2 thread starts ~8 s later | The first connection came ~71 s later |<br>| Run value, OneDrive.lnk (flag active), scheduled task | None created; the installation branch was never entered |<br>| .wctt_ok, .wctt_paths, .wctg markers | Confirmed; they are created as Hidden + System, .wctg holds the bot ID |<br>| COM hijack via CLSID\…\InprocServer32 | Not seen; the CLSID key written is a state record |<br>| FUN_140022f20 installation check | Corrected: single-instance check |<br>| Anti-debug and anti-VM off | True in practice: the TLS callback runs the checks but skips the result |</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgmYVSjfew4CaM4VGv7AgA.png" /><figcaption>What the static analysis said, and what the runs showed.</figcaption></figure><h3>Measuring the Evidence With FACE-EO</h3><p>In my reports I write behaviors using the FACE-EO (Nar, 2026) model. The model breaks a behavior into six components and records the evidence status of each one separately:</p><p>C (Context): Who ran it, with what privileges?</p><p>F (File): Which file? Hash, signature, threat intelligence.</p><p>A (Actions): Which actions, in what order?</p><p>Ei (Immediate effects): What changed immediately?</p><p>Ep (Persistent effects): What remained 60 s after the process ended?</p><p>O: Which component is Observed, Partial, Inferred, Missing or Conflicting?</p><p>Then a confidence score comes out: with weights Observed 1, Partial 0.5, Inferred 0.25, Missing 0, the average of the five components is IC(B). Its real benefit in this analysis was this: when a claim from static analysis conflicts with a dynamic observation, it forces you to record it as Conflicting instead of silently favoring one over the other.</p><p>Dynamic analysis changed the scores as follows:</p><p>| Behavior | Static only | Static + dynamic | What changed |<br>| — — | — — | — — | — — |<br>| B1: Installed-copy path (state record, markers) | 0.25 | 0.80 | C, A and Ei observed; Ep partial (the process never exited) |<br>| B2: C2 session | 0.25 | 0.60 | Connection and first messages seen; the protocol stayed at FakeNet’s reflection |<br>| B3: Encryption round | 0.15 | 0.15 | Not executed; the module is not in the sample |<br>| B4: Persistence (Run, LNK, task) | 0.25 (inside B1) | 0.30 | Static says “active,” dynamic says “never ran”: Conflicting |</p><p>In the static report, persistence was inside B1 as part of installation. The dynamic results required splitting it into a separate behavior object:</p><p>```<br>B4 Persistence: Run value, Startup\OneDrive.lnk, scheduled task<br>C = process that decides in the branch (standard and elevated) O(C) = Observed<br>F = hash, unsigned PE, no TI query O(F) = Partial<br>A = static: code decompiled, flag 0x1400992cf = 2<br> dynamic: TEST R15B,R15B at 0x14002F0F7 sent 4 of 4 runs<br> to the else branch O(A) = Conflicting<br>Ei = nothing was created O(Ei) = Missing<br>Ep = no trace after the runs O(Ep) = Missing<br>IC(B4) = (1 + 0.5 + 0 + 0 + 0) / 5 = 0.30<br>```</p><p>The model does not define a weight for Conflicting; I counted it as 0 and stated this explicitly in the report. B4’s low score does not mean “no persistence”: it means “the evidence on this is contradictory, and this is the place to look before deciding.” The remaining gaps are clear in order too: the threat-intelligence query (F), the state after the process closes (Ep), and what determines R15B (B4).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RlWv2dCRV-Yiwmo4VfMYPw.png" /></figure><h3>Lessons Learned</h3><p>“Can do” is not the same as “did.” Static analysis correctly found the OneDrive.lnk code and the active flag, but that is a capability. In an incident-response report, saying “this machine has persistence” and saying “this sample can set up persistence” lead to very different outcomes. Writing the report with the FACE-EO model, I marked this contradiction explicitly as “Conflicting”; neither of the two sources silently overrode the other.</p><p>A sandbox result could also have been misleading. This build would probably show network and file activity in a sandbox but not persistence. A “no persistence” verdict would understate what the code can do.</p><p>Mistakes are part of the process too. Things I did in this analysis and noted for next time:</p><p>- In Procmon, Include filters added to different columns combine with AND, and those in the same column with OR. When I added all the filters at once, the screen went blank.<br>- When Procmon held 22 million events in memory, it crashed on its own. Drop Filtered Events and a backing file on disk prevent this.<br>- I fell into the rdtscp trap myself by stepping through with F8. You need to get past timing checks with F9 or “Run to cursor.”<br>- At one point I did an RVA calculation by hand and got 0x43948 instead of 0x23948, then looked at an unrelated function in Ghidra and formed the hypothesis “the code changes while running.” The hashes coming out identical disproved this hypothesis. The sample.exe:$XXXXX value at the bottom of x64dbg is the RVA itself; you should use it instead of calculating by hand.</p><p>The breakpoint + Call Stack + Ghidra trio is very powerful. Instead of stepping from start to finish, stopping at the API I cared about (here RegSetValueExW) and going backward from the Call Stack led me to the decision point in WinMain within minutes.</p><h3>IOCs and MITRE ATT&amp;CK</h3><p>| Type | Value |<br>| — — | — — |<br>| SHA256 | 5160c6ca466626650a1bd5cb2918d756ed101a721bb31c4d7611c62e9427597f |<br>| C2 | 2.27.4.184:49812 (TCP) |<br>| Mutex | Mtx_PmYU1EfxDG |<br>| Registry (state record) | HKCU\Software\Classes\CLSID\{90DDBCAF-8162–1E5B-3578–190ADB384401} → p, g (GUID may vary per machine) |<br>| Files | Hidden + system .wctg, .wctt_ok, .wctt_paths (in the sample’s folder); %TEMP%\wctk.dat |<br>| Shared memory | Local\DCSI&lt;id&gt;, Local\DCSS&lt;id&gt; |<br>| NTFS ADS | :$FortKnox |<br>| Static persistence names (not seen in these runs) | Run ShellExperienceHost, Startup\OneDrive.lnk |</p><p>| Technique | Evidence |<br>| — — | — — |<br>| T1564.001 Hidden Files and Directories | Hidden + System marker files |<br>| T1112 Modify Registry | State record under a fake CLSID |<br>| T1622 Debugger Evasion | TLS callback: BeingDebugged, NtGlobalFlag, Dr0–Dr3 |<br>| T1497.003 Time Based Evasion | rdtscp difference &gt; 1,500,000 cycles |<br>| T1083 File and Directory Discovery | Searches for an installed copy and :$FortKnox |<br>| T1095 Non-Application Layer Protocol | C2 over raw TCP |<br>| T1547.001 Registry Run Keys / Startup Folder | Present in code, not triggered in these runs |</p><p>I am not sharing the sample file; it can be searched by its SHA256. All static and dynamic findings, the FACE-EO evaluation, and YARA rules are in a separate analysis report.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f83175dfc1f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>