#!/bin/zsh # 分块并行下载 Ghidra(GitHub release 单连接只有 ~150KB/s,多连接能快很多)。 set -e URL="https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_12.1.4_build/ghidra_12.1.4_PUBLIC_20260921.zip" TOTAL=569649598 PARTS=8 HERE="$(cd "$(dirname "$0")" && pwd)" OUT="$HERE/ghidra.zip" CHUNK=$(( (TOTAL + PARTS - 1) / PARTS )) for index in $(seq 0 $((PARTS - 1))); do start=$(( index * CHUNK )) end=$(( start + CHUNK - 1 )) (( end >= TOTAL )) && end=$(( TOTAL - 1 )) part="$HERE/.ghidra.part$index" have=0 [[ -f "$part" ]] && have=$(stat -f%z "$part") want=$(( end - start + 1 )) if (( have >= want )); then echo "part$index 已完成 ($have)" continue fi echo "part$index -> $(( have )) / $want" curl -sL --max-time 1800 -r $(( start + have ))-$end -o "$part" "$URL" & done wait echo "拼接" : > "$OUT" for index in $(seq 0 $((PARTS - 1))); do cat "$HERE/.ghidra.part$index" >> "$OUT" done ls -la "$OUT"