1.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw Wed Jun 25 22:26:34 2014 +0200
1.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw Fri Jul 18 13:45:09 2014 +0100
1.3 @@ -39,6 +39,8 @@
1.4 import urllib
1.5 import urllib2
1.6 import webbrowser
1.7 +import _winreg
1.8 +import re
1.9
1.10 from PyQt4 import QtCore
1.11 from PyQt4 import QtGui
1.12 @@ -105,6 +107,27 @@
1.13 d = AboutDialog()
1.14 d.exec_()
1.15
1.16 + def getProxySettings(self):
1.17 + aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_CURRENT_USER)
1.18 + aKey = _winreg.OpenKey(aReg, r"Software\Microsoft\Windows\CurrentVersion\Internet Settings")
1.19 + subCount, valueCount, lastModified = _winreg.QueryInfoKey(aKey)
1.20 + reg_entries = dict()
1.21 + for i in range(valueCount):
1.22 + try:
1.23 + n,v,t = _winreg.EnumValue(aKey,i)
1.24 + reg_entries[n] = v
1.25 + except EnvironmentError:
1.26 + break
1.27 + _winreg.CloseKey(aKey)
1.28 +
1.29 + if 'ProxyEnable' in reg_entries.keys() and reg_entries['ProxyEnable'] == 1:
1.30 + proxy_search = re.search(r"(?<=http=)(?P<ProxyServer>.*?)(?=;)", reg_entries['ProxyServer'])
1.31 + if proxy_search:
1.32 + proxies = proxy_search.groupdict()
1.33 + if 'ProxyServer' in proxies.keys(): # found http proxy
1.34 + return {'ProxyServer': proxies['ProxyServer']}
1.35 + return {'ProxyServer': reg_entries['ProxyServer']}
1.36 + return None
1.37
1.38 def clicked_browser(self):
1.39 """wish for safe internet browsing"""
1.40 @@ -114,16 +137,22 @@
1.41 return
1.42
1.43 try:
1.44 -
1.45 # get a proper browsing VM
1.46 Cygwin.start_X11()
1.47
1.48 # TODO: HARDCODED ADDRESS OF OPENSECURITYD
1.49 - browsing_vm = urllib2.urlopen('http://127.0.0.1:8080/browsing').readline()
1.50 - print('Called http://127.0.0.1:8080/browsing got: ' + str(browsing_vm))
1.51 -
1.52 + proxy_support = urllib2.ProxyHandler({})
1.53 + opener = urllib2.build_opener(proxy_support)
1.54 + urllib2.install_opener(opener)
1.55 +
1.56 + req_data = ""
1.57 + proxy = self.getProxySettings()
1.58 + if proxy:
1.59 + req_data = '?' + urllib.urlencode(proxy)
1.60 + req = 'http://127.0.0.1:8080/browsing'+ req_data
1.61 + browsing_vm = urllib2.urlopen(req).readline()
1.62 + print('Called '+ req + ' got: ' + str(browsing_vm))
1.63 except:
1.64 -
1.65 QtGui.QApplication.instance().processEvents()
1.66 QtGui.QMessageBox.critical(None, 'Failed to invoke Safe Internet Browsing', 'OpenSecurity Error')
1.67
1.68 @@ -218,6 +247,8 @@
1.69
1.70 self._menu_format.clear()
1.71 for m in machines:
1.72 + if u'SecurityDVM0' in m:
1.73 + continue
1.74 a = self._menu_format.addAction(m + '\\\\' + machines[m])
1.75 a.setIcon(self._icon_network)
1.76 a.triggered.connect(self.format_drive)