@ -1,16 +1,33 @@
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#!/bin/sh
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# The reference version of this script is maintained in:
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#   kali-installer/simple-cdd/profiles/kali.postinst
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#   kali-live/kali-config/common/includes.installer/kali-finish-install
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#   kali-live/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#   kali-vm/scripts/finish-install.sh
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# (sometimes with small variations)
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				#
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# It is used in multiple places to finish configuring the target system
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# and build.sh copies it where required (in the simple-cdd configuration
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				# and in the live-build configuration).
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				get_user_list() {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    echo kali
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				configure_zsh() {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # Stop if zsh is not present
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if [ ! -x /usr/bin/zsh ]; then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if echo "${LIVE_CONFIG_CMDLINE}" | grep -q 'nozsh'; then 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        echo "INFO: user opted out of zsh by default" 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        return
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    fi
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # Stop if user has opted out of zsh
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if echo "${LIVE_CONFIG_CMDLINE}" | grep -qs 'nozsh'; then
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    if [ ! -x /usr/bin/zsh ]; then 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        echo "INFO: /usr/bin/zsh is not available" 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        return
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    fi
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    chsh --shell /usr/bin/zsh kali
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    chsh --shell /usr/bin/zsh root
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    for user in $(get_user_list); do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        echo "INFO: changing default shell of user '$user' to zsh"
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        chsh --shell /usr/bin/zsh $user
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    done
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				configure_usergroups() {
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -19,15 +36,18 @@ configure_usergroups() {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    addgroup --system wireshark || true
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # adm - read access to log files
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # dialout - for serial port  access
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # dialout - for serial access
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # kaboxer - for kaboxer
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # vboxsf - shared folders for virtualbox guest
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # wireshark - capture sessions without being root 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    # wireshark - capture sessions in wireshark 
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    kali_groups="adm dialout kaboxer vboxsf wireshark"
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    for grp in $kali_groups; do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        getent group $grp >/dev/null || continue
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        usermod -a -G $grp kali
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    for user in $(get_user_list | grep -xv root); do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        echo "INFO: adding user '$user' to groups '$kali_groups'"
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        for grp in $kali_groups; do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            getent group $grp >/dev/null || continue
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				            usermod -a -G $grp $user
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        done
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    done
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				}
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				
 
			
		 
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
			
			 
			 
			
				@ -38,6 +58,7 @@ pkg_installed() {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				configure_terminal() {
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    while read -r desktop terminal; do
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        pkg_installed kali-desktop-$desktop || continue
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        echo "INFO: setting x-terminal-emulator alternative to '$terminal'"
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        update-alternatives --verbose --set x-terminal-emulator /usr/bin/$terminal || true
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				        break
 
			
		 
		
	
		
			
				 
				 
			
			 
			 
			
				    done <<END