Link to home
Start Free TrialLog in
Avatar of LuiLui77
LuiLui77

asked on

what is Frame[Ether] and Frame[IP] using scapy in Python?

Hello all,

I am new to Python and I have a couple of questions regarding the code below. I am currently going through a lesson that shows you how to replay packets using scapy. In my try block on the code below, what does "frame[Ether].src" and "frame[IP].src" where did I get these variables from?
Is ".src" a module? what is "[Ether]" and [IP]?

I hope you guys can clarify.

Thank you!

from scapy.all import *
from scapy.utils import rdpcap

src_mac = "08:00:27:ae:6f:d7"
dst_mac = "08:00:27:87:57:be"
src_ip = "192.168.1.118"
dst_ip = "192.168.1.117"

frames = rdpcap("/root/pcaps/ping_traffic.pcap")
for frame in frames:
    try:
        frame[Ether].src = src_mac
        frame[Ether].dst = dst_mac

        if IP in frame:
            frame[IP].src = src_ip
            frame[IP].dst = dst_ip

        sendp(frame)
    except Exception as e:
        print(e)
Avatar of aikimark
aikimark
Flag of United States of America image

Frames comes from rdpcap
rdpcap is part of the scapy library you imported
Avatar of LuiLui77
LuiLui77

ASKER

Hi aikimark, thank you for your reply

how about frame[ETHER].src? I am aware that it means the ethernet or layer 2 portion of the source frame but [ETHER] and .src, where do they come from?
Do they come from the scapy library as well?
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you aikimark, it's all a lot clearer now.