def __init__(self): cmd.Cmd.__init__(self) self.prompt = 'cmedb > ' try: # set the database connection to autocommit w/ isolation level conn = sqlite3.connect('data/cme.db', check_same_thread=False) conn.text_factory = str conn.isolation_level = None self.db = CMEDatabase(conn) except Exception as e: print "[-] Could not connect to database: {}".format(e) sys.exit(1) try: self.config = ConfigParser() self.config.read('cme.conf') except Exception as e: print "[-] Error reading cme.conf: {}".format(e)
if args.verbose: setup_debug_logger() logger = CMEAdapter(setup_logger()) if not os.path.exists('data/cme.db'): logger.error( 'Could not find CME database, did you run the setup_database.py script?' ) sys.exit(1) # set the database connection to autocommit w/ isolation level db_connection = sqlite3.connect('data/cme.db', check_same_thread=False) db_connection.text_factory = str db_connection.isolation_level = None db = CMEDatabase(db_connection) if args.cred_id: try: c_id, credtype, domain, username, password = db.get_credentials( filterTerm=args.cred_id)[0] args.username = [username] if not args.domain: args.domain = domain if credtype == 'hash': args.hash = [password] elif credtype == 'plaintext': args.password = [password] except IndexError: logger.error("Invalid database credential ID!")