{"id":292131,"date":"2019-07-16T15:00:49","date_gmt":"2019-07-16T15:00:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=292131"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=292131","title":{"rendered":"\u0420\u0435\u0446\u0435\u043f\u0442\u044b \u0434\u043b\u044f ELF\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xk\/e_\/v6\/xke_v6gzyavn2y7zh5skzlm3op0.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ELF-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u0444\u043e\u0440\u043c\u0430\u0442 ELF (Execution &amp; Linkable Format) \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 Linux \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 Unix-\u0441\u0438\u0441\u0442\u0435\u043c). \u041d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u043b\u044c\u0444\u0430\u043c\u0438, \u043d\u043e \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u0441\u0431\u043e\u0440\u043d\u0438\u043a\u0430 \u0440\u0435\u0446\u0435\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0438 \u0440\u0435\u0432\u0435\u0440\u0441-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c ELF (\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 <a href=\"http:\/\/www.intezer.com\/executable-linkable-format-101-part1-sections-segments\/\">Executable and Linkable Format 101<\/a>).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u0440\u0438\u0435\u043c\u044b \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 <del>\u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<\/del> \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u044c\u0444\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<blockquote><p>\u2014 \u042f \u0442\u043e\u0436\u0435 \u044d\u043b\u044c\u0444\u2026 \u0421\u0438\u043d\u0438\u0439 \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0439\u2026 \u042d\u043b\u044c\u0444\u044b \u043e\u0447\u0435\u043d\u044c \u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u044b\u2026 \u0421\u0438\u043d\u0438\u0439 \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0439\u2026 \u0410 \u043c\u044b \u044d\u043b\u044c\u0444\u044b!.. \u0421\u0438\u043d\u0438\u0439 \u0432 \u043a\u0440\u0430\u0441\u043d\u044b\u0439\u2026 \u041e\u0442 \u043c\u0430\u0433\u0438\u0438 \u043e\u0434\u043d\u0438 \u0431\u0435\u0434\u044b\u2026<br \/>  (\u0441) \u041c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u043a\u043e\u0440\u043e\u043b\u0435\u0432\u0441\u0442\u0432\u043e \u0411\u0435\u043d\u0430 \u0438 \u0425\u043e\u043b\u043b\u0438<\/p><\/blockquote>\n<p>  <\/p>\n<h1 id=\"instrumenty\">\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b<\/h1>\n<p>  <\/p>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0430 Linux, \u0442\u0430\u043a \u0438 \u043d\u0430 Windows.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0446\u0435\u043f\u0442\u0430\u0445 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 binutils (objcopy, objdump, readelf, strip);<\/li>\n<li>\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"https:\/\/www.radare.org\/r\/\">radare2<\/a>;<\/li>\n<li>hex-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0444\u0430\u0439\u043b\u043e\u0432 (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u043d <a href=\"https:\/\/www.sweetscape.com\/010editor\/\">010Editor<\/a>, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 <a href=\"https:\/\/codisec.com\/veles\/\">Veles<\/a>); <\/li>\n<li>Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/lief.quarkslab.com\/\">LIEF<\/a>;<\/li>\n<li>\u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b (\u0441\u0441\u044b\u043b\u043a\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u0440\u0435\u0446\u0435\u043f\u0442\u0435).<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"testovye-elfy\">\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u044d\u043b\u044c\u0444\u044b<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u00ab\u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e\u00bb \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ELF-\u0444\u0430\u0439\u043b <em>simple<\/em> \u0438\u0437 \u0442\u0430\u0441\u043a\u0430 <a href=\"https:\/\/crackmes.one\/crackme\/5c11e1f333c5d41e58e00579\">nutcake&#8217;s PieIsMyFav<\/a> \u043d\u0430 crackmes.one, \u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c \u00ab\u044d\u043b\u044c\u0444\u0438\u0439\u0441\u043a\u043e\u0433\u043e\u00bb \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430. \u0415\u0441\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u044d\u043b\u044c\u0444\u0430.<\/p>\n<p>  <\/p>\n<p>\u00ab\u0421\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445\u00bb \u044d\u043b\u044c\u0444\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/JonathanSalwan\/binary-samples\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u044d\u043b\u044c\u0444\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c<\/a>;<\/li>\n<li><a href=\"https:\/\/github.com\/radare\/radare2-regressions\/tree\/master\/bins\/elf\">\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u044d\u043b\u044c\u0444\u044b \u0434\u043b\u044f radare2<\/a>;<\/li>\n<li><a href=\"https:\/\/github.com\/MaskRay\/ElfHacks\/\">\u041f\u0440\u043e\u0435\u043a\u0442 ElfHacks \u043d\u0430 Github<\/a> \u2014 \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u044d\u043b\u044c\u0444\u043e\u0432 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438;<\/li>\n<li><a href=\"https:\/\/crackmes.one\">Crackme \u0434\u043b\u044f Unix\/Linux<\/a> \u2014 \u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0445\u0438\u0442\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u0446\u044b.<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"chtenie-poluchenie-informacii\">\u0427\u0442\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/h1>\n<p>  <\/p>\n<h2 id=\"tip-fayla-zagolovok-sekcii\">\u0422\u0438\u043f \u0444\u0430\u0439\u043b\u0430, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0441\u0435\u043a\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0442\u0438\u043f \u0444\u0430\u0439\u043b\u0430 (DYN \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, EXEC \u2014 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439, RELOC \u2014 \u043b\u0438\u043d\u043a\u0443\u0435\u043c\u044b\u0439);<\/li>\n<li>\u0446\u0435\u043b\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 (E_MACHINE \u2014 x86_64, x86, ARM \u0438 \u0442.\u0434.);<\/li>\n<li>\u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (Entry Point);<\/li>\n<li>\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0441\u0435\u043a\u0446\u0438\u044f\u0445.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"010editor\">010Editor<\/h3>\n<p>  <\/p>\n<p>HEX-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 010Editor \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u0414\u043b\u044f ELF-\u0444\u0430\u0439\u043b\u043e\u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, <em>ELF.bt<\/em> \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 <em>Executable<\/em> (\u043c\u0435\u043d\u044e Templates \u2014 Executable).<br \/>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b (entry point) (\u0437\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u0430).<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uz\/f4\/i6\/uzf4i6yhfy9epat61pd4uolvegw.png\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h3 id=\"readelf\">readelf<\/h3>\n<p>  <\/p>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0443 <em>readelf<\/em> \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e\u0431 ELF-\u0444\u0430\u0439\u043b\u0435.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0444\u0430\u0439\u043b\u0430:<br \/> \n<pre><code class=\"bash\">$ readelf -h simple<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">ELF Header:   Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00   Class:                             ELF64   Data:                              2's complement, little endian   Version:                           1 (current)   OS\/ABI:                            UNIX - System V   ABI Version:                       0   Type:                              DYN (Shared object file)   Machine:                           Advanced Micro Devices X86-64   Version:                           0x1   Entry point address:               0x1070   Start of program headers:          64 (bytes into file)   Start of section headers:          14800 (bytes into file)   Flags:                             0x0   Size of this header:               64 (bytes)   Size of program headers:           56 (bytes)   Number of program headers:         11   Size of section headers:           64 (bytes)   Number of section headers:         30   Section header string table index: 29<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0445 \u0438 \u0441\u0435\u043a\u0446\u0438\u044f\u0445:<br \/> \n<pre><code class=\"bash\">$ readelf -l -W simple<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a 32-\u0431\u0438\u0442\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"markdown\">Elf file type is DYN (Shared object file) Entry point 0x1070 There are 11 program headers, starting at offset 64  Program Headers:  Type         Offset   VirtAddr   PhysAddr   FileSiz  MemSiz   Flg Align  PHDR         0x000040 0x00000040 0x00000040 0x000268 0x000268 R   0x8  INTERP       0x0002a8 0x000002a8 0x000002a8 0x00001c 0x00001c R   0x1      [Requesting program interpreter: \/lib64\/ld-linux-x86-64.so.2]  LOAD         0x000000 0x00000000 0x00000000 0x0005f8 0x0005f8 R   0x1000  LOAD         0x001000 0x00001000 0x00001000 0x00026d 0x00026d R E 0x1000  LOAD         0x002000 0x00002000 0x00002000 0x0001b8 0x0001b8 R   0x1000  LOAD         0x002de8 0x00003de8 0x00003de8 0x000258 0x000260 RW  0x1000  DYNAMIC      0x002df8 0x00003df8 0x00003df8 0x0001e0 0x0001e0 RW  0x8  NOTE         0x0002c4 0x000002c4 0x000002c4 0x000044 0x000044 R   0x4  GNU_EH_FRAME 0x002070 0x00002070 0x00002070 0x00003c 0x00003c R   0x4  GNU_STACK    0x000000 0x00000000 0x00000000 0x000000 0x000000 RW  0x10  GNU_RELRO    0x002de8 0x00003de8 0x00003de8 0x000218 0x000218 R   0x1   Section to Segment mapping:   Segment Sections...    00         01     .interp    02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt    03     .init .plt .plt.got .text .fini    04     .rodata .eh_frame_hdr .eh_frame    05     .init_array .fini_array .dynamic .got .got.plt .data .bss    06     .dynamic    07     .note.ABI-tag .note.gnu.build-id    08     .eh_frame_hdr    09         10     .init_array .fini_array .dynamic .got<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u043a\u0446\u0438\u044f\u0445:<br \/> \n<pre><code class=\"bash\">$ readelf -S -W simple<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a 32-\u0431\u0438\u0442\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"markdown\">There are 30 section headers, starting at offset 0x39d0:  Section Headers:   [Nr] Name              Type            Address  Off    Size   ES Flg Lk Inf Al   [ 0]                   NULL            00000000 000000 000000 00      0   0  0   [ 1] .interp           PROGBITS        000002a8 0002a8 00001c 00   A  0   0  1   [ 2] .note.ABI-tag     NOTE            000002c4 0002c4 000020 00   A  0   0  4   [ 3] .note.gnu.build-id NOTE            000002e4 0002e4 000024 00   A  0   0  4   [ 4] .gnu.hash         GNU_HASH        00000308 000308 000024 00   A  5   0  8   [ 5] .dynsym           DYNSYM          00000330 000330 0000d8 18   A  6   1  8   [ 6] .dynstr           STRTAB          00000408 000408 0000a2 00   A  0   0  1   [ 7] .gnu.version      VERSYM          000004aa 0004aa 000012 02   A  5   0  2   [ 8] .gnu.version_r    VERNEED         000004c0 0004c0 000030 00   A  6   1  8   [ 9] .rela.dyn         RELA            000004f0 0004f0 0000c0 18   A  5   0  8   [10] .rela.plt         RELA            000005b0 0005b0 000048 18  AI  5  23  8   [11] .init             PROGBITS        00001000 001000 000017 00  AX  0   0  4   [12] .plt              PROGBITS        00001020 001020 000040 10  AX  0   0 16   [13] .plt.got          PROGBITS        00001060 001060 000008 08  AX  0   0  8   [14] .text             PROGBITS        00001070 001070 0001f2 00  AX  0   0 16   [15] .fini             PROGBITS        00001264 001264 000009 00  AX  0   0  4   [16] .rodata           PROGBITS        00002000 002000 000070 00   A  0   0  8   [17] .eh_frame_hdr     PROGBITS        00002070 002070 00003c 00   A  0   0  4   [18] .eh_frame         PROGBITS        000020b0 0020b0 000108 00   A  0   0  8   [19] .init_array       INIT_ARRAY      00003de8 002de8 000008 08  WA  0   0  8   [20] .fini_array       FINI_ARRAY      00003df0 002df0 000008 08  WA  0   0  8   [21] .dynamic          DYNAMIC         00003df8 002df8 0001e0 10  WA  6   0  8   [22] .got              PROGBITS        00003fd8 002fd8 000028 08  WA  0   0  8   [23] .got.plt          PROGBITS        00004000 003000 000030 08  WA  0   0  8   [24] .data             PROGBITS        00004030 003030 000010 00  WA  0   0  8   [25] .bss              NOBITS          00004040 003040 000008 00  WA  0   0  1   [26] .comment          PROGBITS        00000000 003040 00001c 01  MS  0   0  1   [27] .symtab           SYMTAB          00000000 003060 000630 18     28  44  8   [28] .strtab           STRTAB          00000000 003690 000232 00      0   0  1   [29] .shstrtab         STRTAB          00000000 0038c2 000107 00      0   0  1 Key to Flags:   W (write), A (alloc), X (execute), M (merge), S (strings), l (large)   I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)   O (extra OS processing required) o (OS specific), p (processor specific)<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u0445:<br \/> \n<pre><code class=\"bash\">$ readelf -s -W simple<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0412\u044b\u0432\u043e\u0434 \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0447\u0442\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"markdown\">Symbol table '.dynsym' contains 9 entries:    Num:  Value        Size   Type    Bind    Vis      Ndx Name      0: 00000000   0 NOTYPE  LOCAL  DEFAULT  UND      1: 00000000   0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTable      2: 00000000   0 FUNC    GLOBAL DEFAULT  UND puts@GLIBC_2.2.5 (2)      3: 00000000   0 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.2.5 (2)      4: 00000000   0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (2)      5: 00000000   0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__      6: 00000000   0 FUNC    GLOBAL DEFAULT  UND __isoc99_scanf@GLIBC_2.7 (3)      7: 00000000   0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable      8: 00000000   0 FUNC    WEAK   DEFAULT  UND __cxa_finalize@GLIBC_2.2.5 (2)  Symbol table '.symtab' contains 66 entries:    Num:  Value        Size   Type    Bind    Vis      Ndx Name      0: 00000000   0 NOTYPE  LOCAL  DEFAULT  UND      1: 000002a8   0 SECTION LOCAL  DEFAULT    1      2: 000002c4   0 SECTION LOCAL  DEFAULT    2      3: 000002e4   0 SECTION LOCAL  DEFAULT    3      4: 00000308   0 SECTION LOCAL  DEFAULT    4      5: 00000330   0 SECTION LOCAL  DEFAULT    5      6: 00000408   0 SECTION LOCAL  DEFAULT    6      7: 000004aa   0 SECTION LOCAL  DEFAULT    7      ....     26: 00000000   0 SECTION LOCAL  DEFAULT   26     27: 00000000   0 FILE    LOCAL  DEFAULT  ABS crtstuff.c     28: 000010a0   0 FUNC    LOCAL  DEFAULT   14 deregister_tm_clones     29: 000010d0   0 FUNC    LOCAL  DEFAULT   14 register_tm_clones     30: 00001110   0 FUNC    LOCAL  DEFAULT   14 __do_global_dtors_aux     31: 00004040   1 OBJECT  LOCAL  DEFAULT   25 completed.7389      ....<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u043f\u0446\u0438\u044f <code>-W<\/code> \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0448\u0438\u0440\u0438\u043d\u044b \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, 80 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432).<\/p>\n<p>  <\/p>\n<h3 id=\"lief\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u043a\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u043d\u0430 Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF (\u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 API \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f Python):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary = lief.parse(\"simple.elf\") header = binary.header  print(\"Entry point: %08x\" % header.entrypoint) print(\"Architecture: \", header.machine_type)  for section in binary.sections:     print(\"Section %s - size: %s bytes\" % (section.name, section.size)<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"informaciya-o-kompilyatore\">\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435 \u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 <code>.comment<\/code> \u0438 <code>.note<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"objdump\">objdump<\/h3>\n<p>  <\/p>\n<pre><code class=\"bash\">$ objdump -s --section .comment simple<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">simple:     file format elf64-x86-64  Contents of section .comment:  0000 4743433a 20284465 6269616e 20382e32  GCC: (Debian 8.2  0010 2e302d39 2920382e 322e3000           .0-9) 8.2.0.<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"readelf-1\">readelf<\/h3>\n<p>  <\/p>\n<pre><code class=\"bash\">$ readelf -p .comment simple<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">String dump of section '.comment':   [     0]  GCC: (Debian 8.2.0-9) 8.2.0<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<pre><code class=\"bash\">$ readelf -n simple<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"markdown\">Displaying notes found at file offset 0x000002c4 with length 0x00000020:   Owner                 Data size    Description   GNU                  0x00000010    NT_GNU_ABI_TAG (ABI version tag)     OS: Linux, ABI: 3.2.0  Displaying notes found at file offset 0x000002e4 with length 0x00000024:   Owner                 Data size    Description   GNU                  0x00000014    NT_GNU_BUILD_ID (unique build ID bitstring)     Build ID: dae0509e4edb79719a65af37962b74e4cf2a8c2e<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"lief-1\">LIEF<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"simple\") comment = binary.get_section(\".comment\") print(\"Comment: \", bytes(comment.content)) <\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ya-vychislyu-tebya-po-rpath\">\u042f \u0432\u044b\u0447\u0438\u0441\u043b\u044e \u0442\u0435\u0431\u044f \u043f\u043e\u2026 RPATH<\/h2>\n<p>  <\/p>\n<p>\u042d\u043b\u044c\u0444\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>LD_LIBRARY_PATH<\/code> \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0432\u0448\u0438\u0442\u044c\u00bb \u044d\u0442\u043e\u0442 \u043f\u0443\u0442\u044c \u0432 ELF-\u0444\u0430\u0439\u043b.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <code>.dynamic<\/code> \u0441 \u0442\u0438\u043f\u043e\u043c <code>DT_RPATH<\/code> \u0438\u043b\u0438 <code>DT_RUNPATH<\/code> (\u0441\u043c. \u0433\u043b\u0430\u0432\u0443 <a href=\"https:\/\/docs.oracle.com\/cd\/E26505_01\/html\/E26506\/chapter6-63352.html#chapter3-10898\">Directories Searched by the Runtime Linker<\/a> \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438).<\/p>\n<p>  <\/p>\n<p><strong>\u0418 \u0431\u0443\u0434\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u0435\u043d, \u044e\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043d\u0435 \u00ab\u0441\u043f\u0430\u043b\u0438\u00bb \u0441\u0432\u043e\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430!<\/strong><\/p>\n<p>  <\/p>\n<h3 id=\"kak-poyavlyaetsya-rpath\">\u041a\u0430\u043a \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f RPATH?<\/h3>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f RPATH-\u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u044d\u043b\u044c\u0444\u0435 \u2014 \u043e\u043f\u0446\u0438\u044f <code>-rpath<\/code> \u043b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ gcc -L.\/lib -Wall -Wl,-rpath=\/run\/media\/pablo\/disk1\/projects\/cheat_sheets\/ELF\/lib\/ -o test_rpath.elf bubble_main.c -lbubble<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <code>.dynamic<\/code> RPATH-\u0437\u0430\u043f\u0438\u0441\u044c \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>\/run\/media\/pablo\/disk1\/projects\/cheat_sheets\/ELF\/lib\/<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"readelf-2\">readelf<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 <code>.dynamic<\/code> (\u0441\u0440\u0435\u0434\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0438 RPATH) \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ readelf -d test_rpath.elf <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0447\u0442\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"markdown\">Dynamic section at offset 0x2dd8 contains 28 entries:   Tag        Type                         Name\/Value  0x0000000000000001 (NEEDED)             Shared library: [libbubble.so]  0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]  0x000000000000000f (RPATH)              Library rpath: [\/run\/media\/pablo\/disk1\/projects\/cheat_sheets\/ELF\/lib\/]  0x000000000000000c (INIT)               0x1000  0x000000000000000d (FINI)               0x11c8 ....<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"lief-2\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c RPATH-\u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u044d\u043b\u044c\u0444\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief from lief.ELF import DYNAMIC_TAGS  elf = lief.parse(\"test_rpath.elf\")  if elf.has(DYNAMIC_TAGS.RPATH):     rpath = next(filter(lambda x: x.tag == DYNAMIC_TAGS.RPATH, elf.dynamic_entries))     for path in rpath.paths:         print(path) else:     print(\"No RPATH in ELF\") <\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/cd\/E26505_01\/html\/E26506\/chapter6-42444.html\">\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0441\u0435\u043a\u0446\u0438\u044e .dynamic<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"proverka-elfa-na-bezopasnost\">\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044d\u043b\u044c\u0444\u0430 \u043d\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/www.trapkit.de\/tools\/checksec.html\">checksec.sh<\/a> \u043e\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f Tobias Klein (\u0430\u0432\u0442\u043e\u0440\u0430 \u043a\u043d\u0438\u0433\u0438 <a href=\"https:\/\/nostarch.com\/bughunter\">A Bug Hunter&#8217;s Diary<\/a>) \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0441\u044f \u0441 2011 \u0433\u043e\u0434\u0430. \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f ELF-\u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043e\u043f\u0446\u0438\u0439 RelRO (Read Only Relocations), NX (Non-Executable Stack), Stack Canaries, PIE (Position Independent Executables) \u0438 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u0442\u0438\u043b\u0438\u0442\u0443 readelf.<\/p>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 \u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0435 Python \u0438 LIEF (\u0447\u0443\u0442\u044c \u043a\u043e\u0440\u043e\u0447\u0435 \u043f\u0440\u0430\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/dsec\/blog\/433108\/\">separate-code<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief from lief.ELF import DYNAMIC_TAGS, SEGMENT_TYPES  def filecheck(filename):     binary = lief.parse(filename)      # check RELRO     if binary.has(SEGMENT_TYPES.GNU_RELRO):         print(\"+ Full RELRO\") if binary.has(DYNAMIC_TAGS.BIND_NOW) else print(\"~ Partial RELRO\")     else:         print(\"- No RELRO\")                  # check for stack canary support     print(\"+ Canary found\") if binary.has_symbol(\"__stack_chk_fail\") else print(\"- No canary found\")      # check for NX support (check X-flag for GNU_STACK-segment)     print(\"+ NX enabled\") if binary.has_nx else print(\"- NX disabled\")      # check for PIE support     print(\"+ PIE enabled\") if binary.is_pie else print(\"- No PIE\")      # check for rpath \/ run path     print(\"+ RPATH\") if binary.has(DYNAMIC_TAGS.RPATH) else print(\"- No RPATH\")     print(\"+ RUNPATH\")if binary.has(DYNAMIC_TAGS.RUNPATH) else print(\"- No RUNPATH\")      # check separate-code option     if set(binary.get_section('.text').segments) == set(binary.get_section('.rodata').segments):         print(\"- Not Separated Code Sections\")     else:         print(\"+ Separated Code Sections\")  filecheck('test_rpath.elf')<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"syroy-kod-iz-elfa-binary-from-elf\">\u00ab\u0421\u044b\u0440\u043e\u0439 \u043a\u043e\u0434\u00bb \u0438\u0437 \u044d\u043b\u044c\u0444\u0430 (binary from ELF)<\/h2>\n<p>  <\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u00ab\u044d\u043b\u044c\u0444\u0438\u0439\u0441\u043a\u0438\u0435 \u043e\u0434\u0451\u0436\u0438\u00bb \u0432 \u0432\u0438\u0434\u0435 ELF-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0430 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u00ab\u0433\u043e\u043b\u044b\u0439\u00bb \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"objcopy\">objcopy<\/h3>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>objcopy<\/em> \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u043e \u0442\u0435\u043c, \u043a\u0442\u043e \u043f\u0438\u0448\u0435\u0442 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ objcopy -O binary -S -g simple.elf simple.bin<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><code>-S<\/code> \u2014 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438;<\/li>\n<li><code>-g<\/code> \u2014 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"lief-3\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u041d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0433\u0438\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u0438 \u0441\u043b\u0435\u043f\u0438\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0431\u0438\u043d\u0430\u0440\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief from lief.ELF import SECTION_FLAGS, SECTION_TYPES  binary = lief.parse(\"test\") end_addr = 0 data = []  for section in filter(lambda x: x.has(SECTION_FLAGS.ALLOC) and                                 x.type != SECTION_TYPES.NOBITS,                       binary.sections):     if 0 &lt; end_addr &lt; section.virtual_address:         align_bytes = b'\\x00' * (section.virtual_address - end_addr)         data.append(align_bytes)              data.append(bytes(section.content))     end_addr = section.virtual_address + section.size  with open('test.lief.bin', 'wb') as f:     for d_bytes in data:         f.write(d_bytes)<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"mangled---demangled-imena-funkciy\">Mangled \u2014 demangled \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h2>\n<p>  <\/p>\n<p>\u0412 ELF-\u0430\u0445, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0421++ \u043a\u043e\u0434\u0430, \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b (\u043c\u0430\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b) \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/radare\/radare2-regressions\/blob\/master\/bins\/elf\/demangle-test-cpp\">\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u044d\u043b\u044c\u0444<\/a><\/p>\n<p>  <\/p>\n<h3 id=\"nm\">nm<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043c\u0451\u043d \u0432 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <a href=\"https:\/\/sourceware.org\/binutils\/docs\/binutils\/nm.html\">nm<\/a> \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 binutils: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># \u0422\u0443\u0442 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043c\u0430\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 $ nm -D demangle-test-cpp      ...       U _Unwind_Resume       U _ZdlPv       U _Znwm       U _ZSt17__throw_bad_allocv       U _ZSt20__throw_length_errorPKc  # \u0422\u0443\u0442 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0432\u0438\u0434\u0435 $ nm -D --demangle demangle-test-cpp       ...       U _Unwind_Resume       U operator delete(void*)       U operator new(unsigned long)       U std::__throw_bad_alloc()       U std::__throw_length_error(char const*)<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-4\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0438\u043c\u0451\u043d \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u0434\u0435\u043c\u0430\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"demangle-test-cpp\") for symb in binary.symbols:     print(symb.name, symb.demangled_name)<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"sborka-zapis-modifikaciya-elfa\">\u0421\u0431\u043e\u0440\u043a\u0430, \u0437\u0430\u043f\u0438\u0441\u044c, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u044d\u043b\u044c\u0444\u0430<\/h1>\n<p>  <\/p>\n<h2 id=\"elf-bez-metainformacii\">\u042d\u043b\u044c\u0444 \u0431\u0435\u0437 \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043e \u0438 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0438\u043a\u0438\u0439 \u043c\u0438\u0440, \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u2014 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432;<\/li>\n<li>\u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2014 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u0434\u043b\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0447\u0443\u0442\u044c \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0440\u0435\u0432\u0435\u0440\u0441);<\/li>\n<li>\u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0435\u043a\u0446\u0438\u0439 \u2014 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0435\u0451 \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0438\u0435 \u0447\u0443\u0442\u044c \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u0440\u0435\u0432\u0435\u0440\u0441).<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"udalenie-simvolnoy-informacii\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0421\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0411\u0435\u0437 \u043d\u0435\u0451 \u0440\u0435\u0432\u0435\u0440\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"strip\">strip<\/h3>\n<p>  <\/p>\n<p>\u0412 \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 <a href=\"https:\/\/www.sourceware.org\/binutils\/docs\/binutils\/strip.html\">strip<\/a> \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 binutils. \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<br \/> \n<pre><code class=\"bash\">$ strip -s simple<\/code><\/pre>\n<\/li>\n<li>\u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<br \/> \n<pre><code class=\"bash\">$ strip --strip-unneeded libsimple.so<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"sstrip\">sstrip<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430) \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 sstrip \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 <a href=\"https:\/\/github.com\/BR903\/ELFkickers\">ELFkickers<\/a>. \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ sstrip -z simple<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-5\">LIEF<\/h3>\n<p>  <\/p>\n<p>C \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 strip (\u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u2014 \u0441\u0435\u043a\u0446\u0438\u044f <code>.symtab<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"simple\") binary.strip() binary.write(\"simple.stripped\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"udalenie-tablicy-sekciy\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u043d\u0430\u043b\u0438\u0447\u0438\u0435\/\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439 \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0435\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439 \u0440\u0435\u0432\u0435\u0440\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<br \/>  \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 LIEF \u043f\u043e\u0434 Python \u0438 <a href=\"https:\/\/github.com\/lief-project\/LIEF\/blob\/master\/examples\/python\/elf_remove_section_table.py\">\u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u043a\u0446\u0438\u0439<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"simple\") binary.header.numberof_sections = 0 binary.header.section_header_offset = 0 binary.write(\"simple.modified\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"izmenenie-i-udalenie-rpath\">\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 RPATH<\/h2>\n<p>  <\/p>\n<h3 id=\"chrpath-patchelf\">chrpath, PatchELF<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f RPATH \u043f\u043e\u0434 Linux \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438 <em>chrpath<\/em> (\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u0432) \u0438\u043b\u0438 <a href=\"https:\/\/nixos.org\/patchelf.html\">PatchELF<\/a>.<\/p>\n<p>  <\/p>\n<ul>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c RPATH:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ chrpath -r \/opt\/my-libs\/lib:\/foo\/lib test_rpath.elf<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438\u043b\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ patchelf --set-rpath \/opt\/my-libs\/lib:\/foo\/lib test_rpath.elf<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c RPATH:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ chrpath -d test_rpath.elf<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438\u043b\u0438 <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ patchelf --shrink-rpath test_rpath.elf<\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"lief-6\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LIEF \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0442\u0430\u043a \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c RPATH-\u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p>  <\/p>\n<ul>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c RPATH:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary  = lief.parse(\"test_rpath.elf\") rpath = next(filter(lambda x: x.tag == lief.ELF.DYNAMIC_TAGS.RPATH, binary.dynamic_entries)) rpath.paths = [\"\/opt\/my-lib\/here\"] binary.write(\"test_rpath.patched\")<\/code><\/pre>\n<p>  <\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c RPATH:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary  = lief.parse(\"test_rpath.elf\") binary.remove(lief.ELF.DYNAMIC_TAGS.RPATH) binary.write(\"test_rpath.patched\")<\/code><\/pre>\n<p>  <\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"obfuskaciya-simvolnoy-informacii\">\u041e\u0431\u0444\u0443\u0441\u043a\u0430\u0446\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0432\u0435\u0440\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u043b\u044c\u0444 <em>crackme01_32bit<\/em> \u0438\u0437 <a href=\"https:\/\/crackmes.one\/crackme\/5ab77f5e33c5d40ad448c78b\">crackme01 by seveb<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"https:\/\/github.com\/lief-project\/LIEF\/blob\/master\/examples\/python\/elf_symbol_obfuscation.py\">\u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary = lief.parse(\"crackme01_32bit\")  for i, symb in enumerate(binary.static_symbols):     symb.name = \"zzz_%d\" % i  binary.write(\"crackme01_32bit.obfuscated\")<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ readelf -s crackme01_32bit.obfuscated ... Symbol table '.symtab' contains 78 entries:    Num:    Value  Size Type    Bind   Vis      Ndx Name      0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND zzz_0      1: 08048154     0 SECTION LOCAL  DEFAULT    1 zzz_1      2: 08048168     0 SECTION LOCAL  DEFAULT    2 zzz_2      3: 08048188     0 SECTION LOCAL  DEFAULT    3 zzz_3      4: 080481ac     0 SECTION LOCAL  DEFAULT    4 zzz_4      5: 080481d0     0 SECTION LOCAL  DEFAULT    5 zzz_5      6: 080482b0     0 SECTION LOCAL  DEFAULT    6 zzz_6      7: 0804835a     0 SECTION LOCAL  DEFAULT    7 zzz_7      8: 08048378     0 SECTION LOCAL  DEFAULT    8 zzz_8      9: 080483b8     0 SECTION LOCAL  DEFAULT    9 zzz_9     10: 080483c8     0 SECTION LOCAL  DEFAULT     10 zzz_10 ...<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"podmena-funkciy-cherez-pltgot\">\u041f\u043e\u0434\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 PLT\/GOT<\/h2>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043a\u0430\u043a <a href=\"http:\/\/phrack.org\/issues\/56\/7.html\">ELF PLT INFECTION<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0431\u044b \u043d\u0435 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u0438\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u0442\u0435\u043c\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/106107\/\">\u041f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 ELF-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445<\/a><\/li>\n<li><a href=\"https:\/\/lief.quarkslab.com\/doc\/latest\/tutorials\/05_elf_infect_plt_got.html\">Infecting the plt\/got with LIEF<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"izmenit-tochku-vhoda\">\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430<\/h2>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0430\u0442\u0447\u0435\u0439, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0445\u0443\u043a\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0439 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0443 \u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u043b\u044c\u0444\u0430 crackme01_32bit \u0438\u0437 <a href=\"https:\/\/crackmes.one\/crackme\/5ab77f5e33c5d40ad448c78b\">crackme01 by seveb<\/a><\/p>\n<p>  <\/p>\n<h3 id=\"radare2\">radare2<\/h3>\n<p>  <\/p>\n<p>radare2 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 (\u043e\u043f\u0446\u0438\u044f <code>-w<\/code>) \u2014 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0432\u043d\u0435\u0441\u0435\u043d\u044b \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ .\/crackme01_32bit Please enter the secret number: ^C  $ r2 -w -nn crackme01_32bit [0x00000000]&gt; .pf.elf_header.entry=0x0804860D [0x00000000]&gt; q  $ .\/crackme01_32bit Nope.<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-7\">LIEF<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary = lief.parse(\"crackme01_32bit\") header = binary.header header.entrypoint = 0x0804860D binary.write(\"crackme01_32bit.patched\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"patching-koda\">\u041f\u0430\u0442\u0447\u0438\u043d\u0433 \u043a\u043e\u0434\u0430<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u043a\u0440\u044f\u043a\u043c\u0438 <a href=\"https:\/\/crackmes.one\/crackme\/5ccecc7e33c5d4419da559b3\">novn91&#8217;s crackmepal<\/a>. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ .\/crackmeMario usage &lt;password&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">.\/crackmeMario qwerty try again pal.<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0430\u0442\u0447, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u00abgood job! now keygen me!\u00bb<\/p>\n<p>  <\/p>\n<h3 id=\"radare2-1\">radare2<\/h3>\n<p>  <\/p>\n<p>radare2 \u0443\u043c\u0435\u0435\u0442 \u043f\u0430\u0442\u0447\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0430\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0430\u0442\u0447\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\"># Rapatch for https:\/\/crackmes.one\/crackme\/5ccecc7e33c5d4419da559b3 !echo Patching crackme 0x115D : jmp 0x1226<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0442\u0447 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ r2 -P patch.txt crackmeMario<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u043f\u0430\u0442\u0447\u0438\u043d\u0433 \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 radare2:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/rayoflightz.github.io\/linux\/assembly\/2019\/03\/26\/Binary-patching-using-radare2.html\">Binary Patching Using Radare2 by wolfshirtz<\/a><\/li>\n<li><a href=\"https:\/\/monosource.gitbooks.io\/radare2-explorations\/content\/tut1\/tut1_-_simple_patch.html\">Radare2 Explorations. Tutorial 1 \u2014 Simple Patch<\/a><\/li>\n<li><a href=\"https:\/\/scriptdotsh.com\/index.php\/2018\/08\/13\/reverse-engineering-patching-binaries-with-radare2-arm-aarch64\/\">Ground Zero: Part 3-2 \u2013 Reverse Engineering \u2013 Patching Binaries with Radare2 \u2013 ARM64<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"lief-8\">LIEF<\/h3>\n<p>  <\/p>\n<p>LIEF \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0430\u0442\u0447\u0438\u0442\u044c \u044d\u043b\u044c\u0444 (\u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b) \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u041f\u0430\u0442\u0447 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0438\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"crackmeMario\") binary.patch_address(0x115D, bytearray(b\"\\xe9\\xc4\\x00\\x00\\x00\")) binary.write(\"crackmeMario.patched\")<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0442\u0447\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ .\/crackmeMario.patched good job! now keygen me!<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"dobavit-sekciyu-v-elf\">\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e \u0432 ELF<\/h2>\n<p>  <\/p>\n<h3 id=\"objcopy-1\">objcopy<\/h3>\n<p>  <\/p>\n<p><em>objcopy<\/em> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e, \u043d\u043e \u044d\u0442\u0430 \u0441\u0435\u043a\u0446\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043d\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0443 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u041e\u0417\u0423 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ objcopy --add-section .testme=data.zip \\    --set-section-flags .testme=alloc,contents,load,readonly \\    --change-section-address .testme=0x08777777 \\     simple simple.patched.elf<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-9\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LIEF \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0435\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 (\u0444\u043b\u0430\u0433 <strong><code>loaded=True<\/code><\/strong>) \u0432 \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f ELF:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary  = lief.parse(\"simple\") data = bytearray(b\"\\xFF\" * 16)  section = lief.ELF.Section(\".testme\", lief.ELF.SECTION_TYPES.PROGBITS) section += lief.ELF.SECTION_FLAGS.EXECINSTR section += lief.ELF.SECTION_FLAGS.ALLOC section.content = data    binary.add(section, loaded=True) binary.write(\"simple.testme.lief\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"izmenit-sekciyu\">\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e<\/h2>\n<p>  <\/p>\n<h3 id=\"objcopy-2\">objcopy<\/h3>\n<p>  <\/p>\n<p><em>objcopy<\/em> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438 \u0444\u043b\u0430\u0433\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ objcopy --update-section .testme=patch.bin \\     --change-section-address .testme=0x08999999     simple simple.testme.elf<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-10\">LIEF<\/h3>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary  = lief.parse(\"simple\") data = bytearray(b\"\\xFF\" * 17)  section = binary.get_section(\".text\") section.content = data    binary.write(\"simple.patched\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"udalit-sekciyu\">\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e<\/h2>\n<p>  <\/p>\n<h3 id=\"objcopy-3\">objcopy<\/h3>\n<p>  <\/p>\n<p><em>objcopy<\/em> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e \u043f\u043e \u0438\u043c\u0435\u043d\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ objcopy --remove-section .testme simple.testme.elf simple.no_testme.elf<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-11\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief binary = lief.parse(\"simple.testme.elf\") binary.remove_section(\".testme\") binary.write(\"simple.no_testme\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"elf-konteyner\">\u042d\u043b\u044c\u0444-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/h2>\n<p>  <\/p>\n<p>\u0420\u0435\u0446\u0435\u043f\u0442 \u043d\u0430\u0432\u0435\u044f\u043d \u0441\u0442\u0430\u0442\u044c\u0451\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/neobit\/blog\/332918\/\">\u0413\u0440\u0435\u043c\u043b\u0438\u043d\u044b \u0438 ELF\u0438\u0439\u0441\u043a\u0430\u044f \u043c\u0430\u0433\u0438\u044f: \u0430 \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 ELF-\u0444\u0430\u0439\u043b \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440?<\/a>. \u0412\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 man\u2019\u044b \u043f\u0440\u043e \u0443\u0442\u0438\u043b\u0438\u0442\u0443 <a href=\"https:\/\/docs.oracle.com\/cd\/E36784_01\/html\/E36870\/elfwrap-1.html\">elfwrap<\/a> \u0440\u043e\u0434\u043e\u043c \u0438\u0437 Solaris, \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 ELF-\u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0444\u043e\u0440\u043c\u0430\u0442 ELF \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043d\u0430 Python \u0438 LIEF.<br \/>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LIEF \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043b\u044c\u0444-\u0444\u0430\u0439\u043b c \u043d\u0443\u043b\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0435\u0439 \u043f\u043e\u043c\u043e\u0447\u044c \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 ELF-\u0448\u0430\u0431\u043b\u043e\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ echo \"\" | gcc -m32 -fpic -o empty.o -c -xc - $ gcc -m32 -shared -o libempty.so empty.o<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary = lief.parse(\"libempty.so\") filename = \"crackme.zip\" data = open(filename, 'rb').read()  # Add section with zip-archive as content section = lief.ELF.Section() section.content = data section.name = \".%s\"%filename binary.add(section, loaded=True)     # Add symbol as a reference to zip-archive symb = lief.ELF.Symbol() symb.type = lief.ELF.SYMBOL_TYPES.OBJECT symb.binding = lief.ELF.SYMBOL_BINDINGS.GLOBAL symb.size = len(data) symb.name = filename symb.value = section.virtual_address binary.add_static_symbol(symb)  binary.write(\"libdata.crackme.container\")<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"elf-s-pricepom\">\u042d\u043b\u044c\u0444 \u00ab\u0441 \u043f\u0440\u0438\u0446\u0435\u043f\u043e\u043c\u00bb<\/h2>\n<p>  <\/p>\n<p>ELF-\u0444\u043e\u0440\u043c\u0430\u0442 \u043d\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0435, \u043d\u043e \u043d\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u043d\u0438 \u0432 \u043e\u0434\u0438\u043d \u0441\u0435\u0433\u043c\u0435\u043d\u0442. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435 ELF-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f <em>\u0447\u0442\u043e-\u0442\u043e<\/em>. \u042d\u0442\u043e <em>\u0447\u0442\u043e-\u0442\u043e<\/em> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0432 \u041e\u0417\u0423 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438, \u043d\u043e \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u0438 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044d\u0442\u043e <em>\u0447\u0442\u043e-\u0442\u043e<\/em> \u043c\u043e\u0436\u043d\u043e \u0441 \u0434\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c. <\/p>\n<p>  <\/p>\n<ul>\n<li><em>IDA Pro \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435<\/em><\/li>\n<\/ul>\n<p>  <\/p>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0444\u0430\u0439\u043b\u0430 \u00ab\u0441 \u043f\u0440\u0438\u0446\u0435\u043f\u043e\u043c\u00bb<\/em><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rr\/br\/sk\/rrbrsktjs_p8l7fmdfq7t4mejns.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<h3 id=\"radare2-2\">radare2<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u00ab\u043f\u0440\u0438\u0446\u0435\u043f\u0430\u00bb \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ radare2 test.elf [0x00001040]&gt; ?v $s 0x40c1 [0x00001040]&gt; iZ 14699<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"readelf-3\">readelf<\/h3>\n<p>  <\/p>\n<p><em>readelf<\/em> \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u00ab\u043f\u0440\u0438\u0446\u0435\u043f\u0430\u00bb, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">$ ls -l test.elf  # \u0420\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 16577 \u0431\u0430\u0439\u0442  $ readelf -h test.elf Start of section headers    e_shoff     14704 Size of section headers     e_shentsize 64 Number of section headers   e_shnum     29  # \u0420\u0430\u0437\u043c\u0435\u0440 ELF-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: e_shoff + ( e_shentsize * e_shnum ) = 16560<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"lief-12\">LIEF<\/h3>\n<p>  <\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 LIEF \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u00ab\u043f\u0440\u0438\u0446\u0435\u043f\u0430\u00bb, \u0442\u0430\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e. \u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c LIEF \u0432\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import lief  binary  = lief.parse(\"test\")  # check if overlay exists print('ELF has overlay data') if binary.has_overlay else print(\"No overlay data\")  # add overlay data to ELF data = bytearray(b'\\xFF'*17) binary.overlay = data  binary.write('test.overlay')<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"elf-iz-pustoty-elf-from-scratch\">\u042d\u043b\u044c\u0444 \u0438\u0437 \u043f\u0443\u0441\u0442\u043e\u0442\u044b (ELF from scratch)<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e ELF-\u0444\u0430\u0439\u043b\u0430 \u00ab\u0432\u0440\u0443\u0447\u043d\u0443\u044e\u00bb \u2014 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u0449\u0438\u043a\u0430 \u043f\u043e\u0434 \u043e\u0431\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u00abELF from scratch\u00bb:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/statusfailed\/elf-from-scratch\">\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 Github<\/a><\/li>\n<li>\u0421\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/www.conradk.com\/codebase\/2017\/05\/28\/elf-from-scratch\/\">Elf from scratch<\/a><\/li>\n<li>\u0412\u0435\u0442\u043a\u0430 <a href=\"https:\/\/github.com\/lief-project\/LIEF\/tree\/elf_from_scratch\">elf_from_scratch<\/a> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438 \u0431\u043b\u0430\u0433\u043e\u0442\u0432\u043e\u0440\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u043f\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0435\u0431\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 ELF.<\/p>\n<p>  <\/p>\n<h2 id=\"samyy-malenkiy-elf\">\u0421\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u044d\u043b\u044c\u0444<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0441 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u044d\u043b\u044c\u0444\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"http:\/\/www.muppetlabs.com\/~breadbox\/software\/tiny\/teensy.html\">A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux<\/a> <\/li>\n<li><a href=\"http:\/\/www.muppetlabs.com\/~breadbox\/software\/tiny\/somewhat.html\">A Whirlwind Tutorial on Creating Somewhat Teensy ELF Executables for Linux<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/137706\/\">\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ELF<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u044d\u043b\u044c\u0444\u0430 \u0432 \u041e\u0421 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 ELF\u2019\u0430 (\u043a\u043e\u0434 \u0432\u0437\u044f\u0442 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">; tiny.asm    BITS 32       org     0x00010000      db      0x7F, \"ELF\"             ; e_ident      dd      1                                       ; p_type      dd      0                                       ; p_offset      dd      $$                                      ; p_vaddr       dw      2                       ; e_type        ; p_paddr      dw      3                       ; e_machine      dd      _start                  ; e_version     ; p_filesz      dd      _start                  ; e_entry       ; p_memsz      dd      4                       ; e_phoff       ; p_flags   _start:      mov     bl, 42                  ; e_shoff       ; p_align      xor     eax, eax      inc     eax                     ; e_flags      int     0x80      db      0      dw      0x34                    ; e_ehsize      dw      0x20                    ; e_phentsize      db      1                       ; e_phnum                                      ; e_shentsize                                      ; e_shnum                                      ; e_shstrndx   filesize      equ     $ - $$<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c ELF \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c\u2026 <strong>45 \u0431\u0430\u0439\u0442<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">  $ nasm -f bin -o a.out tiny.asm   $ chmod +x a.out   $ .\/a.out ; echo $?   42   $ wc -c a.out        45 a.out<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"elf-po-shablonu\">\u042d\u043b\u044c\u0444 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u044c\u0444\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438 (\u0441\u043c. \u0440\u0435\u0446\u0435\u043f\u0442 \u00ab\u042d\u043b\u044c\u0444-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u00bb):<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0432\u0437\u044f\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 ELF-\u0444\u0430\u0439\u043b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430;<\/li>\n<li>\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0435\u043a\u0446\u0438\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u043a\u0446\u0438\u0438;<\/li>\n<li>\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (\u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430, \u0444\u043b\u0430\u0433\u0438).<\/li>\n<\/ul>\n<p>  <\/p>\n<h1 id=\"vmesto-zaklyucheniya\">\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044e, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043e\u0434\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 LIEF. \u041d\u043e \u0442\u0430\u043a \u043d\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u2014 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ELF-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b \u0437\u0434\u0435\u0441\u044c \u2014 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<p>  <\/p>\n<h1 id=\"ssylki-i-literatura\">\u0421\u0441\u044b\u043b\u043a\u0438 \u0438 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/h1>\n<p>  <\/p>\n<ul>\n<li><a href=\"http:\/\/www.skyfree.org\/linux\/references\/ELF_Format.pdf\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 ELF<\/a><\/li>\n<li><a href=\"https:\/\/docs.oracle.com\/cd\/E23824_01\/html\/819-0690\/chapter6-46512.html#scrolltoc\">\u0415\u0449\u0451 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Oracle<\/a><\/li>\n<li><a href=\"https:\/\/www.radare.org\/doc\/elf-tutorial\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 ELF\u2019\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c radare2<\/a><\/li>\n<li><a href=\"https:\/\/lief.quarkslab.com\/doc\/latest\/index.html\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/lief-project\/LIEF\/tree\/master\/examples\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LIEF<\/a><\/li>\n<li>\u041a\u043d\u0438\u0433\u0430 \u00abPRACTICAL BINARY ANALYSIS\u00bb, Dennis Andriesse<\/li>\n<li>\u041a\u043d\u0438\u0433\u0430 \u00abLearning Linux Binary Analysis\u00bb, Ryan &#171;elfmaster&#187; O&#8217;Neill<\/li>\n<\/ul>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <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\/company\/inforion\/blog\/460247\/\"> https:\/\/habr.com\/ru\/company\/inforion\/blog\/460247\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xk\/e_\/v6\/xke_v6gzyavn2y7zh5skzlm3op0.jpeg\" alt=\"image\"><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ELF-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 (\u0444\u043e\u0440\u043c\u0430\u0442 ELF (Execution &amp; Linkable Format) \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 Linux \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 Unix-\u0441\u0438\u0441\u0442\u0435\u043c). \u041d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u043b\u044c\u0444\u0430\u043c\u0438, \u043d\u043e \u043d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0438 \u0441\u0431\u043e\u0440\u043d\u0438\u043a\u0430 \u0440\u0435\u0446\u0435\u043f\u0442\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0438 \u0440\u0435\u0432\u0435\u0440\u0441-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c ELF (\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 <a href=\"http:\/\/www.intezer.com\/executable-linkable-format-101-part1-sections-segments\/\">Executable and Linkable Format 101<\/a>).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u0440\u0438\u0435\u043c\u044b \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 <del>\u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<\/del> \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u044c\u0444\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b.<\/p>\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-292131","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292131","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=292131"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292131\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}