Python Scapy Beginner Questions

JC0133

Senior member
Nov 2, 2010
201
1
76
I apologize in advance for my questions. I am fairly new to networking.

I am trying to write a program that listens for packets. Basically I am trying to get some guidance on how to use scapy to listen for packets and figure out if the packet type that pings me is a arp request or not?

Also I have been watching some videos on scapy and they all are using it from the command line.

I need to used scapy from actually inside the source code. Like when I am coding in python?

Also I am using Ubuntu 14.04 and scapy 2.2.0.

I have seen more videos for scapy 2.3.. and some of the commands don't match up.

Like for example I was trying to run sniff command.

But I keep getting an error when I do it like this, packet = sniff(filter = "TCP", iface = "eth0").

I can't find any examples of how to sniff and using the filter and iface in scapy 2.2.0.
 

JC0133

Senior member
Nov 2, 2010
201
1
76
So I am working on a networking project(I am not looking for an answer to my homework or anything)and I am looking for a little understanding here. Because I am not passing all of my test cases when I submit and I have no clue why. I have no networking experience FYI.

Basically I am supposed to intercept a packet and send it back the way I received it with out modification. I am supposed to change the destination and source IP/MAC accord lying but I am provided with that information. Basically I am writing a code to be a reflector.

I am using two virtual machines. Basically pinging on IP address on one machine and setting up code in scapy to intercept the ping and send it back. Sniffing on the other machine.

I am doing this for IP packet(ICMP, UDP, TCP).

The issue is I am getting some errors in the test cases when I submit even tho, when I ping it works and I can see the packets in wireshark and on the command lines.

I pass some a test case:
Passed test ping IP

Then I am failing one.
Failed test ping IP again
Here's the first 750 characters output from.
Stdout:
Stderr:


Every time I send a ping it works so I don't understand how I am failing. And I don't know what Stdout: and Stderr: means in networking?

Any help?

I guess it would help if I was getting a IP packet, what needs to be modified so I could send the exact packet back to a the return source for ICMP, UDP, TCP.

What is confusing is I know a lot of people who are getting this to work but they are simple updating the right IP/MAC SRC/DST and deleting the checksums in the proper place. No clue why this is not working for me in scapy.