Exploit databaseDownload repository ZIP
GH-26cf433f596e93369cfd25b99d8fc8aa
feedbeef/dji_ble_vuln
Sources for CVE-2026-78306
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files11
feedbeef/dji_ble_vulnRevision 3034a00e1d05
- README.md
- ble_console.py
- ble_transport.py
- commands.json
- duml_decoders.py
- duml_protocol.py
- flyc_parameters.txt
- parameters.py
- payload_builders.py
- requirements.txt
- terminal.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
terminal.py
Python · 11,549 bytes
import os
import shutil
import sys
import threading
class C:
R = "\033[31m"; G = "\033[32m"; Y = "\033[33m"; B = "\033[34m"
M = "\033[35m"; CY = "\033[36m"; BOLD = "\033[1m"; DIM = "\033[2m"; X = "\033[0m"
LB = "\033[94m" # bright ("light") blue -- readable on dark terminals
def say(tag, msg, col=C.CY):
print("%s[%s]%s %s" % (col, tag, C.X, msg), flush=True)
# ---------------------------------------------------------------------------
# receive mute
# ---------------------------------------------------------------------------
_rx_lock = threading.Lock()
_rx_state = dict(muted=False, held=[], flushed=0)
def rx_print(text):
"""Print an asynchronous line from the aircraft, or hold it if a prompt
is currently open."""
with _rx_lock:
if _rx_state["muted"]:
_rx_state["held"].append(text)
return
print(text, flush=True)
def rx_mute():
with _rx_lock:
_rx_state["muted"] = True
def rx_flush():
with _rx_lock:
_rx_state["muted"] = False
held = _rx_state["held"]
_rx_state["held"] = []
_rx_state["flushed"] += len(held)
if not held:
return
print("%s[*] %d drone message(s) held while you were typing%s"
% (C.CY, len(held), C.X))
for line in held:
print(line)
def take_flushed():
"""How many held lines have been printed since this was last asked. A
screen checks it before clearing, so a reply that landed mid-prompt is not
wiped before it has been read."""
with _rx_lock:
n = _rx_state["flushed"]
_rx_state["flushed"] = 0
return n
def hdr(msg):
print("\n%s%s%s%s" % (C.BOLD, C.B, msg, C.X), flush=True)
# ---------------------------------------------------------------------------
# in-place screens
# ---------------------------------------------------------------------------
LOGO = [
" ██████╗██╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗ █████╗ ██████╗ ██████╗ ██████╗ ",
"██╔════╝██║ ██║██╔════╝ ╚════██╗██╔═████╗╚════██╗██╔════╝ ╚════██║██╔══██╗╚════██╗██╔═████╗██╔════╝ ",
"██║ ██║ ██║█████╗█████╗ █████╔╝██║██╔██║ █████╔╝███████╗ █████╗ ██╔╝╚█████╔╝ █████╔╝██║██╔██║███████╗ ",
"██║ ╚██╗ ██╔╝██╔══╝╚════╝██╔═══╝ ████╔╝██║██╔═══╝ ██╔═══██╗╚════╝██╔╝ ██╔══██╗ ╚═══██╗████╔╝██║██╔═══██╗",
"╚██████╗ ╚████╔╝ ███████╗ ███████╗╚██████╔╝███████╗╚██████╔╝ ██║ ╚█████╔╝██████╔╝╚██████╔╝╚██████╔╝",
" ╚═════╝ ╚═══╝ ╚══════╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚════╝ ╚═════╝ ╚═════╝ ╚═════╝ ",
" ",
]
RAMP = ["38;5;51", "38;5;45", "38;5;39", "38;5;33", "38;5;27", "38;5;26", "38;5;25"]
LOGO_WIDTH = 57
BYLINE = "by Abdelrahman Yousef"
TAGLINE = "B L U E T O O T H · C O M M A N D · I N J E C T I O N"
CAGE = [
" ╭─────╮ ",
" ╱ ╲│╱ ╲ ",
"│ ──●── │",
" ╲ ╱│╲ ╱ ",
" ╰─────╯ ",
]
SHELL = [
" ╭────╮ ",
" │▓▓▓▓│ ",
"╭─┴────┴─╮",
"│ ○○○○ │",
"┤ ├",
"│ │",
"│ D J I │",
"│ │",
"│ │",
"│ │",
"┤ ├",
"│ │",
"╰───()───╯",
]
_CAGE_AT = {2: 0, 3: 1, 4: 2, 5: 3, 6: 4, 8: 0, 9: 1, 10: 2, 11: 3, 12: 4}
_ARM_ROWS = (4, 10)
BODY_TONE = "38;5;81"
DIM_TONE = "38;5;240"
DRONE_ROWS = len(SHELL) # 13
DRONE_WIDTH = 49 # plain width of one drone row, padding in
_screen = dict(enabled=True, banner="auto")
def set_clear_enabled(flag):
"""Turn the in-place redraw off (piped output, or --scroll)."""
_screen["enabled"] = bool(flag)
def set_banner(mode):
"""full / side / small / off, or auto to fit the terminal."""
_screen["banner"] = mode or "auto"
def clear():
"""Home the cursor and wipe the visible screen. Scrollback is left alone,
so anything already read is still there to scroll back to."""
if _screen["enabled"] and sys.stdout.isatty():
sys.stdout.write("\033[H\033[2J")
sys.stdout.flush()
else:
print()
def _tty():
return sys.stdout.isatty() and os.environ.get("TERM") not in (None, "dumb")
def _paint(code, text):
return "\033[%sm%s\033[0m" % (code, text) if _tty() else text
def logo_lines():
out = []
for row, line in enumerate(LOGO):
tone = RAMP[row % len(RAMP)]
out.append(" " + _paint(tone, line))
return out
def drone_lines():
"""The aircraft: four caged rotors on arms, around the shell."""
out = []
pad = " " * 7
for r, mid in enumerate(SHELL):
tone = DIM_TONE if r < 2 else BODY_TONE
if r in _CAGE_AT:
cage = _paint(tone, CAGE[_CAGE_AT[r]])
fill = _paint(tone, "─" * 5) if r in _ARM_ROWS else " " * 5
out.append(pad + cage + fill + _paint(tone, mid) + fill + cage)
else:
out.append(pad + " " * 16 + _paint(tone, mid))
return out
def masthead_lines(width=78):
"""The masthead, in whichever layout this terminal has room for:
full logo, tagline, byline, then the aircraft underneath (22 rows)
side logo and aircraft flying next to each other (13 rows)
small logo and byline only ( 8 rows)
line one line ( 1 row )
"""
rows, cols = term_height(), term_width()
logo, drone = logo_lines(), drone_lines()
byline = " " + _paint(DIM_TONE, BYLINE)
forced = _screen["banner"]
if forced == "off":
return []
if forced == "small":
return logo + [byline]
if forced == "side":
rows, cols = 99, max(cols, 1 + LOGO_WIDTH + 2 + DRONE_WIDTH)
if forced == "full" or rows >= 34:
head = list(logo)
head.append(" " + _paint(DIM_TONE, "─" * LOGO_WIDTH))
head.append(" " + _paint("1;96", TAGLINE))
head.append(byline)
head.append("")
return head + drone
if cols >= 1 + LOGO_WIDTH + 2 + DRONE_WIDTH and rows >= 22:
head = []
for i in range(DRONE_ROWS):
left = logo[i] if i < len(logo) else " " * (LOGO_WIDTH + 1)
if i < len(logo):
head.append(left + " " + drone[i])
else:
head.append(" " * (LOGO_WIDTH + 3) + drone[i])
head.append(byline)
return head
if rows >= 26:
return logo + [byline]
return [" %s%s · %s%s" % (C.BOLD + C.CY + "DJI MITM" + C.X, C.DIM,
BYLINE, C.X)]
def term_height(default=24):
try:
return max(10, shutil.get_terminal_size((80, default)).lines)
except OSError:
return default
def banner(status=None, width=78):
"""The masthead. It is redrawn at the top of every screen, so it never
scrolls away and only the part underneath it changes."""
for line in masthead_lines(width):
print(line)
if status:
print(" %s%s%s" % (C.DIM, "─" * (width - 1), C.X))
print(" %s%s%s" % (C.DIM, status, C.X))
def screen(title, subtitle=None, status=None, width=78):
"""Clear, draw the masthead, then this screen's title bar."""
clear()
banner(status, width)
print("%s%s%s" % (C.BOLD + C.M, "=" * width, C.X))
print(title.center(width))
if subtitle:
print("%s%s%s" % (C.DIM, subtitle.center(width), C.X))
print("%s%s%s" % (C.BOLD + C.M, "=" * width, C.X))
def rule(title=None, width=78, col=C.BOLD + C.M):
print("\n%s%s" % (col, "=" * width))
if title:
print(title.center(width))
print("=" * width)
print(C.X, end="")
def term_width(default=100):
try:
return max(60, shutil.get_terminal_size((default, 24)).columns)
except OSError:
return default
def columns(labels, cols=5, indent=" ", colours=None, min_cell=20):
"""Print numbered labels as a grid, filling column-first so the numbers
read down each column.
The requested column count is honoured whenever the cells stay at least
min_cell wide -- long names are then truncated with a '~', and the full
name is shown again on the detail screen. A narrow terminal gets fewer,
wider columns instead."""
if not labels:
print(indent + "(nothing to show)")
return
width = term_width() - len(indent)
longest = max(len(l) for l in labels) + 2
untruncated = max(1, width // longest)
cols = (cols if untruncated >= cols
else max(1, min(cols, width // min_cell)))
cell = width // cols
rows = (len(labels) + cols - 1) // cols
for r in range(rows):
line = []
for c in range(cols):
i = c * rows + r
if i >= len(labels):
continue
text = labels[i]
if len(text) > cell - 1:
text = text[:cell - 2] + "~"
pad = " " * (cell - len(text))
col = (colours or {}).get(i, "")
line.append((col + text + C.X if col else text) + pad)
print(indent + "".join(line).rstrip())
def ask(prompt, default=None):
"""Read one line with the aircraft's chatter held back until it lands."""
rx_mute()
try:
answer = input(prompt).strip()
except (EOFError, KeyboardInterrupt):
print()
return default
finally:
rx_flush()
return answer or default
def ask_int(prompt, lo, hi, base=10):
raw = ask(prompt)
if raw is None:
return None
try:
value = int(raw, base)
except ValueError:
return None
return value if lo <= value <= hi else None
def menu_index(text, count):
"""1-based menu pick -> 0-based index, or None when it is not one."""
if not text or not text.isdigit():
return None
n = int(text)
return n - 1 if 1 <= n <= count else None
def show_intro():
"""The boot screen: the full masthead, whatever the terminal size."""
print()
for line in logo_lines():
print(line)
print(" " + _paint(DIM_TONE, "─" * LOGO_WIDTH))
print(" " + _paint("1;96", TAGLINE))
print(" " + _paint(DIM_TONE, BYLINE))
print()
for line in drone_lines():
print(line)
print()