靶场是实战的演习,通过靶场能学习很多东西,这样下次遇到类似的问题,就知道该怎么做了。
此次的靶场,我独立完成了60~70%,剩下的因为自己的粗心和知识面问题,导致错失100%完成度。好了,废话不多说,我会在过程中详细说明自己的思路。
一、信息收集
nmap扫描
我平时使用的最多的是这条nmap命令:
nmap -sV -sC -A -Pn -oN ip.txt ip
但是这次的靶场,我只扫出了一个21端口,只有使用了下面这条语句,才能完整把这次的靶场端口全扫出来。
nmap -sT -sV -A -p- -Pn -T5 -oN ip.txt ip
区别在哪里
-p-、T5和-sT
1、-p是指定端口,-p-是指定1-65535,也就是全端口扫描。
2、sT Tcp connect() scan,不同于sS(半开式扫描,不需要完整的TCP三次握手也能获取主机信息),sT需要建立三次握手
3、T5 这里的T后跟0 ~ 5,默认的是T3,数字越大,代表扫描速度越快,之所以分为不同的扫描速度等级,是为了根据实际情况用于IDS躲避,比如0~1这两种模式。这里设置为T5是因为靶机在本地虚拟机,没有IDS保护。
造成第一次扫描不全面的原因,是因为少了指定全端口扫描-p-式扫描,已验证。
贴上端口信息:
21/tcp open ftp vsftpd 2.0.8 or later
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r-- 1 0 0 88 Jun 13 00:02 note.txt
| ftp-syst:
| STAT:
| FTP server status:
| Connected to 172.16.230.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 1
| vsFTPd 3.0.2 - secure, fast, stable
|_End of status
1515/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-title: Mission-Pumpkin
3535/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 d8:8d:e7:48:3a:3c:91:0e:3f:43:ea:a3:05:d8:89:e2 (DSA)
| 2048 f0:41:8f:e0:40:e3:c0:3a:1f:4d:4f:93:e6:63:24:9e (RSA)
| 256 fa:87:57:1b:a2:ba:92:76:0c:e7:85:e7:f5:3d:54:b1 (ECDSA)
|_ 256 fa:e8:42:5a:88:91:b4:4b:eb:e4:c3:74:2e:23:a5:45 (ED25519)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
同时打开目录扫描工具,扫描http://172.16.230.154:1515/,网站端口不在默认的80端口。
二、FTP
看到ftp支持匿名访问,于是
由于是匿名,所以password无论输入什么都会让你成功登录。打开下载的note.txt内容:
Hello Dear!
Looking for route map to PumpkinGarden? I think jack can help you find it.
ok.
三、Getshell
扫描目录发现/img/目录
打开clue.txt,内容:
c2NhcmVjcm93IDogNVFuQCR5
使用base64进行解码:
scarecrow : 5Qn@$y
看起来像是账号密码?使用ssh进行尝试
ssh -p 3535 scarecrow@172.16.230
OK,成功进入
ls,看到还有一个note.txt,打开:
Oops!!! I just forgot; keys to the garden are with LordPumpkin(ROOT user)!
Reach out to goblin and share this "Y0n$M4sy3D1t" to secretly get keys from LordPumpkin.
这里我的工地英文使我陷入了尴尬,我一度卡在这里,因为我认为这里给的信息是使用:LordPumpkin:Y0n M 4 s y 3 D 1 t 去 切 换 用 户 , 后 来 仔 细 阅 读 发 现 并 不 是 ! 而 是 g o b l i n : Y 0 n M4sy3D1t去切换用户,后来仔细阅读发现并不是!而是goblin:Y0n M4sy3D1t去切换用户,后来仔细阅读发现并不是!而是goblin:Y0nM4sy3D1t,粗心啊!
ok,切换用户执行,推荐使用ssh登录goblin
发现goblin还是有个note,内容:
Hello Friend! I heard that you are looking for PumpkinGarden key.
But Key to the garden will be with LordPumpkin(ROOT user), don't worry, I know where LordPumpkin had placed the Key.
You can reach there through my backyard.
Here is the key to my backyard
https://www.securityfocus.com/data/vulnerabilities/exploits/38362.sh
四、提权
由于某些不可抗力因素,我无法下载到这个脚本,于是乎,查看别人的wirteup,手敲了一遍这个shell脚本,敲的时候我还有些郁闷,这不是一些shell命令么?贴上:
好的,使用python -m simpleHTTPServer 8086将本地的脚本下载到靶机。但是执行过程总是失败,我以为执行这个就可以,后来我终于了解它的用法了,两种用法:
第一种:
从cd /tmp开始,依次执行到第19行,会发现已经提权成root权限。
第二种:
./38364.sh (你有权限编辑的文件)
这里因为靶机每隔15s就会删除你的文件,嫌麻烦就没去试了。
最终拿到PumpkinGarden_Key
也就是最终的flag
base64解密,Congratulations!