# HG changeset patch # User om # Date 1385996520 -3600 # Node ID 166c38b8b6eda1e4a0233c68e46261e893a55338 # Parent 0c8bc9c94951be30a1bcb63f2afacf27401cd23a added multiple session firefox script diff -r 0c8bc9c94951 -r 166c38b8b6ed OpenSecurity/install/content.txt --- a/OpenSecurity/install/content.txt Mon Dec 02 14:33:29 2013 +0100 +++ b/OpenSecurity/install/content.txt Mon Dec 02 16:02:00 2013 +0100 @@ -1,5 +1,5 @@ Content of Opensecurity/install -============================== +=============================== Additonally to the files already present in this folder, we need: diff -r 0c8bc9c94951 -r 166c38b8b6ed OpenSecurity/vm/usr/local/bin/ff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/vm/usr/local/bin/ff Mon Dec 02 16:02:00 2013 +0100 @@ -0,0 +1,33 @@ +#!/bin/bash + +# create a disposable firefox session +# +# Remark: this script expects the firefox sessions +# to be stored in ~/.mozilla/fireofx +# + +# pick the next profile number +PROFILE_NUMBER=$(new_firefox_profile_id.py) +PROFILE_PATH=$(basename $(mktemp -d ~/.mozilla/firefox/XXXXXXXX.os_user_${PROFILE_NUMBER})) +PROFILE_TIMESTAMP="$(date +%s)000" +PROFILE_NAME=$(echo ${PROFILE_PATH} | awk -F '.' '{ print $NF; }') + +# create a fake times.json +cat > ${PROFILE_PATH}/times.json << __EO_TIMES_JSON__ +{ +"created": ${PROFILE_TIMESTAMP} +} +__EO_TIMES_JSON__ + +# add out new "profile" to firefox +cat >> ~/.mozilla/firefox/profiles.ini << __EO_PROFILES_INI__ +[Profile${PROFILE_NUMBER}] +Name=${PROFILE_NAME} +IsRelative=1 +Path=${PROFILE_PATH} + +__EO_PROFILES_INI__ + + +# launch firefox +firefox -P ${PROFILE_NAME} -no-remote $@ diff -r 0c8bc9c94951 -r 166c38b8b6ed OpenSecurity/vm/usr/local/bin/new_firefox_profile_id.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OpenSecurity/vm/usr/local/bin/new_firefox_profile_id.py Mon Dec 02 16:02:00 2013 +0100 @@ -0,0 +1,64 @@ +#!/bin/env python +# -*- coding: utf-8 -*- + +# ------------------------------------------------------------ +# new_firefox_profile_id +# +# pick the next firefox profile id +# +# Autor: Oliver Maurhart, +# +# Copyright (C) 2013 AIT Austrian Institute of Technology +# AIT Austrian Institute of Technology GmbH +# Donau-City-Strasse 1 | 1220 Vienna | Austria +# http://www.ait.ac.at +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation version 2. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# ------------------------------------------------------------ + + +# ------------------------------------------------------------ +# imports + +import os +import os.path +import ConfigParser # in pythjon 3 this is lowercase + + +# ------------------------------------------------------------ +# code + + +def main(): + + # grab the firefox profile ini (path may differ ...) + profiles_path = os.path.join(os.path.expanduser('~'), '.mozilla', 'firefox', 'profiles.ini') + cfg = ConfigParser.ConfigParser() + cfg.read(profiles_path) + profiles = [p for p in cfg.sections() if p.startswith('Profile')] + i = 0 + for p in profiles: + p_number = p[len('Profile'):] + try: + i = max(int(p_number), i) + except: + pass + print i + 1 + + +if __name__ == '__main__': + main() + +