├── README.md └── ctf_env.sh /README.md: -------------------------------------------------------------------------------- 1 | # 🦉Kali 中 CTF 环境配置 2 | 3 | 由于 Kali 系统又双叒叕崩了,开个仓库记录配置和安装的软件,方便以后快速重装... 4 | 5 | 系统版本 `kali-linux-2022.4-vmware-amd64` 6 | 7 | ```bash 8 | wget -N --no-check-certificate https://raw.githubusercontent.com/5ime/ctf_env/main/ctf_env.sh && chmod +x ctf_env.sh && sudo bash ctf_env.sh 9 | ``` 10 | 11 | - 更换 apt 源 12 | - 安装 Git、libssl-dev 等必要工具 13 | - 安装并配置 Python2 / 3 14 | - 安装并配置 Docker 15 | - 安装 Docker Compose 16 | - 下载并配置 SecLists 17 | - 解压 rockyou 字典 18 | - 安装 zsteg 19 | - 安装 steghide 20 | - 安装 Pwntools 21 | - 安装 pycrypto 22 | - 安装 gmpy2 23 | - 安装 dirsearch 24 | - 安装 Ciphey(Docker 容器) 25 | - 安装 stegseek 26 | - 安装 outguess 27 | - 安装 crackle 28 | -------------------------------------------------------------------------------- /ctf_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set +e 4 | 5 | RED='\033[0;31m' 6 | GREEN='\033[0;32m' 7 | YELLOW='\033[0;33m' 8 | BLUE='\033[0;34m' 9 | CYAN='\033[0;36m' 10 | NC='\033[0m' 11 | 12 | if [ "$(id -u)" -ne 0 ]; then 13 | echo -e "${RED}[!] 请使用 root 用户运行该脚本!${NC}" 14 | exit 1 15 | fi 16 | 17 | echo -e "${CYAN} 18 | ######################################################### 19 | # CTF_ENV # 20 | # 用于快速安装和配置各种安全工具 # 21 | # # 22 | # Version: 1.0.1 # 23 | # Author: iami233 # 24 | # Repo: https://github.com/5ime/ctf_env # 25 | ######################################################### 26 | ${NC}" 27 | 28 | # 通用安装和验证函数 29 | installAndVerify() { 30 | local name=$1 31 | local installCmd=$2 32 | local verifyCmd=$3 33 | 34 | echo -e "${CYAN}[+] 安装 ${name}...${NC}" 35 | if eval "$installCmd"; then 36 | if eval "$verifyCmd" &>/dev/null; then 37 | echo -e "${GREEN}[✓] ${name} 安装成功${NC}" 38 | else 39 | echo -e "${RED}[!] ${name} 验证失败${NC}" 40 | fi 41 | else 42 | echo -e "${RED}[!] ${name} 安装失败${NC}" 43 | fi 44 | } 45 | 46 | # 安装必要工具 47 | installTools() { 48 | echo -e "${CYAN}[+] 安装必要工具...${NC}" 49 | if ! apt install -y git libssl-dev libffi-dev build-essential libpcap-dev libmcrypt4 libmhash2; then 50 | echo -e "${RED}[!] 安装失败,是否切换源并重试?(y/n)${NC}" 51 | read -r choice 52 | if [[ "$choice" == "y" || "$choice" == "Y" ]]; then 53 | updateSources 54 | apt install -y git libssl-dev libffi-dev build-essential || { echo -e "${RED}[!] 安装失败,请检查源配置${NC}"; exit 1; } 55 | else 56 | echo -e "${RED}[!] 用户选择不切换源,退出${NC}" 57 | exit 1 58 | fi 59 | fi 60 | echo -e "${GREEN}[✓] 必要工具安装完成${NC}" 61 | } 62 | 63 | # 更新APT源 64 | updateSources() { 65 | echo -e "${CYAN}[+] 更新 APT 源...${NC}" 66 | mv /etc/apt/sources.list /etc/apt/sources.list.bak 67 | cat < /etc/apt/sources.list 68 | deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib 69 | deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib 70 | EOF 71 | if ! apt-get update -y; then 72 | echo -e "${RED}[!] 更新源失败,是否尝试更换 GPG 密钥并重新更新?(y/n)${NC}" 73 | read -r choice 74 | if [[ "$choice" == "y" ]]; then 75 | echo -e "${CYAN}[+] 更新 GPG 密钥...${NC}" 76 | wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add - 77 | apt-get update -y && echo -e "${GREEN}[✓] GPG 密钥更新成功${NC}" || echo -e "${RED}[!] GPG 密钥更新失败${NC}" 78 | else 79 | echo -e "${RED}[!] 用户选择不更新 GPG 密钥,退出安装${NC}" 80 | exit 1 81 | fi 82 | else 83 | echo -e "${GREEN}[✓] APT 源更新成功${NC}" 84 | fi 85 | } 86 | 87 | # 配置SSH服务 88 | installSsh() { 89 | systemctl start ssh 90 | update-rc.d ssh enable 91 | } 92 | 93 | # 安装Python环境 94 | installPython() { 95 | apt install -y python2 python3 python3-pip build-essential libssl-dev libffi-dev 96 | wget https://bootstrap.pypa.io/pip/2.7/get-pip.py 97 | python2 get-pip.py 98 | mkdir -p /root/.pip 99 | cat < /root/.pip/pip.conf 100 | [global] 101 | index-url = https://pypi.tuna.tsinghua.edu.cn/simple 102 | [install] 103 | trusted-host = pypi.tuna.tsinghua.edu.cn 104 | EOF 105 | python3 -m pip install --upgrade pip 106 | python2 -m pip install --upgrade pip 107 | } 108 | 109 | # 安装Docker环境 110 | installDocker() { 111 | apt-get install -y docker.io docker-compose 112 | mkdir -p /etc/docker 113 | cat < /etc/docker/daemon.json 114 | { 115 | "registry-mirrors": [ 116 | "https://registry.docker-cn.com", 117 | "http://hub-mirror.c.163.com", 118 | "https://docker.mirrors.ustc.edu.cn", 119 | "https://cr.console.aliyun.com", 120 | "https://mirror.ccs.tencentyun.com" 121 | ] 122 | } 123 | EOF 124 | systemctl daemon-reload 125 | systemctl restart docker 126 | } 127 | 128 | # 安装Stegseek 129 | installStegseek() { 130 | wget -O stegseek.deb https://github.com/RickdeJager/stegseek/releases/download/v0.6/stegseek_0.6-1.deb 131 | dpkg -i stegseek.deb 132 | rm stegseek.deb 133 | } 134 | 135 | # 安装Crackle 136 | installCrackle() { 137 | git clone --depth 1 https://github.com/mikeryan/crackle.git 138 | cd crackle && make && make install && cd .. && rm -rf crackle 139 | } 140 | 141 | # 定义安装选项(名称:安装命令:验证命令) 142 | declare -A install_options=( 143 | ["SSH服务"]="installSsh:systemctl status ssh" 144 | ["更新APT源"]="updateSources:cat /etc/apt/sources.list | grep aliyun" 145 | ["Python环境"]="installPython:python3 -V" 146 | ["Docker环境"]="installDocker:docker --version" 147 | ["Pwntools"]="python3 -m pip install pwntools && python2 -m pip install pwntools:python3 -c 'import pwn'" 148 | ["SecLists"]="git clone --depth 1 https://github.com/danielmiessler/SecLists.git && mv SecLists /usr/share/wordlists/ && rm -rf SecLists:ls /usr/share/wordlists/Fuzzing" 149 | ["Rockyou字典"]="gzip -d /usr/share/wordlists/rockyou.txt.gz:ls /usr/share/wordlists/rockyou.txt" 150 | ["Zsteg"]="gem install zsteg:which zsteg" 151 | ["Steghide"]="apt install -y steghide:which steghide" 152 | ["Pycrypto"]="python3 -m pip install pycrypto:python3 -c 'import Crypto'" 153 | ["Gmpy2"]="python3 -m pip install gmpy2:python3 -c 'import gmpy2'" 154 | ["Dirsearch"]="apt install -y dirsearch:which dirsearch" 155 | ["Ciphey"]="docker run --rm remnux/ciphey:docker images | grep remnux/ciphey" 156 | ["Stegseek"]="installStegseek:which stegseek" 157 | ["Outguess"]="apt install -y outguess:which outguess" 158 | ["Crackle"]="installCrackle:which crackle" 159 | ) 160 | 161 | # 获取选项名称数组 162 | options=($(printf '%s\n' "${!install_options[@]}" | sort)) 163 | 164 | # 询问是否安装必备工具 165 | echo -e "${YELLOW}[?] 是否安装必备工具?(git libssl-dev libffi-dev build-essential libpcap-dev libmcrypt4 libmhash2)${NC}" 166 | read -p "输入 y 确认安装,n 跳过: " install_deps 167 | 168 | if [[ "$install_deps" == "y" || "$install_deps" == "Y" ]]; then 169 | # 安装必要工具 170 | installTools 171 | else 172 | echo -e "${YELLOW}[!] 跳过必备工具安装${NC}" 173 | fi 174 | 175 | # 主菜单循环 176 | while true; do 177 | echo -e "${CYAN}[+] 请选择要安装的组件(输入数字1-${#options[@]},或 q 退出):${NC}" 178 | for i in "${!options[@]}"; do 179 | echo "$((i+1)). ${options[$i]}" 180 | done 181 | read -p "输入选项: " choice 182 | 183 | if [[ "$choice" == "q" ]]; then 184 | echo -e "${YELLOW}[!] 用户退出安装${NC}" 185 | break 186 | elif [[ "$choice" -ge 1 && "$choice" -le ${#options[@]} ]]; then 187 | selected_option="${options[$((choice-1))]}" 188 | IFS=':' read -r install_cmd verify_cmd <<< "${install_options[$selected_option]}" 189 | installAndVerify "$selected_option" "$install_cmd" "$verify_cmd" 190 | else 191 | echo -e "${RED}[!] 无效选项,请输入数字1-${#options[@]}或 q 退出${NC}" 192 | fi 193 | done 194 | 195 | echo -e "${GREEN}[✓] 所有选定组件安装完成${NC}" 196 | --------------------------------------------------------------------------------