-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathREADME
More file actions
90 lines (65 loc) · 2.24 KB
/
Copy pathREADME
File metadata and controls
90 lines (65 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# SSHMonitorPy
Python implementation of SSHMonitor.rb.
SSHMonitorPy notifies you of any ssh attempts to your computer, whether the attempts are successful or not.
Build program:
sudo python setup.py install
Remove program:
python setup.py remove
Modify version in setup.py before building:
setup(
packages=[],
name='sshmonitor',
version='0.0.6', # increment version number
Build package for PyPi:
python setup.py sdist
twine upload dist/*
NOTE: If twine does not work with the above command you can try,
twine upload --repository-url 'https://upload.pypi.org/legacy/' dist/sshmonitor-0.0.6.tar.gz
Contents of ~/.pypirc:
[distutils]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.python.org/pypi
username=username
password='password'
[pypitest]
repository=https://testpypi.python.org/pypi
username=username
password='password'
Compile C Module
gcc -c -fPIC masquerade.c -o masquerade.o
gcc masquerade.o -shared -o libmasquerade.so
or
gcc -shared -o libmasquerade.so -fPIC masquerade.c
Compile masquerade(uses pthread)
gcc masquerade.c -o masquerade -lpthread
Building libbuild.so
gcc -c -fPIC src/build.c -o libbuild.o
gcc libbuild.o -shared -o libbuild.so
cp -i src/lib/shared/libbuild.so src/lib/shared/original.libbuild.so
cp libbuild.so src/lib/shared/
>>> import os
>>> import ctypes
>>> shared_object = 'libmasquerade.so'
>>> shared_object_path = os.path.join(*(os.path.split(os.path.__file__)[:-1] + (shared_object, )))
>>> User = ctypes.cdll.LoadLibrary(shared_object_path)
>>> User.masquerade('anthony')
anthony@ghost:~/Documents/Python/sshmonitor/src$ sudo python
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, ctypes
>>> from ctypes import cdll
>>> libmasquerade = cdll.LoadLibrary('/home/anthony/Documents/Python/sshmonitor/src/libmasquerade.so')
>>> libmasquerade.masquerade('anthony')
anthony
Compile GTK UI
gcc notify-gtk.c -o notify-gtk `pkg-config --cflags --libs gtk+-2.0`
Create shared object via gcc
gcc -shared -o libmasquerade.so -fPIC masquerade.c -lpthread
Set env
env DISPLAY=:0
Debugging sshmonitor.py
sudo gdb --args python -dv sshmonitor.py --disable-email --verbose