zoukankan      html  css  js  c++  java
  • Ubuntu本地提权适配不同小版本内核(CVE-2017-16995)

    朋友在执行的时候说有的会出现提权不成功,内核crash掉的现象。因为cred结构体的偏移量可能因为内核版本不同、内核编译选项不同而出现差异,作者给的exp偏移量是写死的,所以exp里面对应的偏移地址也要改一下。以下方法可以算出不同内核版本默认编译选项下的cred偏移地址:

    1.Makefile

    obj-m += getCredOffset.o
     
    all:
            make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
             
    clean:
            make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

    2.getCredOffset.c

    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/init.h>
    #include <linux/slab.h>
    #include <linux/kthread.h>
    #include <linux/errno.h>
    #include <linux/types.h>
        int init_module()
    
        {
            printk("[!]current cred offset:%x
    ",(unsigned long)&(current->cred)-(unsigned long)current);
            return 0;
        }
        void cleanup_module()
        {
            printk("module cleanup
    ");
        }

    把上面俩文件扔到一目录里,make一下,生成getCredOffset.ko,执行insmod getCredOffset.ko,然后新开一个命令行执行dmesg | grep "cred offset",OK了,把得到的offset替换到exp里面。

    前面说了,这个适合默认的内核编译选项,这样才能在本地环境中的root权限下insmod,至于其他情况,只能通过其他方法来确定cred偏移量了。

    这个漏洞是个任意地址读写漏洞,所以也可以在确定task_struct地址之后,以当前用户的uid为特征去搜索内存,毕竟cred离task_struct不远。

     

  • 相关阅读:
    NYOJ-开灯问题
    cocos2dx 3.0 飞机大战
    Java 实现享元(Flyweight)模式
    MongoDB 操作手冊CRUD查询指针
    均值滤波
    cxf调用c#的webservice
    SharePoint 2013 术语和术语集介绍
    Unity3d 网络编程(二)(Unity3d内建网络各项參数介绍)
    linux服务器在运行210天左右宕机
    好的用户界面-界面设计的一些技巧
  • 原文地址:https://www.cnblogs.com/rebeyond/p/8603056.html
Copyright © 2011-2022 走看看