{"id":468207,"date":"2025-07-22T15:01:31","date_gmt":"2025-07-22T15:01:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=468207"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=468207","title":{"rendered":"<span>[\u041f\u0435\u0440\u0435\u0432\u043e\u0434] \u041f\u043e\u0438\u0441\u043a \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u0432 Linux (\u0427\u0430\u0441\u0442\u044c 2). \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438<\/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 decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d0c\/0b9\/90b\/d0c0b990b895f2b400c4d48b9e983d6b.png\" width=\"1760\" height=\"1360\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d0c\/0b9\/90b\/d0c0b990b895f2b400c4d48b9e983d6b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d0c\/0b9\/90b\/d0c0b990b895f2b400c4d48b9e983d6b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f &#8212; \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442 Pepe Berba &#8212;\u00a0<a href=\"https:\/\/pberba.github.io\/security\/2021\/11\/23\/linux-threat-hunting-for-persistence-account-creation-manipulation\/\" rel=\"noopener noreferrer nofollow\">Hunting for Persistence in Linux<\/a>.  <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">! \u0412\u0441\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0437\u043b\u043e\u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445 \u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u0437\u0430\u043a\u043e\u043d\u043e\u0434\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443. \u0410\u0432\u0442\u043e\u0440 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435 \u043d\u0435\u0441\u0443\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u043e\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. !  <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435  <\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/928244\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <\/a>\u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c <strong>auditd<\/strong> \u0438 <strong>sysmon<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u0445\u043d\u0438\u043a \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0445\u043e\u0441\u0442\u0430\u0445 Linux. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e: SSH Authorized Keys<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u0442\u0435\u0445\u043d\u0438\u043a \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h2>2 \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438: \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0447\u0451\u0442\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c  <\/h2>\n<p><strong> 2.1 \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>MITRE: <a href=\"https:\/\/attack.mitre.org\/techniques\/T1136\/001\/\" rel=\"noopener noreferrer nofollow\">https:\/\/attack.mitre.org\/techniques\/T1136\/001\/<\/a><\/p>\n<p>\u0417\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c \u0436\u0435\u0440\u0442\u0432\u044b \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u044d\u043a\u0434\u043e\u0440-\u0432\u0435\u0431-\u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f!<\/p>\n<p>\u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">sudo adduser --shell \/bin\/bash --home \/var\/www\/ nginx   sudo usermod -aG sudo nginx<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>nginx<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <code>sudo<\/code>. (\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043e\u0431\u043c\u0430\u043d\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e <code>nginx <\/code>\u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <code>nginx<\/code>.)<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044c \u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SSH \u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<pre><code class=\"bash\">mkdir \/var\/www\/.ssh   echo \"ssh-ed25519 AA ... \" &gt; \/var\/www\/.ssh\/authorized_keys<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>nginx@&lt;\u0432\u0437\u043b\u043e\u043c\u0430\u043d\u043d\u044b\u0439_\u0445\u043e\u0441\u0442&gt;<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c root-\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0445\u043e\u0441\u0442\u0443.<\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0442\u0430\u043a \u0438 \u0435\u0451 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f.<\/p>\n<p><strong> 2.2 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 auditbeat<\/strong> <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>auditbeat<\/code>, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>event.module: system<\/code> \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <code>process_started<\/code>. \u041e\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c: <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aa4\/7e8\/1d1\/aa47e81d172a167d20db1b21c6ec24ca.png\" width=\"800\" height=\"64\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/aa4\/7e8\/1d1\/aa47e81d172a167d20db1b21c6ec24ca.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/aa4\/7e8\/1d1\/aa47e81d172a167d20db1b21c6ec24ca.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>event.action<\/code>:<\/p>\n<ul>\n<li>\n<p><code>user_added<\/code>: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0444\u0430\u0439\u043b\u044b <code>passwd <\/code>\u0438 <code>shadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>password_changed<\/code>: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p><code>user_changes<\/code>: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 sudo<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f61\/5a1\/203\/f615a12033d9dc20f4c54dab3dfb6da1.png\" width=\"800\" height=\"121\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f61\/5a1\/203\/f615a12033d9dc20f4c54dab3dfb6da1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f61\/5a1\/203\/f615a12033d9dc20f4c54dab3dfb6da1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p><strong>2.3 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432<\/strong><code><strong> \/etc\/shadow<\/strong><\/code><strong>, <\/strong><code><strong>\/etc\/passwd<\/strong><\/code><strong> \u0438 <\/strong><code><strong>\/etc\/group<\/strong><\/code><br \/> \u0417\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>passwd <\/code>\u0438 <code>adduser<\/code>, \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/etc\/gshadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/shadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/passwd<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/group<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>adduser<\/code>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c2\/e6b\/d66\/8c2e6bd669eafc83afd59eb4b4abb4c0.png\" width=\"800\" height=\"296\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8c2\/e6b\/d66\/8c2e6bd669eafc83afd59eb4b4abb4c0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c2\/e6b\/d66\/8c2e6bd669eafc83afd59eb4b4abb4c0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/nshadow<\/code>,<code> \/etc\/passwd.lock<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445. \u042d\u0442\u043e \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434 <code>passwd <\/code>\u0438 <code>usermod<\/code>.<\/p>\n<p>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>2.4 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 auditd \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong><br \/>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e auditd, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"xml\">-w \/etc\/group -p wa -k etcgroup   -w \/etc\/passwd -p wa -k etcpasswd   -w \/etc\/gshadow -k etcgroup   -w \/etc\/shadow -k etcpasswd  -w \/usr\/sbin\/useradd -p x -k user_modification   -w \/usr\/sbin\/adduser -p x -k user_modification -w \/usr\/bin\/passwd -p x -k passwd_modification<\/code><\/pre>\n<p> \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u044b \u0438 \u0442.\u0434.:  <\/p>\n<pre><code>-w \/etc\/sudoers -p rw -k priv_esc   -w \/etc\/sudoers.d -p rw -k priv_esc  -w \/usr\/sbin\/usermod -p x -k user_modification   -w \/usr\/sbin\/userdel -p x -k user_modification   -w \/usr\/sbin\/groupadd -p x -k group_modification   -w \/usr\/sbin\/groupmod -p x -k group_modification   -w \/usr\/sbin\/addgroup -p x -k group_modification <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435\/\u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>sudoers<\/code><\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/group<\/code> \u0438\u043b\u0438 <code>\/etc\/passwd<\/code><\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 <code>\/etc\/gshadow<\/code> \u0438<code> \/etc\/shadow<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <code>useradd <\/code>\u0438 <code>usermod<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043b\u043e\u0433 <code>auditd <\/code>\u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430 <code>\/etc\/passwd<\/code>:<\/p>\n<pre><code class=\"bash\">type=SYSCALL msg=audit(1637599618.765:11426): arch=c000003e syscall=82  success=yes exit=0 a0=7ffeb8ffa160 a1=564262d92020 a2=7ffeb8ffa0d0 a3=2 items=5  ppid=13573 pid=13578 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0  fsgid=0 tty=pts0 ses=19 comm=\"useradd\" exe=\"\/usr\/sbin\/useradd\" subj==unconfined  key=\"etcpasswd\", type=PATH msg=audit(1637599618.765:11426): item=0 name=\"\/etc\/\"  inode=131075 dev=08:01 mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0,  type=PATH msg=audit(1637599618.765:11426): item=1 name=\"\/etc\/\" inode=131075 dev=08:01  mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0000000000000000  cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PATH  msg=audit(1637599618.765:11426): item=2 name=\"\/etc\/shadow+\" inode=131557  dev=08:01 mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=DELETE  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0,  type=PATH msg=audit(1637599618.765:11426): item=3 name=\"\/etc\/shadow\"  inode=144749 dev=08:01 mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=DELETE  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PATH  msg=audit(1637599618.765:11426): item=4 name=\"\/etc\/shadow\" inode=131557 dev=08:01  mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=CREATE cap_fp=0000000000000000  cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PROCTITLE  msg=audit(1637599618.765:11426):  proctitle=2F7362696E2F75736572616464002D64002F7661722F7777772F002D67006E67696E78002D73002F62696E2F62617368002D750031303032006E67696E78<\/code><\/pre>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p><code>comm=\"useradd\" exe=\"\/usr\/sbin\/useradd\"<\/code>\u2014 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p><code>name=\"\/etc\/shadow\"<\/code> \u2014 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p><code>key=\"etcpasswd\"<\/code> \u2014 \u0442\u0435\u0433 \u0438\u043b\u0438 \u043a\u043b\u044e\u0447 \u0438\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 auditd<\/p>\n<\/li>\n<li>\n<p><code>proctitle=2F7362...<\/code> \u2014 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>\/sbin\/useradd -d \/var\/www\/ -g nginx -s \/bin\/bash -u 1002 nginx<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>2.4.1 \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0440\u043e UID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong><br \/>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0444\u0430\u0439\u043b<code> \/etc\/passwd<\/code>, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>nginx <\/code>\u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 <code>UID<\/code>, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441 <code>100X<\/code>.<\/p>\n<pre><code class=\"bash\">messagebus:x:104:105::\/nonexistent:\/usr\/sbin\/nologin   sshd:x:105:65534::\/run\/sshd:\/usr\/sbin\/nologin   _chrony:x:106:112:Chrony daemon,,,:\/var\/lib\/chrony:\/usr\/sbin\/nologin   systemd-coredump:x:999:999:systemd Core Dumper:\/:\/usr\/sbin\/nologin   user:x:1000:1001::\/home\/user:\/bin\/bash   nginx:x:1002:1003:,,,:\/var\/www\/:\/bin\/bash<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Linux-\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 UID, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0441\u0442\u044c, \u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0438\u0437\u043a\u0438\u0439 UID. <\/p>\n<p><strong>2.5 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 sysmon \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong> <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 MSTIC \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u0432\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/persistence\/T1136.001_CreateLocalAccount_Commands.xml\" rel=\"noopener noreferrer nofollow\">T1136.001_CreateLocalAccount_Commands.xml<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/discovery\/T1087.001_LocalAccount_Commands.xml\" rel=\"noopener noreferrer nofollow\">T1087.001_LocalAccount_Commands.xml<\/a><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">    &lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;ProcessCreate onmatch=\"include\"&gt;         &lt;Rule name=\"TechniqueID=T1087.001,TechniqueName=Account Discovery: Local Account\" groupRelation=\"or\"&gt;           &lt;CommandLine condition=\"contains\"&gt;\/etc\/passwd&lt;\/CommandLine&gt;           &lt;CommandLine condition=\"contains\"&gt;\/etc\/sudoers&lt;\/CommandLine&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"TechniqueID=T1136.001,TechniqueName=Create Account: Local Account\" groupRelation=\"or\"&gt;           &lt;Image condition=\"end with\"&gt;useradd&lt;\/Image&gt;           &lt;Image condition=\"end with\"&gt;adduser&lt;\/Image&gt;         &lt;\/Rule&gt;       &lt;\/ProcessCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 <code>\/etc\/passwd<\/code>. \u0427\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 <code>useradd <\/code>\u0438\u043b\u0438 <code>adduser<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u0442\u0430\u0440\u0442 \u0434\u043b\u044f \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u0447\u0435\u0442\u043e\u043a, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438, \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>useradd\/adduser<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e<code> T1087.001 <\/code>\u0438\u0449\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 <code>\/etc\/passwd<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>\/etc\/passwd<\/code>, \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u044f\u0432\u043d\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043e\u0439\u0442\u0438 \u0438 \u044d\u0442\u043e \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 <code>root<\/code>.<\/p>\n<pre><code class=\"bash\">echo \"nginx:x:0:0::\/home\/nginx:\/bin\/bash\" &gt;&gt; \/etc\/\/passwd passwd nginx <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044c \u0431\u0435\u0437 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0432\u044b\u0448\u0435 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439. \u041c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>useradd <\/code>\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0441\u044b\u043b\u0430\u043b\u0438\u0441\u044c \u043d\u0430 <code>\/etc\/\/passwd<\/code>, \u0447\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 <code>\/etc\/passwd<\/code> \u0438\u0437-\u0437\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u044d\u0448\u0430.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"bash\">-w \/etc\/passwd -p wa -k etcpasswd  <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0438 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/passwd<\/code>, <code>\/etc\/shadow<\/code> \u0438 \u0442.\u043f., \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u0432 sysmon \u2014 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e: <\/p>\n<pre><code class=\"xml\">    &lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;FileCreate onmatch=\"include\"&gt;         &lt;Rule name=\"etcpasswd\" groupRelation=\"or\"&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/passwd&lt;\/TargetFilename&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/shadow&lt;\/TargetFilename&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"etcgroup\" groupRelation=\"or\"&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/group&lt;\/TargetFilename&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/gshadow&lt;\/TargetFilename&gt;         &lt;\/Rule&gt;       &lt;\/FileCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<p> \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0441\u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <\/p>\n<pre><code class=\"bash\">vi \/etc\/passwd useradd<\/code><\/pre>\n<p>(\u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>\/etc\/shadow+<\/code>, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0444\u0430\u0439\u043b <code>\/etc\/shadow<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.)<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445:<\/p>\n<pre><code class=\"bash\">echo \"&lt;TEXT&gt;\" &gt;&gt; \/etc\/passwd sed -i 's\/BEFORE\/AFTER\/g' \/etc\/passwd<\/code><\/pre>\n<p> \u0425\u0443\u0436\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b \u044f\u0432\u043d\u043e \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <code>\/etc\/shadow<\/code>, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043f\u043e\u0445\u043e\u0436\u0435, \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0435: <\/p>\n<pre><code class=\"bash\">passwd user<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c sysmon \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432. <\/p>\n<p> \u042f \u0431\u044b \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043b \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0433\u0440\u0443\u043f\u043f, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 <code>auditd<\/code>. <\/p>\n<pre><code class=\"xml\">&lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;ProcessCreate onmatch=\"include\"&gt;         &lt;Rule name=\"group_modification\" groupRelation=\"or\"&gt;           &lt;Image condition=\"end with\"&gt;groupmod&lt;\/Image&gt;           &lt;Image condition=\"end with\"&gt;addgroup&lt;\/Image&gt;           &lt;Image condition=\"end with\"&gt;groupadd&lt;\/Image&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"user_modification\" groupRelation=\"or\"&gt;           &lt;Image condition=\"end with\"&gt;usermod&lt;\/Image&gt;           &lt;Image condition=\"end with\"&gt;userdel&lt;\/Image&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"passwd_modification\" groupRelation=\"or\"&gt;           &lt;Image condition=\"end with\"&gt;passwd&lt;\/Image&gt;         &lt;\/Rule&gt;       &lt;\/ProcessCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<h2> 3 \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438: \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438  <\/h2>\n<p>MITRE: <a href=\"https:\/\/attack.mitre.org\/techniques\/T1098\/\" rel=\"noopener noreferrer nofollow\">https:\/\/attack.mitre.org\/techniques\/T1098\/<\/a> \u0438 <a href=\"https:\/\/attack.mitre.org\/techniques\/T1078\/\" rel=\"noopener noreferrer nofollow\">https:\/\/attack.mitre.org\/techniques\/T1078\/<\/a><\/p>\n<p><strong>3.1 \u0417\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438<\/strong><br \/><strong>3.1.1 \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/strong><\/p>\n<p>\u0417\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u043b\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u0438 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043c\u0435\u044e\u0442 \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u043e\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0431\u0435\u043b\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u0441\u0432\u043e\u0438\u0445 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0431\u044d\u043a\u0434\u043e\u0440 \u0432 \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c <code>www-data<\/code>. \u041c\u044b \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c <code>www-data<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <code>sudo<\/code>.<\/p>\n<pre><code class=\"bash\">sudo passwd www-data   sudo usermod -aG sudo www-data<\/code><\/pre>\n<p>\u041c\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b <code>\/etc\/passwd<\/code>, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e SSH \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c www-data, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0443: <\/p>\n<pre><code>www-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin<\/code><\/pre>\n<p>\u043d\u0430<\/p>\n<pre><code>www-data:x:33:33:www-data:\/var\/www:\/bin\/bash<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b <code>\/etc\/ssh\/sshd_config<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u0438.  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443: <\/p>\n<pre><code>PasswordAuthentication yes<\/code><\/pre>\n<p>\u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441:<\/p>\n<pre><code>sudo service ssh restart<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043f\u043e SSH \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c <code>www-data<\/code> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <code>sudo<\/code>.  <\/p>\n<p><strong>3.2.2 \u0414\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438<\/strong><\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0443 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0421\u043d\u044f\u0442\u044c \u0434\u0430\u043c\u043f \u0444\u0430\u0439\u043b\u0430 <code>\/etc\/shadow<\/code> \u0438 \u0432\u0437\u043b\u043e\u043c\u0430\u0442\u044c \u0445\u044d\u0448\u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0438\u0437 \u043f\u0430\u043f\u043e\u043a <code>.ssh<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0438 \u0438 \u0442\u043e\u043a\u0435\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u043e\u0432 CLI<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u0445\u0430\u0440\u0434\u043a\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u0441 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u044b, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<p><strong>3.3 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438<\/strong><\/p>\n<p>\u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u043a\u0430\u043a <code>\/etc\/passwd<\/code> \u0438 <code>\/etc\/shadow<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<p>\u0421\u043d\u044f\u0442\u0438\u0435 \u0434\u0430\u043c\u043f\u0430 <code>\/etc\/shadow<\/code> \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 <code>auditd<\/code>:<\/p>\n<pre><code class=\"bash\">-w \/etc\/shadow -k etcpasswd<\/code><\/pre>\n<p> \u0414\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>sshd <\/code>\u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <code>auditd<\/code>: <\/p>\n<pre><code class=\"bash\">## SSH configuration   -w \/etc\/ssh\/sshd_config -k sshd   -w \/etc\/ssh\/sshd_config.d -k sshd<\/code><\/pre>\n<p><strong>3.4 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u041f\u043e\u0438\u0441\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e osquery<\/strong><\/p>\n<p><strong>3.4.1 \u041f\u043e\u0438\u0441\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong><\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0432\u0430\u0448\u0438\u043c \u0445\u043e\u0441\u0442\u0430\u043c \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435.<\/p>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"sql\">SELECT type, user, host  FROM logged_in_users  WHERE type = 'user';<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code>+------+----------+-----------------+ | type | user     | host            | +------+----------+-----------------+ | user | www-data | 1.2.3.4         | | user | user     | 1.2.3.4         | +------+----------+-----------------+<\/code><\/pre>\n<p><strong>3.4.2 \u041f\u043e\u0438\u0441\u043a \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u043e\u043b\u044f\u043c\u0438<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432\u0445\u043e\u0434 \u043f\u043e \u043f\u0430\u0440\u043e\u043b\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0448\u0438\u043d\u044b), \u0442\u043e \u0432\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u043e\u043b\u044f\u043c\u0438. <\/p>\n<pre><code class=\"sql\">SELECT password_status, username, last_change FROM shadow  WHERE password_status = 'active';<\/code><\/pre>\n<pre><code>+-----------------+----------+-------------+ | password_status | username | last_change | +-----------------+----------+-------------+ | active          | www-data | 18953       | | active          | legit    | 18819       | +-----------------+----------+-------------+<\/code><\/pre>\n<p><strong>3.4.3 \u041f\u043e\u0438\u0441\u043a \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 <\/strong><\/p>\n<p>\u0418\u0449\u0438\u0442\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0438\u043b\u0435\u0433\u0438\u0439 (privesc). \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0443\u0447\u0451\u0442\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u0447\u0442\u0435\u043d\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u0430.<\/p>\n<pre><code class=\"sql\">SELECT uid,  username, groupname  FROM user_groups  JOIN users  USING(uid) JOIN groups  ON user_groups.gid=groups.gid  WHERE    (groupname = 'sudo'    OR groupname = 'root')   AND username != 'root';<\/code><\/pre>\n<pre><code>+------+----------+-----------+ | uid  | username | groupname | +------+----------+-----------+ | 33   | www-data | sudo      | | 1001 | legit    | sudo      | | 1002 | nginx    | sudo      | +------+----------+-----------+<\/code><\/pre>\n<p><strong>3.4.4 \u041f\u043e\u0438\u0441\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430\u043c\u0438 (shell)<\/strong><\/p>\n<p> \u0415\u0441\u043b\u0438 \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438 (<code>shell<\/code>) \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d <code>\/bin\/bash<\/code>, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0431\u044d\u043a\u0434\u043e\u0440\u0430.  <\/p>\n<pre><code class=\"sql\">SELECT uid, username, directory, shell FROM users  WHERE shell != \"\/usr\/sbin\/nologin\";<\/code><\/pre>\n<pre><code>+------+----------+-------------+-----------+ | uid  | username | directory   | shell     | +------+----------+-------------+-----------+ | 0    | root     | \/root       | \/bin\/bash | | 4    | sync     | \/bin        | \/bin\/sync | | 33   | www-data | \/var\/www    | \/bin\/bash | | 1000 | user     | \/home\/user  | \/bin\/bash | | 1001 | legit    | \/home\/legit | \/bin\/bash | | 1002 | nginx    | \/var\/www\/   | \/bin\/bash | +------+----------+-------------+-----------+<\/code><\/pre>\n<p><strong>3.4.5 \u041f\u043e\u0438\u0441\u043a \u043a\u043e\u043c\u0430\u043d\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/strong><\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u0438 \u0432 <strong>auditd<\/strong> \u0438 <strong>sysmon<\/strong>. \u0415\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043d\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u043b \u0438\u0441\u0442\u043e\u0440\u0438\u044e bash, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0441\u043b\u0435\u0434\u044b \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0444\u0430\u0439\u043b\u0430 <code>authorized_keys<\/code><\/p>\n<pre><code class=\"sql\">SELECT uid, username, command  FROM users  JOIN  shell_history  USING(uid)  WHERE  regex_match(command,  'useradd|adduser|passwd|usermod|groupmod|addgroup|groupadd|authorized_keys', 0)   IS NOT NULL;<\/code><\/pre>\n<pre><code>+------+----------+--------------------------------------------------+ | uid  | username | command                                          | +------+----------+--------------------------------------------------+ | 0    | root     | passwd www-data                                  | | 0    | root     | vi \/etc\/passwd                                   | | 0    | root     | cat \/etc\/passwd                                  | | 0    | root     | echo \"ssh-ed25519 AA...\" &gt;&gt; .ssh\/authorized_keys | | 1000 | user     | echo \"ssh-ed25519 ...\" &gt;&gt; authorized_keys        | | 1000 | user     | usermod -aG sudo legit                           | | 1000 | user     | sudo usermod -aG sudo legit                      | | 1001 | legit    | sudo vi authorized_keys                          | +------+----------+--------------------------------------------------+<\/code><\/pre>\n<p><strong>3.5 \u0420\u0443\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/strong> <\/p>\n<p><strong>3.5.1 lastlog<\/strong> <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>lastlog<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u0445\u043e\u0434\u0438\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. <\/p>\n<pre><code class=\"bash\">&gt;&gt; lastlog | grep -v Never Username         Port     From             Latest www-data         pts\/1    1.2.3.4  Wed Nov 24 11:17:46 +0000 2021 user             pts\/0    1.2.3.4  Wed Nov 24 11:41:22 +0000 2021 legit            pts\/1    1.2.3.4   Sun Jul 11 16:18:58 +0000 2021 nginx            pts\/1    1.2.3.4  Mon Nov 22 16:59:47 +0000 2021<\/code><\/pre>\n<p><strong>3.5.2 \/var\/log\/auth.log <\/strong><\/p>\n<p>\u0418\u043b\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043b\u043e\u0433\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u043b\u044f SSH-\u0441\u0435\u0441\u0441\u0438\u0439.<\/p>\n<pre><code class=\"bash\">&gt;&gt; cat \/var\/log\/auth.log | grep sshd | grep -i Accepted Nov 22 16:36:05 test-auditd sshd[13413]: Accepted publickey for user from 1.2.3.4 port 17629 ssh2: ED25519 SHA256:AA... Nov 22 16:38:42 test-auditd sshd[13446]: Accepted publickey for user from 1.2.3.4 port 18131 ssh2: ED25519 SHA256:AA... Nov 22 16:54:55 test-auditd sshd[13634]: Accepted publickey for nginx from 1.2.3.4 port 21020 ssh2: ED25519 SHA256:AA... Nov 22 16:59:46 test-auditd sshd[13683]: Accepted publickey for nginx from 1.2.3.4 port 17676 ssh2: ED25519 SHA256:AA... Nov 24 10:37:40 test-auditd sshd[11981]: Accepted publickey for user from 1.2.3.4 port 18970 ssh2: ED25519 SHA256:AA... Nov 24 11:17:45 test-auditd sshd[15854]: Accepted password for www-data from 1.2.3.4 port 18669 ssh2 Nov 24 11:41:21 test-auditd sshd[16566]: Accepted publickey for user from 1.2.3.4 port 17873 ssh2: ED25519 SHA256:AA...<\/code><\/pre>\n<h2> 4 \u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f \u0443\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438: SSH Authorized Keys  <\/h2>\n<p>MITRE: <a href=\"https:\/\/attack.mitre.org\/techniques\/T1098\/004\/\" rel=\"noopener noreferrer nofollow\">https:\/\/attack.mitre.org\/techniques\/T1098\/004\/<\/a><\/p>\n<p><strong>4.1 \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 SSH Authorized Keys<\/strong><\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 SSH-\u043a\u043b\u044e\u0447\u0435\u0439 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0444\u0430\u0439\u043b <code>authorized_keys<\/code> \u0447\u0430\u0441\u0442\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u043a\u0430\u043a GCP \u0438 AWS, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u044b \u0440\u0435\u0434\u043a\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c SSH-\u043a\u043b\u044e\u0447, \u043e\u043d, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0430\u043c \u043d\u0430\u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>\u0424\u0430\u0439\u043b <code>authorized_keys<\/code> \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>&lt;home&gt;\/.ssh\/<\/code> \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438:<\/p>\n<pre><code class=\"bash\">root:x:0:0:root:\/root:\/bin\/bash  user:x:1000:1001::\/home\/user:\/bin\/bash   nginx:x:0:0:,,,:\/var\/www\/:\/bin\/bash<\/code><\/pre>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 SSH-\u043a\u043b\u044e\u0447\u0438 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/var\/www\/.ssh\/authorized_keys<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/home\/user\/.ssh\/authorized_keys<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/root\/.ssh\/authorized_keys<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\"># create .ssh directory if it does not exist   mkdir \/var\/www\/.ssh  echo \"ssh-ed25519 AA ... \" &gt;&gt; \/var\/www\/.ssh\/authorized_keys   echo \"ssh-ed25519 AA ... \" &gt;&gt; \/home\/user\/.ssh\/authorized_keys   echo \"ssh-ed25519 AA ... \" &gt;&gt; \/root\/.ssh\/authorized_keys<\/code><\/pre>\n<p><strong>4.2 \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f \u043f\u043e SSH-\u043a\u043b\u044e\u0447\u0430\u043c \u0432 authorized_keys<\/strong><\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0438\u043a\u043e\u0432, \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 SSH-\u043a\u043b\u044e\u0447\u0430 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 SSH-\u043a\u043b\u044e\u0447\u0435\u0439.<\/p>\n<pre><code class=\"bash\">ssh-ed25519 AAAAC3NzaC1lZDI1NTg3f2vasdcascTcwuq8CVppeNDQv85MQ3fsdsa592q86W1  paul@LP-291221   ssh-ed25519 AAAAC3NzaC1lZDascacasbI1NTE5AAAAIB7q5ZK6GMNO6lTd90yutRohmGPugoCruTL  paul@LP-291221<\/code><\/pre>\n<p>\u00ab\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b\u00bb \u0432 SSH-\u043a\u043b\u044e\u0447\u0430\u0445 \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u00abkali\u00bb \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u043a\u0438 \u0432 \u0432\u0430\u0448\u0438\u0445 \u0431\u044d\u043a\u0434\u043e\u0440\u043d\u044b\u0445 SSH-\u043a\u043b\u044e\u0447\u0430\u0445.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a SSH-\u043a\u043b\u044e\u0447\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code># DO NOT REMOVE   ssh-ed25519 AAAAC3NzaC1lZDI1NTg3f2vasdcascTcwuq8CVppeNDQv85MQ3fsdsa592q86W1  security-team   ssh-ed25519 AAAAC3NzaC1lZDascacasbI1NTE5AAAAIB7q5ZK6GMNO6lTd90yutRohmGPugoCruTL  paul@LP-291221<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0440\u0435\u0434\u0430\u0445, \u043a\u0430\u043a Google Cloud Platform.<\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e SSH-\u043a\u043b\u044e\u0447\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e \u0432\u0441\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c <code># Added by Google<\/code>. \u042d\u0442\u0438 SSH-\u043a\u043b\u044e\u0447\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u00ab\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c\u0438\u00bb \u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043a\u043b\u044e\u0447\u0430 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f, SSH-\u043a\u043b\u044e\u0447\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435\u0442 \u0432 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 SSH-\u043a\u043b\u044e\u0447 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c <code># Added by Google<\/code> (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u044b).<\/p>\n<pre><code># Added by Google         ssh-ed25519 AAAAC3NzaC1lZDI1NTg3f2vasdcascTcwuq8CVppeNDQv85MQ3fsdsa592q86W1  security-team   # Added by Google   ssh-ed25519 AAAAC3NzaC1lZDascacasbI1NTE5AAAAIB7q5ZK6GMNO6lTd90yutRohmGPugoCruTL  paul@LP-291221<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 SSH-\u043a\u043b\u044e\u0447\u0438 \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p><strong>4.3 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong><\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>auditbeat <\/code>\u043d\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b. \u0427\u0442\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0430\u043f\u043a\u0443 <code>.ssh<\/code> \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435.<\/p>\n<pre><code class=\"bash\">- module: file_integrity     paths:     - \/bin     - \/usr\/bin     - \/sbin     - \/usr\/sbin     - \/etc     - \/root            # &lt;--- Add     - \/home\/user\/.ssh  # &lt;--- Add   - module: system     datasets:       - package # Installed, updated, and removed packages<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 <code>authorized_keys<\/code> \u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0439\u0442\u0438 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043d\u043e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438\u0445 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0430\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u00ab\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f\/\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c5\/305\/f4a\/6c5305f4a06a0bebf3506225694a9f68.png\" width=\"800\" height=\"134\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/6c5\/305\/f4a\/6c5305f4a06a0bebf3506225694a9f68.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c5\/305\/f4a\/6c5305f4a06a0bebf3506225694a9f68.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p><strong>4.4 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: Auditd<\/strong> <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 (FIM), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0451 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code>-w \/root\/.ssh -p wa -k rootkey   -w \/home\/user\/.ssh -p wa -k userkey<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430\u0445 <code>\/home\/user\/.ssh\/*<\/code> \u0438 <code>\/root\/.ssh\/*<\/code>.<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0430 auditd:<\/p>\n<pre><code class=\"bash\">type=SYSCALL msg=audit(1637609476.111:15803): arch=c000003e syscall=257  success=yes exit=3 a0=ffffff9c a1=563001182d80 a2=241 a3=1b6 items=2 ppid=15409  pid=15410 auid=1000 uid=1000 gid=1001 euid=1000 suid=1000 fsuid=1000 egid=1001  sgid=1001 fsgid=1001 tty=pts0 ses=50 comm=\"bash\" exe=\"\/usr\/bin\/bash\"  subj==unconfined key=\"userkey\", type=PATH msg=audit(1637609476.111:15803):  item=0 name=\".ssh\/\" inode=526594 dev=08:01 mode=040700 ouid=1000 ogid=1001  rdev=00:00 nametype=PARENT cap_fp=0000000000000000 cap_fi=0000000000000000  cap_fe=0 cap_fver=0, type=PATH msg=audit(1637609476.111:15803): item=1  name=\".ssh\/authorized_keys\" inode=527241 dev=08:01 mode=0100600 ouid=1000  ogid=1001 rdev=00:00 nametype=NORMAL cap_fp=0000000000000000  cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PROCTITLE  msg=audit(1637609476.111:15803): proctitle=\"-bash\"<\/code><\/pre>\n<p><strong>4.5 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: Sysmon <\/strong><\/p>\n<pre><code class=\"xml\">&lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;FileCreate onmatch=\"include\"&gt;         &lt;Rule name=\"TechniqueID=T1098.004,TechniqueName=Account Manipulation: SSH Authorized Keys\" groupRelation=\"or\"&gt;           &lt;TargetFilename condition=\"contains\"&gt;authorized_keys&lt;\/TargetFilename&gt;           &lt;TargetFilename condition=\"contains\"&gt;.ssh&lt;\/TargetFilename&gt;         &lt;\/Rule&gt;       &lt;\/FileCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u0430 \u0444\u0430\u0439\u043b <code>authorized_keys<\/code> \u0435\u0449\u0451 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u044d\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0430. <\/p>\n<pre><code class=\"bash\">echo \"ssh-ed25519 AA ... \" &gt;&gt; \/var\/www\/.ssh\/authorized_keys<\/code><\/pre>\n<pre><code class=\"xml\">&lt;Event&gt;   &lt;System&gt;     &lt;Provider Name=\"Linux-Sysmon\" Guid=\"{ff032593-a8d3-4f13-b0d6-01fc615a0f97}\"\/&gt;     &lt;EventID&gt;11&lt;\/EventID&gt;     &lt;Version&gt;2&lt;\/Version&gt;         &lt;EventRecordID&gt;12463&lt;\/EventRecordID&gt;     &lt;Correlation\/&gt;     &lt;Execution ProcessID=\"20655\" ThreadID=\"20655\"\/&gt;     &lt;Channel&gt;Linux-Sysmon\/Operational&lt;\/Channel&gt;     &lt;Computer&gt;sysmon-test&lt;\/Computer&gt;     &lt;Security UserId=\"0\"\/&gt;   &lt;\/System&gt;   &lt;EventData&gt;     &lt;Data Name=\"RuleName\"&gt;TechniqueID=T1098.004,TechniqueName=Acco&lt;\/Data&gt;         &lt;Data Name=\"ProcessId\"&gt;20667&lt;\/Data&gt;     &lt;Data Name=\"Image\"&gt;\/usr\/bin\/bash&lt;\/Data&gt;     &lt;Data Name=\"TargetFilename\"&gt;\/var\/www\/.ssh\/authorized_keys&lt;\/Data&gt;     &lt;Data Name=\"CreationUtcTime\"&gt;2021-11-24 09:22:36.722&lt;\/Data&gt;     &lt;Data Name=\"User\"&gt;root&lt;\/Data&gt;   &lt;\/EventData&gt; &lt;\/Event&gt;<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b <code>authorized_keys<\/code> \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0417\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u044d\u0442\u043e \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u0441\u043e\u0437\u0434\u0430\u0432 \u0444\u0430\u0439\u043b \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 <code>.ssh<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0432 \u0435\u0433\u043e \u0432 <code>authorized_keys<\/code>.<\/p>\n<pre><code class=\"bash\">echo \"ssh-ed25519 AA ... \" &gt;&gt; \/tmp\/keys  mv \/tmp\/keys \/var\/www\/.ssh\/authorized_keys<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0441\u0441\u044b\u043b\u0430\u044e\u0441\u044c, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/persistence\/T1543.002_CreateModSystemProcess_Systemd.xml\" rel=\"noopener noreferrer nofollow\">T1543.002_CreateModSystemProcess_Systemd.xml<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/persistence\/T1053.003_Cron_Activity.xml\" rel=\"noopener noreferrer nofollow\">T1053.003_Cron_Activity.xml<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/persistence\/T1037_BootLogonInitScripts_CommonDirectories.xml\" rel=\"noopener noreferrer nofollow\">T1037_BootLogonInitScripts_CommonDirectories.xml<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>4.6 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: OSQuery<\/strong> <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 osquery, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c <a href=\"https:\/\/github.com\/fleetdm\/fleet\" rel=\"noopener noreferrer nofollow\">fleet<\/a>, \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 <code>authorized_keys<\/code> \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u0441\u043d\u044d\u043f\u0448\u043e\u0442\u044b \u0441\u043e \u0432\u0441\u0435\u0445 \u0445\u043e\u0441\u0442\u043e\u0432. <\/p>\n<pre><code class=\"sql\">SELECT authorized_keys.*    FROM users    JOIN authorized_keys    USING(uid)<\/code><\/pre>\n<pre><code>+----------+-----------------+----------------------------------+ | username | key             | key_file                         | +----------+-----------------+----------------------------------+ | root     | ssh-ed25519 ... | \/root\/.ssh\/authorized_keys       | | root     | ssh-ed25519 ... | \/root\/.ssh\/authorized_keys       | | www-data | ssh-ed25519 ... | \/var\/www\/.ssh\/authorized_keys    | | www-data | ssh-ed25519 ... | \/var\/www\/.ssh\/authorized_keys    | | user     | ssh-ed25519 ... | \/home\/user\/.ssh\/authorized_keys  | | user     | ssh-ed25519 ... | \/home\/user\/.ssh\/authorized_keys  | | user     | ssh-ed25519 ... | \/home\/user\/.ssh\/authorized_keys  | | user     | ssh-ed25519 ... | \/home\/user\/.ssh\/authorized_keys  | | user     | ssh-ed25519 ... | \/home\/user\/.ssh\/authorized_keys  | | legit    | ssh-ed25519 ... | \/home\/legit\/.ssh\/authorized_keys | | nginx    | ssh-ed25519 ... | \/var\/www\/.ssh\/authorized_keys    | | nginx    | ssh-ed25519 ... | \/var\/www\/.ssh\/authorized_keys    | +----------+-----------------+----------------------------------+<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c SSH-\u043a\u043b\u044e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0434\u043a\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0443 \u0432\u0430\u0441.<\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434\u044b \u0438 \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435<\/strong><\/p>\n<p>\u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0438\u0441\u043a \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>useradd<\/code>.<\/p>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/passwd<\/code>, <code>\/etc\/shadow<\/code>, <code>\/etc\/gshadow<\/code> \u0438 <code>\/etc\/group<\/code>. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <code>authorized_keys<\/code>. \u0414\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c auditd \u0438\/\u0438\u043b\u0438 auditbeat.<\/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\/929952\/\"> https:\/\/habr.com\/ru\/articles\/929952\/<\/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>\u0414\u0430\u043d\u043d\u0430\u044f \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f &#8212; \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e\u0442 Pepe Berba &#8212;\u00a0<a href=\"https:\/\/pberba.github.io\/security\/2021\/11\/23\/linux-threat-hunting-for-persistence-account-creation-manipulation\/\" rel=\"noopener noreferrer nofollow\">Hunting for Persistence in Linux<\/a>.  <\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">! \u0412\u0441\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442\u043e\u0432 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0435\u0440 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0418\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0437\u043b\u043e\u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445 \u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u0437\u0430\u043a\u043e\u043d\u043e\u0434\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443. \u0410\u0432\u0442\u043e\u0440 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435 \u043d\u0435\u0441\u0443\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u043d\u0435\u043f\u0440\u0430\u0432\u043e\u043c\u0435\u0440\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. !  <\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435  <\/h2>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/928244\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <\/a>\u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c <strong>auditd<\/strong> \u0438 <strong>sysmon<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u0445\u043d\u0438\u043a \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0445\u043e\u0441\u0442\u0430\u0445 Linux. \u0412 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<\/li>\n<li>\n<p>\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e: SSH Authorized Keys<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u0442\u0435\u0445\u043d\u0438\u043a \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h2>2 \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438: \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0443\u0447\u0451\u0442\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c  <\/h2>\n<p><strong> 2.1 \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f<\/strong><\/p>\n<p>MITRE: <a href=\"https:\/\/attack.mitre.org\/techniques\/T1136\/001\/\" rel=\"noopener noreferrer nofollow\">https:\/\/attack.mitre.org\/techniques\/T1136\/001\/<\/a><\/p>\n<p>\u0417\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0443\u0447\u0451\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c \u0436\u0435\u0440\u0442\u0432\u044b \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u044d\u043a\u0434\u043e\u0440-\u0432\u0435\u0431-\u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f!<\/p>\n<p>\u041c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">sudo adduser --shell \/bin\/bash --home \/var\/www\/ nginx   sudo usermod -aG sudo nginx<\/code><\/pre>\n<p>\u042d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>nginx<\/code> \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 <code>sudo<\/code>. (\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u043e\u0431\u043c\u0430\u043d\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e <code>nginx <\/code>\u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <code>nginx<\/code>.)<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044c \u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c SSH \u0441 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<pre><code class=\"bash\">mkdir \/var\/www\/.ssh   echo \"ssh-ed25519 AA ... \" &gt; \/var\/www\/.ssh\/authorized_keys<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>nginx@&lt;\u0432\u0437\u043b\u043e\u043c\u0430\u043d\u043d\u044b\u0439_\u0445\u043e\u0441\u0442&gt;<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c root-\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0445\u043e\u0441\u0442\u0443.<\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0442\u0430\u043a \u0438 \u0435\u0451 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f.<\/p>\n<p><strong> 2.2 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u043c\u043e\u0434\u0443\u043b\u0435 auditbeat<\/strong> <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e <code>auditbeat<\/code>, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>event.module: system<\/code> \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <code>process_started<\/code>. \u041e\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u043e \u043f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>event.action<\/code>:<\/p>\n<ul>\n<li>\n<p><code>user_added<\/code>: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0444\u0430\u0439\u043b\u044b <code>passwd <\/code>\u0438 <code>shadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>password_changed<\/code>: \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p><code>user_changes<\/code>: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 sudo<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><\/figure>\n<p><strong>2.3 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432<\/strong><code><strong> \/etc\/shadow<\/strong><\/code><strong>, <\/strong><code><strong>\/etc\/passwd<\/strong><\/code><strong> \u0438 <\/strong><code><strong>\/etc\/group<\/strong><\/code><br \/> \u0417\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>passwd <\/code>\u0438 <code>adduser<\/code>, \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/etc\/gshadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/shadow<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/passwd<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/group<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043b\u0435\u0433\u0438\u0442\u0438\u043c\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>adduser<\/code>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/nshadow<\/code>,<code> \/etc\/passwd.lock<\/code> \u0438 \u0434\u0440\u0443\u0433\u0438\u0445. \u042d\u0442\u043e \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434 <code>passwd <\/code>\u0438 <code>usermod<\/code>.<\/p>\n<p>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>2.4 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 auditd \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong><br \/>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e auditd, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"xml\">-w \/etc\/group -p wa -k etcgroup   -w \/etc\/passwd -p wa -k etcpasswd   -w \/etc\/gshadow -k etcgroup   -w \/etc\/shadow -k etcpasswd  -w \/usr\/sbin\/useradd -p x -k user_modification   -w \/usr\/sbin\/adduser -p x -k user_modification -w \/usr\/bin\/passwd -p x -k passwd_modification<\/code><\/pre>\n<p> \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u044b \u0438 \u0442.\u0434.:  <\/p>\n<pre><code>-w \/etc\/sudoers -p rw -k priv_esc   -w \/etc\/sudoers.d -p rw -k priv_esc  -w \/usr\/sbin\/usermod -p x -k user_modification   -w \/usr\/sbin\/userdel -p x -k user_modification   -w \/usr\/sbin\/groupadd -p x -k group_modification   -w \/usr\/sbin\/groupmod -p x -k group_modification   -w \/usr\/sbin\/addgroup -p x -k group_modification <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435\/\u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>sudoers<\/code><\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/group<\/code> \u0438\u043b\u0438 <code>\/etc\/passwd<\/code><\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 <code>\/etc\/gshadow<\/code> \u0438<code> \/etc\/shadow<\/code><\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <code>useradd <\/code>\u0438 <code>usermod<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043b\u043e\u0433 <code>auditd <\/code>\u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430 <code>\/etc\/passwd<\/code>:<\/p>\n<pre><code class=\"bash\">type=SYSCALL msg=audit(1637599618.765:11426): arch=c000003e syscall=82  success=yes exit=0 a0=7ffeb8ffa160 a1=564262d92020 a2=7ffeb8ffa0d0 a3=2 items=5  ppid=13573 pid=13578 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0  fsgid=0 tty=pts0 ses=19 comm=\"useradd\" exe=\"\/usr\/sbin\/useradd\" subj==unconfined  key=\"etcpasswd\", type=PATH msg=audit(1637599618.765:11426): item=0 name=\"\/etc\/\"  inode=131075 dev=08:01 mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0,  type=PATH msg=audit(1637599618.765:11426): item=1 name=\"\/etc\/\" inode=131075 dev=08:01  mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT cap_fp=0000000000000000  cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PATH  msg=audit(1637599618.765:11426): item=2 name=\"\/etc\/shadow+\" inode=131557  dev=08:01 mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=DELETE  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0,  type=PATH msg=audit(1637599618.765:11426): item=3 name=\"\/etc\/shadow\"  inode=144749 dev=08:01 mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=DELETE  cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PATH  msg=audit(1637599618.765:11426): item=4 name=\"\/etc\/shadow\" inode=131557 dev=08:01  mode=0100640 ouid=0 ogid=42 rdev=00:00 nametype=CREATE cap_fp=0000000000000000  cap_fi=0000000000000000 cap_fe=0 cap_fver=0, type=PROCTITLE  msg=audit(1637599618.765:11426):  proctitle=2F7362696E2F75736572616464002D64002F7661722F7777772F002D67006E67696E78002D73002F62696E2F62617368002D750031303032006E67696E78<\/code><\/pre>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p><code>comm=\"useradd\" exe=\"\/usr\/sbin\/useradd\"<\/code>\u2014 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p><code>name=\"\/etc\/shadow\"<\/code> \u2014 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f<\/p>\n<\/li>\n<li>\n<p><code>key=\"etcpasswd\"<\/code> \u2014 \u0442\u0435\u0433 \u0438\u043b\u0438 \u043a\u043b\u044e\u0447 \u0438\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 auditd<\/p>\n<\/li>\n<li>\n<p><code>proctitle=2F7362...<\/code> \u2014 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>\/sbin\/useradd -d \/var\/www\/ -g nginx -s \/bin\/bash -u 1002 nginx<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>2.4.1 \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0440\u043e UID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong><br \/>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0444\u0430\u0439\u043b<code> \/etc\/passwd<\/code>, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f <code>nginx <\/code>\u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 <code>UID<\/code>, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0441 <code>100X<\/code>.<\/p>\n<pre><code class=\"bash\">messagebus:x:104:105::\/nonexistent:\/usr\/sbin\/nologin   sshd:x:105:65534::\/run\/sshd:\/usr\/sbin\/nologin   _chrony:x:106:112:Chrony daemon,,,:\/var\/lib\/chrony:\/usr\/sbin\/nologin   systemd-coredump:x:999:999:systemd Core Dumper:\/:\/usr\/sbin\/nologin   user:x:1000:1001::\/home\/user:\/bin\/bash   nginx:x:1002:1003:,,,:\/var\/www\/:\/bin\/bash<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Linux-\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 UID, \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0441\u0442\u044c, \u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0438\u0437\u043a\u0438\u0439 UID. <\/p>\n<p><strong>2.5 \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 sysmon \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/strong> <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 MSTIC \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0434\u0432\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/persistence\/T1136.001_CreateLocalAccount_Commands.xml\" rel=\"noopener noreferrer nofollow\">T1136.001_CreateLocalAccount_Commands.xml<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/microsoft\/MSTIC-Sysmon\/blob\/main\/linux\/configs\/attack-based\/discovery\/T1087.001_LocalAccount_Commands.xml\" rel=\"noopener noreferrer nofollow\">T1087.001_LocalAccount_Commands.xml<\/a><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">    &lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;ProcessCreate onmatch=\"include\"&gt;         &lt;Rule name=\"TechniqueID=T1087.001,TechniqueName=Account Discovery: Local Account\" groupRelation=\"or\"&gt;           &lt;CommandLine condition=\"contains\"&gt;\/etc\/passwd&lt;\/CommandLine&gt;           &lt;CommandLine condition=\"contains\"&gt;\/etc\/sudoers&lt;\/CommandLine&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"TechniqueID=T1136.001,TechniqueName=Create Account: Local Account\" groupRelation=\"or\"&gt;           &lt;Image condition=\"end with\"&gt;useradd&lt;\/Image&gt;           &lt;Image condition=\"end with\"&gt;adduser&lt;\/Image&gt;         &lt;\/Rule&gt;       &lt;\/ProcessCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442:<\/p>\n<ul>\n<li>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 <code>\/etc\/passwd<\/code>. \u0427\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0447\u0438\u0442\u0430\u044e\u0449\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 <code>useradd <\/code>\u0438\u043b\u0438 <code>adduser<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u0442\u0430\u0440\u0442 \u0434\u043b\u044f \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u0447\u0435\u0442\u043e\u043a, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0438, \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>useradd\/adduser<\/code>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e<code> T1087.001 <\/code>\u0438\u0449\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 <code>\/etc\/passwd<\/code>. \u0415\u0441\u043b\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>\/etc\/passwd<\/code>, \u043d\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u044f\u0432\u043d\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043e\u0439\u0442\u0438 \u0438 \u044d\u0442\u043e \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 <code>root<\/code>.<\/p>\n<pre><code class=\"bash\">echo \"nginx:x:0:0::\/home\/nginx:\/bin\/bash\" &gt;&gt; \/etc\/\/passwd passwd nginx <\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044c \u0431\u0435\u0437 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0432\u044b\u0448\u0435 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u0438\u0439. \u041c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>useradd <\/code>\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0441\u044b\u043b\u0430\u043b\u0438\u0441\u044c \u043d\u0430 <code>\/etc\/\/passwd<\/code>, \u0447\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 <code>\/etc\/passwd<\/code> \u0438\u0437-\u0437\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u044d\u0448\u0430.<\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code class=\"bash\">-w \/etc\/passwd -p wa -k etcpasswd  <\/code><\/pre>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0438 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 <code>\/etc\/passwd<\/code>, <code>\/etc\/shadow<\/code> \u0438 \u0442.\u043f., \u043d\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u0432 sysmon \u2014 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e: <\/p>\n<pre><code class=\"xml\">    &lt;RuleGroup name=\"\" groupRelation=\"or\"&gt;       &lt;FileCreate onmatch=\"include\"&gt;         &lt;Rule name=\"etcpasswd\" groupRelation=\"or\"&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/passwd&lt;\/TargetFilename&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/shadow&lt;\/TargetFilename&gt;         &lt;\/Rule&gt;         &lt;Rule name=\"etcgroup\" groupRelation=\"or\"&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/group&lt;\/TargetFilename&gt;           &lt;TargetFilename condition=\"contains\"&gt;\/etc\/gshadow&lt;\/TargetFilename&gt;         &lt;\/Rule&gt;       &lt;\/FileCreate&gt;     &lt;\/RuleGroup&gt;<\/code><\/pre>\n<p> \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0441\u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <\/p>\n<pre><code class=\"bash\">vi \/etc\/passwd useradd<\/code><\/pre>\n<p>(\u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>\/etc\/shadow+<\/code>, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442 \u0444\u0430\u0439\u043b <code>\/etc\/shadow<\/code> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.)<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445:<\/p>\n<pre><code class=\"bash\">echo \"&lt;TEXT&gt;\" &gt;&gt; \/etc\/passwd sed -i 's\/BEFORE\/AFTER\/g' \/etc\/passwd<\/code><\/pre>\n<p> \u0425\u0443\u0436\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043c\u044b<\/p>\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-468207","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/468207","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=468207"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/468207\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=468207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=468207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=468207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}