unzip_bruteforce should be good

This commit is contained in:
Your Name
2026-04-02 19:02:40 +02:00
parent 260db0dff7
commit b8104380ca
+22 -17
View File
@@ -1,27 +1,32 @@
#!/usr/bin/bash
#!/usr/bin/env bash
if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]; then
echo "Usage: $0 list file.zip"
set -euo pipefail
LIST=${1:-list}
FILE=${2:-}
usage() {
echo "usage: $0 [wordlist] <zipfile>"
echo "default wordlist: ./list"
exit 1
fi
}
LIST=$1
FILE=$2
COUNT=$(mktemp)
echo 0 > "$COUNT"
export FILE COUNT
[[ -z "$FILE" ]] && usage
[[ ! -f "$LIST" ]] && { echo "missing wordlist: $LIST"; exit 1; }
[[ ! -f "$FILE" ]] && { echo "missing zip: $FILE"; exit 1; }
xargs -a "$LIST" -P4 -I{} bash -c '
line="$1"
i=0
# atomic-ish counter
n=$(($(<"$COUNT")+1))
echo "$n" > "$COUNT"
while IFS= read -r line; do
((i++))
((n % 1000 == 0)) && echo "$n tries..."
(( i % 1000 == 0 )) && echo "$i tried..."
if unzip -P "$line" -t "$FILE" >/dev/null 2>&1; then
echo "FOUND: $line"
killall xargs 2>/dev/null
exit 0
fi
' _ {}
done < "$LIST"
echo "not found"
exit 1