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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#!/usr/bin/env bash
DIR=$(dirname "$0")
cd "$DIR" || exit 1
myscript=$(basename $0)
server="$1"
client="$2"
user="$3"
if [ -z "$server" ] \
|| [ -z "$client" ] \
|| [ -z "$user" ] ; then
echo "Usage: $myscript [server address] [client address] [client user]"
exit 1
fi
path="$PWD"
build="$path/build"
target="$path/target"
ssh_opts="-o StrictHostKeyChecking=no"
fail()
{
echo
echo "Test setup failed: $@"
echo
exit 1
}
makedir()
{
rm -rf "$1"
mkdir -p "$1" || fail "could not mkdir $1"
}
cdir()
{
cd "$1" || fail "could not cd to $1"
}
build_and_install()
{
# Create a build directory, and fill it with the source.
makedir "$build"
makedir "$build/test"
ls ../ | while read f ; do
[ "$f" = "test" ] && continue
[ "$f" = ".git" ] && continue
cp -ar ../"$f" "$build" || fail "could not copy ../$f to $build"
done || exit 1
# Add some extra directories/files.
cp -ar fs-data "$build"
# Create a target directory, compile burp and install it into the
# target.
makedir "$target"
cdir "$build"
make clean
./configure --prefix=/usr --sysconfdir=/etc/burp --localstatedir=/var || fail "configure failed"
make || fail "make failed"
# For some reason, make is not returning an error code.
# Look for important binaries before carrying on.
[ -x burp ] || fail "make failed to build binaries"
make install-all DESTDIR="$target" || fail "make install failed"
cdir -
# Now build the Windows installer.
cdir "$build/src/win32"
make WIN64=yes || fail
# Now copy the Windows installer to the client
installer=$(find -name burp-win64-installer*.exe)
[ -z "$client" ] && fail
scp $ssh_opts "$installer" "$user@$client:" || fail
cdir -
}
build_and_install
# Copy the build directory to the client, to give it something to backup.
cdir "$path" || fail
# The Windows build symlinks cock things up for 'diff -ur' on the restore
# later, so delete them first.
rm -f build/burp-depkgs
rm -f build/burp-cross-tools
tar -cjf build.tar.bz2 build || fail
scp $ssh_opts build.tar.bz2 "$user@$client:" || fail
installer=$(basename $installer)
clientburpdir="/cygdrive/c/Program Files/Burp"
rm -f windowsscript
cat >> windowsscript << EOF
#!/usr/bin/env bash
set -ex
clientburpdir="$clientburpdir"
function check_conf()
{
local conf="\$clientburpdir/burp.conf"
grep "\$1" "\$conf"
}
echo "Test command line switches"
rm -rf "\$clientburpdir"
./$installer /S /cname=customcname /server=1.2.3.4 /password=custompass
check_conf '^cname = customcname$'
check_conf '^server = 1.2.3.4:4971$'
check_conf '^password = custompass$'
echo "Test command line without switches"
rm -rf "\$clientburpdir"
./$installer /S
check_conf "^cname = \$(hostname)$"
check_conf '^server = 10.0.0.1:4971$'
check_conf '^password = abcdefgh$'
# Remove the cron job, or unexpected results can occur.
schtasks /DELETE /TN "burp cron" /F
tar -xjf build.tar.bz2 -C "$clientburpdir"
# Encrypt some directories and files to test EFS.
cipher.exe /E /S:"C:/Program Files/Burp/build/utest/builders"
# Run utest.exe.
cd "/cygdrive/c/Program Files/Burp/bin"
./utest.exe
EOF
scp $ssh_opts windowsscript "$user@$client:" || fail
ssh $ssh_opts "$user@$client" chmod 755 windowsscript || fail
ssh $ssh_opts "$user@$client" chmod 755 "$installer" || fail
ssh $ssh_opts "$user@$client" ./windowsscript || fail
# args:
# 1 - directory where build was installed
# 2 - location of client burp
# 3 - location of client conf (for editing)
# 4 - location of client conf (for giving as option to burp binary)
# 5 - directory to backup
# 6 - directory to restore to
# 7 - address of the server
# 8 - ssh command (leave unset for self test)
# 9 - scp command (leave unset for self test)
# 10 - address of the client (leave unset for self test)
do_run()
{
rm -rf "$target/var/spool/burp/global"
rm -rf "$target/var/spool/burp/testclient"
./test_main \
"$target" \
"$clientburpdir/bin/burp.exe" \
"$clientburpdir/burp.conf" \
"C:\Program Files\Burp\burp.conf" \
"C:/Program Files/Burp/build" \
"C:/Program Files/Burp/restore" \
"$server" \
"ssh $ssh_opts" \
"scp $ssh_opts" \
"$user@$client" || exit 1
}
echo "Running with split_vss=0, strip_vss=0"
do_run
echo "Running with split_vss=1, strip_vss=0"
NO_CA_GEN=1 SPLIT_VSS=1 do_run
echo "Running with split_vss=0, strip_vss=1"
NO_CA_GEN=1 STRIP_VSS=1 do_run
|