Achari - Converting KeepNotes to PDF and PNG

Monday, February 20, 2017

Achari - Converting KeepNotes to PDF and PNG


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. You can check out this link for a neat guide on note taking apps.

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.

What is Achari???

Achari is a simple bash script based tool, that converts Keep Notes into either a PDF document or a PNG image. Achari heavily utilizes the wkhtmltopdf binary for the conversion. 


The tool at the moment can only convert Keep Notes located in a specified folder. This means that the tool is limited to converting one note at a time. The other consideration is that all the folder and sub-folder names MUST be preceded with a numerical value in ascending order, as illustrated below. 



Given that KeepNote supports an extension system, Achari has quite some potential to become a KeepNote extension. This would make it easier for it's users to quickly convert their respective notes to PDF documents. Probably even facilitate PDF customization and an enhanced note taking experience.  

Conclusion

The most simple conversations can give rise to a noble idea, that when acted upon, can grow into an actual resource that someone, somewhere can make use of. I believe, this is how a vast majority of infosec tools start. Ideas, turned into tools that fulfill a defined objective or goal. It is my hope that Achari proves to be a useful companion to your note taking. 

References