<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>marcel.re</title>
    <link rel="self" type="application/atom+xml" href="https://marcel.re/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://marcel.re"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2024-12-30T22:00:00+01:00</updated>
    <id>https://marcel.re/atom.xml</id>
    <entry xml:lang="en">
        <title>Rust UEFI Runtime Driver</title>
        <published>2020-10-08T22:00:00+01:00</published>
        <updated>2024-12-30T22:00:00+01:00</updated>
        
        <author>
          <name>
            
              Marcel Meuter
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://marcel.re/articles/rust-uefi-runtime-driver/"/>
        <id>https://marcel.re/articles/rust-uefi-runtime-driver/</id>
        
        <content type="html" xml:base="https://marcel.re/articles/rust-uefi-runtime-driver/">&lt;h1 id=&quot;introduction&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#introduction&quot; aria-label=&quot;Anchor link for: introduction&quot;&gt;Introduction&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;In the last few months I&#x27;ve started working with Rust in the UEFI world, in order to write a hypervisor as a UEFI runtime driver for educational purposes.&lt;&#x2F;p&gt;
&lt;p&gt;At first, I evaluated &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-osdev&#x2F;uefi-rs&quot;&gt;uefi-rs&lt;&#x2F;a&gt; as a wrapper between UEFI interfaces and Rust. According to the developers, its main goal is to &quot;to provide safe and performant wrappers for UEFI interfaces, and allow developers to write idiomatic Rust code&quot;. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;phil-opp&quot;&gt;Philipp Oppermann&lt;&#x2F;a&gt;, the author of &lt;a href=&quot;https:&#x2F;&#x2F;os.phil-opp.com&#x2F;&quot;&gt;&quot;Writing an OS in Rust&quot;&lt;&#x2F;a&gt;, uses the library for example to create an experimental &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-osdev&#x2F;bootloader&#x2F;tree&#x2F;uefi&quot;&gt;x86 UEFI bootloader&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Unfortunately, I&#x27;ve quickly ran into the first problems, since the library in its current state does not cover all the interfaces and functionality needed for my purposes. As a result, I&#x27;ve decided to use &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;r-efi&#x2F;r-efi&quot;&gt;r-efi&lt;&#x2F;a&gt;, which provides all protocol constants and definitions of the &lt;a href=&quot;https:&#x2F;&#x2F;uefi.org&#x2F;sites&#x2F;default&#x2F;files&#x2F;resources&#x2F;UEFI_Spec_2_8_final.pdf&quot;&gt;UEFI Reference Specification&lt;&#x2F;a&gt; without any safe wrappers implemented in Rust.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;features&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#features&quot; aria-label=&quot;Anchor link for: features&quot;&gt;Features&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;Today I&#x27;ve written down my insights over the past months and created a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;rust-uefi-runtime-driver&quot;&gt;GitHub repository&lt;&#x2F;a&gt;, which serves as a foundation for UEFI runtime driver development in Rust. Its equipped with various useful features for developing and prototyping and aims to help getting started.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;cargo-configuration&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#cargo-configuration&quot; aria-label=&quot;Anchor link for: cargo-configuration&quot;&gt;Cargo configuration&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Before the release of &lt;code&gt;nightly 2020–07–15&lt;&#x2F;code&gt;, using &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-osdev&#x2F;cargo-xbuild&quot;&gt;&lt;code&gt;cargo xbuild&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; was the recommended way to cross compile the sysroot crates &lt;code&gt;core&lt;&#x2F;code&gt;, &lt;code&gt;compiler_builtins&lt;&#x2F;code&gt; and &lt;code&gt;alloc&lt;&#x2F;code&gt; for custom targets. Fortunately, Cargo by now supports &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nightly&#x2F;cargo&#x2F;reference&#x2F;unstable.html#build-std&quot;&gt;&lt;code&gt;build-std&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and as a result is able to cross compile the sysroot without any extra tools. Furthermore, we can remove &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;rlibc&quot;&gt;&lt;code&gt;rlibc&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; as a dependency, since &lt;code&gt;nightly 2020-09-30&lt;&#x2F;code&gt; allows to use &lt;code&gt;compiler_builtins&lt;&#x2F;code&gt; &lt;code&gt;mem&lt;&#x2F;code&gt; feature to provide the implementations of &lt;code&gt;memset&lt;&#x2F;code&gt;, &lt;code&gt;memcpy&lt;&#x2F;code&gt;, etc.&lt;&#x2F;p&gt;
&lt;p&gt;We can activate both of these features by creating a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;rust-uefi-runtime-driver&#x2F;blob&#x2F;master&#x2F;.cargo&#x2F;config&quot;&gt;&lt;code&gt;.cargo&#x2F;config.toml&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; in our project root file containing:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-yaml &quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;build&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;target = &amp;quot;x86_64-unknown-uefi&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;rustflags = [&amp;quot;-Z&amp;quot;, &amp;quot;pre-link-args=&#x2F;subsystem:efi_runtime_driver&amp;quot;]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;unstable&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;build-std = [&amp;quot;core&amp;quot;, &amp;quot;compiler_builtins&amp;quot;, &amp;quot;alloc&amp;quot;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;build-std-features = [&amp;quot;compiler-builtins-mem&amp;quot;]
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Furthermore, we set our build target to be &lt;code&gt;x86_64-unknown-uefi&lt;&#x2F;code&gt; and provide an additional argument to the linker, in order to create a UEFI runtime driver instead of an UEFI application.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;serial-port-logging&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#serial-port-logging&quot; aria-label=&quot;Anchor link for: serial-port-logging&quot;&gt;Serial port logging&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Using UEFIs &lt;code&gt;Simple Text Output Protocol&lt;&#x2F;code&gt; for logging is only viable for UEFI applications which operate before &lt;code&gt;ExitBootServices()&lt;&#x2F;code&gt; is called. Since we want our logger to work even after the boot services are not safe to call anymore, the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;rust-uefi-runtime-driver&#x2F;blob&#x2F;master&#x2F;src&#x2F;logger.rs&quot;&gt;custom logger&lt;&#x2F;a&gt; writes to a serial port (COM1, &lt;code&gt;0x3F8&lt;&#x2F;code&gt;) instead. As a result, we are able to use our logging macros such as &lt;code&gt;debug!&lt;&#x2F;code&gt; and &lt;code&gt;info!&lt;&#x2F;code&gt; even after the operating system is loaded.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;setup&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#setup&quot; aria-label=&quot;Anchor link for: setup&quot;&gt;Setup&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;building&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#building&quot; aria-label=&quot;Anchor link for: building&quot;&gt;Building&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Compiling our template project is as simple as building any other Rust project.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ cargo build
&lt;&#x2F;span&gt;&lt;span&gt;Finished dev [unoptimized + debuginfo] target(s) in 0.02s
&lt;&#x2F;span&gt;&lt;span&gt;$ file target&#x2F;x86_64-unknown-uefi&#x2F;debug&#x2F;rust-efi-runtime-driver.efi 
&lt;&#x2F;span&gt;&lt;span&gt;target&#x2F;x86_64-unknown-uefi&#x2F;debug&#x2F;rust-efi-runtime-driver.efi: PE32+ executable (EFI runtime driver) x86-64, for MS Windows
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As intended, we&#x27;ve successfully built a &lt;code&gt;PE32+ executable&lt;&#x2F;code&gt; containing a &lt;code&gt;EFI runtime driver&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;vmware&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#vmware&quot; aria-label=&quot;Anchor link for: vmware&quot;&gt;VMware&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;With the driver ready to go, we will update the VMware configuration of our guest machine to allow for proper debugging.&lt;&#x2F;p&gt;

    &lt;div class=&quot;hint&quot; position=&quot;left&quot;&gt;
        &lt;p&gt;VMware &lt;strong&gt;Workstation&lt;&#x2F;strong&gt; is required for UEFI support.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;

&lt;p&gt;To do so, we append the following to our &lt;code&gt;.vmx&lt;&#x2F;code&gt; configuration file.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;cfg&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-cfg &quot;&gt;&lt;code class=&quot;language-cfg&quot; data-lang=&quot;cfg&quot;&gt;&lt;span&gt;debugStub&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;listen&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;guest64 &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;TRUE&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;debugStub&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;listen&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;guest64&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;remote &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;TRUE&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;debugStub&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;hideBreakpoints &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;1&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The GDB-based guest debug stub while now await connections (local and remote) on port 8864.&lt;&#x2F;p&gt;
&lt;p&gt;In the repository, a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;rust-uefi-runtime-driver&#x2F;blob&#x2F;master&#x2F;create_disk.sh&quot;&gt;&lt;code&gt;create_disk.sh&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; script is provided to automatically create a &lt;code&gt;.vmdk&lt;&#x2F;code&gt; (Virtual Machine Disk) file containing the driver, which can then be mounted by the guest machine.&lt;&#x2F;p&gt;
&lt;p&gt;To now load the runtime driver, we select &lt;code&gt;Power On to firmware&lt;&#x2F;code&gt;, boot into an EFI shell and use the &lt;code&gt;load&lt;&#x2F;code&gt; command to load the driver.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Beware:&lt;&#x2F;strong&gt; If you built the driver as a debug build, loading the driver will freeze the machine until a debugger connects and breaks the waiting loop.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;windows&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#windows&quot; aria-label=&quot;Anchor link for: windows&quot;&gt;Windows&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Receiving serial port output for logging is incredibly useful, especially during the runtime of the operating system. In order to receive the serial port output on Windows after &lt;code&gt;ntoskrnl&lt;&#x2F;code&gt; has been initialized, we need to activate the &lt;code&gt;Debug mode&lt;&#x2F;code&gt; on our test machine by executing &lt;code&gt;msconfig&lt;&#x2F;code&gt; as shown below and rebooting the machine afterwards.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;marcel.re&#x2F;articles&#x2F;rust-uefi-runtime-driver&#x2F;.&#x2F;windows_debug_mode.png&quot; alt=&quot;Windows Advanced Boot Options&amp;quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;gdb-clion&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#gdb-clion&quot; aria-label=&quot;Anchor link for: gdb-clion&quot;&gt;GDB &amp;amp; CLion&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;By today&#x27;s standards, debugging with GDB on the command line is not as convenient as source-level debuggers in IDEs such as Visual Studio or CLion. Luckily, we can make use of CLions &lt;a href=&quot;https:&#x2F;&#x2F;www.jetbrains.com&#x2F;help&#x2F;clion&#x2F;remote-debug.html&quot;&gt;GDB Remote Debug&lt;&#x2F;a&gt; feature to debug our runtime driver and therefore be able to use advanced debugging features such as conditional breakpoints, Rust language support and built-in visualizers (strings, vectors and other standard types).&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;marcel.re&#x2F;articles&#x2F;rust-uefi-runtime-driver&#x2F;.&#x2F;clion_debug_configuration.png&quot; alt=&quot;CLion Debug Configuration&amp;quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;By creating a new debug configuration we can specify a remote target, containing the address of the host machine as well as the previously mentioned port 8864.&lt;&#x2F;p&gt;
&lt;p&gt;An additional step is needed to enable GDB to load the debug symbols of our runtime driver. At this point, the driver is already loaded in memory and stuck in the debug waiting loop. While GDB can load the debug symbols of our PE file out-of-the-box, it lacks information on where the respective sections are mapped in memory. The following code snippet is part of the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;rust-uefi-runtime-driver&#x2F;blob&#x2F;master&#x2F;load-symbols.py&quot;&gt;&lt;code&gt;load-symbols.py&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; script I&#x27;ve provided in the repository.&lt;&#x2F;p&gt;

    &lt;div class=&quot;hint&quot; position=&quot;left&quot;&gt;
        &lt;p&gt;Make sure to install &lt;strong&gt;pefile&lt;&#x2F;strong&gt; within the Python environment used by GDB.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;

&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span&gt;argv &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;gdb&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;string_to_argv&lt;&#x2F;span&gt;&lt;span&gt;(args)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Parse arguments.
&lt;&#x2F;span&gt;&lt;span&gt;address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;get_number&lt;&#x2F;span&gt;&lt;span&gt;(argv[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;])
&lt;&#x2F;span&gt;&lt;span&gt;path &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;get_string&lt;&#x2F;span&gt;&lt;span&gt;(argv[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;])
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#88c0d0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;{path}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span&gt;{address:02x}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Find the base address of the PE.
&lt;&#x2F;span&gt;&lt;span&gt;base_address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;0xfffffffffffff000
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;while &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;get_number&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;*(unsigned int *)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;format&lt;&#x2F;span&gt;&lt;span&gt;(base_address)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;!= &lt;&#x2F;span&gt;&lt;span&gt;pe_magic:
&lt;&#x2F;span&gt;&lt;span&gt;    base_address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;0x1000
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Print base address.
&lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#88c0d0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;Base (&lt;&#x2F;span&gt;&lt;span&gt;{path}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;): &lt;&#x2F;span&gt;&lt;span&gt;{base_address:02x}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Parse PE.
&lt;&#x2F;span&gt;&lt;span&gt;sections &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;{}
&lt;&#x2F;span&gt;&lt;span&gt;pe &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;pefile&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;PE&lt;&#x2F;span&gt;&lt;span&gt;(path)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;section &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;in &lt;&#x2F;span&gt;&lt;span&gt;pe&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;sections:
&lt;&#x2F;span&gt;&lt;span&gt;    name &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;section&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;Name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;decode&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;rstrip&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\x00&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;section&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;VirtualAddress &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;+ &lt;&#x2F;span&gt;&lt;span&gt;base_address
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;name[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;!= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&#x2F;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#88c0d0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;Section: &lt;&#x2F;span&gt;&lt;span&gt;{name}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span&gt;{address:02x}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;        sections[name] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span&gt;address
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Remove previous symbol file.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;try&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    gdb&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;execute&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;remove-symbol-file &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;{path}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;format&lt;&#x2F;span&gt;&lt;span&gt;(path&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;path))
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;except &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fbcbb;&quot;&gt;Exception &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;as &lt;&#x2F;span&gt;&lt;span&gt;_error:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;pass
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;# Add the symbol file.
&lt;&#x2F;span&gt;&lt;span&gt;gdb&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;execute&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;add-symbol-file &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;{path} {textaddr}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt; -s &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;{sections}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;format&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;    path&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;path&lt;&#x2F;span&gt;&lt;span style=&quot;color:#eceff4;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span&gt;textaddr&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;sections[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;.text&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#eceff4;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    sections&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39; -s &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;join&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39; &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;join&lt;&#x2F;span&gt;&lt;span&gt;((name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#eceff4;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;str&lt;&#x2F;span&gt;&lt;span&gt;(address))) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;for &lt;&#x2F;span&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#eceff4;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span&gt;address &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;in &lt;&#x2F;span&gt;&lt;span&gt;sections&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;items&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;name &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;!= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;#39;.text&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The approach is to take the current &lt;code&gt;rip&lt;&#x2F;code&gt; and iterate backwards until we find the PE file signature at the beginning of our driver. This works, since the &lt;code&gt;rip&lt;&#x2F;code&gt; currently points to the instructions of our waiting loop within the &lt;code&gt;.text&lt;&#x2F;code&gt; section. We parse the PE binary to recover the virtual addresses of the sections and add them to the previously calculated base address. The created mapping is then fed back into GDB to make use of the contained debugging information and allow for source-level debugging.&lt;&#x2F;p&gt;
&lt;p&gt;We create a custom GDB command called &lt;code&gt;dbg&lt;&#x2F;code&gt; to combine the needed commands into a single command. By storing the command in a file named &lt;code&gt;.gdbinit&lt;&#x2F;code&gt; at the root folder of the project, GDB is able to automatically import our new command during startup.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;cfg&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-cfg &quot;&gt;&lt;code class=&quot;language-cfg&quot; data-lang=&quot;cfg&quot;&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;define&lt;&#x2F;span&gt;&lt;span&gt; dbg
&lt;&#x2F;span&gt;&lt;span&gt;  source &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;load&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;symbols&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;py
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;  file
&lt;&#x2F;span&gt;&lt;span&gt;  load-symbols $rip &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;.&#x2F;target&#x2F;x86_64-unknown-uefi&#x2F;debug&#x2F;rust-efi-runtime-driver.efi&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  set &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fbcbb;&quot;&gt;GDB_ATTACHED &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;end
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notice how the command sets the the variable &lt;code&gt;GDB_ATTACHED&lt;&#x2F;code&gt; to &lt;code&gt;1&lt;&#x2F;code&gt; after loading the symbols, in order to break the waiting loop the driver is currently stuck in.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;debugger-showcase&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#debugger-showcase&quot; aria-label=&quot;Anchor link for: debugger-showcase&quot;&gt;Debugger Showcase&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;div style=&quot;width:100%;height:0px;position:relative;padding-bottom:56.250%;&quot;&gt;&lt;iframe src=&quot;https:&#x2F;&#x2F;streamable.com&#x2F;e&#x2F;ylz2w8?loop=0&quot; frameborder=&quot;0&quot; width=&quot;100%&quot; height=&quot;100%&quot; allowfullscreen style=&quot;width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden;&quot;&gt;&lt;&#x2F;iframe&gt;&lt;&#x2F;div&gt;
&lt;h1 id=&quot;future-work&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#future-work&quot; aria-label=&quot;Anchor link for: future-work&quot;&gt;Future Work&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;In the next weeks, I plan to finally polish my UEFI runtime driver + user mode library, which allows to read and write virtual and physical memory as well as execute kernel code from user mode. Eventually, I also hope to finish and release my UEFI hypervisor together with a user mode library comprising various Virtual Machine Introspection (VMI) related features. Both projects showcase various UEFI-related characteristics and features such as memory allocations in combination with Rust or UEFIs multi-processor protocol.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Connect Box CH7465LG: Unauthenticated Remote Code Execution (CVE-2019-13025)</title>
        <published>2019-10-01T18:00:00+01:00</published>
        <updated>2019-10-01T18:00:00+01:00</updated>
        
        <author>
          <name>
            
              Marcel Meuter
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://marcel.re/articles/connect-box-ch7465lg-rce/"/>
        <id>https://marcel.re/articles/connect-box-ch7465lg-rce/</id>
        
        <content type="html" xml:base="https://marcel.re/articles/connect-box-ch7465lg-rce/">&lt;h1 id=&quot;introduction&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#introduction&quot; aria-label=&quot;Anchor link for: introduction&quot;&gt;Introduction&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;The following work was conducted on the Connect Box &lt;code&gt;CH7465LG&lt;&#x2F;code&gt; with the firmware version &lt;code&gt;CH7465LG-NCIP-6.12.18.24-5p8-NOSH&lt;&#x2F;code&gt; running &lt;code&gt;Linux 3.12.14&lt;&#x2F;code&gt; on a Intel XScale CPU (armv6b). The device was supplied to me in February 2019 by &lt;a href=&quot;https:&#x2F;&#x2F;www.unitymedia.de&#x2F;&quot;&gt;Unitymedia&lt;&#x2F;a&gt; as the default cable modem for new customers.&lt;&#x2F;p&gt;
&lt;p&gt;According to Unitymedia itself there are currently about 1.8 million customers using the Connect Box alone in Germany. &lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; Since the Connect Box is also used by other ISPs such as KabelBW, UPC Austria and more the number of affected customers is even higher.&lt;&#x2F;p&gt;
&lt;p&gt;The device and firmware itself is produced by &lt;a href=&quot;https:&#x2F;&#x2F;www.compal.com&#x2F;&quot;&gt;Compal&lt;&#x2F;a&gt; and only branded by the different ISPs.&lt;&#x2F;p&gt;
&lt;p&gt;It is important to note, that the vulnerability listed below need access to the web interface of the cable modem. This can be achieved in two different ways:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Being a client in the local network of the device.&lt;&#x2F;li&gt;
&lt;li&gt;Accessing the web interface over the Internet via the remote maintenance feature.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;

    &lt;div class=&quot;hint&quot; position=&quot;left&quot;&gt;
        &lt;p&gt;&lt;strong&gt;Shodan&lt;&#x2F;strong&gt; is a search engine that lets you find specific types of devices, such as routers, which are connected to the internet by using a variety of filters.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;

&lt;p&gt;A quick search of devices with open ports revealing the web interface with the help of &lt;a href=&quot;https:&#x2F;&#x2F;shodan.io&quot;&gt;Shodan&lt;&#x2F;a&gt; shows several thousand affected devices. Not to mention that every single device is vulnerable if local access is available.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;remote-code-execution&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#remote-code-execution&quot; aria-label=&quot;Anchor link for: remote-code-execution&quot;&gt;Remote Code Execution&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;The web interfaces offers &lt;code&gt;ping&lt;&#x2F;code&gt; and &lt;code&gt;traceroute&lt;&#x2F;code&gt; functions to test the network connection to other hosts. Although the web interface is protected by a password, most of the APIs do not require any form of authentication.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;vulnerability&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#vulnerability&quot; aria-label=&quot;Anchor link for: vulnerability&quot;&gt;Vulnerability&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Internally the implementation on both functions builds upon calling the &lt;code&gt;ping&lt;&#x2F;code&gt; and &lt;code&gt;traceroute&lt;&#x2F;code&gt; binaries on the shell provided by the operating system. The input parameters are only verified on the client-side in the web interface but not correctly escaped or verified within API endpoint itself. Therefore the endpoint is vulnerable to command injection by manipulating the POST parameters sent to the endpoint by including an escape sequence as well as the desired command(s).&lt;&#x2F;p&gt;
&lt;h1 id=&quot;implementation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#implementation&quot; aria-label=&quot;Anchor link for: implementation&quot;&gt;Implementation&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;The ping and traceroute function both can be found in &lt;code&gt;libhttp_plugin.so&lt;&#x2F;code&gt;&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#2&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;  named &lt;code&gt;cbn_http_xml_start_pin&lt;&#x2F;code&gt; and  &lt;code&gt;cbn_http_xml_start_tracert&lt;&#x2F;code&gt;. I&#x27;ve attached the shared library for readers which may be interested in having a closer look on their own.&lt;&#x2F;p&gt;
&lt;p&gt;Furthermore I&#x27;m planning to release a more detailed post about the whole process of:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Finding the first vulnerability while examining the web interface.&lt;&#x2F;li&gt;
&lt;li&gt;Gaining remote code execution.&lt;&#x2F;li&gt;
&lt;li&gt;Dumping the firmware of the device.&lt;&#x2F;li&gt;
&lt;li&gt;Further analysis of the firmware and the discovery of more vulnerabilities.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Nevertheless, I would like to point out (even if it should be obvious) that it is essential to always escape and verify the user input arguments when executing commands on the shell. It&#x27;s also recommended to avoid invoking the shell in general by using &lt;code&gt;exec()&lt;&#x2F;code&gt; instead of  &lt;code&gt;system()&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;proof-of-concept&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#proof-of-concept&quot; aria-label=&quot;Anchor link for: proof-of-concept&quot;&gt;Proof of  Concept&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;A PoC to sent arbitrary commands to be executed on the shell of the device can be found in my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;CVE-2019-13025&quot;&gt;GitHub repository&lt;&#x2F;a&gt;. By doing so we can for example start a telnet server on the device and connect to the provided debug CLI.&lt;&#x2F;p&gt;
&lt;p&gt;{{&amp;lt; asciinema &quot;dKJ2wyz3PTgwU3IYIfDPmuXVi&quot; &amp;gt;}}&lt;&#x2F;p&gt;
&lt;h1 id=&quot;timeline&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#timeline&quot; aria-label=&quot;Anchor link for: timeline&quot;&gt;Timeline&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Date&lt;&#x2F;th&gt;&lt;th&gt;Event&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;2019-06-25&lt;&#x2F;td&gt;&lt;td&gt;First message to an employee from Liberty Global&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-06-26&lt;&#x2F;td&gt;&lt;td&gt;First response as well as transfer of my issue to a superior&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-06-28&lt;&#x2F;td&gt;&lt;td&gt;Submission of a written report to Liberty Global. Proposed date for full-disclosure is +90 days&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-06-28&lt;&#x2F;td&gt;&lt;td&gt;Submission of the CVE ID request (CVE-2019-13025)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-09-22&lt;&#x2F;td&gt;&lt;td&gt;I noticed an automatic firmware update (&lt;code&gt;CH7465LG-NCIP-6.12.18.25-2p6-NOSH&lt;&#x2F;code&gt;) on my device, which patches the vulnerability&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-09-25&lt;&#x2F;td&gt;&lt;td&gt;Originally planned date for full-disclosure (90-day deadline) of the vulnerabilities&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-10-01&lt;&#x2F;td&gt;&lt;td&gt;Publication of this article and the GitHub Repository. Contacted CVE team in order to release the CVE entry to the public&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;2019-10-02&lt;&#x2F;td&gt;&lt;td&gt;German news portals report about the found vulnerabilities &lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#3&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; and publish a statement by Unitymedia, stating that 95% of the affected 2.2 million devices deployed by Unitymedia have been patched&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h1 id=&quot;references&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#references&quot; aria-label=&quot;Anchor link for: references&quot;&gt;References&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;1&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;newsroom.unitymedia.de&#x2F;neuigkeiten&#x2F;cpe-swap-unitymedia-tauscht-alte-hardware-bei-300-000-kunden-gegen-die-connect-box-aus&#x2F;&quot;&gt;Gezielter Austausch bei 300.000 Kunden: Connect Box ersetzt technisch veraltete Router&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;2&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;mega.nz&#x2F;#!LG51iQ7J!VwPN1O6UakvP3HlMs-JWa6XiNGyIxPn7G1bdbIQRXP4&quot;&gt;libhttp_plugin.so&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;3&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;3&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.heise.de&#x2F;security&#x2F;meldung&#x2F;Unitymedia-Fatale-Sicherheitsluecke-in-Millionen-Routern-4544886.html&quot;&gt; Unitymedia: Fatale Sicherheitslücke in Millionen Routern&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>VAC3 Modules Dumper Linux</title>
        <published>2018-09-17T18:00:00+01:00</published>
        <updated>2018-09-17T18:00:00+01:00</updated>
        
        <author>
          <name>
            
              Marcel Meuter
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://marcel.re/articles/vac3-modules-dumper-linux/"/>
        <id>https://marcel.re/articles/vac3-modules-dumper-linux/</id>
        
        <content type="html" xml:base="https://marcel.re/articles/vac3-modules-dumper-linux/">&lt;p&gt;I just released a VAC3 module dumper for Linux on &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;x1tan&#x2F;vac3-dumper&quot;&gt;Github&lt;&#x2F;a&gt; (with pre-compiled binary).&lt;&#x2F;p&gt;
&lt;p&gt;Additionally I uploaded the &lt;a href=&quot;https:&#x2F;&#x2F;mega.nz&#x2F;#!aXgngSoD!FaCZ1fUdc61tkjPvqx1Sttp98YW20sAc6_AyD7XSazw&quot;&gt;six modules&lt;&#x2F;a&gt; I dumped at the end of August in case anyone wants to do some analysis himself. Furthermore I&#x27;m planing to post some more in-depth analysis of the respective modules soon.&lt;&#x2F;p&gt;
&lt;p&gt;While I want to start a new post series on this blog soon, I am not quite sure yet about which topic. Currently I am thinking about building an VAC3 emulation system or working on a self-made Linux anti-cheat to demonstrate and explain some well-known (and not so well-known) techniques used in modern anti-cheats.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Path of Exile Bot</title>
        <published>2018-07-09T18:00:00+01:00</published>
        <updated>2018-07-09T18:00:00+01:00</updated>
        
        <author>
          <name>
            
              Marcel Meuter
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://marcel.re/articles/path-of-exile-bot/"/>
        <id>https://marcel.re/articles/path-of-exile-bot/</id>
        
        <content type="html" xml:base="https://marcel.re/articles/path-of-exile-bot/">&lt;p&gt;I uploaded a little showcase video to show the current state of my Path of Exile bot named &lt;strong&gt;Pathil&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Current Features:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Dynamic Pathfinding&lt;&#x2F;li&gt;
&lt;li&gt;Basic Combat Routine (spells, buffs, flasks, reviving)&lt;&#x2F;li&gt;
&lt;li&gt;Basic Loot Filter (only loots specified items)&lt;&#x2F;li&gt;
&lt;li&gt;Automatic Map Runs (runs new maps from the hideout in a loop)&lt;&#x2F;li&gt;
&lt;li&gt;User Interface In-game (basic settings in different windows rendered in-game)&lt;&#x2F;li&gt;
&lt;li&gt;Fully Background Compatible (does not need an active window at all)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Hopefully I will be able to finish the basic functionality left as for example customized combat routines and improved inventory and looting soon.&lt;&#x2F;p&gt;
&lt;p&gt;The video shows the work of one week which included a complete rewrite from the first version which was implemented in Rust and fully external (out of process).&lt;&#x2F;p&gt;
&lt;div style=&quot;width:100%;height:0px;position:relative;padding-bottom:56.250%;&quot;&gt;&lt;iframe src=&quot;https:&#x2F;&#x2F;streamable.com&#x2F;s&#x2F;8n80q&#x2F;lwnwai&quot; frameborder=&quot;0&quot; width=&quot;100%&quot; height=&quot;100%&quot; allowfullscreen style=&quot;width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden;&quot;&gt;&lt;&#x2F;iframe&gt;&lt;&#x2F;div&gt;
&lt;p&gt;Since I wanted to support background botting and multiple game clients on one machine as well was some other features I decided to go internal and rewrite the bot in C++.&lt;&#x2F;p&gt;
&lt;p&gt;Currently I am working on reversing the new anti cheat deployed in late June. It was deployed to finally fight against PoEHud and other tools.&lt;&#x2F;p&gt;
&lt;p&gt;It is not always active but can be armed at any point. Usually when a new league or season starts. The anti cheat modules get streamed and manually map during runtime to prevent static analysis of the anti cheat  (if you only have the game client to your hands).&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
