-
Notifications
You must be signed in to change notification settings - Fork 13
Docker
Avi Lumelsky edited this page May 24, 2023
·
1 revision
Table of Contents generated with DocToc
- Install Docker: https://docs.docker.com/get-docker
-
./build.sh
- will build a docker image with
- python with dtrace static USDT instrumentations
- bpftrace
- secimport code
- ~1GB in size
- will build a docker image with
-
./run.sh
will start a new docker container with secimport.-
secimport-shell
or./trace.sh
will open a syscall-tracing python shell.- All syscalls and modules will be logged to traced_modules.json once you hit CTRL+D.
-
./run_sandbox.sh
will run a python script inside the sandboxsandbox.bt
.- It will execute
os.system('ps')
, and the process will be killed. - Logs will be written to
sandbox.log
- It will execute
- You can use
-v
in docker run to mount your code into the container and trace it.
-
root@d57458518cbf:/workspace$ ./run_sandbox.sh
π Starting secimport sandbox with bpftrace backend, the sandbox should kill the python process...
WARNING: Addrspace is not set
PID TTY TIME CMD
1 pts/0 00:00:00 sh
10 pts/0 00:00:00 bash
18 pts/0 00:00:00 bash
19 pts/0 00:00:00 bpftrace
23 pts/0 00:00:00 python
24 pts/0 00:00:00 sh
25 pts/0 00:00:00 sh
26 pts/0 00:00:00 pkill
27 pts/0 00:00:00 ps
π The process was killed, as expected.
π The sandbox bpftrace code is at sandbox.bt
π The sandbox log is at sandbox.log.
- The Docker for mac runs Linux on a hypervisor called hyperkit, and docker runs inside it, so you can use Linux features.
- Not at the moment. The bpftrace runs inside a Linux VM.
- For macOS, there is dtrace.
=====================
Based on the great example repo: https://github.com/mmisono/try-bpftrace-in-mac