]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - crypto-keygen-standalone-brute.sh
Cryptographic authentication support for the d0_blind_id library available on http...
[xonotic/darkplaces.git] / crypto-keygen-standalone-brute.sh
diff --git a/crypto-keygen-standalone-brute.sh b/crypto-keygen-standalone-brute.sh
new file mode 100755 (executable)
index 0000000..a081b06
--- /dev/null
@@ -0,0 +1,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