Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Windows support! (Status: Beta!) #51

Closed
wants to merge 11 commits into from

1 participant

@Foxboron

Do not merge this pull request!

Branch for all changes related too getting selfspy running with Windows!
https://github.com/Foxboron/selfspy

Contributions are accepted. I'll bring beer and pizza.

Current bugs/problems:

selfstat.py does not like my Norwegian letters, this might be a big problem for other languages also.

Need to update the charmap with missing keys.

@Foxboron

Update:
So after a 12 hours + hackathon:
PyHooks bugs just disappears. I got no idea how, nor why.
Fixing up the sqlalchemy schema problems.
@gurgeh, i'd love if you could actually post schema info somewhere :P Then i don't have to guess.

@Foxboron

I have also added a patch. There is never a self.session.rollback() issues when needed. So added it quickly if everything else fails, does work on windows.

Foxboron added some commits
@Foxboron Foxboron closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 21, 2012
  1. @Foxboron

    Added windows sniffer

    Foxboron authored
Commits on Jan 11, 2013
  1. @Foxboron

    wat

    Foxboron authored
  2. @Foxboron

    added windows files

    Foxboron authored
  3. @Foxboron

    added pyhook

    Foxboron authored
Commits on Jan 12, 2013
  1. @Foxboron

    Fixed pyhooks bug

    Foxboron authored
Commits on Jan 19, 2013
  1. @Foxboron

    Windows support: Beta

    Foxboron authored
  2. @Foxboron

    addded requirments

    Foxboron authored
Commits on Apr 15, 2013
  1. merge fix

    Foxboron authored
  2. working

    Foxboron authored
  3. added requirements

    Foxboron authored
  4. fixed encoding issue

    Foxboron authored
This page is out of date. Refresh to see the latest.
View
15 README.md
@@ -3,7 +3,20 @@ Selfspy is a daemon for Unix/X11 and (thanks to @ljos!) Mac OS X, that continuou
See Example Statistics, below, for some of the fabulous things you can do with this data.
-*If you are a Windows programmer, I think that it would be fairly easy to get Selfspy to run there too, by creating an alternative to sniff_x.py and sniff_cocoa.py. If anyone wants to experiment with that, I look forward to your patches.*
+### Windows
+Due too Windows libs needing a external compiler to compile libs, some libs won't compile on all computers.
+These are the sinners*:
+pyHook==1.5.1
+pyCrypto==2.5
+
+They are added too the `windows-requirements.txt`, but IF you fail to build these libs, here are the precompiled binaries. pyWin32 is needed for some library dependency, pip can't install pyWin32, so please use the binary below.
+pyHook: http://sourceforge.net/projects/pyhook/files/pyhook/
+pyCrytpo: http://www.voidspace.org.uk/python/modules.shtml#pycrypto
+pyWin32: http://sourceforge.net/projects/pywin32/files/pywin32/
+
+*SQLAlchemy does compile without the external compiler, but it uses a clean Python version which might slow things down.
+
+
### Installing Selfspy
View
1  osx-requirements.txt
@@ -1,7 +1,6 @@
SQLAlchemy==0.7.6
lockfile==0.9.1
pycrypto==2.5
-python-daemon==1.6
pyobjc-core==2.4
pyobjc==2.4
keyring==1.2.2
View
3  requirements.txt
@@ -2,5 +2,4 @@ SQLAlchemy==0.7.6
lockfile==0.9.1
pycrypto==2.5
python-daemon==1.6
-keyring==1.2.2
-
+keyring==1.2.2
View
1  selfspy/__init__.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import os
import sys
View
9 selfspy/activity_store.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import time
from datetime import datetime
@@ -24,6 +25,8 @@
import platform
if platform.system() == 'Darwin':
from selfspy import sniff_cocoa
+elif platform.system() == "Windows":
+ from selfspy import sniff_win
else:
from selfspy import sniff_x
@@ -80,12 +83,16 @@ def trycommit(self):
break
except sqlalchemy.exc.OperationalError:
time.sleep(1)
+ except:
+ self.session.rollback()
def run(self):
self.session = self.session_maker()
if platform.system() == 'Darwin':
self.sniffer = sniff_cocoa.SniffCocoa()
+ if platform.system() == 'Windows':
+ self.sniffer = sniff_win.SniffWIN()
else:
self.sniffer = sniff_x.SniffX()
self.sniffer.screen_hook = self.got_screen_change
@@ -251,4 +258,4 @@ def change_password(self, new_encrypter):
dkeys = k.decrypt_keys()
k.encrypt_text(dtext, new_encrypter)
k.encrypt_keys(dkeys, new_encrypter)
- self.session.commit()
+ self.session.commit()
View
1  selfspy/check_password.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import os
View
3  selfspy/models.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import zlib
import json
@@ -193,4 +194,4 @@ def load_timings(self):
return json.loads(zlib.decompress(self.timings))
def __repr__(self):
- return "<Keys %s>" % self.nrkeys
+ return "<Keys %s>" % self.nrkeys
View
1  selfspy/password_dialog.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import sys
import getpass
View
1  selfspy/period.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
import bisect
View
101 selfspy/sniff_win.py
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+# Copyright 2012 Morten Linderud
+
+# This file is part of Selfspy
+
+# Selfspy is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Selfspy is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+
+import pyHook
+import pythoncom
+import sys
+
+class SniffWIN:
+ """Winning!"""
+ def __init__(self):
+ self.encoding = sys.stdin.encoding
+ self.key_hook = lambda x: True
+ self.mouse_button_hook = lambda x: True
+ self.mouse_move_hook = lambda x: True
+ self.screen_hook = lambda x: True
+ self.remap = {
+ 248: u"\xf8",
+ 216: u"\xd8",
+ 230: u"\xe6",
+ 198: u"\xc6",
+ 229: u"\xe5",
+ 197: u"\xc5"
+ }
+
+ def run(self):
+ try:
+ self.hm = pyHook.HookManager()
+ self.hm.KeyDown = self.KeyboardEvent
+ self.hm.MouseAllButtonsDown = self.MouseButtons
+ self.hm.MouseMove = self.MouseMove
+ self.hm.HookKeyboard()
+ self.hm.HookMouse()
+ pythoncom.PumpMessages()
+ except (SystemExit, KeyboardInterrupt,AttributeError):
+ self.hm.UnhookKeyboard()
+ self.hm.UnhookMouse()
+ sys.exit(0)
+ return 0
+
+ def cancle(self):
+ self.hm.UnhookKeyboard()
+ sys.exit()
+
+ def MouseButtons(self, event):
+ loc = event.Position
+ if event.MessageName == "mouse right down":
+ self.mouse_button_hook(3, loc[0], loc[1],)
+ if event.MessageName == "mouse left down":
+ self.mouse_button_hook(1, loc[0], loc[1])
+ if event.MessageName == "mouse middle down":
+ self.mouse_button_hook(2, loc[0], loc[1])
+ try:
+ string_event = event.WindowName.decode(self.encoding)
+ except AttributeError:
+ string_event = ""
+ self.screen_hook(str(event.Window), string_event, loc[0], loc[1], 0, 0)
+ return True
+
+ def MouseMove(self, event):
+ loc = event.Position
+ if event.MessageName == "mouse move":
+ self.mouse_move_hook(loc[0], loc[1])
+ if event.MessageName == "mouse wheel":
+ if event.Wheel == -1:
+ self.mouse_button_hook(5, loc[0], loc[1],)
+ elif event.Wheel == 1:
+ self.mouse_button_hook(4, loc[0], loc[1],)
+ return True
+
+ def KeyboardEvent(self, event):
+ modifiers = []
+ if event.Key in ["Lshift", "Rshift"]:
+ modifiers.append('Shift')
+ elif event.Key in ["Lmenu", "Rmenu"]:
+ modifiers.append('Alt')
+ elif event.Key in ["Rcontrol", "Lcontrol"]:
+ modifiers.append('Ctrl')
+ elif event.Key in ["Rwin", "Lwin"]:
+ modifiers.append('Super')
+ if event.Ascii in self.remap.keys():
+ string = self.remap[event.Ascii]
+ else:
+ string = unicode(chr(event.Ascii))
+ self.key_hook(str(event.Ascii), modifiers, string, False)
+ self.screen_hook(str(event.Window), event.WindowName.decode(self.encoding), 0, 0, 0, 0)
+ return True
View
2  selfspy/sniff_x.py
@@ -18,6 +18,8 @@
# This file is loosely based on examples/record_demo.py in python-xlib
+# -*- coding: utf8 -*-
+
import sys
from Xlib import X, XK, display
View
2  selfspy/stats.py
@@ -17,6 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with Selfspy. If not, see <http://www.gnu.org/licenses/>.
+# -*- coding: utf8 -*-
+
import os
import sys
import re
View
2  setup.py
@@ -4,6 +4,8 @@
# dep_link = []
if platform.system() == 'Darwin':
req_file = 'osx-requirements.txt'
+elif platform.system() == 'Windows':
+ req_file = 'windows-requirements.txt'
else:
req_file = 'requirements.txt'
#dep_link = ['http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/tags/xlib_0_15rc1/?view=tar#egg=pyxlib']
View
5 windows-requirements.txt
@@ -0,0 +1,5 @@
+SQLAlchemy==0.7.6
+lockfile==0.9.1
+keyring==1.2.2
+pyHook==1.5.1
+pycrypto==2.5
Something went wrong with that request. Please try again.