<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://consumerrights.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fooooo</id>
	<title>Consumer Rights Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://consumerrights.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fooooo"/>
	<link rel="alternate" type="text/html" href="https://consumerrights.wiki/w/Special:Contributions/Fooooo"/>
	<updated>2026-04-30T00:55:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://consumerrights.wiki/index.php?title=Reverse_engineering_Bambu_Connect&amp;diff=6448</id>
		<title>Reverse engineering Bambu Connect</title>
		<link rel="alternate" type="text/html" href="https://consumerrights.wiki/index.php?title=Reverse_engineering_Bambu_Connect&amp;diff=6448"/>
		<updated>2025-01-29T01:12:05Z</updated>

		<summary type="html">&lt;p&gt;Fooooo: no longer obfuscated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;div style=&amp;quot;padding-left:1.6rem;margin-bottom:0.5rem;&amp;quot;&amp;gt;&#039;&#039;This is part of the [[Bambu Lab Authorization Control System]] article.&#039;&#039;&amp;lt;/div&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
Bambu Connect is an [[Help:Electron|Electron]] App with [[security through obscurity]], which makes it inherently insecure.&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{GuideNotice}}&lt;br /&gt;
The purpose of this guide is to demonstrate the trivial process of extracting the &#039;&#039;&amp;quot;private keys&amp;quot;&#039;&#039; used for communicating with Bambu devices to examine, and challenge, the technical basis for Bambu Lab&#039;s security justification of Bambu Connect.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Update (January 29, 2024)&#039;&#039;&#039;: Bambu Connect 1.1.3 is no longer obfuscated, you can skip all steps related to asarmor, asarfix, Ghidra and string deobfuscation.&lt;br /&gt;
&lt;br /&gt;
To read the main.js for further analysis or extracting the private key stored by Bambu in the app:&lt;br /&gt;
&lt;br /&gt;
#Use the MacOS .dmg file, not the exe. Finding the needed decryption code is easier in the .dmg&lt;br /&gt;
#Extract &#039;&#039;bambu-connect-beta-darwin-arm64-v1.0.4_4bb9cf0.dmg&#039;&#039;&amp;lt;ref&amp;gt;https://public-cdn.bblmw.com/upgrade/bambu-connect/bambu-connect-beta-darwin-arm64-v1.0.4_4bb9cf0.dmg&amp;lt;/ref&amp;gt;, in there you can find the files of the underlying Electron app in &amp;lt;code&amp;gt;Bambu Connect (Beta).app/Contents/Resources&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
#The app uses asarmor to prevent easy reading, the key is stored in the mach-o binary located here: &amp;lt;code&amp;gt;/Bambu Connect (Beta).app/Contents/Resources/app.asar.unpacked/.vite/build/main.node&amp;lt;/code&amp;gt; and can be extracted. Unpacking app.asar without fixing it first will result in an encrypted main.js file and 100 GB of decoy files generated, don&#039;t try it.&lt;br /&gt;
#Load main.node in Ghidra and Auto-Analyze it. Then search for the GetKey function, or press G and go to &amp;lt;code&amp;gt;0000b67e&amp;lt;/code&amp;gt;&amp;lt;ref&amp;gt;https://www.reddit.com/r/OrcaSlicer/comments/1i2t6l8/comment/m7tuf2i/&amp;lt;/ref&amp;gt;&lt;br /&gt;
#Write down the hex key. You will need to follow the previous steps to get the current key if the provided one does not work. As of 19 January 2025, they are:&lt;br /&gt;
##macOS: &amp;lt;code&amp;gt;B0AE6995063C191D2B404637FBC193AE10DAB86A6BC1B1DE67B5AEE6E03018A2&amp;lt;/code&amp;gt;&lt;br /&gt;
##Windows: &amp;lt;code&amp;gt;D8BCE831F1284E1993D98EE807101F10F27AFF4E30BD4B420E057D02B8E9BD1B&amp;lt;/code&amp;gt;&lt;br /&gt;
#Install the npm package &amp;lt;code&amp;gt;asarfix&amp;lt;/code&amp;gt; and use it to fix the archive: &amp;lt;code&amp;gt;npx asarfix app.asar -k &amp;lt;KEY&amp;gt; -o fixed.asar&amp;lt;/code&amp;gt;&lt;br /&gt;
#Now you can extract it in cleartext with  &amp;lt;code&amp;gt;npx asar extract fixed.asar src&amp;lt;/code&amp;gt;&lt;br /&gt;
#&amp;lt;code&amp;gt;./src/.vite/build/main.js&amp;lt;/code&amp;gt; is minified, use any JavaScript beautifier (for example &amp;lt;code&amp;gt;prettier&amp;lt;/code&amp;gt;) to make it better readable. Interesting user code including the private key is at the end of the file.&lt;br /&gt;
&lt;br /&gt;
===Extracting certs and private key===&lt;br /&gt;
The private key and certs are further obfuscated, to get cleartext you need to do: Encrypted string from cy() -&amp;gt; ure(string, key) -&amp;gt; RC4 decryption -&amp;gt;  decodeURIComponent() -&amp;gt; final string.&lt;br /&gt;
&lt;br /&gt;
Example Python reimplementation to extract the secrets, easy to run. Copy the content of t from function cy() in main.js and paste it here. After running, you have a private key from Bambu Lab.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import urllib.parse&lt;br /&gt;
&lt;br /&gt;
def cy():&lt;br /&gt;
    t = [&lt;br /&gt;
		# copy from main.js&lt;br /&gt;
	]&lt;br /&gt;
    return t&lt;br /&gt;
&lt;br /&gt;
def ure(t, e):&lt;br /&gt;
    # RC4 implementation&lt;br /&gt;
    r = list(range(256))&lt;br /&gt;
    n = 0&lt;br /&gt;
    s = &amp;quot;&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    # Key-scheduling algorithm (KSA)&lt;br /&gt;
    for o in range(256):&lt;br /&gt;
        n = (n + r[o] + ord(e[o % len(e)])) % 256&lt;br /&gt;
        r[o], r[n] = r[n], r[o]&lt;br /&gt;
    &lt;br /&gt;
    # Pseudo-random generation algorithm (PRGA)&lt;br /&gt;
    o = n = 0&lt;br /&gt;
    for byte in t:&lt;br /&gt;
        o = (o + 1) % 256&lt;br /&gt;
        n = (n + r[o]) % 256&lt;br /&gt;
        r[o], r[n] = r[n], r[o]&lt;br /&gt;
        k = r[(r[o] + r[n]) % 256]&lt;br /&gt;
        s += chr(byte ^ k)&lt;br /&gt;
    &lt;br /&gt;
    return s&lt;br /&gt;
&lt;br /&gt;
def lt(t, e):&lt;br /&gt;
    r = cy()&lt;br /&gt;
    n = t - 106&lt;br /&gt;
    s = r[n]&lt;br /&gt;
    s = ure(s, e)&lt;br /&gt;
    return urllib.parse.unquote(s)&lt;br /&gt;
&lt;br /&gt;
def extract_certs_and_key():&lt;br /&gt;
    try:&lt;br /&gt;
        result = {}&lt;br /&gt;
        result[&amp;quot;Are&amp;quot;] = lt(106, &amp;quot;1o9B&amp;quot;)&lt;br /&gt;
        result[&amp;quot;fre&amp;quot;] = lt(107, &amp;quot;FT2A&amp;quot;)&lt;br /&gt;
        result[&amp;quot;private_key&amp;quot;] = lt(108, &amp;quot;Tlj0&amp;quot;)&lt;br /&gt;
        result[&amp;quot;cert&amp;quot;] = lt(109, &amp;quot;NPub&amp;quot;)&lt;br /&gt;
        result[&amp;quot;crl&amp;quot;] = lt(110, &amp;quot;x077&amp;quot;)&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        print(f&amp;quot;Error extracting certs/key: {e}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    for key, value in result.items():&lt;br /&gt;
        print(f&amp;quot;{key}:\n{value}\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    extract_certs_and_key()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Purpose of the private key===&lt;br /&gt;
The private key is used to digitally sign critical operations, such as print jobs and G-code commands. The printer can validate whether received MQTT commands are signed by Bambu Connect using the app&#039;s public key, rejecting any unsigned or improperly signed commands.&lt;br /&gt;
&lt;br /&gt;
Bambu Lab&#039;s authorization control system that is meant to increase security is entirely built on the assumption that attackers do not have access to the private key and thus cannot create valid signatures.&lt;br /&gt;
&lt;br /&gt;
However, since the private key has already been leaked, third-party software can now send print jobs and G-code commands again, while risks or dangerous situations&amp;lt;ref&amp;gt;https://blog.bambulab.com/firmware-update-introducing-new-authorization-control-system-2/&amp;lt;/ref&amp;gt; are still not addressed by Bambu Lab.&lt;br /&gt;
&lt;br /&gt;
===Purpose of the certificates===&lt;br /&gt;
The private key corresponds to the public key contained in the app&#039;s certificate. This certificate is sent to the printer, allowing it to verify the authenticity of the digital signature using the public key.&lt;br /&gt;
&lt;br /&gt;
Bambu Connect continues to work after these certificates expire. Due to how they are used, it is also unlikely that it causes the printer to get &amp;quot;bricked&amp;quot;, but this needs to be proven through experiments or firmware analysis.&lt;br /&gt;
&lt;br /&gt;
===Additional security measures===&lt;br /&gt;
Bambu Connect also encrypts G-code commands and file paths of print operations using the printer&#039;s public key. This ensures that only the intended printer can decrypt the data, rather than all authenticated MQTT clients and the cloud, adding another layer of security.&lt;br /&gt;
&lt;br /&gt;
However, the potential security benefits are diminished because both the encrypted and plain text strings are sent at the same time, likely due to negligence or the need for backwards compatibility.&lt;br /&gt;
&lt;br /&gt;
Note that network traffic is encrypted via TLS regardless of this, ensuring that no middleman can decrypt it.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Bambu Lab]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Fooooo</name></author>
	</entry>
</feed>