Skip to content

Instantly share code, notes, and snippets.

@trevor-vaughan
Created September 27, 2017 16:33
Show Gist options
  • Select an option

  • Save trevor-vaughan/5115d99e50e58c6c7ad4e360c5361dd0 to your computer and use it in GitHub Desktop.

Select an option

Save trevor-vaughan/5115d99e50e58c6c7ad4e360c5361dd0 to your computer and use it in GitHub Desktop.
Print all commands run by a program
#!/usr/bin/env ruby
# Expects an input file generated using:
# strace -f -qq -o <output_file> -e trace=execve <command>
infile = ARGV.first
unless File.exists?(infile)
$stderr.puts("'#{infile}' is not a valid file")
end
puts File.read(infile).lines.map{|x| if x =~ %r(execve\("(.+?)") then x = $1 else; x = nil end }.compact.sort.uniq.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment