added opensecurity-system tray starter
authorom
Tue, 10 Dec 2013 17:24:12 +0100
changeset 376d7b4672414c
parent 36 cc6abcf9108b
child 38 560882d3d3c0
added opensecurity-system tray starter
OpenSecurity/bin/launch.py
OpenSecurity/bin/launch.pyw
OpenSecurity/bin/opensecurity_tray.py
OpenSecurity/bin/opensecurity_tray.pyw
OpenSecurity/bin/os-tray.bat
OpenSecurity/cygwin/content.txt
     1.1 --- a/OpenSecurity/bin/launch.py	Tue Dec 10 16:02:24 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,271 +0,0 @@
     1.4 -#!/bin/env python
     1.5 -# -*- coding: utf-8 -*-
     1.6 -
     1.7 -# ------------------------------------------------------------
     1.8 -# opensecurity-launcher
     1.9 -# 
    1.10 -# launches an application inside a VM
    1.11 -#
    1.12 -# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    1.13 -#
    1.14 -# Copyright (C) 2013 AIT Austrian Institute of Technology
    1.15 -# AIT Austrian Institute of Technology GmbH
    1.16 -# Donau-City-Strasse 1 | 1220 Vienna | Austria
    1.17 -# http://www.ait.ac.at
    1.18 -#
    1.19 -# This program is free software; you can redistribute it and/or
    1.20 -# modify it under the terms of the GNU General Public License
    1.21 -# as published by the Free Software Foundation version 2.
    1.22 -# 
    1.23 -# This program is distributed in the hope that it will be useful,
    1.24 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.25 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.26 -# GNU General Public License for more details.
    1.27 -# 
    1.28 -# You should have received a copy of the GNU General Public License
    1.29 -# along with this program; if not, write to the Free Software
    1.30 -# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    1.31 -# Boston, MA  02110-1301, USA.
    1.32 -# ------------------------------------------------------------
    1.33 -
    1.34 -
    1.35 -# ------------------------------------------------------------
    1.36 -# imports
    1.37 -
    1.38 -import argparse
    1.39 -import os
    1.40 -import subprocess
    1.41 -import sys
    1.42 -import urllib
    1.43 -import urllib2
    1.44 -
    1.45 -from PyQt4 import QtCore
    1.46 -from PyQt4 import QtGui
    1.47 -
    1.48 -# local
    1.49 -from about import About
    1.50 -from cygwin import Cygwin
    1.51 -from environment import Environment
    1.52 -
    1.53 -
    1.54 -# ------------------------------------------------------------
    1.55 -# code
    1.56 -
    1.57 -
    1.58 -class Chooser(QtGui.QDialog, object):
    1.59 -    
    1.60 -    """Ask the user what to launch."""
    1.61 -    
    1.62 -    def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
    1.63 -    
    1.64 -        super(Chooser, self).__init__(parent, flags)
    1.65 -        self.setWindowTitle('OpenSecuirty Launch Application')
    1.66 -        self.setup_ui()
    1.67 -        
    1.68 -        # positionate ourself central
    1.69 -        screen = QtGui.QDesktopWidget().screenGeometry()
    1.70 -        self.resize(self.geometry().width() * 1.25, self.geometry().height())
    1.71 -        size = self.geometry()
    1.72 -        self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
    1.73 -        
    1.74 -        self._vms = [ { 'name': 'SecurityDVM0', 'ip': '192.168.56.101' } ]
    1.75 -        self._apps = [ { 'name': 'Browser', 'command': '/usr/bin/iceweasel' } ]
    1.76 -        
    1.77 -        # add the VMs we know
    1.78 -        self._cbVM.clear()
    1.79 -        for vm in self._vms:
    1.80 -            self._cbVM.addItem(vm['name'])
    1.81 -            
    1.82 -        # add the commands we know
    1.83 -        self._cbApplication.clear()
    1.84 -        for app in self._apps:
    1.85 -            self._cbApplication.addItem(app['name'])
    1.86 -        
    1.87 -        
    1.88 -        
    1.89 -    def app_get(self):
    1.90 -        """The application of the user."""
    1.91 -        a = str(self._cbApplication.currentText())
    1.92 -        for app in self._apps:
    1.93 -            if a == app['name']:
    1.94 -                return app['command']
    1.95 -        return a
    1.96 -        
    1.97 -    app = property(app_get)
    1.98 -        
    1.99 -
   1.100 -    def clicked_about(self):
   1.101 -        """clicked the about button"""
   1.102 -        dlgAbout = About()
   1.103 -        dlgAbout.exec_()
   1.104 -
   1.105 -
   1.106 -    def clicked_cancel(self):
   1.107 -        """clicked the cancel button"""
   1.108 -        self.reject()
   1.109 -    
   1.110 -
   1.111 -    def clicked_ok(self):
   1.112 -        """clicked the ok button"""
   1.113 -        self.accept()
   1.114 -    
   1.115 -    
   1.116 -    def setup_ui(self):
   1.117 -        """Create the widgets."""
   1.118 -        
   1.119 -        lyMain = QtGui.QVBoxLayout(self)
   1.120 -        lyMain.setContentsMargins(8, 8, 8, 8)
   1.121 -        
   1.122 -        # content area: left pixmap, right text
   1.123 -        lyContent = QtGui.QHBoxLayout()
   1.124 -        lyMain.addLayout(lyContent)
   1.125 -        
   1.126 -        # pixmap
   1.127 -        lbPix = QtGui.QLabel()
   1.128 -        lbPix.setPixmap(QtGui.QPixmapCache.find('opensecurity_icon_64'))
   1.129 -        lyContent.addWidget(lbPix, 0, QtCore.Qt.Alignment(QtCore.Qt.AlignTop + QtCore.Qt.AlignHCenter))
   1.130 -        lyContent.addSpacing(16)
   1.131 -        
   1.132 -        # launch ...
   1.133 -        lyLaunch = QtGui.QGridLayout()
   1.134 -        lyContent.addLayout(lyLaunch)
   1.135 -        lbTitle = QtGui.QLabel('Specify details for application to launch.')
   1.136 -        lyLaunch.addWidget(lbTitle, 0, 0, 1, 2)
   1.137 -        
   1.138 -        lbVM = QtGui.QLabel('&VM-ID:')
   1.139 -        lyLaunch.addWidget(lbVM, 1, 0)
   1.140 -        self._cbVM = QtGui.QComboBox()
   1.141 -        self._cbVM.setEditable(True)
   1.142 -        self._cbVM.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
   1.143 -        lyLaunch.addWidget(self._cbVM, 1, 1)
   1.144 -        lbVM.setBuddy(self._cbVM)
   1.145 -        
   1.146 -        lbApplication = QtGui.QLabel('&Application:')
   1.147 -        lyLaunch.addWidget(lbApplication, 2, 0)
   1.148 -        self._cbApplication = QtGui.QComboBox()
   1.149 -        self._cbApplication.setEditable(True)
   1.150 -        self._cbApplication.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
   1.151 -        lyLaunch.addWidget(self._cbApplication, 2, 1)
   1.152 -        lbApplication.setBuddy(self._cbApplication)
   1.153 -        
   1.154 -        lyLaunch.addWidget(QtGui.QWidget(), 3, 0, 1, 2)
   1.155 -        lyLaunch.setColumnStretch(1, 1)
   1.156 -        lyLaunch.setRowStretch(3, 1)
   1.157 -        
   1.158 -        lyMain.addStretch(1)
   1.159 -        
   1.160 -        # buttons
   1.161 -        lyButton = QtGui.QHBoxLayout()
   1.162 -        lyMain.addLayout(lyButton)
   1.163 -        
   1.164 -        lyButton.addStretch(1)
   1.165 -        btnOk = QtGui.QPushButton('&Ok', self)
   1.166 -        btnOk.setDefault(True)
   1.167 -        btnOk.setMinimumWidth(100)
   1.168 -        lyButton.addWidget(btnOk)
   1.169 -        btnCancel = QtGui.QPushButton('&Cancel', self)
   1.170 -        btnCancel.setMinimumWidth(100)
   1.171 -        lyButton.addWidget(btnCancel)
   1.172 -        btnAbout = QtGui.QPushButton('&About', self)
   1.173 -        btnAbout.setMinimumWidth(100)
   1.174 -        lyButton.addWidget(btnAbout)
   1.175 -        
   1.176 -        button_width = max(btnOk.width(), btnCancel.width(), btnAbout.width())
   1.177 -        btnOk.setMinimumWidth(button_width)
   1.178 -        btnCancel.setMinimumWidth(button_width)
   1.179 -        btnAbout.setMinimumWidth(button_width)
   1.180 -        
   1.181 -        # reduce to the max
   1.182 -        self.resize(lyMain.minimumSize())
   1.183 -        
   1.184 -        # connectors
   1.185 -        btnOk.clicked.connect(self.clicked_ok)
   1.186 -        btnCancel.clicked.connect(self.clicked_cancel)
   1.187 -        btnAbout.clicked.connect(self.clicked_about)
   1.188 -
   1.189 -        
   1.190 -    def vm_get(self):
   1.191 -        """The vm of choice."""
   1.192 -        v = str(self._cbVM.currentText())
   1.193 -        for vm in self._vms:
   1.194 -            if v == vm['name']:
   1.195 -                return vm['ip']
   1.196 -        return v
   1.197 -        
   1.198 -    vm = property(vm_get)
   1.199 -        
   1.200 -        
   1.201 -def ask_user():
   1.202 -    """ask the user for VM and app to start"""
   1.203 -    
   1.204 -    # launch Qt
   1.205 -    app = QtGui.QApplication(sys.argv)
   1.206 -    
   1.207 -    # prebuild the pixmap cache: fetch all jpg, png and jpeg images and load them
   1.208 -    image_path = os.path.join(Environment("OpenSecurity").data_path, '..', 'gfx')
   1.209 -    for file in os.listdir(image_path):
   1.210 -        if file.lower().rpartition('.')[2] in ('jpg', 'png', 'jpeg'):
   1.211 -            QtGui.QPixmapCache.insert(file.lower().rpartition('.')[0], QtGui.QPixmap(os.path.join(image_path, file)))
   1.212 -            
   1.213 -    # we should have now our application icon
   1.214 -    app.setWindowIcon(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')))
   1.215 -    
   1.216 -    # pop up the dialog
   1.217 -    dlg = Chooser()
   1.218 -    dlg.show()
   1.219 -    app.exec_()
   1.220 -    
   1.221 -    if dlg.result() == QtGui.QDialog.Accepted:
   1.222 -        return dlg.vm, dlg.app
   1.223 -
   1.224 -    return '', ''
   1.225 -    
   1.226 -
   1.227 -def main():
   1.228 -    """entry point"""
   1.229 -    
   1.230 -    # parse command line
   1.231 -    parser = argparse.ArgumentParser(description = 'OpenSecurity Launcher: run application in VM')
   1.232 -    parser.add_argument('ip', metavar='IP', help='IP of Virtual Machine', nargs='?', type=str, default='')
   1.233 -    parser.add_argument('command', metavar='COMMAND', help='Full path of command and arguments to start inside VM', nargs='?', type=str, default='')
   1.234 -    args = parser.parse_args()
   1.235 -    
   1.236 -    # we must have at least all or none set
   1.237 -    set_ip = args.ip != ''
   1.238 -    set_command = args.command != ''
   1.239 -    set_ALL = set_ip and set_command
   1.240 -    set_NONE = (not set_ip) and (not set_command)
   1.241 -    if (not set_ALL) and (not set_NONE):
   1.242 -        sys.stderr.write("Please specify ip and command or none.\n")
   1.243 -        sys.stderr.write("Type '--help' for help.\n")
   1.244 -        sys.exit(1)
   1.245 -        
   1.246 -    # check if we need to ask the user
   1.247 -    if set_NONE:
   1.248 -        args.ip, args.command = ask_user()
   1.249 -        
   1.250 -    # still no IP? --> no chance, over and out!
   1.251 -    if args.ip == '':
   1.252 -        sys.exit(0)
   1.253 -        
   1.254 -    # ensure we have our X11 running
   1.255 -    #Cygwin.start_X11()
   1.256 -    
   1.257 -    # call the OpenSecurity Admin to launch our progie =)
   1.258 -    url_vm = urllib.quote(args.ip)
   1.259 -    url_command = urllib.quote(args.command)
   1.260 -    print(url_vm)
   1.261 -    print(url_command)
   1.262 -    
   1.263 -    # user_at_guest = args.user + '@' + args.ip
   1.264 -    # ssh = 'DISPLAY=:0 /usr/bin/ssh -Y ' + user_at_guest + ' ' + args.command
   1.265 -    # print(ssh)
   1.266 -    
   1.267 -    # # off we go!
   1.268 -    # Cygwin()(['/bin/bash', '--login', '-i', '-c', ssh], None, None, None)
   1.269 -
   1.270 -    
   1.271 -# start
   1.272 -if __name__ == "__main__":
   1.273 -    main()
   1.274 -
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/OpenSecurity/bin/launch.pyw	Tue Dec 10 17:24:12 2013 +0100
     2.3 @@ -0,0 +1,271 @@
     2.4 +#!/bin/env python
     2.5 +# -*- coding: utf-8 -*-
     2.6 +
     2.7 +# ------------------------------------------------------------
     2.8 +# opensecurity-launcher
     2.9 +# 
    2.10 +# launches an application inside a VM
    2.11 +#
    2.12 +# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    2.13 +#
    2.14 +# Copyright (C) 2013 AIT Austrian Institute of Technology
    2.15 +# AIT Austrian Institute of Technology GmbH
    2.16 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
    2.17 +# http://www.ait.ac.at
    2.18 +#
    2.19 +# This program is free software; you can redistribute it and/or
    2.20 +# modify it under the terms of the GNU General Public License
    2.21 +# as published by the Free Software Foundation version 2.
    2.22 +# 
    2.23 +# This program is distributed in the hope that it will be useful,
    2.24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.26 +# GNU General Public License for more details.
    2.27 +# 
    2.28 +# You should have received a copy of the GNU General Public License
    2.29 +# along with this program; if not, write to the Free Software
    2.30 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    2.31 +# Boston, MA  02110-1301, USA.
    2.32 +# ------------------------------------------------------------
    2.33 +
    2.34 +
    2.35 +# ------------------------------------------------------------
    2.36 +# imports
    2.37 +
    2.38 +import argparse
    2.39 +import os
    2.40 +import subprocess
    2.41 +import sys
    2.42 +import urllib
    2.43 +import urllib2
    2.44 +
    2.45 +from PyQt4 import QtCore
    2.46 +from PyQt4 import QtGui
    2.47 +
    2.48 +# local
    2.49 +from about import About
    2.50 +from cygwin import Cygwin
    2.51 +from environment import Environment
    2.52 +
    2.53 +
    2.54 +# ------------------------------------------------------------
    2.55 +# code
    2.56 +
    2.57 +
    2.58 +class Chooser(QtGui.QDialog, object):
    2.59 +    
    2.60 +    """Ask the user what to launch."""
    2.61 +    
    2.62 +    def __init__(self, parent = None, flags = QtCore.Qt.WindowFlags(0)):
    2.63 +    
    2.64 +        super(Chooser, self).__init__(parent, flags)
    2.65 +        self.setWindowTitle('OpenSecuirty Launch Application')
    2.66 +        self.setup_ui()
    2.67 +        
    2.68 +        # positionate ourself central
    2.69 +        screen = QtGui.QDesktopWidget().screenGeometry()
    2.70 +        self.resize(self.geometry().width() * 1.25, self.geometry().height())
    2.71 +        size = self.geometry()
    2.72 +        self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
    2.73 +        
    2.74 +        self._vms = [ { 'name': 'SecurityDVM0', 'ip': '192.168.56.101' } ]
    2.75 +        self._apps = [ { 'name': 'Browser', 'command': '/usr/bin/iceweasel' } ]
    2.76 +        
    2.77 +        # add the VMs we know
    2.78 +        self._cbVM.clear()
    2.79 +        for vm in self._vms:
    2.80 +            self._cbVM.addItem(vm['name'])
    2.81 +            
    2.82 +        # add the commands we know
    2.83 +        self._cbApplication.clear()
    2.84 +        for app in self._apps:
    2.85 +            self._cbApplication.addItem(app['name'])
    2.86 +        
    2.87 +        
    2.88 +        
    2.89 +    def app_get(self):
    2.90 +        """The application of the user."""
    2.91 +        a = str(self._cbApplication.currentText())
    2.92 +        for app in self._apps:
    2.93 +            if a == app['name']:
    2.94 +                return app['command']
    2.95 +        return a
    2.96 +        
    2.97 +    app = property(app_get)
    2.98 +        
    2.99 +
   2.100 +    def clicked_about(self):
   2.101 +        """clicked the about button"""
   2.102 +        dlgAbout = About()
   2.103 +        dlgAbout.exec_()
   2.104 +
   2.105 +
   2.106 +    def clicked_cancel(self):
   2.107 +        """clicked the cancel button"""
   2.108 +        self.reject()
   2.109 +    
   2.110 +
   2.111 +    def clicked_ok(self):
   2.112 +        """clicked the ok button"""
   2.113 +        self.accept()
   2.114 +    
   2.115 +    
   2.116 +    def setup_ui(self):
   2.117 +        """Create the widgets."""
   2.118 +        
   2.119 +        lyMain = QtGui.QVBoxLayout(self)
   2.120 +        lyMain.setContentsMargins(8, 8, 8, 8)
   2.121 +        
   2.122 +        # content area: left pixmap, right text
   2.123 +        lyContent = QtGui.QHBoxLayout()
   2.124 +        lyMain.addLayout(lyContent)
   2.125 +        
   2.126 +        # pixmap
   2.127 +        lbPix = QtGui.QLabel()
   2.128 +        lbPix.setPixmap(QtGui.QPixmapCache.find('opensecurity_icon_64'))
   2.129 +        lyContent.addWidget(lbPix, 0, QtCore.Qt.Alignment(QtCore.Qt.AlignTop + QtCore.Qt.AlignHCenter))
   2.130 +        lyContent.addSpacing(16)
   2.131 +        
   2.132 +        # launch ...
   2.133 +        lyLaunch = QtGui.QGridLayout()
   2.134 +        lyContent.addLayout(lyLaunch)
   2.135 +        lbTitle = QtGui.QLabel('Specify details for application to launch.')
   2.136 +        lyLaunch.addWidget(lbTitle, 0, 0, 1, 2)
   2.137 +        
   2.138 +        lbVM = QtGui.QLabel('&VM-ID:')
   2.139 +        lyLaunch.addWidget(lbVM, 1, 0)
   2.140 +        self._cbVM = QtGui.QComboBox()
   2.141 +        self._cbVM.setEditable(True)
   2.142 +        self._cbVM.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
   2.143 +        lyLaunch.addWidget(self._cbVM, 1, 1)
   2.144 +        lbVM.setBuddy(self._cbVM)
   2.145 +        
   2.146 +        lbApplication = QtGui.QLabel('&Application:')
   2.147 +        lyLaunch.addWidget(lbApplication, 2, 0)
   2.148 +        self._cbApplication = QtGui.QComboBox()
   2.149 +        self._cbApplication.setEditable(True)
   2.150 +        self._cbApplication.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
   2.151 +        lyLaunch.addWidget(self._cbApplication, 2, 1)
   2.152 +        lbApplication.setBuddy(self._cbApplication)
   2.153 +        
   2.154 +        lyLaunch.addWidget(QtGui.QWidget(), 3, 0, 1, 2)
   2.155 +        lyLaunch.setColumnStretch(1, 1)
   2.156 +        lyLaunch.setRowStretch(3, 1)
   2.157 +        
   2.158 +        lyMain.addStretch(1)
   2.159 +        
   2.160 +        # buttons
   2.161 +        lyButton = QtGui.QHBoxLayout()
   2.162 +        lyMain.addLayout(lyButton)
   2.163 +        
   2.164 +        lyButton.addStretch(1)
   2.165 +        btnOk = QtGui.QPushButton('&Ok', self)
   2.166 +        btnOk.setDefault(True)
   2.167 +        btnOk.setMinimumWidth(100)
   2.168 +        lyButton.addWidget(btnOk)
   2.169 +        btnCancel = QtGui.QPushButton('&Cancel', self)
   2.170 +        btnCancel.setMinimumWidth(100)
   2.171 +        lyButton.addWidget(btnCancel)
   2.172 +        btnAbout = QtGui.QPushButton('&About', self)
   2.173 +        btnAbout.setMinimumWidth(100)
   2.174 +        lyButton.addWidget(btnAbout)
   2.175 +        
   2.176 +        button_width = max(btnOk.width(), btnCancel.width(), btnAbout.width())
   2.177 +        btnOk.setMinimumWidth(button_width)
   2.178 +        btnCancel.setMinimumWidth(button_width)
   2.179 +        btnAbout.setMinimumWidth(button_width)
   2.180 +        
   2.181 +        # reduce to the max
   2.182 +        self.resize(lyMain.minimumSize())
   2.183 +        
   2.184 +        # connectors
   2.185 +        btnOk.clicked.connect(self.clicked_ok)
   2.186 +        btnCancel.clicked.connect(self.clicked_cancel)
   2.187 +        btnAbout.clicked.connect(self.clicked_about)
   2.188 +
   2.189 +        
   2.190 +    def vm_get(self):
   2.191 +        """The vm of choice."""
   2.192 +        v = str(self._cbVM.currentText())
   2.193 +        for vm in self._vms:
   2.194 +            if v == vm['name']:
   2.195 +                return vm['ip']
   2.196 +        return v
   2.197 +        
   2.198 +    vm = property(vm_get)
   2.199 +        
   2.200 +        
   2.201 +def ask_user():
   2.202 +    """ask the user for VM and app to start"""
   2.203 +    
   2.204 +    # prebuild the pixmap cache: fetch all jpg, png and jpeg images and load them
   2.205 +    image_path = os.path.join(Environment("OpenSecurity").data_path, '..', 'gfx')
   2.206 +    for file in os.listdir(image_path):
   2.207 +        if file.lower().rpartition('.')[2] in ('jpg', 'png', 'jpeg'):
   2.208 +            QtGui.QPixmapCache.insert(file.lower().rpartition('.')[0], QtGui.QPixmap(os.path.join(image_path, file)))
   2.209 +            
   2.210 +    # we should have now our application icon
   2.211 +    app.setWindowIcon(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')))
   2.212 +    
   2.213 +    # pop up the dialog
   2.214 +    dlg = Chooser()
   2.215 +    dlg.show()
   2.216 +    app.exec_()
   2.217 +    
   2.218 +    if dlg.result() == QtGui.QDialog.Accepted:
   2.219 +        return dlg.vm, dlg.app
   2.220 +
   2.221 +    return '', ''
   2.222 +    
   2.223 +
   2.224 +def main():
   2.225 +    """entry point"""
   2.226 +    
   2.227 +    # launch Qt
   2.228 +    global app
   2.229 +    app = QtGui.QApplication(sys.argv)
   2.230 +    
   2.231 +    # parse command line
   2.232 +    parser = argparse.ArgumentParser(description = 'OpenSecurity Launcher: run application in VM')
   2.233 +    parser.add_argument('ip', metavar='IP', help='IP of Virtual Machine', nargs='?', type=str, default='')
   2.234 +    parser.add_argument('command', metavar='COMMAND', help='Full path of command and arguments to start inside VM', nargs='?', type=str, default='')
   2.235 +    args = parser.parse_args()
   2.236 +    
   2.237 +    # we must have at least all or none set
   2.238 +    set_ip = args.ip != ''
   2.239 +    set_command = args.command != ''
   2.240 +    set_ALL = set_ip and set_command
   2.241 +    set_NONE = (not set_ip) and (not set_command)
   2.242 +    if (not set_ALL) and (not set_NONE):
   2.243 +        sys.stderr.write("Please specify ip and command or none.\n")
   2.244 +        sys.stderr.write("Type '--help' for help.\n")
   2.245 +        sys.exit(1)
   2.246 +        
   2.247 +    # check if we need to ask the user
   2.248 +    if set_NONE:
   2.249 +        args.ip, args.command = ask_user()
   2.250 +        
   2.251 +    # still no IP? --> no chance, over and out!
   2.252 +    if args.ip == '':
   2.253 +        sys.exit(0)
   2.254 +        
   2.255 +    # ensure we have our X11 running
   2.256 +    Cygwin.start_X11()
   2.257 +    
   2.258 +    # call the OpenSecurity Admin to launch our progie =)
   2.259 +    url_vm = urllib.quote(args.ip)
   2.260 +    url_command = urllib.quote(args.command)
   2.261 +    QtGui.QMessageBox.information(None, 'OpenSecurity Launche', 'About to launch <br/><b>' + url_command + '</b><br/>at VM <br/><b>' + url_vm + '</b>')
   2.262 +    
   2.263 +    # user_at_guest = args.user + '@' + args.ip
   2.264 +    # ssh = 'DISPLAY=:0 /usr/bin/ssh -Y ' + user_at_guest + ' ' + args.command
   2.265 +    # print(ssh)
   2.266 +    
   2.267 +    # # off we go!
   2.268 +    # Cygwin()(['/bin/bash', '--login', '-i', '-c', ssh], None, None, None)
   2.269 +
   2.270 +    
   2.271 +# start
   2.272 +if __name__ == "__main__":
   2.273 +    main()
   2.274 +
     3.1 --- a/OpenSecurity/bin/opensecurity_tray.py	Tue Dec 10 16:02:24 2013 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,131 +0,0 @@
     3.4 -#!/bin/env python
     3.5 -# -*- coding: utf-8 -*-
     3.6 -
     3.7 -# ------------------------------------------------------------
     3.8 -# opensecurity-dialog
     3.9 -# 
    3.10 -# an opensecurity dialog
    3.11 -#
    3.12 -# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    3.13 -#
    3.14 -# Copyright (C) 2013 AIT Austrian Institute of Technology
    3.15 -# AIT Austrian Institute of Technology GmbH
    3.16 -# Donau-City-Strasse 1 | 1220 Vienna | Austria
    3.17 -# http://www.ait.ac.at
    3.18 -#
    3.19 -# This program is free software; you can redistribute it and/or
    3.20 -# modify it under the terms of the GNU General Public License
    3.21 -# as published by the Free Software Foundation version 2.
    3.22 -# 
    3.23 -# This program is distributed in the hope that it will be useful,
    3.24 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.25 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.26 -# GNU General Public License for more details.
    3.27 -# 
    3.28 -# You should have received a copy of the GNU General Public License
    3.29 -# along with this program; if not, write to the Free Software
    3.30 -# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    3.31 -# Boston, MA  02110-1301, USA.
    3.32 -# ------------------------------------------------------------
    3.33 -
    3.34 -
    3.35 -# ------------------------------------------------------------
    3.36 -# imports
    3.37 -
    3.38 -import argparse
    3.39 -import os
    3.40 -import subprocess
    3.41 -import sys
    3.42 -
    3.43 -from PyQt4 import QtCore
    3.44 -from PyQt4 import QtGui
    3.45 -
    3.46 -# local
    3.47 -from about import About
    3.48 -from environment import Environment
    3.49 -
    3.50 -
    3.51 -# ------------------------------------------------------------
    3.52 -# code
    3.53 -
    3.54 -
    3.55 -class OpenSecurityTrayIcon(QtGui.QSystemTrayIcon):
    3.56 -    
    3.57 -    """This is the OpenSecuirty Tray Icon"""
    3.58 -
    3.59 -    def __init__(self, icon, parent=None):
    3.60 -        
    3.61 -        super(OpenSecurityTrayIcon, self).__init__(icon, parent)
    3.62 -        self.setup_ui()
    3.63 -        
    3.64 -        
    3.65 -    def clicked_about(self):
    3.66 -        """clicked about"""
    3.67 -        dlgAbout = About()
    3.68 -        dlgAbout.exec_()
    3.69 -    
    3.70 -
    3.71 -    def clicked_exit(self):
    3.72 -        """clicked exit"""
    3.73 -        sys.exit(0)
    3.74 -    
    3.75 -
    3.76 -    def clicked_launch_application(self):
    3.77 -        """clicked the launch an application"""
    3.78 -        dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
    3.79 -        process_command = [sys.executable, dlg_launch_image]
    3.80 -        print(process_command)
    3.81 -        process = subprocess.Popen(process_command, shell = False)
    3.82 -        process.communicate()
    3.83 -            
    3.84 -            
    3.85 -    def clicked_refresh(self):
    3.86 -        """clicked refresh"""
    3.87 -        self.setup_ui()
    3.88 -
    3.89 -    
    3.90 -    def setup_ui(self):
    3.91 -        """create the user interface
    3.92 -        As for the system tray this is 'just' the context menu.
    3.93 -        """
    3.94 -    
    3.95 -        # define the tray icon menu
    3.96 -        menu = QtGui.QMenu(self.parent())
    3.97 -        self.setContextMenu(menu)
    3.98 -        
    3.99 -        # add known apps
   3.100 -        
   3.101 -        # add standard menu items
   3.102 -        cAcLaunch = menu.addAction(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')), 'Lauch Application')
   3.103 -        menu.addSeparator()
   3.104 -        cAcRefresh = menu.addAction('Refresh')
   3.105 -        cAcAbout = menu.addAction("About")
   3.106 -        cAcExit = menu.addAction("Exit")
   3.107 -        
   3.108 -        cAcLaunch.triggered.connect(self.clicked_launch_application)
   3.109 -        cAcRefresh.triggered.connect(self.clicked_refresh)
   3.110 -        cAcAbout.triggered.connect(self.clicked_about)
   3.111 -        cAcExit.triggered.connect(self.clicked_exit)
   3.112 -        
   3.113 -        
   3.114 -def main():
   3.115 -    
   3.116 -    app = QtGui.QApplication(sys.argv)
   3.117 -
   3.118 -    # prebuild the pixmap cache: fetch all jpg, png and jpeg images and load them
   3.119 -    image_path = os.path.join(Environment("OpenSecurity").data_path, '..', 'gfx')
   3.120 -    for file in os.listdir(image_path):
   3.121 -        if file.lower().rpartition('.')[2] in ('jpg', 'png', 'jpeg'):
   3.122 -            QtGui.QPixmapCache.insert(file.lower().rpartition('.')[0], QtGui.QPixmap(os.path.join(image_path, file)))
   3.123 -
   3.124 -    w = QtGui.QWidget()
   3.125 -    trayIcon = OpenSecurityTrayIcon(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')), w)
   3.126 -
   3.127 -    trayIcon.show()
   3.128 -    sys.exit(app.exec_())
   3.129 -   
   3.130 -
   3.131 -# start
   3.132 -if __name__ == "__main__":
   3.133 -    main()
   3.134 -
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/OpenSecurity/bin/opensecurity_tray.pyw	Tue Dec 10 17:24:12 2013 +0100
     4.3 @@ -0,0 +1,143 @@
     4.4 +#!/bin/env python
     4.5 +# -*- coding: utf-8 -*-
     4.6 +
     4.7 +# ------------------------------------------------------------
     4.8 +# opensecurity-dialog
     4.9 +# 
    4.10 +# an opensecurity dialog
    4.11 +#
    4.12 +# Autor: Oliver Maurhart, <oliver.maurhart@ait.ac.at>
    4.13 +#
    4.14 +# Copyright (C) 2013 AIT Austrian Institute of Technology
    4.15 +# AIT Austrian Institute of Technology GmbH
    4.16 +# Donau-City-Strasse 1 | 1220 Vienna | Austria
    4.17 +# http://www.ait.ac.at
    4.18 +#
    4.19 +# This program is free software; you can redistribute it and/or
    4.20 +# modify it under the terms of the GNU General Public License
    4.21 +# as published by the Free Software Foundation version 2.
    4.22 +# 
    4.23 +# This program is distributed in the hope that it will be useful,
    4.24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.26 +# GNU General Public License for more details.
    4.27 +# 
    4.28 +# You should have received a copy of the GNU General Public License
    4.29 +# along with this program; if not, write to the Free Software
    4.30 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, 
    4.31 +# Boston, MA  02110-1301, USA.
    4.32 +# ------------------------------------------------------------
    4.33 +
    4.34 +
    4.35 +# ------------------------------------------------------------
    4.36 +# imports
    4.37 +
    4.38 +import argparse
    4.39 +import os
    4.40 +import subprocess
    4.41 +import sys
    4.42 +
    4.43 +from PyQt4 import QtCore
    4.44 +from PyQt4 import QtGui
    4.45 +
    4.46 +# local
    4.47 +from about import About
    4.48 +from environment import Environment
    4.49 +
    4.50 +
    4.51 +# ------------------------------------------------------------
    4.52 +# code
    4.53 +
    4.54 +
    4.55 +class OpenSecurityTrayIcon(QtGui.QSystemTrayIcon):
    4.56 +    
    4.57 +    """This is the OpenSecuirty Tray Icon"""
    4.58 +
    4.59 +    def __init__(self, icon, parent=None):
    4.60 +        
    4.61 +        super(OpenSecurityTrayIcon, self).__init__(icon, parent)
    4.62 +        self.setup_ui()
    4.63 +        
    4.64 +        
    4.65 +    def clicked_about(self):
    4.66 +        """clicked about"""
    4.67 +        dlgAbout = About()
    4.68 +        dlgAbout.exec_()
    4.69 +    
    4.70 +
    4.71 +    def clicked_browser(self):
    4.72 +        """wish for safe internet browsing"""
    4.73 +        dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
    4.74 +        process_command = [sys.executable, dlg_launch_image, '192.168.56.101', '/usr/bin/iceweasel']
    4.75 +        print(process_command)
    4.76 +        process = subprocess.Popen(process_command, shell = False)
    4.77 +        process.communicate()
    4.78 +            
    4.79 +            
    4.80 +    def clicked_exit(self):
    4.81 +        """clicked exit"""
    4.82 +        sys.exit(0)
    4.83 +    
    4.84 +
    4.85 +    def clicked_launch_application(self):
    4.86 +        """clicked the launch an application"""
    4.87 +        dlg_launch_image = os.path.join(sys.path[0], 'launch.pyw')
    4.88 +        process_command = [sys.executable, dlg_launch_image]
    4.89 +        print(process_command)
    4.90 +        process = subprocess.Popen(process_command, shell = False)
    4.91 +        process.communicate()
    4.92 +            
    4.93 +            
    4.94 +    def clicked_refresh(self):
    4.95 +        """clicked refresh"""
    4.96 +        self.setup_ui()
    4.97 +
    4.98 +    
    4.99 +    def setup_ui(self):
   4.100 +        """create the user interface
   4.101 +        As for the system tray this is 'just' the context menu.
   4.102 +        """
   4.103 +    
   4.104 +        # define the tray icon menu
   4.105 +        menu = QtGui.QMenu(self.parent())
   4.106 +        self.setContextMenu(menu)
   4.107 +        
   4.108 +        # add known apps
   4.109 +        cAcBrowser = menu.addAction(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')), 'Safe Internet Browsing')
   4.110 +        menu.addSeparator()
   4.111 +        
   4.112 +        # add standard menu items
   4.113 +        cAcLaunch = menu.addAction(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')), 'Lauch Application')
   4.114 +        menu.addSeparator()
   4.115 +        cAcRefresh = menu.addAction('Refresh')
   4.116 +        cAcAbout = menu.addAction("About")
   4.117 +        cAcExit = menu.addAction("Exit")
   4.118 +        
   4.119 +        cAcBrowser.triggered.connect(self.clicked_browser)
   4.120 +        cAcLaunch.triggered.connect(self.clicked_launch_application)
   4.121 +        cAcRefresh.triggered.connect(self.clicked_refresh)
   4.122 +        cAcAbout.triggered.connect(self.clicked_about)
   4.123 +        cAcExit.triggered.connect(self.clicked_exit)
   4.124 +        
   4.125 +        
   4.126 +def main():
   4.127 +    
   4.128 +    app = QtGui.QApplication(sys.argv)
   4.129 +
   4.130 +    # prebuild the pixmap cache: fetch all jpg, png and jpeg images and load them
   4.131 +    image_path = os.path.join(Environment("OpenSecurity").data_path, '..', 'gfx')
   4.132 +    for file in os.listdir(image_path):
   4.133 +        if file.lower().rpartition('.')[2] in ('jpg', 'png', 'jpeg'):
   4.134 +            QtGui.QPixmapCache.insert(file.lower().rpartition('.')[0], QtGui.QPixmap(os.path.join(image_path, file)))
   4.135 +
   4.136 +    w = QtGui.QWidget()
   4.137 +    trayIcon = OpenSecurityTrayIcon(QtGui.QIcon(QtGui.QPixmapCache.find('opensecurity_icon_64')), w)
   4.138 +
   4.139 +    trayIcon.show()
   4.140 +    sys.exit(app.exec_())
   4.141 +   
   4.142 +
   4.143 +# start
   4.144 +if __name__ == "__main__":
   4.145 +    main()
   4.146 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/OpenSecurity/bin/os-tray.bat	Tue Dec 10 17:24:12 2013 +0100
     5.3 @@ -0,0 +1,3 @@
     5.4 +@echo off
     5.5 +cd %0%\..
     5.6 +START /B CMD /C "C:\Python27\pythonw opensecurity_tray.pyw" >NUL 2>&1
     5.7 \ No newline at end of file
     6.1 --- a/OpenSecurity/cygwin/content.txt	Tue Dec 10 16:02:24 2013 +0100
     6.2 +++ b/OpenSecurity/cygwin/content.txt	Tue Dec 10 17:24:12 2013 +0100
     6.3 @@ -8,3 +8,4 @@
     6.4      - openssh
     6.5      - xinit
     6.6      - genisofs
     6.7 +    - xset