Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scapy - the interface of a sniffed packet

I'm sniffing with scapy 2.2 on Windows 7 with Python 2.6. Is there a way I can recognize the interface of a sniffed packet? I thought about using the mac address to identify it, but is there a way to do it with scapy?

something like this (doesn't work) -

packet = sniff(count=1, iface='eth0')[0]
print packet.iface  # prints 'eth0' 
like image 849
ori Avatar asked May 17 '15 09:05

ori


People also ask

How do you use sniff packets with scapy?

Sniffing packets using scapy: To sniff the packets use the sniff() function. The sniff() function returns information about all the packets that has been sniffed. To see the summary of packet responses, use summary(). The sniff() function listens for an infinite period of time until the user interrupts.

What is PRN in scapy sniff?

The prn argument is defined as: prn: function to apply to each packet. If something is returned, it is displayed. For instance you can use prn = lambda x: x.

What is a scapy packet?

Scapy is a packet manipulation tool for computer networks, originally written in Python by Philippe Biondi. It can forge or decode packets, send them on the wire, capture them, and match requests and replies. It can also handle tasks like scanning, tracerouting, probing, unit tests, attacks, and network discovery.


1 Answers

In scapy, the interface-name the packet was captured on is stored in the property sniffed_on, for example:

    packet.sniffed_on
like image 199
Martin Sundhaug Avatar answered Sep 27 '22 20:09

Martin Sundhaug