【问题标题】:How to run scapy after installing安装后如何运行scapy
【发布时间】:2020-10-19 05:23:27
【问题描述】:

我已经在我的 ubuntu 终端上使用命令 pip install scapy 安装了 scapy。我还安装了 Python 2.7.17。如何在 ubuntu 终端中运行 scapy?我试过运行命令:sudo ./scapy。我的目标是使用 scapy 来嗅探数据包并记录数据包的发送和接收时间。

【问题讨论】:

标签: packet-sniffers


【解决方案1】:

你可以的

python -m scapy

将 scapy 模块 (-m) 作为 CLI 工具启动

【讨论】:

    【解决方案2】:

    scapy 不是可执行文件。它是一个用于 python 的库,可以导入到 python 代码中:

    将 scapy.all 导入为 scapy

    然后您可以调用 scapy.ARP、scapy.Ether 或代码中的层/字段。

    如果你想从网络上嗅探信息,你也需要导入层:

    从 scapy.layers 导入 http

    然后您可以使用 http.HTTPRequest 进行搜索和过滤:

    if packet.haslayer(http.HTTPRequest):
        print(packet.show())
    

    要了解您要获取哪些字段,例如从 scapy.Raw 加载:

    数据包[scapy.Raw].load

    查看文档:https://scapy.readthedocs.io/en/latest/layers/http.html

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-09
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多