<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohammed Aref Alsrkal</title>
    <description>The latest articles on DEV Community by Mohammed Aref Alsrkal (@alsrkal).</description>
    <link>https://dev.to/alsrkal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4259480%2Fa159cfa2-e738-4268-855d-566a65a62f87.png</url>
      <title>DEV Community: Mohammed Aref Alsrkal</title>
      <link>https://dev.to/alsrkal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alsrkal"/>
    <language>en</language>
    <item>
      <title>Building a WhatsApp Web extension with no server: a Manifest V3 bridge, a deleted-message vault and what broke</title>
      <dc:creator>Mohammed Aref Alsrkal</dc:creator>
      <pubDate>Tue, 24 Nov 2026 11:38:38 +0000</pubDate>
      <link>https://dev.to/alsrkal/building-a-whatsapp-web-extension-with-no-server-a-manifest-v3-bridge-a-deleted-message-vault-and-4ipc</link>
      <guid>https://dev.to/alsrkal/building-a-whatsapp-web-extension-with-no-server-a-manifest-v3-bridge-a-deleted-message-vault-and-4ipc</guid>
      <description>&lt;p&gt;MadarWA is a WhatsApp Web toolkit with three goals: blur chats when someone is looking over your shoulder, keep a local copy of messages that are deleted after you received them, and never send any of that to a server you do not control.&lt;/p&gt;

&lt;p&gt;The third goal shaped everything. This post covers how MadarWA works: a Manifest V3 Chrome extension that runs entirely inside the browser, and the engineering problems that "no server" creates.&lt;/p&gt;

&lt;h2&gt;
  
  
  The constraint: no backend, no remote code
&lt;/h2&gt;

&lt;p&gt;MadarWA has no relay server, no telemetry and no remote code. Settings, the message vault and the logs live in &lt;code&gt;chrome.storage.local&lt;/code&gt;. Media lives in IndexedDB. The extension CSP is &lt;code&gt;script-src 'self'; object-src 'self'; base-uri 'none'&lt;/code&gt;, and every script is bundled at build time.&lt;/p&gt;

&lt;p&gt;That sounds like a slogan until you try to do something useful with it. WhatsApp Web does not give extensions an API. So the first decision was how to reach WhatsApp's internals at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reaching the internals without scraping the DOM
&lt;/h2&gt;

&lt;p&gt;Scraping WhatsApp's DOM breaks every time the class names change. Instead MadarWA bundles &lt;code&gt;@wppconnect/wa-js&lt;/code&gt; (pinned to 4.7.2) locally and uses the &lt;code&gt;WPP&lt;/code&gt; interfaces it exposes. That code has to run in the page's own JavaScript context, which Manifest V3 allows with &lt;code&gt;world: "MAIN"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the extension is split in two worlds:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Runs in&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;preload.js&lt;/code&gt;, &lt;code&gt;wppconnect-wa.js&lt;/code&gt;, &lt;code&gt;injected.js&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;MAIN world (page JS)&lt;/td&gt;
&lt;td&gt;Turn analytics off, wait for &lt;code&gt;WPP.loader.onReady&lt;/code&gt;, listen to new messages, revokes and presence changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;content.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ISOLATED world&lt;/td&gt;
&lt;td&gt;React UI inside a Shadow DOM, settings, vault, campaigns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;background.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Service worker&lt;/td&gt;
&lt;td&gt;Webhook delivery, badge, notifications, daily maintenance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Shadow DOM matters more than it looks. WhatsApp's styles are aggressive and change often, and an isolated style boundary keeps the panel from being broken by them, and keeps the panel from breaking WhatsApp.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bridge between the two worlds
&lt;/h2&gt;

&lt;p&gt;The MAIN world is page code, so anything in it can be reached by other scripts on the page. The two halves talk through CustomEvents, and I wanted that channel to reject tampering and replays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the isolated side creates an ephemeral 32-byte session key and a random session id&lt;/li&gt;
&lt;li&gt;every envelope carries a namespace, the session id, a monotonic sequence number, the payload and a keyed checksum&lt;/li&gt;
&lt;li&gt;the MAIN side rejects wrong sessions, altered payloads and any sequence number it has already seen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I should be precise about what this is. It is transport hardening, not secrecy. Code running in the MAIN world can always observe its own traffic, and the README says so. What the bridge buys is that a stray script cannot forge commands or replay old ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  The anti-delete vault
&lt;/h2&gt;

&lt;p&gt;When someone deletes a message "for everyone", WhatsApp tells your client to remove it. By then the text is usually gone. The vault has to act earlier.&lt;/p&gt;

&lt;p&gt;MadarWA keeps a bounded cache of message text and metadata as messages arrive. For media, it downloads the decrypted file with &lt;code&gt;WPP.chat.downloadMedia&lt;/code&gt; right away (up to 25 MB) and stores the blob in IndexedDB with an LRU limit of 150 items. When a &lt;code&gt;chat.msg_revoke&lt;/code&gt; event arrives, it looks up the original by id and stanza id, writes a vault entry, and replaces the deleted bubble with an interactive element in the chat: text with copy and timestamps, photo with a lightbox, playable video and voice notes, and downloadable documents.&lt;/p&gt;

&lt;p&gt;Two details took longer than the feature itself:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Revokes arrive in more than one shape.&lt;/strong&gt; Sometimes WhatsApp sends a revoke event. Sometimes it inserts a new row of type &lt;code&gt;revoked&lt;/code&gt; through a normal &lt;code&gt;add&lt;/code&gt;. The vault listens to &lt;code&gt;add&lt;/code&gt;, &lt;code&gt;change:type&lt;/code&gt; and &lt;code&gt;chat.msg_revoke&lt;/code&gt;, and resolves the original key through a chain of fallbacks. There are tests for the chained resolution and for group message ids that have four parts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WhatsApp redraws constantly.&lt;/strong&gt; An earlier version restored deleted messages, but when you switched to another chat and came back, the restored elements were gone and stayed gone. In a chat with 9 deleted messages, nothing was covered even after 12 seconds. After the fix, all nine were covered in under a third of a second: two restored copies and seven short notes saying why no copy exists. That last part matters. If MadarWA never received the message, or the deletion is older than when saving started, the bubble says so instead of leaving you wondering. A deletion 134 days old correctly showed "older than when saving started".&lt;/p&gt;

&lt;p&gt;And deletions that WhatsApp reports again after a page reload used to fire a second alert and a second webhook. They no longer do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Privacy mode, one element at a time
&lt;/h2&gt;

&lt;p&gt;Blurring the whole page is easy and useless. MadarWA tags exact elements (names, phone numbers, previews, avatars, message text, the composer box, media) and reveals only the one under the pointer, after 160 ms. The tagger and the CSS rules have their own tests.&lt;/p&gt;

&lt;p&gt;There is also a part that is not cosmetic. Hiding typing and recording state, blocking read receipts and private status viewing go through the real &lt;code&gt;WPP.privacy&lt;/code&gt; calls. Turning off read receipts changes your actual WhatsApp account setting across devices, and the UI warns you before doing it. Suppressing "audio played" receipts is best effort through wrapped calls and may not work on every WhatsApp build. I would rather write that in the README than discover it in a bug report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smaller things that were worth getting right
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PIN lock:&lt;/strong&gt; PBKDF2-SHA256, 120,000 iterations, a random 16-byte salt, constant-time comparison. It is a UI convenience, not disk encryption. Anyone with DevTools access can bypass it, and the docs say that too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Webhooks:&lt;/strong&gt; delivered from the service worker with an SSRF guard that rejects private and reserved IPv4 and IPv6 ranges, &lt;code&gt;localhost&lt;/code&gt;, &lt;code&gt;.local&lt;/code&gt;, &lt;code&gt;.internal&lt;/code&gt;, URLs with credentials and single-label hostnames. Redirects are disabled, the timeout is 20 s and the body is capped at 512 KB. Transient failures (network, 429, 5xx) retry with a stable delivery id so the receiver can deduplicate. DNS rebinding is still a residual risk that an extension cannot fully solve, and the README lists it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSV and Excel export:&lt;/strong&gt; UTF-8 with BOM so Arabic opens correctly in Excel, plus protection against formula injection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bilingual UI:&lt;/strong&gt; Arabic (RTL) and English (LTR), switchable instantly, with a test that the two translation files have matching keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;The project has 175 Vitest tests in 23 files, covering the bridge (tampering, replay, timeouts, rejecting foreign origins), SSRF rules, spintax, phone number normalization, the queue, the PIN, receipts, the media vault and the in-chat restore. The current gate is typecheck, tests, build and a build verification step, and all four pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does not do well
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It depends on WhatsApp's internal modules through a pinned wa-js. A future WhatsApp build may break it until the pin is upgraded.&lt;/li&gt;
&lt;li&gt;It has not had an external security audit. It is verified structurally and functionally, which is not the same thing.&lt;/li&gt;
&lt;li&gt;Campaigns live in memory and do not survive a page reload. Attachments are capped at 4 MB by the bridge.&lt;/li&gt;
&lt;li&gt;The vault keeps up to 1,000 deleted messages and the message cache up to 3,000.&lt;/li&gt;
&lt;li&gt;Bulk sending can get a WhatsApp account restricted. The campaign module exists, with delays, batches and pause on disconnect, but you should treat it carefully.&lt;/li&gt;
&lt;li&gt;The vault stores local copies of message text. Use it only where you have the consent and the legal right to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;It is not on the Chrome Web Store, so you build it yourself (Chrome 111+, Node 22.12+):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/ALSRKAL/MadarWA.git
&lt;span class="nb"&gt;cd&lt;/span&gt; MadarWA
npm install
npm run build
npm run verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open &lt;code&gt;chrome://extensions&lt;/code&gt;, enable Developer mode, choose &lt;strong&gt;Load unpacked&lt;/strong&gt;, and select &lt;code&gt;dist/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Source and docs, in Arabic and English: &lt;a href="https://github.com/ALSRKAL/MadarWA" rel="noopener noreferrer"&gt;github.com/ALSRKAL/MadarWA&lt;/a&gt; (MIT).&lt;/p&gt;

&lt;p&gt;I wrote about my other tools too: &lt;a href="https://dev.to/alsrkal/my-bash-network-tool-was-lying-to-me-so-i-rewrote-it-in-rust-27ij"&gt;the Bash network script that lied to me&lt;/a&gt; and &lt;a href="https://dev.to/alsrkal/adb-tcpip-kept-breaking-my-android-wireless-debugging-so-i-built-a-tool-that-never-uses-it-dd5"&gt;the Android wireless debugging tool&lt;/a&gt;. If you work on MV3 extensions and have opinions on the bridge design, I would like to hear them.&lt;/p&gt;

</description>
      <category>chrome</category>
      <category>privacy</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>adb tcpip kept breaking my Android wireless debugging, so I built a tool that never uses it</title>
      <dc:creator>Mohammed Aref Alsrkal</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:18:38 +0000</pubDate>
      <link>https://dev.to/alsrkal/adb-tcpip-kept-breaking-my-android-wireless-debugging-so-i-built-a-tool-that-never-uses-it-dd5</link>
      <guid>https://dev.to/alsrkal/adb-tcpip-kept-breaking-my-android-wireless-debugging-so-i-built-a-tool-that-never-uses-it-dd5</guid>
      <description>&lt;p&gt;I test on real Android devices. Every day, for years, my workflow started the same way: plug in the USB cable, run &lt;code&gt;adb tcpip 5555&lt;/code&gt;, unplug, &lt;code&gt;adb connect&lt;/code&gt;, get to work. Every Android tutorial on the internet tells you to do exactly this.&lt;/p&gt;

&lt;p&gt;It worked. Until Android 11, when it started quietly breaking my phone.&lt;/p&gt;

&lt;p&gt;This is the story of what &lt;code&gt;adb tcpip&lt;/code&gt; actually does to a modern phone, the bugs that forced me to understand it, and the tool I ended up building: &lt;a href="https://github.com/ALSRKAL/adb-wireless-manager" rel="noopener noreferrer"&gt;ADB Wireless Manager&lt;/a&gt;, a tray app and CLI that keeps several devices connected over Wi-Fi and never, ever restarts &lt;code&gt;adbd&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What adb tcpip actually does
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;adb tcpip &amp;lt;port&amp;gt;&lt;/code&gt; does not "enable Wi-Fi debugging". It restarts the &lt;code&gt;adbd&lt;/code&gt; daemon on the phone in TCP mode. On Android 10 and older that was fine, because there was nothing else.&lt;/p&gt;

&lt;p&gt;Android 11 introduced real Wireless debugging: a proper TLS service that the phone advertises over mDNS, on a port that changes after every reboot and every Wi-Fi toggle. And here is the part nobody warns you about: restarting &lt;code&gt;adbd&lt;/code&gt; tears that TLS session down and leaves the Wireless-debugging toggle in Developer options switched off.&lt;/p&gt;

&lt;p&gt;So my daily habit was doing this to my phone: kill the secure service, leave the switch off, and fall back to the legacy unencrypted port. Every single morning. I only noticed when the toggle kept mysteriously turning itself off and I blamed the phone.&lt;/p&gt;

&lt;p&gt;The fix is not a better flag. It is to stop touching &lt;code&gt;adbd&lt;/code&gt; at all: if the phone is already advertising over mDNS, connect to the advertised port and change nothing. Only fall back to &lt;code&gt;tcpip&lt;/code&gt; when there is genuinely no other path, and restore the toggle afterwards.&lt;/p&gt;

&lt;p&gt;That decision shaped the whole tool. And then reality taught me three more lessons, each with a bug attached.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug one: I connected to the wrong phone
&lt;/h2&gt;

&lt;p&gt;mDNS adverts outlive the services they describe. And DHCP leases move around. One day my "reconnect" succeeded, I ran my tests, and nothing made sense, because I had connected to a phone that had inherited the old phone's IP address. &lt;code&gt;adb connect&lt;/code&gt; said "connected". It was connected. To the wrong device.&lt;/p&gt;

&lt;p&gt;Now every connection is verified before it is reported as successful. The tool runs a real command round-trip and compares the hardware serial against the device it was asked to reach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;serial_of_target&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="c"&gt;# target -&amp;gt; hardware serial (uppercase) or empty&lt;/span&gt;
    adbq -s &lt;span class="s2"&gt;"$1"&lt;/span&gt; shell getprop ro.serialno 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null \
        &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;'\r\n'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tr &lt;span class="s1"&gt;'[:lower:]'&lt;/span&gt; &lt;span class="s1"&gt;'[:upper:]'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the serial does not match, it disconnects immediately and refuses, instead of silently adopting a stranger. An address that refuses the connection fails fast and the next candidate is tried, rather than eating the whole retry budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug two: the phone lied about enabling wireless debugging
&lt;/h2&gt;

&lt;p&gt;On Android 11+ you can try to flip the toggle from the host:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell settings put global adb_wifi_enabled 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command exits 0. Successfully. Even when the vendor's framework silently discards the write. Several vendors do exactly that: the switch is meant to be user-controlled and Android offers no sanctioned command for it.&lt;/p&gt;

&lt;p&gt;If you have read my post about &lt;a href="https://dev.to/alsrkal/my-bash-network-tool-was-lying-to-me-so-i-rewrote-it-in-rust-27ij"&gt;rewriting my Bash network tool in Rust&lt;/a&gt;, you know my rule: no fake data. Same rule here. The tool writes the setting, then reads it back. If it did not stick, it says so and asks you to flip the switch yourself, rather than pretending it worked. An honest "I could not do this, here is the one manual step" beats a confident lie every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug three: my healing loop was the thing breaking the connection
&lt;/h2&gt;

&lt;p&gt;The natural way to fix a stuck adb connection is &lt;code&gt;adb reconnect&lt;/code&gt;, or worse, &lt;code&gt;adb usb&lt;/code&gt; to reset. Both are traps: anything that restarts &lt;code&gt;adbd&lt;/code&gt; on the phone kills the wireless-debugging session, which is the very thing the healing loop exists to protect.&lt;/p&gt;

&lt;p&gt;So the healing path is host-side only:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;heal_transport&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="c"&gt;# ip port&lt;/span&gt;
    &lt;span class="c"&gt;# Clears a half-open transport on the HOST only. `adb usb` / `adb tcpip`&lt;/span&gt;
    &lt;span class="c"&gt;# restart adbd on the phone, which on Android 11+ tears down the&lt;/span&gt;
    &lt;span class="c"&gt;# Wireless-debugging session and leaves the toggle switched off, so&lt;/span&gt;
    &lt;span class="c"&gt;# neither belongs in a healing path.&lt;/span&gt;
    adbc disconnect &lt;span class="s2"&gt;"$ip:$port"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"$LOG_FILE"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
    run_to 8 adb reconnect offline &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"$LOG_FILE"&lt;/span&gt; 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And because I do not trust myself at 1 AM, there is a source-level test that fails the build if any code path ever calls &lt;code&gt;adb usb&lt;/code&gt;. The unit tests also cover the connection strategy, output parsers, and the device-identity merge that keeps one row per physical device in the menu, whatever transport it is using.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it became
&lt;/h2&gt;

&lt;p&gt;The result is a cross-platform tool: a POSIX bash CLI for Linux and macOS, a PowerShell CLI for Windows, and a PyQt5 system-tray app that shows every device in one row, whether it is on USB or wireless.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz1gxcpw8krqwq54hvsl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz1gxcpw8krqwq54hvsl5.png" alt="Tray menu: every device in one row, whatever its transport" width="251" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The flow per device is a small decision tree:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Device state&lt;/th&gt;
&lt;th&gt;Path taken&lt;/th&gt;
&lt;th&gt;Effect on the phone&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Android 11+, advertising over mDNS&lt;/td&gt;
&lt;td&gt;connect to the advertised port&lt;/td&gt;
&lt;td&gt;nothing is changed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 11+, toggle off&lt;/td&gt;
&lt;td&gt;try to set &lt;code&gt;adb_wifi_enabled&lt;/code&gt;, read it back&lt;/td&gt;
&lt;td&gt;toggle on when the vendor allows it, honest failure otherwise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Android 10 or older, or no mDNS&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;adb tcpip&lt;/code&gt; fallback&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;adbd&lt;/code&gt; restarts, toggle restored afterwards&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On top of that: a wireless pairing wizard for Android 11+ (no cable needed at all), a watch mode that heals dropped links, scrcpy screen mirroring per device, an APK installer with a drop zone, screenshots and recordings to the desktop, an environment doctor, and a fully bilingual Arabic/English interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl6qjn3wi22f70fco75i7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl6qjn3wi22f70fco75i7.png" alt="Wireless pairing wizard for Android 11+" width="512" height="652"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reconnecting tries addresses in order: the current mDNS advert for that serial, the last saved address, then the fixed port on every host it has seen, which is where a legacy-path device still listens. It survives network drops, computer reboots, and phone reboots, because the port changing no longer matters when you are listening to mDNS instead of remembering numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The lesson, again
&lt;/h2&gt;

&lt;p&gt;Between netRo and this tool, the pattern in my own work is embarrassingly consistent: the dangerous bugs are never the ones that crash. They are the ones that report success while doing the wrong thing. &lt;code&gt;adb connect&lt;/code&gt; saying "connected" to the wrong phone. &lt;code&gt;settings put&lt;/code&gt; exiting 0 into the void. A toggle silently switched off every morning by my own habit.&lt;/p&gt;

&lt;p&gt;Verify identity. Read back your writes. Never restart the thing you are trying to protect.&lt;/p&gt;

&lt;p&gt;The project is MIT-licensed and on GitHub: &lt;a href="https://github.com/ALSRKAL/adb-wireless-manager" rel="noopener noreferrer"&gt;ALSRKAL/adb-wireless-manager&lt;/a&gt;. Clone it, run &lt;code&gt;./install.sh&lt;/code&gt;, and unplug the cable for good. Issues, ideas and pull requests are welcome, and a star tells me someone else got tired of the cable too.&lt;/p&gt;

</description>
      <category>android</category>
      <category>bash</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>My Bash network tool was lying to me, so I rewrote it in Rust</title>
      <dc:creator>Mohammed Aref Alsrkal</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:04:59 +0000</pubDate>
      <link>https://dev.to/alsrkal/my-bash-network-tool-was-lying-to-me-so-i-rewrote-it-in-rust-27ij</link>
      <guid>https://dev.to/alsrkal/my-bash-network-tool-was-lying-to-me-so-i-rewrote-it-in-rust-27ij</guid>
      <description>&lt;p&gt;For years I had a Bash script called netRo.sh. It was a 733-line interactive dashboard I used to check servers: CPU, memory, network, a few "security" checks. It felt useful until the day I actually read it carefully.&lt;/p&gt;

&lt;p&gt;I sat down and wrote an audit of my own script, line by line, and it hurt. A function called update_system_info() did nothing but sleep 2 to look busy. The rootkit check always printed "skipped", forever. The unauthorized-users check flagged every account with UID under 1000, which on Linux is every system account, so it cried wolf on a clean machine. My "suspicious process" detector grepped for nmap, wireshark and tcpdump, which is to say it accused every network engineer of being a hacker. And the worst one: a "block device" feature ran iptables and then wrote the rules permanently to disk, with sudo, with no confirmation and no rollback.&lt;/p&gt;

&lt;p&gt;No tests. No CI. No machine-readable output. Linux only. I had trusted this thing.&lt;/p&gt;

&lt;p&gt;So I kept the idea and deleted the code. netRo 5.0 is a full rewrite in Rust, and this post is about the one rule that shaped every decision in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule: no fake data
&lt;/h2&gt;

&lt;p&gt;Every result netRo prints comes from a real check. Anything a platform cannot do is reported as UNSUPPORTED, DEPENDENCY_MISSING or PERMISSION_DENIED, with a hint. This sounds obvious until you look at how many tools quietly guess. My old script guessed constantly.&lt;/p&gt;

&lt;p&gt;The rule has teeth because of the error model. Every failure returns a structured error with a stable code (PERMISSION_DENIED, TIMEOUT, UNAUTHORIZED_SCAN, and so on), a message, and a hint, mapped to specific exit codes. A missing tool degrades one check instead of killing the whole run, which is what set -e did to the old script every time a dependency was missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture that enforces the rule
&lt;/h2&gt;

&lt;p&gt;The code is layered: a clap CLI and a ratatui TUI both sit on top of a commands layer, which calls a portable core, which talks to the OS only through provider traits.&lt;/p&gt;

&lt;p&gt;SystemProvider, NetworkProvider, ProcessProvider, SecurityProvider, FirewallControl: adding a platform means implementing those traits, nothing in core/ changes. Linux providers parse /proc and /sys and drive ufw, firewalld, nftables and iptables. Windows providers call PowerShell and CIM. macOS uses netstat, lsof, scutil, socketfilterfw and system_profiler. I can verify the layering with one grep: there is not a single OS command string in src/core/.&lt;/p&gt;

&lt;p&gt;The TUI is a second presentation layer over the same engine. It contains zero diagnostics of its own and never builds a command line. If the CLI and the TUI ever disagreed, that would be a bug in exactly one place.&lt;/p&gt;

&lt;h2&gt;
  
  
  The no-shell policy
&lt;/h2&gt;

&lt;p&gt;There is no sh -c, bash -c or cmd /c anywhere in the codebase. Every external program runs with an explicit argument vector, resolved to an absolute path first so a poisoned PATH cannot swap in a different binary during a privileged call.&lt;/p&gt;

&lt;p&gt;Windows was the interesting one. The PowerShell bridge passes fixed scripts through -EncodedCommand (UTF-16LE base64). User input is never concatenated into script text; the only user data that crosses the boundary is validated IP literals for firewall rules. Targets are validated for length, characters and a leading dash even though no shell ever re-parses them, because defense in depth is cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that were harder than they look
&lt;/h2&gt;

&lt;p&gt;DNS. I wanted real queries without depending on nslookup, so netRo has a built-in DNS client: UDP with TCP fallback, A/AAAA/CNAME/MX/TXT/NS/SOA/PTR/SRV records, RTT measurement, custom servers, reverse lookups. Parsing DNS is a rite of passage: compression pointers, loops, bounds checks. The tests include NXDOMAIN handling and pointer-loop attacks.&lt;/p&gt;

&lt;p&gt;TLS. Port scanning is a TCP connect scan (SYN scanning is explicitly not implemented and the docs say so), but on open ports netRo grabs the service banner and probes TLS certificates with rustls to tell you what is actually listening and when its certificate expires. The TLS dependency is feature-gated so you can cross-compile without a C toolchain for the target.&lt;/p&gt;

&lt;p&gt;Privileges. netRo never runs sudo on its own. Firewall changes check elevation first and fail with PERMISSION_DENIED plus the exact hint for your platform. There is a --dry-run that prints the exact commands and rollback without root, and applying a change requires confirmation or --yes, shows every command, and records rollback state so unblock only removes rules netRo itself created. My old script's silent iptables-save is the reason this exists.&lt;/p&gt;

&lt;p&gt;The doctor command. One command runs every check and produces a score. The score is transparent: every deduction is listed by category with evidence, impact and a recommendation, and informational findings never lower it. A score you cannot explain is just a number that makes people anxious.&lt;/p&gt;

&lt;h2&gt;
  
  
  Numbers
&lt;/h2&gt;

&lt;p&gt;On Linux x86_64 with the release build: startup is about 12 ms. A 10,000-port localhost scan with 512 workers takes about 370 ms. The full doctor run is about 4.7 s at 22 MB RSS. Steady-state monitoring costs about 16 ms per sample. The binary is a single static executable (thin LTO, stripped), and CI builds and tests it on Ubuntu, Windows, macOS Intel and Apple Silicon. There are 239 tests, including end-to-end CLI contract tests and snapshot-rendered TUI tests that inject hostile ANSI payloads into remote-derived strings to prove they cannot reach your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would tell past me
&lt;/h2&gt;

&lt;p&gt;Writing the audit document was the most valuable hour of the whole project. Reading your own old code as if you were an auditor, and writing down every finding with a disposition, turns "my script is probably fine" into a concrete list you can fix one by one. The audit of the old script is still in the repo (docs/AUDIT.md), next to the engineering audit of the rewrite, because I want the receipts public.&lt;/p&gt;

&lt;p&gt;netRo is MIT licensed: &lt;a href="https://github.com/ALSRKAL/netRo" rel="noopener noreferrer"&gt;https://github.com/ALSRKAL/netRo&lt;/a&gt;. Linux is the primary, fully tested platform; Windows and macOS pass compile and CI runtime tests but I would genuinely love bug reports from real machines there. If you try the doctor command on something weird, I want to hear about it.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>cli</category>
      <category>devops</category>
      <category>security</category>
    </item>
  </channel>
</rss>
