-
Notifications
You must be signed in to change notification settings - Fork 21
/
afl-pollenate
executable file
·71 lines (61 loc) · 1.8 KB
/
afl-pollenate
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
#! /usr/bin/env ruby
# (c) Ben Nagy, 2015, All Rights Reserved
# This software is licensed under a permissive but non-GPL compatible license,
# found in the accompanying LICENSE file.
# Pollenate ONE sync dir from each target into all other
# targets fuzzing the same format. Assumes that work
# dirs are named as by https://github.com/bnagy/afl-launch.
#
# Each target syncs inside its own directory already
# so copying any of the sync dirs works. It is possible
# that you'll miss some stuff, but it saves N * N-1 sync
#
# Layout is like
# /path/to/fuzzing
# |_ target1
# |_ t1-M0
# |_ t1-S1
# |_ [...]
# |_ target2
# |_ t2-M0
# |_ t2-S1
# |_ [...]
#
# Then run pollenate /path/to/fuzzing. Dirs will
# be copied as t1-S1.sync
root = ARGV[0]
SNOOZE = 3600
INTERVAL = 10
DEBUG = false
unless root && File.directory?( root )
$stderr.puts "Usage: #{$0} /root/dir/of/fuzzers"
exit(1)
end
dirs = Dir["#{File.expand_path(root)}/*/"]
loop do
dirs.each {|dir|
others = dirs - [dir]
fuzzer_dirs = Dir["#{dir}*S1/"]
fuzzer_dirs.each {|fd|
others.each {|other|
src = fd.chomp("/")
# Don't sync from synced dirs - that can try to write into the original,
# which ends poorly.
next if src =~ /.sync/
cmd = "rsync -ra --exclude=\".nfs*\" --exclude=\"crashes*/\" " +
"--exclude=\"hangs*/\" #{src}/ #{File.join(other, File.basename(src)+'.sync')}/"
$stderr.puts "[DEBUG] #{cmd}" if DEBUG
$stderr.print "Syncing #{fd.chomp("/")} -> #{other}"
mark = Time.now
`#{cmd}`
$stderr.puts " ... #{"%.2f" % (Time.now - mark)}s"
}
}
}
(0...SNOOZE).step(INTERVAL).each {|left|
print "\r"
print( "[SLEEPING] (%dm%ds remaining, ^C to abort) " % (SNOOZE-left).divmod(60) )
sleep INTERVAL
}
puts
end