OLD | NEW |
(Empty) | |
| 1 #!/bin/sh |
| 2 # |
| 3 # american fuzzy lop - fuzzer synchronization tool |
| 4 # ------------------------------------------------ |
| 5 # |
| 6 # Written and maintained by Michal Zalewski <lcamtuf@google.com> |
| 7 # |
| 8 # Copyright 2014 Google Inc. All rights reserved. |
| 9 # |
| 10 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 # you may not use this file except in compliance with the License. |
| 12 # You may obtain a copy of the License at: |
| 13 # |
| 14 # http://www.apache.org/licenses/LICENSE-2.0 |
| 15 # |
| 16 # To make this script work: |
| 17 # |
| 18 # - Edit FUZZ_HOSTS, FUZZ_DOMAIN, FUZZ_USER, and SYNC_DIR to reflect your |
| 19 # environment. |
| 20 # |
| 21 # - Make sure that the system you are running this on can log into FUZZ_HOSTS |
| 22 # without a password (authorized_keys or otherwise). |
| 23 # |
| 24 # - Make sure that every fuzzer is running with -o pointing to SYNC_DIR and -S |
| 25 # that consists of its local host name, followed by an underscore, and then |
| 26 # by some host-local fuzzer ID. |
| 27 # |
| 28 |
| 29 # Hosts to synchronize the data across. |
| 30 FUZZ_HOSTS='host1 host2 host3 host4' |
| 31 |
| 32 # Domain for all hosts |
| 33 FUZZ_DOMAIN='example.com' |
| 34 |
| 35 # Remote user for SSH |
| 36 FUZZ_USER=bob |
| 37 |
| 38 # Directory to synchronize |
| 39 SYNC_DIR='/home/bob/sync_dir' |
| 40 |
| 41 # Interval (seconds) between sync attempts |
| 42 SYNC_INTERVAL=$((30 * 60)) |
| 43 |
| 44 if [ "$PWD" = "/tmp" -o "$PWD" = "/var/tmp" ]; then |
| 45 echo "[-] Error: do not use shared /tmp or /var/tmp directories with this scri
pt." 1>&2 |
| 46 exit 1 |
| 47 fi |
| 48 |
| 49 rm -rf .sync_tmp 2>/dev/null |
| 50 mkdir .sync_tmp || exit 1 |
| 51 |
| 52 while :; do |
| 53 |
| 54 # Pull data in... |
| 55 |
| 56 for host in $FUZZ_HOSTS; do |
| 57 |
| 58 echo "[*] Retrieving data from ${host}.${FUZZ_DOMAIN}..." |
| 59 |
| 60 ssh -o 'passwordauthentication no' ${FUZZ_USER}@${host}.$FUZZ_DOMAIN \ |
| 61 "cd '$SYNC_DIR' && tar -czf - ${host}_*/[qf]*" >".sync_tmp/${host}.tgz" |
| 62 |
| 63 done |
| 64 |
| 65 # Distribute data. For large fleets, see tips in the docs/ directory. |
| 66 |
| 67 for dst_host in $FUZZ_HOSTS; do |
| 68 |
| 69 echo "[*] Distributing data to ${dst_host}.${FUZZ_DOMAIN}..." |
| 70 |
| 71 for src_host in $FUZZ_HOSTS; do |
| 72 |
| 73 test "$src_host" = "$dst_host" && continue |
| 74 |
| 75 echo " Sending fuzzer data from ${src_host}.${FUZZ_DOMAIN}..." |
| 76 |
| 77 ssh -o 'passwordauthentication no' ${FUZZ_USER}@$dst_host \ |
| 78 "cd '$SYNC_DIR' && tar -xkzf -" <".sync_tmp/${src_host}.tgz" |
| 79 |
| 80 done |
| 81 |
| 82 done |
| 83 |
| 84 echo "[+] Done. Sleeping for $SYNC_INTERVAL seconds (Ctrl-C to quit)." |
| 85 |
| 86 sleep $SYNC_INTERVAL |
| 87 |
| 88 done |
| 89 |
OLD | NEW |