chmod 4755 (rwsr-xr-x) 给出 (rwxrwxrwx)

chmod 4755 (rwsr-xr-x) 给出 (rwxrwxrwx)

我想要将程序 call_shellcode (调用 shellcode) 的权限设置为 -rwsr-xr-x。当我运行:

sudo chmod 4755 call_shellcode

由于某种原因,权限仍然设置为 -rwxrwxrwx

展示权限的图片

我正在尝试获取 root shell,但当我执行程序时,我得到的是正常 shell。我在 VirtualBox 中使用 Ubuntu 16.04(32 位)

答案1

由于某种奇怪的原因,您以 root 身份运行gcc,但随后您以普通用户身份运行chmod。由于您以 root 身份编译了它,因此您无权更改的权限call_shellcode,因此权限保持不变。

不要以 root 身份编译!不要这样做任何事物以 root 身份执行,除非必须如此。

答案2

man chmod

SETUID AND SETGID BITS

   chmod clears the set-group-ID bit of a regular file if the file's group
   ID  does  not  match the user's effective group ID or one of the user's
   supplementary group IDs, unless the user  has  appropriate  privileges.
   Additional restrictions may cause the set-user-ID and set-group-ID bits
   of MODE or RFILE to be ignored.  This behavior depends  on  the  policy
   and  functionality of the underlying chmod system call.  When in doubt,
   check the underlying system behavior.

答案3

按照 Zanna 的问题,我将文件移出共享文件夹,现在权限设置正确。

相关内容