Subversion Repositories kim

Rev

Rev 6 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# Author: Tomás Vírseda <tomasvirseda@gmail.com>
# Version: 0.1
# License: GPLv3
# Description: KIM (Keep In Mind) is a little script to extract visited
#              SAP Notes from webbrowsers (currently Firefox and Chrome)
# Docs
# Firefox: https://github.com/shadow-box/Violent-Python-Examples/blob/master/Chapter-3/6-firefoxParse.py
# Chrome: https://github.com/karthikeyankc/HistoryAnalyzer/blob/master/HistoryAnalyzer.py
# https://sandersonforensics.com/forum/content.php?205-Chrome-history-with-Recursive-Common-Table-Expressions
"""


import argparse

try:
    from .logger import Logger
    from .utils import *
    from .project import *
except:
    from logger import Logger
    from utils import Utils
    from project import *


def get_app_options():
    parser = argparse.ArgumentParser(description='%s by %s <%s>' % (name, author, author_email))
    #~ parser.add_argument('-a', '--all', action='all', help='Get SAP Notes from all browsers')
    #~ parser = parser.add_mutually_exclusive_group(required=False)
    #~ parser.add_argument('-f', '--firefox', action='store_true', dest='Firefox', help='Get SAP Notes from Firefox')
    #~ parser.add_argument('-c', '--chrome', dest='Chrome', help='Get SAP Notes from Chrome')
    parser.add_argument('-d',  '--debug',   dest='LOGLEVEL',    help='Increase output verbosity', action='store', default='INFO')
    parser.add_argument('-v', '--version', action='version', version='%s %s' % (name, version))
    params = parser.parse_args()

    return params

class KIM:
    snotes = set()
    dnotes = {}
    log = None
    utils = None
    options = None

    def __init__(self):
        self.options = get_app_options()
        self.utils = Utils(self.options)
        self.log = Logger('KIM', level=self.options.LOGLEVEL).get_logger()
        self.log.debug('Starting %s %s', name, version)

    def run(self):
        snff = self.utils.get_firefox_history()
        snch = self.utils.get_chrome_history()
        usndict = self.utils.get_uniq_sapnotes([snff, snch])
        self.log.debug("Total Unique SAP Notes: %d", len(usndict))

        return usndict


def main():
    kim = KIM()
    usndict = kim.run()
    return usndict

if __name__ == '__main__':
    main()