<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Projects on kevinv.dev</title>
        <link>https://lastedit.com/categories/projects/</link>
        <description>Recent content in Projects on kevinv.dev</description>
        <generator>Hugo</generator>
        <language>en-us</language>
        <lastBuildDate>Sat, 07 Nov 2026 09:40:00 -0500</lastBuildDate>
        <atom:link href="https://lastedit.com/categories/projects/index.xml" rel="self" type="application/rss+xml" />
        <item>
            <title>Along the Footpath</title>
            <link>https://lastedit.com/p/along-the-footpath/</link>
            <pubDate>Sat, 07 Nov 2026 09:40:00 -0500</pubDate>
            <guid>https://lastedit.com/p/along-the-footpath/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/along-the-footpath/marshy-point.jpg&#34; alt=&#34;&#34; /&gt;&lt;p&gt;I&amp;rsquo;ve started a new site: &lt;a href=&#34;https://alongthefootpath.com&#34;&gt;Along the Footpath&lt;/a&gt;. It&amp;rsquo;s a journal of the trails I walk around Maryland and the mid-Atlantic.&lt;/p&gt;&#xA;&lt;p&gt;Each trail gets its own guide with photos, the trail&amp;rsquo;s stats, a map, and a walking video of the whole route. The videos are on &lt;a href=&#34;https://www.youtube.com/@alongthefootpath&#34;&gt;YouTube&lt;/a&gt;. You can browse every guide on the &lt;a href=&#34;https://alongthefootpath.com/trails/&#34;&gt;trails page&lt;/a&gt;, find one near you on the &lt;a href=&#34;https://alongthefootpath.com/map/&#34;&gt;map&lt;/a&gt;, or look them up by park or place.&lt;/p&gt;&#xA;&lt;p&gt;The two most recent guides are both in Baltimore County: the Choate Mine Trail at Soldiers Delight, which goes through serpentine barrens and some old mining history, and the Vernal Pond Trail at Marshy Point Nature Center, which has plenty of wetlands and birding. There&amp;rsquo;s an &lt;a href=&#34;https://alongthefootpath.com/index.xml&#34;&gt;RSS feed&lt;/a&gt; if you want to follow along as I add more.&lt;/p&gt;&#xA;</description>
        </item>
        <item>
            <title>Traffic Analysis and Timelapse</title>
            <link>https://lastedit.com/p/traffic-analysis-and-timelapse/</link>
            <pubDate>Sun, 17 Sep 2023 08:16:00 -0500</pubDate>
            <guid>https://lastedit.com/p/traffic-analysis-and-timelapse/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/traffic-analysis-and-timelapse/cover.png&#34; alt=&#34;&#34; /&gt;&lt;p&gt;Ever since changing jobs and increasing my commute from 20-30 minutes to 60-90 minutes I&amp;rsquo;ve been searching for the best time to leave to minimize my time in traffic.&lt;/p&gt;&#xA;&lt;p&gt;I started out with using the Waze integration in &lt;a href=&#34;https://www.home-assistant.io&#34;&gt;Home Assistant&lt;/a&gt; to log the drive time according to Waze to and from work throughout the day:&lt;/p&gt;&#xA;&lt;figure class=&#34;post-figure&#34;&gt;&#xA;    &lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/traffic-analysis-and-timelapse/drivetime.png&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/traffic-analysis-and-timelapse/drivetime_hu_f0c5bc1e23b271eb.png&#34; width=&#34;1600&#34; height=&#34;696&#34; alt=&#34;Waze Drive Time&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;Waze Drive Time&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;This was then logged into InfluxDB and graphed with Grafana. However this only really gave me an idea of when the best time to leave was, not the best route to take. What I really wanted to see was how the traffic patterns changed over time because it often seemed that when I left there was almost no traffic and by the time I got halfway to work there was a lot of traffic.&lt;/p&gt;&#xA;&lt;h2 id=&#34;capturing-the-screenshots&#34;&gt;Capturing the Screenshots&lt;/h2&gt;&#xA;&lt;p&gt;So from that I got the idea to try to make a timelapse of the traffic along the route. A quick Google search turned up this article from Browserless which was pretty much exactly what I wanted to do: &lt;a href=&#34;https://www.browserless.io/blog/2022/08/03/how-to-create-time-lapse-traffic/&#34;&gt;https://www.browserless.io/blog/2022/08/03/how-to-create-time-lapse-traffic/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;However that was all Javascript and based on using their browser testing service so I decided to see if there was an easier way to do it locally. Basically what I wanted was to just setup a cron job that ran at a certain interval to save a screenshot of Google Maps with the traffic layer turned on.&lt;/p&gt;&#xA;&lt;p&gt;After some more research I found that &lt;a href=&#34;https://www.selenium.dev&#34;&gt;Selenium&lt;/a&gt; is available for Python and had the ability to load a page in a windowless environment and then save a screenshot of the webpage.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve posted the Python script I wrote to handle the screenshots here: &lt;a href=&#34;https://gist.github.com/KalenXI/4dcfb8df5f72f052b241930459e33b0f&#34;&gt;https://gist.github.com/KalenXI/4dcfb8df5f72f052b241930459e33b0f&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Basically it uses Selenium to load up Chrome in a windowless environment, load the Google Maps page, waits 5 seconds for the page to finish loading, runs some Javascript to hide parts of the Google Maps UI that I don&amp;rsquo;t want in the screenshot and adds a timestamp. Then saves a screenshot of the page to a PNG file.&lt;/p&gt;&#xA;&lt;p&gt;I then set this up as a cron job that runs every minute to take a screenshot of the current traffic. Afterwards you&amp;rsquo;ll end up with a folder full of PNGs with the Unix timestamp.&lt;/p&gt;&#xA;&lt;h2 id=&#34;converting-to-video&#34;&gt;Converting to Video&lt;/h2&gt;&#xA;&lt;p&gt;To make this into a video I wrote a shell script that uses ffmpeg to convert the PNG image sequence into an MP4 video, then deletes all of the source images. And I have that shell script set to run every night at midnight via another cron job.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;&#xA;&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;8&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#!/bin/bash&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; /home/kevin/traffic&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;date_dir&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;$(&lt;/span&gt;date +%F -d yesterday&lt;span class=&#34;k&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ffmpeg -framerate &lt;span class=&#34;m&#34;&gt;25&lt;/span&gt; -pattern_type glob -i &lt;span class=&#34;s1&#34;&gt;&amp;#39;*.png&amp;#39;&lt;/span&gt; -c:v libx264 -crf &lt;span class=&#34;m&#34;&gt;22&lt;/span&gt; -y &lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;date_dir&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;.mp4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rm *.png&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;So every night at midnight I end up with a MP4 file showing the traffic from the previous day like this:&lt;/p&gt;&#xA;&lt;div class=&#34;video-frame&#34;&gt;&#xA;    &lt;video controls preload=&#34;metadata&#34; src=&#34;2023-09-15.mp4&#34;&gt;&#xA;        &lt;a href=&#34;2023-09-15.mp4&#34;&gt;Download the video&lt;/a&gt;&#xA;    &lt;/video&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;h2 id=&#34;analysis&#34;&gt;Analysis&lt;/h2&gt;&#xA;&lt;p&gt;What&amp;rsquo;s especially interesting is that you can actually see the &lt;a href=&#34;https://en.wikipedia.org/wiki/Traffic_wave&#34;&gt;traffic waves&lt;/a&gt; as they propagate backwards from the direction of traffic.&lt;/p&gt;&#xA;&lt;figure class=&#34;post-figure&#34;&gt;&#xA;    &lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/traffic-analysis-and-timelapse/trafficwaves.gif&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/traffic-analysis-and-timelapse/trafficwaves.gif&#34; width=&#34;414&#34; height=&#34;258&#34; alt=&#34;Traffic Waves&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;Traffic Waves&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;And you can also see the effect of heavy storms as they pass through.&lt;/p&gt;&#xA;&lt;div class=&#34;video-frame&#34;&gt;&#xA;    &lt;video controls preload=&#34;metadata&#34; src=&#34;storms.mp4&#34;&gt;&#xA;        &lt;a href=&#34;storms.mp4&#34;&gt;Download the video&lt;/a&gt;&#xA;    &lt;/video&gt;&#xA;&lt;/div&gt;&#xA;&#xA;</description>
        </item>
        <item>
            <title>Reverse Engineering NissanConnect</title>
            <link>https://lastedit.com/p/reverse-engineering-nissanconnect/</link>
            <pubDate>Fri, 18 Nov 2022 15:00:09 -0500</pubDate>
            <guid>https://lastedit.com/p/reverse-engineering-nissanconnect/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/app-screen.png&#34; alt=&#34;&#34; /&gt;&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;&#xA;&lt;p&gt;Back in 2020 I wanted to find a way to integrate my car&amp;rsquo;s auto-start capability into my Home Assistant setup so that I could have Home Assistant auto-start my car when the Waze integration determined it was time for me to leave for work in order to arrive at a certain time.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately as far as I&amp;rsquo;m aware Nissan doesn&amp;rsquo;t provide any kind of official API to tie into what they call their telematics system which is what lets you remote control your car through their NissanConnect app.&lt;/p&gt;&#xA;&lt;p&gt;So first I tried just sniffing the packets coming out of the app and doing a MITM attack. Fortunately for their security, but unfortunately for me they use SSL with key pinning so I wasn&amp;rsquo;t able to glean any useful information that way.&lt;/p&gt;&#xA;&lt;p&gt;Then it occurred to me that since it was available as a free Android app it&amp;rsquo;d be fairly trivial to decompile the apk file and from there I could just reverse engineer their entire protocol.&lt;/p&gt;&#xA;&lt;p&gt;Long story short it turns out the protocol was fairly simple and just required sending my NissanConnect username and password and getting a token in return. So I took what I learned and wrote it into a &lt;a href=&#34;https://github.com/KalenXI/NissanConnect&#34;&gt;Python script&lt;/a&gt; I could call from Home Assistant to automate starting my car. I also added the ability for me to send my car commands through a Telegram bot.&lt;/p&gt;&#xA;&lt;h2 id=&#34;version-20&#34;&gt;Version 2.0&lt;/h2&gt;&#xA;&lt;p&gt;This worked great for 2 years then suddenly stopped working one day earlier this year. At first I thought maybe Nissan had just finally blocked the app-ID I was using since the auth API required sending &lt;code&gt;cv.nissan.connect.us.android.25&lt;/code&gt; in the &lt;code&gt;CV-APPID&lt;/code&gt; header and this was hard-coded into their app. So once again I took the latest version of their Android app, decompiled it and pulled the file with the header constants. To my surprise though the app ID hadn&amp;rsquo;t changed, but the base URL for the API had. So I tried changing the base URL in my code as well to no avail.&lt;/p&gt;&#xA;&lt;p&gt;At this point I began to suspect that the API itself had changed, but I was kind of surprised that they would&amp;rsquo;ve just cut off their own app&amp;rsquo;s access. So I tried downloading the previous version of the app from APK Mirror which was only a week or two older than the current version and sure enough that older version wasn&amp;rsquo;t even able to login.&lt;/p&gt;&#xA;&lt;h3 id=&#34;re-reverse-engineering&#34;&gt;Re-Reverse Engineering&lt;/h3&gt;&#xA;&lt;p&gt;So I began the process of re-reverse engineering how their API worked from the source code. Unfortunately their app appears to be a bit of a hodge-podge of different code bases and APIs so it can be hard to tell which calls go with which APIs.&lt;/p&gt;&#xA;&lt;p&gt;After spending a bit of time jumping around through Java calls and definitions I eventually found that they had rearchitected the way that authentication worked on the API to require the app to first retrieve an access token in order to place a call to the endpoint that would allow the user to login. This process involved having the app login itself with some credentials which were hard-coded into the executable.&lt;/p&gt;&#xA;&lt;h3 id=&#34;tracking-down-the-right-api&#34;&gt;Tracking Down the Right API&lt;/h3&gt;&#xA;&lt;figure class=&#34;post-figure&#34;&gt;&#xA;    &lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/invalid-client.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/invalid-client.jpeg&#34; width=&#34;860&#34; height=&#34;431&#34; alt=&#34;Trying to get an access token.&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;Trying to get an access token.&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;p&gt;This turned out to not be quite as easy as I had hoped. Simply passing the hard-coded client ID and secret along with the request just resulted in an &amp;ldquo;Invalid client&amp;rdquo; error. This sent me down a bit of a rabbit hole because I figured given the error message the problem must be with how I&amp;rsquo;m authenticating the app.&lt;/p&gt;&#xA;&lt;p&gt;After spending a few hours hitting dead end after dead end I decided to spend a bit more time tracing exactly what the app is calling for each step of the authentication process. This was when I noticed that the API base-URL I was using was not the only one defined in the BuildConfig. There were in fact 10 different base-URLs each going to a different API. This was a lot different from the older version of the app which only used two API base-urls: one for logging in, one for sending remote commands.&lt;/p&gt;&#xA;&lt;p&gt;Following a bit more digging I finally realized that I was actually using the wrong endpoint for the initial app authentication. I had been using &lt;code&gt;BASE_URL&lt;/code&gt; which I suppose is the generic endpoint, what I should have been using was &lt;code&gt;CV_BASE_URL&lt;/code&gt;. So I tried again with this new URL.&lt;/p&gt;&#xA;&lt;figure class=&#34;post-figure&#34;&gt;&#xA;    &lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/missing-username.png&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/missing-username_hu_1b2696df7f3ee3b9.png&#34; width=&#34;1600&#34; height=&#34;604&#34; alt=&#34;Once more, with the right URL.&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;Once more, with the right URL.&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;h3 id=&#34;not-quite-authenticated-enough&#34;&gt;Not Quite Authenticated Enough&lt;/h3&gt;&#xA;&lt;p&gt;Close but no luck. This was at least a slightly more helpful error message. I knew I needed to provide a username and presumably a password. So I first tried providing the username and password I use to login to the NissanConnect app since this was previously all the old API required. This at least got rid of the missing username error, but just resulted in another error:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;&#xA;&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;error_description&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Authentication Failed&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;error&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;invalid_grant&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;So what username and password was it looking for? Luckily this was fairly easy to find, as this was also hard-coded into the app&amp;rsquo;s source code. As it turns out, not only do you need an OAuth-style client ID and client secret, but the app itself also has it&amp;rsquo;s own username and password that it uses to login to the API in order to get its initial auth token. Personally this seems incredibly redundant to me. Requiring what is essentially two usernames and two passwords to login to the API isn&amp;rsquo;t any more secure than just one ID and secret when both of them are hard-coded in plain text into the source code, but I guess it made sense to someone at SiriusXM.&lt;/p&gt;&#xA;&lt;p&gt;Newly equipped with my dual username, password, and a slightly lower level of respect for the API developers I tried again and got this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;&#xA;&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;error_description&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;No scope requested and no default scope configured&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;error&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;invalid_scope&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;Getting closer. Now there were a couple of different &amp;ldquo;scopes&amp;rdquo; available to choose from in the source code. At first I just tried passing &lt;code&gt;openid&lt;/code&gt; as the scope since I figured that&amp;rsquo;s all I needed for logging in. Nope, I actually needed to include a few more keywords I don&amp;rsquo;t understand. Then I tried passing in &lt;code&gt;openid tes cps&lt;/code&gt;. What are TES and CPS? No idea. But finally:&lt;/p&gt;&#xA;&lt;figure class=&#34;post-figure&#34;&gt;&#xA;    &lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/access-token.png&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/reverse-engineering-nissanconnect/access-token_hu_1714f3451a043cc4.png&#34; width=&#34;1600&#34; height=&#34;818&#34; alt=&#34;Success!&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;figcaption&gt;Success!&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;h3 id=&#34;login-to-the-login&#34;&gt;Login to the Login&lt;/h3&gt;&#xA;&lt;p&gt;Now we&amp;rsquo;re getting somewhere. But I still hadn&amp;rsquo;t even logged into my account yet. This was all merely to get access to the login API, something that in the previous API version required no authentication at all to access.&lt;/p&gt;&#xA;&lt;p&gt;Luckily the actual login process was fairly similar to the old API. It just required figuring out the correct API base-URL (which for some reason was passed directly into the OpenID function in the session manager rather than being defined as a constant in the BuildConfig file like all of the other base_urls), passing in the auth bearer token from the first authentication step, and providing your actual username and password as a JSON-encoded body of the request.&lt;/p&gt;&#xA;&lt;h3 id=&#34;sending-some-commands&#34;&gt;Sending Some Commands&lt;/h3&gt;&#xA;&lt;p&gt;Finally, equipped with the auth bearer token from the first step, and the &lt;code&gt;id_token&lt;/code&gt; from the second step I could finally send commands to the car. This involved a third separate API, in this case the RTS API. And is just a matter of making a POST request to the particular endpoint for the command you want to send for instance: &lt;code&gt;https://rts.cv000-telematics.net/telematicsservices/v0/vehicles/remote-horn-and-lights&lt;/code&gt;, and including the auth bearer token from the first step, the &lt;code&gt;id_token&lt;/code&gt; from the second step, and your car&amp;rsquo;s VIN along with the command you want to execute in JSON in the request body:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;&#xA;&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2&#xA;&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td class=&#34;lntd&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;command&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;HORN_LIGHT&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;To both mine, and probably my neighbors surprise since I did this at around midnight, the &lt;code&gt;HORN_LIGHT&lt;/code&gt; command does not simply beep the horn once and blink the lights like when you lock the car from the key fob. It actually sets the car alarm off until you send an unlock command.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;At some point I&amp;rsquo;ll probably get around to updating my Python script to use the new API at which point you&amp;rsquo;ll be able to see a bit more about how exactly all of this works. But having spent 3 days figuring out the new API I wanted a bit of a break before delving into how to translate all of this into a Python CLI app. I&amp;rsquo;m also a bit concerned that Nissan will start blocking their client secrets and passwords or making it more difficult to obtain than simply including it as plain-text in the decompiled source code. Not like I wanted to have to decompile their app just to figure all of this out though. I&amp;rsquo;d much rather they provide official support for third-party API access, especially given I&amp;rsquo;m paying something like $12/mo for this service. But that&amp;rsquo;s almost certainly wishful thinking.&lt;/p&gt;&#xA;&lt;p&gt;Until next time.&lt;/p&gt;&#xA;</description>
        </item>
        <item>
            <title>Restoring a 386</title>
            <link>https://lastedit.com/p/restoring-a-386/</link>
            <pubDate>Fri, 16 Sep 2022 01:07:04 -0500</pubDate>
            <guid>https://lastedit.com/p/restoring-a-386/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/cover.jpg&#34; alt=&#34;&#34; /&gt;&lt;p&gt;&lt;span class=&#34;gallery-item&#34; style=&#34;flex-grow: 132&#34;&gt;&lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/restoring-a-386/1.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/1_hu_80ce052ade147f51.jpeg&#34; width=&#34;1600&#34; height=&#34;1205&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;/span&gt; &lt;span class=&#34;gallery-item&#34; style=&#34;flex-grow: 132&#34;&gt;&lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/restoring-a-386/2.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/2_hu_1455cc75b75ae4da.jpeg&#34; width=&#34;1600&#34; height=&#34;1205&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;/span&gt; &lt;span class=&#34;gallery-item&#34; style=&#34;flex-grow: 75&#34;&gt;&lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/restoring-a-386/3.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/3_hu_f5221650a3caad00.jpeg&#34; width=&#34;1600&#34; height=&#34;2125&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;span class=&#34;gallery-item&#34; style=&#34;flex-grow: 75&#34;&gt;&lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/restoring-a-386/4.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/4_hu_2c312690c349318a.jpeg&#34; width=&#34;1600&#34; height=&#34;2125&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;/span&gt; &lt;span class=&#34;gallery-item&#34; style=&#34;flex-grow: 75&#34;&gt;&lt;a class=&#34;lightbox&#34; href=&#34;https://lastedit.com/p/restoring-a-386/5.jpeg&#34;&gt;&lt;img src=&#34;https://lastedit.com/p/restoring-a-386/5_hu_72cd8e6a1c90739b.jpeg&#34; width=&#34;1600&#34; height=&#34;2125&#34; alt=&#34;&#34; loading=&#34;lazy&#34;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&#xA;&lt;p&gt;Been messing around with this 30 year old 386 PC I found hidden under a shelf at work.&lt;/p&gt;&#xA;&lt;p&gt;The 40MB drive in it was still functional and had MS-DOS 6.20 on it along with some networking apps and the drivers for the network card in it.&lt;/p&gt;&#xA;&lt;p&gt;Ended up needing to make a DOS boot disk on a 5.25&amp;quot; floppy to format the CF card I&amp;rsquo;m replacing the HDD with as the 3.5&amp;quot; floppy drive is connected as the B: drive and it will only boot from the A: drive which is the 5.25&amp;quot; drive. Luckily I happen to have a single 1.2MB 5.25&amp;quot; disk in my obsolete media collection and it still worked.&lt;/p&gt;&#xA;&lt;p&gt;Once I got the CF card formatted and working I was able to back up all of the contents on the HDD. Then I wanted to see if I could get it connected to the internet since it had a 10mbps Ethernet adapter. After a bunch of trial and error I finally figured out the right combination of commands to get the network driver loaded and a telnet client working. Was able to connect to some actual BBSes and connect to the terminal for my media server.&lt;/p&gt;&#xA;</description>
        </item>
        <item>
            <title>Video Site Update 2</title>
            <link>https://lastedit.com/p/video-site-update-2/</link>
            <pubDate>Sat, 25 Sep 2021 01:29:00 -0500</pubDate>
            <guid>https://lastedit.com/p/video-site-update-2/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/video-site-update-2/video%20site%20update%202.png&#34; alt=&#34;&#34; /&gt;&lt;p&gt;My video site now has support for logins and video uploads and transcode progress through the web interface.&lt;/p&gt;&#xA;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;&#x9;&#x9;&#x9;&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/wcLqmlncO1w?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;&#xA;&#x9;&#x9;&lt;/div&gt;&#xA;&#xA;</description>
        </item>
        <item>
            <title>Video Site Update 1</title>
            <link>https://lastedit.com/p/video-site-update-1/</link>
            <pubDate>Thu, 16 Sep 2021 22:32:00 -0500</pubDate>
            <guid>https://lastedit.com/p/video-site-update-1/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/video-site-update-1/video%20site%20update%201.png&#34; alt=&#34;&#34; /&gt;&lt;p&gt;After getting fed up with how long YouTube was taking to process my videos and wanting a way to present a video archive to clients without having to pay hundreds of dollars a year for Vimeo I decided to build my own Vimeo-esque video sharing site for myself.&lt;/p&gt;&#xA;&lt;p&gt;The front end is built with Nuxt.js and the backend is written in Python using FastAPI, MongoDB, and Auth0.&lt;/p&gt;&#xA;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;&#x9;&#x9;&#x9;&lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/0VpXJstpvUA?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;&gt;&lt;/iframe&gt;&#xA;&#x9;&#x9;&lt;/div&gt;&#xA;&#xA;</description>
        </item>
        <item>
            <title>Bandersnatch State Engine</title>
            <link>https://lastedit.com/p/bandersnatch-state-engine/</link>
            <pubDate>Sun, 06 Jan 2019 19:10:58 -0500</pubDate>
            <guid>https://lastedit.com/p/bandersnatch-state-engine/</guid>
            <description>&lt;img src=&#34;https://lastedit.com/p/bandersnatch-state-engine/header.png&#34; alt=&#34;&#34; /&gt;&lt;p&gt;Original Reddit Post: &lt;a href=&#34;https://www.reddit.com/r/blackmirror/comments/adbppu/reverse_engineering_the_bandersnatch_state_engine/&#34;&gt;https://www.reddit.com/r/blackmirror/comments/adbppu/reverse_engineering_the_bandersnatch_state_engine/&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So I decided to spend the weekend reverse engineering the state engine that Netflix uses to drive their interactive videos. Unfortunately it got to the point where the boolean branching operations got too complex to do manually. So I figured I&amp;rsquo;d just present what I have so far in case anybody wants to pick up where I left off.&lt;/p&gt;&#xA;&lt;p&gt;The repository with my work so far is here: &lt;a href=&#34;https://github.com/KalenXI/Bandersnatch&#34;&gt;https://github.com/KalenXI/Bandersnatch&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It contains a program written in C# that will take the Bandersnatch JSON data and process it in a variety of ways. It&amp;rsquo;s what I used to generate the 3 text files in the root of the repository:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bandersnatch.json - This is the original JSON metadata pulled from Netflix that defines all of the scenes and the direction each decision will take.&lt;/li&gt;&#xA;&lt;li&gt;Moments.txt - This is a list of all scenes alphabetically including which state variable get set once that scene is entered, the destination scene or scene group for each option, and any self-contained preconditions for entering that scene.&lt;/li&gt;&#xA;&lt;li&gt;States.txt - This is a list of every state variable, which scenes set that variable, and to what. Also includes some notes for what choice each state represents. A lot of them just indicate whether a certain scene has been seen.&lt;/li&gt;&#xA;&lt;li&gt;Preconditions.txt - This is a list of the global branching preconditions for every scene that has them. This is what the branching engine uses to chose which scene to go to when sent to a sequence group.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I also started to make two flow charts defining the possible paths. Page 1 is a non-linear representation and page 2 is a very incomplete linear representation: &lt;a href=&#34;https://www.draw.io/?lightbox=1&amp;amp;highlight=0000ff&amp;amp;edit=_blank&amp;amp;layers=1&amp;amp;nav=1&amp;amp;page=1&amp;amp;title=Bandersnatch.xml#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1NKu-ES-ZXVRLN5cr1D1YEKZwZJGaYbo6%26export%3Ddownload&#34;&gt;https://www.draw.io/?lightbox=1&amp;amp;highlight=0000ff&amp;amp;edit=_blank&amp;amp;layers=1&amp;amp;nav=1&amp;amp;page=1&amp;amp;title=Bandersnatch.xml#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1NKu-ES-ZXVRLN5cr1D1YEKZwZJGaYbo6%26export%3Ddownload&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The non-linear representation breaks at each scene group and you&amp;rsquo;d have to go through the list of preconditions to determine which path would have been followed given the current state of the state variables. The linear representation was my attempt to actually follow all of the possible choices. You can see I only got partly down a single path before I started running into boolean operators for the precondition that looked like this: (((!(p_cm || p_ty) &amp;amp;&amp;amp; !(p_lsd &amp;amp;&amp;amp; p_2b) &amp;amp;&amp;amp; (!(p_2b) || (p_2b &amp;amp;&amp;amp; p_lsd)) &amp;amp;&amp;amp; p_3aj) || (!(p_cm || p_ty) &amp;amp;&amp;amp; !(p_lsd &amp;amp;&amp;amp; p_2b) &amp;amp;&amp;amp; p_2b &amp;amp;&amp;amp; !(p_lsd) &amp;amp;&amp;amp; p_3ah) || (p_cm || p_ty)) &amp;amp;&amp;amp; !(p_3ab || p_3ac || p_3aj || p_3ah || p_3ak || p_3al || p_3af)). At that point it was taking me 15 minutes per branch just to manually translate the prefix boolean JSON notation used in the metadata to the infix boolean notation that Javascript and C# used just to figure out which branch to take so I stopped.&lt;/p&gt;&#xA;&lt;p&gt;In the flow chart:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Rectangles = Sequences, including title, sequence ID, and any state variable that are set by viewing said sequence.&lt;/li&gt;&#xA;&lt;li&gt;Ovals = Choice options branching from the preceding sequence&lt;/li&gt;&#xA;&lt;li&gt;Cylinders = Sequence groups. These are the major components of how the branching engine works. When a choice leads to a sequence group the engine will go down the options one by one comparing the current settings of the state variables to the preconditions for each sequence listed in the sequence group. Once it finds one that returns true it will follow that path.&lt;/li&gt;&#xA;&lt;li&gt;Hexagons = Precondition groups. Once you get to a sequence group you go down through the hexagons from top to bottom until you find a set of preconditions that matches the current state variable state at which point you should branch to the right and jump to that particular sequence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Hopefully someone else finds this interesting as well. The state engine that Netflix built for their interactive stories is amazingly flexible. As you can see from the flow chart there are some scenes that can branch in 12+ different directions depending on exactly what choices the user made. There&amp;rsquo;s (if I&amp;rsquo;m remembering right) 143 sequences with 2 choices each which gives you a theoretical maximum of 2^(143) possible paths. In practice there are fewer paths because some dead end and some loop back on themselves. There are 2^(59)ish or  576 quadrillion possible state engine states with 62 variables (again not all of which are used in practice).&lt;/p&gt;&#xA;</description>
        </item>
    </channel>
</rss>
