summaryrefslogtreecommitdiff
path: root/download-phrack-targz.sh
blob: 6ec9c01b29673c640ffcb047ee45b4e3b1a35375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

if ! command -v curl &>/dev/null; then
    printf "%s\n" "[err] curl not found"
    exit 1
fi

archives=$(curl -sSLf https://archives.phrack.org/tgz/ | grep -oP '(?<=phrack)[0-9]{1,}(?=\.tar\.gz)' | sort -n | tail -1)

if ! test "${archives}"; then
    printf "%s\n" "[err] failed to get phrack archives"
    exit 1
fi

for ((i=1; i<=archives; i++)); do
    remote_file="phrack${i}.tar.gz"
    if (( i < 10 )); then
        local_file="phrack0${i}.tar.gz"
    else
        local_file="${remote_file}"
    fi
    url="http://phrack.org/archives/tgz/${remote_file}"
    printf "%s\n" "[inf] downloading ${url}"
    curl -sSLf "${url}" -o "${local_file}"
done