Created
July 31, 2019 22:40
-
-
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.
This file contains 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 | |
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