Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop packet recieved from network using python (scapy?)

I am creating a program in python (either 2 or 3) in which I need to be able to drop a packet. Using scapy I know how to inspect packets, craft one and modify one sniffed from the sniff() function. I believe the sniff function can't actually modify the incomming packets (correct me if I'm wrong). I would like to know how I could drop some packets. Ex: if it has a src.ip==192.168.1.5, then drop it there.

like image 582
Bob Ebert Avatar asked Feb 09 '16 21:02

Bob Ebert


1 Answers

You can not drop packets with scapy or any other sniffing programm. You should try using iptables. There is a wrapper for iptables called python-iptables. It can help you to create, manage and delete different firewall rules from your python programm

like image 86
Dmitriy Vorotnikov Avatar answered Sep 22 '22 00:09

Dmitriy Vorotnikov