olejorgenb / ColorNote-backup-decryptor

Decrypt a ColorNote backup file to export your notes (https://www.colornote.com)
MIT License
52 stars 9 forks source link

Ambiguous redirect #1

Closed pshem closed 6 years ago

pshem commented 6 years ago

Thank you for writing this, it came in very handy!

When trying to use your program in Ubuntu Xenial, I couldn't get it to work with the java -jar < *-AUTO.doc | fixup > notes.json. I kept getting ambiguous redirect. Luckily cat *-AUTO.dat | java -jar colornote-backup-decrypt.doc | fixup > notes.json worked.

With the current colornote format, there is a lot of junk at the beginnig of the file too, so it won't open properly, but you can still read it with tail -n 100 notes.json. Instead of 100, put the number of notes you have there, as one note takes a single line.

olejorgenb commented 6 years ago

Glad it still works (kinda) :)

I will update the instructions, they silently assumed only one *doc file was present.

pshem commented 6 years ago

It works really well. I mostly had problems due to my own knowledge shortages - should have thought that the < redirect assumed a single file. I had ~80 files.

I was working with a recent version because the device wouldn't open old notes after an update.(Now that I think about it, that could be another reason for the crap at the beginning of the json file)

The new extension is .doc, they even open in Word although they're 100% gibberish, regardless of whether they're plaintext or encrypted.

The cumulative notes.json file had ~4k lines in total, and only the last ~80 were actual json. I only had the backup for a short period of time and was required to delete it immediately afterwards, so I manually selected the valid lines and was done with it. If someone were to do it properly, a fixup2.sh script would have to look a bit like this:

#setup variables
x=1
tail -n $x notes.json > notesV.json

#check longer parts for valid json
while [ isJson notesV.json ]
do
((x++))
tail -n $x notes.json > notesV.json
done

#go back to last well known json
((x--))
tail -n $x notes.json > notesV.json

Writing isJson seems like the hard part, cause I don't know how jq works ;)

PS. This is more of an explaination and writing down suggestions for anyone who might do this in the future than a real issue. Thanks for the useful program and have a nice day.