HAMMER 60I/Many: Mirroring
[dragonfly.git] / secure / lib / libssh / generate-blacklist.sh
blob39044e30e815b90d332afe05d42758d7d1bd5e63
1 #!/bin/bash
2 # $DragonFly: src/secure/lib/libssh/generate-blacklist.sh,v 1.1 2008/05/21 14:07:41 corecode Exp $
3 set -e
5 LIBSSL=$(apt-cache policy libssl0.9.8 | grep Installed | awk '{print $NF}')
6 dpkg --compare-versions "$LIBSSL" lt 0.9.8g-9 || {
7 echo "Your libssl0.9.8 is newer than the fixed version (0.9.8g-9)." >&2
8 echo "This script is only sensible to run with a broken version. :)" >&2
9 exit 1
12 KEYTYPE=$(echo "$1" | tr A-Z a-z)
13 KEYSIZE="$2"
14 if [ -z "$KEYTYPE" ] || [ -z "$KEYSIZE" ]; then
15 echo "Usage: $0 KEYTYPE KEYSIZE" >&2
16 exit 1
19 WORKDIR=$(mktemp -d -t blacklist-XXXXXX)
20 cd "$WORKDIR"
22 cat >getpid.c <<EOM
24 * Compile:
26 gcc -fPIC -c getpid.c -o getpid.o
27 gcc -shared -o getpid.so getpid.o
29 * Use:
31 FORCE_PID=1234 LD_PRELOAD=./getpid.so bash
34 # Copyright (C) 2001-2008 Kees Cook
35 # kees@outflux.net, http://outflux.net/
37 # This program is free software; you can redistribute it and/or
38 # modify it under the terms of the GNU General Public License
39 # as published by the Free Software Foundation; either version 2
40 # of the License, or (at your option) any later version.
42 # This program is distributed in the hope that it will be useful,
43 # but WITHOUT ANY WARRANTY; without even the implied warranty of
44 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 # GNU General Public License for more details.
47 # You should have received a copy of the GNU General Public License
48 # along with this program; if not, write to the Free Software
49 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
50 # http://www.gnu.org/copyleft/gpl.html
54 #include <sys/types.h>
55 #include <unistd.h>
56 #include <stdlib.h>
58 pid_t getpid(void)
60 return atoi(getenv("FORCE_PID"));
62 EOM
64 gcc -fPIC -c getpid.c -o getpid.o
65 gcc -shared -o getpid.so getpid.o
67 echo "# generated on $(uname -m) at $(date)"
69 for pid in $(seq 1 32767)
71 FILE="key-$pid"
72 HASH=$(FORCE_PID="$pid" LD_PRELOAD=./getpid.so \
73 ssh-keygen -P "" -t "$KEYTYPE" -b "$KEYSIZE" -f "$FILE" | \
74 grep :..: | cut -d" " -f1 | sed -e 's/://g')
75 rm -f "$FILE" "$FILE".pub
76 echo "$HASH"
77 done
79 rm -f getpid.*
80 cd /
81 rmdir "$WORKDIR"