-
Notifications
You must be signed in to change notification settings - Fork 84
/
update-tools.sh
executable file
·96 lines (79 loc) · 2.77 KB
/
update-tools.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# Generate data/tools.
# Format: <name>\t<version>\t<url>\t<description>
export LC_ALL=C
SITE="blackarch.org"
REPO="blackarch"
ARCH="x86_64"
OUT="data/tools"
# Remove previous file entry except the mirrors file
find data ! -name 'mirrors' -type f -exec rm -f {} +
make_tmp() {
tmp=$(mktemp -d /tmp/blackarch.XXXXXXXXXXX)
}
get_db() {
curl "https://$SITE/blackarch/$REPO/os/$ARCH/$REPO.db.tar.gz" |
tar xz -C "$tmp"
}
parse_db() {
mkdir -p "$(dirname file)"
for d in "$tmp"/*
do
# Name
name="$(grep --no-group-separator -A2 '^%NAME%$' "${d}"/desc |
sed -e 's/[0-9]\+://' -e 's/-[0-9]\+//' | grep -v '^%NAME%$')"
# Version
vers="$(grep --no-group-separator -A2 '^%VERSION%$' "${d}"/desc |
sed -e 's/[0-9]\+://' -e 's/-[0-9]\+//' | grep -v '^%VERSION%$')"
# Description
desc="$(grep --no-group-separator -A2 '^%DESC%$' "${d}"/desc |
sed -e 's/[0-9]\+://' -e 's/-[0-9]\+//' | grep -v '^%DESC%$')"
# Category
# Add exception for the following packages
case "${name}" in
"blackarch-config-awesome"|"blackarch-config-fluxbox"|"blackarch-config-openbox"|"blackarch-config-i3"|"blackarch-config-spectrwm"|"blackarch-config-wmii"|"blackarch-config-lxdm"|"blackarch-config-vim"|"blackarch-config-bash"|"blackarch-config-x11"|"blackarch-config-gtk"|"blackarch-mirrorlist"|"blackarch-menus"|"bactl"|"blackarch-config-xfce"|"blackarch-config-zsh"|"blackarch-config-cursor"|"blackarch-config-icons"|"blackarch-config-calamares")
continue
;;
"truecrack"|"cudahashcat"|"cryptohazemultiforcer")
group="blackarch-cracker"
;;
"nuclei-templates")
group="blackarch-scanner"
;;
"seclists"|"assetnote-wordlists")
group="blackarch-wordlist"
;;
"vmcloak"|"malboxes"|"thezoo")
group="blackarch-malware"
;;
*)
# All the other packages (add '0,/blackarch/s///' for remove first occurrence only
group="$(grep --no-group-separator -A2 '^%GROUPS%$' "${d}"/desc |
sed -e 's/[0-9]\+://' -e 's/-[0-9]\+//' -e '0,/blackarch/s///' |
grep -v '^%GROUPS%$' | tr -s '\n' ' ')"
esac
# Website url
url="$(grep --no-group-separator -A2 '^%URL%$' "${d}"/desc |
sed -e 's/[0-9]\+://' -e 's/-[0-9]\+//' | grep -v '^%URL%$')"
fgroup=$(echo "$group" | sed -e 's/blackarch-//g' -e 's/ //g' -e "s/'//g")
# Do not insert the current package if the $group variable is empty
if [ "$group" ]; then
echo "$name|$vers|$desc|$group|$url" >> "$OUT"
if [ "$fgroup" ]; then
# [review] This was happening at least three times.
echo "$name|$vers|$desc|$url" >> data/"$fgroup"
fi
fi
done
}
split() {
sed -i 's/\t/\|/g' "$OUT"
}
main() {
rm -f "$OUT"
make_tmp
get_db
parse_db
split
}
main "$@"