Hacking and crafting IPv4 packets with Python and Scapy
A three-chapter book on building, sending, capturing and dissecting IPv4 packets with Python and Scapy, and ending up using Scapy as a library in your own tools. The book is in Spanish.
With Daniel Alfocea
- chapters
- 3
- level
- intermediate

In Spanish. This program is taught in Spanish: its videos, exercises and exam are in Spanish. This page is a translation to help you decide.
Who it is for
You work in networking, security or development and want to build and send IPv4 packets with Python and Scapy. You need an intermediate level of Python.
About the program
Stop looking at packets and start making them
A book for building, sending and dissecting IPv4 packets with Python and Scapy.
Language: the book is written in Spanish. All of its text is in Spanish; this page is the English description only.
You open Wireshark, see a packet and more or less understand it.
Until you have to build it yourself. With the layers you want, the fields you want, and send it to see what the other side answers.
That is exactly what Scapy does. You build the packet field by field, send it, and keep the response in a variable.
Who is telling you this
I’m Daniel Alfocea. I’ve spent twenty years in development and security, and I’ve written a few audit tools (GoLismero, Plecost, Dockerscan).
What you get
Three chapters, from the Scapy console to your own tools.
1. Introduction to Scapy. What makes it different from other tools and what is underneath. The operating modes, why permissions matter and which help functions you have at hand. And your first packet, with Wireshark watching over your shoulder, up to a ping.
2. Advanced use of Scapy. What a layer is and why order matters. When to use send and when sendp. Reading and replaying PCAP files, generating flood traffic, creating your own layer and exporting packets as hexadecimal, base64, PDF and graphs.
3. Using Scapy as a library. Importing what you need and putting your own tool together. Fuzzing, command-line parameters, threads and their limits, intercepting packets with the firewall’s help, remote logging with syslog and, to finish, a DNS server built with Scapy’s Automaton.
What you’ll be able to do
- Move around the Scapy interpreter and ask it for help on any function or layer.
- Choose between
sendandsendpknowing what changes. - Open a capture, find the frame you’re after and replay it.
- Create a new layer when Scapy doesn’t ship the one you need.
- Split work between threads, knowing what is worth parallelizing and what isn’t.
- Write a DNS server as a finite state machine, without learning the mathematical theory around it.
I won’t tell you here how any of it is done. It’s all inside.
The contents, chapter by chapter
Chapter 1. Introduction to Scapy
- What Scapy is and why use it.
- Installation and interactive mode: permissions, users and autocompletion.
- Help functions.
- Building a basic packet: Wireshark as a debugger, first packet, sending and ping.
Chapter 2. Advanced use of Scapy
- Layers: definition, order, the TCP/IP stack and the OSI model.
- Layer parameters and their data types.
- Sending modes:
sendandsendp. - Analyzing responses: the
srfunctions,.show()and dissection. - Reading PCAP files.
- Replaying in flood mode.
- Creating a new layer.
- Exporting to hexadecimal, base64 and PDF, and creating graphs.
Chapter 3. Using Scapy as a library
- Functions and calls: importing Scapy, layers and functions that take functions as parameters.
- Sending data, creating packets and fuzzing.
- Command-line parameters.
- Scapy and multithreading.
- Packet interception and the operating system, with the firewall’s help.
- Remote logging with syslog.
- Automaton: states, transitions, execution and a DNS server.
And a glossary at the end.
What it costs
€5, one payment, and the book is yours.
You won’t come out a protocol expert. You’ll come out knowing your way around the Scapy console, with your own packets and with programs you can open, break and change.
If you already write tools with Scapy every day, the first chapter is not for you.
I'll pay the €5 and open it today
Cheers,
Dani
P.S. Five euros. If one chapter saves you an afternoon of fighting the console, it has already paid for itself.
Syllabus
1 lesson.
Libro 1 lesson
- Hacking y manipulación de paquetes IPv4 con Python y Scapy
Who teaches it

Daniel Alfocea
Twenty years in development and security, and author of tools such as GoLismero, Plecost and Dockerscan.
Questions
How much Python do I need?
An intermediate level. You can write a script, import modules and read a traceback without panicking.
The book is about networks and Scapy. If you have never written Python, the last chapter will be hard going.
Is it a book or a video course?
It’s a book. You read it, you don’t watch it. There are no videos and no sample lessons.
If you’d rather have someone typing in front of you, look at the Scapy video course.
IPv4 only?
What do I send the packets to?
To your own things. Some chapters cover flooding, fuzzing and intercepting traffic, and all of it is tested against machines you control or have permission to test.
Sending it at someone else’s network is not part of what I teach.
Is it useful if I already use Wireshark?
Will it make me a protocol expert?
No. The book itself warns that the theory is limited: just enough to understand each concept, from the basics to the advanced material.
With that and some practice you have what you need to keep going on your own.
Who it is forYou work in networking, security or development and want to build and send IPv4 packets with Python and Scapy. You need an intermediate level of Python.