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

7,118

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.

Share:
7,118
James
Author by

James

Updated on September 18, 2022

Comments

  • James
    James over 1 year

    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

    • Zanna
      Zanna about 6 years
      Is this file on an NTFS partition or something like that?
    • PerlDuck
      PerlDuck about 6 years
      Please don't post pictures of your problem! Post it as text instead.
    • James
      James about 6 years
      It is in a shared folder between host and guest for the VM
    • Connor Payne
      Connor Payne about 6 years
      Who is the owner of the file? you can find this out by running ls -l on the directory.
    • terdon
      terdon about 6 years
      Is that really the only error message you get? Nothing about Operation not permitted?
    • James
      James about 6 years
      Yeah it only shows what is there
    • Yaron
      Yaron about 6 years
      please edit your question, and add the result of ls -l in that directory
  • James
    James about 6 years
    I just tried gcc -o call_shellcode call_shellcode.c without the sudo and it still doesnt work
  • Yaron
    Yaron about 6 years
    @JamesTan - the file call_shellcode already exists and owned by root, you need to sudo rm call_shellcode before running the gcc as regular user