在Python中实现Hexdump
如何在Python 3中获得以下内容?
CAT文件| SIGTOOL –HEX-DUMP | Head -C 2048
我正在尝试读取我创建的.NDB数据库,以检查恶意PHP文件,但是我需要能够在Python中创建文件的六角签名此数据库。
How can I achieve the following in Python 3?
cat file | sigtool –hex-dump | head -c 2048
I’m attempting to read a .ndb database which I have created in order to check for malicious PHP files, however I need to be able to create hex signatures of files in python in order to check against this database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
binascii.hexlify
函数:我将hex_bytes转换为字符串,以便我可以将它们打印出来,但是您可能会忽略,如果您可以使用
bytes
对象,则Hexlify
直接(例如以二进制模式写入文件,或将其直接保存到数据库中)。Try using the
binascii.hexlify
function:I converted the hex_bytes into a string so I could print them out, but you might omit that if you can use the
bytes
object returned byhexlify
directly (e.g. writing it to a file in binary mode, or saving it directly into a database).