Scapy 在嗅探数据包后显示数据包内容 - UnicodeEncodeError

发布于 2025-01-18 10:42:14 字数 657 浏览 4 评论 0原文

我想每次收到它们时都会嗅探伪像连接消息并打印以安装邮件。因此,我使用了Scapy 嗅探方法。每次收到连接 frame时,都会显示以下错误。 连接 -message的格式正确,在Wireshark中可见。每次收到这样的框架时,嗅探方法都会流产。如果我用Wireshark导出框架,并使用SCAPY读取.pcap-file,则框架将正确显示。你有什么建议吗?我目前正在使用Python 3.8.10和Scapy版本2.4.5rc1.dev205。谢谢!

UnicodeCodeError:“ Latin-1”编解码器无法编码字符'\ u0797'位置595:不在范围内(256)

def update_connect_load(pkt): 
    pkt.show2() 

def stopFilter(x):
    return False

sniff(
    filter=f"ether src {mac_address}",
    store=0,
    count=-1,
    prn=update_connect_load,
    iface=iface,
    stop_filter=stopFilter,
)`

尝试编码PRN功能中的Paket,但这无效。还尝试使用DCERPC()解析数据包,但这也无效。

I want to sniff ProfiNet Connect Messages and print them to console every time i receive them. Herefore i used the Scapy sniff method. Every time a Connect-Frame is received the following error is displayed. The Connect-Message is in correct format and is visible in Wireshark. The sniff-method aborts every time such a frame is received. If i export the frame with wireshark and read the .pcap-file with scapy the frame is correctly displayed. Do you have any suggestions? I'm currently using Python 3.8.10 and scapy version 2.4.5rc1.dev205. Thanks!

UnicodeEncodeError: 'latin-1' codec can't encode character '\u0797' in position 595: ordinal not in range(256)

def update_connect_load(pkt): 
    pkt.show2() 

def stopFilter(x):
    return False

sniff(
    filter=f"ether src {mac_address}",
    store=0,
    count=-1,
    prn=update_connect_load,
    iface=iface,
    stop_filter=stopFilter,
)`

Tried encoding the paket in the prn-function, but that didn't work. Also tried parsing the packet with DceRpc() but that also didn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余罪 2025-01-25 10:42:15

只需将 Python 版本更新到 3.9 即可一切正常!

Just update the Python Version to 3.9 and everything works!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文