File docs/pre1.tex changed (mode: 100644) (index 98e1c33..5e966f5) |
8 |
8 |
\usepackage[utf8]{inputenc} |
\usepackage[utf8]{inputenc} |
9 |
9 |
|
|
10 |
10 |
\title{ninedogs project} |
\title{ninedogs project} |
11 |
|
\subtitle{Augumented high and low-level tracing} |
|
|
11 |
|
\subtitle{Augmented high and low-level tracing} |
12 |
12 |
\author{\small Catalin(ux) M. BOIE - ninedogs@embedromix.ro} |
\author{\small Catalin(ux) M. BOIE - ninedogs@embedromix.ro} |
13 |
13 |
\date{\small 2022-11-09} |
\date{\small 2022-11-09} |
14 |
14 |
%\titlegraphic{\includegraphics[width=2.5cm]{ninedogs.svg}} |
%\titlegraphic{\includegraphics[width=2.5cm]{ninedogs.svg}} |
|
57 |
57 |
\begin{frame} |
\begin{frame} |
58 |
58 |
\begin{block}{How ninedogs is working?} |
\begin{block}{How ninedogs is working?} |
59 |
59 |
\begin{itemize} |
\begin{itemize} |
60 |
|
\item It uses LD\_PRELOAD mechanism to hook all interesting shared libraries calls. |
|
61 |
|
\item Examples of hooked functions (not syscalls! it does not use ptrace): recv, send, open, |
|
62 |
|
mysqli\_fetch\_array, pg\_pconnect, sqlite3\_open\_v2, syslog etc. |
|
63 |
|
\item Many more will come in each release. |
|
|
60 |
|
\item It uses LD\_PRELOAD mechanism to hook all interesting shared libraries |
|
61 |
|
calls and write the events in a shared memory area. |
|
62 |
|
\item The tracing tool (nd-trace) will attach to the target process' shared |
|
63 |
|
memory area and exfiltrate the data. |
|
64 |
|
\item Examples of hooked functions (not syscalls, it does not use ptrace): |
|
65 |
|
recv, send, open, mysqli\_fetch\_array, pg\_pconnect, sqlite3\_open\_v2, syslog etc. |
64 |
66 |
\end{itemize} |
\end{itemize} |
65 |
67 |
\end{block} |
\end{block} |
66 |
68 |
\end{frame} |
\end{frame} |
|
70 |
72 |
\begin{itemize} |
\begin{itemize} |
71 |
73 |
\item They cannot be used in GCP and Azure (probably also AWS) containers for |
\item They cannot be used in GCP and Azure (probably also AWS) containers for |
72 |
74 |
security reasons. |
security reasons. |
73 |
|
\item They are low level tools; e.g. if a connection to a database is encrypted, |
|
74 |
|
you cannot see anything interesting. |
|
|
75 |
|
\item They are low level tools; e.g. if a connection to a database or web |
|
76 |
|
server is encrypted, you cannot see anything interesting. |
75 |
77 |
\item They are way too verbose. |
\item They are way too verbose. |
76 |
78 |
\end{itemize} |
\end{itemize} |
77 |
79 |
\end{block} |
\end{block} |
|
81 |
83 |
\begin{block}{Why strace is better (if it can be used)?} |
\begin{block}{Why strace is better (if it can be used)?} |
82 |
84 |
\begin{itemize} |
\begin{itemize} |
83 |
85 |
\item strace can be used on static linked binaries, ninedogs cannot. |
\item strace can be used on static linked binaries, ninedogs cannot. |
84 |
|
In practice, this is rarely encountered. |
|
|
86 |
|
One notable exceptions are Go programs which are statically linked. |
85 |
87 |
\end{itemize} |
\end{itemize} |
86 |
88 |
\end{block} |
\end{block} |
87 |
89 |
\end{frame} |
\end{frame} |
|
92 |
94 |
\item It uses shared memory as a ring buffer to pass information to the tracer. |
\item It uses shared memory as a ring buffer to pass information to the tracer. |
93 |
95 |
\item The biggest cost is copying from memory to memory (negligible). |
\item The biggest cost is copying from memory to memory (negligible). |
94 |
96 |
\item It does not block if the ring is full. |
\item It does not block if the ring is full. |
95 |
|
\item It uses a small amount of memory compared with other solutions. |
|
|
97 |
|
\item It uses a small amount of memory and CPU compared with other solutions. |
96 |
98 |
\end{itemize} |
\end{itemize} |
97 |
99 |
\end{block} |
\end{block} |
98 |
100 |
\end{frame} |
\end{frame} |
|
... |
... |
dnf install catalinux+ninedogs |
128 |
130 |
\begin{block}{Usage in a systemd service file} |
\begin{block}{Usage in a systemd service file} |
129 |
131 |
\small |
\small |
130 |
132 |
\begin{verbatim} |
\begin{verbatim} |
131 |
|
TODO |
|
|
133 |
|
/etc/systemd/system/bla.service.d/ninedogs.conf: |
|
134 |
|
Environment=LD_PRELOAD=ninedogs.so |
132 |
135 |
\end{verbatim} |
\end{verbatim} |
133 |
136 |
\end{block} |
\end{block} |
134 |
137 |
\end{frame} |
\end{frame} |
|
... |
... |
curl_easy_cleanup(curl); |
229 |
232 |
\tiny |
\tiny |
230 |
233 |
\begin{verbatim} |
\begin{verbatim} |
231 |
234 |
curl_easy_init() = 0x1c2b960 |
curl_easy_init() = 0x1c2b960 |
232 |
|
curl_easy_setopt(0x1c2b960, CURLOPT_URL, 'https://localhost') = ok |
|
233 |
|
curl_easy_setopt(0x1c2b960, CURLOPT_POST, 1) = ok |
|
234 |
|
curl_easy_setopt(0x1c2b960, CURLOPT_POSTFIELDS, 0x402010) = ok |
|
235 |
|
curl_easy_setopt(0x1c2b960, CURLOPT_POSTFIELDSIZE, 10) = ok |
|
236 |
|
curl_easy_setopt(0x1c2b960, CURLOPT_HTTPHEADER, {'Content-Type: application/json', 'X-ninedogs-bla: 1'}) = ok |
|
|
235 |
|
curl_easy_setopt(0x1c2b960, URL, 'https://localhost') = ok |
|
236 |
|
curl_easy_setopt(0x1c2b960, POST, 1) = ok |
|
237 |
|
curl_easy_setopt(0x1c2b960, POSTFIELDS, '{"a": "1"}') = ok |
|
238 |
|
curl_easy_setopt(0x1c2b960, POSTFIELDSIZE, 10) = ok |
|
239 |
|
curl_easy_setopt(0x1c2b960, HTTPHEADER, {'Content-Type: application/json', 'X-ninedogs-bla: 1'}) = ok |
237 |
240 |
curl_easy_perform(0x1c2b960) |
curl_easy_perform(0x1c2b960) |
238 |
241 |
curl_easy_cleanup(0x1c2b960) |
curl_easy_cleanup(0x1c2b960) |
239 |
242 |
\end{verbatim} |
\end{verbatim} |
|
... |
... |
Segmentation fault (core dumped) |
441 |
444 |
\subsection{Demo} |
\subsection{Demo} |
442 |
445 |
|
|
443 |
446 |
\begin{frame}[fragile]{Entering a container and do a trace} |
\begin{frame}[fragile]{Entering a container and do a trace} |
444 |
|
We assume that a container named c1 is already runing and it has |
|
|
447 |
|
We assume that a container named c1 is already running and it has |
445 |
448 |
the ninedogs tools installed and that a program is already running with |
the ninedogs tools installed and that a program is already running with |
446 |
449 |
\verb|LD_PRELOAD=ninedogs|. |
\verb|LD_PRELOAD=ninedogs|. |
447 |
450 |
\small |
\small |
448 |
451 |
\begin{verbatim} |
\begin{verbatim} |
449 |
452 |
$ docker exec -it c1 /bin/bash # enter container |
$ docker exec -it c1 /bin/bash # enter container |
450 |
|
$ nd-trace -o my_trace_file.nd -p 1 |
|
451 |
|
Saving output to [my_trace_file.nd] |
|
|
453 |
|
$ nd-trace -p 1 # pid 1 is usualy the main program |
452 |
454 |
1: shm_open returned 4 |
1: shm_open returned 4 |
453 |
455 |
1: Attached |
1: Attached |
454 |
456 |
16692xxxxx.054 1 getrandom(buf, 1, 0x1) |
16692xxxxx.054 1 getrandom(buf, 1, 0x1) |