|  | 
 |  | 
 | 
												
													
														| 1017 |  
 | 1017 |  
 | 
												
													
														| 1018 |      if [[ $ARCHITECTURE == 'amd64' ]]; then
 | 1018 |      if [[ $ARCHITECTURE == 'amd64' ]]; then
 | 
												
													
														| 1019 |          chroot "$rootdir" apt-get -yq install linux-image-amd64 -t jessie-backports
 | 1019 |          chroot "$rootdir" apt-get -yq install linux-image-amd64 -t jessie-backports
 | 
												
													
														|  | 
 | 1020 | +        chroot "$rootdir" apt-get -yq install grub2
 | 
												
													
														| 1020 |      fi
 | 1021 |      fi
 | 
												
													
														| 1021 |  
 | 1022 |  
 | 
												
													
														| 1022 |      chroot "$rootdir" apt-get -yq install locales locales-all debconf
 | 1023 |      chroot "$rootdir" apt-get -yq install locales locales-all debconf
 | 
												
													
														| 1023 |  
 | 1024 |  
 | 
												
													
														| 1024 | -    # basic firewall
 |  | 
 | 
												
													
														| 1025 | -    chroot "$rootdir" iptables -P INPUT ACCEPT
 |  | 
 | 
												
													
														| 1026 | -    chroot "$rootdir" ip6tables -P INPUT ACCEPT
 |  | 
 | 
												
													
														| 1027 | -    chroot "$rootdir" iptables -F
 |  | 
 | 
												
													
														| 1028 | -    chroot "$rootdir" ip6tables -F
 |  | 
 | 
												
													
														| 1029 | -    chroot "$rootdir" iptables -t nat -F
 |  | 
 | 
												
													
														| 1030 | -    chroot "$rootdir" ip6tables -t nat -F
 |  | 
 | 
												
													
														| 1031 | -    chroot "$rootdir" iptables -X
 |  | 
 | 
												
													
														| 1032 | -    chroot "$rootdir" ip6tables -X
 |  | 
 | 
												
													
														| 1033 | -    chroot "$rootdir" iptables -P INPUT DROP
 |  | 
 | 
												
													
														| 1034 | -    chroot "$rootdir" ip6tables -P INPUT DROP
 |  | 
 | 
												
													
														| 1035 | -    chroot "$rootdir" iptables -P FORWARD DROP
 |  | 
 | 
												
													
														| 1036 | -    chroot "$rootdir" ip6tables -P FORWARD DROP
 |  | 
 | 
												
													
														| 1037 | -    chroot "$rootdir" iptables -A INPUT -i lo -j ACCEPT
 |  | 
 | 
												
													
														| 1038 | -    chroot "$rootdir" iptables -A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
 |  | 
 | 
												
													
														| 1039 | -    chroot "$rootdir" iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
 |  | 
 | 
												
													
														| 1040 | -    chroot "$rootdir" iptables -A INPUT -f -j DROP
 |  | 
 | 
												
													
														| 1041 | -    chroot "$rootdir" iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
 |  | 
 | 
												
													
														| 1042 | -    chroot "$rootdir" iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
 |  | 
 | 
												
													
														| 1043 | -    chroot "$rootdir" iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
 |  | 
 | 
												
													
														| 1044 | -    chroot "$rootdir" iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
 |  | 
 | 
												
													
														| 1045 | -    chroot "$rootdir" iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
 |  | 
 | 
												
													
														| 1046 | -    chroot "$rootdir" iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
 |  | 
 | 
												
													
														| 1047 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport 548 -j ACCEPT
 |  | 
 | 
												
													
														| 1048 | -    chroot "$rootdir" iptables -A INPUT -p udp --dport 548 -j ACCEPT
 |  | 
 | 
												
													
														| 1049 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport 5353 -j ACCEPT
 |  | 
 | 
												
													
														| 1050 | -    chroot "$rootdir" iptables -A INPUT -p udp --dport 5353 -j ACCEPT
 |  | 
 | 
												
													
														| 1051 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport 5354 -j ACCEPT
 |  | 
 | 
												
													
														| 1052 | -    chroot "$rootdir" iptables -A INPUT -p udp --dport 5354 -j ACCEPT
 |  | 
 | 
												
													
														| 1053 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport $SSH_PORT -j ACCEPT
 |  | 
 | 
												
													
														| 1054 | -    chroot "$rootdir" iptables -A INPUT -p udp -m udp --dport 1024:65535 --sport 53 -j ACCEPT
 |  | 
 | 
												
													
														| 1055 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport 80 -j ACCEPT
 |  | 
 | 
												
													
														| 1056 | -    chroot "$rootdir" iptables -A INPUT -p tcp --dport 443 -j ACCEPT
 |  | 
 | 
												
													
														| 1057 | -
 |  | 
 | 
												
													
														| 1058 | -    # save the firewall
 |  | 
 | 
												
													
														| 1059 | -    chroot "$rootdir" iptables-save > /etc/firewall.conf
 |  | 
 | 
												
													
														| 1060 | -    chroot "$rootdir" ip6tables-save > /etc/firewall6.conf
 |  | 
 | 
												
													
														| 1061 | -    printf '#!/bin/sh\n' > $rootdir/etc/network/if-up.d/iptables
 |  | 
 | 
												
													
														| 1062 | -    printf 'iptables-restore < /etc/firewall.conf\n' >> $rootdir/etc/network/if-up.d/iptables
 |  | 
 | 
												
													
														| 1063 | -    printf 'ip6tables-restore < /etc/firewall6.conf\n' >> $rootdir/etc/network/if-up.d/iptables
 |  | 
 | 
												
													
														| 1064 | -    if [ -f $rootdir/etc/network/if-up.d/iptables ]; then
 |  | 
 | 
												
													
														| 1065 | -        chmod +x $rootdir/etc/network/if-up.d/iptables
 |  | 
 | 
												
													
														| 1066 | -    fi
 |  | 
 | 
												
													
														| 1067 | -
 |  | 
 | 
												
													
														| 1068 |      SYSCTL_FILE=$rootdir/etc/sysctl.conf
 | 1025 |      SYSCTL_FILE=$rootdir/etc/sysctl.conf
 | 
												
													
														| 1069 |      if [ ! -f $SYSCTL_FILE ]; then
 | 1026 |      if [ ! -f $SYSCTL_FILE ]; then
 | 
												
													
														| 1070 |          touch $SYSCTL_FILE
 | 1027 |          touch $SYSCTL_FILE
 | 
												
											
												
													
														|  | 
 |  | 
 | 
												
													
														| 1092 |      chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
 | 1049 |      chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
 | 
												
													
														| 1093 |      chroot "$rootdir" apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
 | 1050 |      chroot "$rootdir" apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
 | 
												
													
														| 1094 |      chroot "$rootdir" apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
 | 1051 |      chroot "$rootdir" apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
 | 
												
													
														| 1095 | -    chroot "$rootdir" apt-get -yq install pinentry-curses eatmydata iotop bc grub2 hostapd haveged
 |  | 
 | 
												
													
														| 1096 | -    chroot "$rootdir" apt-get -yq install cpulimit screen elinks
 |  | 
 | 
												
													
														| 1097 | -    chroot "$rootdir" apt-get -yq install libpam-cracklib
 |  | 
 | 
												
													
														|  | 
 | 1052 | +    chroot "$rootdir" apt-get -yq install pinentry-curses eatmydata iotop bc hostapd haveged
 | 
												
													
														|  | 
 | 1053 | +    chroot "$rootdir" apt-get -yq install cpulimit screen elinks libpam-cracklib
 | 
												
													
														| 1098 |  
 | 1054 |  
 | 
												
													
														| 1099 |      # Tor and ssh over tor
 | 1055 |      # Tor and ssh over tor
 | 
												
													
														| 1100 |      chroot "$rootdir" apt-get -yq install tor connect-proxy
 | 1056 |      chroot "$rootdir" apt-get -yq install tor connect-proxy
 |