简体   繁体   English

用 LD_PRELOAD 覆盖 getuid 不能直接工作,但在 gdb 中工作

[英]overriding getuid with LD_PRELOAD not working directly, but works in gdb

I was solving a challenge from nebula exploit exercise( https://exploit-exercises.lains.space/nebula/level13/ ).我正在解决星云利用练习( https://exploit-exercises.lains.space/nebula/level13/ )中的一个挑战。 Since the compiled binary is dynamically linked, I thought of writing my custom getuid() to return 1000 and set LD_PRELOAD=custom_getuid.由于编译后的二进制文件是动态链接的,我想到了编写我的自定义 getuid() 来返回 1000 并设置 LD_PRELOAD=custom_getuid。 This does not seem to work when I directly execute the binary, but I'm able to bypass the check by executing in gdb, ltrace,strace.当我直接执行二进制文件时,这似乎不起作用,但我可以通过在 gdb、ltrace、strace 中执行来绕过检查。 gdb is able to load my custom getuid. gdb 能够加载我的自定义 getuid。 Can anyone explain this behaviour please?任何人都可以解释这种行为吗? Thanks!谢谢!

find the output of two approaches here在这里找到两种方法的输出

I found the issue, LD_PRELOAD does not affect suid binaries.我发现了这个问题,LD_PRELOAD 不影响 suid 二进制文件。 So my binary has suid set to flag13 user.所以我的二进制文件将 suid 设置为 flag13 用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM