2
0
mirror of https://github.com/mozilla/cipherscan.git synced 2024-10-05 18:53:40 +02:00
cipherscan/top1m/testtop1m.sh
Hubert Kario 8817a7b1c8 testtop1m.sh: correct counting of background jobs
`jobs` command returns multiple lines for a jobs with `if` so counting
number of background jobs was off
2014-05-13 13:41:16 +02:00

43 lines
888 B
Bash
Executable File

#!/usr/bin/env bash
parallel=50
max_bg=50
[ ! -e "results" ] && mkdir results
function wait_for_jobs() {
local no_jobs
no_jobs=$(jobs | wc -l)
while [ $no_jobs -gt $1 ]; do
sleep 1
no_jobs=$(jobs | wc -l)
done
}
function scan_host() {
tcping -u 10000000 $1 443;
if [ $? -gt 0 ];then
tcping -u 10000000 www.$1 443;
if [ $? -gt 0 ]; then
return;
else
../cipherscan -json www.$1:443 > results/www.$t
return;
fi;
fi;
../cipherscan -json $t:443 > results/$t
}
i=0
count=$(wc -l top-1m.csv | awk '{print $1}')
while [ $i -lt $count ]
do
echo processings sites $i to $((i + parallel))
for t in $(tail -$(($count - $i)) top-1m.csv | head -$parallel |cut -d ',' -f 2)
do
(scan_host $t)&
done
i=$(( i + parallel))
wait_for_jobs $max_bg
done
wait