3 """A tool for looking for indirect jumps and calls in x86 binaries.
5 Helpful to verify whether or not retpoline mitigations are catching
6 all of the indirect branches in a binary and telling you which
7 functions the remaining ones are in (assembly, etc).
9 Depends on llvm-objdump being in your path and is tied to the
19 # Look for indirect calls/jmps in a binary. re: (call|jmp).*\*
20 def look_for_indirect(file):
21 args
= ['llvm-objdump']
25 p
= subprocess
.Popen(args
=args
, stdin
=None, stderr
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
)
26 (stdout
,stderr
) = p
.communicate()
29 for line
in stdout
.splitlines():
30 if line
.startswith(' ') == False:
32 result
= re
.search('(call|jmp).*\*', line
)
34 # TODO: Perhaps use cxxfilt to demangle functions?
40 # No options currently other than the binary.
41 parser
= optparse
.OptionParser("%prog [options] <binary>")
42 (opts
, args
) = parser
.parse_args(args
)
44 parser
.error("invalid number of arguments: %s" % len(args
))
45 look_for_indirect(args
[1])
47 if __name__
== '__main__':