树莓派2 Kali Linux 2.1 自动配置脚本

今天准备打造一个完美的HACKBOX,于是边进行配置边写了这个脚本。

或执行:

 脚本说明

执行脚本时会让用户选择步骤,输入1到4的数字按下回车即可执行相应步骤。

步骤分别为:

  1. 禁用过扫描(去除黑边) — 配置中科大源 — 启用WiFi(会要求输入WiFi SSID密码
  2. 更新源 — 安装必要软件(vim git htop curl python3)– 开启中文支持(时区+区域
  3. 可选)安装全部Kali工具
  4. 可选)更新全部软件包到最新版本.

----------

附录:

此脚本的内容如下:

#!/bin/bash

function step1() {
  clear
  echo "Disable overscan..."
  mount /dev/mmcblk0p1 /boot
  cat > /boot/config.txt << EOF
disable_overscan=1
EOF

  echo ""
  echo ""

  echo "Configurating APT source..."
  rm -f /etc/apt/sources.list
  cat > /etc/apt/sources.list << EOF
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
EOF

  echo ""
  echo ""

  echo "Enable WiFi..."
  echo "Provide your WiFi's SSID:"
  read ssid
  echo "Provide your WiFi's Password:"
  read pass
  cat >> /etc/network/interfaces << EOF
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "${ssid}"
wpa-psk "${pass}"
EOF

  clear
  echo "Step 1 completed. Plug in your WiFi dungle now and press any key to reboot."
  echo "When Rasberry Pi booted, execute this script again and select STEP 2."
  echo ""
  echo "Press any key to reboot..."
  read a
  reboot
}

function step2() {
  clear
  echo "Updating source..."
  echo ""
  apt update

  echo ""
  echo ""

  echo "Installing vim git htop curl python3..."
  apt -y install vim git htop curl python3

  echo ""
  echo ""

  echo "Enable Chinese support..."
  apt install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy
  update-locale LANG=zh_CN.UTF-8
  locale-gen --purge zh_CN.UTF-8
  echo "Asia/Shanghai" > /etc/timezone
  dpkg-reconfigure -f noninteractive tzdata

  clear
  echo "Step 2 completed. System language will change to Simplified Chinese after reboot."
  echo "You can run this script again to goto optional step 3 & 4."
  echo ""
  echo "Press any key to reboot..."
  read a
  reboot
}

function step3() {
  echo "Installing ALL Kali tools..."
  echo ""
  apt -y install dnsenum fierce dmitry maltego tcptraceroute theharvester arping fping hping3 nbtscan p0f nmap unicornscan zenmap amap onesixtyone snmpcheck

  clear
  echo "All done. Enjoy!"
  read a
  exit
}

function step4() {
  clear
  echo "Fully upgrading..."
  echo ""
  apt -y upgrade

  clear
  echo "All done. Press any key to exit..."
  read a
  exit
}

clear
echo "###########################################"
echo "# Kali 2.0 Auto-Config for Raspberry Pi 2 #"
echo "# --------------------------------------- #"
echo "# Author: CYRO4S <https://ralf.ren>       #"
echo "# Intro: <https://ralf.ren/1234>          #"
echo "###########################################"
echo ""
echo ""
echo "Welcome to Kali 2.0 Auto-Config!"
echo "Let's get started, make sure to follow these steps!"
echo ""
echo "1. Disable overscan -- Configure APT source -- Enable WiFi"
echo "2. Update APT source -- Install useful softwares -- Enable Chinese support"
echo "3. (Optional) Install all Kali tools"
echo "4. (Optional) Do a full upgrade for all softwares"
echo ""
echo "Which step are we now at? (1, 2, 3, 4)"
read num
case "$num" in
[1] ) (step1);;
[2] ) (step2);;
[3] ) (step3);;
[4] ) (step4);;
*) echo "Invalid input, now exiting...";;
esac