Created
September 27, 2017 16:33
-
-
Save trevor-vaughan/5115d99e50e58c6c7ad4e360c5361dd0 to your computer and use it in GitHub Desktop.
Print all commands run by a program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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