美文网首页Python
Python Scapy模块

Python Scapy模块

作者: __周__ | 来源:发表于2018-05-18 11:59 被阅读225次
对数据包的操作
summary()   displays a list of summaries of each packet(显示每一个数据包的摘要)
nsummary()  same as previous, with the packet number(和上面额一样,多了一个数据包数量)
conversations()     displays a graph of conversations(显示通讯的图)
show()  displays the prefered representation (usually nsummary())(显示优先的事)
filter()    returns a packet list filtered with a lambda function(返回被lambda表达式过滤后的数据包列表)
hexdump()   returns a hexdump of all packets(返回所有数据包的十六进制数据)
hexraw()    returns a hexdump of the Raw layer of all packets(返回所有数据包的原始协议的十六进制数据)
padding()   returns a hexdump of packets with padding(显示填充过的数据包的十六进制数据)
nzpadding()     returns a hexdump of packets with non-zero padding(显示没有用零填充过的数据包的十六进制数据)
plot()  plots a lambda function applied to the packet list(设置一个lambda函数应用到数据包列表)
make table()    displays a table according to a lambda function(根据lambda函数显示一个列表)
发送数据包
  • send()函数会在第三层协议(网络层)发送数据,也就是说它将会处理路由和第二层协议
  • sendp()函数工作在第二层协议上(数据链路层),它在于你可以选择合适的接口和合适的链路层协议。
>>> send(IP(dst="1.1.1.1")/ICMP())
.
Sent 1 packets.
>>> sendp(Ether()/IP(dst="1.1.1.1",ttl=(1,4)), iface="eth1")
....
Sent 4 packets.
>>> sendp("I'm travelling on Ethernet", iface="eth1", loop=1, inter=0.2)
................^C
Sent 16 packets.
>>> sendp(rdpcap("/tmp/pcapfile")) # tcpreplay
...........
Sent 11 packets.
发送和接收数据包(sr)
  • sr()函数可以发送数据包并接收回应,这个函数返回一个数据包和响应,和没有响应数据包的列表
  • 函数sr1()是只返回发送数据包的一个返回的数据包,这个数据包必须是第三层协议的数据包(IP,ARP等等)
  • 函数srp()在第二层协议上做同样的事(数据链路层)。

https://blog.csdn.net/dj1174232716/article/details/44891203

相关文章

网友评论

    本文标题:Python Scapy模块

    本文链接:https://www.haomeiwen.com/subject/safgdftx.html