š¾ Archived View for benjaminja.info āŗ log āŗ 2023 āŗ feed.xml captured on 2024-05-10 at 10:50:57.
ā”ļø Next capture (2024-07-09)
-=-=-=-=-=-=-
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"> <title>Benjamin Jacobs | Log - 2023</title> <link rel="self" type="application/atom+xml" hreflang="" href="gemini://benjaminja.com/log/2023/feed.xml" /> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/" /><id>/</id> <updated>2023-01-01T07:00:00Z</updated> <generator>Hugo 0.125.4</generator> <entry> <title><![CDATA[Simple Site Generator]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/09/03-simple_site_gen/" /> <id>gemini://benjaminja.com/log/2023/09/03-simple_site_gen/</id> <updated>2023-09-03T08:06:00Z</updated> <summary type="gemini"><![CDATA[Itās been a while since I last posted. I have been busy working on my weatherstation. Iāll need to write about that soon, but for now I want to talk about the state of my capsule. ]]></summary><content type="gemini"><![CDATA[Itās been a while since I last posted. I have been busy working on my weatherstation. Iāll need to write about that soon, but for now I want to talk about the state of my capsule. During my breaks from the weatherstation, I have been working on my own site generator. I have finally got it to the point where I can start using it in production. Thereās definitely a lot of work left to be done before I can publish it for others to use. I have been calling it `simple-site` for now, though Iāll probably think of a better name when I actually release it. I have designed the generator to be as simple possible while allowing for complexity to come if desired. The design starts out with templating. I designed my own simple templating engine that I found works surprisingly well. Each document will be rendered and passed to a chain of configured templates. To get added functionality, scripts can be created which will behave like functions in the templating engine. If you need more control, then generator scripts can be used to make alterations to the structure of the site. Since I have migrated my capsule over to the new system, I have most likely missed a few things. ### Example Here is a pretty simple example of what my generator does. Hopefully it can help visualize whatās going on.
+- content
| +- index.gmi
| +- my-image.jpg
+- templates
| +- base.gmi
+- site.toml
$ simple-site site.toml
Rendering "index.gmi" with template "base.gmi"Copying "my-image.jpg"
]]></content> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <category term="capsule" label="Capsule" scheme="gemini://benjaminja.com/tags/capsule/" /> <category term="gemini" label="Gemini" scheme="gemini://benjaminja.com/tags/gemini/" /> <published>2023-09-03T08:06:00Z</published></entry> <entry> <title><![CDATA[Installing Ethernet]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/06/26-upgrading_internet/" /> <id>gemini://benjaminja.com/log/2023/06/26-upgrading_internet/</id> <updated>2023-06-26T18:52:00Z</updated> <summary type="gemini"><![CDATA[My house used to be connected to Comcast before we switched over to a local fiber ISP. This switch has happened years ago and the house was outfitted with coax back in the Comcast days. Of course now, there is no use for Coax. ]]></summary><content type="gemini"><![CDATA[My house used to be connected to Comcast before we switched over to a local fiber ISP. This switch has happened years ago and the house was outfitted with coax back in the Comcast days. Of course now, there is no use for Coax. The local antenna stations are not great and we donāt have cable coming in either. So I figured that I would replace our existing coax with ethernet. We have three coax ports. One in the basement that goes outside along the wall. And two in the house that share the same wall across two floors. The basement port was very easy to replace as I just had to poke the ethernet out the wall and re-enter into the boiler roomāwhere the networking is located. Iām still planning out how to replace the two remaining ports. My original plan was to attach the existing coax cable to the ethernet cable and pull it through the wall up into the attic without having to cut any access holes. This would work great in theory, but I have found that there is only one coax cable coming into the attic. This means that somewhere in the wall is a coax splitter. => example.png š¼ It might be easier to see an example of what I mean. Iām not entirely certain that this is how the cable was installed, but it seems that way. There are two possible solutions that I can think of to make this work: Make the existing access point hole bigger in the attic so that I can pull the splitter through and not have to cut the walls. I could remove the box on the second floor and remove the splitter from that access point and replace the box in the future. If I were to cut in the attic, it is possible that I will reduce structural integrity. If I were to remove the outlet box, I may have to make repairs to the wall. The box may not be attached to any studs, free floating on the drywall with mounting ears. This might make it easier for me to remove the box without damaging the wall. When I get the chance, Iāll try to remove that box and see if Iām right about the splitter. ## Update - Retrofitting telephone wire 2023-06-28 alextheuxguy responded and said that he was lucky that the phone jacks were wired with Cat5e. Thatās pretty cool! And now that I think of it, when I was last in the attic I saw some mysterious 8-wire unsheathed cable up there that looked suspiciously like ethernet. I know there is a telephone jack in the dining room, so maybe I would also be able to retrofit the telephone jack with ethernet. Iāll have some more investigating to do. Thanks for the tip Alex! ]]></content> <category term="home-improvement" label="Home-Improvement" scheme="gemini://benjaminja.com/tags/home-improvement/" /> <published>2023-06-26T18:52:00Z</published></entry> <entry> <title><![CDATA[Communicating with my weatherstation]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/06/24-comms_with_weatherstation/" /> <id>gemini://benjaminja.com/log/2023/06/24-comms_with_weatherstation/</id> <updated>2023-06-24T18:42:00Z</updated> <summary type="gemini"><![CDATA[In my original plan for my weatherstation, I would wirelessly send weatherdata to a ground station. I have given up on this idea primarily because managing a rechargeable battery would introduce too many variables. Now, I have decided to have a cable that connects between the ground station and the sensors. ]]></summary><content type="gemini"><![CDATA[In my original plan for my weatherstation, I would wirelessly send weatherdata to a ground station. I have given up on this idea primarily because managing a rechargeable battery would introduce too many variables. Now, I have decided to have a cable that connects between the ground station and the sensors. I will be using an ethernet cable as the medium, but I wonāt be using the ethernet protocol. Having a network card on the station is more overhead than I would like. The original plan was to connect the serial lines directly. This is not a great idea, since plain datalines cannot go a long distance without losing integrity. Instead, making the lines differential twisted pairsāwhich ethernet is already made ofāwould allow for longer reliable distance. I just donāt know how I would convert a line into a twisted differential pair. I discovered that CAN bus could be the better option for me. It stands for Controller Area Network, and is designed to be a light weight alternative to Ethernet. CAN is generally used in cars and in industrial settings. Now I just need to come up with a protocol to manage the weatherstation. Iāve discovered a protocol called CANopen which seems very interesting. Iām currently stuck trying to decide whether I want to fully implement CANopen, or if I want to develop my own protocol that is inspired from CANopen. There is a lot of stuff that goes on with CANopen that I donāt necessarily need (particularly since I donāt plan to integrate the weatherstation with other CANopen devices). There is a library for CANopen called CANopenNode, however I would have to make my own compatibility layer with it since no has done that for the Teensy4.0. It might just be better for me to design my own partial CANopen library. Maybe Iāve gone too far into CAN, and would have been better off just using an Ethernet card. Iāve had fun working with CAN and CANopen, so I donāt think I have wasted my own time here, but sometimes I wonder if it would have been better to use a different board that has ethernet built-in. ]]></content> <category term="side-project" label="Side-Project" scheme="gemini://benjaminja.com/tags/side-project/" /> <category term="weather-station" label="Weather-Station" scheme="gemini://benjaminja.com/tags/weather-station/" /> <published>2023-06-24T18:42:00Z</published></entry> <entry> <title><![CDATA[My weather vane is now better than new]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/04/30-repaired_weather_vane/" /> <id>gemini://benjaminja.com/log/2023/04/30-repaired_weather_vane/</id> <updated>2023-04-30T17:12:00Z</updated> <summary type="gemini"><![CDATA[Yesterday, I wrote about how I broke and repaird my weather-vane After it got repaired, I was able to get the sensor working in software. Everything worked, but there was one thing odd about the sensor. ]]></summary><content type="gemini"><![CDATA[=> /log/2023/04/29-broke_weather_vane/ Yesterday, I wrote about how I broke and repaird my weather-vane After it got repaired, I was able to get the sensor working in software. Everything worked, but there was one thing odd about the sensor. To give some background, the sensor can tell the direction of the wind by triggering one of 8 magnetic reed switches each connected to a resistor. If I measure the resistance of the sensor, I can tell which direction the wind is blowing. The east resistor measured infinite ohms. In hindsight this is obviously a problem, but I thought that everything was normal until after I did my repair. Why would there be a reed switch that connects to an infinite resistor? This is the same as having a switch connected to nothing. I took apart the sensor once again to look for any damage. I was only hoping that I wouldnāt have a busted reed switch. After some continuity testing, I found this on the east sensor: => broken_reed.jpg š¼ A reed switch that has been pulled off the circuit board This must be something that has been broken for over 6 years now. I was able to make the repair, luckily it was pretty simple. Just a jumper from the resistor to the reed switch. => repaired_reed.jpg š¼ The repaired sensor I canāt describe just how happy I am about this. If the wind points between two of the sensors, then it will no longer think the wind has spontaneously pointed east. ]]></content> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <category term="weather-station" label="Weather-Station" scheme="gemini://benjaminja.com/tags/weather-station/" /> <published>2023-04-30T17:12:00Z</published></entry> <entry> <title><![CDATA[Whoops, I broke my weather vane]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/04/29-broke_weather_vane/" /> <id>gemini://benjaminja.com/log/2023/04/29-broke_weather_vane/</id> <updated>2023-04-29T17:47:00Z</updated> <summary type="gemini"><![CDATA[I am working on my weatherstation project now, and Iām going to finish it for real! Yesterday I was opening up the weather-vane to reverse-engineer the board it has and make sure what I already know is correct. ]]></summary><content type="gemini"><![CDATA[I am working on my weatherstation project now, and Iām going to finish it for real! Yesterday I was opening up the weather-vane to reverse-engineer the board it has and make sure what I already know is correct. I was able to get my picture and put it all back together; there was only one problem. The sensor no longer worked! It turns out that when I took the board out of the housing, I also pulled the cable a bit too hard and broke the connection to the board, whoops. Fixing the board should be pretty easy, I just have to remove whatās left of the wires, and solder the wires back in. To make sure that the wires donāt fall apart again, I decided to use solid core wires and connect the cable to that. Everything went pretty well until I accidentally ripped one of the pads off the circuit board, whoops. I am just lucky that the pad I pulled off had a simple connection that I could easily bypass. I was able to fix the sensor just fine. It looks a little silly, but thatās ok. The one thing that Iām more annoyed at than anything else is that I didnāt need to take apart the sensor. I had already done that around 6 years ago, and uploaded it to my wordpress blog. => /log/2017/04/04-weatherstation/ My blog where I analyzed the weather-vane. => sensor-back.jpg š¼ Back of the repaird weather-vane => sensor-front.jpg š¼ Front of the repaird weather-vane ]]></content> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <category term="weather-station" label="Weather-Station" scheme="gemini://benjaminja.com/tags/weather-station/" /> <published>2023-04-29T17:47:00Z</published></entry> <entry> <title><![CDATA[Planning PWS Hardware]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/04/16-planning_pws_hardware/" /> <id>gemini://benjaminja.com/log/2023/04/16-planning_pws_hardware/</id> <updated>2023-04-16T17:26:00Z</updated> <summary type="gemini"><![CDATA[It has been a dream of mine to create my own personal weather station (PWS). Iāve been working on this project for over 6 years now. Due to school and scope creep: I have not been able to complete this project. ]]></summary><content type="gemini"><![CDATA[It has been a dream of mine to create my own personal weather station (PWS). Iāve been working on this project for over 6 years now. Due to school and scope creep: I have not been able to complete this project. This time will be different. I have a plan. This plan has been split up into two parts: hardware and software. In previous iterations, I have developed hardware and software at the same time without a clear plan, which I believe is part of the reason why it has taken me so long. With this semester is almost over, I have done a bit of planning so I can hit the ground running with this project. I want to have the hardware installed as soon as reasonably possible so that I can start work on the software remotely. The general idea for this project is to have a weather station that hosts a web-app. This would allow you to view the current weather conditions from anywhere in the building. In order to do this, I will have a raspberry pi to host the server and communicate with the station hardware. The station hardware will include a weather vane, rain meter, temperature, humidity, pressure, and possibly a uv-index sensor. This will all be directly controlled by a teensy. ## Hardware plan The raspberry pi will sit on the roof in a shady spot. It will be connected to the internet via ethernet and get power over ethernet (PoE). The pi will interface with the teensy using CAN over an ethernet cable. Itās possible that the pi could be placed indoors, but I want to attach a camera as a little bonus thing. The teensy will be directly connected with all the sensors over i2c. The weather vane and rain meter donāt have any logic chips and so will need to be specially programmed. ## Software plan The teensy will generally act as a bridge between the sensors and the pi. The weather vane and rain meter will need special logic which I will go into later. The teensy will respond to requests from the pi. The pi will run OctoWeather (PWS software that I am developing). I havenāt made any plans yet of how this software will work, but I have general ideas of what it will do in my projects page. The weather vane has two parts: wind direction and wind speed. Both of these use reed switches to detect what is happening. The wind speed closes the circuit on every rotation (maybe every 180Āŗ I canāt quite remember which). The wind direction has eight reed switches each connected to a different resistance to detect which cardinal direction the wind is blowing in. The rain meter has one reed switch that triggers every time 0.01 inches has fallen. The wind speed and rain meter will need to have special software to asynchronously determine how much rain has fallen and how fast the wind is blowing. This should be relatively easy by using pin change interrupts. The wind direction can be connected to a voltage divider to measure resistance on an analog pin. ## What Iāve done so far I have been able to install an ethernet cable that goes from the basement to the roof. I have also collected all of the hardware that I plan to use for this project. => ethernet_install.jpg š¼ Ethernet Going to the roof => pws_hardware.jpg š¼ Hardware I have so far ]]></content> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <category term="weather-station" label="Weather-Station" scheme="gemini://benjaminja.com/tags/weather-station/" /> <published>2023-04-16T17:26:00Z</published></entry> <entry> <title><![CDATA[Organizing My Life]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/02/26-organizing_my_life/" /> <id>gemini://benjaminja.com/log/2023/02/26-organizing_my_life/</id> <updated>2023-02-26T21:22:00Z</updated> <summary type="gemini"><![CDATA[I have always been bad at organizing my life. It can be hard for me to know what to do and when to do it. This is a particularly big problem for me because of executive disfunction. ]]></summary><content type="gemini"><![CDATA[I have always been bad at organizing my life. It can be hard for me to know what to do and when to do it. This is a particularly big problem for me because of executive disfunction. There are many ways in which I could go about keeping track of what needs to be done, but they all boil down to some sort of calendar system. That being said, each system has you think about things in a different way. I have tried using my calendar app, various todo apps, and physical journaling. Each one has their pros and cons, but they all ultimately failed me in the sense that I have gotten out of the habbit of using them. Life has been getting overwelming recently and so I thought that it would be a good idea to get back into the habbit of using one of these. It sounds a little odd, but I have found that physical journaling has been the most useful for me. I have a bit of a hard time expressing why this is, but I think it has to do with how a lot of effort needs to be put into writing in a journal. It is so easy to setup an app, that it is also easy to just ignore it. With journaling, what I write tends to sticks with me. I follow the the bullet journal style of journaling which has been useful for me to have an organized todo list as well as being able to write down my random thoughts. => https://help.bulletjournal.com/en-US/articles/bullet-journaling-101-17356 Bullet Journaling 101 Of course, the bulletjournal site will try to sell you a journal or even a course on how to use it. I am just using a notebook a friend gifted to me. => journal.jpg š¼ My journal Iāll eventually fall out of use with my journaling again, but thatās ok because all that matters is that it has been useful while it lasts. ]]></content> <category term="life" label="Life" scheme="gemini://benjaminja.com/tags/life/" /> <published>2023-02-26T21:22:00Z</published></entry> <entry> <title><![CDATA[How I deploy to my server]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/02/13-how_i_deploy/" /> <id>gemini://benjaminja.com/log/2023/02/13-how_i_deploy/</id> <updated>2023-02-14T17:25:00Z</updated> <summary type="gemini"><![CDATA[I donāt run this capsule on a server that I physically own. I rent out my server from digitalocean. Since my server doesnāt need to have lots of computing power or memory, I have opted to use the cheapest server possible that pennies can buy. ]]></summary><content type="gemini"><![CDATA[I donāt run this capsule on a server that I physically own. I rent out my server from digitalocean. Since my server doesnāt need to have lots of computing power or memory, I have opted to use the cheapest server possible that pennies can buy. The only problem is that the server is so underpowered: it is nearly impossible to install software from source. In this log, I will explain how I go about deploying software to my server. => https://digitalocean.com digitalocean.com Iāve deployed my server as a droplet using a single shared CPU with 512 MB of memory. Because of these low specs, I have decided that all of my server/CGI software will run on native binaries to make using my capsule as smooth as possible. The main server software that I use is made with Rust; a language known for its long and intensive compilations. I tried building it on my server and it took around 10 minutes before the build crashed from a lack of available memory. I would probably be better off cross compiling from my computer and uploading the binary than trying to find some workaround. ## Uploading to the server Compiling software for the server can vary widely from language to language, but it is almost always the same to upload your built binary to the server. The way I do it is by having a `deploy.sh` script in the root of a project that will build, upload, and install the software on the server.
BINARY=path/to/binary
REMOTE=root@my_server
BINAME="$(basename "$BINARY")"BINDIR=/usr/local/bin
TMPDIR=/var/tmp
install -Dm755 ./$BINAME$BINDIR/$BINAME &&
rm ./$BINAME"
Of course depending on the type of software Iām deploying, the script may need to change to fit the projectās needs. I feel that it would be simpler to just scp the binary directly into the installed destination rather than installing it with a separate command, but I kind of like it. ## Deploying Rust Rust has become my goto language when it comes to compiled software. It supports a lot of language features that I like. It can feel like a high-level language while still allowing for low level control. My problem with Rust is with how difficult it is to cross compile. In theory, it is very easy to cross compile Rust, but when external libraries are used: the process becomes infinitely more complicated. You will first need to install a target for your toolchain (This is fairly easy). If the program doesnāt use any external libraries, you should be good to go. Otherwise, you will need to install a C cross compiling toolchain (This can be tricky depending on your host system) and tell rust the linker you will be using in `.cargo/config.toml`. If your build still fails, a library might be compiling C from source, so you will need to tell rust that any C code should be built using your cross compiling toolchain in an environment variable. If you still canāt cross compile the software, then get ready for a never ending rabbit hole. There is a tool that will help you do cross compiling that I wish I had known about before I spent a week learning how to do it manually. It is called āCrossā, and allows you to do cross compilations with very little hassle. => https://github.com/cross-rs/cross Cross You will need to have Docker installed for Cross to work, but I think I have read that it might be possible to configure Cross to use Zig as a linker/compiler instead of building inside a Docker container. Building with Cross is usually as simple as replacing `cargo` with `cross`. Depending on your needs, you may need to create a `Cross.toml` to customize your build, but that is still simpler than doing it manually.
TARGET=x86_64-unknown-linux-gnu
BINAME=<binary>
BINARY=target/release/$TARGET/$BINAME
cross build --release --target $TARGET
## Deploying Go In comparison to Rust, Go is a walk in the park. All that is needed to cross compile Go is two environment variables: `GOOS` and `GOARCH`. I donāt know if there are any edge cases that might show up when building. I really should learn Go.
BINAME=<binary>
BINARY=$BINAME
GOOS=linux GOARCH=amd64 go build
I havenāt needed to do anything else for Go to work, but I also donāt know the language. If it were possible to use external libraries, then I would imagine that cross compilation could get more complicated, but I just donāt know enough about the language to know if thatās even possible. ## Deploying my capsule This isnāt a language, but I figure itās worth mentioning. When I deploy my capsule, I upload the project up to the server and then render it. This allows for semi-dynamic content that is stored exclusively on the server to be rendered into the capsule. The way I go about deploying the capsule is a little bit funky, but it works and thatās all that matters.
DIR="$(dirname -- "${BASH_SOURCE[0]}")"SERVER='gemini@my_server'DEST='/path/to/capsule/data/'SOURCE="$DIR/."GEMINI="/var/www/gemini/my.site/"COMMAND="${1:-upload}"# Upload to the serverif["$COMMAND"="upload"]; then# Synchronize the project with the server rsync -rltp --delete-after -z --exclude='./git' --filter=':- .gitignore' -h "$SOURCE""$SERVER:$DEST" echo "Uploaded capsule"# Run the build section of the deploy script on the server ssh -t "$SERVER""cd $DEST ; ./deploy.sh build"elif["$COMMAND"="build"]; then# Render the capsule cd "$DIR" kiln build
RES=$?
if[ $RES -ne 0]; then exit $RES
fi# Copy the rendered files into the server folder rsync -r "${DEST}public/""$GEMINI" RES=$?
if[ $RES -ne 0]; then exit $RES
fielse echo "Invalid Command, should be one of [upload, build]"fi
I havenāt yet had the chance to deploy any other types of software, but I can imagine that some will be easier than others. Zig should be pretty simple, but C/C++ scares me. The thought of having to find or build libraries does not seem at all fun. Though C/C++ should still be easier than Rust. ]]></content> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <category term="capsule" label="Capsule" scheme="gemini://benjaminja.com/tags/capsule/" /> <category term="gemini" label="Gemini" scheme="gemini://benjaminja.com/tags/gemini/" /> <published>2023-02-14T17:25:00Z</published></entry> <entry> <title><![CDATA[My Capsule Plans]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/02/10-capsule_plans/" /> <id>gemini://benjaminja.com/log/2023/02/10-capsule_plans/</id> <updated>2023-02-10T19:20:00Z</updated> <summary type="gemini"><![CDATA[I have been getting fairly ambitious with ideas for my capsule. This is dangerous with me being in the middle of a heavy semester, so I am going to write down my plans and implement them later. ]]></summary><content type="gemini"><![CDATA[I have been getting fairly ambitious with ideas for my capsule. This is dangerous with me being in the middle of a heavy semester, so I am going to write down my plans and implement them later. Hopefully I donāt end up working on these projects to avoid my schoolwork (I am writing this very log to distract myself from a project I need to do š). ## Serve my content on both gemini and https At the moment, I am serving my capsule on the www under a proxy. This has been good, but I would like to have more control of how it looks. To do this, I want to serve my capsule natively on both gemini and https protocols. I want the feel of the web version to be simple, but feel like it was meant for the web. Primarily so that I can have a navigation section and inline images. If I were to do this, I might need to write most of my content in markdown so that I can convert it into http/gemtext without much fuss. ## Automated Gemmentions implementation => https://codeberg.org/bacardi55/gemini-mentions-rfc Gemini Mentions RFC Seeing some of the implementations of gemini mentions has been really good. Notably Seanās implementation where mentions to a post are placed at the bottom of the page under āDiscussions about this entryā. I particularly like how it feels like Iām going through a big discussion thread without the need of looking through an aggregator. => gemini://gemini.conman.org/boston/2023/01/04.1 Thoughts on an implementation of Gemini mentions (The post where I first saw mentions being used) I want to have a feature like this myself, but I also donāt want to do any of it by hand. The idea would be to have a gemmention CGI script that adds mentioned pages to a database, then ask the site generator to rebuild the capsule (Any mentions would be placed in a footing after the article). Iāve already written a CGI program that can upload mentions to a database, but I have yet to figure out how to insert mentions into posts. I would like to make the program portable so that anyone who would like to have similar functionality could do it themselves. The only problem is that the software I wrote is too complicated to publish without a lot of simplifications. ## Aggregate topics On most of my pages, I have added a little topics section at the top of the page. I want to have a section of my capsule where you can sort by similar topics. I would have tags stored in the frontmatter and my site generator could generate pages for each topic. Also the title, date, and tags could be automatically inserted into the generated gemini files so I donāt have to repeat myself too much. An example of the frontmatter might be like:
---
title: My Capsule Plans
date: 2023-02-10T12:20:00-07:00
tags:
- plans
- capsule
author: ttocsneb
---
I have been getting fairly ambitious with ideas for my capsule...
## Learn the ins and outs of Kiln => gemini://kiln.adnano.co/ Kiln I am currently using Kiln to build my capsule. It has been great so far, but there are a few features that confuse me. I think that most of my problems lie in the fact that I am not familier with the Go templating engine. I know that I can use kiln to build an alternative http format, but Iām not sure whether it will be able to do what I want with gemmentions and topics. I think it should be possible using the templating engine, but I will need to do research to verify. If I end up not being able to do these things, then I might design my own site generator inspired by Kiln, maybe something with python and jinja2. ]]></content> <category term="plans" label="Plans" scheme="gemini://benjaminja.com/tags/plans/" /> <category term="capsule" label="Capsule" scheme="gemini://benjaminja.com/tags/capsule/" /> <category term="gemini" label="Gemini" scheme="gemini://benjaminja.com/tags/gemini/" /> <published>2023-02-10T19:20:00Z</published></entry> <entry> <title><![CDATA[MAC Attack!]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/02/06-macattack/" /> <id>gemini://benjaminja.com/log/2023/02/06-macattack/</id> <updated>2023-02-07T05:43:00Z</updated> <summary type="gemini"><![CDATA[I just finished the third project for my security class. This project has been simultaneously the most difficult and most easy lab that I have done. I wanted to describe my experience of the lab here. ]]></summary><content type="gemini"><![CDATA[I just finished the third project for my security class. This project has been simultaneously the most difficult and most easy lab that I have done. I wanted to describe my experience of the lab here. ## The Premise The premise is that my TA has sent a message to my professor and I was able to intercept it. The message is as follows. > No one has completed lab 2 so give them all a 0 A MAC (Message Authenticated Code) was also in the message, which we know used a 128-bit key. The MAC is as follows in hex. > e384efadf26767a613162142b5ef0efbb9d7659a I want to change the message to tell the professor that I should get full points, but I canāt because there is a MAC attached to the message. If I were to change the message, the attached MAC would be invalid and I could not generate a new MAC because I donāt have the secret key for the MAC. => gemini://gemi.dev/cgi-bin/wp.cgi/view?Message+authentication+code MAC (Gemipedia) => https://en.wikipedia.org/wiki/Message_authentication_code MAC (Wikipedia) ## How I went about the lab This lab was one of those projects where you just have no idea where to start. I knew what I needed to do and vaguely how it should be done, but the specifics were beyond me. The project turned mostly into analyzing library code and trying to figure out how I could modify it to do what I need, which is to say the least, very stressful. With this in mind, I was mostly working on creating unit tests that would help me fumble my way through the lab and took many breaks. I would say the most frustrating thing about the lab was that a big part of it was on hashes, which changes wildly with even the smallest change, so it was very difficult to know whether I was getting close or not. In the end, I was able to figure it out and I canāt describe how relieved I was. Below is a more technical description of how the lab worked, so tread on if you dare. ## Vulnerability in MAC There is a vulnerability in MAC which took me a while to fully understand. In order to explain the vulnerability, I will have to explain how MAC works in the first place. MAC is relatively simple. You start out with a key and a message. you concatenate them together and hash it:
Key = "0123456789abcdef"
Message = "Hello World!"
MAC = SHA("0123456789abcdefHello World!")
MAC = 36f141824e771ed3313815d82c996522d8191a99
The SHA algorithm will recursively calculate a digest from 512-bit blocks of data. Because of this, it is possible to continue calculating a hash by using the digest as the initialization vector for the SHA algorithm. If we were to add to the end of the original message, hash that added bit with IV (initialization vector) being the original MAC, then we could pass this modified message and MAC to the professor and they would think the message was authentic. The only problem is that SHA adds some information and padding to the end of the message internally to keep all blocks exactly 512 bits long. The solution is to simply add the padding to the end of the message, but before our added bit. One last thing to deal with is that SHA adds the length of the hashed string at the end of the last block, so we will need to know the length of the key for this to work. ## The Attack We are given pretty much everything we need for the attack. The most difficult thing will be figuring out how to modify the IV. According to my teacher, golangās API for SHA allows setting the IV, but most languages donāt provide that functionality. I had to download a SHA-1 library and modify it myself to allow for setting an initialization vector. Analyzing the library and making it work for what I need was probably one of the most hair pulling things I have done. Adding the padding to the message wasnāt too difficult, particularly with the aid of unit testing. In the end I was able to generate this message to send to my teacher; posing as my TA with a valid MAC. The message itself looks a little corrupted, but that is a problem to deal with another day. > Message: No one has completed lab 2 so give them all a 0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf8P.S. Except for ttocsneb, Give him 100% > MAC: d338d12365cd75f5f13673991d9cd1359e355b2e ## Prevention from this kind of attack The best way to prevent this attack from being possible would be to use HMAC instead. It essentially performs two hashes with the key being manipulated in a way that I can not understand. => gemini://gemi.dev/cgi-bin/wp.cgi/view?HMAC HMAC (Gemipedia) => https://en.wikipedia.org/wiki/HMAC HMAC (Wikipedia) ]]></content> <category term="school" label="School" scheme="gemini://benjaminja.com/tags/school/" /> <category term="projects" label="Projects" scheme="gemini://benjaminja.com/tags/projects/" /> <published>2023-02-07T05:43:00Z</published></entry> <entry> <title><![CDATA[School has begun]]></title> <link rel="alternate" type="text/gemini" hreflang="" href="gemini://benjaminja.com/log/2023/01/15-school_has_begun/" /> <id>gemini://benjaminja.com/log/2023/01/15-school_has_begun/</id> <updated>2023-01-15T17:06:00Z</updated> <summary type="gemini"><![CDATA[I find it funny that I chose to start a gemlog right as school started. I was fully expecting to be able to put out more content than I have so far, but thatās ok. School should probably have a higher priority than my hobbies. ]]></summary><content type="gemini"><![CDATA[I find it funny that I chose to start a gemlog right as school started. I was fully expecting to be able to put out more content than I have so far, but thatās ok. School should probably have a higher priority than my hobbies. Iām almost done with school! Iāll be taking my final CS classes this semester with a few generals. For spring and summer terms, I just need to take 3 GEs and I will be graduated! The first week has already passed, so I have a pretty good idea of how this semester will go. I will be taking these classes this semester: