#!/usr/bin/expect -f # # whitelist home # set timeout 10 spawn $env(SHELL) match_max 100000 set overlay [lindex $argv 0] set chroot [lindex $argv 1] # # N # send -- "firejail --noprofile --whitelist=/home/netblue/.config\r" expect { timeout {puts "TESTING ERROR 0\n";exit} "Child process initialized" } sleep 1 send -- "ls -al | wc -l\r" expect { timeout {puts "TESTING ERROR 1.1\n";exit} "6" } send -- "ls -al .bashrc\r" expect { timeout {puts "TESTING ERROR 1.2\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.3\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.4\n";exit} ".bashrc" } send -- "ls -al .Xauthority\r" expect { timeout {puts "TESTING ERROR 1.5\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.6\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.7\n";exit} ".Xauthority" } send -- "ls -al | grep .config\r" expect { timeout {puts "TESTING ERROR 1.8\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.9\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 1.10\n";exit} ".config" } after 100 send -- "exit\r" sleep 1 # # O # if { $overlay == "overlay" } { send -- "firejail --noprofile --overlay --whitelist=/home/netblue/.config\r" expect { timeout {puts "TESTING ERROR 2\n";exit} "overlay option is not available" {puts "grsecurity\n"; exit} "Child process initialized" {puts "normal system\n"} } sleep 1 send -- "ls -al | wc -l\r" expect { timeout {puts "TESTING ERROR 3.1\n";exit} "6" } send -- "ls -al .bashrc\r" expect { timeout {puts "TESTING ERROR 3.2\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.3\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.4\n";exit} ".bashrc" } send -- "ls -al .Xauthority\r" expect { timeout {puts "TESTING ERROR 3.5\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.6\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.7\n";exit} ".Xauthority" } send -- "ls -al | grep .config\r" expect { timeout {puts "TESTING ERROR 3.8\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.9\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 3.10\n";exit} ".config" } after 100 send -- "exit\r" sleep 1 } # # C # if { $chroot == "chroot" } { send -- "firejail --noprofile --chroot=/tmp/chroot --whitelist=/home/netblue/.config\r" expect { timeout {puts "TESTING ERROR 4\n";exit} "Child process initialized" } sleep 1 send -- "ls -al | wc -l\r" expect { timeout {puts "TESTING ERROR 5.1\n";exit} "6" } send -- "ls -al .bashrc\r" expect { timeout {puts "TESTING ERROR 5.2\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.3\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.4\n";exit} ".bashrc" } send -- "ls -al .Xauthority\r" expect { timeout {puts "TESTING ERROR 5.5\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.6\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.7\n";exit} ".Xauthority" } send -- "ls -al | grep .config\r" expect { timeout {puts "TESTING ERROR 5.8\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.9\n";exit} "netblue" } expect { timeout {puts "TESTING ERROR 5.10\n";exit} ".config" } after 100 send -- "exit\r" sleep 1 } puts "\nall done\n"