Questions tagged [scapy]

Scapy is a network packet manipulation tool for use with Python.

What is Scapy?

Scapy is a network packet manipulation program for use with Python. It is able to:

  • forge or decode packets of a wide number of protocols
  • send them on the wire, capture them, match requests and replies, and much more. It can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery. (it can replace hping, 85% of nmap, arpspoof, arp-sk, arping, tcpdump, tethereal, p0f, etc.)

What makes scapy different from most other networking tools?

  • You can build whatever packets you want, stack ARP on top of 802.11, use double 802.1q encapsulation or send an ICMP packet with padding, and send them over the wire.

  • Scapy does not interpret answers: unlike most tools, it won't say “this port is open” instead of “I received a SYN-ACK”. You are free to interpret the packets as you want

  • It reports everything: you see the padding, the reserved fields... Nothing is dismissed


Useful links:

2198 questions
15
votes
3 answers

Importing python modules in jython

I'm having some issues importing scapy under jython. I've been doing java forever, but python for only a day or two. The simple case to reproduce the problem is: $jython >>> import sys >>> sys.path ['', '/usr/share/jython/Lib',…
TheBigS
  • 491
  • 1
  • 4
  • 14
14
votes
4 answers

Python Scapy wrpcap - How do you append packets to a pcap file?

I have some software that can emulate things like BER and delays on the network. I need a way to test the BER module of the software to make sure it actually works correctly. My solution is to create a program that sends out raw Ethernet frames…
14
votes
6 answers

ImportError: No module named scapy.all

I'm running macOS Sierra and Python 2.7. In my terminal I've installed scapy with: pip install scapy Requirement already satisfied: scapy in /usr/local/lib/python2.7/site-packages But running this: from scapy.all import * for pkt in…
Michael Nielsen
  • 1,194
  • 3
  • 22
  • 37
14
votes
5 answers

Scapy.all import * does not work

So, I wrote a little script in Ubuntu for scapy. #!/usr/bin/env python import sys #from scapy.all import * try import scapy except ImportError: del scapy from scapy import all as scapy i= IP() t=…
Nicholas
  • 1,189
  • 4
  • 20
  • 40
14
votes
4 answers

suppress scapy warning message when importing the module

I'm writing a small script, that gathers some information using scapy and then returns some xml code, that I'll pass on to the xmlrpc interface of metasploit. I'd like it that my script only returns xml, and no additional warnings etc. I can…
user857990
  • 1,140
  • 3
  • 14
  • 29
13
votes
10 answers

Python: Can't import a function from another.py file

I have a file named handshake.py. Where there is a function send_data(argument). I want to import that function into another file named siptest.py. I am encountering two problems. I am using microsoft visual studio with windows 7, 64-bit. 1) I can't…
Kashif Ahmad
  • 426
  • 3
  • 8
  • 22
13
votes
1 answer

'ImportError: No module named dumbnet' when trying to run a script that leverages scapy on OS X

So, I am trying to learn about the scapy library in Python and trying to run a script that uses scapy. The script imports the module with: from scapy.all import * I saw this and of course installed scapy with: pip install scapy Next, I got the…
timbram
  • 1,797
  • 5
  • 28
  • 49
13
votes
1 answer

How to send UDP packet to specific UDP dst port in scapy?

I would like to send my packet to a UDP dst port number and send it through eth0 interface (if scapy handles my layer2 directly, then eth0 does not need to be given as an argument)
drdot
  • 3,215
  • 9
  • 46
  • 81
13
votes
2 answers

Scapy packet sniffer triggering an action up on each sniffed packet

I'm using scapy with python to sniff live traffic. capture=sniff(iface="", filter="tcp") But this sniffs each packet and adds it to the list capture which can be processed later. I want to process a packet and display few fields of…
RatDon
  • 3,403
  • 8
  • 43
  • 85
13
votes
6 answers

Scapy install issues. Nothing seems to actually be installed?

I have an apple computer running Leopard with python 2.6. I downloaded the latest version of scapy and ran "python setup.py install". All went according to plan. Now, when I try to run it in interactive mode by just typing "scapy", it throws a…
Chris
  • 21,549
  • 25
  • 71
  • 99
13
votes
1 answer

Scapy error: no module names pcapy

The code given below is for sniffing a packet from the IP address provided. from scapy.all import * sniff(filter="tcp and host 192.168.0.90", count=10) On running this code the error I am getting is: Traceback (most recent call last): File…
praxmon
  • 5,009
  • 22
  • 74
  • 121
13
votes
1 answer

how to fix Scapy "Warning pcapy API does not permit to get capure file descriptor"?

I am trying to capture outgoing packets (i.e., from my localhost) by using Scapy capturing function sniff, then parse them as they get captured but I keep getting the following warning: WARNING: fileno: pcapy API does not permit to get capure file…
OiaSam
  • 560
  • 7
  • 19
13
votes
2 answers

Python: access structure field through its name in a string

In Scapy, I want to compare a number of header fields between any two packets a and b. This list of fields is predefined, say: fieldsToCompare = ['tos', 'id', 'len', 'proto'] #IP header Normally I would do it individually: if a[IP].tos ==…
Ricky Robinson
  • 21,798
  • 42
  • 129
  • 185
13
votes
6 answers

Raw sockets and sendto in python

I am working on integrating scapy with twisted, but I ran into this very weird bug on OSX that I can't seem to figure out. Basically I am unable to send a valid TCP packet (inclusive of IP headers) via a raw socket. This is what I am doing: import…
12
votes
1 answer

Adding payload in packet

Can I insert image or document (in MBs) as a data in packet using scapy? This is what I did to send data. data = "University of texas at San Antonio" a = IP(dst="129.132.2.21")/TCP()/data send(a)
Chetan
  • 141
  • 1
  • 1
  • 4