forked from ooni/probe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
286 lines (233 loc) · 8.58 KB
/
setup.py
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
"""
ooniprobe: a network interference detection tool
================================================
.. image:: https://travis-ci.org/TheTorProject/ooni-probe.png?branch=master
:target: https://travis-ci.org/TheTorProject/ooni-probe
.. image:: https://coveralls.io/repos/TheTorProject/ooni-probe/badge.png
:target: https://coveralls.io/r/TheTorProject/ooni-probe
___________________________________________________________________________
.. image:: https://ooni.torproject.org/images/ooni-header-mascot.png
:target: https:://ooni.torproject.org/
OONI, the Open Observatory of Network Interference, is a global observation
network which aims is to collect high quality data using open methodologies,
using Free and Open Source Software (FL/OSS) to share observations and data
about the various types, methods, and amounts of network tampering in the
world.
Read this before running ooniprobe!
-----------------------------------
Running ooniprobe is a potentially risky activity. This greatly depends on the
jurisdiction in which you are in and which test you are running. It is
technically possible for a person observing your internet connection to be
aware of the fact that you are running ooniprobe. This means that if running
network measurement tests is something considered to be illegal in your country
then you could be spotted.
Furthermore, ooniprobe takes no precautions to protect the install target machine
from forensics analysis. If the fact that you have installed or used ooni
probe is a liability for you, please be aware of this risk.
Setup ooniprobe
-------------------
To install ooniprobe you will need the following dependencies:
* python
* python-dev
* python-setuptools
* build-essential
* libdumbnet1
* python-dumbnet
* python-libpcap
* tor
* libgeoip-dev
* libpcap0.8-dev
* libssl-dev
* libffi-dev
* libdumbnet-dev
On debian based systems this can generally be done by running:
.. code:: bash
sudo apt-get install -y build-essential libdumbnet-dev libpcap-dev libgeoip-dev libffi-dev python-dev python-pip
When you got them run:
.. code:: bash
sudo pip install ooniprobe
Using ooniprobe
---------------
It is recommended that you start the ooniprobe-agent system daemon that will
expose a localhost only Web UI and automatically run tests for you.
This can be done with:
.. code:: bash
ooniprobe-agent start
Then connect to the local web interface on http://127.0.0.1:8842/
Have fun!
"""
from __future__ import print_function
import os
import errno
import tempfile
from glob import glob
from ConfigParser import SafeConfigParser
from os.path import join as pj
from setuptools import setup
from setuptools.command.install import install as InstallCommand
from subprocess import check_call
from ooni import __version__, __author__
CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Environment :: Console
Framework :: Twisted
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: End Users/Desktop
Intended Audience :: Information Technology
Intended Audience :: Science/Research
Intended Audience :: Telecommunications Industry
License :: OSI Approved :: BSD License
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2 :: Only
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Operating System :: MacOS :: MacOS X
Operating System :: POSIX
Operating System :: POSIX :: BSD
Operating System :: POSIX :: BSD :: BSD/OS
Operating System :: POSIX :: BSD :: FreeBSD
Operating System :: POSIX :: BSD :: NetBSD
Operating System :: POSIX :: BSD :: OpenBSD
Operating System :: POSIX :: Linux
Operating System :: Unix
Topic :: Scientific/Engineering :: Information Analysis
Topic :: Security
Topic :: Security :: Cryptography
Topic :: Software Development :: Libraries :: Application Frameworks
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Software Development :: Testing
Topic :: Software Development :: Testing :: Traffic Generation
Topic :: System :: Networking :: Monitoring
"""
def is_lepidopter():
return os.path.exists('/etc/default/lepidopter')
def is_updater_installed():
return os.path.exists('/etc/lepidopter-update/version')
def install_lepidopter_update():
check_call(["data/lepidopter-update.py", "install"])
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as ose:
if ose.errno != errno.EEXIST:
raise
class OoniInstall(InstallCommand):
def gen_config(self, share_path):
config_file = pj(tempfile.mkdtemp(), "ooniprobe.conf.sample")
o = open(config_file, "w+")
with open("data/ooniprobe.conf.sample") as f:
for line in f:
if "/usr/share" in line:
line = line.replace("/usr/share", share_path)
o.write(line)
o.close()
return config_file
def set_data_files(self, prefix):
share_path = pj(prefix, 'share')
if prefix.startswith("/usr"):
var_path = "/var/lib/"
else:
var_path = pj(prefix, 'var', 'lib')
self.distribution.data_files.append(
(
pj(share_path, 'ooni', 'decks-available'),
glob('data/decks/*')
)
)
settings = SafeConfigParser()
settings.add_section("directories")
settings.set("directories", "usr_share",
os.path.join(share_path, "ooni"))
settings.set("directories", "var_lib",
os.path.join(var_path, "ooni"))
settings.set("directories", "etc",
os.path.join(var_path, "ooni"))
with open("ooni/settings.ini", "w+") as fp:
settings.write(fp)
mkdir_p(pj(var_path, 'ooni'))
mkdir_p(pj(share_path, 'ooni'))
mkdir_p(pj(share_path, 'ooni', 'decks-available'))
def pre_install(self):
prefix = os.path.abspath(self.prefix)
self.set_data_files(prefix)
def run(self):
self.pre_install()
self.do_egg_install()
if is_lepidopter() and not is_updater_installed():
print("Lepidopter now requires that ooniprobe is installed via the "
"updater")
print("Let me install the auto-updater for you and we shall use that "
"for updates in the future.")
install_lepidopter_update()
def setup_package():
setup_requires = []
install_requires = []
dependency_links = []
data_files = []
packages = [
'ooni',
'ooni.agent',
'ooni.common',
'ooni.contrib',
'ooni.contrib.dateutil',
'ooni.contrib.dateutil.tz',
'ooni.deck',
'ooni.kit',
'ooni.nettests',
'ooni.nettests.manipulation',
'ooni.nettests.experimental',
'ooni.nettests.scanning',
'ooni.nettests.blocking',
'ooni.nettests.third_party',
'ooni.scripts',
'ooni.templates',
'ooni.tests',
'ooni.ui',
'ooni.ui.web',
'ooni.utils'
]
with open('requirements.txt') as f:
for line in f:
if line.startswith("#"):
continue
if line.startswith('https'):
dependency_links.append(line)
continue
install_requires.append(line)
metadata = dict(
name="ooniprobe",
version=__version__,
author=__author__,
author_email="[email protected]",
description="Network measurement tool for"
"identifying traffic manipulation and blocking.",
long_description=__doc__,
license='BSD 2 clause',
url="https://ooni.torproject.org/",
package_dir={'ooni': 'ooni'},
data_files=data_files,
packages=packages,
include_package_data=True,
dependency_links=dependency_links,
install_requires=install_requires,
setup_requires=setup_requires,
zip_safe=False,
entry_points={
'console_scripts': [
'ooniresources = ooni.scripts.ooniresources:run', # This is deprecated
'oonideckgen = ooni.scripts.oonideckgen:run', # This is deprecated
'ooniprobe = ooni.scripts.ooniprobe:run',
'oonireport = ooni.scripts.oonireport:run',
'ooniprobe-agent = ooni.scripts.ooniprobe_agent:run'
]
},
cmdclass={
"install": OoniInstall
},
classifiers=[c for c in CLASSIFIERS.split('\n') if c]
)
setup(**metadata)
if __name__ == "__main__":
setup_package()