Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


chmod: changing permissions of 'drop_caches': Operation not permitted - Page 2
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

chmod: changing permissions of 'drop_caches': Operation not permitted

2

Comments

  • @eol said:
    Of course it fails.
    It executes with your current user permissions.

    I've tried -rwsr-xr-x and -rwsr-sr-x.
    Sorry but I really don't want to fiddle around with the /etc/fstab unless it's a last resort.

  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire
    edited December 2018

    Create the C code and compile it

    dropcaches.c

    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
        setuid(0);
        system("/bin/echo 3 > /proc/sys/vm/drop_caches");
        return 0;
    }
    
    gcc dropcaches.c -o dropcaches
    chmod 4755 dropcaches
    

    EDIT: Modified the system call to use full path

    Thanked by 3tcp6 eol Falzo
  • @tcp6 said:

    @eol said:
    Of course it fails.
    It executes with your current user permissions.

    I've tried -rwsr-xr-x and -rwsr-sr-x.
    Sorry but I really don't want to fiddle around with the /etc/fstab unless it's a last resort.

    Sure.
    While it might work it has severe security implications.

  • @Janevski said:
    So apparently there is a way of doing this, but it is a bad idea from security standpoint:

    https://stackoverflow.com/questions/13646925/allowing-a-non-root-user-to-drop-cache

    https://km.mk/allowing-a-non-root-user-to-drop-cache.pdf

    I've tested it on ubuntu, it seems to work. Sorry i cannot paste the text, CloudFlare thinks i am hacking LET, so i'll post a screen shot.

    Exactly what I needed. Kudos for that.

    Thanked by 1Janevski
  • tcp6tcp6 Member
    edited December 2018

    @FAT32 said:
    Create the C code and compile it

    dropcaches.c

    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
        setuid(0);
        system("/bin/echo 3 > /proc/sys/vm/drop_caches");
        return 0;
    }
    
    gcc dropcaches.c -o dropcaches
    chmod 4755 dropcaches
    

    Flawless.

    Thanked by 2eol FAT32
  • eoleol Member
    edited December 2018

    @FAT32 said:
    Create the C code and compile it

    dropcaches.c

    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
        setuid(0);
        system("/bin/echo 3 > /proc/sys/vm/drop_caches");
        return 0;
    }
    
    gcc dropcaches.c -o dropcaches
    chmod 4755 dropcaches
    

    Not bad.

    EDIT:
    Code update.

    Thanked by 1FAT32
  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire
    edited December 2018

    @FAT32 said:
    Create the C code and compile it

    dropcaches.c

    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
        setuid(0);
        system("/bin/echo 3 > /proc/sys/vm/drop_caches");
        return 0;
    }
    
    gcc dropcaches.c -o dropcaches
    chmod 4755 dropcaches
    

    It works.

    Thanked by 2eol tcp6
  • Sure works on a KVM VPS, however on an OpenVZ VPS, that's a no-go.

  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire

    After reading the comment and the StackOverflow post by @Janevski, I forgot that the "PATH" environment variable can be changed to a malicious one.

    Please change the system call to the following to secure the system:
    system("/bin/echo 3 > /proc/sys/vm/drop_caches");

    Thanked by 1eol
  • @FAT32 said:
    After reading the comment and the StackOverflow post by @Janevski, I forgot that the "PATH" environment variable can be changed to a malicious one.

    Please change the system call to the following to secure the system:
    system("/bin/echo 3 > /proc/sys/vm/drop_caches");

    Makes sense, would you mind editing your initial code snippet as well? In case someone else stumbles on it someday and doesn't bother reading further.

  • FAT32FAT32 Administrator, Deal Compiler Extraordinaire

    @tcp6 said:
    Makes sense, would you mind editing your initial code snippet as well? In case someone else stumbles on it someday and doesn't bother reading further.

    I did, perhaps you and @eol can update the quote as well

    Thanked by 2tcp6 eol
  • @FAT32 said:

    @tcp6 said:
    Makes sense, would you mind editing your initial code snippet as well? In case someone else stumbles on it someday and doesn't bother reading further.

    I did, perhaps you and @eol can update the quote as well

    Done on my end. :wink:

    Thanked by 1FAT32
  • @FAT32 said:

    @tcp6 said:
    Makes sense, would you mind editing your initial code snippet as well? In case someone else stumbles on it someday and doesn't bother reading further.

    I did, perhaps you and @eol can update the quote as well

    Done.

    Thanked by 2FAT32 tcp6
  • Will all that being said, OpenVZ really needs to die.

    • Can't swapon -a.
    • Can't flush memory buffers.
    • Can't use FUSE properly if it hasn't been compiled as a module on the host node.

    I can't believe people in the hosting industry are still using OVZ. :angry:

  • @tcp6 said:
    Will all that being said, OpenVZ really needs to die.

    This.

    Thanked by 1tcp6
  • Now there is still a security problem.
    One could replace the echo binary with something slightly more malicious.
    But anyway problem solved.

    Thanked by 1tcp6
  • @tcp6 said:
    Will all that being said, OpenVZ really needs to die.

    • Can't swapon -a.
    • Can't flush memory buffers.
    • Can't use FUSE properly if it hasn't been compiled as a module on the host node.

    I can't believe people in the hosting industry are still using OVZ. :angry:

    We love OVZ if we don't need to do the above mentioned things. For everything else there is KVM or bare back metal.

    Thanked by 1eol
  • @dahartigan said:
    We love OVZ if we don't need to do the above mentioned things. For everything else there is KVM or bare back metal.

    Really?
    Come on...

    Thanked by 1dahartigan
  • @eol said:

    @dahartigan said:
    We love OVZ if we don't need to do the above mentioned things. For everything else there is KVM or bare back metal.

    Really?
    Come on...

    Oh, and I'd never put anything sensitive anywhere near an OVZ.

    Thanked by 1eol
  • tcp6tcp6 Member
    edited December 2018

    gaia 2.6.32-042stab128.2

    root@gaia:~# id
    uid=0(root) gid=0(root) groups=0(root)

    root@gaia:~# fallocate -l 1G /mnt/1GB.swap

    root@gaia:~# mkswap /mnt/1GB.swap
    Setting up swapspace version 1, size = 1048572 KiB
    no label, UUID=19b804ff-bbf9-4b20-ac28-00d455696f51

    root@gaia:~# chmod 0600 /mnt/1GB.swap

    root@gaia:~# swapon /mnt/1GB.swap
    swapon: /mnt/1GB.swap: swapon failed: Operation not permitted

    root@gaia:~# echo 3 > /proc/sys/vm/drop_caches
    -su: /proc/sys/vm/drop_caches: Permission denied

    Piece of shit.

    Thanked by 2eol dahartigan
  • Get a dedicated server and call it a day old chap.

    Thanked by 1eol
  • eoleol Member
    edited December 2018

    @dahartigan said:
    Get a dedicated server and call it a day old chap.

    Agreed.

    EDIT:
    Nothing better than idling a bunch of dedicated servers.

    Thanked by 1dahartigan
  • @eol said:
    Now there is still a security problem.
    One could replace the echo binary with something slightly more malicious.
    But anyway problem solved.

    One work-around I am thinking of regarding the "echo binary issue" would be to use busybox, at least that's how it is done on embedded systems with minimal kernels and space constraints. :hushed:

    Thanked by 1eol
  • @eol said:

    @dahartigan said:
    Get a dedicated server and call it a day old chap.

    Agreed.

    EDIT:
    Nothing better than idling a bunch of dedicated servers.

    It's not idling if they are running tmux + htop.

    Thanked by 2eol tcp6
  • eoleol Member
    edited December 2018

    @tcp6 said:

    @eol said:

    One work-around I am thinking of regarding the "echo binary issue" would be to use busybox, at least that's how it is done on embedded systems with minimal kernels and space constraints. :hushed:

    While that might work... don't you think busybox is somewhat limited?

    EDIT:
    Quote.

  • @dahartigan said:
    It's not idling if they are running tmux + htop.

    You forgot screen! You n00b. :wink:

    Thanked by 2dahartigan eol
  • @tcp6 said:

    @dahartigan said:
    It's not idling if they are running tmux + htop.

    You forgot screen! You n00b. :wink:

    Tmux is screen's sexy sister.

    Thanked by 2eol tcp6
  • tcp6tcp6 Member
    edited December 2018

    @eol said:
    While that might work... don't you think busybox is somewhat limited?

    That depends on "how" you've compiled it actually.

    See: https://busybox.net/downloads/BusyBox.html

    Edit: Busybox can even have it's own internal httpd, ftpd, nc and so forth. Back in my days some rootkits were actually nothing but modified busybox binaries disguised as legit daemons running on compromised hosts.

    Thanked by 2eol lion
  • @dahartigan said:
    It's not idling if they are running tmux + htop.

    True.

    Thanked by 1dahartigan
  • @dahartigan said:

    @tcp6 said:

    @dahartigan said:
    It's not idling if they are running tmux + htop.

    You forgot screen! You n00b. :wink:

    Tmux is screen's sexy sister.

    Yeah but when you're drunk to the boot, you'd still fuck the uglier sister regardless. :smiley:

    Thanked by 2dahartigan eol
Sign In or Register to comment.