Why I Hack | Yoav Shai
3 min read
Why I Hack

A couple of days ago, a friend asked for a scan of my passport so he could order a flight for us.

Considering that I know it to be saved in my Obsidian vault under areas.documents.passport.png, that WhatsApp still doesn’t have Share implemented on Mac OS for some reason and that I’m more of a CLI person anyways, I did what any reasonable person would:

pbcopy < Notes/areas.documents.passport.png

Delighted with how I’d saved myself from yet another grueling Finder session, I pasted it into our chat.

Shit.

WhatsApp instantly froze, and unfortunately one feature that they did bother implementing is draft storage. Restarting the program did not help, neither did my attempts at archiving the chat to see if it makes a difference.

Unwilling to admit defeat and delete our entire chat, I went looking for where it lurked. I decided it’s better to let my computer look than doing it myself, so I found a nice readable string in the PNG file (to avoid having to fight binary grep patterns) and searched my homedir for it.

λ ~ rg 3CHIWf -ail
# [ ... omitted for brevity ... ]
Library/Group Containers/group.net.whatsapp.WhatsApp.shared/ChatStorage.sqlite
Library/Group Containers/group.net.whatsapp.WhatsApp.shared/Message/Media/972525381648@s.whatsapp.net/0/3/03881f96-7285-4518-bac0-3ea2dd8a06f2.png
zsh: killed     rg 3CHIWf -ail

Two of the hits stood out: the WhatsApp database itself and what I assume was the file on disk from when I (properly) sent the same picture to my mom. I quickly grepped the output of sqlite3 ChatStorage.sqlite .dump for the string again, locating it in the ZSAVEDINPUT field of the ZWACHATSESSION table. A quick Set to NULL later (for this I used DB Browser; enough troubles for one day) and I got our chat working again.

While nothing interesting or novel, this reminded me why I loved tinkering in the first place. It’s what allowed me to fetch synchronized music lyrics for my favorite music or fuck my friends over in random drawings. You can just solve stuff, and sometimes you even luck out and have fun on your way there.