This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
microdump.lua
66 lines (58 loc) · 1.87 KB
/
microdump.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
-- Copyright 2019 VMware, Inc.
-- SPDX-License-Identifier: BSD-2-Clause
-- chisel description
description = "this chisel will print all the file paths included in your capture, including relative commands to PATH"
short_description = "get a list a files to build a microcontainer, use with ./micropacker"
category = "misc"
-- arguments list
args = {}
-- Initialization callback
function on_init()
-- get some handlers
dir_h = chisel.request_field("evt.dir")
stype_h = chisel.request_field("syscall.type")
arg_filename_h = chisel.request_field("evt.arg.filename")
arg_name_h = chisel.request_field("evt.arg.name")
arg_path_h = chisel.request_field("evt.arg.path")
arg_exe_h = chisel.request_field("evt.arg.exe")
absolute_h = chisel.request_field("evt.abspath")
return true
end
-- main event handler
function on_event()
-- get the right fields depending on the direction
if evt.field(dir_h) == "<" then
-- we might have a > execve with filename=/path/abc.sh
-- but then we need to capture also /bin/sh in the < execve
if evt.field(stype_h) == "execve" then
arg_exe = evt.field(arg_exe_h)
if arg_exe ~= nil and arg_exe ~= "<NA>" then
print(arg_exe)
end
-- check for name in < open
elseif evt.field(stype_h) == "open" then
arg_name = evt.field(arg_name_h)
if arg_name ~= nil and arg_name ~= "<NA>" then
print(arg_name)
end
end
end
if evt.field(dir_h) == ">" and evt.field(stype_h) ~= nil then
absolute = evt.field(absolute_h)
if absolute ~= nil then
print(absolute)
else
arg_filename = evt.field(arg_filename_h)
arg_name = evt.field(arg_name_h)
arg_path = evt.field(arg_path_h)
if arg_filename ~= nil and arg_filename ~= "<NA>" then
print(arg_filename)
elseif arg_name ~= nil and arg_name ~= "<NA>" then
print(arg_name)
elseif arg_path ~= nil and arg_path ~= "<NA>" then
print(arg_path)
end
end
end
return true
end