1.1 --- a/OpenSecurity/install/content.txt Mon Dec 02 14:33:29 2013 +0100
1.2 +++ b/OpenSecurity/install/content.txt Mon Dec 02 16:02:00 2013 +0100
1.3 @@ -1,5 +1,5 @@
1.4 Content of Opensecurity/install
1.5 -==============================
1.6 +===============================
1.7
1.8 Additonally to the files already present in this folder, we need:
1.9
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/OpenSecurity/vm/usr/local/bin/ff Mon Dec 02 16:02:00 2013 +0100
2.3 @@ -0,0 +1,33 @@
2.4 +#!/bin/bash
2.5 +
2.6 +# create a disposable firefox session
2.7 +#
2.8 +# Remark: this script expects the firefox sessions
2.9 +# to be stored in ~/.mozilla/fireofx
2.10 +#
2.11 +
2.12 +# pick the next profile number
2.13 +PROFILE_NUMBER=$(new_firefox_profile_id.py)
2.14 +PROFILE_PATH=$(basename $(mktemp -d ~/.mozilla/firefox/XXXXXXXX.os_user_${PROFILE_NUMBER}))
2.15 +PROFILE_TIMESTAMP="$(date +%s)000"
2.16 +PROFILE_NAME=$(echo ${PROFILE_PATH} | awk -F '.' '{ print $NF; }')
2.17 +
2.18 +# create a fake times.json
2.19 +cat > ${PROFILE_PATH}/times.json << __EO_TIMES_JSON__
2.20 +{
2.21 +"created": ${PROFILE_TIMESTAMP}
2.22 +}
2.23 +__EO_TIMES_JSON__
2.24 +
2.25 +# add out new "profile" to firefox
2.26 +cat >> ~/.mozilla/firefox/profiles.ini << __EO_PROFILES_INI__
2.27 +[Profile${PROFILE_NUMBER}]
2.28 +Name=${PROFILE_NAME}
2.29 +IsRelative=1
2.30 +Path=${PROFILE_PATH}
2.31 +
2.32 +__EO_PROFILES_INI__
2.33 +
2.34 +
2.35 +# launch firefox
2.36 +firefox -P ${PROFILE_NAME} -no-remote $@
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/OpenSecurity/vm/usr/local/bin/new_firefox_profile_id.py Mon Dec 02 16:02:00 2013 +0100
3.3 @@ -0,0 +1,64 @@
3.4 +#!/bin/env python
3.5 +# -*- coding: utf-8 -*-
3.6 +
3.7 +# ------------------------------------------------------------
3.8 +# new_firefox_profile_id
3.9 +#
3.10 +# pick the next firefox profile id
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 os
3.39 +import os.path
3.40 +import ConfigParser # in pythjon 3 this is lowercase
3.41 +
3.42 +
3.43 +# ------------------------------------------------------------
3.44 +# code
3.45 +
3.46 +
3.47 +def main():
3.48 +
3.49 + # grab the firefox profile ini (path may differ ...)
3.50 + profiles_path = os.path.join(os.path.expanduser('~'), '.mozilla', 'firefox', 'profiles.ini')
3.51 + cfg = ConfigParser.ConfigParser()
3.52 + cfg.read(profiles_path)
3.53 + profiles = [p for p in cfg.sections() if p.startswith('Profile')]
3.54 + i = 0
3.55 + for p in profiles:
3.56 + p_number = p[len('Profile'):]
3.57 + try:
3.58 + i = max(int(p_number), i)
3.59 + except:
3.60 + pass
3.61 + print i + 1
3.62 +
3.63 +
3.64 +if __name__ == '__main__':
3.65 + main()
3.66 +
3.67 +