-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tracing and profile creation examples
- Loading branch information
Avi Lumelsky
authored and
Avi Lumelsky
committed
Jul 11, 2022
1 parent
c462167
commit ca211bc
Showing
3 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Tracing processes for syscalls | ||
There are several ways to create a secimport profile for your modules. | ||
|
||
- Using `secure_import` from python: | ||
- `secimport.secure_import(..., log_syscalls=True, destructive=False)` | ||
- The log output will contain all the syscalls made by your process. | ||
- Create a secure import based on that log | ||
- Using our dscript to generate a profile: | ||
- `sudo dtrace -s src/secimport/templates/default.allowlist.template.d -c "python -m http.server"` | ||
- CTRL+C | ||
- Create a secure import based on that log. | ||
- Using simple `dtrace` | ||
- Tracing the syscalls of a process with pid `12345` | ||
- `dtrace -n 'syscall::: /pid == ($1)/ {@[pid,execname,probefunc]=count()}' 12345` | ||
- Tracing the syscalls of a docker container with pid `12345` | ||
- `dtrace -n 'syscall::: /progenyof($1)/ {@[pid,execname,probefunc]=count()}' 12345` | ||
- Using `strace` | ||
- A script to list all your application's syscalls using `strace`.<br> I contributed it to `firejail` a few years ago: | ||
- https://github.com/netblue30/firejail/blob/master/contrib/syscalls.sh | ||
- ``` | ||
wget "https://raw.githubusercontent.com/netblue30/firejail/c5d426b245b24d5bd432893f74baec04cb8b59ed/contrib/syscalls.sh" -O syscalls.sh | ||
chmod +x syscalls.sh | ||
./syscalls.sh examples/http_request.py | ||
``` |
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