<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Paul Sajna&#x27;s Blog</title>
    <link rel="self" type="application/atom+xml" href="https://blog.paulsajna.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.paulsajna.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-10-02T00:00:00+00:00</updated>
    <id>https://blog.paulsajna.com/atom.xml</id>
    <entry xml:lang="en">
        <title>I accidentally a car</title>
        <published>2025-10-02T00:00:00+00:00</published>
        <updated>2025-10-02T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/i-accidentally-a-car/"/>
        <id>https://blog.paulsajna.com/i-accidentally-a-car/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/i-accidentally-a-car/">&lt;p&gt;&lt;strong&gt;Question:&lt;&#x2F;strong&gt; How long does it take to turn lolcatz into production automobiles?
&lt;strong&gt;Answer:&lt;&#x2F;strong&gt; 5 years and 2 days.&lt;&#x2F;p&gt;
&lt;p&gt;Obviously that&#x27;s a ridiculous question with an overly-specific answer. As the description of this blog post (&quot;A surreal
story of Open Source maintainership&quot;), indicates, the whole story you&#x27;re about to read feels equally ridiculous to me.
But that&#x27;s part of what makes it so fun. Those who know me personally probably know I get a bit lost trying to explain
things on the spot, and prefer to contemplate my words longer than realtime speech allows, so it&#x27;s time to get this story
down somewhere people can see it (also a few years late).&lt;&#x2F;p&gt;
&lt;p&gt;Alright, so lolcatz and cars, what? Stay with me here. During Winter break of 2018 (while I was in college),  I posted &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;atsamd-rs&#x2F;atsamd&#x2F;pull&#x2F;31&quot;&gt;a
PR&lt;&#x2F;a&gt; on GitHub to a project called atsamd-rs. A little while earlier, I had
received (free of charge, thanks Scott Shawcroft!) some &lt;a href=&quot;https:&#x2F;&#x2F;adafruit.com&quot;&gt;Adafruit&lt;&#x2F;a&gt; dev boards, in particular,
a &lt;a href=&quot;https:&#x2F;&#x2F;www.adafruit.com&#x2F;product&#x2F;3382&quot;&gt;Metro M4&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;www.adafruit.com&#x2F;product&#x2F;3333&quot;&gt;Circuit Playground
Express&lt;&#x2F;a&gt;, and a &lt;a href=&quot;https:&#x2F;&#x2F;www.adafruit.com&#x2F;product&#x2F;3403&quot;&gt;Feather M0 Express&lt;&#x2F;a&gt;.
A lot of people use their early 20s and college years as a time to experiment. For me, in 2018, that meant trying out
hot new programming languages, Go and Rust. I fell in love with &lt;a href=&quot;https:&#x2F;&#x2F;rust-lang.org&quot;&gt;Rust&lt;&#x2F;a&gt;, made some contributions to &lt;a href=&quot;https:&#x2F;&#x2F;redox-os.org&quot;&gt;Redox
OS&lt;&#x2F;a&gt;, and continued exploring, particularly in the realm of &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;embedded-book&quot;&gt;Embedded
Rust&lt;&#x2F;a&gt;. My programming journey has been characterized by a need to unravel
abstractions and see what&#x27;s beneath them. I had been programming for roughly 10 years in my spare time by 2018, so I was
pretty deep below the surface-level abstractions, close to the metal, at the level of microcontrollers.
Anyway, I had some adafruit dev boards, and I wanted to try embedded rust. For the Circuit Playground Express and the
Feather M0, the underlying microcontroller a Microchip&#x2F;Atmel SAM D21, was supported by the atsamd-rs project already,
so I contributed some board-specific support files and examples for the CPX, and reviewed&#x2F;tested Ben Bergman&#x27;s changes to add
the Feather M0. That was a good way to get my feet wet, but the Metro M4 posed a more interesting challenge. It had a
newer, more powerful variant of the Microchip&#x2F;Atmel SAM D family, the SAM D51. The SAM D51 had no HAL (hardware
abstraction layer) support in atsamd-rs, meaning none of the microcontroller functionality had a usable interface for
doing much of anything in Rust. That takes us back to the PR at the start of this long-winded paragraph. By late
December 2018, I had gotten the SAM D51 and Metro M4 roughly working enough to blink an LED, and posted the PR.
There was more to do to get other basics working, but by February 25 2019, I had enough working to draw the following
image to an SSD1306 embedded oled display, and jokingly added a comment to the PR containing the image.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;i_can_haz_merge.jpg&quot; alt=&quot;I can haz cheezburger cat with text &amp;quot;I can haz merge?&amp;quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Ok so that&#x27;s a lolcat, maybe, or is it called happycat? Eh, close enough. But what does any of this rant have to do with
cars? I have an answer, I promise, it&#x27;s coming, but hopefully the way I&#x27;m telling this story expresses how disconnected
I personally feel the two things are. Initially, atsamd-rs was maintained by a gentleman named Wez Furlong, but shortly
after I started contributing, he moved on to his &lt;a href=&quot;https:&#x2F;&#x2F;wezterm.org&#x2F;&quot;&gt;WezTerm&lt;&#x2F;a&gt; project, and I was left to maintain
atsamd-rs, along with some other contributors and maintainers. I continued adding more features, and reviewed a lot of
PRs from other contributors, some of which went way over my head. On March 29th 2021, roughly 2 years after I started
contributing, atsamd-rs received it&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;atsamd-rs&#x2F;atsamd&#x2F;pull&#x2F;424&#x2F;commits&quot;&gt;first commits and PR&lt;&#x2F;a&gt; from Glaeqen and vcchtjader
We didn&#x27;t realize at this time, but the vcc in vcchtjader stands for Volvo Cars Corporation. Check &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;atsamd-rs&#x2F;atsamd&#x2F;commit&#x2F;153099ebb1394e6f394cdead943d4764f81e0b32&quot;&gt;the merge commit
message&lt;&#x2F;a&gt; if you don&#x27;t believe me.
By this time I was getting distracted by other cool rust projects, and starting my career, so I mostly left reviews to
others, and eventually passed maintainership to Bradley Harden, like Wez had passed it to me. So I can&#x27;t take much of
the credit and I don&#x27;t mean to. The blog title &quot;I accidentally a car&quot;, isn&#x27;t an attempt to take credit, it&#x27;s more of a
joke in the style of &quot;I accidentally a word&quot;, like, &quot;where did that come from?&quot;. By September of 2022, Volvo posted &lt;a href=&quot;https:&#x2F;&#x2F;medium.com&#x2F;volvo-cars-engineering&#x2F;why-volvo-thinks-you-should-have-rust-in-your-car-4320bd639e09&quot;&gt;a
blog to Medium&lt;&#x2F;a&gt;
announcing it&#x27;s usage of Rust in cars, and how it was using &quot;an ATMEL&#x2F;Microchip ATSAME chip, and there is an Open Source
project for it.&quot; Props to mvniekerk for adding the ATSAME53 by the way, without which I might not have this story to
tell. The SAM E53 is similar to the SAM D51 in a lot of aspects, and I like to think my addition of SAM D51 set the
stage, but the SAM E53 was the real star of the automotive world. It turns out, very similar chips to those used in
Adafruit dev boards played with by college students, are used in the safety critical automotive industry. Who&#x27;da thunk?&lt;&#x2F;p&gt;
&lt;p&gt;So by September 2022, we were well aware of Volvo&#x27;s involvement, and atsamd-rs was increasingly being used for professional
development, not just in cars either. A little later we learned Volvo was working with Polestar on the Polestar 3, which
finally takes us back to the initial question&#x27;s answer. The &lt;a href=&quot;https:&#x2F;&#x2F;investors.polestar.com&#x2F;news-releases&#x2F;news-release-details&#x2F;polestar-3-production-starts-early-test-production-successful&quot;&gt;Polestar 3 was announced production
ready&lt;&#x2F;a&gt; on February 27th 2024.
5 years and 2 days after I had posted the lolcatz on February 25 2019. Thanks to the atsamd-rs contributors and
maintainers, and especially Volvo employees for putting this wild scenario in my lap. Thanks for reading.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;polestar3.jpg&quot; alt=&quot;Polestar 3&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Redox in your pocket</title>
        <published>2025-09-21T00:00:00+00:00</published>
        <updated>2025-09-21T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/redox-in-your-pocket/"/>
        <id>https://blog.paulsajna.com/redox-in-your-pocket/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/redox-in-your-pocket/">&lt;p&gt;I had the pleasure of going to RustConf 2025 in Seattle this year. During the conference, I met lots of new people, but
in particular, I had the pleasure of spending a large portion of the conference hanging out with Jeremy Soller of Redox
and System76. Eventually, we got chatting about EFI and bootloaders, and my contributions to
&lt;a href=&quot;https:&#x2F;&#x2F;postmarketos.org&quot;&gt;PostmarketOS&lt;&#x2F;a&gt;, and my
experience booting EFI-based operating systems (Linux) on smartphones using &lt;a href=&quot;https:&#x2F;&#x2F;u-boot.org&quot;&gt;U-Boot&lt;&#x2F;a&gt;. &lt;a href=&quot;https:&#x2F;&#x2F;redox-os.org&quot;&gt;Redox OS&lt;&#x2F;a&gt; is also booted via EFI,
and so the nerdsnipe began. Could I run Redox OS on my smartphone the same way I could run PostmarketOS Linux?&lt;&#x2F;p&gt;
&lt;p&gt;Spoilers, yes.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;redox_bbry.jpg&quot; alt=&quot;Image of Redox OS Login prompt on Blackberry KEY2 LE&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This blog post will document the process I took to get it to boot, so that others can hopefully follow in my footsteps
and improve some of the challenges I bumped up against, and maybe even contribute drivers and further the support.
It will be a little handwavey and assume a high level of knowledge in some areas, because it is written for developers,
and I don&#x27;t want to explain every little detail.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;step-1-das-u-boot&quot;&gt;Step 1: Das U-Boot&lt;&#x2F;h2&gt;
&lt;p&gt;As alluded to in the introduction, U-Boot is a critical part of getting this to work. PostmarketOS developers (and
others), have created compatible Qualcomm U-Boot Android bootimg for a handful of devices. This work is very much
ongoing and scattered, but a few places to look include:
&lt;a href=&quot;https:&#x2F;&#x2F;wiki.postmarketos.org&#x2F;wiki&#x2F;Main_Page&quot;&gt;the PostmarketOS wiki&lt;&#x2F;a&gt;,
&lt;a href=&quot;https:&#x2F;&#x2F;www.linaro.org&#x2F;blog&#x2F;initial-u-boot-release-for-qualcomm-platforms&#x2F;&quot;&gt;the U-Boot Qualcomm blogpost by Linaro&lt;&#x2F;a&gt;
&lt;a href=&quot;https:&#x2F;&#x2F;gitlab.postmarketos.org&#x2F;tauchgang&#x2F;u-boot&#x2F;-&#x2F;pipelines&quot;&gt;Tauchgang&lt;&#x2F;a&gt;
&lt;a href=&quot;https:&#x2F;&#x2F;matrix.to&#x2F;#&#x2F;#u-boot-qcom:postmarketos.org&quot;&gt;U-Boot Qualcomm matrix channel&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Now, we&#x27;ll assume those resources are sufficient, and that you have a U-Boot Android Bootimg for the device in question.
The first thing to do is get into fastboot (refer to postmarketos wiki), and flash the U-Boot image to your boot
partition. We&#x27;ll also assume you have backed up any internal storage you want to keep from your device.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;THE FOLLOWING WILL OVERWRITE INTERNAL STORAGE AND YOU COULD BREAK THE PHONE, PLEASE TAKE APPROPRIATE PRECAUTIONS&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;fastboot&lt;&#x2F;span&gt;&lt;span&gt; erase dtbo
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;fastboot&lt;&#x2F;span&gt;&lt;span&gt; flash boot &#x2F;tmp&#x2F;u-boot.img
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;fastboot&lt;&#x2F;span&gt;&lt;span&gt; reboot
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now the device will boot into U-Boot, and for most Qualcomm phones you have to hold volume up while U-Boot is booting
to get a menu.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;u_boot_menu.jpg&quot; alt=&quot;Image of U-Boot menu&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Select USB Mass Storage in this menu (use volume and power to navigate), plug in a USB cable, and your phone&#x27;s internal storage should show up as a series
of partitions on your computer.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;step-2-flash-and-hack-redox-image&quot;&gt;Step 2: Flash and Hack Redox image&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Download the latest AARCH64 Redox Desktop live iso from &lt;code&gt;https:&#x2F;&#x2F;static.redox-os.org&#x2F;img&#x2F;aarch64&#x2F;&lt;&#x2F;code&gt;
(currently at time of writing https:&#x2F;&#x2F;static.redox-os.org&#x2F;img&#x2F;aarch64&#x2F;redox_desktop_aarch64_2025-09-21_91_redox-live.iso.zst)&lt;&#x2F;li&gt;
&lt;li&gt;Uncompress the zstd image &lt;code&gt;zstd -d redox_desktop_aarch64_2025-09-21_91_redox-live.iso.zst&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Loopback mount the image &lt;code&gt;losetup -f -P redox_desktop_aarch64_2025-09-21_91_redox-live.iso&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Now we have the individual partitions of the redox image ready to flash and change on the phone.
We&#x27;ll be overwriting the phone&#x27;s storage once again, so ensure you have a copy of whatever you want to keep.&lt;&#x2F;p&gt;
&lt;p&gt;Alright then, choose a couple small partitions that are big enough on the phone&#x27;s internal storage, in my case that&#x27;s
cache and system but in your case it might be different.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;dd&lt;&#x2F;span&gt;&lt;span&gt; if=&#x2F;dev&#x2F;loop0p2 of=&#x2F;dev&#x2F;disk&#x2F;by-partlabel&#x2F;cache bs=8M oflag=direct status=progress
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;dd&lt;&#x2F;span&gt;&lt;span&gt; if=&#x2F;dev&#x2F;loop0p3 of=&#x2F;dev&#x2F;disk&#x2F;by-partlabel&#x2F;system bs=8M oflag=direct status=progress
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now we need to mount the partitions we just flashed onto the phone and make some changes.&lt;&#x2F;p&gt;
&lt;p&gt;Perhaps eventually Redox will support split images, and the problems I uncovered with the bootloader and pcid will be
fixed, and this will all be redundant.&lt;&#x2F;p&gt;
&lt;p&gt;The RedoxFS filesystem isn&#x27;t natively supported under Linux, but can be mounted as a Filesystem-in-userspace by running
the redoxfs command from the following repo https:&#x2F;&#x2F;gitlab.redox-os.org&#x2F;redox-os&#x2F;redoxfs&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;mnt&#x2F;redox-boot
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;mnt&#x2F;redox-root
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;mount&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;dev&#x2F;disk&#x2F;by-partlabel&#x2F;cache &#x2F;mnt&#x2F;redox-boot
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;redoxfs&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;dev&#x2F;disk&#x2F;by-partlabel&#x2F;system &#x2F;mnt&#x2F;redox-root
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Copy the DTB for your phone (from postmarketos or u-boot) to the boot partition
&lt;code&gt;cp u-boot&#x2F;.output&#x2F;dts&#x2F;dt.dtb &#x2F;mnt&#x2F;redox-boot&#x2F;dt.dtb&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The Redox bootloader does some weird stuff when parsing DTBs, and I hacked around it to get things working.
My patch doesn&#x27;t make a lot of sense so I haven&#x27;t upstreamed it yet, but basically it turns all reads into 32-bit.
Apply the following patch to the bootloader, recompile it, and copy it over the existing one.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;gitlab.redox-os.org&#x2F;redox-os&#x2F;bootloader
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span&gt; bootloader
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;vim&lt;&#x2F;span&gt;&lt;span&gt; bootloader.patch
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;diff&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-diff &quot;&gt;&lt;code class=&quot;language-diff&quot; data-lang=&quot;diff&quot;&gt;&lt;span&gt;diff --git a&#x2F;src&#x2F;os&#x2F;uefi&#x2F;dtb.rs b&#x2F;src&#x2F;os&#x2F;uefi&#x2F;dtb.rs
&lt;&#x2F;span&gt;&lt;span&gt;index 3c7662e..59bf25e 100644
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c594c5;&quot;&gt;--- a&#x2F;src&#x2F;os&#x2F;uefi&#x2F;dtb.rs
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c594c5;&quot;&gt;+++ b&#x2F;src&#x2F;os&#x2F;uefi&#x2F;dtb.rs
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c594c5;&quot;&gt;@@ -46,24 +46,25 @@ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;unsafe fn get_dev_mem_region(fdt: &amp;amp;Fdt) {
&lt;&#x2F;span&gt;&lt;span&gt;             }
&lt;&#x2F;span&gt;&lt;span&gt;         };
&lt;&#x2F;span&gt;&lt;span&gt;         let parent_bus_addr = {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            if cell_sizes.address_cells == 1 {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                BE::read_u32(&amp;amp;chunk[4..8]) as u64
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            } else if cell_sizes.address_cells == 2 {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                BE::read_u32(&amp;amp;chunk[8..16]) as u64
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            } else {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                DEV_MEM_AREA.clear();
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                return;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            }
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;+                BE::read_u32(&amp;amp;chunk[0..4]) as u64
&lt;&#x2F;span&gt;&lt;span&gt;         };
&lt;&#x2F;span&gt;&lt;span&gt;         let addr_size = {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            if cell_sizes.size_cells == 1 {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                BE::read_u32(&amp;amp;chunk[8..12]) as u64
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            } else if cell_sizes.size_cells == 2 {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                BE::read_u32(&amp;amp;chunk[16..20]) as u64
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            } else {
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                DEV_MEM_AREA.clear();
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-                return;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;-            }
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;+            BE::read_u32(&amp;amp;chunk[0..4]) as u64
&lt;&#x2F;span&gt;&lt;span&gt;         };
&lt;&#x2F;span&gt;&lt;span&gt;         println!(
&lt;&#x2F;span&gt;&lt;span&gt;             &amp;quot;dev mem 0x{:08x} 0x{:08x} 0x{:08x}&amp;quot;,
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; apply bootloader.patch
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;make&lt;&#x2F;span&gt;&lt;span&gt; TARGET=aarch64-unknown-uefi BUILD=build
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;cp&lt;&#x2F;span&gt;&lt;span&gt; build&#x2F;bootloader.efi &#x2F;mnt&#x2F;redox-boot&#x2F;EFI&#x2F;BOOT&#x2F;BOOTAA64.EFI
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;pcid fails to launch because Redox doesn&#x27;t have a pci controller for Qualcomm. It doesn&#x27;t need it to boot, but by
default it will try and halt the boot if it fails.
Remove the following line from &lt;code&gt;&#x2F;mnt&#x2F;redox-root&#x2F;usr&#x2F;lib&#x2F;init.d&#x2F;00_drivers&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;pcid-spawner &#x2F;etc&#x2F;pcid.d&#x2F;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Alright, changes made, unmount and let&#x27;s get booting!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;umount&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;mnt&#x2F;redox-root
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;umount&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;mnt&#x2F;redox-boot
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;losetup&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -d&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;dev&#x2F;loop0
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;step-3-boot&quot;&gt;Step 3 boot&lt;&#x2F;h2&gt;
&lt;p&gt;Press volume buttons to exit the usb mass storage function of u-boot, and select the usb serial gadget function
Then we&#x27;ll get to configuring the bootloader.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;u_boot_usb_serial.jpg&quot; alt=&quot;Image of U-Boot usb serial menuitem selected&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;picocom -b 115200 &#x2F;dev&#x2F;ttyACM0
&lt;&#x2F;span&gt;&lt;span&gt;eficonfig
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will bring up the menu to configure EFI, unfortunately the partitions are listed by number rather than name, so
either try a bunch of them until you find the partition redox boot partition, or go back to ums and run &lt;code&gt;blkid&lt;&#x2F;code&gt; to find
it.&lt;&#x2F;p&gt;
&lt;p&gt;Configure roughly as follows:
&lt;img src=&quot;&#x2F;u_boot_efi.jpg&quot; alt=&quot;Image of U-Boot efi configuration&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Then run &lt;code&gt;bootefi bootmgr&lt;&#x2F;code&gt; and the Redox bootloader should start&lt;&#x2F;p&gt;
&lt;p&gt;Press &lt;code&gt;l&lt;&#x2F;code&gt; for live mode when prompted, then press enter&lt;&#x2F;p&gt;
&lt;p&gt;After all that work, it will most likely still be temperamental and require a few retries to boot. There&#x27;s some weird
issue with parsing and mapping the available memory&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;redox_memory_err.jpg&quot; alt=&quot;Image of Redox memory error&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;After a few tries though, it should show the login prompt. This is the end of the road for now, because there are no
touch drivers etc. Until next time.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;redox_bbry.jpg&quot; alt=&quot;Image of Redox OS Login prompt on Blackberry KEY2 LE&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>FPGA MCS6530 RRIOT Replacement Released!</title>
        <published>2025-02-04T00:00:00+00:00</published>
        <updated>2025-02-04T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/fpga-mcs6530-rriot/"/>
        <id>https://blog.paulsajna.com/fpga-mcs6530-rriot/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/fpga-mcs6530-rriot/">&lt;p&gt;&lt;img src=&quot;&#x2F;kim-1-yo6530.jpg&quot; alt=&quot;img&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Today I&#x27;m excited to announce a project I&#x27;ve been working on for over a year is working and ready for early adopters to
play with. Since October 2023, I&#x27;ve been writing FPGA gateware to replicate one of the rarest chips in the
retrocomputing space, the MCS6530 released by MOS.
This chip is featured in the KIM-1 Computer, released in 1975, as well as several other arcade boards from the 70s and
80s.&lt;&#x2F;p&gt;
&lt;p&gt;My project is called yo6530 and it is available on github
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sajattack&#x2F;yo6530&quot;&gt;here&lt;&#x2F;a&gt;. The board it uses is called the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;daglem&#x2F;redip-riot&quot;&gt;reDIP
RIOT&lt;&#x2F;a&gt; and it was designed by  Dag Lem,
creator of the reSID engine used by the VICE C64 emulator.
The board features a Lattice ICE40UP5k FPGA, and the gateware compiles with the opensource toolchains.&lt;&#x2F;p&gt;
&lt;p&gt;I currently have the 6530-002 and 6530-003 variants of this chip
functioning well enough to boot my replica KIM-1 with the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;eduardocasino&#x2F;kim-1&quot;&gt;motherboard&lt;&#x2F;a&gt; designed by
Eduardo Casino.&lt;&#x2F;p&gt;
&lt;p&gt;There is more work to do to support different variants of the 6530 in my project, as well as ironing out any bugs found.
Contributions are welcome on github.&lt;&#x2F;p&gt;
&lt;p&gt;I have more exciting things coming in the world of KIM-1, so stay tuned!
This is just the beginning of what I have coming, but &lt;a href=&quot;http:&#x2F;&#x2F;retro.hansotten.nl&#x2F;6502-sbc&#x2F;6530-6532&#x2F;6530-hardware-emulator-in-fpga-in-40-pin-dip&#x2F;&quot;&gt;people seem to be taking
notice&lt;&#x2F;a&gt;, so I suppose I
should make it official.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Modern Desktop Linux on a Sony PS3 in 2024</title>
        <published>2024-08-18T00:00:00+00:00</published>
        <updated>2024-08-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/ps3-linux/"/>
        <id>https://blog.paulsajna.com/ps3-linux/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/ps3-linux/">&lt;p&gt;Alternate title: 2024 - The year of the linux desktop on a PS3&lt;&#x2F;p&gt;
&lt;p&gt;This guide will show you how to install the latest Debian (trixie&#x2F;sid) distro with a very modern Linux kernel (6.4
currently). The instructions should be pretty much the same going forward beyond these versions in the future.&lt;&#x2F;p&gt;
&lt;p&gt;Why would you want to do that, you may be asking? I don&#x27;t have a great answer but maybe you want to bring new life
to your old console or maybe you just think it&#x27;s cool&#x2F;funny&#x2F;interesting like I do. If you found your way here
you probably don&#x27;t need my weak attempts at justification anyways. I consider many of my projects to be what I&#x27;ve
taken to calling Dada programming (as in &lt;a href=&quot;https:&#x2F;&#x2F;simple.wikipedia.org&#x2F;wiki&#x2F;Dadaism&quot;&gt;Dadaism&lt;&#x2F;a&gt;), but that&#x27;s a blog post
for another time.&lt;&#x2F;p&gt;
&lt;p&gt;So let&#x27;s get on with it then.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;installing-cfw&quot;&gt;Installing CFW&lt;&#x2F;h2&gt;
&lt;p&gt;The first thing you&#x27;ll need to do is install up to date CFW (custom firmware) on your PS3. I used Evilnat CFW but
anything with OtherOS&#x2F;PetitBoot support should work. There&#x27;s a video that shows you how to do that &lt;a href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=LIVu3Px3eXY&quot;&gt;here&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;One thing I ran into while trying to follow that video was that my PS3 didn&#x27;t have recent enough SSL certificates
to browse to the https:&#x2F;&#x2F;www.ps3toolset.com URL. (error code 0x80710a06)
If that&#x27;s the case you may have to update to OFW (official firmware)
4.91 before installing custom firmware, or you can use a reverse proxy. I used a modified version of the script
from &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;41382806&#x2F;reverse-proxy-in-python-3&quot;&gt;this stackoverflow page&lt;&#x2F;a&gt;,
but I no longer have the exact script I used and the more think about it I&#x27;m not really
sure how it works well enough to make a firm recommendation. Proxying http to http to a page that redirects to https???
Sorry, I did something that worked on 4.75 but I really don&#x27;t know how it worked or what it was anymore.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;installing-petitboot-bootloader&quot;&gt;Installing Petitboot Bootloader&lt;&#x2F;h2&gt;
&lt;p&gt;Once you have the custom firmware running, the next step is to set up the bootloader for OtherOS, which is called
Petitboot. You can download it &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Evilnat&#x2F;xai_plugin&#x2F;tree&#x2F;main&#x2F;Petitboot&quot;&gt;here&lt;&#x2F;a&gt;. Whether you download
the NAND or NOR file depends on the model of PS3 you have. You can look up the model number
&lt;a href=&quot;https:&#x2F;&#x2F;www.psdevwiki.com&#x2F;ps3&#x2F;SKU_Models&quot;&gt;here&lt;&#x2F;a&gt;. Put the dtbimage file for your model
on a USB flash drive and plug it into your PS3, then select these options in the XMB in this order.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;cfw_tools.png&quot; alt=&quot;cfw tools&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;otheros_tools.png&quot; alt=&quot;otheros_tools&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;resize_vflash.png&quot; alt=&quot;resize_flash&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;install_petitboot.png&quot; alt=&quot;install_petitboot&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;downloading-tools&quot;&gt;Downloading tools&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;m assuming you have a traditional Linux Desktop PC to set this up on. You&#x27;ll also need an external USB HDD&#x2F;SSD&#x2F;or I
guess a 32GB+ flash drive might work too.&lt;&#x2F;p&gt;
&lt;p&gt;So on your linux workstation, you&#x27;re going to need the following tools to follow along with the rest of this guide.
How you&#x27;ll obtain and configure them is distro-specific, but should be easy enough to search if you have a
moderate level of linux experience.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;git&lt;&#x2F;li&gt;
&lt;li&gt;powerpc64-linux-gnu-gcc ( not powerpc64le-linux-gnu-gcc! )&lt;&#x2F;li&gt;
&lt;li&gt;qemu binfmt (also sometimes called binfmt-misc)&lt;&#x2F;li&gt;
&lt;li&gt;gparted&lt;&#x2F;li&gt;
&lt;li&gt;debootstrap&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;formatting-the-disk&quot;&gt;Formatting the disk&lt;&#x2F;h2&gt;
&lt;p&gt;Whether the disk is MBR or GPT partition table doesn&#x27;t seem to matter. I&#x27;ve heard GPT is recommended
but I used MBR without noticing it and it works fine. Set up the disk with a large ext4 root partition
and a 2GB (or more if you want) swap partition. The PS3 has 256MB of main system RAM and another 256MB
of VRAM that can be used with some manual setup, and you&#x27;ll probably be swapping lots as a result.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;ps3_linux_gparted.png&quot; alt=&quot;ps3_linux_gparted&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Once I formatted the disk as ext4 and tried to boot off it, I got some weird errors from petitboot (or maybe it was the
kernel, I don&#x27;t remember for sure). I had to disable journalling and checksumming in the filesystem to get it to boot&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tune2fs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -O&lt;&#x2F;span&gt;&lt;span&gt; ^metadata_csum &#x2F;dev&#x2F;sdb1 &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;# MAKE SURE YOU REPLACE THIS WITH THE CORRECT BLOCK DEVICE
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tune2fs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -O&lt;&#x2F;span&gt;&lt;span&gt; ^has_journal &#x2F;dev&#x2F;sdb1 &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;# MAKE SURE YOU REPLACE THIS WITH THE CORRECT BLOCK DEVICE
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;cross-compiling-the-kernel&quot;&gt;Cross-Compiling the Kernel&lt;&#x2F;h2&gt;
&lt;p&gt;You might need to download a bunch of other nonsense like yacc and bison for this step, search up the packages
you need to compile a kernel before continuing.&lt;&#x2F;p&gt;
&lt;p&gt;The kernel sources for ps3 linux are available &lt;a href=&quot;https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;geoff&#x2F;ps3-linux.git&#x2F;&quot;&gt;here&lt;&#x2F;a&gt;.
I used the master branch which is currently version 6.4.0 but you&#x27;re welcome to explore some of the other branches&#x2F;tags
if you&#x27;re feeling adventurous. Clone this repo using git.&lt;&#x2F;p&gt;
&lt;p&gt;My kernel config is &lt;a href=&quot;&#x2F;ps3_linux_kernel_config&quot;&gt;here&lt;&#x2F;a&gt;. It&#x27;s similar to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;olin000&#x2F;PS3-Debian&#x2F;blob&#x2F;master&#x2F;boot&#x2F;config-6.3.0&quot;&gt;this
one&lt;&#x2F;a&gt; which itself is derived from the upstream
&lt;a href=&quot;https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;geoff&#x2F;ps3-linux.git&#x2F;tree&#x2F;arch&#x2F;powerpc&#x2F;configs&#x2F;ps3_defconfig&quot;&gt;ps3_defconfig&lt;&#x2F;a&gt;.
My config adds some drivers specific to the usb keyboard I was using because I had issues with that initially. I think
the actual problem I encountered may have been kernel modules not being properly installed, so one of the other configs
would probably work just as well. Place the config in the ps3-linux folder you cloned from git and call it .config (this
will make it a hidden file!). As new kernel options are added you may also need to run&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;make ARCH=powerpc CROSS_COMPILE=&amp;quot;powerpc64-linux-gnu-&amp;quot; olddefconfig
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;to update the config and you can also use &lt;code&gt;menuconfig&lt;&#x2F;code&gt; in place of
&lt;code&gt;olddefconfig&lt;&#x2F;code&gt; to bring up the kernel configuration menu if you have any additional customizations to make.&lt;&#x2F;p&gt;
&lt;p&gt;Once the kernel is configured, run&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;make ARCH=powerpc CROSS_COMPILE=&amp;quot;powerpc64-linux-gnu-&amp;quot; -j$(nproc)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;to compile the kernel&lt;&#x2F;p&gt;
&lt;p&gt;Next you&#x27;ll want to mount the ext4 partition you created on your external disk with gparted so we can install the kernel
to it.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; mkdir &#x2F;mnt&#x2F;ps3linux
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span&gt; ext4 &#x2F;dev&#x2F;sdb1 &#x2F;mnt&#x2F;ps3linux &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;# replace sdb1 with your actual block device
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; mkdir &#x2F;mnt&#x2F;ps3linux&#x2F;boot
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then to actually install the kernel, run&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; make ARCH=powerpc CROSS_COMPILE=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;powerpc64-linux-gnu-&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; INSTALL_PATH=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&#x2F;mnt&#x2F;ps3linux&#x2F;boot&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; install
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; make ARCH=powerpc CROSS_COMPILE=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;powerpc64-linux-gnu-&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; INSTALL_MOD_PATH=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&#x2F;mnt&#x2F;ps3linux&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; modules_install
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;creating-the-rootfs&quot;&gt;Creating the rootfs&lt;&#x2F;h2&gt;
&lt;p&gt;Ok we have the kernel, next up is the userspace! You could probably use any distro that supports PPC64 (big endian) here
but to keep things focused and straightforward I&#x27;ll show you how to set up Debian.&lt;&#x2F;p&gt;
&lt;p&gt;Debian has a tool called debootstrap that it uses to create the rootfs.&lt;&#x2F;p&gt;
&lt;p&gt;You might also be able to use mmdebstrap to install the rootfs and the standard desktop packages together, but I didn&#x27;t try
that, so I&#x27;ll show you what I tried.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;sh&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-sh &quot;&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; apt install debian-ports-archive-keyring
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; debootstrap&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; --arch&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;ppc64&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; --variant&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;buildd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; --keyring&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;usr&#x2F;share&#x2F;keyrings&#x2F;debian-ports-archive-keyring.gpg sid &#x2F;mnt&#x2F;ps3linux https:&#x2F;&#x2F;deb.debian.org&#x2F;debian-ports
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt; -t&lt;&#x2F;span&gt;&lt;span&gt; proc proc &#x2F;mnt&#x2F;ps3linux&#x2F;proc
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; chroot &#x2F;mnt&#x2F;ps3linux
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; apt install debian-ports-archive-keyring
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This creates a very simple small debian install on our external drive, and changes-root (chroots) into it using
qemu-binfmt so we can continue adding things we need.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;configuring-the-rootfs&quot;&gt;Configuring the rootfs&lt;&#x2F;h2&gt;
&lt;p&gt;At this point, you&#x27;ve got a debian install you can add whatever you need to. I&#x27;ll make some recommendations but this
part is very individualized and personal to what you like on your linux systems.&lt;&#x2F;p&gt;
&lt;p&gt;I typically install a text editor (vim), some build tools (build-essential), curl, wget, git, ssh, etc.&lt;&#x2F;p&gt;
&lt;p&gt;You&#x27;re also going to want to configure your users and passwords in this step so you can login when the system boots up
on the ps3.&lt;&#x2F;p&gt;
&lt;p&gt;I installed and ran the &lt;code&gt;tasksel&lt;&#x2F;code&gt; command which is part of the debian installer and gives you a guided menu to install
the default desktop environment and many other default packages.&lt;&#x2F;p&gt;
&lt;p&gt;Lastly, when I was troubleshooting the boot process later on, I noticed I needed to install the &lt;code&gt;login&lt;&#x2F;code&gt; package, because
&lt;code&gt;systemd-logind&lt;&#x2F;code&gt; was somehow broken and I was unable to login to my user accounts.&lt;&#x2F;p&gt;
&lt;p&gt;We&#x27;ll also need to set up the initial ram filesystem (initramfs) which the kernel uses during the boot process&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;mkinitramfs -k -o &#x2F;boot&#x2F;initrd.img 6.4.0+ # replace &amp;#39;6.4.0+&amp;#39; with the kernel version you compiled
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Once you&#x27;re done, run &lt;code&gt;exit&lt;&#x2F;code&gt; to leave the chroot.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;configuring-the-bootloader&quot;&gt;Configuring the bootloader&lt;&#x2F;h2&gt;
&lt;p&gt;Place this bootloader config in &lt;code&gt;&#x2F;mnt&#x2F;ps3linux&#x2F;etc&#x2F;yaboot.conf&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Note this assumes a 1080p screen video mode.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;init-message = &amp;quot;Debian on PS3&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;timeout=5
&lt;&#x2F;span&gt;&lt;span&gt;default=Debian
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;image=&#x2F;boot&#x2F;vmlinux
&lt;&#x2F;span&gt;&lt;span&gt;        label=Debian
&lt;&#x2F;span&gt;&lt;span&gt;        initrd=&#x2F;boot&#x2F;initrd.img
&lt;&#x2F;span&gt;&lt;span&gt;        root=UUID=f9937a76-f7e6-4c7a-a4bd-04820c13d420
&lt;&#x2F;span&gt;&lt;span&gt;        append=&amp;quot;video=ps3fb:mode:133 nomodeset rw&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;image=&#x2F;boot&#x2F;vmlinux
&lt;&#x2F;span&gt;&lt;span&gt;        label=Debian failsafe
&lt;&#x2F;span&gt;&lt;span&gt;        initrd=&#x2F;boot&#x2F;initrd.img
&lt;&#x2F;span&gt;&lt;span&gt;        root=UUID=f9937a76-f7e6-4c7a-a4bd-04820c13d420
&lt;&#x2F;span&gt;&lt;span&gt;        append=&amp;quot;video=ps3fb:mode:133 nomodeset rw memtest noapic noapm nodma nomce net.ifnames=0 nolapic vga=normal&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;image=&#x2F;boot&#x2F;vmlinux.old
&lt;&#x2F;span&gt;&lt;span&gt;        label=Debian old
&lt;&#x2F;span&gt;&lt;span&gt;        initrd=&#x2F;boot&#x2F;initrd.img.old
&lt;&#x2F;span&gt;&lt;span&gt;        root=UUID=f9937a76-f7e6-4c7a-a4bd-04820c13d420
&lt;&#x2F;span&gt;&lt;span&gt;        append=&amp;quot;video=ps3fb:mode:133 nomodeset rw nosplash&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;image=&#x2F;boot&#x2F;vmlinux.old
&lt;&#x2F;span&gt;&lt;span&gt;        label=Debian old failsafe
&lt;&#x2F;span&gt;&lt;span&gt;        initrd=&#x2F;boot&#x2F;initrd.img.old
&lt;&#x2F;span&gt;&lt;span&gt;        root=UUID=f9937a76-f7e6-4c7a-a4bd-04820c13d420
&lt;&#x2F;span&gt;&lt;span&gt;        append=&amp;quot;video=ps3fb:mode:133 nomodeset rw nosplash memtest noapic noapm nodma nomce nolapic vga=normal&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Other video modes may be used by replacing 133 with one of these&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;AUTO Detect Mode:
&lt;&#x2F;span&gt;&lt;span&gt;      0: auto (480i&#x2F;576i if not HDMI)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;60 Hz Broadcast Modes:
&lt;&#x2F;span&gt;&lt;span&gt;      1: 480i    (576 x 384)
&lt;&#x2F;span&gt;&lt;span&gt;      2: 480p    (576 x 384)
&lt;&#x2F;span&gt;&lt;span&gt;      3: 720p   (1124 x 644)
&lt;&#x2F;span&gt;&lt;span&gt;      4: 1080i  (1688 x 964)
&lt;&#x2F;span&gt;&lt;span&gt;      5: 1080p  (1688 x 964)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;50 Hz Broadcast Modes:
&lt;&#x2F;span&gt;&lt;span&gt;      6: 576i    (576 x 460)
&lt;&#x2F;span&gt;&lt;span&gt;      7: 576p    (576 x 460)
&lt;&#x2F;span&gt;&lt;span&gt;      8: 720p   (1124 x 644)
&lt;&#x2F;span&gt;&lt;span&gt;      9: 1080i  (1688 x 964)
&lt;&#x2F;span&gt;&lt;span&gt;      10: 1080p  (1688 x 964)
&lt;&#x2F;span&gt;&lt;span&gt;VESA Modes:
&lt;&#x2F;span&gt;&lt;span&gt;      11: wxga   (1280 x 768)
&lt;&#x2F;span&gt;&lt;span&gt;      12: sxga   (1280 x 1024)
&lt;&#x2F;span&gt;&lt;span&gt;      13: wuxga  (1920 x 1200)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;60 Hz Full Screen Broadcast Modes:
&lt;&#x2F;span&gt;&lt;span&gt;      129: 480if   (720 x 480)
&lt;&#x2F;span&gt;&lt;span&gt;      130: 480pf   (720 x 480)
&lt;&#x2F;span&gt;&lt;span&gt;      131: 720pf  (1280 x 720)
&lt;&#x2F;span&gt;&lt;span&gt;      132: 1080if (1920 x 1080)
&lt;&#x2F;span&gt;&lt;span&gt;      133: 1080pf (1920 x 1080)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;50 Hz Full Screen Broadcast Modes:
&lt;&#x2F;span&gt;&lt;span&gt;      134: 576if   (720 x 576)
&lt;&#x2F;span&gt;&lt;span&gt;      135: 576pf   (720 x 576)
&lt;&#x2F;span&gt;&lt;span&gt;      136: 720pf  (1280 x 720)
&lt;&#x2F;span&gt;&lt;span&gt;      137: 1080if (1920 x 1080)
&lt;&#x2F;span&gt;&lt;span&gt;      138: 1080pf (1920 x 1080)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;boot-penguin-penguin-tada&quot;&gt;Boot 🐧🐧 🎉&lt;&#x2F;h2&gt;
&lt;p&gt;With all that set up, you should be ready to unplug the external drive from your linux workstation,
plug it and a usb keyboard into your PS3, and select the &quot;Set OtherOS boot flag&quot; option in the
menu we previously used to install petitboot. Petitboot will present the bootloader options
we&#x27;ve just configured, you can select one of them to boot. Hopefully you see the happy Tux penguins during boot and land
at a login prompt. Happy Linuxing!&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;ps3_linux_moneyshot.png&quot; alt=&quot;moneyshot&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;miscellaneous-notes&quot;&gt;Miscellaneous Notes&lt;&#x2F;h2&gt;
&lt;p&gt;You can use PS3 vram as swap by following &lt;a href=&quot;https:&#x2F;&#x2F;www.horan.hk&#x2F;blog&#x2F;ps3-linux-vram&#x2F;&quot;&gt;this guide&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;You may also need to set up &#x2F;etc&#x2F;fstab to take advantage of the swap partition you configured earlier.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;references-kudos&quot;&gt;References&#x2F;Kudos&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;sourceforge.net&#x2F;p&#x2F;redribbon&#x2F;wiki&#x2F;Home&#x2F;&quot;&gt;https:&#x2F;&#x2F;sourceforge.net&#x2F;p&#x2F;redribbon&#x2F;wiki&#x2F;Home&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;olin000&#x2F;PS3-Debian&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;olin000&#x2F;PS3-Debian&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.psx-place.com&#x2F;threads&#x2F;cfw-4-91-2-evilnat-cobra-8-5-beta10-cex-dex-pex-d-pex.39743&#x2F;&quot;&gt;EvilNat CFW&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;wiki.debian.org&#x2F;PPC64&quot;&gt;https:&#x2F;&#x2F;wiki.debian.org&#x2F;PPC64&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>PSP Reverse Engineering - Choose your words wisely</title>
        <published>2021-03-23T00:00:00+00:00</published>
        <updated>2021-03-23T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/words/"/>
        <id>https://blog.paulsajna.com/words/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/words/">&lt;blockquote&gt;
&lt;p&gt;“Words have a magical power. They can either bring the greatest happiness or the deepest despair.” -Sigmund Freud&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;&#x2F;h2&gt;
&lt;p&gt;What went wrong when I initially tested my Rust nidcracker program? As I
mentioned in the original post, high entropy and a small hash == garbage output.
The high entropy problem comes from using every permutation of 4 words from
1000 words (give or take).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-solution&quot;&gt;The solution&lt;&#x2F;h2&gt;
&lt;p&gt;How can we solve it? Simple, use a shorter, more carefully crafted wordlist.
User Meeeow in
&lt;a href=&quot;https:&#x2F;&#x2F;discord.gg&#x2F;bePrj9W&quot;&gt;The PSP Homebrew Discord Server&lt;&#x2F;a&gt;,
One of the main contributors behind &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;uofw&#x2F;uofw&quot;&gt;UOFW&lt;&#x2F;a&gt;, used
my same exact nidcracker program from the previous post, combined with some
knowledge of what the functions with unknown NIDs did, chose specific words
related to what the functions were doing, and successfully cracked a few unknown
NIDs.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;found match: 0x7939C851 = sceChkregGetPspModel
&lt;&#x2F;span&gt;&lt;span&gt;found match: 0x6894A027 = sceChkregGetPsFlags
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;lessons&quot;&gt;Lessons&lt;&#x2F;h2&gt;
&lt;p&gt;The first lesson is, with the right wordlist, these NIDs can be cracked,
and there&#x27;s absolutely nothing wrong with my program, but with the approach
I took to creating the wordlist for it. In the first blog post, I basically
alleged that NIDs couldn&#x27;t be cracked without the results being meaningless.
I now know this is not the case. In fact, watch what happens if I cheat a bit
and use known nids, with a wordlist built from words in those known NIDs.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;found match: ED1410E0 = sceKernelDeleteFpl
&lt;&#x2F;span&gt;&lt;span&gt;found match: 86255ADA = sceKernelDeleteMbx
&lt;&#x2F;span&gt;&lt;span&gt;found match: 6B2371C2 = sceKernelDeleteModule
&lt;&#x2F;span&gt;&lt;span&gt;found match: F8170FBE = sceKernelDeleteMutex
&lt;&#x2F;span&gt;&lt;span&gt;found match: 28B6489C = sceKernelDeleteSema
&lt;&#x2F;span&gt;&lt;span&gt;found match: 9FA03CD3 = sceKernelDeleteThread
&lt;&#x2F;span&gt;&lt;span&gt;found match: 32BF938E = sceKernelDeleteTlspl
&lt;&#x2F;span&gt;&lt;span&gt;found match: 89B3D48C = sceKernelDeleteVpl
&lt;&#x2F;span&gt;&lt;span&gt;found match: 3FC9AE6A = sceKernelDevkitVersion
&lt;&#x2F;span&gt;&lt;span&gt;found match: D636B827 = sceKernelDipswAll
&lt;&#x2F;span&gt;&lt;span&gt;found match: 5282DD5E = sceKernelDipswSet
&lt;&#x2F;span&gt;&lt;span&gt;found match: D774BA45 = sceKernelDisableIntr
&lt;&#x2F;span&gt;&lt;span&gt;found match: 1C46158A = sceKernelDmaExit
&lt;&#x2F;span&gt;&lt;span&gt;found match: 4D6E7305 = sceKernelEnableIntr
&lt;&#x2F;span&gt;&lt;span&gt;found match: 05572A5F = sceKernelExitGame
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Within seconds, we have hundreds of valid nids. (list shortened for blogpost)&lt;&#x2F;p&gt;
&lt;p&gt;That brings me to the second
lesson: test the happy path before giving up. A coworker of mine says the
happy path hides bugs, because it&#x27;s usually the things you don&#x27;t think about
that cause problems in code. But, if we never test the happy path at all,
how can we ever be happy? In the previous blog post, I tested NIDs that had
been uncracked for years, with 1000 words from NIDs we knew, and concluded
that a solution was impossible. I failed to ever test the happy path, and I
was unhappy with the outcome. It seems obvious now.&lt;&#x2F;p&gt;
&lt;p&gt;In conclusion:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Don&#x27;t worry, be happy. -Bob Marley&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;PS: I wrote a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;pspdev&#x2F;hashcat&quot;&gt;hashcat module for NIDs&lt;&#x2F;a&gt; after
I was inspired by the successful outcomes of Meeeow.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>PSP Reverse Engineering - NID Cracking</title>
        <published>2020-10-07T00:00:00+00:00</published>
        <updated>2020-10-07T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.paulsajna.com/nid-cracking/"/>
        <id>https://blog.paulsajna.com/nid-cracking/</id>
        
        <content type="html" xml:base="https://blog.paulsajna.com/nid-cracking/">&lt;h2 id=&quot;what-is-a-nid&quot;&gt;What is a NID?&lt;&#x2F;h2&gt;
&lt;p&gt;A NID, which I believe stands for Name Identifier, is an identifier used in Sony&#x27;s PRX
executable format for function imports and exports. They are located in the .rodata.SceNid
section of every PRX, to identify which operating system or other external functions are
used in the program. A NID consists of the first 4 little-endian bytes of the SHA-1 hash
of the function name, and in later versions of the PSP OS, a salt.  Legend has it,
they can be bruteforced to discover the names Sony used for their functions, to aid in
reverse engineering. Experienced cryptographers would have probably realized the problem
before writing a program to check the results.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;&#x2F;h2&gt;
&lt;p&gt;So it turns out, there are quite a few hash collisions for the first 4 hexadecimal bytes
of a SHA-1 hash. Here are a few of my favourites, which you can check by running
&lt;code&gt;echo -n &amp;lt;name&amp;gt; | sha1sum&lt;&#x2F;code&gt;
on any linux pc (assuming checksum packages are installed). Note that you have to swap
endianness (read the bytes backwards).&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;7CF05E81 = sceSysregAllocateNotifyRapidHead
&lt;&#x2F;span&gt;&lt;span&gt;4C0BED71 = sceSysregAbortFatfmtSteepIn
&lt;&#x2F;span&gt;&lt;span&gt;7CF05E81 = sceSysregActivateDataMbogoPIO
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I purposely chose two here that came up with the same NID for the function name, to
demonstrate the problem of hash collisions. If you&#x27;re following along at home, run the
following at a linux prompt:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;echo -n sceSysregAllocateNotifyRapidHead | sha1sum
&lt;&#x2F;span&gt;&lt;span&gt;echo -n sceSysregActivateDataMbogoPIO | sha1sum
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The results are&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#0f1419;color:#bfbab0;&quot;&gt;&lt;code&gt;&lt;span&gt;815ef07c4b2f44c74cab9af3772c49e49dc41544  -
&lt;&#x2F;span&gt;&lt;span&gt;815ef07cbd77ac3b13f1813c063aff7794960741  -
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It is plain to see  that they start with the same 4 bytes (8 characters), and if you
read the bytes (digit pairs) backwards, you will see the NID. So that&#x27;s no good,
we have multiple possible answers to the same problem, and both of them are nonsensical.
I&#x27;m unsure how functionnames were ever recovered from NIDs, after working through this.
I know some of the function names were leaked in &lt;a href=&quot;&#x2F;blog&#x2F;list&#x2F;&quot;&gt;games with debug symbols&lt;&#x2F;a&gt;,
but that doesn&#x27;t account for all the kernel functions that were never used in games
that have been recovered. Maybe the salts narrow the problem down a bit, I&#x27;m not sure.
I tested without salts, because I was told earlier versions of the kernel didn&#x27;t use them,
with NIDs, and it was easier for me not to.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;methods&quot;&gt;Methods&lt;&#x2F;h2&gt;
&lt;p&gt;So, if you want to try your hand at NID cracking, I&#x27;ll explain what I did in this section.
I wrote a parallelized &lt;a href=&quot;https:&#x2F;&#x2F;rust-lang.org&quot;&gt;Rust&lt;&#x2F;a&gt; program that runs on a modern
desktop CPU. I was planning to later use GPUs for more parallelism&#x2F;speed, but the
ridiculous results I got have me convinced it&#x27;s not worth persuing further.&lt;&#x2F;p&gt;
&lt;p&gt;If you&#x27;re unfamiliar with Rust, you can download it at &lt;a href=&quot;https:&#x2F;&#x2F;rustup.rs&quot;&gt;https:&#x2F;&#x2F;rustup.rs&lt;&#x2F;a&gt;, and learn how to use it at &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;&quot;&gt;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The (slightly messy) source of my program is below:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span&gt;openssl&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;sha&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;sha1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span&gt;rayon&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;prelude&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::*&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span&gt;rayon&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;iter&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;ParallelBridge&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span&gt;std&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;fs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;read_to_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span&gt;itertools&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;Itertools&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ffb454;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span&gt;() {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;&#x2F;&#x2F;let module_names_string = read_to_string(&amp;quot;module-names.txt&amp;quot;).unwrap();
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;&#x2F;&#x2F;let module_names_split = module_names_string.split(&amp;#39;\n&amp;#39;);
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#5c6773;&quot;&gt;&#x2F;&#x2F;let module_names: Vec&amp;lt;&amp;amp;str&amp;gt; = module_names_split.collect();
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; module_name &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;sceSysreg&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;read_to_string&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;wordlist.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist_split &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; wordlist_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;split&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#95e6cb;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#39bae6;&quot;&gt;Vec&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;str&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; wordlist_split&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;collect&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; unknown_nids_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;read_to_string&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;unknown_nids.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; unk_nids_split &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; unknown_nids_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;split&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#95e6cb;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; unk_nids&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;font-style:italic;color:#39bae6;&quot;&gt;Vec&lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;str&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; unk_nids_split&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;collect&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    wordlist&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;par_iter&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;for_each&lt;&#x2F;span&gt;&lt;span&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;word&lt;&#x2F;span&gt;&lt;span&gt;| {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; module_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; word&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; hash &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;sha1&lt;&#x2F;span&gt;&lt;span&gt;(test_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_bytes&lt;&#x2F;span&gt;&lt;span&gt;())&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_nid &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;format!&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{:02X}{:02X}{:02X}{:02X}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        )&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; unk_nids&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()) {
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;found match: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_string)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    })&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist_2perms &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; wordlist
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;permutations&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;par_bridge&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_par_iter&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    wordlist_2perms&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;for_each&lt;&#x2F;span&gt;&lt;span&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;perm&lt;&#x2F;span&gt;&lt;span&gt;| {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; module_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; hash &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;sha1&lt;&#x2F;span&gt;&lt;span&gt;(test_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_bytes&lt;&#x2F;span&gt;&lt;span&gt;())&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_nid &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;format!&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{:02X}{:02X}{:02X}{:02X}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        )&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; unk_nids&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()) {
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;found match: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_string)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    })&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist_3perms &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; wordlist
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;permutations&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;par_bridge&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_par_iter&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    wordlist_3perms&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;for_each&lt;&#x2F;span&gt;&lt;span&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;perm&lt;&#x2F;span&gt;&lt;span&gt;| {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; module_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; hash &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;sha1&lt;&#x2F;span&gt;&lt;span&gt;(test_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_bytes&lt;&#x2F;span&gt;&lt;span&gt;())&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_nid &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;format!&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{:02X}{:02X}{:02X}{:02X}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        )&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; unk_nids&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()) {
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;found match: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_string)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    })&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; wordlist_4perms &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; wordlist
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;permutations&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_iter&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;par_bridge&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;into_par_iter&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    wordlist_4perms&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;for_each&lt;&#x2F;span&gt;&lt;span&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;perm&lt;&#x2F;span&gt;&lt;span&gt;| {
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_string &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; module_name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span&gt;() &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;] &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span&gt; perm[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; hash &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;sha1&lt;&#x2F;span&gt;&lt;span&gt;(test_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_bytes&lt;&#x2F;span&gt;&lt;span&gt;())&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; test_nid &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;format!&lt;&#x2F;span&gt;&lt;span&gt;(
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{:02X}{:02X}{:02X}{:02X}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; hash[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        )&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ff7733;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; unk_nids&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;contains&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span&gt;test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29668;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;as_str&lt;&#x2F;span&gt;&lt;span&gt;()) {
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f07178;&quot;&gt;println!&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;found match: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt; = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f29718;&quot;&gt;{}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_nid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; test_string)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    })&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bfbab0cc;&quot;&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I hard-coded the module name to look for functions of the sceSysreg module for this first
test, and was planning to cover other modules as well. The program then uses rayon&#x27;s parallel iterator and itertools to calculate permutations of a wordlist, and calculates hashes of the permuations with openssl. I used a python program to build a wordlist from known nids (basically splitting camelcase into words), and got some unknown nids from the emulator
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jpcsp&#x2F;jpcsp&#x2F;blob&#x2F;d4c891ec1e9ba820a70a9f17ba0af3295b593c6b&#x2F;src&#x2F;jpcsp&#x2F;HLE&#x2F;modules&#x2F;sceSysreg.java&quot;&gt;JPCSP&lt;&#x2F;a&gt;. My wordlist is at &lt;a href=&quot;&#x2F;wordlist.txt&quot;&gt;wordlist.txt&lt;&#x2F;a&gt; and the nids I chose to crack are at &lt;a href=&quot;&#x2F;unknown_nids.txt&quot;&gt;unknown_nids.txt&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Rust projects also have a Cargo.toml file with basic metadata, which I will supply below&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;toml&quot; style=&quot;background-color:#0f1419;color:#bfbab0;&quot; class=&quot;language-toml &quot;&gt;&lt;code class=&quot;language-toml&quot; data-lang=&quot;toml&quot;&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;package&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;name &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;nidcracker&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;version &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;0.1.0&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;authors &lt;&#x2F;span&gt;&lt;span&gt;= [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;Paul Sajna &amp;lt;sajattack@gmail.com&amp;gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;edition &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;2018&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;dependencies&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;openssl &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;0.10&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;rayon &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;1.4.1&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#59c2ff;&quot;&gt;itertools &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c2d94c;&quot;&gt;&amp;quot;0.8.2&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The latest version of the code is available at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sajattack&#x2F;nidcracker&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;sajattack&#x2F;nidcracker&lt;&#x2F;a&gt;.
Build the project like any other rust project, with &lt;code&gt;cargo build --release&lt;&#x2F;code&gt;, and the binary
will be output as target&#x2F;release&#x2F;nidcracker.&lt;&#x2F;p&gt;
&lt;p&gt;So I ran all this for a few hours, and you can see my results at &lt;a href=&quot;https:&#x2F;&#x2F;gist.github.com&#x2F;sajattack&#x2F;dd4c6df4aec0de8b641216515bdc49ed&quot;&gt;https:&#x2F;&#x2F;gist.github.com&#x2F;sajattack&#x2F;dd4c6df4aec0de8b641216515bdc49ed&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;m not really sure where to go from here. The results are nonsensical so I will have to
find another way to uncover kernel function names. If you have any suggestions feel free
to contact me on &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;sajattack&quot;&gt;Twitter&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
