Added WPAD proxy support.
authorBarthaM@N3SIM1218.D03.arc.local
Wed, 24 Sep 2014 16:40:43 +0100
changeset 223a4fb6694e6fe
parent 222 ac227c9dc244
child 224 dc7cee534574
child 225 e68561e69f86
Added WPAD proxy support.
Not fully tested
OpenSecurity/bin/opensecurity_tray.pyw
OpenSecurity/bin/opensecurityd.pyw
OpenSecurity/bin/vmmanager.pyw
     1.1 --- a/OpenSecurity/bin/opensecurity_tray.pyw	Fri Sep 12 12:16:51 2014 +0200
     1.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw	Wed Sep 24 16:40:43 2014 +0100
     1.3 @@ -119,6 +119,9 @@
     1.4              except EnvironmentError:                                               
     1.5                  break
     1.6          _winreg.CloseKey(aKey)
     1.7 +        
     1.8 +        if 'AutoConfigURL' in reg_entries.keys():
     1.9 +            return {'ProxyAutoConfigURL': reg_entries['AutoConfigURL']}
    1.10  
    1.11          if 'ProxyEnable' in reg_entries.keys() and reg_entries['ProxyEnable'] == 1:
    1.12              proxy_search = re.search(r"(?<=http=)(?P<ProxyServer>.*?)(?=;)", reg_entries['ProxyServer'])
    1.13 @@ -127,6 +130,7 @@
    1.14                  if 'ProxyServer' in proxies.keys(): # found http proxy
    1.15                      return {'ProxyServer': proxies['ProxyServer']}  
    1.16              return {'ProxyServer': reg_entries['ProxyServer']}
    1.17 +            
    1.18          return None
    1.19  
    1.20      def clicked_browser(self):
     2.1 --- a/OpenSecurity/bin/opensecurityd.pyw	Fri Sep 12 12:16:51 2014 +0200
     2.2 +++ b/OpenSecurity/bin/opensecurityd.pyw	Wed Sep 24 16:40:43 2014 +0100
     2.3 @@ -34,9 +34,9 @@
     2.4  # imports
     2.5  
     2.6  import json
     2.7 -import os
     2.8 +#import os
     2.9  import os.path
    2.10 -import subprocess
    2.11 +#import subprocess
    2.12  import sys
    2.13  import tempfile
    2.14  import web
    2.15 @@ -102,9 +102,12 @@
    2.16          global gvm_mgr
    2.17          try:
    2.18              proxy = None
    2.19 +            wpad = None
    2.20              if 'ProxyServer' in args:
    2.21                  proxy = args['ProxyServer']
    2.22 -            result = gvm_mgr.handleBrowsingRequest(proxy)
    2.23 +            if 'ProxyAutoConfigURL' in args:
    2.24 +                wpad = args['ProxyAutoConfigURL']
    2.25 +            result = gvm_mgr.handleBrowsingRequest(proxy, wpad)
    2.26              return result
    2.27          except:
    2.28              raise web.internalerror()
    2.29 @@ -258,7 +261,7 @@
    2.30          global gvm_mgr
    2.31          command = '/' + command
    2.32          showTrayMessage('Launching application in isolated VM...', 7000)
    2.33 -        result = Cygwin.sshExecuteX11(command, gvm_mgr.getHostOnlyIP(name), 'osecuser', Cygwin.cygPath(gvm_mgr.getMachineFolder()) + '/' + name + '/dvm_key'  )
    2.34 +        Cygwin.sshExecuteX11(command, gvm_mgr.getHostOnlyIP(name), 'osecuser', Cygwin.cygPath(gvm_mgr.getMachineFolder()) + '/' + name + '/dvm_key'  )
    2.35          return 'Command ' + str(command) + ' started on VM "' + name + '" with IP ' + gvm_mgr.getHostOnlyIP(name)
    2.36      
    2.37  
     3.1 --- a/OpenSecurity/bin/vmmanager.pyw	Fri Sep 12 12:16:51 2014 +0200
     3.2 +++ b/OpenSecurity/bin/vmmanager.pyw	Wed Sep 24 16:40:43 2014 +0100
     3.3 @@ -740,9 +740,9 @@
     3.4          return network_drives
     3.5      
     3.6      # handles browsing request    
     3.7 -    def handleBrowsingRequest(self, proxy):
     3.8 +    def handleBrowsingRequest(self, proxy, wpad):
     3.9          showTrayMessage('Starting Secure Browsing...', 7000)
    3.10 -        handler = BrowsingHandler(self, proxy)
    3.11 +        handler = BrowsingHandler(self, proxy, wpad)
    3.12          handler.start()
    3.13          return 'ok'
    3.14      
    3.15 @@ -958,20 +958,25 @@
    3.16  class BrowsingHandler(threading.Thread):
    3.17      vmm = None
    3.18      proxy = None
    3.19 -    def __init__(self, vmmanager, proxy):
    3.20 +    wpad = None
    3.21 +    def __init__(self, vmmanager, proxy, wpad):
    3.22          threading.Thread.__init__(self)
    3.23          self.vmm = vmmanager
    3.24          self.proxy = proxy
    3.25 +        self.wpad = wpad
    3.26          
    3.27      def run(self):
    3.28          #browser = '\\\"/usr/bin/chromium; pidof dbus-launch | xargs kill\\\"'
    3.29          #browser = '\\\"/usr/bin/chromium\\\"'
    3.30          
    3.31          try:
    3.32 -            if self.proxy:
    3.33 +            if self.wpad:
    3.34 +                browser = '\\\"/usr/bin/chromium --proxy-pac-url=\\\"'+self.wpad+'\\\"\\\"'
    3.35 +            elif self.proxy:
    3.36                  browser = '\\\"export http_proxy='+self.proxy+'; /usr/bin/chromium\\\"'
    3.37              else:
    3.38                  browser = '\\\"/usr/bin/chromium\\\"'
    3.39 +                
    3.40              self.vmm.browsingManager.started.wait() 
    3.41              result = Cygwin.sshExecuteX11(browser, self.vmm.browsingManager.ip_addr, 'osecuser', Cygwin.cygPath(self.vmm.getMachineFolder()) + '/' + self.vmm.browsingManager.vm_name + '/dvm_key')
    3.42              self.vmm.backupFile('/home/osecuser/.config/chromium', self.vmm.browsingManager.appDataDir + '/OpenSecurity/')