Python Forum
Listening on receiving Interface (using scapy)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Listening on receiving Interface (using scapy)
#1
Hello, so I have tried setting up a NIC with dual ethernet interfaces, and I have connected them in a loopback. What I am trying to do is that I send packets from Interface1 (00:11:22:33:44:55) to Interface2 (99:88:77:66:55:44).

I have been failing to read out the packets from the receiving Interface2, but I can see that there is traffic on the interface when I am monitoring in wireshark. As I have understood in the Scapy documentation, the PRN is just a function callback to deal with each packet that is returned by sniff. For some reason the referenced callback "paket_processor" is never called, but I can see that the pakets are sent. I would like to be able to sniff the packets on the receiving end and hexdump them to validate that they look the same in first hand. But since the callback is never fired I don't know what is going wrong. I appreciate all the help I could get, to figure out what I have misunderstood Huh

The code is very simple and looks like this:

from scapy.utils import rdpcap
from scapy.layers.l2 import Ether

def packet_processor(pkt):
    print("Packet sniffed..")
    pkt.show()

sniff(count=2, iface="Interface1", prn=packet_processor, store=0)

pkts=rdpcap("SomeARP.pcap")
for pkt in pkts:
    print(pkt)
    pkt[Ether].src = "00:11:22:33:44:55"
    pkt[Ether].dst = "99:88:77:66:55:44"
    hexdump(pkt)
    sendp(pkt, iface="Interface1")

pkts=rdpcap("AnotherARP.pcap")
for pkt in pkts:
    print(pkt)
    pkt[Ether].src = "00:11:22:33:44:55"
    pkt[Ether].dst = "99:88:77:66:55:44"
    hexdump(pkt)
    sendp(pkt, iface="Interface1")
Larz60+ write Sep-06-2024, 10:03 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added this time. Please use BBCode tags on future posts.
Reply
#2
did you maybe find the solution, because I am facing the same problem
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Sending Packages with Scapy yoda2247 3 905 Dec-25-2024, 11:14 PM
Last Post: yoda2247
  Handling receiving updates from user in Telebot mohsenamiri 0 1,185 Aug-26-2024, 09:25 AM
Last Post: mohsenamiri
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 5,167 Aug-13-2023, 12:16 AM
Last Post: cubangt
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 2,082 Jul-31-2022, 08:20 PM
Last Post: paulyan
  Permission issue when using scapy jao 3 16,098 Feb-05-2022, 06:14 PM
Last Post: snippsat
  Receiving snmp traps with more than one Community String ilknurg 0 3,598 Jan-19-2022, 09:02 AM
Last Post: ilknurg
  Listening music from url ebolisa 1 2,214 Nov-25-2020, 07:53 AM
Last Post: ebolisa
  Waiting and listening test 2 2,960 Nov-13-2020, 04:43 PM
Last Post: michael1789
  [Selenium]Timed out receiving message from renderer: 10.000 wood_6636 0 3,420 Jun-26-2020, 08:59 AM
Last Post: wood_6636
  How can I make this server stop listening for connections to sockets Emekadavid 0 4,520 Jun-03-2020, 02:28 PM
Last Post: Emekadavid

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020