File: crypto-keygen-standalone-brute.sh

package info (click to toggle)
darkplaces 0~20180412~beta1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 18,200 kB
  • sloc: ansic: 176,886; makefile: 485; pascal: 455; perl: 372; objc: 245; sh: 102
file content (53 lines) | stat: -rwxr-xr-x 795 bytes parent folder | download | duplicates (5)
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
#!/bin/sh

outfile=$1; shift
hosts=$1; shift

on()
{
	case "$1" in
		localhost)
			shift
			exec "$@"
			;;
		*)
			exec ssh "$@"
			;;
	esac
}

pids=
mainpid=$$
trap 'kill $pids' EXIT
trap 'exit 1' INT USR1

n=0
for h in $hosts; do
	nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[ 	:]'`
	n=$(($nn + $n))
done

rm -f bruteforce-*
i=0
for h in $hosts; do
	nn=`on "$h" cat /proc/cpuinfo | grep -c '^processor[ 	:]'`
	ii=$(($nn + $i))
	while [ $i -lt $ii ]; do
		i=$(($i+1))
		(
			on "$h" ./crypto-keygen-standalone -n $n -o /dev/stdout "$@" > bruteforce-$i &
			pid=$!
			trap 'kill $pid' TERM
			wait
			if [ -s "bruteforce-$i" ]; then
				trap - TERM
				mv "bruteforce-$i" "$outfile"
				kill -USR1 $mainpid
			else
				rm -f "bruteforce-$i"
			fi
		) &
		pids="$pids $!"
	done
done
wait