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
|
#!/usr/bin/env bash
input=$(mktemp)
binary=$(mktemp)
trap "rm -f $input $binary" EXIT
function sseq()
{
for ((i = $1; i < $2; i=i<<1)); do
echo $i
done
}
function do_base64()
{
if [ -n "$(type -p base64)" ]; then
base64 $1
elif [ -n "$(type -p uuencode)" ]; then
uuencode -m $1 data | sed 1d | sed '$d'
else
echo "No tool found for base64 encoding." >&2
exit 1
fi
}
for i in $(sseq 1 1024) 2048 10240;
do
echo $i
dd if=/dev/urandom of=$binary bs=1 count=$i &>/dev/null
echo "-----BEGIN INITSTATE-----" > $input
do_base64 $binary >> $input
echo "-----END INITSTATE-----" >> $input
./base64decode $input $binary
if [ $? -ne 0 ]; then
exit 1
fi
done
|