Celeb Glow
general | March 19, 2026

chmod 4755 (rwsr-xr-x) gives (rwxrwxrwx)

I want to get the permissions of a program, call_shellcode (which calls shellcode), to be set to -rwsr-xr-x. When I run:

sudo chmod 4755 call_shellcode

the permissions for some reason is still set at -rwxrwxrwx

Picture showcasing permissions

I am trying to get the root shell, but when I execute the program I get a normal shell. I am using Ubuntu 16.04 (32-bit) in VirtualBox

7

3 Answers

You are running gcc as root for some strange reason, but then you run the chmod as your regular user. You don't have [permission to change the rights of call_shellcode since you compiled it as root, and therefore the permissions remain unchanged.

Don't compile as root! Don't do anything as root unless you have to.

2

From 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.

Following Zanna's question, I moved the files out of the shared folder and now the permissions are set correctly.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy