Skip to content

Instantly share code, notes, and snippets.

@bobquest33
Last active May 18, 2017 20:59
Show Gist options
  • Select an option

  • Save bobquest33/8fff6d777fafeba46b315b2e778c18ec to your computer and use it in GitHub Desktop.

Select an option

Save bobquest33/8fff6d777fafeba46b315b2e778c18ec to your computer and use it in GitHub Desktop.
Contains the code for recovering the Sticky Notes Data from Windows 7
from rtf.Rtf2Markdown import getMarkdown
import olefile
import sys
import chardet
import json
#Gets the notes from the File path where Sticky Notes backup is preent
def get_notes(sticky_notes_file_path):
notes = []
# The file format is that of an olefile, read the database from the file
snt_file = olefile.OleFileIO(sticky_notes_file_path)
#Within the OLE database read all the notes
for storage in snt_file.listdir(storages=True, streams=False):
note_id = storage[0] # UUID-like string representing the note ID
note_text_rtf_file = '0' # RTF content of the note
#Read notes content from the ole file and append to a notes array
with snt_file.openstream([note_id, note_text_rtf_file]) as note_content:
rawdata = note_content.read()
encoding = chardet.detect(rawdata)
note_text_rtf = rawdata.decode('ascii')
notes.append({'text': getMarkdown(note_text_rtf), 'color': None})
snt_file.close()
return notes
# Main part of the program where the notes are read and saved in Json and text format
sn_path = sys.argv[1]
with open("notes.json","w") as wp:
vals = get_notes(sn_path)
snotes = json.dumps(vals,indent=4)
print(snotes)
wp.write(snotes)
with open("notes.txt","w") as wp:
vals = get_notes(sn_path)
for note in vals:
print(note["text"])
text = note["text"]
wp.write(text)
wp.write("------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment