def main(): args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter) try: os.makedirs(args['data_dir']) except OSError: pass strm = os.popen("ps -ef | grep -i 'selfspy' | grep -v 'grep'") time.sleep(1) res = strm.read() if len(res.split('\n')) > 2: print "It seems there's already a selfspy process; shutting down." sys.exit(1) if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print 'Password failed' sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = make_encrypter(new_password) print 'Re-encrypting your keys...' astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print 'Exiting...' sys.exit(0) astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) try: astore.run() except SystemExit: astore.close() except KeyboardInterrupt: pass
def main(): args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter) try: os.makedirs(args['data_dir']) except OSError: pass lockname = os.path.join(args['data_dir'], LOCK_FILE) lock = lockfile.FileLock(lockname) if lock.is_locked(): print '%s is locked! I am probably already running.' % lockname print 'If you can find no selfspy process running, it is a stale lock and you can safely remove it.' print 'Shutting down.' sys.exit(1) if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print 'Password failed' sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = make_encrypter(new_password) print 'Re-encrypting your keys...' astore = ActivityStore(os.path.join(args['data_dir'], DBNAME), encrypter, store_text=(not args['no_text'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print 'Exiting...' sys.exit(0) astore = ActivityStore(os.path.join(args['data_dir'], DBNAME), encrypter, store_text=(not args['no_text'])) try: astore.run() except SystemExit: astore.close()
def main(): try: args = vars(parse_config()) except EnvironmentError as e: print(str(e)) sys.exit(1) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter, read_only=True) ss = Selfstats(os.path.join(args['data_dir'], cfg.DBNAME), args) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) models.ENCRYPTER = make_encrypter(args['password']) if not check_password.check( args['data_dir'], models.ENCRYPTER, read_only=True): print('Password failed') sys.exit(1) ss.do()
def main(): args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter, read_only=True) ss = Selfstats(os.path.join(args['data_dir'], cfg.DBNAME), args) if args['limit']: try: int(args['limit'][0]) except ValueError: print 'First argument to --limit must be an integer' sys.exit(1) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) models.ENCRYPTER = make_encrypter(args['password']) if not check_password.check( args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) ss.do()
def main(): args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter, read_only=True) ss = Selfstats(os.path.join(args['data_dir'], cfg.DBNAME), args) if args['limit']: try: int(args['limit'][0]) except ValueError: print 'First argument to --limit must be an integer' sys.exit(1) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) models.ENCRYPTER = make_encrypter(args['password']) if not check_password.check(args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) ss.do()
def main(): try: args = vars(parse_config()) except EnvironmentError as e: print str(e) sys.exit(1) args['data_dir'] = os.path.expanduser(args['data_dir']) print args['data_dir'] def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter, read_only=True) ss = Selfstats(os.path.join(args['data_dir'], cfg.DBNAME), args) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) models.ENCRYPTER = make_encrypter(args['password']) if not check_password.check(args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) # ss.do() return ss
def main(): args = vars(parse_config()) args['data_dir'] = os.path.expanduser(args['data_dir']) ss = Selfstats(os.path.join(args['data_dir'], DBNAME), args) if args['limit']: try: int(args['limit'][0]) except ValueError: print 'First argument to --limit must be an integer' sys.exit(1) if ss.need_text or ss.need_keys: if args['password'] is None: args['password'] = get_password() if args['password'] == "": models.ENCRYPTER = None else: models.ENCRYPTER = Blowfish.new(hashlib.md5(args['password']).digest()) if not check_password.check(args['data_dir'], models.ENCRYPTER, read_only=True): print 'Password failed' sys.exit(1) ss.do()
def main(): try: args = vars(parse_config()) except EnvironmentError as e: print str(e) sys.exit(1) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter) try: os.makedirs(args['data_dir']) except OSError: pass lockname = os.path.join(args['data_dir'], cfg.LOCK_FILE) cfg.LOCK = LockFile(lockname) if cfg.LOCK.is_locked(): print '%s is locked! I am probably already running.' % lockname print 'If you can find no selfspy process running, it is a stale lock and you can safely remove it.' print 'Shutting down.' sys.exit(1) if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print 'Password failed' sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = make_encrypter(new_password) print 'Re-encrypting your keys...' astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print 'Exiting...' sys.exit(0) astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) cfg.LOCK.acquire() try: astore.run() except SystemExit: astore.close() except KeyboardInterrupt: pass # In OS X this is has to be released in sniff_cocoa cfg.LOCK.release()
def main(): try: args = vars(parse_config()) except EnvironmentError as e: print(str(e)) sys.exit(1) args['data_dir'] = os.path.expanduser(args['data_dir']) def check_with_encrypter(password): encrypter = make_encrypter(password) return check_password.check(args['data_dir'], encrypter) try: os.makedirs(args['data_dir']) except OSError: pass lockname = os.path.join(args['data_dir'], cfg.LOCK_FILE) cfg.LOCK = LockFile(lockname) if cfg.LOCK.is_locked(): print('%s is locked! I am probably already running.' % lockname) print('If you can find no selfspy process running, it is a stale lock and you can safely remove it.') print('Shutting down.') sys.exit(1) if args['no_text']: args['password'] = "" if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = make_encrypter(args['password']) if not check_password.check(args['data_dir'], encrypter): print('Password failed') sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = make_encrypter(new_password) print('Re-encrypting your keys...') astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print('Exiting...') sys.exit(0) astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) cfg.LOCK.acquire() try: astore.run() except SystemExit: astore.close() except KeyboardInterrupt: pass # In OS X this is has to be released in sniff_cocoa cfg.LOCK.release()
def main(): try: args = vars(parse_config()) except EnvironmentError as ex: print(str(ex)) sys.exit(1) print(args) args['data_dir'] = os.path.expanduser(args['data_dir']) try: os.makedirs(args['data_dir']) except OSError: pass lockname = os.path.join(args['data_dir'], cfg.LOCK_FILE) cfg.LOCK = LockFile(lockname) if cfg.LOCK.is_locked(): print('%s is locked! I am probably already running.' % lockname) print('If you can find no selfspy process running, it is a stale lock ' 'and you can safely remove it.') print('Shutting down.') sys.exit(1) try_db_conversion = False salt_file_path = os.path.join(args['data_dir'], cfg.SALT_FILE) if os.path.exists(salt_file_path): with open(salt_file_path, 'rb') as f: salt = f.read() else: try_db_conversion = True print( 'No salt file found, generating salt and attempting db conversion') salt = os.urandom(16) with open(salt_file_path, 'wb') as f: f.write(salt) def check_with_encrypter(password): encrypter = selfspy.encryption.make_encrypter(salt, password) return check_password.check(args['data_dir'], encrypter) digest_path = os.path.join(args['data_dir'], check_password.DIGEST_NAME) if try_db_conversion and os.path.exists(digest_path): os.remove(digest_path) if args['password'] is None: args['password'] = get_password(verify=check_with_encrypter) encrypter = selfspy.encryption.make_encrypter(salt, args['password']) if try_db_conversion: selfspy.models.ENCRYPTER = _make_legacy_encrypter(args['password']) sessionmaker = selfspy.models.initialize( os.path.join(args['data_dir'], cfg.DBNAME)) session = sessionmaker() try: for key in session.query(selfspy.models.Keys).all(): dtext = key.decrypt_text() dkeys = key.decrypt_keys() key.encrypt_text(dtext, encrypter) key.encrypt_keys(dkeys, encrypter) for window in session.query(selfspy.models.Window).all(): window.set_title(window.title, encrypter) session.commit() except Exception as e: session.rollback() raise sessionmaker = selfspy.models.initialize( os.path.join(args['data_dir'], cfg.DBNAME)) session = sessionmaker() for window in session.query(selfspy.models.Window).all(): encrypter.decrypt(window.title.encode('utf8')).decode('utf8') if not check_password.check(args['data_dir'], encrypter): print('Password failed') sys.exit(1) if args['change_password']: new_password = get_password(message="New Password: ") new_encrypter = selfspy.encryption.make_encrypter(salt, new_password) print('Re-encrypting your keys...') astore = ActivityStore( os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) astore.change_password(new_encrypter) # delete the old password.digest os.remove(os.path.join(args['data_dir'], check_password.DIGEST_NAME)) check_password.check(args['data_dir'], new_encrypter) # don't assume we want the logger to run afterwards print('Exiting...') sys.exit(0) astore = ActivityStore( os.path.join(args['data_dir'], cfg.DBNAME), encrypter, store_text=(not args['no_text']), repeat_char=(not args['no_repeat'])) try: cfg.LOCK.acquire() try: astore.run() except SystemExit: astore.close() finally: cfg.LOCK.release()