{"id":316643,"date":"2021-01-20T09:00:46","date_gmt":"2021-01-20T09:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316643"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316643","title":{"rendered":"\u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 Linux"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/crosstech\/blog\/531738\/\">\u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438 \u043f\u0440\u043e Linux Kernel Module (LKM) \u0438 \u043e\u0431\u0435\u0449\u0430\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u043f\u0443\u0442\u0438 \u043a \u043d\u0435\u043c\u0443 \u0438 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438. \u041d\u0443 \u0447\u0442\u043e \u0436, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0435\u0433\u043e \u0432\u0440\u0435\u043c\u044f. LKM \u2013 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0435\u0431\u044f.<\/p>\n<h3>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p>&#171;Windows \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u043d\u0430 Linux Kernel Module LKM\u2026&#187; \u0438\u0442\u0430\u043a, \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043d\u0430\u0447\u0430\u043b\u0443 \u043f\u0443\u0442\u0438. \u041c\u044b \u0438\u043c\u0435\u0435\u043c Windows \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443. \u041a\u0430\u043a \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0438\u043b\u0438 \u0447\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445?  \u041f\u043e\u043a\u043e\u043f\u0430\u0432\u0448\u0438\u0441\u044c \u0432 <a href=\"https:\/\/www.ibm.com\/developerworks\/ru\/library\/l-linux-filesystem\/index.html\">\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435<\/a>, \u043f\u043e\u0447\u0438\u0442\u0430\u0432 \u043f\u0440\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/15739320\/hook-functions-for-linux-filesystem\">\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442<\/a> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0432 <a href=\"https:\/\/stackoverflow.com\/questions\/51877771\/make-a-minifilter-like-driver-for-linux\">Linux<\/a> \u2013 \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043a\u0443\u0447\u0443 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439.<\/p>\n<p>Inotify<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1d5\/cfd\/db7\/1d5cfddb798d973e0a3e8f6489bf2b32.jpg\" width=\"336\" height=\"252\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u043a\u0438\u043d\u0443\u0432 \u0443\u0434\u043e\u0447\u043a\u0438 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0444\u043e\u0440\u0443\u043c\u043e\u0432, \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u00ab\u043a\u043e\u043f\u0430\u0442\u044c\u00bb \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/inotify.7.html\">Inotify<\/a>. Inotify \u2013 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438. \u041d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u00ab\u0431\u0440\u0430\u0442\u00bb \u2013 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/fanotify.7.html\">fanotify<\/a>. \u0412 \u043d\u0451\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/gist.github.com\/jaypeche\/497ac0c3ce36cdb7f5b9\">\u0444\u0430\u0439\u043b\u0430<\/a>. \u041d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, fanotify \u043d\u0430\u043c \u0432 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0425\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e fanotify \u2013 \u044d\u0442\u043e userspace \u0443\u0442\u0438\u043b\u0438\u0442\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e\u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e. <\/p>\n<p>Virtual File System<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad3\/da2\/b9a\/ad3da2b9a4c1fa8327cebeccc9127dc4.png\" width=\"785\" height=\"558\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/issue.life\/questions\/43242939\">VFS<\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 <a href=\"http:\/\/www.linuxrsp.ru\/artic\/linux_kernel_module_guide_development.html\">VFS<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"http:\/\/www.brendangregg.com\/dtrace.html\">Dtrace<\/a>, <a href=\"http:\/\/www.brendangregg.com\/bpf-performance-tools-book.html\">eBPF<\/a> \u0438 <a href=\"https:\/\/github.com\/iovisor\/bcc\">bcc<\/a>, \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/www.opennet.ru\/base\/dev\/intercept_lnx.txt.html\">LKM<\/a>. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>     \u2022   \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443;<\/p>\n<p>     \u2022   \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443 \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0438\u0437 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445;<\/p>\n<p>     \u2022   \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>Janus, SElinux \u0438 AppArmor<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2dd\/182\/f6d\/2dd182f6db4a77cc303411c51ea6bd96.png\" width=\"1855\" height=\"1056\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0431\u044b\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 <a href=\"https:\/\/cyberleninka.ru\/article\/n\/rasshirenie-funktsionalnosti-sistemy-bezopasnosti-yadra-linux-na-osnove-podmeny-sistemnyh-vyzovov\/viewer\">Linux<\/a>. \u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0421\u0430\u043c\u044b\u043c \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/kenprice\/janus\">Janus<\/a>. \u041c\u0438\u043d\u0443\u0441\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0432\u0435\u0436\u0438\u0445 \u044f\u0434\u0435\u0440 \u0438 \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b LKM \u0445\u0443\u043a\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <a href=\"https:\/\/github.com\/SELinuxProject\/selinux\">SELinux<\/a> \u0438 <a href=\"https:\/\/gitlab.com\/apparmor\/apparmor\">AppArmor<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0432\u0438\u043d\u0442\u044d\u0441\u0441\u0435\u043d\u0446\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435. \u041c\u043e\u0434\u0443\u043b\u044c SELinux \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/p>\n<p>     \u2022   \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<br \/>     \u2022   \u043a\u044d\u0448 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0430\u043d\u0433\u043b. Access Vector Cache, AVC);<br \/>     \u2022   \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432;<br \/>     \u2022   \u043a\u043e\u0434 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f;<br \/>     \u2022   \u0441\u0432\u043e\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (selinuxfs) \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u0432. <\/p>\n<h3>\u0414\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u00ab\u043d\u043e\u00bb, \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u0451\u043b \u0425\u0430\u0431\u0440!  \u041d\u0430\u0442\u043a\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/413241\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>, \u0441\u0442\u0430\u043b\u043e \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a61\/1d6\/1b2\/a611d61b2f81fe1c13dbeb3c598d56f2.jpg\" width=\"1024\" height=\"768\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e <a href=\"https:\/\/habr.com\/ru\/company\/selectel\/blog\/280322\/\">ftrace<\/a>  \u0438 <a href=\"https:\/\/github.com\/ilammy\/ftrace-hook\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a> \u0438\u0437 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 LKM \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 ftrace. \u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b debugfs, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 Linux \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. Hook&#8217;\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f clone \u0438 open:<\/p>\n<p>     \u2022   openat,<br \/>     \u2022   rename,<br \/>     \u2022   unlink,<br \/>     \u2022   unlinkat. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430. <\/p>\n<p>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/2e6\/eb7\/2ac2e6eb79146cf2392c47a29c3a4166.png\" width=\"741\" height=\"648\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u044f\u0434\u0440\u0430 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c userspace. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442 \u0434\u0432\u0430:<\/p>\n<p>     \u2022   socket \u043c\u0435\u0436\u0434\u0443 kernel \u0438 userspace;<br \/>     \u2022   \u0437\u0430\u043f\u0438\u0441\u044c\/\u0447\u0442\u0435\u043d\u0438\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b. <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/netlink.7.html\">netlink<\/a> socket, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 Windows \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 &#8212; <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/fltkernel\/nf-fltkernel-fltsendmessage\">FltSendMessage<\/a>. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/stackoverflow.com\/questions\/8252630\/linux-kernel-socket-programmingsendmsg-function-msg-address-can-not-access%0A\">inet<\/a> socket, \u043d\u043e \u044d\u0442\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.  \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e \u043d\u0430 .Net Core, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e userspace \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, <a href=\"https:\/\/github.com\/dotnet\/runtime\/issues\/28157%0A\">\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442<\/a> <a href=\"https:\/\/stackoverflow.com\/questions\/53666063\/using-netlink-connector-in-dotnet-c%0A\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a> netlink.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 <a href=\"https:\/\/habr.com\/ru\/post\/121254\/%0A\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/a> <a href=\"https:\/\/stackoverflow.com\/questions\/31653257\/how-to-send-and-receive-messages-from-function-other-than-registered-callback-fu\">netlink<\/a> \u0438 \u0443\u0436\u0435 \u0435\u0451 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. <\/p>\n<pre><code class=\"cpp\"> int open_netlink_connection(void) {     \/\/initialize our variables     int sock;     struct sockaddr_nl addr;     int group = NETLINK_GROUP;      \/\/open a new socket connection     sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_USERSOCK);      \/\/if the socket failed to open,     if (sock &lt; 0)      {         \/\/inform the user         printf(\"Socket failed to initialize.\\n\");         \/\/return the error value         return sock;     }      \/\/initialize our addr structure by filling it with zeros     memset((void *) &amp;addr, 0, sizeof(addr));     \/\/specify the protocol family     addr.nl_family = AF_NETLINK;     \/\/set the process id to the current process id     addr.nl_pid = getpid();      \/\/bind the address to the socket created, and if it failed,     if (bind(sock, (struct sockaddr *) &amp;addr, sizeof(addr)) &lt; 0)      {         \/\/inform the user         printf(\"bind &lt; 0.\\n\");         \/\/return the function with a symbolic error code         return -1;     }      \/\/set the option so that we can receive packets whose destination     \/\/is the group address specified (so that we can receive the message broadcasted by the kernel)     if (setsockopt(sock, 270, NETLINK_ADD_MEMBERSHIP, &amp;group, sizeof(group)) &lt; 0)      {         \/\/if it failed, inform the user         printf(\"setsockopt &lt; 0\\n\");         \/\/return the function with a symbolic error code         return -1;     }      \/\/if we got thus far, then everything     \/\/went fine. Return our socket.     return sock; }  char* read_kernel_message(int sock) {     \/\/initialize the variables     \/\/that we are going to need     struct sockaddr_nl nladdr;     struct msghdr msg;     struct iovec iov;     char* buffer[CHUNK_SIZE];     char* kernelMessage;     int ret;      memset(&amp;msg, 0, CMSG_SPACE(MAX_PAYLOAD));     memset(&amp;nladdr, 0, sizeof(nladdr));     memset(&amp;iov, 0, sizeof(iov));     \/\/specify the buffer to save the message     iov.iov_base = (void *) &amp;buffer;     \/\/specify the length of our buffer     iov.iov_len = sizeof(buffer);      \/\/pass the pointer of our sockaddr structure     \/\/that will save the source IP and port of the connection     msg.msg_name = (void *) &amp;(dest_addr);     \/\/give the size of our structure     msg.msg_namelen = sizeof(dest_addr);     \/\/pass our scatter\/gather I\/O structure pointer     msg.msg_iov = &amp;iov;     \/\/we will pass only one buffer array,     \/\/therefore we will specify that here     msg.msg_iovlen = 1;      \/\/listen\/wait for new data     ret = recvmsg(sock, &amp;msg, 0);      \/\/if message was received successfully,     if(ret &gt;= 0)     {         \/\/get the string data and save them to a local variable         char* buf = NLMSG_DATA((struct nlmsghdr *) &amp;buffer);          \/\/allocate memory for our kernel message         kernelMessage = (char*)malloc(CHUNK_SIZE);          \/\/copy the kernel data to our allocated space         strcpy(kernelMessage, buf);          \/\/return the pointer that points to the kernel data         return kernelMessage;     }          \/\/if we got that far, reading the message failed,     \/\/so we inform the user and return a NULL pointer     printf(\"Message could not received.\\n\");     return NULL; }  int send_kernel_message(int sock, char* kernelMessage) {     \/\/initialize the variables     \/\/that we are going to need     struct msghdr msg;     struct iovec iov;     char* buffer[CHUNK_SIZE];         int ret;      memset(&amp;msg, 0, CMSG_SPACE(MAX_PAYLOAD));     memset(&amp;iov, 0, sizeof(iov));      nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));     memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));     nlh-&gt;nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);     nlh-&gt;nlmsg_pid = getpid();     nlh-&gt;nlmsg_flags = 0;      char buff[160];     snprintf(buff, sizeof(buff), \"From:DSSAgent;Action:return;Message:%s;\", kernelMessage);     strcpy(NLMSG_DATA(nlh), buff);      iov.iov_base = (void *)nlh;     iov.iov_len = nlh-&gt;nlmsg_len;     \/\/pass the pointer of our sockaddr structure     \/\/that will save the source IP and port of the connection     msg.msg_name = (void *) &amp;(dest_addr);     \/\/give the size of our structure     msg.msg_namelen = sizeof(dest_addr);     msg.msg_iov = &amp;iov;     msg.msg_iovlen = 1;     printf(\"Sending message to kernel (%s)\\n\",(char *)NLMSG_DATA(nlh));     ret = sendmsg(sock, &amp;msg, 0);     return ret; }  int sock_netlink_connection() { \tsock_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_USER);     if (sock_fd &lt; 0)         return -1;       memset(&amp;src_addr, 0, sizeof(src_addr));     src_addr.nl_family = AF_NETLINK;     src_addr.nl_pid = getpid(); \/* self pid *\/       bind(sock_fd, (struct sockaddr *)&amp;src_addr, sizeof(src_addr));       memset(&amp;dest_addr, 0, sizeof(dest_addr));     dest_addr.nl_family = AF_NETLINK;     dest_addr.nl_pid = 0; \/* For Linux Kernel *\/     dest_addr.nl_groups = 0; \/* unicast *\/       nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));     memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));     nlh-&gt;nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);     nlh-&gt;nlmsg_pid = getpid();     nlh-&gt;nlmsg_flags = 0;       strcpy(NLMSG_DATA(nlh), \"From:DSSAgent;Action:hello;\");       iov.iov_base = (void *)nlh;     iov.iov_len = nlh-&gt;nlmsg_len;     msg.msg_name = (void *)&amp;dest_addr;     msg.msg_namelen = sizeof(dest_addr);     msg.msg_iov = &amp;iov;     msg.msg_iovlen = 1;       printf(\"Sending message to kernel\\n\");     sendmsg(sock_fd, &amp;msg, 0);     printf(\"Waiting for message from kernel\\n\");       \/* Read message from kernel *\/     recvmsg(sock_fd, &amp;msg, 0);     printf(\"Received message payload: %s\\n\", (char *)NLMSG_DATA(nlh)); \t \treturn sock_fd; } void sock_netlink_disconnection(int sock) { \tclose(sock);     free(nlh); }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 Net.Core \u2013 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0438\u0441\u043a \u043f\u043e pid \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u044d\u0442\u043e\u0442 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/api\/system.diagnostics.process.getprocessbyid?view=net-5.0\">\u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/a>. <a href=\"https:\/\/coderoad.ru\/5327707\/%D0%9A%D0%B0%D0%BA-%D1%8F-%D0%BC%D0%BE%D0%B3%D1%83-%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B8%D1%82%D1%8C-%D0%B8%D0%BC%D1%8F-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F-%D0%B8%D0%B7-%D0%B8%D0%B4%D0%B5%D0%BD%D1%82%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%82%D0%BE%D1%80%D0%B0-%D0%BF%D1%80%D0%BE%D1%86%D0%B5%D1%81%D1%81%D0%B0-%D0%B2-python-%D0%BD%D0%B0\">\u041f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <\/a><a href=\"https:\/\/stackoverflow.com\/questions\/6457682\/how-to-programatically-get-uid-from-pid-in-osx-using-c\">\u0434\u0430\u043d\u043d\u043e\u0439 <\/a><a href=\"https:\/\/man7.org\/tlpi\/code\/online\/dist\/sysinfo\/procfs_user_exe.c.html\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <\/a><a href=\"https:\/\/superuser.com\/questions\/479746\/how-to-find-pids-user-name-in-linux\/479748\">\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c <\/a><a href=\"https:\/\/coderoad.ru\/6457682\/%D0%9A%D0%B0%D0%BA-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE-%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B8%D1%82%D1%8C-uid-%D0%B8%D0%B7-pid-%D0%B2-osx-%D1%81-%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E-c\">\u043c\u0430\u0441\u0441\u0430<\/a>, \u043d\u043e, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f uid \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0438\u043c\u044f. <\/p>\n<pre><code>char* get_username_by_pid(int pid) {    register struct passwd *pw;   register uid_t uid;   int c;   FILE *fp;   char filename[255];   sprintf(filename, \"\/proc\/%d\/loginuid\", pid);   char cc[8];      \/\/ \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430   if((fp= fopen(filename, \"r\"))==NULL)     {         perror(\"Error occured while opening file\");         return \"\";     }   \/\/ \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0439\u0434\u0435\u043c \u0434\u043e \u043a\u043e\u043d\u0446\u0430   while((fgets(cc, 8, fp))!=NULL) {}         fclose(fp);      uid = atoi(cc);    pw = getpwuid (uid);   if (pw)   {       return pw-&gt;pw_name;   }   else   {       return \"\";   } }<\/code><\/pre>\n<p>\u0414\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f<\/p>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e netlink \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e LKM. <\/p>\n<pre><code class=\"cpp\">static int fh_init(void) {     int err; \tstruct netlink_kernel_cfg cfg = \t{ #if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(3, 6, 0) \t\t.groups = 1, #endif \t\t.input = nl_recv_msg, \t};  #if LINUX_VERSION_CODE &gt; KERNEL_VERSION(2, 6, 36) \tnl_sk = netlink_kernel_create(&amp;init_net, NETLINK_USER, &amp;cfg); #elif LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2, 6, 32) \tnl_sk = netlink_kernel_create(&amp;init_net, NETLINK_USER, 0, nl_recv_msg, NULL, THIS_MODULE); #else \tnl_sk = netlink_kernel_create(NETLINK_USER, 0, nl_recv_msg, THIS_MODULE); #endif  \tif (!nl_sk) \t{ \t\tprintk(KERN_ERR \"%s Could not create netlink socket\\n\", __func__); \t\treturn 1; \t}  \terr = fh_install_hooks(hooks, ARRAY_SIZE(hooks)); \tif (err) \t\treturn err;  \tp_list_hook_files = (tNode *)kmalloc(sizeof(tNode), GFP_KERNEL); \tp_list_hook_files-&gt;next = NULL; \tp_list_hook_files-&gt;value = 0;  \tpr_info(\"module loaded\\n\");  \treturn 0; } module_init(fh_init);  static void fh_exit(void) { \tdelete_list(p_list_hook_files); \tfh_remove_hooks(hooks, ARRAY_SIZE(hooks)); \tnetlink_kernel_release(nl_sk); \tpr_info(\"module unloaded\\n\"); } module_exit(fh_exit);<\/code><\/pre>\n<p>Socket \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443. \u041c\u043e\u0434\u0443\u043b\u044c, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430, pid \u0438 \u0438\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. Userspace \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0451 \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0444\u0430\u0439\u043b\u043e\u043c (\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f). \u0412\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432.<\/p>\n<pre><code class=\"cpp\">static void send_msg_to_user(const char *msgText) { \tint msgLen = strlen(msgText);  \tstruct sk_buff *skb = nlmsg_new(NLMSG_ALIGN(msgLen), GFP_KERNEL);  \tif (!skb) \t{ \t\tprintk(KERN_ERR \"%s Allocation skb failure.\\n\", __func__); \t\treturn; \t}  \tstruct nlmsghdr *nlh = nlmsg_put(skb, 0, 1, NLMSG_DONE, msgLen, 0);  \tif (!nlh) \t{ \t\tprintk(KERN_ERR \"%s Create nlh failure.\\n\", __func__); \t\tnlmsg_free(skb); \t\treturn; \t}  \tNETLINK_CB(skb).dst_group = 0; \tstrncpy(nlmsg_data(nlh), msgText, msgLen);  \tint errorVal = nlmsg_unicast(nl_sk, skb, pid);  \tif (errorVal &lt; 0) \t\tprintk(KERN_ERR \"%s nlmsg_unicast() error: %d\\n\", __func__, errorVal); }  static void return_msg_to_user(struct nlmsghdr *nlh) { \tpid = nlh-&gt;nlmsg_pid;  \tconst char *msg = \"Init socket from kernel\"; \tconst int msg_size = strlen(msg);  \tstruct sk_buff *skb = nlmsg_new(msg_size, 0); \tif (!skb) \t{ \t\tprintk(KERN_ERR \"%s Failed to allocate new skb\\n\", __func__); \t\treturn; \t}  \tnlh = nlmsg_put(skb, 0, 0, NLMSG_DONE, msg_size, 0); \tNETLINK_CB(skb).dst_group = 0; \tstrncpy(nlmsg_data(nlh), msg, msg_size);  \tint res = nlmsg_unicast(nl_sk, skb, pid); \tif (res &lt; 0) \t\tprintk(KERN_ERR \"%s Error while sending back to user (%i)\\n\", __func__, res); }<\/code><\/pre>\n<p>\u041f\u043e\u0437\u0434\u043d\u0435\u0435, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443 (\u043f\u043e \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438) \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u0440\u043e\u043c\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e (\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e pid \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430).<\/p>\n<pre><code class=\"cpp\">static void parse_return_from_user(char *return_msg) { \tchar *msg = np_extract_value(return_msg, \"Message\", ';'); \tconst char *file_name = strsep(&amp;msg, \"|\");  \tprintk(KERN_INFO \"%s Name:(%s) Permiss:(%s)\\n\", __func__, file_name, msg);  \tif (strstr(msg, \"Deny\")) \t\treload_name_list(p_list_hook_files, file_name, Deny); \telse \t\treload_name_list(p_list_hook_files, file_name, Allow); }  static void free_guards(void) { \t\/\/ Possibly unpredictable behavior during cleaning \tmemset(&amp;guards, 0, sizeof(struct process_guards)); }  static void change_guards(char *msg) { \tchar *path = np_extract_value(msg, \"Path\", ';'); \tchar *count_str = np_extract_value(msg, \"Count\", ';');  \tif (path &amp;&amp; strlen(path) &amp;&amp; count_str &amp;&amp; strlen(count_str)) \t{ \t\tint i, found = -1;  \t\tfor (i = 0; i &lt; guards.count; ++i) \t\t\tif (guards.process[i].file_path &amp;&amp; !strcmp(path, guards.process[i].file_path)) \t\t\t\tfound = i;  \t\tguards.is_busy = 1;  \t\tint count; \t\tkstrtoint(count_str, 10, &amp;count);  \t\tif (count &gt; 0) \t\t{ \t\t\tif (found == -1) \t\t\t{ \t\t\t\tstrcpy(guards.process[guards.count].file_path, path); \t\t\t\tfound = guards.count; \t\t\t\tguards.count++; \t\t\t}  \t\t\tfor (i = 0; i &lt; count; ++i) \t\t\t{ \t\t\t\tchar buff[8]; \t\t\t\tsnprintf(buff, sizeof(buff), \"Pid%d\", i + 1); \t\t\t\tchar *pid = np_extract_value(msg, buff, ';'); \t\t\t\tif (pid &amp;&amp; strlen(pid)) \t\t\t\t\tkstrtoint(pid, 10, &amp;guards.process[found].allow_pids[i]); \t\t\t\telse \t\t\t\t\tguards.process[found].allow_pids[i] = 0; \t\t\t}  \t\t\tguards.process[found].allow_pids[count] = 0; \t\t} \t\telse \t\t{ \t\t\tif (found &gt;= 0) \t\t\t{ \t\t\t\tfor (i = found; i &lt; guards.count - 1; ++i) \t\t\t\t\tguards.process[i] = guards.process[i + 1];  \t\t\t\tguards.count--; \t\t\t} \t\t}  \t\tguards.is_busy = 0; \t} }  \/\/ Example message is \"From:CryptoCli;Action:clear;\" or \"From:DSSAgent;Action:init;\" static void nl_recv_msg(struct sk_buff *skb) { \tprintk(KERN_INFO \"%s &lt;--\\n\", __func__);  \tstruct nlmsghdr *nlh = (struct nlmsghdr *)skb-&gt;data;  \tprintk(KERN_INFO \"%s Netlink received msg payload:%s\\n\", __func__, (char *)nlmsg_data(nlh));  \tchar *msg = (char *)nlmsg_data(nlh);  \tif (msg &amp;&amp; strlen(msg)) \t{ \t\tchar *from = np_extract_value(msg, \"From\", ';'); \t\tchar *action = np_extract_value(msg, \"Action\", ';');  \t\tif (from &amp;&amp; strlen(from) &amp;&amp; action &amp;&amp; strlen(action)) \t\t{ \t\t\t \t\t\tif (!strcmp(from, \"DSSAgent\")) \t\t\t{ \t\t\t\tif (!strcmp(action, \"init\")) \t\t\t\t{ \t\t\t\t\treturn_msg_to_user(nlh); \t\t\t\t} \t\t\t\telse if (!strcmp(action, \"return\")) \t\t\t\t{ \t\t\t\t\tparse_return_from_user(msg); \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\tprintk(KERN_ERR \"%s Failed msg, \\\"From\\\" is %s and \\\"Action\\\" is %s\\n\", __func__, from, action); \t\t\t\t} \t\t\t} \t\t\telse if (!strcmp(from, \"CryptoCli\")) \t\t\t{ \t\t\t\tif (!strcmp(action, \"clear\")) \t\t\t\t{ \t\t\t\t\tfree_guards(); \t\t\t\t} \t\t\t\telse if (!strcmp(action, \"change\")) \t\t\t\t{ \t\t\t\t\tchange_guards(msg); \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\tprintk(KERN_ERR \"%s Failed msg, \\\"From\\\" is %s and \\\"Action\\\" is %s\\n\", __func__, from, action); \t\t\t\t} \t\t\t} \t\t\telse \t\t\t{ \t\t\t\tprintk(KERN_ERR \"%s Failed msg, \\\"From\\\" is %s and \\\"Action\\\" is %s\\n\", __func__, from, action); \t\t\t}  \t\t} \t\telse \t\t{ \t\t\tprintk(KERN_ERR \"%s Failed parse msg, don`t found \\\"From\\\" and \\\"Action\\\" (%s)\\n\", __func__, msg); \t\t} \t} \telse \t{ \t\tprintk(KERN_ERR \"%s Failed parse struct nlmsg_data, msg is empty\\n\", __func__); \t}  \tprintk(KERN_INFO \"%s --&gt;\\n\", __func__); }  static bool check_file_access(char *fname, int processPid) { \tif (fname &amp;&amp; strlen(fname)) \t{ \t\tint i;  \t\tfor (i = 0; i &lt; guards.count; ++i) \t\t{ \t\t\tif (!strcmp(fname, guards.process[i].file_path) &amp;&amp; guards.process[i].allow_pids[0] != 0) \t\t\t{ \t\t\t\tint j; \t\t\t\t \t\t\t\tfor (j = 0; guards.process[i].allow_pids[j] != 0; ++j) \t\t\t\t\tif (processPid == guards.process[i].allow_pids[j]) \t\t\t\t\t\treturn true;  \t\t\t\treturn false; \t\t\t} \t\t} \t\t \t\t\/\/ Not found filename in guards \t\tif (strstr(fname, filetype)) \t\t{ \t\t\tchar *processName = current-&gt;comm;  \t\t\tprintk(KERN_INFO \"%s service pid = %d\\n\", __func__, pid); \t\t\tprintk(KERN_INFO \"%s file name = %s, process pid: %d, , process name = %s\\n\", __func__, fname, processPid, processName);  \t\t\tif (processPid == pid) \t\t\t{ \t\t\t\treturn true; \t\t\t} \t\t\telse \t\t\t{ \t\t\t\tadd_list(p_list_hook_files, processPid, fname, None);  \t\t\t\tchar *buffer = kmalloc(4096, GFP_KERNEL); \t\t\t\tsprintf(buffer, \"%s|%s|%d\", fname, processName, processPid); \t\t\t\tsend_msg_to_user(buffer); \t\t\t\tkfree(buffer);  \t\t\t\tssleep(5);  \t\t\t\tbool ret = true;  \t\t\t\tif (find_list(p_list_hook_files, fname) == Deny) \t\t\t\t\tret = false;  \t\t\t\tdelete_node(p_list_hook_files, fname);  \t\t\t\treturn ret; \t\t\t} \t\t} \t}  \treturn true; }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u043c\u0438\u043d\u0443\u0441\u0430 LKM \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e ftrace, \u0442\u0440\u0435\u0442\u0438\u0439 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u043b. \u041c\u0430\u043b\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u043e\u0435 \u044f\u0434\u0440\u043e \u043d\u0443\u0436\u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f, \u0443\u0436\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u00ab\u043f\u0440\u043e\u0442\u0443\u0445\u043d\u0443\u0442\u044c\u00bb. \u0411\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c userspace \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  \u0412 <a href=\"https:\/\/habr.com\/ru\/company\/crosstech\/blog\/531738\/\">\u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 Linux \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e \u00ab\u0441\u043b\u0443\u0436\u0431\u0443\u00bb, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443, \u043c\u044b \u00ab\u0434\u0435\u043c\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u00bb \u043f\u0443\u0442\u0451\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 system. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0430.service \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0443\u043d\u043a\u0442\u0430, \u043f\u043e\u043c\u0438\u043c\u043e ExecStart \u0438 ExecStop \u0431\u0443\u0434\u0443\u0442:<\/p>\n<pre><code class=\"bash\">ExecStartPre=\/bin\/sh \/\u043f\u0443\u0442\u044c_\u0434\u043e_\u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f\/prestart.sh ExecStopPost=\/sbin\/rmmod \u0438\u043c\u044f_\u043c\u043e\u0434\u0443\u043b\u044f.ko<\/code><\/pre>\n<p>\u0430 \u0432 \u0441\u0430\u043c prestart.sh:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh  MOD_VAL=$(lsmod | grep \u0438\u043c\u044f_\u043c\u043e\u0434\u0443\u043b\u044f | wc -l)  cd \/\u043f\u0443\u0442\u044c_\u0434\u043e_\u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f_\u043c\u043e\u0434\u0443\u043b\u044f make clean make all  if [ $MOD_VAL = 1 ] then     for proc in $(ps aux | grep DSS.Agent | awk '{print $2}'); do kill -9 $proc; done else     \/sbin\/insmod \/ \u043f\u0443\u0442\u044c_\u0434\u043e_\u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f_\u043c\u043e\u0434\u0443\u043b\u044f\/\u0438\u043c\u044f_\u043c\u043e\u0434\u0443\u043b\u044f.ko fi<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c: \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0443\u0442\u044c, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u0448\u043b\u0438, \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u00ab\u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0438 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0439\u00bb, \u043d\u043e, \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0443\u044e \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u041e\u0421 Windows. \u0411\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043c\u043d\u0435\u043d\u0438\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0448 DevOps, \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0430\u043a\u0435\u0442\u0430 Linux \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438\/\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438 LKM, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Access Control List (ACL). \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u044b \u0437\u0430\u0439\u043c\u0451\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u043f\u043e\u0434 Linux.  \u0418, \u0434\u0430, \u0441\u043a\u043e\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043b\u0438 MS Forms \u043d\u0430 Avalonia \u0438 \u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 Linux.<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u043b\u0438<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/413241\/\">\u0421\u0442\u0430\u0442\u044c\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e LKM \u043d\u0430 \u0431\u0430\u0437\u0435 ftrace<\/a><\/p>\n<\/li>\n<li>\n<p>\u0413\u0434\u0435 \u043c\u044b <a href=\"https:\/\/superuser.com\/questions\/479746\/how-to-find-pids-user-name-in-linux\/479748\">\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c<\/a> uid \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u043e pid \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/31653257\/how-to-send-and-receive-messages-from-function-other-than-registered-callback-fu\">Netlink socket<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<p> \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\/company\/crosstech\/blog\/538206\/\"> https:\/\/habr.com\/ru\/company\/crosstech\/blog\/538206\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/crosstech\/blog\/531738\/\">\u0441\u0442\u0430\u0442\u044c\u0435 <\/a>\u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0430\u043a\u0435\u0442\u0430 \u043d\u0430 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438 \u043f\u0440\u043e Linux Kernel Module (LKM) \u0438 \u043e\u0431\u0435\u0449\u0430\u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u043f\u0443\u0442\u0438 \u043a \u043d\u0435\u043c\u0443 \u0438 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438. \u041d\u0443 \u0447\u0442\u043e \u0436, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0435\u0433\u043e \u0432\u0440\u0435\u043c\u044f. LKM \u2013 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0435\u0431\u044f.<\/p>\n<h3>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<p>&#171;Windows \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u043d\u0430 Linux Kernel Module LKM\u2026&#187; \u0438\u0442\u0430\u043a, \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043d\u0430\u0447\u0430\u043b\u0443 \u043f\u0443\u0442\u0438. \u041c\u044b \u0438\u043c\u0435\u0435\u043c Windows \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443. \u041a\u0430\u043a \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0438\u043b\u0438 \u0447\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445?  \u041f\u043e\u043a\u043e\u043f\u0430\u0432\u0448\u0438\u0441\u044c \u0432 <a href=\"https:\/\/www.ibm.com\/developerworks\/ru\/library\/l-linux-filesystem\/index.html\">\u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435<\/a>, \u043f\u043e\u0447\u0438\u0442\u0430\u0432 \u043f\u0440\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/15739320\/hook-functions-for-linux-filesystem\">\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442<\/a> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0432 <a href=\"https:\/\/stackoverflow.com\/questions\/51877771\/make-a-minifilter-like-driver-for-linux\">Linux<\/a> \u2013 \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043a\u0443\u0447\u0443 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u0430\u043c\u043d\u0435\u0439.<\/p>\n<p>Inotify<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u043a\u0438\u043d\u0443\u0432 \u0443\u0434\u043e\u0447\u043a\u0438 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0444\u043e\u0440\u0443\u043c\u043e\u0432, \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u00ab\u043a\u043e\u043f\u0430\u0442\u044c\u00bb \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/inotify.7.html\">Inotify<\/a>. Inotify \u2013 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438. \u041d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u00ab\u0431\u0440\u0430\u0442\u00bb \u2013 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/fanotify.7.html\">fanotify<\/a>. \u0412 \u043d\u0451\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/gist.github.com\/jaypeche\/497ac0c3ce36cdb7f5b9\">\u0444\u0430\u0439\u043b\u0430<\/a>. \u041d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u0435\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, fanotify \u043d\u0430\u043c \u0432 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442. \u0425\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e fanotify \u2013 \u044d\u0442\u043e userspace \u0443\u0442\u0438\u043b\u0438\u0442\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e\u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e. <\/p>\n<p>Virtual File System<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/issue.life\/questions\/43242939\">VFS<\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 <a href=\"http:\/\/www.linuxrsp.ru\/artic\/linux_kernel_module_guide_development.html\">VFS<\/a> \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <a href=\"http:\/\/www.brendangregg.com\/dtrace.html\">Dtrace<\/a>, <a href=\"http:\/\/www.brendangregg.com\/bpf-performance-tools-book.html\">eBPF<\/a> \u0438 <a href=\"https:\/\/github.com\/iovisor\/bcc\">bcc<\/a>, \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/www.opennet.ru\/base\/dev\/intercept_lnx.txt.html\">LKM<\/a>. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>     \u2022   \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443;<\/p>\n<p>     \u2022   \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0444\u0430\u0439\u043b\u0443 \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430 \u043d\u0435 \u0438\u0437 \u043f\u0440\u043e\u0432\u043e\u0434\u043d\u0438\u043a\u0430, \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0445;<\/p>\n<p>     \u2022   \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0441\u0432\u043e\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>Janus, SElinux \u0438 AppArmor<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0431\u044b\u043b\u0430 \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u044f\u0434\u0440\u0430 <a href=\"https:\/\/cyberleninka.ru\/article\/n\/rasshirenie-funktsionalnosti-sistemy-bezopasnosti-yadra-linux-na-osnove-podmeny-sistemnyh-vyzovov\/viewer\">Linux<\/a>. \u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0421\u0430\u043c\u044b\u043c \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/kenprice\/janus\">Janus<\/a>. \u041c\u0438\u043d\u0443\u0441\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0432\u0435\u0436\u0438\u0445 \u044f\u0434\u0435\u0440 \u0438 \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b LKM \u0445\u0443\u043a\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <a href=\"https:\/\/github.com\/SELinuxProject\/selinux\">SELinux<\/a> \u0438 <a href=\"https:\/\/gitlab.com\/apparmor\/apparmor\">AppArmor<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0432\u0438\u043d\u0442\u044d\u0441\u0441\u0435\u043d\u0446\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0438\u0437\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0435\u0435. \u041c\u043e\u0434\u0443\u043b\u044c SELinux \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/p>\n<p>     \u2022   \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<br \/>     \u2022   \u043a\u044d\u0448 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0430\u043d\u0433\u043b. Access Vector Cache, AVC);<br \/>     \u2022   \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432;<br \/>     \u2022   \u043a\u043e\u0434 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441\u0435\u0442\u0435\u0432\u043e\u0433\u043e \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f;<br \/>     \u2022   \u0441\u0432\u043e\u044e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (selinuxfs) \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u0432. <\/p>\n<h3>\u0414\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u00ab\u043d\u043e\u00bb, \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u0451\u043b \u0425\u0430\u0431\u0440!  \u041d\u0430\u0442\u043a\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/413241\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>, \u0441\u0442\u0430\u043b\u043e \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e <a href=\"https:\/\/habr.com\/ru\/company\/selectel\/blog\/280322\/\">ftrace<\/a>  \u0438 <a href=\"https:\/\/github.com\/ilammy\/ftrace-hook\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a> \u0438\u0437 \u0441\u0430\u043c\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 LKM \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 ftrace. \u0414\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b debugfs, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432 Linux \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. Hook&#8217;\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f clone \u0438 open:<\/p>\n<p>     \u2022   openat,<br \/>     \u2022   rename,<br \/>     \u2022   unlink,<br \/>     \u2022   unlinkat. <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430. <\/p>\n<p>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u044f\u0434\u0440\u0430 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c userspace. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442 \u0434\u0432\u0430:<\/p>\n<p>     \u2022   socket \u043c\u0435\u0436\u0434\u0443 kernel \u0438 userspace;<br \/>     \u2022   \u0437\u0430\u043f\u0438\u0441\u044c\/\u0447\u0442\u0435\u043d\u0438\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432 \u0444\u0430\u0439\u043b. <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man7\/netlink.7.html\">netlink<\/a> socket, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 Windows \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 &#8212; <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/ddi\/fltkernel\/nf-fltkernel-fltsendmessage\">FltSendMessage<\/a>. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/stackoverflow.com\/questions\/8252630\/linux-kernel-socket-programmingsendmsg-function-msg-address-can-not-access%0A\">inet<\/a> socket, \u043d\u043e \u044d\u0442\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.  \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0447\u0442\u043e \u043d\u0430 .Net Core, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e userspace \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, <a href=\"https:\/\/github.com\/dotnet\/runtime\/issues\/28157%0A\">\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442<\/a> <a href=\"https:\/\/stackoverflow.com\/questions\/53666063\/using-netlink-connector-in-dotnet-c%0A\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a> netlink.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 <a href=\"https:\/\/habr.com\/ru\/post\/121254\/%0A\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/a> <a href=\"https:\/\/stackoverflow.com\/questions\/31653257\/how-to-send-and-receive-messages-from-function-other-than-registered-callback-fu\">netlink<\/a> \u0438 \u0443\u0436\u0435 \u0435\u0451 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442. <\/p>\n<pre><code class=\"cpp\"> int open_netlink_connection(void) {     \/\/initialize our variables     int sock;     struct sockaddr_nl addr;     int group = NETLINK_GROUP;      \/\/open a new socket connection     sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_USERSOCK);      \/\/if the socket failed to open,     if (sock &lt; 0)      {         \/\/inform the user         printf(\"Socket failed to initialize.\\n\");         \/\/return the error value         return sock;     }      \/\/initialize our addr structure by filling it with zeros     memset((void *) &amp;addr, 0, sizeof(addr));     \/\/specify the protocol family     addr.nl_family = AF_NETLINK;     \/\/set the process id to the current process id     addr.nl_pid = getpid();      \/\/bind the address to the socket created, and if it failed,     if (bind(sock, (struct sockaddr *) &amp;addr, sizeof(addr)) &lt; 0)      {         \/\/inform the user         printf(\"bind &lt; 0.\\n\");         \/\/return the function with a symbolic error code         return -1;     }      \/\/set the option so that we can receive packets whose destination     \/\/is the group address specified (so that we can receive the message broadcasted by the kernel)     if (setsockopt(sock, 270, NETLINK_ADD_MEMBERSHIP, &amp;group, sizeof(group)) &lt; 0)      {         \/\/if it failed, inform the user         printf(\"setsockopt &lt; 0\\n\");         \/\/return the function with a symbolic error code         return -1;     }      \/\/if we got thus far, then everything     \/\/went fine. Return our socket.     return sock; }  char* read_kernel_message(int sock) {     \/\/initialize the variables     \/\/that we are going to need     struct sockaddr_nl nladdr;     struct msghdr msg;     struct iovec iov;     char* buffer[CHUNK_SIZE];     char* kernelMessage;     int ret;      memset(&amp;msg, 0, CMSG_SPACE(MAX_PAYLOAD));     memset(&amp;nladdr, 0, sizeof(nladdr));     memset(&amp;iov, 0, sizeof(iov));     \/\/specify the buffer to save the message     iov.iov_base = (void *) &amp;buffer;     \/\/specify the length of our buffer     iov.iov_len = sizeof(buffer);      \/\/pass the pointer of our sockaddr structure     \/\/that will save the source IP and port of the connection     msg.msg_name = (void *) &amp;(dest_addr);     \/\/give the size of our structure     msg.msg_namelen = sizeof(dest_addr);     \/\/pass our scatter\/gather I\/O structure pointer     msg.msg_iov = &amp;iov;     \/\/we will pass only one buffer array,     \/\/therefore we will specify that here     msg.msg_iovlen = 1;      \/\/listen\/wait for new data     ret = recvmsg(sock, &amp;msg, 0);      \/\/if message was received successfully,     if(ret &gt;= 0)     {         \/\/get the string data and save them to a local variable         char* buf = NLMSG_DATA((struct nlmsghdr *) &amp;buffer);          \/\/allocate memory for our kernel message         kernelMessage = (char*)malloc(CHUNK_SIZE);          \/\/copy the kernel data to our allocated space         strcpy(kernelMessage, buf);          \/\/return the pointer that points to the kernel data         return kernelMessage;     }          \/\/if we got that far, reading the message failed,     \/\/so we inform the user and return a NULL pointer     printf(\"Message could not received.\\n\");     return NULL; }  int send_kernel_message(int sock, char* kernelMessage) {     \/\/initialize the variables     \/\/that we are going to need     struct msghdr msg;     struct iovec iov;     char* buffer[CHUNK_SIZE];         int ret;      memset(&amp;msg, 0, CMSG_SPACE(MAX_PAYLOAD));     memset(&amp;iov, 0, sizeof(iov));      nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));     memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));     nlh-&gt;nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);     nlh-&gt;nlmsg_pid = getpid();     nlh-&gt;nlmsg_flags = 0;      char buff[160];     snprintf(buff, sizeof(buff), \"From:DSSAgent;Action:return;Message:%s;\", kernelMessage);     strcpy(NLMSG_DATA(nlh), buff);      iov.iov_base = (void *)nlh;     iov.iov_len = nlh-&gt;nlmsg_len;     \/\/pass the pointer of our sockaddr structure     \/\/that will save the source IP and port of the connection     msg.msg_name = (void *) &amp;(dest_addr);     \/\/give the size of our structure     msg.msg_namelen = sizeof(dest_addr);     msg.msg_iov = &amp;iov;     msg.msg_iovlen = 1;     printf(\"Sending message to kernel (%s)\\n\",(char *)NLMSG_DATA(nlh));     ret = sendmsg(sock, &amp;msg, 0);     return ret; }  int sock_netlink_connection() { \tsock_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_USER);     if (sock_fd &lt; 0)         return -1;       memset(&amp;src_addr, 0, sizeof(src_addr));     src_addr.nl_family = AF_NETLINK;     src_addr.nl_pid = getpid(); \/* self pid *\/       bind(sock_fd, (struct sockaddr *)&amp;src_addr, sizeof(src_addr));       memset(&amp;dest_addr, 0, sizeof(dest_addr));     dest_addr.nl_family = AF_NETLINK;     dest_addr.nl_pid = 0; \/* For Linux Kernel *\/     dest_addr.nl_groups = 0; \/* unicast *\/       nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));     memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));     nlh-&gt;nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);     nlh-&gt;nlmsg_pid = getpid();     nlh-&gt;nlmsg_flags = 0;       strcpy(NLMSG_DATA(nlh), \"From:DSSAgent;Action:hello;\");       iov.iov_base = (void *)nlh;     iov.iov_len = nlh-&gt;nlmsg_len;     msg.msg_name = (void *)&amp;dest_addr;     msg.msg_namelen = sizeof(dest_addr);     msg.msg_iov = &amp;iov;     msg.msg_iovlen = 1;       printf(\"Sending message to kernel\\n\");     sendmsg(sock_fd, &amp;msg, 0);     printf(\"Waiting for message from kernel\\n\");       \/* Read message from kernel *\/     recvmsg(sock_fd, &amp;msg, 0);     printf(\"Received message payload: %s\\n\", (char *)NLMSG_DATA(nlh)); \t \treturn sock_fd; } void sock_netlink_disconnection(int sock) { \tclose(sock);     free(nlh); }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 Net.Core \u2013 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0438\u0441\u043a \u043f\u043e pid \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u044d\u0442\u043e\u0442 <a href=\"https:\/\/docs.microsoft.com\/ru-ru\/dotnet\/api\/system.diagnostics.process.getprocessbyid?view=net-5.0\">\u043f\u0440\u043e\u0446\u0435\u0441\u0441<\/a>. <a href=\"https:\/\/coderoad.ru\/5327707\/%D0%9A%D0%B0%D0%BA-%D1%8F-%D0%BC%D0%BE%D0%B3%D1%83-%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B8%D1%82%D1%8C-%D0%B8%D0%BC%D1%8F-%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8F-%D0%B8%D0%B7-%D0%B8%D0%B4%D0%B5%D0%BD%D1%82%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%82%D0%BE%D1%80%D0%B0-%D0%BF%D1%80%D0%BE%D1%86%D0%B5%D1%81%D1%81%D0%B0-%D0%B2-python-%D0%BD%D0%B0\">\u041f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <\/a><a href=\"https:\/\/stackoverflow.com\/questions\/6457682\/how-to-programatically-get-uid-from-pid-in-osx-using-c\">\u0434\u0430\u043d\u043d\u043e\u0439 <\/a><a href=\"https:\/\/man7.org\/tlpi\/code\/online\/dist\/sysinfo\/procfs_user_exe.c.html\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <\/a><a href=\"https:\/\/superuser.com\/questions\/479746\/how-to-find-pids-user-name-in-linux\/479748\">\u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c <\/a><a href=\"https:\/\/coderoad.ru\/6457682\/%D0%9A%D0%B0%D0%BA-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE-%D0%BF%D0%BE%D0%BB%D1%83%D1%87%D0%B8%D1%82%D1%8C-uid-%D0%B8%D0%B7-pid-%D0%B2-osx-%D1%81-%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E-c\">\u043c\u0430\u0441\u0441\u0430<\/a>, \u043d\u043e, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p><\/br><\/br><\/p>\n<p><\/br><\/br><\/br><\/br><\/br><\/br><\/p>\n<p><\/br><\/br><\/br><\/br><\/br><\/p>\n<p><\/br><\/p>\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-316643","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316643","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=316643"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316643\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}