Skip to content

Commit 96f7c03

Browse files
authored
Merge pull request #2016 from HackTricks-wiki/research_update_src_binary-exploitation_rop-return-oriented-programing_ret2vdso_20260317_023759
Research Update Enhanced src/binary-exploitation/rop-return-...
2 parents 4250b2e + b0bfd61 commit 96f7c03

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • src/binary-exploitation/rop-return-oriented-programing

src/binary-exploitation/rop-return-oriented-programing/ret2vdso.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44

55
## Basic Information
66

7-
There might be **gadgets in the vDSO region**, which is used to change from user mode to kernel mode. In these type of challenges, usually a kernel image is provided to dump the vDSO region.
7+
There might be **gadgets in the vDSO region**, which is a small ELF DSO mapped by the kernel to provide fast user-space implementations of some kernel helpers. In these type of challenges, usually a kernel image is provided to dump the vDSO region.
8+
9+
### Locating the vDSO base and exports
10+
11+
The vDSO base address is passed in the auxiliary vector as `AT_SYSINFO_EHDR`, so if you can read `/proc/<pid>/auxv` (or call `getauxval` in a helper process), you can recover the base without relying on a memory leak. See [Auxiliary Vector (auxv) and vDSO](../basic-stack-binary-exploitation-methodology/elf-tricks.md) for practical ways to obtain it.
12+
13+
Once you have the base, treat the vDSO like a normal ELF DSO (`linux-vdso.so.1`): dump the mapping and use `readelf -Ws`/`objdump -d` (or the kernel reference parser `tools/testing/selftests/vDSO/parse_vdso.c`) to resolve exported symbols and look for gadgets. On x86 32-bit the vDSO commonly exports `__kernel_vsyscall`, `__kernel_sigreturn`, and `__kernel_rt_sigreturn`; on x86_64 typical exports include `__vdso_clock_gettime`, `__vdso_gettimeofday`, and `__vdso_time`. Because the vDSO uses symbol versioning, match the expected version when resolving symbols.
814

915
Following the example from [https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/](https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/) it's possible to see how it was possible to dump the vdso section and move it to the host with:
1016

@@ -60,13 +66,16 @@ pop_ebx_pop_esi_pop_ebp_ret = vdso_addr + 0x15cd
6066
6167
### ARM64
6268

63-
After dumping and checking the vdso section of a binary in kali 2023.2 arm64, I couldn't find in there any interesting gadget (no way to control registers from values in the stack or to control x30 for a ret) **except a way to call a SROP**. Check more info int eh example from the page:
69+
After dumping and checking the vdso section of a binary in kali 2023.2 arm64, I couldn't find in there any interesting gadget (no way to control registers from values in the stack or to control x30 for a ret) **except a way to call a SROP**. Check more info in the example from the page:
6470

6571

6672
{{#ref}}
6773
srop-sigreturn-oriented-programming/srop-arm64.md
6874
{{#endref}}
6975

70-
{{#include ../../banners/hacktricks-training.md}}
76+
## References
7177

78+
- [https://man7.org/linux/man-pages/man7/vdso.7.html](https://man7.org/linux/man-pages/man7/vdso.7.html)
79+
- [https://www.kernel.org/doc/Documentation/ABI/stable/vdso](https://www.kernel.org/doc/Documentation/ABI/stable/vdso)
7280

81+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)