Achari – Converting KeepNotes to PDF and PNGadmin
KeepNote is a note taking application that allows you to take notes quickly and efficiently. Keep Note is quite popular in the infosec community, more so given that it’s the recommended note taking application for the Offensive Security Certified Professional (OSCP) certification. In case you are not familiar with OSCP, it’s basically a completely hands-on offensive information security certification. It’s highly coveted by infosec professionals and usually denoted as a sign for advanced penetration testing skill and insight.
Given that i had never used KeepNote before, i simply used to keep my pentest notes in a specified folder, that contained the various screenshots and scan outputs dumped to a text file. My to-do list was stored on Evernote for fast and easy access as i moved around. I can’t say that this approach was efficient but, well, it worked for me.
The light bulb moment!!!
After getting to see how KeepNote can come in very handy from Jade and Trune, then getting a chance to have a look at Gabby’s notes, i was sold on it. KeepNote just made is easy to aggregate notes into one manageable location, where i can easily separate each project into various notes.
One thing that came up though, is Jade jokingly mentioning that it would be really great if there was a tool that could convert the notes in KeepNote to PDF for easy sharing and probably even submit the notes as a report. This was with reference to Gabby’s incredibly detailed pentest notes. I’m not kidding, his notes are precise and really spot on. That suggestion was great but i really didn’t put my mind to it.
Fast forward to a few days later, as i was researching online. I came across wkhtmltopdf and remembered that snorby (snort IDS gui) uses the wkhtmltopdf to convert it’s html reports to PDF. This is when i had a light bulb moment and decided to see if it could convert the keep note files to a PDF document.
Getting down and dirty!!!
The first thing was to understand how KeepNote structures it’s notes. This meant manually looking through my notes and some sample notes i had borrowed. It turned out that the default file where the notes are kept is the page.html file. The next step was playing around with the wkhtmltopdf binary to validate if it’s possible to convert the notes into a PDF document and PNG image. After some trial and error to figure out how the tool works, i managed to converts a few specific notes to PDF and image.
At this point, the next logical step was to create a simple script that would recursively go through a specified KeepNote folder and grab all the page.html files, then proceed to convert all of them. On the first few attempts, sorting the html files and any available images (screenshots) was simply a mess. The PDF document had all the notes re-arranged and not in the order i required.
After lots of googling, i resolved to arranging the folders and subfolders in numerical order, in ascending format. This made it easier to sort the files and consequently generate the PDF document with all the notes, in the exact order i desired. I put together a simple bash script that i could use to point it to where my notes are and then proceed to convert them.
It was great to see the tool able to convert the notes quite smoothly. This script then morphed into a tool now called Achari and it’s available here on github. I must admit that the tool is not perfect and it still has a lot to be worked on but it’s pretty neat and can come in very handy.