This is a grey area for piracy since you need to own the ebook but... you also don't really "own" anything purchased in digital distribution and this is removing DRM from that. Suffice to say, if this were Nintendo they would try to sue you so it is probably more piracy than not.
Confirmed working as of a few minutes ago since I wanted to rebuild this with KVM.
Run the Kindle app and disable updating (Tools > Options > General > disable "Automatically install updates..."). Optionally change the save path.
Run the batch script disable_k4pc_download.bat (SHA256 656fbabfa9d1bb3fd1160100391fbf3886597633178e37cffcffe747d3b66567
) under step 2a at https://www.mobileread.com/forums/showthread.php?t=361503 to ACTUALLY disable automatic upgrading
Re-enable networking.
Download and install Calibre. 7.13.0 from https://download.calibre-ebook.com/7.13.0/. This version is known working and all efforts I found used Windows so I went with the msi (SHA256 7c1b57b6f55076cc646a30eb6394ec00df18be373c3badf80d7ee39152ccffda
) since this install exists solely to strip DRM before I then add them to my Calibre-Web server.
Launch Calibre and install the KFX Input plugin from the built in plugin manager
Launch Kindle, login, and download whatever you want to strip DRM from. I did run into some weirdness where I had an exclamation point after logging in but restarting the k4pc app allowed me to download books.
In Calibre, add all the books you downloaded by clicking and dragging the .azw file from Explorer to the Calibre window. You must do this from the downloaded directory as DeDRM is dependent on metadata in the same directory. This can be automated using a batch script pretty trivially.
Then convert them to a non azw3 format (mobi if you are putting it back on a Kindle. epub otherwise).
And then all the epub files in your Calibre library should have had DRM removed and be ready to import into your real Calibre library (or in a random folder on your computer)