Say I want scapy to be a server to receive packet, like:
>> p=r("host:port") // waiting for a package
Is it possible?
If you really want to bind a socket, you'll have to use the socket
module from Python. You can do so from Scapy and use it to dissect the captured packet.
By doing so however, you'll behave as a regular application and hence will only get the "application" layer (and not the network layers IP
and TCP
or UDP
.
Now if you want to capture one packet from the network on a specific port, you can do so in "pure" Scapy, with the sniff()
function and a simple BPF filter:
p = sniff(filter="port 53", count=1)[0]