Error managing bytes array while trying to code my first Burp extension

huangapple go评论80阅读模式
英文:

Error managing bytes array while trying to code my first Burp extension

问题

我目前正在尝试用Python编写我的第一个Burp扩展程序,但在处理来自响应的字节数组时出现了错误。我使用了一个可能已过时的教程,其中包括以下代码行:body = response[response_data.getBodyOffset():].tostring(),但在最新的Python版本中,这个方法已被弃用。

我尝试将其替换为新的方法tobytes(),但在编译成Burp时,我仍然遇到相同的错误:AttributeError: 'array.array' object has no attribute 'tobytes'。我在另一个程序中进行了测试,它完美地工作,所以我想知道可能的原因是什么。这可能与Jython不兼容这个新方法有关吗?在这种情况下,错误不应该是与tostring()有关的吗?

你认为这个问题如何?我是否应该尝试降级我的Python版本以使tostring()起作用?

提前感谢你的帮助!

PS:我使用的是最新稳定版的Python(3.10.10)和Jython(2.7.3)。

英文:

I'm currently trying to code my first burp extension in python and I have an error when it comes to managing bytes array which I get from the response. I used a, probably, outdated tutorial which use this line of code : body = response[response_data.getBodyOffset():].tostring() but in the last python version this method is deprecated.

I tried to replace it with the new one tobytes()but when compiling into burp I keep having the same error AttributeError: 'array.array' object has no attribute 'tobytes'. I tried it in another program just to test it and it work perfectly so I'm wondering what could be the cause of this. Can it comes from Jython not compatible with this new method ? In this case shouldn't be the error another one from the tostring() ?
What do you think about it ? Should I just try to downgrade my python version to make tostring() work ?

Thanks in advance for your help !

PS: I'm using the last stable python (3.10.10) and Jython (2.7.3) version,

答案1

得分: 0

Jython 2.7.3 在 Java 中实现了 Python 2.7,因此您不能调用在该 Python 版本中不存在的方法。这就是为什么从 jython.org 的文档链接会带您到 Python 2.7 文档 的原因。

如果 burp 插件只支持 jython,我不确定为什么您要在 python 3.10 中运行该代码。除非您指的是 Java 的 .toBytes() 方法,否则可以参考 这个答案

英文:

Jython 2.7.3 implements Python 2.7 in Java, so you can't call methods that don't exist in that version of Python. This is why the documentation link from jython.org takes you to the Python 2.7 documentation.

I'm not sure why you're running the code in python 3.10 if the burp plugin only supports jython. Unless you're referring to a java .toBytes() method, in which case this answer might help you.

huangapple
  • 本文由 发表于 2023年6月8日 18:01:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76430713.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定