{"id":383368,"date":"2024-06-29T04:52:05","date_gmt":"2024-06-29T04:52:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=383368"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=383368","title":{"rendered":"<span>eBPF \u0432 \u0440\u0443\u043a\u0430\u0445 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0435\u0433\u043e: \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/53f\/1fa\/5da\/53f1fa5da75a54773f54525aa962576b.jpg\" alt=\"\" title=\"\" width=\"5304\" height=\"3200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53f\/1fa\/5da\/53f1fa5da75a54773f54525aa962576b.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439, \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043a\u0438\u0431\u0435\u0440\u0443\u0433\u0440\u043e\u0437 \u0432 R-Vision. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e\u0431 <a href=\"https:\/\/ebpf.io\/\">eBPF<\/a> (extended Berkeley Packet Filter) &#8212; \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 Linux. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u0438\u043b\u0430 eBPF \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 \u0431\u0435\u0437 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0431\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f eBPF \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0434\u043b\u044f Linux. \u041e\u0431\u043b\u0430\u0434\u0430\u044f \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432, \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0438 \u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e, \u043a\u0430\u043a \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c eBPF \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043a\u0430\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0434\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0432 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043b\u0438\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435.  <\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 eBPF \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u043e\u043c<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043c, \u0447\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u044b \u043d\u0435\u043b\u0438\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435 eBPF.  \u0421\u0440\u0430\u0437\u0443 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 eBPF \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u043f\u0440\u0430\u0432\u0430 <code>root<\/code> \u0438\u043b\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/capabilities.7.html\">\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 <\/a><code>CAP_BPF<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043d\u0435 \u043f\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0430\u0442\u0430\u043a\u0438.<br \/>\u041e\u0431\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 MITRE<em> <\/em>ATT&amp;CK, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f <a href=\"https:\/\/attack.mitre.org\/tactics\/TA0003\/\">\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/attack.mitre.org\/tactics\/TA0005\/\">\u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0433\u043e \u041f\u041e<\/a> \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0435 eBPF, \u043c\u043d\u043e\u044e \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c. <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/Gui774ume\/ebpfkit\">https:\/\/github.com\/Gui774ume\/ebpfkit<\/a><br \/><a href=\"https:\/\/github.com\/pathtofile\/bad-bpf\">https:\/\/github.com\/pathtofile\/bad-bpf<\/a><br \/><a href=\"https:\/\/github.com\/krisnova\/boopkit\">https:\/\/github.com\/krisnova\/boopkit<\/a><br \/><a href=\"https:\/\/github.com\/h3xduck\/TripleCross\">https:\/\/github.com\/h3xduck\/TripleCross<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0443 \u0441\u0435\u0431\u044f \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442<strong>:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438\u043b\u0438 \u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0431\u044d\u043a\u0434\u043e\u0440\u044b \u0434\u043b\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u0442\u0430\u043a\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c eBPF \u0438 \u043a\u0430\u043a\u043e\u0432\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a. <\/p>\n<h3>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0435BPF<\/h3>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 BPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <a href=\"https:\/\/github.com\/libbpf\/bpftool\/blob\/master\/README.md\">bpftool<\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">  bpftool prog list -p<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 <a href=\"https:\/\/github.com\/pathtofile\/bad-bpf\">bad bpf<\/a>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>id<\/code> \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0435\u0433\u043e \u0438\u043c\u044f, \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 id \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; <code>map_ids<\/code>:<\/p>\n<pre><code class=\"json\">[   ... {         \"id\": 168,         \"type\": \"tracepoint\",         \"name\": \"handle_execve_e\",         \"tag\": \"d4b5eec1dc561f40\",         \"gpl_compatible\": true,         \"loaded_at\": 1684082570,         \"uid\": 0,         \"bytes_xlated\": 1088,         \"jited\": true,         \"bytes_jited\": 625,         \"bytes_memlock\": 4096,         \"map_ids\": [44,43         ],         \"btf_id\": 154     },     ... ] <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a, \u043e\u043f\u0438\u0440\u0430\u0441\u044f\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0438\u0445, \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c eBPF. \u0422\u0430\u043a\u0436\u0435 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c eBPF \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u044b bpftool (hijacking). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 eBPF \u043f\u043e\u0441\u0442\u0444\u0430\u043a\u0442\u0443\u043c, \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c eBPF  \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>strace<\/code> \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0440\u0430\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<pre><code class=\"bash\">... bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_KPROBE, insn_cnt=6, insns=0x7ffd3ba9ec70, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, pro                                                                                           g_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=                                                                                           0, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 close(6)                                = 0 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_CGROUP_SOCK, insn_cnt=2, insns=0x7ffd3ba9ea10, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0                                                                                           , prog_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_SOCK_CREATE, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_                                                                                           info_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 close(6)                                = 0 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=136, insns=0x56534c1f6650, license=\"Dual BSD\/GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(5, 15, 0), p                                                                                           rog_flags=0, prog_name=\"handle_execve_e\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=3, func_info_rec_size=8, func_info=0x56534c1f5ba0, func_info_cnt=1, line_info_r                                                                                           ec_size=16, line_info=0x56534c1f5c30, line_info_cnt=69, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=32, max_entries=1, map_flags=0, inner_map_fd=0, map_name=\"\", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id                                                                                           =0, btf_vmlinux_value_type_id=0, map_extra=0}, 120) = 7 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffd3ba9e980, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags                                                                                           =0, prog_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_in                                                                                           fo_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 120) = 8 bpf(BPF_PROG_BIND_MAP, 0x7ffd3ba9e850, 120) = 0 close(7)                                = 0 close(8)                                = 0 bpf(BPF_PROG_BIND_MAP, 0x7ffd3ba9e9d0, 120) = 0 munmap(0x7fe2d0e23000, 5173248)         = 0 munmap(0x7fe2d0d84000, 561152)          = 0 mmap(0x7fe2d1aa6000, 4096, PROT_READ, MAP_SHARED|MAP_FIXED, 5, 0) = 0x7fe2d1aa6000 openat(AT_FDCWD, \"\/sys\/kernel\/debug\/tracing\/events\/syscalls\/sys_enter_execve\/id\", O_RDONLY) = 7 newfstatat(7, \"\", {st_mode=S_IFREG|0440, st_size=0, ...}, AT_EMPTY_PATH) = 0 read(7, \"716\\n\", 4096)                  = 4 read(7, \"\", 4096)                       = 0 close(7)                                = 0 perf_event_open({type=PERF_TYPE_TRACEPOINT, size=PERF_ATTR_SIZE_VER7, config=716, sample_period=0, sample_type=0, read_format=0, precise_ip=0 \/* arbitrary skid *\/, ...}, -1, 0, -1, PERF_FLAG_FD_C                                                                                           LOEXEC) = 7 ioctl(7, PERF_EVENT_IOC_SET_BPF, 6)     = 0 ioctl(7, PERF_EVENT_IOC_ENABLE, 0)      = 0 epoll_create1(EPOLL_CLOEXEC)            = 8 bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, info_len=80, info=0x7ffd3ba9ee60}}, 120) = 0 ...<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>perf_event_open()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/bpf.2.html\">\u0432\u044b\u0437\u043e\u0432\u0435 <\/a><code>bpf()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438:<\/p>\n<pre><code class=\"bash\">bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=136, insns=0x56534c1f6650, license=\"Dual BSD\/GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(5, 15, 0), p                                                                                           rog_flags=0, prog_name=\"handle_execve_e\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=3, func_info_rec_size=8, func_info=0x56534c1f5ba0, func_info_cnt=1, line_info_r                                                                                           ec_size=16, line_info=0x56534c1f5c30, line_info_cnt=69, attach_btf_id=0, attach_prog_fd=0}, 120) = 6<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p><strong>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b BPF.<\/strong>  \u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 bpf.h \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 <code>bpf_cmd<\/code>; <\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/strong> \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u044f\u0434\u0440\u043e;<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f <code>BPF_PROG_LOAD<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u044f\u0434\u0440\u043e. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435: <\/p>\n<ul>\n<li>\n<p><code>prog_type<\/code>&#8212; \u0442\u0438\u043f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0439 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0447\u0442\u043e \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430;<\/p>\n<\/li>\n<li>\n<p><code>insn_cnt<\/code>&#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 eBPF. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0442\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443 \u043d\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439; <\/p>\n<\/li>\n<li>\n<p><code>prog_name<\/code>&#8212;  \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b eBPF. \u041c\u043e\u0436\u043d\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u0441\u0432\u0435\u0440\u044f\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u043c\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p><code>expected_attach_type<\/code>&#8212; \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0434\u0440\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0430 eBPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<strong>.<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><code>BPF_MAP_CREATE<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 BPF map, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0421\u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0435 \u041f\u041e \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 map;<\/p>\n<\/li>\n<li>\n<p><code>BPF_PROG_GET_NEXT_ID<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 BPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0437\u0432\u0435\u0434\u043a\u0435 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 eBPF \u043c\u043e\u0434\u0443\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p><code>BPF_PROG_ATTACH<\/code> \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 BPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u044e \u044f\u0434\u0440\u0430 Linux, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044e \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u044b. \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u043e\u043c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u0443;<\/p>\n<\/li>\n<li>\n<p><code>BPF_PROG_DETACH<\/code> \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 BPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043e\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u044f\u0434\u0440\u0430. \u0417\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c BPF \u043c\u043e\u0434\u0443\u043b\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e\/\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u043c \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c;<\/p>\n<\/li>\n<li>\n<p><code>BPF_PROG_QUERY<\/code>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e BPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435. \u0422\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p><code>BPF_RAW_TRACEPOINT_OPEN<\/code> \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u044f\u0434\u0440\u0435 Linux. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0432 \u044f\u0434\u0440\u0435;<\/p>\n<\/li>\n<li>\n<p><code>BPF_BTF_LOAD<\/code>\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 BTF-\u0442\u0438\u043f\u044b \u0432 \u044f\u0434\u0440\u043e Linux. \u041c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/bpf.2.html\">auditd<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445. <\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 bpf()<\/h3>\n<h4>Auditd<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b <code>bpf()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f auditd, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e:<\/p>\n<pre><code>-a always,exit -F arch=b64 -S bpf -F key=bpf<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b <code>bpf()<\/code>. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0443\u044e \u043d\u0430\u043c \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <code>exechijack<\/code>, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432:<\/p>\n<pre><code class=\"bash\">type=BPF msg=audit(1684082570.912:2485): prog-id=168 op=LOAD type=SYSCALL msg=audit(1684082570.912:2485): arch=c000003e syscall=321 success=yes exit=6 a0=5 a1=7ffe4bfa6c00 a2=78 a3=0 items=0 ppid=11598 pid=11793 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid =0 tty=pts1 ses=191 comm=\"exechijack\" exe=\"\/home\/sea-admin\/bad-bpf\/src\/bin\/exechijack\" subj=unconfined key=\"bpf\"^]ARCH=x86_64 SYSCALL=bpf AUID=\"sea-admin\" UID=\"root\" GID=\"root\" EUID=\"root\" SUID=\"root\" FSUID=\"root\" EGID=\"root\" SGID=\"root\" FSGID=\"root\" type=PROCTITLE msg=audit(1684082570.912:2485): proctitle=2E2F6578656368696A61636B002D7400333332<\/code><\/pre>\n<p>\u0422\u0438\u043f <code>SYSCALL<\/code> \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <code>exe<\/code>. \u0415\u0449\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f <code>auid<\/code> \u0438 <code>tty<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 audit ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0435\u043d\u043d\u043e. \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>a0<\/code>,<code>a1<\/code>,<code>a2<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432\u044b\u0437\u043e\u0432\u0430 <code>bpf()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u043b\u0438 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 <code>strace<\/code>.<\/p>\n<p>\u0422\u0438\u043f <code>BPF<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0435\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c &#8212; <code>prog-id<\/code>.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>a0<\/code> \u0438 <code>a2<\/code> \u0431\u044b\u043b\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 <code>int<\/code> \u0438 <code>unsigned int<\/code>, \u0438 \u043e\u043d\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044b \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 <code>auditd<\/code>, \u0442\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>a1<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u043e\u043c <code>union<\/code>. \u0418 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 a0, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <code>enum bpf_cmd<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 bpf &#8212; <code>\/usr\/include\/linux\/bpf.h<\/code>. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>enum bpf_cmd { BPF_MAP_CREATE, BPF_MAP_LOOKUP_ELEM, BPF_MAP_UPDATE_ELEM, BPF_MAP_DELETE_ELEM, BPF_MAP_GET_NEXT_KEY, BPF_PROG_LOAD, BPF_OBJ_PIN, BPF_OBJ_GET, BPF_PROG_ATTACH, BPF_PROG_DETACH, BPF_PROG_TEST_RUN, BPF_PROG_RUN = BPF_PROG_TEST_RUN, BPF_PROG_GET_NEXT_ID, BPF_MAP_GET_NEXT_ID, BPF_PROG_GET_FD_BY_ID, BPF_MAP_GET_FD_BY_ID, BPF_OBJ_GET_INFO_BY_FD, BPF_PROG_QUERY, BPF_RAW_TRACEPOINT_OPEN, BPF_BTF_LOAD, BPF_BTF_GET_FD_BY_ID, BPF_TASK_FD_QUERY, BPF_MAP_LOOKUP_AND_DELETE_ELEM, BPF_MAP_FREEZE, BPF_BTF_GET_NEXT_ID, BPF_MAP_LOOKUP_BATCH, BPF_MAP_LOOKUP_AND_DELETE_BATCH, BPF_MAP_UPDATE_BATCH, BPF_MAP_DELETE_BATCH, BPF_LINK_CREATE, BPF_LINK_UPDATE, BPF_LINK_GET_FD_BY_ID, BPF_LINK_GET_NEXT_ID, BPF_ENABLE_STATS, BPF_ITER_CREATE, BPF_LINK_DETACH, BPF_PROG_BIND_MAP, };<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043d\u0435\u0442 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f eBPF, \u0442\u043e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0434\u043b\u044f \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0445 eBPF.  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 eBPF \u0441 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<br \/>\u041d\u043e \u0438\u043c\u0435\u044f root \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438, \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u043e\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0434\u043b\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. <\/p>\n<p>\u041d\u0430\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435\u0441\u044f \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0435 <code>a1<\/code>. \u0418 \u0434\u043b\u044f \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u044e eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041a\u0441\u0442\u0430\u0442\u0438, \u0440\u0430\u043d\u0435\u0435 \u0432 <a href=\"https:\/\/habr.com\/ru\/companies\/rvision\/articles\/721180\/\">\u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u044f \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u044f\u0434\u0440\u0430.  <\/p>\n<h4>eBPF \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f eBPF \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/github.com\/iovisor\/bcc\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 BCC<\/a>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f <code>BPF_PROG_LOAD.<\/code> \u0414\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0412\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 <code>bpf.h<\/code>.<\/p>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0421-\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439  &#171;\u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c&#187; \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 <code>bpf()<\/code>\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0438\u044f \u0442\u0438\u043f\u0430 <code>BPF_PROG_LOAD<\/code> \u0437\u0430\u0431\u0435\u0440\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0438\u0445 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e.<\/p>\n<pre><code class=\"cpp\">BPF_PERF_OUTPUT(args);  #include &lt;linux\/ptrace.h> #include &lt;linux\/bpf.h> \/\/ \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e struct args {     char task[TASK_COMM_LEN];     int com;     int ptype;     int icount;     char pname[32];     int atype;     unsigned int psize; }; \/\/ \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 bpf() int syscall__bpf(struct pt_regs *ctx, int cmd, union bpf_attr *attr, unsigned int size){     \/\/ \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u0430 BPF_PROG_LOAD     enum bpf_cmd condition;     condition=BPF_PROG_LOAD;     if (cmd == condition) {        struct args arg_data = {};        \/\/          bpf_get_current_comm(&amp;arg_data.task, sizeof(&amp;arg_data.task));         bpf_probe_read(&amp;arg_data.com, sizeof(arg_data.com), &amp;cmd);         bpf_probe_read(&amp;arg_data.ptype, sizeof(arg_data.ptype), &amp;attr->prog_type);        bpf_probe_read(&amp;arg_data.icount, sizeof(arg_data.icount), &amp;attr->insn_cnt);        bpf_probe_read(&amp;arg_data.pname, sizeof(arg_data.pname), &amp;attr->prog_name);        bpf_probe_read(&amp;arg_data.atype, sizeof(arg_data.atype), &amp;attr->expected_attach_type);         bpf_probe_read(&amp;arg_data.psize, sizeof(arg_data.psize), &amp;size);         args.perf_submit(ctx, &amp;arg_data, sizeof(arg_data));         return 0;        } } <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c python-\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c C \u043c\u043e\u0434\u0443\u043b\u044c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435, \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e:<\/p>\n<pre><code class=\"python\">from bcc import BPF  # \u0427\u0438\u0442\u0430\u0435\u043c ebpf \u043a\u043e\u0434 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430  with open(\"bpf.c\") as file:  bpf_txt = file.read() def handle_event(cpu, data, size):     output = bpf_ctx[\"args\"].event(data)     print(\"{:&lt;10} {:&lt;10} {:&lt;10} {:&lt;10} {:&lt;20} {:&lt;10} {:&lt;10}\".format(output.task.decode(\"utf-8\") ,          output.com, output.ptype, output.icount, output.pname.decode(\"utf-8\") , output.atype, output.psize))  bpf_ctx = BPF(text=bpf_txt) # \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u043d\u0430\u0448 ebpf \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 bpf syscall_fnname = bpf_ctx.get_syscall_fnname(\"bpf\") bpf_ctx.attach_kprobe(event=syscall_fnname, fn_name=\"syscall__bpf\")  bpf_ctx[\"args\"].open_perf_buffer(handle_event)  # \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c  print(\"{:&lt;10} {:&lt;10} {:&lt;10} {:&lt;10} {:&lt;20} {:&lt;10} {:&lt;10}\".format('exe_task',      'bpf_type', 'prog_type', 'insn_cnt','prog_name', 'attach_type', 'size')) while 1:     try:         bpf_ctx.perf_buffer_poll()     except KeyboardInterrupt:         print()         exit()   <\/code><\/pre>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f<strong> <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Python \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"bash\">python3 bpf-detect.py<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u043e\u0433\u043e \u0436\u0435 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f <code>exechijack<\/code>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"bash\">exe_task   bpf_type   prog_type  insn_cnt   prog_name            a_type     size exechij    5          1          2                               0          120 exechij    5          1          5                               0          120 exechij    5          1          2          test                 0          120 exechij    5          2          6                               0          120 exechij    5          9          2                               2          120 exechij    5          5          136        handle_execve_e      0          120 exechij    5          1          2                               0          120<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043d\u043e \u0438\u0445 <code>enum<\/code> \u0442\u043e\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 <code>bpf.h<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0445  eBPF \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0435\u043b\u044f.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u043d\u043e\u044e \u0431\u044b\u043b\u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 eBPF \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438. \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 eBPF \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u043e\u0441\u0442\u0444\u0430\u043a\u0442\u0443\u043c \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e eBPF \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0442\u0438\u043b\u0438\u0442.<\/p>\n<p>\u041f\u0440\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f eBPF \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Auditd, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 eBPF \u0434\u043b\u044f \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e eBPF \u043c\u043e\u0434\u0443\u043b\u044f. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0432\u0441\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a eBPF \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445, \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044e \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043d\u0435\u0442. \u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 &#8212; \u0430\u043d\u0430\u043b\u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u043e\u043c\u0430\u043b\u044c\u043d\u044b\u0435, \u043d\u0435\u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a \u0441\u0442\u0430\u0442\u044c\u0435! \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u0441 \u0440\u0430\u0434\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0432\u0435\u0447\u0443 \u043d\u0430 \u043d\u0438\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p><em>\u0410\u0432\u0442\u043e\u0440: \u0415\u043f\u0438\u0448\u0435\u0432 \u0410\u043b\u0435\u043a\u0441\u0435\u0439(<\/em><a href=\"https:\/\/habr.com\/ru\/users\/alexepishev\/\">@alexepishev<\/a><em>), \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a-\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u0438\u0431\u0435\u0440\u0443\u0433\u0440\u043e\u0437 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 R-Vision<\/em>  <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/733458\/\"> https:\/\/habr.com\/ru\/articles\/733458\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439, \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u043a\u0438\u0431\u0435\u0440\u0443\u0433\u0440\u043e\u0437 \u0432 R-Vision. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e\u0431 <a href=\"https:\/\/ebpf.io\/\">eBPF<\/a> (extended Berkeley Packet Filter) &#8212; \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 Linux. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u0438\u043b\u0430 eBPF \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 \u0431\u0435\u0437 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043d\u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0431\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f eBPF \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0434\u043b\u044f Linux. \u041e\u0431\u043b\u0430\u0434\u0430\u044f \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432, \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0438 \u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e, \u043a\u0430\u043a \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c eBPF \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043a\u0430\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u044f\u0434\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u0432 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043b\u0438\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435.  <\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 eBPF \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u043e\u043c<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043c, \u0447\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u044b \u043d\u0435\u043b\u0438\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0435 eBPF.  \u0421\u0440\u0430\u0437\u0443 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 eBPF \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u043f\u0440\u0430\u0432\u0430 <code>root<\/code> \u0438\u043b\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/capabilities.7.html\">\u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0438 <\/a><code>CAP_BPF<\/code>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043d\u0435 \u043f\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0430\u0442\u0430\u043a\u0438.<br \/>\u041e\u0431\u0440\u0430\u0442\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 MITRE<em> <\/em>ATT&amp;CK, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f <a href=\"https:\/\/attack.mitre.org\/tactics\/TA0003\/\">\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/attack.mitre.org\/tactics\/TA0005\/\">\u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u043e\u0433\u043e \u041f\u041e<\/a> \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0435 eBPF, \u043c\u043d\u043e\u044e \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c. <\/p>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/github.com\/Gui774ume\/ebpfkit\">https:\/\/github.com\/Gui774ume\/ebpfkit<\/a><br \/><a href=\"https:\/\/github.com\/pathtofile\/bad-bpf\">https:\/\/github.com\/pathtofile\/bad-bpf<\/a><br \/><a href=\"https:\/\/github.com\/krisnova\/boopkit\">https:\/\/github.com\/krisnova\/boopkit<\/a><br \/><a href=\"https:\/\/github.com\/h3xduck\/TripleCross\">https:\/\/github.com\/h3xduck\/TripleCross<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0443 \u0441\u0435\u0431\u044f \u0432 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442<strong>:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0438\u043b\u0438 \u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0431\u044d\u043a\u0434\u043e\u0440\u044b \u0434\u043b\u044f \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0430\u0442\u0430\u043a\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c eBPF \u0438 \u043a\u0430\u043a\u043e\u0432\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a. <\/p>\n<h3>\u041f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0435BPF<\/h3>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 BPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 <a href=\"https:\/\/github.com\/libbpf\/bpftool\/blob\/master\/README.md\">bpftool<\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"bash\">  bpftool prog list -p<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 <a href=\"https:\/\/github.com\/pathtofile\/bad-bpf\">bad bpf<\/a>, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>id<\/code> \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0435\u0433\u043e \u0438\u043c\u044f, \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 id \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; <code>map_ids<\/code>:<\/p>\n<pre><code class=\"json\">[   ... {         \"id\": 168,         \"type\": \"tracepoint\",         \"name\": \"handle_execve_e\",         \"tag\": \"d4b5eec1dc561f40\",         \"gpl_compatible\": true,         \"loaded_at\": 1684082570,         \"uid\": 0,         \"bytes_xlated\": 1088,         \"jited\": true,         \"bytes_jited\": 625,         \"bytes_memlock\": 4096,         \"map_ids\": [44,43         ],         \"btf_id\": 154     },     ... ] <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a, \u043e\u043f\u0438\u0440\u0430\u0441\u044f\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0438\u0445, \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c eBPF. \u0422\u0430\u043a\u0436\u0435 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c eBPF \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u044b bpftool (hijacking). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 eBPF \u043f\u043e\u0441\u0442\u0444\u0430\u043a\u0442\u0443\u043c, \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c eBPF  \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>strace<\/code> \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0440\u0430\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<pre><code class=\"bash\">... bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_KPROBE, insn_cnt=6, insns=0x7ffd3ba9ec70, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, pro                                                                                           g_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=                                                                                           0, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 close(6)                                = 0 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_CGROUP_SOCK, insn_cnt=2, insns=0x7ffd3ba9ea10, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0                                                                                           , prog_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_SOCK_CREATE, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_                                                                                           info_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 close(6)                                = 0 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=136, insns=0x56534c1f6650, license=\"Dual BSD\/GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(5, 15, 0), p                                                                                           rog_flags=0, prog_name=\"handle_execve_e\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=3, func_info_rec_size=8, func_info=0x56534c1f5ba0, func_info_cnt=1, line_info_r                                                                                           ec_size=16, line_info=0x56534c1f5c30, line_info_cnt=69, attach_btf_id=0, attach_prog_fd=0}, 120) = 6 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=32, max_entries=1, map_flags=0, inner_map_fd=0, map_name=\"\", map_ifindex=0, btf_fd=0, btf_key_type_id=0, btf_value_type_id                                                                                           =0, btf_vmlinux_value_type_id=0, map_extra=0}, 120) = 7 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffd3ba9e980, license=\"GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags                                                                                           =0, prog_name=\"\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0, func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_in                                                                                           fo_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 120) = 8 bpf(BPF_PROG_BIND_MAP, 0x7ffd3ba9e850, 120) = 0 close(7)                                = 0 close(8)                                = 0 bpf(BPF_PROG_BIND_MAP, 0x7ffd3ba9e9d0, 120) = 0 munmap(0x7fe2d0e23000, 5173248)         = 0 munmap(0x7fe2d0d84000, 561152)          = 0 mmap(0x7fe2d1aa6000, 4096, PROT_READ, MAP_SHARED|MAP_FIXED, 5, 0) = 0x7fe2d1aa6000 openat(AT_FDCWD, \"\/sys\/kernel\/debug\/tracing\/events\/syscalls\/sys_enter_execve\/id\", O_RDONLY) = 7 newfstatat(7, \"\", {st_mode=S_IFREG|0440, st_size=0, ...}, AT_EMPTY_PATH) = 0 read(7, \"716\\n\", 4096)                  = 4 read(7, \"\", 4096)                       = 0 close(7)                                = 0 perf_event_open({type=PERF_TYPE_TRACEPOINT, size=PERF_ATTR_SIZE_VER7, config=716, sample_period=0, sample_type=0, read_format=0, precise_ip=0 \/* arbitrary skid *\/, ...}, -1, 0, -1, PERF_FLAG_FD_C                                                                                           LOEXEC) = 7 ioctl(7, PERF_EVENT_IOC_SET_BPF, 6)     = 0 ioctl(7, PERF_EVENT_IOC_ENABLE, 0)      = 0 epoll_create1(EPOLL_CLOEXEC)            = 8 bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=4, info_len=80, info=0x7ffd3ba9ee60}}, 120) = 0 ...<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>perf_event_open()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/bpf.2.html\">\u0432\u044b\u0437\u043e\u0432\u0435 <\/a><code>bpf()<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u043c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438:<\/p>\n<pre><code class=\"bash\">bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=136, insns=0x56534c1f6650, license=\"Dual BSD\/GPL\", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(5, 15, 0), p                                                                                           rog_flags=0, prog_name=\"handle_execve_e\", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=3, func_info_rec_size=8, func_info=0x56534c1f5ba0, func_info_cnt=1, line_info_r                                                                                           ec_size=16, line_info=0x56534c1f5c30, line_info_cnt=69, attach_btf_id=0, attach_prog_fd=0}, 120) = 6<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<ol>\n<li>\n<p><strong>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b BPF.<\/strong>  \u0412\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 bpf.h \u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 <code>bpf_cmd<\/code>; <\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/strong> \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u044f\u0434\u0440\u043e;<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 BPF-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f <code>BPF_PROG_LOAD<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u044f\u0434\u0440\u043e. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435: <\/p>\n<ul>\n<li>\n<p><code>prog_type<\/code>&#8212; \u0442\u0438\u043f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0439 eBPF \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u0447\u0442\u043e \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430;<\/p>\n<\/li>\n<li>\n<p><code>insn_cnt<\/code>&#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 eBPF. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0442\u0435\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443 \u043d\u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439; <\/p>\n<\/li>\n<li>\n<p><code>prog_name<\/code>&#8212;  \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b eBPF. \u041c\u043e\u0436\u043d\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u0441\u0432\u0435\u0440\u044f\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0441 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u043c\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p><code>expected_attach_type<\/code>&#8212; \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0434\u0440\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0430 eBPF-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<strong>.<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p><code>BPF_MAP_CREATE<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 BPF map, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-383368","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383368"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383368\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}