apr 19th changes

This commit is contained in:
Left4Code
2025-04-19 23:15:58 -04:00
parent a157f68243
commit 4d055f0712
20 changed files with 2315 additions and 61 deletions

353
blogs/apr-14-2025.html Normal file
View File

@@ -0,0 +1,353 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="This is a guide on using cryptsetup for Linux to encrypt partitions with luks from the command line. This guide will also cover some funny things that can be done with dd and GPG to essentially create a GPG encrypted headerless luks partition. Not practical really, but funny.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Left4Code">
<meta name="keywords" content="cryptsetup, LUKS, headerless, gpg, shufflecake">
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<title>Left4Code - (Blog) - {cryptsetup}</title>
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">Using cryptsetup on Linux</h1>
<h3>--| Posted: 2025-04-14</h3>
<h4 class="blog-header">Table of Contents</h4>
<div id="toc_container">
<hr>
<ul class="toc_list">
<li><a href="#1">1. Background Information</a>
<li><a href="#2">2. Warnings And Precautions</a></li>
<li><a href="#3">3. Installing Cryptsetup</a></li>
<li><a href="#4">4. Setting up a LUKS partition (insecure solution)</a></li>
<li><a href="#5">5. Setting up a LUKS partition (Better Solution)</a></li>
<ul>
<li><a href="#5.1">5.1. Removing Initial Partitions</a></li>
<li><a href="#5.2">5.2. Overwriting All Content on the drive</a></li>
<li><a href="#5.3">5.3. Option 1) Encrypting the Drive (Including LUKS Header)</a></li>
<li><a href="#5.4">5.4. Option 2) Encrypting the Drive (Separate LUKS Header)</a></li>
</ul>
</li>
<li><a href="#6">6. Opening The LUKS Drive</a></li>
<li><a href="#7">7. Mounting the drive</a></li>
<li><a href="#8">8. Making The Filesystem On The Drive</a></li>
<li><a href="#9">9. Closing The LUKS Partition</a></li>
<li><a href="#10">10. Letting Non-Root Users Modify The LUKS Partition</a></li>
</ul>
<hr>
<ul class="toc_list">
<li><a href="#11">11. Expanding on the Silliness with DD and GPG</a></li>
<ul>
<li><a href="#11.1">11.1. DD To Image a drive or partition</a></li>
<li><a href="#11.2">11.2. Mounting the DD Image as a Loopback Device</a></li>
<li><a href="#11.3">11.3. Encrypting the DD file with Symmetric Encryption</a></li>
</ul>
</ul>
<hr>
<ul class="toc_list">
<li><a href="#12">12. Conclusion</a></li>
<li><a href="#13.0">13. Additional Software of Interest</a></li>
</ul>
<hr>
</div>
<h3 id="1" class="blog-header">1. Background Information</h3>
<p>This is a guide on using cryptsetup for Linux to encrypt partitions with luks from the command line. This guide will also cover some funny things that can be done with dd and GPG to essentially create a GPG encrypted headerless luks partition. Not practical really, but funny.</p>
<p>For the readers who don't know, LUKS stands for Linux Unified Key Setup. It is a way to encrypt partitions on Linux to thwart anyone from just hitting the: </p>
<pre class="preformatted">sudo dd if=/dev/your_drive of=/home/hackaroo/your_drive.img</pre>
<p>special secret move on your drive and getting all your data if your machine is ever stolen. Keep in mind that just because you're using LUKS, you're not 100% safe to just leave that USB in the open. If someone knows that there is an encrypted partition there, they might come back for the keys (if you catch my drift) or might try to brute-force it with hashcat, which I will show how to do in the digital forensics course I'm cobbling together at the slowest rate possible.</p>
<h4 id="2" class="blog-header">2. Warnings And Precautions</h4>
<p>If this is the first time you're using cryptsetup, dd, or gpg. It may be wise to spin up a virtual machine using vmware, virtualbox, or qemu-kvm and pass whatever external media you want through it to prevent you from accidentally deleting sensitive files on your host computer like passwords or photos. These tools can be dangerous to data when a lack of user understanding is present. Be smart and careful until you become smart and confident!</p>
<p><b>Also, Don't just copy-paste the commands on this page, learn what they do, then run them, don't run what you can't understand.</b> </p>
<p>And obviously, I'm not responsible if you wipe out your entire drive with your cat photos on it. With that out of the way, we can begin.</p>
<h3 id="3" class="blog-header">3. Installing Cryptsetup</h3>
<p>If you're using apt, you can just run:</p>
<pre class="preformatted">sudo apt install cryptsetup</pre>
<p>Pretty simple, right?</p>
<h3 id="4" class="blog-header">4. Setting Up A LUKS Partition (Insecure Solution)</h3>
<p>First, you would run the command:</p>
<pre class="preformatted">
lsblk </pre>
<p>to identify the Empty USB you want to encrypt. Take the time to unplug the USB then run lsblk again to completely verify which drive the USB is.</p>
<p>The procedure for setting up a LUKS drive is fairly simple, according to the manual, all you need to run is a single command, which is:</p>
<h4>Warning, The Command Below Deletes All Data On A Partition Or Drive.</h4>
<pre class="preformatted">sudo cryptsetup luksFormat /dev/&lt;drive&gt;</pre>
<p>but there's a little more to it than just running the command and being done with it if you want a more secure solution.</p>
<p>What that command is doing under the hood is not as good as you think, because the defaults for cryptsetup are not maximally secure. By default, cryptsetup will create a type1 luks partition which includes the header on the actual partition. (so it can be conventionally decrypted)</p>
<p>If you are doing forensics on an encrypted partition, the only option you might have aside from slapping the suspect around or hitting that partition with a lot of compute power, is to analyze the "metadata" of the partition. This really only is one option, the size of the drive.</p>
<p>When looking at the partition in a hex editor, if the drive was not set up properly, it could be possible to gain some valuable information about the partition too.</p>
<p>If the start and end offset of the partition can be detected, then it can determine what is potentially on that partition. So how do we get around this?</p>
<h3 id="5" class="blog-header">5. Setting Up A LUKS Partition (Better Solution!)</h3>
<h4 id="5.1">5.1. Removing Initial Partitions: (Warning Will Delete All Data)</h4>
<p>A better procedure is to start by first deleting any existing partitions using fdisk, let's first check out the structure of our drive. To do this run the following:</p>
<pre class="preformatted">lsblk</pre>
<p>you'll then see the name of each device, the size of each device and the size of each partition. If you're using a sata USB for example it should show up as /dev/sd&lt;letter&gt;. Once you identify your drive, run the following command:</p>
<pre class="preformatted">sudo fdisk /dev/sd&lt;letter&gt;</pre>
<p>you should now be thrown into the fdisk user menu, if you want a list of the useful fdisk commands, just press the "<b><i>m</i></b>" key! If you have any partitions on your drive, you can delete them by pressing the "<b><i>d</i></b>" key and then selecting the partition number that you want to delete, if you have multiple partitions, repeat this process until they're all gone. When you want to write your final changes, press the "<b><i>w</i></b>" key. If you ever want to quit, just press "<b><i>q</i></b>" and you'll be booted back to the normal bash prompt.</p>
<h4 id="5.2">5.2. Overwriting All Content On The Drive: (dd or shred)</h4>
<p>Because we haven't made a partition and put a filesystem on it, we will interface with the drive directly using /dev. With this part of the guide, it's honestly up to you as to how you want to wipe your drive and what tool you want to use, the two options I like are using dd or shred.
<pre class="preformatted">sudo dd if=/dev/urandom of=/dev/sd[your_driveletter]</pre>
<p>or</p>
<pre class="preformatted">sudo shred -vn &lt;N.O. Drive Passes&gt; /dev/sd&lt;letter&gt;</pre>
<p>This should sufficiently wipe your drive contents enough to stop a forensic investigator from scraping anything off of a drive image which hasn't been deleted and should additionally mask the size of the luks disk.</p>
<h4 id="5.3">5.3. Option 1) Encrypting The Drive: (Including LUKS Header)</h4>
<p>Hopefully at this point everything is working and we're "all systems go!" to encrypt this silly drive. To encrypt the drive, run the luksformat command that I mentioned before. </p>
<pre class="preformatted">sudo cryptsetup luksFormat --type luks2 /dev/sd[your_driveletter]</pre>
<p>This command will include the LUKS header (type 2 or 1) within the partition, so anyone who gets the USB can see that it is password protected, this can be bad if you really don't want anyone to know that the drive is encrypted.</p>
<p>the <b><i>"--type 2"</i></b> flag specifies that we are using luks type 2, which is used with newer devices and manages the LUKS header a little differently. There's also some improvements to Key Derivation functions but it was a little confusing to understand, if you want to read about it some pages I found are below:</p>
<pre class="preformatted">
<a href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup - (Wiki References Are Good)</a>
<a href="https://www.e2encrypted.com/posts/luks-vs-luks2/">https://www.e2encrypted.com/posts/luks-vs-luks2/ - (Some L and L2 Differences)</a>
<a href="https://gitlab.com/cryptsetup/cryptsetup/-/wikis/LUKS-standard/on-disk-format.pdf">https://gitlab.com/cryptsetup/cryptsetup/-/wikis/LUKS-standard/on-disk-format.pdf - (LUKS On Disk Format Spec Sheet)</a>
<a href="https://cdimage.debian.org/pub/debian-meetings/2019/miniconf-hamburg/slides/luks.pdf">https://cdimage.debian.org/pub/debian-meetings/2019/miniconf-hamburg/slides/luks.pdf - (Another Sort-of Spec Sheet)</a></pre>
<h4 id="5.4">5.4. Option 2) Encrypting The Drive: (Separate LUKS Header)</h4>
<p>To encrypt the drive but without including the header on the partition, you can use the <b><i>--header &lt;path/to/header.head&gt;</i></b> flag when using cryptsetup luksFormat, the full command looks like this:</p>
<pre class="preformatted">sudo cryptsetup luksFormat --type luks2 --header &lt;/path/to/header.head&gt; /dev/&lt;letter&gt;</pre>
<p>You'll now notice that there is a file at the path you specified for --header. You should back this up, because it is needed to be specified every time you will decrypt the device. If you try to decrypt the device without this header cryptsetup will say something like "Partition is not LUKS" or something, but once you specify the header, it will prompt for the drive password like normal.</p>
<h4 id="6" class="blog-header">6. Opening The LUKS Drive</h4>
<p>To open the LUKS partition run the following command. If you set up the partition with the --header option, make sure you specify it.</p>
<pre class="preformatted">sudo cryptsetup open /dev&lt;letter&gt; &lt;name_of_mapper_location&gt; </pre>
<p>or</p>
<pre class="preformatted">sudo cryptsetup --header /dev/&lt;path/to/header.head&gt; open /dev/&lt;letter&gt; &lt;name_of_mapper_location&gt; </pre>
<p>upon running this command, the LUKS header should be mapped to /dev/mapper/&lt;name_of_mapper_location&gt;</p>
<h4 id="7" class="blog-header">7. Mounting the drive</h4>
<p>Since we need to use the mapper device, we will run the following command like this:</p>
<pre class="preformatted">sudo mkdir -p /mnt/luks_decrypted</pre>
<p>In this case, I named the mountpoint something unique. Change it to a name that suits your needs. Then to mount, we run:</p>
<pre class="preformatted">sudo mount /dev/mapper/&lt;name_of_mapper_location&gt; /mnt/luks_decrypted</pre>
<p>This command will likely throw out a bad superblock error because there's no filesystem present on it. Let's add it now.</p>
<h4 id="8" class="blog-header">8. Making The Filesystem On The Drive</h4>
<p>Before we can put data on our partition, we need to make a filesystem for it so that it can store our data. There are many different filesystems that you can choose from. I'd personally use ext4 because I don't know if btrfs would work for this, but I haven't bothered to actually try out btrfs. I know there's something potentially cool going on there though. </p>
<p>If you want to make an ext4 partition in the terminal, just go to the mount point and type the following command to make an ext4 filesystem on the encrypted partition:</p>
<pre class="preformatted">sudo mkfs.ext4 /dev/mapper/&lt;name_of_mapper_location&gt;</pre>
<p>now that the filesystem in created, you can use sudo to make directories on the partition, copy files, add new files, remove files, and read files. Lower in the blog, I explain how to change this so you don't need sudo to make changes to the drive. </p>
<p>Something very useful for the GUI people is if you want to be able to modify your encrypted partition with something like thunar, you can mount it to /media/&lt;Your_Host_name&gt;/ and hopefully the drive should appear now, but keep in mind that if you haven't made the necessary changes to modify the decrypted drive without sudo, you'll need to use the GUI file manager with sudo permissions.</p>
<h4 id="9" class="blog-header">9. Closing The LUKS Partition</h4>
<p>To Close the LUKS partition, begin by unmounting the mountpoint that was created earlier using the following command:</p>
<pre class="preformatted">sudo umount /mnt/&lt;Your_mount_point&gt;</pre>
<p>Then running:</p>
<pre class="preformatted">sudo cryptsetup close &lt;Name_of_drive_from /dev/mapper&gt;</pre>
<p>You can finally check if the parition is re-encrypted to your system's view by running lsblk again. Keep in mind that the drive will stay encrypted the entire time on the physical media and is only decrypted on the Linux Desktop's view, so if you need to yank the USB if your media is removable, as long as you're not writing to it, you're good.</p>
<h3 id="10" class="blog-header">10. Letting Non-Root Users Modify The LUKS Partition</h3>
<p>I found that you can make the directory writable by your normal user if you want to not have to use sudo to write to it. The link is:</p>
<pre class="preformatted">
<a href="https://security.stackexchange.com/questions/115326/access-to-mounted-luks-partition-by-non-root-user">https://security.stackexchange.com/questions/115326/access-to-mounted-luks-partition-by-non-root-user</a></pre>
<p>The short and sweet of this is to run the following command:</p>
<pre class="preformatted">
sudo chmod 770 /Your/Folder/Path
sudo chown &lt;USER&gt;:&lt;GROUP&gt; /Your/Folder/Path</pre>
<p>This sets the root and user permissions to be able to read write and execute files on the mount and the owner needs to be set to your current user. With this you should be able to transfer files like is normally done. This same thing can be applied to the /media folder for access with a GUI file manager. If the whole permission thing doesn't work, try to mount the partition in your home folder, it might change things. </p>
<p>If you followed all of the steps, you should now have an encrypted drive that you can store you're awesome hacker cat pictures, link lists, and passwords on without the fear that any random person can mug you for your USB and ruin your life! Congrats! You'll still have to worry about the whole mugging part, but that's a problem for another day, right?</p>
<p>For all intents and purposes, the blog ends here if all you wanted to do was encrypt a USB. I will now be going completely off the rails and show how to do more experimental things with dd, GPG, and losetup, after I'll shout out an experimental piece of software that I learned about which mimics VeraCrypt and you should experiment with yourself.</p>
<h3 id="11" class="blog-header">11. Expanding on the Silliness with DD and GPG</h3>
<p>Remember how I said the forensic investigator could hit the dd special on an improperly configured drive? If you didn't know, you can actually mount .dd image files as physical partitions using a loopback device. So let's try to reverse the dd special on the investigator. If the .dd image is encrypted with a block-based encryption tool like let's say... LUKS! Then we can also employ the standard file-based encryption like ECC or RSA encryption using GPG on top of the .dd file for double encryption and then manually stripping out the GPG header, why do this? Practically, I have no clue other than for the pursuit of learning and because I can use it as an excuse for practice when I make the GPG blog post. It is important to note that plausibly deniable options are not the best for security of your data when given the current options available.</p>
<p>for the purposes of this post, I'm just going to stick with symmetric encryption. It's the easiest way to demonstrate this!</p>
<h4 id="11.1" class="blog-header">11.1. DD To Image a drive or partition</h4>
<p>I have basically already shown this command off before, but to copy every byte from your drive to a file that can be moved around, you can run the following command:</p>
<h3>Warning! Make Sure You Have Sufficient Space In The Destination Location To Hold The Size Of The Drive You're Copying!</h3>
<pre class="preformatted">
sudo dd if=/dev/&lt;your_drive_or_partition&gt; of=&lt;/path/to/where/you/want.dd&gt;</pre>
<p>If you want to see the progress of the transfer, you can append the "status=progress" without the quotes to the end of the previous command to show the status of the transfer!</p>
<p>Now you can put this .dd file anywhere you want! This method can additionally be used to serve as a way to do cloud backups on random services now that I think about it (I do not recommend this, LUKS may one day be broken conventionally by the public, keep your backups of sensitive data offline!), if you don't have a service that can be used to store these files in their original size, you can always use the split command and specify the size you need, small tangent.</p>
<h4 id="11.2" class="blog-header">11.2. Mounting The DD Image as a Loopback Device</h4>
<p>So you just got a .dd image, either it's from someone else or you just made it yourself. Let's try to mount it. </p>
<p>there is a handy command which allows you to mount a .dd image as a loopback device. The program to do this is called <b>losetup</b>, I think it's pronounced lo-setup like loopback setup, and not lose tup, my brain decided to learn it as lose tup and now I can never remember this command when I need it!</p>
<p>the command to mount the .dd file as a loopback device is:</p>
<pre class="preformatted">
sudo losetup -f --show &lt;your_disk_dump.dd&gt; </pre>
<p>-f or --find will find the next available loop device that has not been created and create it.</p>
<p>--show will show the name of the new loopback device that was created.</p>
<p>You will now need to decrypt the new loopback device that you just created, this can be done by running the following command:</p>
<pre class="preformatted">
sudo cryptsetup open /dev/&lt;your_loopback_device&gt; &lt;mapper_point&gt; </pre>
<p>or</p>
<pre class="preformatted">
sudo cryptsetup open /dev/&lt;your_loopback_device&gt; &lt;mapper_point&gt; --header &lt;your/header/location&gt; </pre>
<p>with this, you should be able to use lsblk to see the new decrypted device that was created and mount it. If you don't decrypt the loopback device, then it will read bad superblock and will not mount properly. Also, if you are using this for forensic purposes for some reason, you can use the -r or --read-only parameter to make the loopback device read-only. I haven't really tested it, but give it a try and see what happens!</p>
<p>you will now want to mount the loopback device.</p>
<pre class="preformatted">
sudo mount /dev/&lt;loopback_device&gt; /&lt;your_mountpoint&gt; </pre>
<p>if the loopback device contains an encrypted partition, you can now decrypt it with cryptsetup like before. </p>
<p>Finally, if you want to detach the loopback device, first unmount the partition with umount as described above, but it's far up into the page and I'd be lazy enough to not scroll, so.</p>
<pre class="preformatted">
sudo umount /mnt/&lt;loopback_mountpoint&gt; </pre>
<p>then you want to run the losetup command again with the -d parameter, specifying the specific loopback point you want to detach</p>
<pre class="preformatted">
losetup -d &lt;loop_device&gt; </pre>
<p>and you're home free!</p>
<h4 id="11.3" class="blog-header">11.3 Encrypting the DD file with Symmetric Encryption</h4>
<p>Now, I'll talk about how we can encrypt the .dd file with something like GPG symmetric encryption to style on the forensic investigator after they're already cowering in the corner filling the room with tears.</p>
<p>Obviously, this should probably not be used as a viable method to hide a partition. But ignoring that (because we're cool). Using symmetric GPG is fundamentally insecure, and 4096 bit keys should be used instead, but the command to do the symmetric encryption is pretty simple. It's just:</p>
<pre class="preformatted">
gpg -c &lt;Your_Funny_.dd_monstrosity&gt; </pre>
<p>This will probably take a bit of time to spit out the full encrypted<sup>2</sup> file</p>
<p>To decrypt it, you need to then run:</p>
<pre class="preformatted">
gpg &lt;Your_Funny_.dd_monstrosity.gpg&gt; </pre>
<p>you will then be prompted to enter your password to decrypt the file.</p>
<h4 id="12" class="blog-header">12. Conclusion</h4>
<p>I hope this helped someone get an encrypted USB set up somewhere and you enjoyed reading this as much as I enjoyed writing it (population: 0! My style is kind of boring, I'm working on it.. Not really though.) If you've lurked on this blog more than once, you probably noticed that I added a table of contents to this blog post. Would you believe me if I told you it was generated entirely using Vim in about 10 keystrokes? No? Well I'm only half-lying, but it's what I'll be discussing next. What I've added to my vimrc has increased the ease of writing HTML by a ton. This in combination with something like Hugo or a different site generator would be magic.</p>
<h4 id="13" class="blog-header">13. Additional Software of Interest</h4>
<p>If you're into that whole "Plausible deniability" thing, then I found an up and coming piece of prototype software called <a href="https://shufflecake.net">shufflecake</a>, I recommend reading the entire first web page, it's quite funny.</p>
<p>from the minimal amount of reading I did, this software seems to be VeraCrypt with a fresh coat of paint. Keep in mind it's still in development, but it could be cool to learn about just for the thrill of it. I might even try to demo it at a later point in time.</p>
<p>So go forth, random human or crawler bot! (I managed to get on DuckDuckGo before Google somehow, ducks for them I guess!) Take this knowledge and do something cool with it.</p>
<p>until next time.</p>
</section>
</div>
</body>
</html>

186
blogs/apr-17-2025.html Normal file
View File

@@ -0,0 +1,186 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="This post is dedicated to those who want to edit fast with Vim. Currently, I'm finding a hard time actually writing out these blog posts, I have to constantly remember the proper syntax and the task of formatting a table of contents in raw Vim is an absolute nightmare, this process is mostly just me moving from the top of the page to the bottom of the page or copying headers into the links, it's not efficient, and for each header I make, there is the potential for a syntax mistake or a content mistake which won't get picked up by me unless I really read through the post.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Left4Code">
<meta name="keywords" content="vim, macro, remap, generate table of contents with vim macro, key remap, spellcheck">
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<title>Left4Code - (Blog) - {Vim Macros for Speedy HTML}</title>
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">Vim Macros for Speedy HTML</h1>
<h3>--| Posted: 2025-04-17</h3>
<h4 class="blog-header">Table of Contents</h4>
<div id="toc_container">
<hr>
<ul class="toc_list">
<li><a href="#>~(1)">1. The Problem</a></li>
<li><a href="#>~(2)">2. My Solution</a></li>
<li><a href="#>~(3)">3. "But how!? Don't keep it all to yourself!"</a></li>
<ul>
<li><a href="#>~{3.1}">3.1 Pre-requisites</a></li>
<li><a href="#>~{3.2}">3.2 Simple Remap</a></li>
<li><a href="#>~{3.3}">3.3 Table Creation and Generation with a Vim Macro</a></li>
<li><a href="#>~{3.4}">3.4 Header and Subheader Generation</a></li>
<li><a href="#>~{3.5}">3.5 Header and Subheader Table of Contents Filling</a></li>
</ul>
<li><a href="#>~(4)">4. Conclusion</a></li>
<ul>
<li><a href="#>~{4.1}">4.1 Benefits of this Solution</a></li>
<li><a href="#>~{4.2}">4.2 Drawbacks of this Solution</a></li>
<li><a href="#>~{4.3}">4.3 One Final Thing. Vim Spellcheck!</a></li>
</ul>
<hr>
</div>
<h4 id=">~(1)" class="blog-header">1. The Problem</h4>
<p>Typing is hard when your hands are cold. Typing HTML manually when your hands are cold is even worse.</p>
<p>Manually adding every single tag and being required to move off of the home row or have really bendy fingers is not fun. I notice myself forgetting what to write because I need to focus all my attention on hitting that &lt; key.</p>
<p>After looking at markdown and downright refusing to use Hugo (probably a big mistake) I found a video by <a href="https://odysee.com/@Luke:7/start-turning-vim-into-a-comfy-ide:3">the lovely Luke Smith</a> which goes over how to use vim macros, Vim spellcheck, and remapped insert mode keys to create a solid experience for going Sonic fast through boilerplate garbage and basically turning HTML into tagged-markdown.</p>
<p>I like Vim, so that's what I decided to go with, and boy was it a night and day change.</p>
<h4 id=">~(2)" class="blog-header">2. My Solution</h4>
<p>I have remapped insert mode keys in vim to add literally every HTML element this website will ever need, links, code, paragraph, bold, italic, headers with link capability, and everything in between. If you've seen an element used on this site, it's now been remapped to automatically generate for me in vim with the press of maybe 3 keys at the maximum.</p>
<h4 id=">~(3)" class="blog-header">3. "But how!? Don't keep it all to yourself!"</h4>
<p>This can be re-used for any language syntactically speaking. Time to spill the secret sauce!</p>
<h4 id=">~{3.1}" class="blog-header">3.1 Pre-requisites</h4>
<p>To successfully write what I've implemented for a different language, you will need to have a decent working-knowledge of vim normal mode commands.</p>
<p>First, go into your vimrc, it is probably located in /etc/vim/vimrc and needs sudo permissions to write to.</p>
<p>Create a gap of newlines in your vimrc and add the following to it:</p>
<pre class="preformatted">
filetype plugin on
set hlsearch</pre>
<p>This will allow you to remap keys in your vimrc depending on the filetype of the file.</p>
<p>as outlined in the Luke Smith video, I will be using &lt;++&gt; as a jumping marker to quickly move to key positions in the element template we will generate, this should be added to your vimrc like this:</p>
<pre class="preformatted">
noremap &lt;Space&gt;&lt;Space&gt; &lt;Esc&gt;/&lt;++&gt;&lt;Enter&gt;"_c4l </pre>
<p>now you should be able to type &lt;++&gt; anywhere in the html file and hit space twice in normal mode and jump to it, automatically getting put into insert mode.</p>
<h4 id=">~{3.2}" class="blog-header">3.2 Simple Remap</h4>
<p>Let's start with a simple remap:</p>
<pre class="preformatted">
autocmd FileType html inoremap ;b &lt;b&gt;&lt;/b&gt; &lt;++&gt;&lt;Esc&gt;4ba </pre>
<p>breaking the command down, we can understand the following:</p>
<p>1. "autocmd FileType html" is used to denote the filetype of the file with that plugin we enabled</p>
<p>2. "inoremap ;b" is used to remap the key combination ";b" in insert mode to a command</p>
<p>3. "&lt;b&gt;&lt;/b&gt; &lt;++&gt;&lt;Esc&gt;4ba" will insert that string into the document, escape to normal mode, then move 4 words back and insert you one character to the right, putting you where you need to be.</p>
<p>This format is literally the entire basis for what I do.</p>
<p>From this point, all there is to do is expand, if you want a complete list of the remap macros I've made, they are <a href="https://git.i2pd.xyz/Left4Code/Dotfiles">on my Gitea</a>. Remember that some of these macros are for my specific CSS and will not work well otherwise unless they are modified.</p>
<h4 id=">~{3.3}" class="blog-header">3.3 Table Creation and Generation with a Vim Macro</h4>
<p>There are entire plugins dedicated to what I'm going to show in this macro-based solution for both generating and quickly populating a table of contents for HTML. This solution includes support for the creating and populating headers and subheaders. So let's have a look at this monster:</p>
<h4 id=">~{3.4}" class="blog-header">3.4 Header and Subheader Generation</h4>
<p>to generate the normal header that would be in the text of the html, you would add the following to your vimrc</p>
<pre class="preformatted">
autocmd FileType html inoremap ;h &lt;h id="&gt;(&lt;++&gt;)" class="blog-header"&gt;&lt;++&gt;&lt;/h&lt;++&gt;&gt;&lt;Enter&gt;&lt;Enter&gt&lt;++&gt;&lt;Esc&gt;2k$2Bhi </pre>
<p>to generate the table of contents entry for the header, the macro is much like the bold macro showcased before</p>
<pre class="preformatted">
autocmd FileType html inoremap ;lh &lt;li&gt;&lt;a href="#&gt;()"&gt;&lt;/a&gt;&lt;/li&gt;&lt;Enter&gt; </pre>
<p>this will all be done in insert mode, there will be no movement and the cursor will stay behind the entire entry. The only difference between this and the subheader is the () changes to {}. If you're wondering why the parenthesis and everything is needed, you'll see in a minute.</p>
<h4 id=">~{3.5}" class="blog-header">3.5 Header and Subheader Table of Contents Filling</h4>
<p>Okay, we have the headers that go in the actual document, we have the links that go in the actual table of contents section, time to take the content from the headers and automatically put them in the table of contents. Which can be done using the following macro for headers.</p>
<pre class="preformatted">
autocmd FileType html noremap ;T /&gt;([0-9]&lt;CR&gt;a~&lt;Esc&gt;2l"by/)&lt;Esc&gt;/&gt;&lt;CR&gt;l"ty/&lt;&lt;CR&gt;A%^%&lt;Esc&gt;/&gt;()&lt;CR&gt;a~&lt;Esc&gt;l"bp/&gt;&lt;CR&gt;"tp/%^%&lt;CR&gt;d3l/&gt;([0-9]&lt;CR&gt;h&lt;Esc&gt; </pre>
<p>My disgusting creation! Typing this out with the HTML specified notations for "&gt and &lt" were really annoying! </p>
<p>To summarize this command instead of breaking everything down, what this does is it will look for the next header in the document, it will then copy the number and content from it, then it will place a unique set of characters at the end of the line and then look for the special empty header value (is it making sense why now?). It will then paste the header number and content into the document and go back to the character, that's the entire macro.</p>
<p>sadly, it doesn't seem like you can run something like "2;T" and replicate the macro twice, you will probably need to put it into a buffer then run "2@&lt;macro_key&gt; to get it to work. Or you could put it into a function and run that. Honestly, it's better to have to spam it out because it gives more fine control over catching mistakes and actually seeing where your content goes."</p>
<h4 id=">~(4)" class="blog-header">4. Conclusion</h4>
<p>Again, all of these macros are 100% correctly "working on my machine bro!" so if you want to get them and change them around, they are <a href="https://git.i2pd.xyz/Left4Code/Dotfiles">here for your viewing displeasure</a>.</p>
<h4 id=">~{4.1}" class="blog-header">4.1 Benefits of this Solution</h4>
<p>You can go fast, I mean <b>really</b> fast with the creation of individual HTML syntax and barely break a sweat making these pages compared to manually typing out all of the syntax and having to verify that what you're typing is actually valid.</p>
<h4 id=">~{4.2}" class="blog-header">4.2 Drawbacks of this Solution</h4>
<p>The only drawback of this solution aside from directly going out of your way to not learn Hugo, is you will 100% forget how to write those tags that you subconsciously beat into your head over the months you've been writing the site for. You will become dependent on the tags and never be able to pass that high school HTML class because you were too busy optimizing your macro to end the universe.</p>
<h4 id=">~{4.3}" class="blog-header">4.3 One Final Thing. Vim Spellcheck!</h4>
<p>"Vim has spellcheck?" Yes. I didn't know this for the longest time and now I have it on all the time, who needs LibreOffice when you've got the funny text editor. To turn it on, assuming you speak English, you can put this in your vimrc:</p>
<pre class="preformatted">
set spell spelllang=en_us </pre>
<p>and just like that, you got it. Anything you typed while half-asleep will hopefully get caught by this.</p>
<p>you can navigate quickly to next word in front of the cursor by typing ]s and can navigate back to the previous wrong word by typing [s, these are done in normal mode.</p>
<p>It wouldn't be much of spellcheck without a list of corrected words, right? When hovered over the wrong word, you can type z= to open a list of potentially correct words and type the number of word you want to correct it to.</p>
<p>That's everything I've got for this blog post. I hope you learned something. Bye for now, either a new edition to the digital forensics course or a GPG blog post next!</p>
</section>
</div>
</body>
</html>

344
blogs/apr-19-2025.html Normal file
View File

@@ -0,0 +1,344 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="This is a general guide to using the GPG software with OpenPGP. This guide will cover key generation, subkey generation, revocation certificate key generation, backup of keys, encrypting data with keys, decrypting data with keys, exchanging keys with someone, and revoking the keys.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Left4Code">
<meta name="keywords" content="GPG, gpg, AGE, GPG create key, GPG create subkey, GPG revoke key, GPG encrypt, GPG decrypt, GPG key exchange, GPG guide, gpg guide, a general guide to gpg, A General Guide to GPG">
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<title>Left4Code - (Blog) - {A General Guide to GPG}</title>
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">A General Guide to GPG</h1>
<h3>--| Posted: 2025-04-19</h3>
<h4 class="blog-header">Table of Contents</h4>
<div id="toc_container">
<hr>
<ul class="toc_list">
<li><a href="#>~(1)">1. My Plan for This Blog Post</a></li>
<ul>
<li><a href="#>~{1.1}">External Resources</a></li>
</ul>
<li><a href="#>~(2)">2. Creating the Master Key</a></li>
<li><a href="#>~(3)">3. Subkey Generation for GPG</a></li>
<ul>
<li><a href="#>~{3.1}">Change Expiry Date for Subkey</a></li>
</ul>
<li><a href="#>~(4)">4. Revocation Certificate Generation</a></li>
<li><a href="#>~(5)">5. Backing up Keys!</a></li>
<li><a href="#>~(6)">6. Encrypting Stuffs!</a></li>
<li><a href="#>~(7)">7. Signing Stuffs!</a></li>
<li><a href="#>~(8)">8. Decrypting Stuffs!</a></li>
<li><a href="#>~(9)">9. Exchanging Keys with Someone</a></li>
<li><a href="#>~(10)">10. Revoking Keys</a></li>
<ul>
<li><a href="#>~{10.1}">10.1 Uploading Keys to a Keyserver</a></li>
</ul>
<li><a href="#>~(11)">11. Conclusion and Additional Software</a></li>
</ul>
<hr>
</div>
<h4 id=">~(1)" class="blog-header">1. My Plan for This Blog Post</h4>
<p>The content from this blog post will be used in the hashcat tutorial for the digital forensics course. My plan is to demonstrate creating a gpg master key, and subkey from it, then backing up everything, deleting the master secret key, and re-importing the secret subkey. For the hashcat post, I will demonstrate how to break a weak secret key symmetric password with hashcat and John the Ripper modules and be able to decrypt messages using it.</p>
<p>to avoid getting confused before you start reading. PGP stands for Pretty-Good-Privacy, which is a software program for key encrypted messaging and signing. GPG is the GNU Privacy Guard, which implements OpenPGP into a software program.</p>
<p>This blog post will not be any better (will be probably worse) than other resources that I've found online when it comes to secure practices for managing and backing up keys.</p>
<p>This post will borrow from a bunch or resources in no particular order with regards to the creation of subkeys and the secure backup of those keys. If you want to go into the weeds with secure key generation and really understand what's going on with GPG. The links that I thought were really good are below:</p>
<h4 id=">~{1.1}" class="blog-header">External Resources</h4>
<pre class="preformatted">
<a href="https://drduh.github.io/YubiKey-Guide/">▶[https://drduh.github.io/YubiKey-Guide/]</a>
◉───╡ Talks About Complete GPG Key Generation.
<a href="https://mikeross.xyz/create-gpg-key-pair-with-subkeys/">▶[https://mikeross.xyz/create-gpg-key-pair-with-subkeys/]</a>
◉───╡ Simple GPG Subkey Generation.
<a href="https://odysee.com/@DenshiVideo:f/gpg-a-%E2%84%82%F0%9D%95%A0%F0%9D%95%9E%F0%9D%95%97%F0%9D%95%AA-guide:1">▶[DenshiVideo's GPG guide]</a>
◉───╡ Covers Encryption, Decryption, and Key Creation.
<a href="https://alexcabal.com/creating-the-perfect-gpg-keypair/">▶[https://alexcabal.com/creating-the-perfect-gpg-keypair/]</a>
◉───╡ Secure Backup of GPG Master Keypair Plus More Information.
<a href="https://rgoulter.com/blog/posts/programming/2022-06-10-a-visual-explanation-of-gpg-subkeys.html">▶[Visual Guide to GPG]</a>
◉───╡ Alleviates Some Confusion About GPG Visually.
<a href="https://www.gnupg.org/gph/en/manual.html">▶[https://www.gnupg.org/gph/en/manual.html]</a>
◉───╡ Official GPG Manual.
<a href="https://keys.openpgp.org/about/usage">▶[https://keys.openpgp.org/about/usage]</a>
◉───╡ Uploading Keys to an OpenPGP Keyserver.</pre>
<h4 id=">~(2)" class="blog-header">2. Creating the Master Key</h4>
<p>To create the master key that is going to be used to create any subkeys. You can run the following command:</p>
<pre class="preformatted">
gpg --full-generate-key </pre>
<p>you should get the option to select ECC, DSA, or RSA. You should probably select either ECC or RSA. Pick the highest keysize available for whatever you pick. If you picked ECC, you can probably pick whatever curve you want, default is fine.</p>
<p>The details you want to add to the key are up to you, however it is good practice to not merely rely on the key details to verify a key. Always verify the fingerprint of the key you will be encrypting data with.</p>
<p>It is probably good to set an expiry date for the master key and set a reasonable timeframe. Not setting an expire date is basically saying that nothing bad will ever happen that key in the forseable span of galactic existence.</p>
<p>I will show how to move the expiry date for the key forward in time to not have it expire at the bottom of the next section.</p>
<p>when you're done with all of the key details, press the <b>O</b> key and it should prompt you for a password. This is the symmetric encryption that your private key gets in case your device gets stolen. Without this password, someone will not be able to use the key.</p>
<p>After you've made a hopefully secure password, you will want to generate some random output for GPG to use to make random data. This could be swinging your mouse around like a maniac or rubbing your face on your keyboard while you're in a text editor to hit all of the keys at once. <a href="https://blog.cloudflare.com/randomness-101-lavarand-in-production/">CloudFlare uses pictures of lavalamps for their generation of keys</a>, but the face method is totally 100% better and guaranteed to work every time. (Disclaimer: Claims issued about the "face rubbing" method of key generation by the author are not 100% effective as previously stated. Use at your own risk.)</p>
<h4 id=">~(3)" class="blog-header">3. Subkey Generation for GPG</h4>
<p>Did you go ballistic on your peripheral device of choice? I hope so! Now it's time to repeat the process for the generation of the subkey. To do this, you will need to edit the existing keypair to add the subkey.</p>
<p>To see your current keys in your keyring, run the following command:</p>
<pre class="preformatted">
gpg --list-keys </pre>
<p>you should now see the fingerprints of all of the keys in your keyring. Find the key that you made and copy the fingerprint.</p>
<p>Now you should run this command to edit the keypair for the fingerprint you copied:</p>
<pre class="preformatted">
gpg --edit-key &lt;your_key_fingerprint&gt; </pre>
<p>you should now be put into a gpg&gt; prompt which you can type the following in:</p>
<pre class="preformatted">
gpg&gt; addkey </pre>
<p>you should get the same prompt to select the kind of key you want. For this key, you should pick whatever key type you want, RSA or ECC, but make sure it is the <b>(encrypt only)</b> option. The same procedure for the creation of the previous key should be followed for this key depending on the use of this subkey.... Facerolling included...</p>
<p>you should also make another subkey for signing <b>(sign only)</b> This is to not accidentally decrypt something for someone which was meant to only be signed.</p>
<p>Finally, you should type save in the gpg prompt which should put you back to your bash prompt.</p>
<pre class="preformatted">
gpg&gt; save </pre>
<h4 id=">~{3.1}" class="blog-header">3.1 Change Expiry Date for Subkey</h4>
<p>To change the expiry date for the subkey or master key, you will need to use the <b>gpg --edit-key</b> option and then change the expire date like this:</p>
<pre class="preformatted">
gpg --edit-key &lt;your_user_id&gt; </pre>
<p>the <b>keynum</b> entry will start from 0 and increment upwards by 1 for each key in your ring.</p>
<pre class="preformatted">
gpg&gt; key &lt;keynum&gt; </pre>
<pre class="preformatted">
gpg&gt; expire </pre>
<p>You can then pick the expire time as shown in the output. An example would be setting the key expire date to five years from now.</p>
<pre class="preformatted">
gpg&gt; 5y </pre>
<p>Finally, you will want to save your changes by typing <b>save</b> in the gpg&gt; prompt</p>
<pre class="preformatted">
gpg&gt; save </pre>
<p>Now you have changed the expire date for your keys.</p>
<h4 id=">~(4)" class="blog-header">4. Revocation Certificate Generation</h4>
<p>In the event that your master keys get stolen from you, you will need a way to revoke the master keys and let others know that key is toast. A revocation certificate generated for the master keys can help with that.</p>
<p>To do this, we will use the <b>--gen-revoke</b> command to generate a revocation certificate for us like this:</p>
<pre class="preformatted">
gpg --output &lt;your_key_id&gt;.revocation-certificate --gen-revoke &lt;your_key_id&gt; </pre>
<p>You now have a revocation certificate to use to revoke your master keys. I will next explain how to back up your keys and remove your master keypair from the machine you generated it on.</p>
<h4 id=">~(5)" class="blog-header">5. Backing up Keys!</h4>
<p>If you've followed me this far, you should now have three keys, a public key, private key, and individual subkeys used for encrypting and signing stuff. You should also have a revocation certificate for your master keypair.</p>
<p>These keys can now be backed up to a USB or other form of storage media of your choice. <a href="apr-17-2025.html">If you followed the cryptsetup blog I did, put them there!</a> To export your keys, for my situation, I made a subkey for encrypting and a subkey for signing, inside of a /tmp directory I created for gpg using the command:</p>
<pre class="preformatted">
mkdir -p /tmp/gpg </pre>
<p>I will run the following commands for gpg:</p>
<pre class="preformatted">
gpg --export --armor &lt;your_key_id&gt; &gt; &lt;your_key_id&gt;-publickeys.gpg
gpg --export-secret-keys --armor &lt;your_key_id&gt; &gt; &lt;your_key_id&gt;-secretkeys.gpg
gpg --export-secret-subkeys --armor &lt;your_key_id&gt; &gt; &lt;your_key_id&gt;-secretsubkeys.gpg </pre>
<p>the <b>--armor</b> option will basically turn your GPG to readable ASCII and put some "BEGIN" and "END" blocks above and below the output. This allows you to basically just read your key in ASCII instead of interpreted ASCII where everything looks like word puke.</p>
<p>You should then move these keys to the external storage device:</p>
<pre class="preformatted">
sudo mv &lt;your_directory_and_keyfilename&gt; /mnt/&lt;your_encrypted_usb_mountpoint&gt; </pre>
<p>In the Alex Cabal guide, Alex recommends to move the revocation certificate to a different piece of media than where your master keypair and other subkeys are stored.</p>
<p>I'd go a little further to say this revocation certificate should be put on another piece of encrypted media which has a completely different password to access it.</p>
<p>For sensitive data, try to follow the <a href="https://www.backblaze.com/blog/the-3-2-1-backup-strategy/">3-2-1</a> data backup strategy, it can save a lot of time and stress if things go wrong.</p>
<p>you will now want to delete the secret keys of the fingerprint off of your machine and import only the sub secret key back on the computer from your external storage.</p>
<pre class="preformatted">
gpg --delete-secret-keys &lt;your_fingerprint&gt; </pre>
<pre class="preformatted">
gpg --import &lt;path/to/your_key_id-secretsubkeys.gpg&gt; </pre>
<p>when you run "gpg --list-secret-keys" again, you should see only one entry with the "sec#". This means there is only one secret subkey available to use."</p>
<p>remember to delete the keys that you exported to your local machine and copied to the external storage. Shred them, SRM them, doesn't matter.</p>
<p>If you're not using a hard-drive for storage, you probably know that it isn't easy to actually delete a file off of an SSD or NVME completely. Most of the manufacturer software for wiping SSD's is closed-source and can not be trusted, this can be circumvented by not even writing anything to the drive in the first place by mounting a ramfs type (temporary storage using RAM) to a mountpoint and exporting your keys there, you would then copy these keys to the external storage and finally remove the keys from the ramfs, unmount the ramfs, and remove the mountpoint.</p>
<p>If you want to do this, the <a href="https://alexcabal.com/creating-the-perfect-gpg-keypair">"Transforming your master keypair into your laptop keypair" section of the Cabal guide shows you</a>. This method of secure extraction is also good for different things like password databases or other files.</p>
<h4 id=">~(6)" class="blog-header">6. Encrypting Stuffs!</h4>
<p>You should now have only the subkeys in your keyring. All your exported keys generated on the original system should be moved to external media and shredded to nothing, the same goes for the revocation certificate.</p>
<p>To encrypt something, the <b>--encrypt</b> flag should be used. For this example, let's encrypt a file using our own public subkey.</p>
<p>We will need to set the recipient as our key id like this:</p>
<pre class="preformatted">
gpg --encrypt -r &lt;your_key_id&gt; &lt;file_to_encrypt&gt; </pre>
<p>this will encrypt the file using our public key. Now you should have a &lt;file_to_encrypt&gt;.gpg file in the same directory.</p>
<p>as mentioned before, if you want to make this file a ASCII only thing, you can add the <b>--armor</b> option. This is the basis for sending emails using pgp through gpg.</p>
<h4 id=">~(7)" class="blog-header">7. Signing Stuffs!</h4>
<p>PGP signing is used to show authenticity that the author of a certain message is actually who they say they are. There are different options for signing stuff. You can sign a message or sign a file. First, I will demonstrate how to sign a file with the new signing subkey that was made.</p>
<p>To sign a file, you can run the following command:</p>
<pre class="preformatted">
gpg --sign &lt;your_file&gt; </pre>
<p>That's literally it, check the directory you're currently in and there should be a signature file.</p>
<p>if you have multiple keys (and this works for encrypting too.) and you want to sign something with a specific key, you can add the -u flag and specify the key ID of the key you want to use. Like this:</p>
<pre class="preformatted">
gpg --sign -u &lt;your_key_id&gt; &lt;your_file&gt; </pre>
<p>Finally, if you want to encrypt, sign, and ascii armor your message all at the same time you can run the following command:</p>
<pre class="preformatted">
gpg -e -s -a -u &lt;your_key_id&gt; -r &lt;your_key_id&gt; &lt;your_file&gt; </pre>
<p>With this out of the way. We can move to decrypting.</p>
<h4 id=">~(8)" class="blog-header">8. Decrypting Stuffs!</h4>
<p>To decrypt, you can just run:</p>
<pre class="preformatted">
gpg --decrypt &lt;your_encrypted_file&gt; </pre>
<p>If you have multiple keys, you should not need to specify the specific key to decrypt the file, GPG should do this automatically. But if there's a real problem. I think you can specify gpg to try all secret keys in your keyring to decrypt the file.</p>
<h4 id=">~(9)" class="blog-header">9. Exchanging Keys with Someone</h4>
<p>When exporting your key, you only want to export the public key. You can do so by running the same export command before. Making sure the specify the <b>--armor</b> option to be able to email this to someone for example.</p>
<pre class="preformatted">
gpg --armor --export &lt;your_key_id&gt; </pre>
<p>you can then copy the output and put it somewhere. On a website, in an email for initial exchange, or do something else with it. QR codes maybe?</p>
<p>If you don't have someone to actually exchange keys with. You can exchange keys with me. If I'm able to get everything on my end working, then I'll totally send you an "All good!" email.</p>
<p>On the main page of this website. My email address and PGP key will be listed there for you to import into your keyring. You can then send me your public key and we can exchange a message.</p>
<p>Finally, let's talk about how to revoke your keys in the event they get stolen.</p>
<h4 id=">~(10)" class="blog-header">10. Revoking Keys</h4>
<p>So you just got mugged for all your Doubloons and you want to make sure they can't start sending PGP messages using your key to all your friends to lure them into that dark alley to mug them too! How would we go about revoking our master key, and in association, our subkeys?</p>
<p>First, you need to go dig that USB out of your Attic and decrypt it. Then you will import the master keys and all other subkeys. From there, <a href="https://alexcabal.com/creating-the-perfect-gpg-keypair">just as the Cabal guide shows in the "In case of emergency" section.</a> You will use the gpg --edit-key option and specify the key ID of your secret key. Then you will select each subkey and revoke it. This can be done by typing <b>key &lt;keynum&gt;</b> and then typing <b>revkey</b>. Finally, you will select the reason for revokation, type <b>save</b> and distribute the key to a keyserver.</p>
<h4 id=">~{10.1}" class="blog-header">10.1 Uploading Keys to a Keyserver</h4>
<p>if you want to upload your key to a keyserver, you can head over to <a href="https://keys.openpgp.org/about/usage">https://keys.openpgp.org/about/usage</a> and look at the steps for how to upload your key. To summarize what is on that page, there is two options for upload, using GPG, and manual website upload. Pick what you want.</p>
<h4 id=">~(11)" class="blog-header">11. Conclusion and Additional Software</h4>
<p>That's basically it for using OpenPGP and GPG to generate keys, exchange them, and encrypt and decrypt messages with them.</p>
<p>Something that peaked my interest is the use of another encryption software suite called <a href="https://github.com/FiloSottile/age">AGE</a>, which stands for "Actually Good Encryption" This is meant to simplify the encryption and decryption process and uses the same trusted algorithms as normal GPG. I might do a post on the utilization of that at a later point in time. If you were interested how I found out this existed, originally it was from <a href="https://sdomi.pl/">https://sdomi.pl/</a>, they do some cool business with bash and they happen to use it for secure communications. (You do sweet stuff, thank you for posting about it.)</p>
<p>the next activity for this website should be in the digital forensics course. I'll show how to use hashcat and John the Ripper's translation modules to decrypt a weak GPG private key password and then we can pose as that user when sending emails.</p>
<p>Remember, this post was a giant mash of other people's stuff. If you want more in-depth knowledge on anything I have talked about in this post, you should consult your search engine or the links at the top of the post.</p>
<p>That's all for now. Until next time.</p>
</section>
</div>
</body>
</html>

Binary file not shown.

204
blogs/mar-21-2025.html Normal file
View File

@@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Left4Code - (Blog) - {Maytag Bravos XL washing machine}</title>
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog / Courses</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">Maytag Bravos SD Error fix procedure</h1>
<h3>--| Posted: 2025-03-21</h3>
<p>This is a bit different from my other tech-related blog and course postings, but I think it's necessary to have on here due to the sadly limited amount of medium-depth content regarding this error and repair for this washing machine. Hopefully the method of repair and tips I give here can help someone experiencing this problem and you're not forced to buy a more crap futuristic washing machine that's even harder to diagnose and repair than this one!</p>
<h3 class="blog-header">Preliminary information (Background):</h3>
<p>Some time ago, I was running a normal rapid wash cycle on a friend's Maytag Bravos XL washing machine, and I got this error, and because you may be stressed trying to fix the issue, I'll keep what happened brief:</p>
<div style="white-space: pre-wrap">
<b>1:</b> Washing machine runs rapid wash cycle until around 14 minutes (right before spin cycle).
<b>2:</b> Clock says 14 minutes for around 5 minutes while slowly agitating clothes.
<b>3:</b> Washing machine sounds a single beep, displays SD (Suds Detected) on screen.
<b>4:</b> Washing machine fills the wash basin (big silver barrel) up completely.
<b>5:</b> Washing machine drains and trys to detect "suds" again.
<b>6:</b> Washing machine it fails again, and stops, leaving a half-filled wash barrel.
<b>7:</b> You wake up groggy and your night-time wash cycle leads to an impromptu scuba diving session
<b>8:</b> You're forced to play <a href=https://en.wikipedia.org/wiki/Apple_bobbing>Bobbing For Apples</a></b> with your soggy undies in a desperate attempt to get them in the dryer.
<b>9:</b> You physically bucket the water out of the barrel like Jack Sparrow trying to save his ship. Water is everywhere now.
<b>10:</b> You slip on wet floor, simultaneously hitting yourself in the face with a full bucket and waterboarding yourself.
<b>11:</b> You run the cycle again to see if it was a fluke, it happens again. (repeat steps 9-10.. Exactly.)
<b>12:</b> You shake your wet arm (or head 🍎️) in the air, curse Maytag, and hopefully find this blog post!
</div>
<h3 class="blog-header">"How Do I Fix This Piece Of Junk!? (The quick fix)"</h3>
<div style="white-space: pre-wrap">
This "fix" gets the water out of the machine and lets you spin out your clothes. Don't make this the permanent fix for this unless you like operating your washing machine like a train conductor... It is fun though and I don't judge!
If you want to consult the official technician's manual for this washing machine, I managed to find revision A of the technical manual for the washer online in PDF form, it is <a href=https://git.i2pd.xyz/Left4Code/left4code.neocities.org/raw/branch/master/blogs/blog_files/mar-21-2025/W10403990A_Maytag.pdf>now on my gitea just view the pdf file</a> but if that link goes down, the original source is <a href=https://parts.alliancelaundry.com/files/docs/maytag-whirlpool/Tech-Sheet-W10403990-Rev-A.pdf>from here</a>, and if THAT goes down, the manual should be in a plastic bag inside your washing machine somewhere taped to the inside wall (you might have to take the washer apart to get to it.)
The sections you will want to consult for information on how to get into manual operation mode are:
1: Page 1 section "ACTIVATION OF AUTOMATIC DIAGNOSTIC TEST MODE" (center of the page)
2: Page 2 section "ACTIVATION OF MANUAL DIAGNOSTIC MODE" steps 1 and 2.
If you hate manuals, your interview is in an hour, and you need that special suit that's water-logged. You can watch <a href=https://youtube.com/watch?v=pV4gBGhBOEg>[This video]</a> [https://youtube.com/watch?v=pV4gBGhBOEg] It's 9 minutes, but if you don't have time for that. I'll describe the process as clearly as possible, because you're probably freaking out right now, so stay calm and focus!
<h4>How to enter manual operation mode:</h4>
<b>0:</b> make sure the washing machine is getting electricity.
<b>1:</b> Spin the middle dial to normal mode (12 o'clock/top option)
<b>2:</b> press the POWER button on the left side of the dial to turn off the display
<b>3:</b> Press and hold the FABRIC SOFTENER button to the right of the lid lock indicator for 3 seconds (1'st time)
<b>4:</b> release for 3 seconds (1'st time)
<b>5:</b> press and hold for another 3 seconds (2'Nd time)
<b>6:</b> release for 3 seconds (2'Nd time)
<b>7:</b> press and hold for another 3 seconds (3'Rd time)
<b>8:</b> release for 3 seconds (3'Rd time)
<b>NOTICE!</b> All lights on the display should now be lit up!
<b>8:</b> press the FABRIC SOFTENER button one more time after the dial lights up and release instantly, you should now be in manual operation mode! WooHoo!
<h4>Spin and Drain Procedure: </h4>
<b>0:</b> spin the dial to the Clean washer mode (5 o'clock/bottom right)
<b>1:</b> press the Water Save spray rinse button on the right side of the panel to manually lock the lid
<b>2:</b> press the start button three times, activating the drain pump
<b>3:</b> wait until the visible water is drained out
<b>4:</b> press start button one more time, shutting off the drain pump.
[IMPORTANT!] If the clothes in the washing machine look unbalanced at this point, unlock the lid by pressing the save spray rinse button and re-balance the clothes. You will spin the clothes in future steps and the washing machine can not sense if the clothes are unbalanced when in manual mode, which could lead to your washing machine moving VIOLENTLY (5:03 of <a href=https://youtube.com/watch?v=pV4gBGhBOEg>[This video]</a>), potentially hurting you or damaging the washing machine. If you unlocked the lid and re-balanced the clothes, make sure to lock the lid again after it is shut.
[Pre-Explanation] There are 4 modes you can manually spin the washing machine at: <b>23 rpm ,530 rpm, 1000 rpm, and 0 rpm</b>, every time you click the spin speed button on the right side of the washing machine, it will cycle through these modes, and because your washing machine is hopefully not spinning right now. You're at 0 rpm!
[Note!] Note that you can always press the power button or pull the washing machine plug as a precaution if you mess up any future steps or the washing machine starts shaking. Just don't shock yourself when pulling the plug, this machine pulls 8 amps at 120V so it's a good amount of dangerous shock you'll get if you improperly grip the plug when you pull it out of the socket. Just make sure you're grabbing the plastic part of the plug and you'll be good.
<b>5:</b> Press the spin speed button once, wait for it to spin up to 23 rpm, ensure clothes are balanced
<b>6:</b> Press the spin speed button again, ensure load is still balanced as it spins up to 530rpm
<b>7:</b> Press the start button 3 times to activate the drain pump while the machine is spinning
[Note] At this point you will get a pretty good spin dry if you leave the machine spinning for about a minute in this state, if you're satisfied with the speed of the spin and you think your clothes are as dry as a normal rapid wash cycle would be, press the spin speed button twice to quickly cycle to 1000 rpm, then to 0 rpm, listen carefully to make sure the machine is slowing down after doing this.
If you're feeling bold, press the spin speed button only once to bring it up to 1000 rpm, then press the spin speed button again to bring it down to 0 rpm once satisfied.
<b>8:</b> press the start button again to stop the drain pump, then unlock the lid with the water save spray rinse button.
And that's it! If you want to exit the manual operation mode, press the power button and get those clothes in the dryer!
</div>
<h3 class="blog-header">"How Do I Actually fix This Piece Of Junk!? (The real fix)"</h3>
<p>before looking into this section make sure you fully watch the video guide below and complete the check that the guy does in the video to determine if the small plastic piece is really the problem or not. The test is to hold onto the agitator while spinning the barrel and if the agitator is able to spin, then it's a problem and you can go forward with the guide.</p>
<p>After you've completed the first section of this, and managed to get the washing machine drained and now know how to turn your washing machine into a steam-powered locomotive, we can move on to the parts that need to be replaced to stop this from happening for around 4-7 months. (I know, It's annoying.)</p>
<p>This section of the guide can be watched for the most part from <a href="https://youtube.com/watch?v=wF9S8ELAytY">onebaddj's video on the subject</a>. Although there are some parts of it that really should have been described more or shown a little closer up, just a personal critique of the matter, other than that, it's amazing and should serve you well.</p>
<h3 class="blog-header">Items Needed For The Fix:</h3>
<div style="white-space: pre-wrap">
<b>0: 280145 W10820039 Washer Hub Kit Replacement Parts Kit</b> (I'll explain this below step 6.)
<b>1: 11mm socket.</b>
<b>2: Ratchet with extension pole </b>(makes things easier).
<b>3: Phillips screwdriver, [flathead, and knife OPTIONAL] .</b>
<b>4: Shoelace or inflatable bags. </b>(hear me out)
<b>5: Popsicle sticks. </b>(I'm serious, I'm about to drop a new method with this.)
<b>6: Another able-bodied human if you're not a complete loner </b>(This isn't a raid encounter, randoms are fine.)
</div>
<p>if you've got everything, you're good to go!</p>
<p>When getting the W10820039 parts kit, amazon sellers sell this parts kit, I guess you can just find the cheapest option if you just want the washer to run again for around 5 months. Also, very important, if they offer a warranty, totally exploit it to the highest degree. The best thing about this being a rapidly wearing part, is that it will almost never surpass the 1 year mark of living before that SD error happens again.</p>
<p>Quick note on what was said in step 0, full disclaimer, I don't know how well this works, but I found it a while ago and it seems like a good idea as the smaller white plastic part's inside teeth are a continuous point of failure for this washing machine. <a href="https://bens-appliances.com/products/w10820039-ba-whirlpool-all-metal-washer-hub">This guy sells the W10820039 kit as a full-metal option</a> so if you're up for an adventure, you could try this out and see if it works well. The outer piece that holds the smaller piece in place is never the point of failure, it is always the small inner piece.</p>
<h3 class="blog-header">Step 1: Remove The Plastic Cap</h3>
<p> The video <a href="https://youtu.be/wF9S8ELAytY?t=380">at 6:22</a> shows him popping off the cap with his hands, my personal experience was not the same, if it's pretty stuck on there, as gently as you can use a flathead screwdriver or the edge of a knife to work at prying it up without breaking it. Slow is smooth with this, so be patient. Once the cap is off, you should see the 11mm socket nut that you're going to take off later.</p>
<h3 class="blog-header">Step 2: Unscrewing The Nut</h3>
<p>The video <a href="https://youtu.be/wF9S8ELAytY?t=398">at 6:37</a> shows him unscrewing the nut with the wrench while using his hand to stabilize the agitator, again it looks insanely easy and was not at all the wrath of hell that I faced trying to get this thing loose the first time.</p>
<p>This is the hardest part of the disassembly for the most part depending on how the Maytag gods have birthed your washing machine into existence. But if this is really hard for you to do alone, I have some awesome loner tips for you to get the job done!</p>
<div style="white-space: pre-wrap">
Find the most comfortable torque position under tension that you can get, what I mean by this is experiment with trying to counter-clockwise turn the nut with the ratchet extension pole on and off of the ratchet, you're probably going to notice that once you start turning the nut, the whole agitator assembly moves, so you need to stabilize it with your other hand while you turn. Now.. If it's too hard for you to turn, this is where my first trick comes in, and hopefully why you convinced yourself to get those <b>Popsicle sticks!</b>
A quick tip regarding the ratchet extension pole assembly and disassembly, if you're having trouble getting either the socket or the extension pole off of the actual ratchet, you can stick a flathead screwdriver in the gap which connects the two and twist so once side of the flathead screwdriver rises, this should put enough force on the socket or pole to get it off if it's stuck to the ratchet like mine always is.
[NOTE!] Don't be dumb like me and drop a lose Popsicle stick through the gap and under the agitator, it won't mess anything up functionality wise as the space under the agitator is mostly solid except for small holes which are too small for the stick the enter. Just work slow and be aware of what your doing.
Depending on the thickness of the Popsicle sticks, stack them on top of each other if needed and shove them between the gap separating the outer rim of the agitator and the actual drum so that the agitator won't move when you go to turn it due to the Popsicle stick friction keeping the agitator and drum as a solid unit. I've seen a video of another guy using a car jack or you could use a thin inflatable pillow or something, just get that agitator and drum to not be independently free-spinning.
So now the only problem you'll have left is keeping your hand on the inside lip of the actual wash drum while you turn the nut with the ratchet connected to the extension pole. If you can get it off like this, then great. If you can't then you might want to enlist the help of someone to hold the inside lip of the wash drum for you while you unscrew the nut with the Popsicle sticks or whatever you can jam in there still in place.
If you're the sole survivor of the apocalypse or something and you really need to get this done alone, you may be able to use a really long shoelace or multiple shoelaces tied together and loop it under the agitator and tie it to something outside before you insert the Popsicle sticks, or if you have two inflatable bags, you can feed one on each side between the washing machine hull and the wash barrel and inflate it to put pressure down and stop the barrel from moving, you would then be able to unscrew the nut without problem, and if the nut is STILL not coming loose, then make sure you're actually turning it the right way to loosen it, and maybe hit the nut with the ratchet to try and loosen any particulates which could be binding the nut's teeth to the screw hole on the inside.
These are about all of the ways that I can hypothesize on how to get the job done on your own, but I haven't ever needed to use an inflatable bag or shoelace like this before for this purpose and it's only a hypothesis as to it's effectiveness.
</div>
<h3 class="blog-header">Step 3: Removing The Agitator Plate</h3>
<div style="white-space: pre-wrap">
<a href="https://youtu.be/wF9S8ELAytY?t=427">at 7:07</a>, again, he hits the caveman special on the agitator plate and pops it up with enough force to make a bodybuilder shake in his boots. For me this was the absolute worst part of the disassembly, and you have two options to get this spawn of Satan off if you're having trouble.
<b>1: shoelace method</b> feed a thin shoelace under the agitator so you can pull up on it, <a href="https://youtube.com/watch?v=orBgQ9lejPE">This video demonstrates the process very well! So thank you The How-To Crew!</a>
<b>2: air pillow thingy method</b> feed the air pillows under the secure spots of the agitator, equally pressurize each one until you get <a href="https://youtu.be/PdDze6z7oSM?t=143">the biggest dopamine dump known to man when it shoots up in the air.</a> That video is one of my favorites by the way. I unironically watch that when I'm having a particularly bad day.
If you get this done, you're ready to move on to the final part!
</div>
<h3 class="blog-header">Step 4: Unscrewing And Removing The Underside Parts</h3>
<p><a href="https://youtu.be/wF9S8ELAytY?t=495">At 8:15</a> he unscrews the main part of the washer hub kit from the wash barrel, my only advice for this is to unscrew each Phillips screw at the same time, slowly. 3 torques of one screw, move to the opposite side, another 3 torques, then do that until all the screws are loose and you can get the piece off.</p>
<p>once you get the larger part of the hub kit off, there's only the smaller part left, it is shown being taken off <a href="https://youtu.be/wF9S8ELAytY?t=582">at 9:42</a>, again it's very easy for him, and a feat of pure will for me. So my tip for if it's stuck is to either use pliers to grip the teeth and pull up from there, or you can lever it up using a flathead screwdriver by inserting the screwdriver under the piece and the base of the metal rod that the piece is around, you will probably want to pull up on the screwdriver, not push down, as when you push down depending on if your screwdriver has square-shaped edges along it's ridge, you could potentially crack the plastic part of the bottom of the wash barrel.</p>
<h3 class="blog-header">Step 5: Putting On The New Parts</h3>
<div style="white-space: pre-wrap">
<a href="https://youtu.be/wF9S8ELAytY?t=727">Video reference 12:07 </a>Now that the small piece is off, examine it and compare it to the new smaller part. Are the teeth on the old part eroded? If they aren't this may have not been the issue, but if you did the pre-check and determined that the agitator free-spins when holding the wash barrel, then you're good.
To put the new part on, just feed it onto the teeth of the metal pole protruding from inside the wash barrel, make sure that the grooves of the metal pole are being filled by the inside teeth of the plastic piece properly and then push it down as far as you can.
Now you need to put the larger piece of plastic on top of the smaller piece, compare the original larger part to the new 2 larger parts and use the same matching one for your specific washer. Make sure that when you put the larger part on, it is aligned with the screw holes, it should only be off by a little bit, just move the larger part around a bit by placing it in different grooves of the smaller part until it lines up nicely with the screw holes. Then repeat the same procedure for tightening the screws as you did for loosening them.
This is just a theory, but you may be able to extend the life of the small piece of the kit by running some temperature safe tape around the metal bit of the washing machine before you put the small piece down, if the problem if that the teeth wear out, it's because of both the excessive force that months of rapidly moving metal to plastic has on this piece but also because of the small gaps that the piece has which do not make it perfectly fit and allow it to be worn down. So if someone has tried this and reports success, shoot me an email and tell me how it went.
All you have to do is pop the wash plate back on and screw the nut back down, be careful to not overturn the nut when fastening it on the washing machine. It also may be good to try tightening the nut again after 2-3 wash cycles to ensure that it is properly fit.
</div>
<h3 class="blog-header">Conclusion:</h3>
<p>Well. That's it, hopefully now that you've put everything back together it runs like normal. If it doesn't I have no clue what to do and additional research might need to be done. Feel free to shoot me an email once I make one to tell me how much you hate me for making you waste hours of your life or like what I did here. Any criticism is welcomed!</p>
<p>It's kind of funny that the most in-depth post on this entire site is barely tech-related when that's the purpose of this site, but whatever, I had a terrible experience fixing this thing so hopefully this post lightens the burden on some poor soul getting this error.</p>
<p>I'll be doing a smaller blog post on using the cryptsetup utility for linux after this, so if you like that kind of stuff, stick around.</p>
</section>
</div>
</body>
</html>

58
blogs/sep-23-2024.html Normal file
View File

@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Left4Code - (Blog) - {Ditch Mouse}</title>
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog / Courses</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">A Method to Ditch Your Mouse on Linux</h1>
<h3>--| Posted: 2024-09-24</h3>
<p>If you've been hunting for ways to become more efficient at completing your daily tasks by using things like dwm, dmenu, or rofi, vim extensions, etc., you may have adopted the core philosophy that your hands should be on the keyboard at all times. This post is for you to expand upon and use. With that out of the way, the small guide begins!</p>
<h3 class="blog-header">Prerequisites for Advanced Usage:</h3>
<p>sxhkd, xdotool, rofi/dmenu</p>
<p>If I ever get the time, I will make a part two to this post detailing how to extend the usage of the setxkbmap command with a shell script to automatically place your mouse on a tile of the screen based on a map I'll create for it that's easy to remember.</p>
<h4>The Ultimate Command:</h4>
<p>Content drop! Xorg supports mouse movement using the numpad when you type the command:</p>
<pre class="preformatted">setxkbmap -option keypad:pointerkeys</pre>
<p>With this, we get basically all the functionality of a mouse on our numpad. Just start it by pressing shift plus the numlock key. The only real pitfalls I can see with this are that the mouse starts moving slowly and there's no real way to replicate what Firefox extensions like Vim Vixen or Vimium do. But if you have no mouse or just refuse to use one, it does the job very well and after not using my mouse for a day I didn't find a task it was unable to complete.</p>
<h4>Understanding funny numpad mouse</h4>
<p>All of the bindings can be found on the <a href=https://wiki.gentoo.org/wiki/Xorg/Using_the_numeric_keyboard_keys_as_mouse>Gentoo Wiki</a> also, setxbmap has a lot of additional functionality like <a href="https://wiki.gentoo.org/wiki/Keyboard_layout_switching">Changing keyboard layouts, key composition, and some other things. </a></p>
<div style="white-space: pre-wrap">
But to boil everything down on this page, all of the keys you need to know are:
<b>/, *, -</b> &#8212; selects left click, middle click, or right click mode
<b>1-4,6-9</b> &#8212; mouse directional keys
<b>0</b> &#8212; used in combination with left click to basically click and hold or click and drag
<b>5</b> &#8212; click!
<b>+</b> &#8212; Mouse double click
<b>.</b> &#8212; release mouse button
</div>
<p>If you're on a system where your xinitrc actually works and you don't need to patch dwm with autostart after compiling, then you can literally just put the command in your xinitrc and have this functionality all the time, also it doesn't seem to get rid of the original numpad functionality, so that's an added bonus.</p>
<h4>Practicality of using this</h4>
<p>It's not, at least in the current state it's in, if there's a way to change the default speed of how fast the cursor goes and change the setting from the cursor being a sort of linear ramp and just have a flat speed or a faster time to reach full speed, then it could be really nice, but that will hopefully be possible with some more research in part 2 (if it ever comes out.)</p>
</section>
</div>
</body>
</html>

71
blogs/sep-30-2024.html Normal file
View File

@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Left4Code - (Blog) - {vim|:norm|:g}</title>
<link rel="icon" type="image/x-icon" href="../favicon/favicon.ico">
<link rel="stylesheet" type="text/css" href='../style.css'>
</head>
<body>
<header>
<span>Left4Code</span>
</header>
<nav>
<div>
<a href="../index.html">Home</a>
<a href="../blog.html">Blog / Courses</a>
</div>
</nav>
<div class="container">
<section>
<h1 class="blog-header">Using :norm And :g In Vim</h1>
<h3>--| Posted: 2024-09-30</h3>
<h4>The Problem I'm Dealing With:</h4>
<p>Basically, I have a bunch of links that are formatted like this with a bunch of forensics tools I want to document how to use for the free digital forensics course I'm trying to make on this site, and I want to add a long dash next to the name and in brackets, either and X symbol or a check mark to show if there is a lesson or guide I have made for a particular tool. I have around 50 links that look like this and don't really want to deal with manually entering these very difficult to type unicode characters for them 50 times over, so let's use Vim to alleviate some of the pain!</p>
<pre class="preformatted">
41 &lt;ul&gt;
42 &lt;li&gt;&lt;a href="itscoming.html"&gt;dd &lt;/a&gt;&lt;/li&gt;
43 &lt;li&gt;&lt;a href="itscoming.html"&gt;ddc3dd &lt;/a&gt;&lt;/li&gt;
44 &lt;li&gt;&lt;a href="itscoming.html"&gt;Guymager &lt;/a&gt;&lt;/li&gt;
45 &lt;li&gt;&lt;a href="itscoming.html"&gt;Cyclone &lt;/a&gt;&lt;/li&gt;
46 &lt;li&gt;&lt;a href="itscoming.html"&gt;ddrescuer &lt;/a&gt;&lt;/li&gt;
47 &lt;li&gt;&lt;a href="itscoming.html"&gt;ftkimage &lt;/a&gt;&lt;/li&gt;
48 &lt;li&gt;&lt;a href="itscoming.html"&gt;Guymager &lt;/a&gt;&lt;/li&gt;
49 &lt;hr&gt;
50 &lt;li&gt;&lt;a href="itscoming.html"&gt;GtkHash &lt;/a&gt;&lt;/li&gt;
51 &lt;li&gt;&lt;a href="itscoming.html"&gt;sha*sum &lt;/a&gt;&lt;/li&gt;
52 &lt;li&gt;&lt;a href="itscoming.html"&gt;hashboy &lt;/a&gt;&lt;/li&gt;
53 &lt;li&gt;&lt;a href="itscoming.html"&gt;hashid &lt;/a&gt;&lt;/li&gt;
54 &lt;li&gt;&lt;a href="itscoming.html"&gt;pehash &lt;/a&gt;&lt;/li&gt;
55 &lt;li&gt;&lt;a href="itscoming.html"&gt;OpenTimestamps &lt;/a&gt;&lt;/li&gt;
56 &lt;/ul&gt;
</pre>
<p>However, I've never really done anything in terms of bulk modification outside of the normal <b>:%s/something/somethingelse/g</b>. It turns out, that there's a lot of ways to deal with the problem I have specifically, :%s is a way to do it, but I would rather learn something new that might help me (or you!) somewhere else where :%s doesn't work well.</p>
<h4><u>:norm</u>, My Guardian Angel.</h4>
<p>:norm is such a cool concept in Vim and I really like it, basically what it does is it allows you to do actions you would usually use in normal mode, but using another mode like visual or :g mode for bulk (which I'll get into soon.) So actions like 04ldw can be completed using the colon key by typing :norm 04ldw and it'll do it on whatever line you're currently on.</p>
<h4>Combining :g With :norm To Modify In Bulk</h4>
<p>I know, I didn't explain what :g does, but it's not that confusing and from the minimal amount of information I've learned about it, it's basically just the way to apply whatever you're doing to one single element to all elements that match the one. With :%s, you can add /g to the end of it to do the same thing. For this specific problem, I'm going to combine both of these things together to quickly insert what I need at a specific position for all 50-ish links. </p>
<h4>The Command I Used To Solve My Problem (and The Problem I Created Accidentally!)</h4>
<pre class="preformatted"><code>:g/<\/a><\/li/norm $4bi& [the dash] [the symbol] </code></pre>
<p>to break down what I haven't explained already, everything after the first "/" is what I'm initially searching for and the one right before the "norm" is what I'm replacing it with. The "\" is an escape character which allows vim to interpret the slash character as a literal and not a / used to denote what Vim should be substituting and not substituting. $ means to go to the end of the line, 4b means to go back 4 words, i goes into insert mode, and everything after that is just normal text</p>
<hr>
<p>In the process of writing this, I accidentally ran the command on the HTML page I had already added the symbols to for the course and now there's two of them, I also just did a shift + z + z on instinct because I didn't realize anything was wrong, now undo is gone, so what should I do? Fix it manually and go against what I just taught you? Or should I do this but in reverse? I think we know what the answer is.</p>
<hr>
<p>after fiddling with it for about 5 minutes, this worked successfully!</p>
<pre class="preformatted">:g/<\/a><\/li/norm $8h6dbi;] </pre>
<p>One very small piece of advice I can give you to use your brain and successfully come up with these kinds of scary looking commands that seem really confusing, is that you should always be more scared of the 20 minutes of annoying manual labor you'll have to do if you don't figure it out, sometimes even if it takes you longer to figure out, you'll now have the tool to do something else much faster next time.</p>
<hr>
<p>8h means move 8 characters to the left, 6db means delete 6 words back, and the rest you should already know.</p>
<h4>Conclusion: Vim Is An Awesome Tool If You Let It Do Work For You!</h4>
<p>Maybe I'm just too deep into using Vim to where I don't see anything else as any more useful, but I really don't think I would have been able to do something like this using Xed. There's a lot more that Vim has to offer, so I guess you should expect more posts about it to happen eventually because writing a site like this seems to challenge every fiber of my soul sometimes, and Vim makes it just a little easier to manage.</p>
</section>
</div>
</body>
</html>