Sending packages using Scapy in Python

I play with Scapy and I want to use it in a Python script, but sending packages seems 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 great 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 is normal, but when it tries to send a 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 
+4
source share
1 answer

When you run this in a Python environment, you use the sr1 function. The sr1 function sr1 send a packet and then wait for a response, storing the number of received packets. More details here -

http://www.secdev.org/projects/scapy/doc/usage.html#send-and-receive-packets-sr

To get the desired behavior, you need to use the send function, as with 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") 
+11
source

Source: https://habr.com/ru/post/1494499/


All Articles