Skip to content

Commit

Permalink
selfspy option to not record special keypresses as repeats
Browse files Browse the repository at this point in the history
using the `-r | --no-repeat` option forces individual recording of
special characters. Special characters have been recorded with a count
integer <[Backspace]x2>. When using `-r | --no-repeat` the same 2
characters will be recorded as <[Backspace]><[Backspace]>.
  • Loading branch information
adamclerk committed Apr 8, 2014
1 parent ff773af commit 1772d59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ optional arguments:
letters. Key timings are stored to enable activity
calculation in selfstats. If this switch is used,
you will never be asked for password.
-r, --no-repeat Do not store special characters as repeated
characters.
--change-password Change the password used to encrypt the keys columns
and exit.
```
Expand Down
9 changes: 6 additions & 3 deletions selfspy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def parse_config():
parser.add_argument('-d', '--data-dir', help='Data directory for selfspy, where the database is stored. Remember that Selfspy must have read/write access. Default is %s' % cfg.DATA_DIR, default=cfg.DATA_DIR)

parser.add_argument('-n', '--no-text', action='store_true', help='Do not store what you type. This will make your database smaller and less sensitive to security breaches. Process name, window titles, window geometry, mouse clicks, number of keys pressed and key timings will still be stored, but not the actual letters. Key timings are stored to enable activity calculation in selfstats. If this switch is used, you will never be asked for password.')

parser.add_argument('-r', '--no-repeat', action='store_true', help='Do not store special characters as repeated characters.')

parser.add_argument('--change-password', action="store_true", help='Change the password used to encrypt the keys columns and exit.')

return parser.parse_args()
Expand Down Expand Up @@ -107,7 +108,8 @@ def check_with_encrypter(password):
print 'Re-encrypting your keys...'
astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME),
encrypter,
store_text=(not args['no_text']))
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))
Expand All @@ -118,7 +120,8 @@ def check_with_encrypter(password):

astore = ActivityStore(os.path.join(args['data_dir'], cfg.DBNAME),
encrypter,
store_text=(not args['no_text']))
store_text=(not args['no_text']),
repeat_char=(not args['no_repeat']))
cfg.LOCK.acquire()
try:
astore.run()
Expand Down
6 changes: 4 additions & 2 deletions selfspy/activity_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def __init__(self, key, time, is_repeat):


class ActivityStore:
def __init__(self, db_name, encrypter=None, store_text=True):
def __init__(self, db_name, encrypter=None, store_text=True, repeat_char=True):
self.session_maker = models.initialize(db_name)

models.ENCRYPTER = encrypter

self.store_text = store_text
self.repeat_char = repeat_char
self.curtext = u""

self.key_presses = []
Expand Down Expand Up @@ -160,7 +161,8 @@ def filter_many(self):

def store_keys(self):
""" Stores the current queued key-presses """
self.filter_many()
if self.repeat_char:
self.filter_many()

if self.key_presses:
keys = [press.key for press in self.key_presses]
Expand Down

0 comments on commit 1772d59

Please sign in to comment.