Skip to content

Instantly share code, notes, and snippets.

@cobbr2
Created July 31, 2019 22:40
Show Gist options
  • Save cobbr2/764bd4e9dcfe4923bab9586c8f303760 to your computer and use it in GitHub Desktop.
Save cobbr2/764bd4e9dcfe4923bab9586c8f303760 to your computer and use it in GitHub Desktop.
Ruby to parse EXECVEs from audispd into something that looks like a shell session.
#!/usr/bin/env ruby
def time(tokens)
if tokens.first =~ /^\d+-\d+-\d+T/
tokens.first
else
tokens[0..2].join(' ')
end
end
while gets do
case $_
when /EXECVE/ then
tokens = $_.split
STDOUT.write time(tokens), ' '
wack = tokens.map do |stringy|
match = /^a(\d+)=(.*)/.match(stringy)
next nil unless match
argnum = match[1]
argument = match[2]
if Integer(argnum) == 0
argument.sub!(/^"/,'')
argument.sub!(/"$/,'')
end
argument
end.compact
puts wack.join(' ')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment