oliver@199
|
1 |
# -*- coding: utf-8 -*-
|
oliver@199
|
2 |
|
oliver@199
|
3 |
# ------------------------------------------------------------
|
oliver@199
|
4 |
# directly start the browsing
|
oliver@199
|
5 |
#
|
oliver@199
|
6 |
# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
|
oliver@199
|
7 |
#
|
oliver@199
|
8 |
# Copyright (C) 2013 AIT Austrian Institute of Technology
|
oliver@199
|
9 |
# AIT Austrian Institute of Technology GmbH
|
oliver@199
|
10 |
# Donau-City-Strasse 1 | 1220 Vienna | Austria
|
oliver@199
|
11 |
# http://www.ait.ac.at
|
oliver@199
|
12 |
#
|
oliver@199
|
13 |
# This program is free software; you can redistribute it and/or
|
oliver@199
|
14 |
# modify it under the terms of the GNU General Public License
|
oliver@199
|
15 |
# as published by the Free Software Foundation version 2.
|
oliver@199
|
16 |
#
|
oliver@199
|
17 |
# This program is distributed in the hope that it will be useful,
|
oliver@199
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
oliver@199
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
oliver@199
|
20 |
# GNU General Public License for more details.
|
oliver@199
|
21 |
#
|
oliver@199
|
22 |
# You should have received a copy of the GNU General Public License
|
oliver@199
|
23 |
# along with this program; if not, write to the Free Software
|
oliver@199
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
oliver@199
|
25 |
# Boston, MA 02110-1301, USA.
|
oliver@199
|
26 |
# ------------------------------------------------------------
|
oliver@199
|
27 |
|
oliver@199
|
28 |
|
oliver@199
|
29 |
# ------------------------------------------------------------
|
oliver@199
|
30 |
# imports
|
oliver@199
|
31 |
|
oliver@199
|
32 |
import sys
|
oliver@199
|
33 |
import urllib
|
oliver@199
|
34 |
import urllib2
|
oliver@199
|
35 |
|
oliver@199
|
36 |
from PyQt4 import QtCore
|
oliver@199
|
37 |
from PyQt4 import QtGui
|
oliver@199
|
38 |
|
oliver@199
|
39 |
# local
|
oliver@199
|
40 |
import __init__ as opensecurity
|
mihai@238
|
41 |
import proxy_getter
|
oliver@199
|
42 |
|
oliver@199
|
43 |
if sys.platform == 'win32' or sys.platform == 'cygwin':
|
oliver@199
|
44 |
from cygwin import Cygwin
|
oliver@199
|
45 |
|
oliver@199
|
46 |
|
oliver@199
|
47 |
# ------------------------------------------------------------
|
oliver@199
|
48 |
# code
|
oliver@199
|
49 |
|
oliver@199
|
50 |
|
oliver@199
|
51 |
# start
|
oliver@199
|
52 |
if __name__ == "__main__":
|
oliver@199
|
53 |
|
oliver@199
|
54 |
if not (sys.platform == 'win32' or sys.platform == 'cygwin'):
|
mihai@238
|
55 |
QtGui.QMessageBox.critical(None, 'OpenSecurity Error', 'This action is not supported on this platform.\nSorry.')
|
oliver@199
|
56 |
sys.exit(1)
|
oliver@199
|
57 |
|
oliver@199
|
58 |
try:
|
oliver@199
|
59 |
|
oliver@199
|
60 |
# get a proper browsing VM
|
oliver@199
|
61 |
Cygwin.start_X11()
|
mihai@238
|
62 |
|
mihai@238
|
63 |
proxy_support = urllib2.ProxyHandler({})
|
mihai@238
|
64 |
opener = urllib2.build_opener(proxy_support)
|
mihai@238
|
65 |
urllib2.install_opener(opener)
|
oliver@199
|
66 |
|
mihai@238
|
67 |
req_data = ""
|
mihai@238
|
68 |
proxy = proxy_getter.getProxySettings()
|
mihai@238
|
69 |
if proxy:
|
mihai@238
|
70 |
req_data = '?' + urllib.urlencode(proxy)
|
mihai@238
|
71 |
req = 'http://127.0.0.1:8080/browsing'+ req_data
|
mihai@238
|
72 |
browsing_vm = urllib2.urlopen(req).readline()
|
mihai@238
|
73 |
print('Called '+ req + ' got: ' + str(browsing_vm))
|
oliver@199
|
74 |
|
oliver@199
|
75 |
except:
|
oliver@199
|
76 |
|
oliver@199
|
77 |
QtGui.QApplication.instance().processEvents()
|
oliver@199
|
78 |
QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')
|
oliver@199
|
79 |
|