<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gianluca Palma on Medium]]></title>
        <description><![CDATA[Stories by Gianluca Palma on Medium]]></description>
        <link>https://medium.com/@gianluca.palma?source=rss-d5c235ccbb7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XN_bwoaGk3UN1O_p3kL4IQ.jpeg</url>
            <title>Stories by Gianluca Palma on Medium</title>
            <link>https://medium.com/@gianluca.palma?source=rss-d5c235ccbb7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:30:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gianluca.palma/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Doom on a $7 Sonoff Wi-Fi relay (well… sort of)]]></title>
            <link>https://medium.com/@gianluca.palma/doom-on-a-7-sonoff-wi-fi-relay-well-sort-of-ce1c797aba18?source=rss-d5c235ccbb7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce1c797aba18</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[doom]]></category>
            <category><![CDATA[esp8266]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[home-automation]]></category>
            <dc:creator><![CDATA[Gianluca Palma]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 16:46:01 GMT</pubDate>
            <atom:updated>2026-10-14T14:21:17.061Z</atom:updated>
            <content:encoded><![CDATA[<h3>80 KB of RAM, one honest ”no”, and the engine I had to write instead</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pey_iJlETWyqQlDHjcw6ww.png" /><figcaption>Can it run Doom? Always.</figcaption></figure><p>If you have ever wondered whether a few-euro smart switch could run Doom, I can save you some time: <strong>the original Doom, no. A new engine that wears Doom’s clothes, yes.</strong> It runs on the relay itself, it is played from a browser, and it is still a perfectly working smart switch for your lamp.</p><p>This is the story of how that happened, what broke along the way, and what it taught me about squeezing a game into a chip that normally switches the bathroom light.</p><h3>The target: a Sonoff Basic</h3><p>The <strong>Sonoff Basic</strong> is a small box with a relay, 2.4 GHz Wi-Fi and a screw terminal. You put it in series with a load, and the load becomes remotely controllable. According to the manufacturer’s manual it handles up to 10 A / 2200 W. I saw it for about $7–9 at the shops I checked.</p><p>Mine has a PCB silk-screened <strong>Sonoff RF R2 POWER V1.0</strong>. Despite the &quot;RF&quot; in the name, this is the Wi-Fi-only revision (there is a separate model with a 433 MHz receiver, and it is not this one). Inside is an <strong>ESP8285</strong>: an ESP8266 with 1 MB of flash built into the chip. The programming pads (3V3, RX, TX, GND) are exposed, and the button and LED are already wired to GPIO pins. That makes it a wonderful hacking target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIyVTSJWpNhAuINWMh7gtw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfrkBgQWynHTwjSe9hCyRQ.jpeg" /><figcaption><strong>Sonoff RF R2 POWER V1.0 PCB</strong></figcaption></figure><p>It also has <strong>80 KB of data RAM</strong>. Keep that number in mind.</p><h3>The first answer was “no”</h3><p>I started the obvious way: look for an existing port. The honest picture was not encouraging:</p><ul><li>The original DOS Doom wants at least <strong>4 MB of RAM</strong>.</li><li>The ESP32 ports I found need an ESP32 with <strong>PSRAM</strong> (one of them asks for a 6 MB memory zone).</li><li>Even the lightest ports I could find for microcontrollers assume hundreds of KB of RAM and an external flash for the game data.</li></ul><p>My chip has 80 KB, and about 33 KB are left once Wi-Fi is on. No amount of “optimizing” turns that into a port of Doom’s engine. The chip simply does not have the memory.</p><p>So I changed the question: <strong>what is the most Doom-like thing that fits?</strong></p><h3>The trick: let the browser do everything that costs RAM</h3><p>The answer was a split of responsibilities:</p><ul><li>The <strong>Sonoff</strong> runs a small raycasting engine (the same principle as Wolfenstein 3D) and renders the 3D view.</li><li>The <strong>browser</strong> does everything else that would eat RAM: the menu, the status bar, the texts, the music and the sound effects.</li><li>The <strong>game data</strong> (textures, sprites, palette, lighting) is taken from the shareware doom1.wad by a Python script on your PC and baked into the firmware, where it lives in <strong>flash</strong> and is read directly from there.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIhUXGXgbdNsYoGFzbFm9Q.png" /><figcaption>Flowchart Engine</figcaption></figure><p>And to be clear about the obvious objection: this is <strong>not</strong> a video stream from a PC hiding somewhere. The pixels you see are really computed by the ESP8285 inside the relay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g0B054Xlwub1wsbX7AwIw.gif" /></figure><h3>Making a game fit in 33 KB</h3><p>A few decisions made the difference.</p><p><strong>No framebuffer.</strong> A 128 × 80 screen at 256 colors is 10 KB, which is a big slice of what I have. So the Sonoff renders <strong>16 columns at a time</strong> into a buffer of about 1.3 KB and sends each strip right away.</p><p><strong>Send only what changed.</strong> Floor and ceiling are a uniform color per row, so the browser draws them by itself. For every column the Sonoff only sends the part that differs: walls, imps and the weapon. In simulations with the real assets, a frame went from about 10 KB (standing in front of a wall) down to about 3 KB (open rooms).</p><p><strong>Textures straight from flash.</strong> The 64 × 64 wall textures and the sprites are stored column by column and read with pgm_read_byte, so they never occupy RAM.</p><p><strong>Doom’s own lighting.</strong> The script keeps 16 of the 32 light levels of Doom’s COLORMAP table and the engine picks one by distance, which is a big part of why it <em>feels</em> like Doom.</p><h3>Making it look like Doom</h3><p>Once the engine worked with made-up graphics, the real fun was making it feel right:</p><ul><li><strong>Real assets from the WAD</strong>: the imp, the pistol and the shotgun, the wall textures, the palette, and the red palettes that flash when you are hit.</li><li><strong>The status bar and the marine’s face</strong>, which looks around, gets bloodier at every hit, turns towards whoever attacked it, and eventually dies.</li><li><strong>The classic menu</strong>, with the blinking skull, drawn in the browser with the WAD’s own pixel font.</li><li><strong>Sound effects</strong> from the WAD (compressed to 4-bit ADPCM to save flash) and <strong>the E1M1 music</strong>, played by a small WebAudio synthesizer reading the original MUS scores. It is not a Sound Blaster, but the notes are right.</li><li><strong>Doors that rise</strong> like the originals, and imps that sleep until they see or hear you, then chase you and open doors by themselves.</li><li><strong>Cheats.</strong> Typing IDDQD or IDKFA pops up a message in the Doom font, signed by me, politely explaining that a relay cannot do that.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTVfaxIMAoJjn1XKJ3ai7A.gif" /><figcaption>Doors opening and the imp waking up</figcaption></figure><h3>The numbers</h3><p>These are measured on the real Sonoff, from the stats line on the page:</p><p>Frames per second about <strong>23.7</strong> Computing one frame about <strong>6.4 ms</strong> Sending one frame over Wi-Fi about <strong>28.8 ms</strong> Traffic about <strong>242 KB/s</strong> Free RAM while playing about <strong>33 KB</strong></p><p>The interesting line is the middle one. Computing a frame takes <strong>6 ms</strong>, and sending it takes almost five times longer. <strong>The Wi-Fi is the bottleneck, not the CPU.</strong> That is why compressing what goes over the air mattered more than any clever optimization of the renderer. My very first version ran at about 17 fps with 42 KB free; most of the improvement came from sending less data, not from calculating faster.</p><h3>Things that broke</h3><p>A project like this is mostly debugging, so here are the bugs I enjoyed the most.</p><p><strong>The Arduino IDE and my function signature.</strong> A function taking const Enemy &amp;e refused to compile with &quot;Enemy does not name a type&quot;, even though the type was clearly declared above. The reason: the Arduino IDE auto-generates function prototypes and puts them at the top of the sketch, <em>before</em> my struct. The fix was to pass an index instead of a reference.</p><p><strong>The mouse that “went crazy” near enemies.</strong> Turning with the mouse felt fine until imps got close, and then the view would spin. When imps are close, the Sonoff spends longer sending each frame and mouse messages pile up, then arrive all at once. The fix was to stop sending movements and send the <strong>total rotation</strong>: the Sonoff uses only the difference from the last value it saw and limits how far it turns per update, so a burst of messages can no longer become a sudden spin.</p><p><strong>The track that stayed silent for 20 seconds.</strong> The second music track (E1M2) starts with the channel volume at zero and fades in. My player read the volume only when a note <em>started</em>, so the first notes were created silent and stayed that way until new ones arrived. The fix was to apply volume changes to notes that are already playing.</p><p><strong>The firmware that outgrew the Wi-Fi updates.</strong> Updating over Wi-Fi needs a spare slot for the new firmware. Once the firmware reached about 565 KB (more than the roughly 500 KB available), updates over Wi-Fi stopped being possible, and every new version had to be flashed over serial with the button held.</p><h3>It is still a smart switch</h3><p>I did not want to lose the reason the device exists in the first place, so the same firmware is also a proper switch:</p><ul><li><strong>First boot</strong>: the Sonoff opens an open Wi-Fi hotspot with a setup page, where you enter your home Wi-Fi and an admin user and password. After the reboot every page asks for that login.</li><li><strong>Two buttons</strong> under the game: <strong>SWITCH</strong> turns the load on and off, and <strong>TOGGLE</strong> gives a <strong>30 ms</strong> pulse. The pulse is ended by a hardware timer, so it lasts 30 ms even while the Sonoff is busy drawing a frame.</li><li><strong>The physical button</strong> toggles the load, and holding it for 10 seconds does a factory reset.</li><li><strong>The load state survives a power cut.</strong></li><li><strong>A small HTTP API</strong> (/relay?cmd=on|off|toggle|pulse) for Home Assistant, Node-RED or a simple script.</li><li>When you shoot, the <strong>relay does not click</strong>, only the LED flashes. Otherwise every shot would switch your lamp off.</li></ul><p>One honest caveat: everything runs over <strong>plain HTTP</strong>, because the ESP8285 cannot reasonably do HTTPS. It is fine at home. Do not expose it to the Internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIGl_jgeDJA1JQDlphg4Jg.gif" /><figcaption>SWITCH and TOGGLE with the LED reacting</figcaption></figure><h3>What it is not</h3><p>To keep expectations honest: it is a <strong>single 16 × 16 map</strong>, all walls are the same height, floor and ceiling are uniform, and there is one enemy type. It is a Wolfenstein-style raycaster with the look of Doom, not Doom. You cannot save. I think that is a fair price for 80 KB.</p><h3>How it was built</h3><p>I built this in dialogue with <strong>Claude Opus 5.5</strong>: it wrote most of the code, and I ran it on the real Sonoff and reported what worked and what did not. That feedback loop (measure on the hardware, say what you see, fix, repeat) is what made it converge. Much of the game logic and the web page were also tested on a PC with simulated libraries, while the hardware-dependent parts (Wi-Fi, relay, button, hotspot) were tested on the device.</p><h3>Try it yourself</h3><p>The code is on GitHub:<strong> </strong><a href="https://github.com/piuppi/sonoff-doom"><strong>https://github.com/piuppi/sonoff-doom</strong></a></p><ul><li>It needs a Sonoff Basic with the Sonoff RF R2 POWER V1.0 PCB (check the silk-screen on your board before anything else), a 3.3 V USB-serial adapter and the Arduino IDE.</li><li><strong>The repository contains no Doom data.</strong> You bring your own shareware doom1.wad, and a script converts it on your PC for your personal use.</li><li><strong>Safety first</strong>: program the Sonoff only from the adapter’s 3.3 V, never connected to the mains, and put it back in its closed case before using it with a load.</li></ul><blockquote><strong>Screenshots and clips show the shareware version of Doom (© id Software), running on a Sonoff. This project is not affiliated with or endorsed by id Software or ITEAD.</strong></blockquote><p>If until yesterday you felt no need to buy a Sonoff, now you have a reason. Or at least a story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce1c797aba18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Engineering the Proscenic 850T Robot Vacuum]]></title>
            <link>https://infosecwriteups.com/reverse-engineering-the-proscenic-850t-robot-vacuum-576164bac97c?source=rss-d5c235ccbb7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/576164bac97c</guid>
            <category><![CDATA[iot-security]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[home-automation]]></category>
            <dc:creator><![CDATA[Gianluca Palma]]></dc:creator>
            <pubDate>Wed, 29 Apr 2026 05:06:56 GMT</pubDate>
            <atom:updated>2026-04-29T05:06:56.033Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I extracted the localKey with Frida, mapped the Tuya Data Points and built a local-control webapp for my robot vacuum</em></p><blockquote><em>My vacuum robot (</em>his name is Yoda!) <em>was driving me crazy. Every time I pressed a directional button from the App I had to wait for the current movement to complete before pressing another one. Real-time steering was impossible. I decided to take the problem apart.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPuH_qI0Ha0crYjBE0TDDQ.png" /></figure><p>What initially looked like a simple home automation project turned into a full <strong>Reverse Engineering Session</strong>: a rooted Android emulator, Frida, JNI method hooking, HTTPS traffic interception, and the discovery that behind the Proscenic brand lies the Tuya ecosystem, complete with hardcoded credentials baked into the app code.</p><blockquote>This article documents the whole journey: from the original frustration to a fully local control webapp, no cloud, no proprietary app required.</blockquote><h3><strong>1. The Problem: a Broken Virtual Remote</strong></h3><p>The Proscenic 850T is a mid-range robot vacuum with WiFi connectivity. The official app lets you control it remotely, set cleaning modes, schedule sessions, and use a virtual directional remote alongside the physical infrared remote.</p><p>The virtual remote’s problem is structural: every directional command (forward, backward, turn left, turn right) is processed synchronously by the robot. The app sends a command, waits for the robot to finish executing it, then unlocks the interface. The result is that to turn while moving forward, you have to wait for the robot to complete the current movement first.</p><p>For normal use this is bearable. For anyone who wants to steer the robot in real time through tight corridors or around obstacles, it’s completely unusable (<em>I’ll mount them on an ESP32-CAM soon</em><strong>).</strong></p><p>I actually opened a support ticket with Proscenic about this issue. Their reply was the usual:</p><blockquote><strong>“Thank you for choosing us, we’ll pass this along to the development team.”</strong></blockquote><blockquote><strong>…As of today, nothing has changed.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*lj5T4_mYZSSJGSPh-SjDvA.png" /><figcaption>It’s so annoying</figcaption></figure><p>But there was a second reason, perhaps more important: <strong>the Cloud.</strong> The Proscenic app requires an account, sends data to the company’s servers, and stops working if the internet connection drops. I wanted full local control , no dependency on third-party servers that could change their policies, deprecate my model, or simply disappear.</p><h3><strong>2. Under the Hood: It’s Tuya All the Way Down</strong></h3><p>The first surprise comes immediately when inspecting the app’s network traffic. All API calls go to <strong>a1.tuyaeu.com</strong> and <strong>appeu.proscenic.com</strong>. Proscenic uses Tuya as its IoT backend, a common pattern among smart device manufacturers in this price range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*by6Gyo54pl1tpxaVNr-f3A.png" /><figcaption>Burp Proxy Intercept</figcaption></figure><p>Tuya is a Chinese IoT platform that provides cloud infrastructure, SDKs and firmware for smart devices. Manufacturers like Proscenic buy a white-label solution, slap their brand on top, but everything underneath runs on Tuya.</p><p>This matters for two reasons:</p><ul><li><strong>There is already a mature ecosystem of tools for local control of Tuya devices, the most popular being TinyTuya</strong></li><li><strong>The local protocol uses AES-128 with a per-device key called the localKey</strong></li></ul><p>The catch is that Proscenic uses a separate Tuya OEM cloud, not the standard one. Proscenic devices don’t appear in the normal Tuya developer portal, and the app doesn’t use a Smart Life account. So we can’t retrieve the <strong>localKey</strong> through official channels, unless we disconnect the robot from the Proscenic app and re-pair it via Smart Life (which I didn’t want to do, since the Proscenic app offers more complete functionality, like generating a floor map during cleaning).</p><blockquote>So to use it locally, we need to extract the localKey from the app!!</blockquote><h3><strong>3. Setup: LDPlayer, </strong>Burp <strong>Suite, ADB and Frida</strong></h3><p>To reverse engineer the Android app on a Windows PC I used:</p><p><strong>• <em>LDPlayer 9</em></strong><em> — Android emulator with native root support</em></p><p><strong><em>• ADB (Android Debug Bridge) </em></strong><em>— to communicate with the emulator from Windows</em></p><p><strong><em>• Frida 17.8.3 </em></strong><em>— dynamic instrumentation framework</em></p><p><strong><em>• frida-server-17.8.3-android-x86_64</em></strong><em> — the Frida server running inside the emulator</em></p><ul><li><strong><em>Burp Suite </em></strong><em>— to intercept HTTPS traffic</em></li></ul><h4>3.1 LDPlayer Configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*hluSWRSEgClCaN9ept_Efg.png" /><figcaption>Your virtual Android friend LDPlayer</figcaption></figure><p>LDPlayer has a crucial feature: under Settings → Disk → System disk setting, selecting <strong>Writable</strong> mounts the system partition in read/write mode. This eliminates all the <strong>mount -o remount,rw /system</strong> headaches that emulators like BlueStacks cause.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*pB6JoF0LLZkUDLAa-f_G8g.png" /><figcaption>LDPLayer Disk Settings</figcaption></figure><p>With <strong>root enabled</strong>, pushing frida-server and installing the Burp Suite CA certificate become trivial operations.</p><blockquote><em>Let me know in the comments if you’d like a detailed step-by-step guide for these, if there’s enough interest I’ll write a dedicated article.</em></blockquote><h4>3.2 Frida: Client-Server Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*okksJHXhUdZd9K_KU7Ia8g.png" /><figcaption>Your best friend for inspecting Android Apps</figcaption></figure><p>Frida works in client-server mode: <strong>frida-server</strong> runs inside the Android emulator with root privileges and listens on <strong>port 27042</strong>. The client (frida-tools) runs on the Windows host and connects via ADB port forwarding:</p><pre>adb -s emulator-555X forward tcp:27042 tcp:27042</pre><p>Once connected, we can inspect and modify any process running on the emulator in real time, no need to modify or recompile the APK.</p><h3><strong>4. Extracting the localKey with Frida</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byGeeldUMWbf3qwP9S2Gvw.png" /><figcaption>Frida Setup</figcaption></figure><h4><strong>4.1 Class Enumeration</strong></h4><p>The first step is understanding the app’s internal structure. With Frida we can enumerate all Java classes loaded in memory by the Proscenic process:</p><pre>Java.perform(() =&gt; {<br>  Java.enumerateLoadedClassesSync()<br>    .filter(c =&gt; c.toLowerCase().includes(&#39;cipher&#39;) ||<br>                 c.toLowerCase().includes(&#39;encrypt&#39;) ||<br>                 c.toLowerCase().includes(&#39;secret&#39;) ||<br>                 c.toLowerCase().includes(&#39;aes&#39;))<br>    .forEach(c =&gt; console.log(c));<br>});</pre><p>The result immediately reveals the structure: <em>The app is built using the Tuya Smart App SDK, referencing the </em><strong><em>thingclips </em></strong><em>namespace in its source code due to </em><a href="https://developer.tuya.com/en/docs/app-development/migration_guide?id=Kci3zqm3wlcut"><em>Tuya&#39;s library restructuring</em></a><em>. At the same time, the app leverages Tuya’s OEM solutions to provide a fully customized, white-label smart home experience.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*tIHeMQ5YeaZcCPHCuc35OQ.png" /><figcaption>Thingclips Classes</figcaption></figure><p>Among the interesting classes:</p><ul><li><strong>com.thingclips.smart.sdk.bean.DeviceBean</strong></li></ul><h4>4.2 The Breakthrough: DeviceBean</h4><p>Instead of trying to intercept the encryption methods (which turn out to be implemented in native JNI code, difficult to hook), the most elegant solution is to read the already-decrypted data directly from the <strong>DeviceBean</strong> object in memory.</p><p>Inspecting the class fields:</p><pre>Java.perform(() =&gt; {<br>  const DeviceBean = Java.use(&#39;com.thingclips.smart.sdk.bean.DeviceBean&#39;);<br>  DeviceBean.class.getDeclaredFields()<br>    .forEach(f =&gt; console.log(f.toString()));<br>});</pre><p>We find exactly what we’re looking for:</p><pre>public java.lang.String com.thingclips.smart.sdk.bean.DeviceBean.localKey<br>public java.lang.String com.thingclips.smart.sdk.bean.DeviceBean.devId<br>private java.lang.String com.thingclips.smart.sdk.bean.DeviceBean.ip</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osTBnMZqLmBWzPgq__3xDw.png" /><figcaption>DeviceBean localKey Field Objects</figcaption></figure><h4>4.3 Reading Directly from the Cache</h4><p>After several Frida hooks, I found that devices are cached through <a href="https://tuya.github.io/tuya-home-android-sdk-api-reference/com/thingclips/smart/home/sdk/api/IThingHomeDataManager.html"><strong>IThingHomeDataManager</strong></a>. We can read the full list and print each device’s data:</p><pre>Java.perform(() =&gt; {<br>  const HomeSdk = Java.use(&#39;com.thingclips.smart.home.sdk.ThingHomeSdk&#39;);<br>  const DRB = Java.use(&#39;com.thingclips.smart.interior.device.bean.DeviceRespBean&#39;);<br>  const dataInstance = HomeSdk.getDataInstance();<br>  const devList = dataInstance.getDevRespBeanList();<br>  for (let i = 0; i &lt; devList.size(); i++) {<br>    const d = Java.cast(devList.get(i), DRB);<br>    console.log(&#39;name: &#39;     + d.getName());<br>    console.log(&#39;devId: &#39;    + d.getDevId());<br>    console.log(&#39;localKey: &#39; + d.getLocalKey());<br>    console.log(&#39;ip: &#39;       + d.getIp());<br>  }<br>});</pre><h4><strong><em>Finally, I successfully extracted the localKey…</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FYVCnqq7ixgRIOu3AaVgw.png" /><figcaption>localKey Extraction</figcaption></figure><h3>5. Bonus: Hardcoded Keys in BuildConfig</h3><p>Analysing the APK with <strong>jadx </strong>(Java decompiler), inside <strong>com.app.robot.BuildConfig</strong> we find hardcoded Tuya credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3DQD3FnR_9ZNT2r9ELMng.png" /><figcaption>Hardcoded Tuya credentials</figcaption></figure><p>These are the <strong>appKey</strong> and <strong>secret</strong> used to sign calls to <strong>a1.tuyaeu.com</strong>. With Burp Suite we can intercept all API traffic to Proscenic and Tuya servers, including OTA firmware update requests.</p><p>By hooking <strong>OkHttp </strong>with Frida we can intercept Proscenic API responses in plaintext, the <strong>appeu.proscenic.com</strong> endpoints return unencrypted JSON, including the full product list with their Tuya <strong>productKey</strong> values, staging/UAT endpoint URLs and session credentials.</p><h4><strong>5.1 One detail worth noting: Umeng Analytics</strong></h4><p>Beyond the Tuya and Google Maps keys, the BuildConfig also contains a pair of <strong>Umeng_Appkey</strong> / <strong>Umeng_Message_Secret</strong> values. Umeng is a Chinese mobile analytics SDK widely used in Android and iOS apps, it collects usage statistics, crash reports and user session data, sending them to servers in China.</p><p>Anyone who buys a Proscenic device probably has no idea that the app is sending behavioural data to Chinese infrastructure every time it’s opened. This isn’t a backdoor, it isn’t an attack, it’s simply undisclosed third-party telemetry, an unfortunately common pattern in the consumer IoT ecosystem.</p><blockquote>From a privacy standpoint, it’s worth knowing. From a security researcher’s perspective, it’s yet another reminder that decompiling the APK of a device you own is always an instructive exercise…</blockquote><h3>6. Local Control with TinyTuya</h3><p>With <strong>devId</strong> and <strong>localKey</strong> in hand, local control is immediate. TinyTuya communicates directly with the device on <strong>port 6668 UDP/TCP</strong> using the Tuya local protocol with AES-128 encryption:</p><pre>import tinytuya<br><br>d = tinytuya.Device(<br>    dev_id   = &#39;XXXXXXXXXXXXXXXXX&#39;,<br>    address  = &#39;10.10.x.x&#39;,<br>    local_key= &#39;*****************&#39;,<br>    version  = 3.3<br>)<br><br>d.set_value(26, &#39;forward&#39;)    # move forward<br>time.sleep(2)<br>d.set_value(26, &#39;turnright&#39;)  # turn right<br>time.sleep(1)<br>d.set_value(26, &#39;stop&#39;)       # stop</pre><p>The most interesting finding: directional commands work in rapid sequence with no issues. The robot processes them immediately, with none of the timeouts of the official app.</p><blockquote>The remote control “bug” was in the App, not in the robot.</blockquote><h3>7. Full Data Points Mapping</h3><p>Tuya devices communicate through Data Points (DPs), key-value pairs that represent each device feature. The complete mapping for the Proscenic 850T was assembled from three sources:</p><ul><li><em>Frida hooking of commands sent by the app during remote control use</em></li><li>By setting up a passive socket to capture real-time status updates and commands sent by the mobile app to the device, below:</li></ul><pre>import tinytuya<br>import time<br><br>d = tinytuya.Device(<br>    dev_id=&quot;xxxxxxxxxxxxxxxxxxxxx&quot;,<br>    address=&quot;10.10.x.x&quot;,<br>    local_key=&quot;****************&quot;,<br>    version=3.3<br>)<br>d.set_socketTimeout(5)<br><br>print(&quot;Listen...&quot;)<br>while True:<br>    try:<br>        data = d.receive()<br>        if data:<br>            print(&quot;Data:&quot;, data)<br>    except Exception as e:<br>        print(&quot;Error:&quot;, e)<br>        time.sleep(1)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*o4lDG6F2O6DQu0f6vfItKQ.png" /></figure><ul><li><em>Analysis of the device model JSON retrieved from the Tuya APIs</em></li><li><em>Chinese technical DP documentation found on </em><a href="https://github.com/make-all/tuya-local/issues/3647"><em>GitHub</em></a><em> issues</em></li></ul><h4><strong>Control Data Points:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mJndIpEx0Kh_LMHy0fdv1g.png" /></figure><h4><strong>Status Data Points:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*csoY1qEbjDtycK7bDpFJYA.png" /></figure><h4>Accessory Reset Data Points:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eTlyys364_SVMJ4Zas-h9Q.png" /></figure><h3>8. The Control Webapp</h3><p>The final result, built during a <strong>Python/Flask + HTML/JS</strong> session with my dear friend <a href="https://claude.ai/">Claude.AI</a>, is a webapp that provides:</p><ul><li><strong><em>Directional remote control via keyboard (arrow keys) and touch</em></strong></li><li><strong><em>Smart START/STOP: sends DP 25 = smart when the robot is idle, DP 33 = false when it’s working</em></strong></li><li><strong><em>Cleaning mode selection with automatic Mop button lockout when the water tank isn’t installed (DP 49)</em></strong></li><li><strong><em>Suction power control with active level highlighting</em></strong></li><li><strong><em>Water flow control (visible only when the mop tank is detected)</em></strong></li><li><strong><em>Accessory wear bars with one-click reset</em></strong></li><li><strong><em>Animated fault banner for DP 11 errors</em></strong></li><li><strong><em>Info balloon with IP, Device ID, Product Key and Serial on hover</em></strong></li><li><strong><em>Automatic polling every 5 seconds, zero cloud dependency</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jt2xXrAMJZIegnZ73ROumQ.png" /><figcaption>WebApp — Finally I can move my robot freely!</figcaption></figure><h3>Conclusions</h3><p>This project started from a practical frustration and became a reverse engineering exercise that reveals how the consumer IoT ecosystem really works.</p><p><strong>Key takeaways:</strong></p><ul><li>Tuya is everywhere. Dozens of different brands, Proscenic, Gosund, Teckin, Merkury and many others, run on the same infrastructure. The techniques described here apply to any Tuya OEM device.</li><li>Hardcoded credentials are the norm. AppKey, secret and staging URLs baked into the APK are practically guaranteed on any IoT mobile app. jadx is your friend.</li><li>Frida makes Android app reverse engineering accessible. No need to modify the APK, no need for a physically rooted device. An emulator with root and frida-server is enough to inspect any app in real time.</li><li>Local control is always achievable. If the device supports direct WiFi communication, with the right key you can eliminate the cloud dependency entirely.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*Dv52PCTSb07md7jkq5UjZQ.png" /></figure><p>The complete code for this project, which I called <a href="https://github.com/piuppi/localScenic"><strong>localScenic</strong></a>, with a Flask backend and HTML frontend, is available on <a href="https://github.com/piuppi">my GitHub repository</a>. The structure is intentionally simple: one Python file and one HTML file, zero frontend dependencies, installable in five minutes on any PC with Python and a local network connection.</p><p><em>Written with curiosity, and a robot vacuum as the test subject.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=576164bac97c" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/reverse-engineering-the-proscenic-850t-robot-vacuum-576164bac97c">Reverse Engineering the Proscenic 850T Robot Vacuum</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Abusing Cloud-Based Sandboxes During Lockdown: An Exploration of Microsoft Services]]></title>
            <link>https://infosecwriteups.com/abusing-cloud-based-sandboxes-during-lockdown-an-exploration-of-microsoft-services-24e59b2daa39?source=rss-d5c235ccbb7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/24e59b2daa39</guid>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[microsoft-teams]]></category>
            <category><![CDATA[cyberattack]]></category>
            <dc:creator><![CDATA[Gianluca Palma]]></dc:creator>
            <pubDate>Tue, 18 Jun 2024 15:49:23 GMT</pubDate>
            <atom:updated>2024-07-01T11:29:51.767Z</atom:updated>
            <content:encoded><![CDATA[<h4>Reevaluating the Risks</h4><h4>Have you ever wondered what would happen if a malware attacked an organization instead of you?</h4><figure><img alt="empty square during lockdown" src="https://cdn-images-1.medium.com/max/873/1*T_HGWAjnJkTq75UeEQ_pnQ.png" /></figure><h3>Introduction</h3><p>Four years have passed since I decided to write this article. I have always postponed it for various reasons, but here I am.</p><p><strong>During the 2020 lockdown</strong>, with the forced advent of remote work, I stumbled upon research that I found extremely intriguing. This research delves into new techniques for exploiting vulnerabilities by using IM platforms such as Microsoft Teams as initial access for an attack.</p><p>It all started during a completely casual chat via Teams with a colleague. We were discussing new attack techniques to be used for an upcoming Red Team engagement. That conversation soon turned into a fascinating exploration that greatly stimulated my OffSec creativity.</p><h3>Social Engineering and Information Gathering: Preparing for the Attack</h3><p>Initially we considered several tactics, and after conducting some passive information gathering on the target, we contemplated using social engineering. We discovered that some software versions exposed by the target company on the Internet were vulnerable. However, exploiting these vulnerabilities was only feasible by targeting endpoints accessible from the internal network (admin panel).</p><p>As a starting point, I had prepared a simple VBA macro for initial testing with my colleague. This proof of concept (PoC), once executed, captured the client’s IP address and sent it via GET request to our web server. The goal was to exploit a well-known Web service exposed by the target, but from within.</p><figure><img alt="Example of an VBA macro that captures the IP addresses of active interfaces and sends them via GET in base64 to a remote server." src="https://cdn-images-1.medium.com/max/1024/1*K_ycPyURM725CeyF3bzvZg.png" /><figcaption>Example of a VBA macro that captures the IP addresses of active interfaces and sends them via GET request, in base64 encoding, to a remote server.</figcaption></figure><h3>The Surprising Reaction of Microsoft’s Sandbox</h3><p>During the Covid-19 lockdown, the only way to collaborate effectively with my colleagues was via Microsoft Teams. I sent the Excel file to my colleague via chat, asking him to run it to get feedback and elaborate new ideas.</p><blockquote><em>although my colleague would never actually run an Excel file with macros crafted by me</em>…</blockquote><p>Shortly after, I noticed a <strong>GET</strong> request from a remote IP containing the base64 encoded payload specified in the VBA macro.</p><figure><img alt="GET from Microsoft’s system" src="https://cdn-images-1.medium.com/max/1024/1*--lZD_iU1JFEanR9p-fH_w.png" /><figcaption>GET request from Microsoft’s system</figcaption></figure><p>My colleague had not run the file, so I checked and found that the internet IP belonged to Microsoft.</p><figure><img alt="Microsoft NetRange (40.80.0.0/12)" src="https://cdn-images-1.medium.com/max/1024/1*sAQkK9SNsLYDVoMXm7NoaQ.png" /><figcaption>Microsoft NetRange (40.80.0.0/12)</figcaption></figure><p>I immediately theorized that it was <strong>SharePoint’s built-in virus protection</strong>, which detonated the attachment before delivering it to the recipient.</p><p>This behavior captured my attention, leading to further tests of data exfiltration from the remote Microsoft’s system (ipconfig, tasklist /svc, etc.)</p><figure><img alt="GET requests with other exfiltrated commands" src="https://cdn-images-1.medium.com/max/1024/1*Ev-fIo_IboGDiLRvNyZW2Q.png" /><figcaption>GET requests with an example of exfiltrated commands’ output</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*71S5m7apxPeZxc-cBY26Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*knih19vKB9gEFoEwu3M-tA.png" /><figcaption>Decoded value of the command output received</figcaption></figure><h3><strong>Exploring the Sandbox: Deploying a Reverse Shell</strong></h3><p>This sandbox behavior drove me to write a somewhat obfuscated VBS script capable of dropping a <strong>Reverse Shell </strong>payload to connect to one of our Internet listeners.</p><figure><img alt="Sample of VBS Reverse Shell" src="https://cdn-images-1.medium.com/max/1024/1*IYDl_l0E_TTdst75Mlkr9w.png" /><figcaption>Sample of VBS Reverse Shell</figcaption></figure><p>Shortly thereafter, I received the connection instantiated by a <strong>Microsoft IP Address (40.80.0.0/12)</strong>, and I began to explore the remote system interactively.</p><figure><img alt="Reverse Shell connection from Microsoft sandbox" src="https://cdn-images-1.medium.com/max/1024/1*VaP4r5L_g0b5wtA4mYUGxw.png" /><figcaption>Reverse Shell connection from Microsoft sandbox</figcaption></figure><p>as you can see from the image below, I was able to interact with the remote system:</p><figure><img alt="Interaction with remote shell" src="https://cdn-images-1.medium.com/max/1024/1*RCnjQIDofBsqVVdBEEmx5Q.png" /><figcaption>Interaction with remote shell</figcaption></figure><p>In this way, I was able to obtain valuable and detailed information, confirming my assumption about the sandbox’s behavior.</p><blockquote>I encountered a similar scenario in <strong>2022</strong>, two years later, when <strong>CySource</strong> researchers exploited <strong>CVE-2021–22204</strong>, a vulnerability in <strong>ExifTool</strong>, to take control of <strong>VirusTotal</strong> <strong>scanners</strong>. More details about their research can be found in their <a href="https://www.cysrc.com/blog/virus-total-blog/"><strong>blog post</strong></a>.</blockquote><p>I then contacted the <strong>Microsoft Security Response Center (MSRC)</strong>, explaining the scenario of this sandbox abuse. After several exchanges with the MSRC team, I was informed that <strong><em>the behavior was part of the design of SharePoint/OneDrive virus/malware detection</em></strong>.</p><figure><img alt="Response from MSRC" src="https://cdn-images-1.medium.com/max/1024/1*87v_FYXBbq7_x3oTK-_rjA.png" /><figcaption>Response from MSRC and case closure</figcaption></figure><h3>Using the Sandbox as a Proxy: A Successful Experiment</h3><p>After setting aside the dispute with Microsoft, I had an idea: I could abuse Microsoft’s sandbox through <strong>Microsoft Teams,</strong> to perform an attack on an external target exposed on the Internet, <strong>effectively making Microsoft appear as the attacker in the target system’s logs</strong>.</p><blockquote>After all, obtaining a Teams Business Account, necessary for accessing its sandbox, is not difficult for an attacker.</blockquote><p>To test this idea, I deployed an old version of JBoss Application Server vulnerable to <a href="https://nvd.nist.gov/vuln/detail/CVE-2013-4810"><strong>CVE-2013–4810</strong></a> and exposed it online using ngrok.</p><p>This vulnerability allow remote attackers to execute arbitrary code via a marshalled object to <strong>EJBInvokerServlet </strong>or <strong>JMXInvokerServlet </strong>servlets.</p><figure><img alt="Jboss Management Console" src="https://cdn-images-1.medium.com/max/981/1*WjJ8jzjz_XExmn2C_K552A.png" /><figcaption>Jboss Management Console</figcaption></figure><p>To run it in the Microsoft sandbox, I had to manually port the <strong>CVE-2013–4810</strong> <strong>exploit </strong>from PHP to VBS . You can find the original exploit here <a href="https://www.exploit-db.com/exploits/28713">https://www.exploit-db.com/exploits/28713</a></p><figure><img alt="Sample of VBScript EJBInvokerServlet exploit" src="https://cdn-images-1.medium.com/max/1024/1*ylkMemQLzMSKpWpF351siQ.png" /><figcaption>Sample of VBScript EJBInvokerServlet exploit</figcaption></figure><blockquote><strong>Note</strong>: The choice of VBS was deliberate since other languages, such as Python, were not executing properly in the sandbox. It appears that the Microsoft sandbox handles VBS very effectively :-)</blockquote><p>then I sent it to my colleague as an attachment via Teams chat:</p><figure><img alt="VBScript attachment" src="https://cdn-images-1.medium.com/max/1024/1*-hNtusqjMecxkUO4kLIxPw.png" /><figcaption>VBScript attachment</figcaption></figure><p>and a few moments later…</p><h3>It Worked! The Attack Succeeded!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*gUY5yOceyT-UV0JzhxTksA.png" /></figure><p>The <strong>CVE-2013–4810</strong> exploit was executed by the Microsoft anti-malware sandbox, and a <strong>JSP Webshell</strong> was deployed on my vulnerable JBoss Server. Of course, all GET/POST requests in the attack came from <strong>Microsoft’s network (40.80.0.0/12)!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X66QEzAAdo8bwTwGyAvV5A.png" /><figcaption>JSP WebShell deployed</figcaption></figure><p>As you can see from the image below, the POST request to the <strong>EJBInvokerServlet </strong>was executed by the Microsoft system with IP address <strong>40.94.94.48</strong>:</p><figure><img alt="POST /invoker/EJBInvokerServlet from Microsoft IP Address" src="https://cdn-images-1.medium.com/max/1024/1*s5mrkV2nJXgZyIeJMk8DCw.png" /><figcaption>POST /invoker/EJBInvokerServlet from Microsoft IP Address</figcaption></figure><h3>Final Proof</h3><p>As a proof of concept (PoC), I also included in my VBS exploit, right after deploying the webshell, a request to execute the ‘<strong>id</strong>’ command on the hacked system.</p><figure><img alt="Webshell Execution (‘id’ command) by a Microsoft server" src="https://cdn-images-1.medium.com/max/1024/1*SwaiGLpSJvQcUKmpjtbeqg.png" /><figcaption>Webshell Execution (‘id’ command) by a Microsoft server</figcaption></figure><p>Next, the base64-encoded command output was sent via “<strong>requestbin.net</strong>” (<em>Melancholy Me…</em>), and as you can see below, the request was performed from a Microsoft’s IP Address.</p><figure><img alt="output of base64-encoded id command" src="https://cdn-images-1.medium.com/max/1024/1*MbfsGhowwIyucc2B-TLSDw.png" /><figcaption>output of base64-encoded id command</figcaption></figure><p>Once decoded, it showed me the output of the ‘id’ command executed on the hacked system:</p><figure><img alt="base64 decoded" src="https://cdn-images-1.medium.com/max/1018/1*Q4tYomn2ZexFZ-HujiPTJw.png" /><figcaption>base64 decoded</figcaption></figure><h3><strong>Conclusions</strong></h3><p>Finally, I demonstrated how it is possible to attack an external company by abusing Microsoft’s built-in antimalware sandbox as a proxy to execute the attack. I also reported this scenario to Microsoft, explaining how sandboxes can be used as proxies to carry out attacks. However, they answered me that this behavior was expected “<strong>by design</strong>” and that I could disclose it publicly without any problems:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MG0436Ohe00xjRC87XP_Wg.png" /><figcaption>MSRC Answer</figcaption></figure><h3>Reevaluating the Risks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8831S34d2I4h-tD5GttVVg.png" /></figure><p>Although Microsoft closed the case by stating that sandbox behavior was expected, it would seem that over the years it has recognized the potential abuse of this feature. In fact, <strong>in a recent test I conducted in 2024</strong>, <strong>it appears that VBS scripts no longer run in the sandbox (!).</strong></p><p>This suggests that the ‘<strong>by design</strong>’ anti-malware behavior may have been changed over time, or that <strong>VBScript </strong>has been disabled due to its impending deprecation, rendering this scenario no longer applicable. However, questions arise as to why this change was implemented if VBS is still in use.</p><figure><img alt="VBScript deprecation timeline" src="https://cdn-images-1.medium.com/max/1024/1*0GvzzCH2XRCo3y4womOMmQ.png" /><figcaption>VBScript deprecation timeline</figcaption></figure><p>Although this approach is <strong>no longer exploitable today</strong>, it remains an interesting case study for me.</p><blockquote>I leave you with one final question: We know that in 2020 Microsoft was doing these analyses in the antimalware sandbox by contacting the impacted remote systems; having changed this process, I wonder how are these analyses performed today?</blockquote><p><strong>I’m eager to hear your thoughts and would love to get your take on this.</strong></p><p>Thank you for reading, and I hope you enjoyed this article! English isn’t my native language, but I’m passionate about improving my skills and sharing knowledge.</p><p>Grazie mille per aver letto fino a questo punto! :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24e59b2daa39" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/abusing-cloud-based-sandboxes-during-lockdown-an-exploration-of-microsoft-services-24e59b2daa39">Abusing Cloud-Based Sandboxes During Lockdown: An Exploration of Microsoft Services</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>