7

I am playing around with Scapy and I want to use it within a Python script but sending packets seem to be a problem. Here is my code.

Scapy Shell:

send(IP(src="10.0.99.100",dst="10.1.99.100")/ICMP()/"Hello World")

This works fine and sends the packet.

Python script:

#! /usr/bin/env python

from scapy.all import sr1,IP,ICMP

p=sr1(IP(src="10.0.99.100",dst="10.1.99.100")/ICMP()/"Hello World")

This runs fine but when it tries to send the packet I get:

WARNING: No route found for IPv6 destination :: (no default route?)
Begin emission:
.Finished to send 1 packets.
....^C
Received 5 packets, got 0 answers, remaining 1 packets
2
  • What exactly is your question? It looks to me like everything is working fine. Commented Jul 31, 2013 at 20:06
  • In the scapy environment I get a output of "Sent 1 packets" and it works but with python it just starts receiving packets and not sending it Commented Jul 31, 2013 at 21:40

1 Answer 1

18

When you run this in the Python environment you are using the sr1 function. The sr1 function will send a packet and then wait for an answer, keeping a count of received packets. See more here -

https://scapy.readthedocs.io/en/latest/usage.html#send-and-receive-packets-sr

To get the behavior you desire, you need to use the send function, just like you did when using the Scapy shell.

#! /usr/bin/env python

from scapy.all import send, IP, ICMP

send(IP(src="10.0.99.100",dst="10.1.99.100")/ICMP()/"Hello World")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.