blob: 1e2ff915a9286b8019c9e4b9012cb8a34025580e (
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
26
27
|
#!/bin/sh
# (c) 2019 KatolaZ <katolaz@freaknet.org>
# MIT License
FILEIN="${1:-/dev/stdin}"
TODAY="$(date +%Y%m%d)"
if [ "${FILEIN}" != '/dev/stdin' ]; then {
cat "${FILEIN}" | tee "${FILEIN}".bak > "${FILEIN}".new
FILEOUT="${FILEIN}".new
} else {
FILEOUT="$(basename $0).out"
}
fi
IFS=' '
while read -r D T S H P SH; do
NSH="$(printf "$S\r\n" | nc $H $P | shasum -a 256 | cut -d " " -f 1)"
[ $? -eq 0 ] &&
[ "${SH}" != "${NSH}" ] && {
D="${TODAY}"
SH="${NSH}"
}
printf "%s\t%s\t%s\t%s\t%s\t%s\n" "$D" "$T" "$S" "$H" "$P" "$SH"
done < "${FILEIN}" | sort -rnk1 -k2 | tee "${FILEOUT}" | \
sed -r "s/^([0-9][0-9]*) /1(\1) /g;s/ [a-f0-9][a-f0-9]*$//g" |\
sort -k1 -k2
|