开发者

Shellcode as payload for buffer overflow (or other) exploits executed as root?

开发者 https://www.devze.com 2023-02-26 06:50 出处:网络
When I use shellcode such as the ones provided here* as payload to some vu开发者_StackOverflow社区lnerable program, how is the shell executed as root? I am asking about how the privileges are elevated

When I use shellcode such as the ones provided here* as payload to some vu开发者_StackOverflow社区lnerable program, how is the shell executed as root? I am asking about how the privileges are elevated to root? The shellcode doesn't seem to call setuid or anything to change user.

* http://www.tenouk.com/Bufferoverflowc/Bufferoverflow5.html


Those examples include the following:

     mov $70, %al           #setreuid is syscall 70

So they're using the setreuid(2) syscall, which sets both the real and effective user IDs of the process:

   int setreuid(uid_t ruid, uid_t euid);


In order to execute shellcode you need a vulnerability like a buffer overflow. The shellcode has all of the rights as the running process. So if you exploit a binary that is setuid root like the passwd command or otherwise running as root such as the cupsd daemon process then the attacker will have root access. The kernel can also suffer from a buffer overflow, and root access can be obtained this way as well.


first you need to giving the program as root privileges (use chown and chmod as root). and you need setreuid() for your payload. that's would give you root, if you can exploit the program by other user.


Of course, if your vuln program has an owner root and your shellcode have a setuid(0) syscall, you can execute /bin/sh as root

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号