<?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: Damjan Cvetko</title>
    <description>The latest articles on DEV Community by Damjan Cvetko (@zobo).</description>
    <link>https://dev.to/zobo</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F184675%2F02aadecf-6b38-40bc-a33c-2465f56b40cf.png</url>
      <title>DEV Community: Damjan Cvetko</title>
      <link>https://dev.to/zobo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zobo"/>
    <language>en</language>
    <item>
      <title>VSCode PHP Debug Release September 2021</title>
      <dc:creator>Damjan Cvetko</dc:creator>
      <pubDate>Fri, 15 Oct 2021 21:29:46 +0000</pubDate>
      <link>https://dev.to/zobo/vscode-php-debug-release-september-2021-1lpb</link>
      <guid>https://dev.to/zobo/vscode-php-debug-release-september-2021-1lpb</guid>
      <description>&lt;p&gt;This is a small writeup on the September 2021 release of VSCode PHP Debug adapter extension. A cover issue describing all work can be found on &lt;a href="https://github.com/xdebug/vscode-php-debug/issues/648"&gt;GitHub issues&lt;/a&gt;.&lt;br&gt;
I intended to do a "release" every month, but I just do incremental releases and write up a monthly (or so) report... It was summer :)&lt;/p&gt;

&lt;p&gt;## No-folder debugging&lt;/p&gt;

&lt;p&gt;A large task was the No-folder debugging. This is when VS Code has the purple status bar, no folder is open at that time, and so no launch.json file is available. I was actually &lt;a href="https://github.com/xdebug/vscode-php-debug/issues/638"&gt;brought to my attention&lt;/a&gt; by Microsoft's VS Code PM. We had a conf call and discussed what can be done to make PHP debugging in VS Code simpler. Especially the initial setup.&lt;/p&gt;

&lt;p&gt;The changes that came out of this are the no-folder debugging and VS Code settings for the location of the PHP binary. And the quick run/debug icon in the editor. The extension had to transition from a pure DAP implementation into a hybrid one. Now there is also native extension code being activated when debugging starts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pO-PYyiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rjgg68v5idojfmukgfl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pO-PYyiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rjgg68v5idojfmukgfl.png" alt="No-folder debugging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are plans to further improve PHP and Xdebug setup for new users.&lt;/p&gt;

&lt;h2&gt;
  
  
  xdebug_notify()
&lt;/h2&gt;

&lt;p&gt;This is a new feature of Xdebug that I helped to define. It is very similar to &lt;code&gt;console.log()&lt;/code&gt;. If a DBGp connection is active it will send whatever is the parameter to the IDE in the form of a property.&lt;br&gt;
The ide was to provide similar facilities to Windows Debug channels. My initial idea was to use the &lt;code&gt;stream&lt;/code&gt; concept of Xdebug, but we later decided to go with notify.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8wgMjlHi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhozbs1dkhhh3c2trprw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8wgMjlHi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhozbs1dkhhh3c2trprw.png" alt="xdebug_notify"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Logpoints
&lt;/h2&gt;

&lt;p&gt;A long standing Pull Request was cleaned up and merged. Logpoints are like breakpoints but they do not stop execution, just print text to the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TpZe8xHN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92ldqxggkv8nccbm2ytf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TpZe8xHN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92ldqxggkv8nccbm2ytf.png" alt="Logpoints"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hit-Count conditional breakpoints
&lt;/h2&gt;

&lt;p&gt;Another old Pull Request was cleaned up and merged. Hit-count conditional breakpoints allow the user to set when the breakpoint will actually stop, depending on the number of hits a breakpoint receives. This functionality is provided by Xdebug. Only conditions &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;%&lt;/code&gt; are available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DJEObzAo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rjggrrwtn43pqtdicvr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DJEObzAo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rjggrrwtn43pqtdicvr.png" alt="Hi-count conditional breakpoints"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Facets
&lt;/h2&gt;

&lt;p&gt;With PHP 8 came readonly properties and enums. Xdebug provides this information in the &lt;code&gt;facets&lt;/code&gt; attribute of the property structure. This is now processed, but does not have a real impact on the UI... yet. Both readonly and enum cannot be edited. Processing this flags allows us to prevent that on the UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Max connections
&lt;/h2&gt;

&lt;p&gt;Another late feature that came in - altho already in october - is the &lt;code&gt;maxConnections&lt;/code&gt; launch parameter. It restricts how many connections at a time can be active. When max connections are reached any new connection will be dropped and PHP will continue execution without debugging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--91EYWZXG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4s3h7bs7nphoi5exw9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--91EYWZXG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4s3h7bs7nphoi5exw9b.png" alt="Max connections"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I'm always happy about feedback and would always like to know how to make debugging experience better. I'm currently focusing on DBGp Proxy and &lt;a href="https://xdebug.cloud/"&gt;Xdebug Cloud&lt;/a&gt; support.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>xdebug</category>
      <category>php</category>
    </item>
    <item>
      <title>VSCODE PHP DEBUG RELEASE MAY 2021</title>
      <dc:creator>Damjan Cvetko</dc:creator>
      <pubDate>Fri, 11 Jun 2021 08:20:58 +0000</pubDate>
      <link>https://dev.to/zobo/vscode-php-debug-release-may-2021-h1j</link>
      <guid>https://dev.to/zobo/vscode-php-debug-release-may-2021-h1j</guid>
      <description>&lt;p&gt;This is a small writeup on the May 2021 release of VSCode PHP Debug adapter extension. A cover issue describing all work can be found on &lt;a href="https://github.com/xdebug/vscode-php-debug/issues/575"&gt;GitHub issues&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switch to Xdebug 3 port
&lt;/h2&gt;

&lt;p&gt;Since Xdebug 2 has been deprecated for a while now, this plugin has switched to default port 9003 - from previous, 9000. The change in Xdebug was introduced by Derick due to often conflicting default PHP-FCGI port also being 9000.&lt;/p&gt;

&lt;p&gt;Now when a new &lt;code&gt;launch.json&lt;/code&gt; file is created, the default listen port will be 9003.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FDf_HY78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ql2gid61tefc55druyj2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FDf_HY78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ql2gid61tefc55druyj2.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto local port
&lt;/h2&gt;

&lt;p&gt;This feature allows the user to explicitly set &lt;code&gt;port&lt;/code&gt; parameter to &lt;code&gt;0&lt;/code&gt; and this instruct the operating system to allocate a random TCP port to listen on. There are two reasons for this feature/change.&lt;/p&gt;

&lt;p&gt;First this is a stepping-stone for implementing DBGp Proxy support. In that case you should use a random local port because more than one user can be working on one system and the well-defined port 9003 is already used by the proxy.&lt;/p&gt;

&lt;p&gt;Second this gives a nice way to completely separate debugging of &lt;em&gt;Launch currently open script&lt;/em&gt;. Let me explain.&lt;/p&gt;

&lt;p&gt;Xdebug/DBGp debugging works so that the debugging engine (PHP+Xdebug) connect back to the IDE (VSCode and this extension). This means that the IDE must LISTEN on a TCP port and the engine connect to that port. This extension must implement &lt;a href="https://microsoft.github.io/debug-adapter-protocol/"&gt;Microsoft Debug Adapter Protocol&lt;/a&gt; and the way things are designed different debugging sessions cannot interact with each other.&lt;/p&gt;

&lt;p&gt;When launching a script for debugging the DAP instance creates a process, tacks is and at the same time creates a DBGp listener and waits for the Engine to connect. What if you want to debug two scripts in parallel?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can start the &lt;em&gt;Listen for Xdebug&lt;/em&gt; configuration and run both scripts from command line, but the adapter cannot track their execution and display output. That might be ok for a lot of cases.&lt;/li&gt;
&lt;li&gt;If you try to start two of them in the IDE, you will get a PORT IN USE error for the second, because the first debug session is already listening for connections. You can create a different debug configuration and specify a different &lt;code&gt;port&lt;/code&gt;. And then also ask the second php script to connect to that different port. So, possible, but a hassle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The solution for this is to allocate a random port and pass the port configuration to the script.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XTDp1gP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gj2e0dogl9ggijs73jo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XTDp1gP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gj2e0dogl9ggijs73jo2.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What happens here is that using the environment variables we configure Xdebug to start the debugging process right away and with correct port. See &lt;a href="https://xdebug.org/docs/all_settings#XDEBUG_CONFIG"&gt;Xdebug docs&lt;/a&gt;. So the only thing that needs to be taken care of is to make sure that Xdebug extension is loaded into PHP. Even that could be solved with &lt;code&gt;runtimeArgs&lt;/code&gt; if we made sure that the downloaded &lt;code&gt;xdebug.so&lt;/code&gt; is in the right place.&lt;/p&gt;

&lt;p&gt;Of course, all these defaults can be changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built-in webserver start configuration
&lt;/h2&gt;

&lt;p&gt;The third configuration change is the PHP built-in web server. There is a generic &lt;code&gt;launch.json&lt;/code&gt; attribute &lt;code&gt;serverReadyAction&lt;/code&gt;. It is used for this specific situation, where you run a program that exposes a web server and the IDE detects the host/port combination and opens a web browser.&lt;/p&gt;

&lt;p&gt;You could already use the &lt;em&gt;launch&lt;/em&gt; configuration to start the Built-in server, but as a requirement you needed to pass a router script. This limitation was removed and an example configuration is now provided.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--49UbQ3dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14njgexlkkpcfvay0m4s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--49UbQ3dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14njgexlkkpcfvay0m4s.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the DBGp port is fixed (9003) and the web server port is randomized. This can easily be changed to, for example: &lt;code&gt;"localhost:8080"&lt;/code&gt;. The same way a randomized DBGp port could be used by setting &lt;code&gt;"port": 0&lt;/code&gt; and adding &lt;code&gt;env&lt;/code&gt; &lt;code&gt;"XDEBUG_CONFIG": "client_port=${port}"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In fact, if you cluck &lt;code&gt;Add Configuration...&lt;/code&gt; and select &lt;code&gt;Launch Built-in web server&lt;/code&gt; the IDE will guide you through placeholders.&lt;/p&gt;

&lt;p&gt;More on &lt;code&gt;launch.json&lt;/code&gt; attributes can be found in the &lt;a href="https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes"&gt;official documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Launch configuration for Xdebug 2
&lt;/h2&gt;

&lt;p&gt;For legacy support, some Xdebug 2 specific snippets were also provided. They do not appear by default in a newly created &lt;code&gt;launch.json&lt;/code&gt; but can be added later by clicking the &lt;code&gt;Add Configuration...&lt;/code&gt; button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug fixes
&lt;/h2&gt;

&lt;p&gt;A bug in how virtual files were handled was fixed.&lt;/p&gt;

&lt;p&gt;Support for &lt;a href="https://xdebug.org/docs/dbgp#extended-properties"&gt;extended properties&lt;/a&gt; was added and turned on by default. This causes all variable names to be decoded in UTF-8. Altho this is not necessarily correct for all scenarios it does cover a lot of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Default Exception filters
&lt;/h2&gt;

&lt;p&gt;The default exception filers are now turned off by default. This was done to mimic other PHP IDEs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_mrl-KaV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t03uevzxckf3dj9roz0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_mrl-KaV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t03uevzxckf3dj9roz0d.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is currently no real support in VSCode to flexibly control Exception breakpoints. Ideally one could have a way to specifically define what Exception class to break on and wat to ignore. Currently the best thing one can do is use the &lt;code&gt;ignore&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fpoLpos---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0038s5h0qfaeer1ivock.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fpoLpos---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0038s5h0qfaeer1ivock.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Logging
&lt;/h2&gt;

&lt;p&gt;I currently ask users that open bug reports to provide a &lt;code&gt;xdebug.log&lt;/code&gt; output. This shows what DBGp commands were exchanged between Xdebug and this extension. This proved to be problematic in a lot of cases. This is why I decided to included all received DBGp protocol data in the log output. Just add &lt;code&gt;"log": true&lt;/code&gt; to your configuration and you should see a lot of protocol data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Hh605N9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gugrve2hw5vg9d9qh3we.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Hh605N9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gugrve2hw5vg9d9qh3we.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Although not a lot of visible changes in this release, we are one step closer to a more current debug experience while also preparing the field for bigger changes coming ahead. As always drop me a &lt;a href="https://github.com/xdebug/vscode-php-debug/issues"&gt;GitHub issue&lt;/a&gt; if there's something broken or if you can't seem to get debugging to work.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>xdebug</category>
      <category>php</category>
    </item>
    <item>
      <title>Mysterious Camera Pairing</title>
      <dc:creator>Damjan Cvetko</dc:creator>
      <pubDate>Fri, 13 Nov 2020 23:25:53 +0000</pubDate>
      <link>https://dev.to/zobo/mysterious-camera-pairing-2n0g</link>
      <guid>https://dev.to/zobo/mysterious-camera-pairing-2n0g</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a report from my own [blog].(&lt;a href="https://damjan.cvetko.org/blog/2020-11-06-camera-pairing/"&gt;https://damjan.cvetko.org/blog/2020-11-06-camera-pairing/&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;While working on an Android project, one of my tasks was to integrate a home camera into the app. Its a popular Chinese product and the vendor provides an SDK and (barely) some english documentation. The SDK uses an “audio pair” feature, where sound is used to transfer Wi-Fi type, SSID and password information to the camera. However after performing an SDK upgrade the pairing process started to work without sound, like magic. This is a dive into this mystery.&lt;/p&gt;

&lt;h2&gt;
  
  
  The What
&lt;/h2&gt;

&lt;p&gt;For some more context, why this was an “adventure”: The vendor provides the SDK for various platforms, among others: Android, iOS, Windows, Linux. Given that the functionality in the SDK includes at least network protocol implementation, encoding/decoding, remote file handling and device pairing it's almost natural that the bulk of the code would be provided in a cross-platform manner. So the SDK provides a few .so (.dll) libraries and some platform specific wrappers. In case of Android some JNIs. Naturally, the .so files were NOT accompanied by their respective C source equivalent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Why
&lt;/h2&gt;

&lt;p&gt;As said, after an (incompatible) upgrade of the SDK the pairing process changed. There was no more sound that carried the Wi-Fi data, however the camera still received the entered Wi-Fi parameters and successfully connected the the network.&lt;/p&gt;

&lt;p&gt;How is that possible? How could it be? Are the Chinese sending the data over some spy satellite??&lt;/p&gt;

&lt;p&gt;What can a guy do. Reverse it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tools
&lt;/h2&gt;

&lt;p&gt;Seeing as we'll only get an answer from the code this seemed a great opportunity to try out something that just came up on my radar. I read about Ghidra available on &lt;a href="https://ghidra-sre.org/"&gt;https://ghidra-sre.org/&lt;/a&gt;. It's a free and OSS reverse engineering tool from the NSA.&lt;/p&gt;

&lt;p&gt;After struggling a bit with the Java madness, learning about setup, options and navigation, I could look at the (not great, not terrible) restored C code of the pairing routine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Mu8ng8P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c7o3frlpwhxktsffnxqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Mu8ng8P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c7o3frlpwhxktsffnxqx.png" alt="ghidra"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What we can see is that it constructs an address (&lt;code&gt;sprintf&lt;/code&gt;) and sends some static data to it with &lt;code&gt;sendto&lt;/code&gt;, typical for UDP traffic. After digging through some more code I knew that the routine took a pre-constructed byte array of data containing the Wi-Fi parameters and was processing this byte by byte, effectively encoding one byte at a time into the sending address. This can also be seen on a network dump using Wireshark.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QIhP2oFb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/45gnj0j2tulh195gyhpd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QIhP2oFb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/45gnj0j2tulh195gyhpd.png" alt="wireshark"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But for the love of it, how did the Camera, that was not connected to the Wi-Fi, not knowing the encryption parameters of the Wi-Fi, get this information?&lt;/p&gt;

&lt;h2&gt;
  
  
  The How
&lt;/h2&gt;

&lt;p&gt;Actually, after getting this far, I already knew the answer. I knew that 239.x.x.x was Multicast, and that when sending Multicast part of the address gets encoded into the MAC destination. An example for the first packet from Wireshark would read:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Ethernet II, Src: 0x:xx:xx:xx:xx:xx (0x:xx:xx:xx:xx:xx), Dst: IPv4mcast_2d:00:29 (01:00:5e:2d:00:29)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And a little bit of research confirmed the other part pd the mystery. On Wi-Fi, even though we have encryption, the L2 layer, the MAC addresses are actually in plain text.&lt;/p&gt;

&lt;p&gt;This means that the camera can listen on popular Wi-Fi channels for multicast packets, with specific contents. The first 3 MAC octets are &lt;code&gt;01:00:5e&lt;/code&gt; for IPv4 multicast, the forts is a checksum, used to verify the validity of the data, the fifth is a sequence and the last one is the data byte. And each data byte gets sent 4 times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Any technology, no matter how primitive, is magic to those who don't understand it.&lt;/em&gt;&lt;sup id="fnref1"&gt;1&lt;/sup&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
What did I learn: Knowing your basics is important. Ghidra.&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;A variant of Clarke's third law: &lt;a href="https://en.wikipedia.org/wiki/Clarke%27s_three_laws"&gt;https://en.wikipedia.org/wiki/Clarke%27s_three_laws&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>android</category>
      <category>reversing</category>
      <category>ghidra</category>
    </item>
    <item>
      <title>Bridge ssh.exe to Pageant</title>
      <dc:creator>Damjan Cvetko</dc:creator>
      <pubDate>Sat, 22 Jun 2019 22:41:52 +0000</pubDate>
      <link>https://dev.to/zobo/bridge-ssh-exe-to-pagenat-4fhg</link>
      <guid>https://dev.to/zobo/bridge-ssh-exe-to-pagenat-4fhg</guid>
      <description>&lt;p&gt;I do a lot of PHP and was a really early adopter of remote debugging (XDebug) however last few years my work setup just didn't let me do this. Then I wanted to trey Visual Studio Code Remote Development that seem to be just the right thing I was looking for, however there was big red stop light right at the start:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Note: PuTTY is not supported on Windows since the ssh command must be in the path.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This just cant be! I know too much of the SSH protocol to let this stop me.&lt;/p&gt;

&lt;p&gt;The end result of an all-nighter was this script that allowed me to use my existing ssh keys stored in Pageant and try out VS Code Remote...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/zobo/weasel-pagent-win32"&gt;https://github.com/zobo/weasel-pagent-win32&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ssh</category>
      <category>putty</category>
      <category>powershell</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
