4
如何告訴scapy sniff()函數在沒有收到數據包時停止? 我使用sendp()函數發送數據包 示例:發送DHCP Discover時未發送響應。如何在沒有收到數據包的情況下告訴scapy sniff()停止?
如何告訴scapy sniff()函數在沒有收到數據包時停止? 我使用sendp()函數發送數據包 示例:發送DHCP Discover時未發送響應。如何在沒有收到數據包的情況下告訴scapy sniff()停止?
Scapy中的sniff()
函數有一個超時參數。您可以在幾秒鐘內提供超時。
您可以通過打印sniff.__doc__
找到其他選擇。
[email protected]:~$ scapy
>>> print sniff.__doc__
Sniff packets
sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] +
L2ListenSocket args) -> list of packets
count: number of packets to capture. 0 means infinity
store: wether to store sniffed packets or discard them
prn: function to apply to each packet. If something is returned,
it is displayed. Ex:
ex: prn = lambda x: x.summary()
lfilter: python function applied to each packet to determine
if further action may be done
ex: lfilter = lambda x: x.haslayer(Padding)
offline: pcap file to read packets from, instead of sniffing them
timeout: stop sniffing after a given time (default: None)
L2socket: use the provided L2socket
opened_socket: provide an object ready to use .recv() on
stop_filter: python function applied to each packet to determine
if we have to stop the capture after this packet
ex: stop_filter = lambda x: x.haslayer(TCP)
是的,我知道超時時間,但我問自己是否有辦法阻止自己編程時間之後沒有任何事情發生。 – yoyo
據我所知,超時是你唯一的選擇。其他一切都需要接收數據包。 – RyPeck
是的,我認爲是經過一些研究後,謝謝^^ – yoyo