admin管理员组文章数量:1620398
https://www.metasploit/ 官网
Metasploit框架体系
基础库文件 metasploit基础库文件位于源码根目录路径下的libraries目录中,包括rex,framework-core,framework-base三部分
rex :Rex是整个框架所依赖的最基础的一些组件,如包装的网络套接字,网络应用协议客户端与服务端实现,日志子系统,渗透攻击支持例程,postgreSQL以及MySql数据库支持。
framework-core :负责实现所有与各种类型的上层模块及插件的交互接口。
framework-base :拓展了framework-core,提供了更简单的包装例程,并为处理框架各个方面的功能提供了一些功能类,用于支持用户接口与功能程序调用框架本身内容及框架集成模块。
模块
Exploits :渗透攻击模块
Aux :辅助模块
Post :后渗透攻击模块
Nops :空指令模块
Payloads :攻击载荷模块
Encoders :编译器模块
接口
msfconsole :控制终端
msfcli :命令行
msfgui :图形化界面
armitage :图形化界面
msfapi :远程调用接口
插件 :扩充框架功能。
功能程序
msf*scan :
msfpayload :可将攻击载荷封装为可执行文件,c语言,javascript语言等。
msfencode :可将攻击载荷封装为可执行文件,c语言,javascript语言等。
msfvenom :可将攻击载荷封装为可执行文件,c语言,javascript语言等。
Metasploit目录结构
#cd /usr/share/metasploit-framework 进入metasploit-framnework文件夹
#ls 显示目录
data:Metasploit使用的可编译文件
documentation:为框架提供文档
lib:框架代码库
modules:实际的MSF模块
plugins:可以在运行时加载的插件
scripts:Meterpreter和其他脚本
tools:各种命令行工具
-----------------------------------------------------------------------------
Metasploitable2-Linux靶机内容
使用普通用户:msfadmin 密码:msfadmin 进行登录
准备修改root用户密码
#sudo passwd root
此时系统会让你输入msfadmin的密码 初始状态下登录密码如上
然后会让你输入两遍需要把root更改后的密码
更改为root登录
#su root
之后永久更改靶机的ip地址
-----------------------------------------------------------------------------
PostgreSQL和MySQL数据的应用场景区别:从应用场景来说,PostgreSQL更加适合严格的企业应用场景(比如金融、电信、ERP、CRM),
而MySQL更加适合业务逻辑相对简单、数据可靠性要求较低的互联网场景。
启动数据库服务 # systemctl start postgresql
设置成开机自启动 # systemctl enable postgresql
-----------------------------------------------------------------------------
启动Metasploit
可在开始菜单打开,也可在终端输入msfconsole命令打开
初次使用metasploit建议使用help命令来进行了解
大概分为以下几种类型:
Core Commands #核心命令
connect命令主要用于远程连接主机。
一般用于内网渗透。比较常用的命令就是“connect192.168.1.1 80”
192.168.1.1是IP地址80是端口号。
查看connect命令参数:
msf6> connect#直接回车
参数 说明 译文说明
-C Try to use CRLF for EOL sequence. 尝试用CRLF进行EOL序列。
-P <opt> Specify source port. 指定源端口。
-S <opt> Specify source address. 指定源地址。
-c <opt> Specify which Comm to use. 指定要使用哪个Comm。
-h Help banner. 帮助中心
-i <opt> Send the contents of a file. 发送文件的内容。
-p <opt> List of proxies to use. 要使用的代理列表。
-s Connect with SSL. 与SSL连接。
-u Switch to a UDP socket. 切换到UDP套接字。
-w <opt> Specify connect timeout. 指定连接超时。
-z Just try to connect, then return. 试着连接,然后返回。
PS:
示例获取服务器版本号 目标网站为rebatekey
connect rebatekey 80
终端提示Connected to rebatekey:80 (via: 198.18.40.134:37059) 译文:连接到rebatekey: 80
提交一个get请求获得服务器版本号
get
HTTP/1.1 400 Bad Request
Date: Fri, 19 Nov 2021 17:42:26 GMT
Server: Apache/2.4.48 (codeit) OpenSSL/1.1.1k PHP/7.4.22 <--apache 2.4.48
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
Module Commands #模块命令
Job Commands #后台任务命令
Resource Script Commands #资源脚本命令
Database Backend Commands #数据库后端命令
Credentials Backend Commands #证书/凭证后端命令
Developer Commands #开发人员命令
-----------------------------------------------------------------------------
模块相关命令之show使用方法
show命令用的很多。
“show”命令的有效参数是:all, encoders, nops, exploits, payloads, auxiliary, post,plugins, info, options
例1:
列出metasploit框架中的所有渗透攻击模块exploits。
msf6> show exploits
#列出metasploit框架中的所有渗透攻击模块。该命令列出数据较多,较为耗费时间。
msf6> show payloads
#列出metasploit框架中的所有攻击载荷。
msf6> show auxiliary#列出metasploit框架中的所有辅助攻击载荷。
-----------------------------------------------------------------------------
模块相关命令之search使用方法
search -h: 显示如下带译文
Usage: search [<options>] [<keywords>:<value>]
#search后主要加选项和关键字
Prepending a value with '-' will exclude any matching results.
在值前面加上'-'将排除任何匹配的结果。
If no options or keywords are provided, cached results are displayed.
如果没有提供选项或关键字,则显示缓存的结果。
OPTIONS:
选项:
-h Show this help information
-h显示帮助信息
-o <file> Send output to a file in csv format
-o <file>以csv格式输出到文件
-S <string> Regex pattern used to filter search results
-S <string>用于过滤搜索结果的正则表达式模式
-u Use module if there is one result
-u如果有一个结果,使用module
-s <search_column> Sort the research results based on <search_column> in ascending order
-s <search_column>根据<search_column>对搜索结果进行升序排序
-r Reverse the search results order to descending order
-r将搜索结果按降序排列
Keywords:
关键词:
aka : Modules with a matching AKA (also-known-as) name
aka:具有匹配aka(也称为-as)名称的模块
author : Modules written by this author
author:作者编写的模块
arch : Modules affecting this architecture
arch:影响这个架构的模块
bid : Modules with a matching Bugtraq ID
bid:与Bugtraq ID匹配的模块
cve : Modules with a matching CVE ID
cve:与cve ID匹配的模块
edb : Modules with a matching Exploit-DB ID
edb:与Exploit-DB ID匹配的模块
check : Modules that support the 'check' method
check:支持check方法的模块
date : Modules with a matching disclosure date
date:具有匹配披露日期的模块
description : Modules with a matching description
description:描述匹配的模块
fullname : Modules with a matching full name
fullname:具有匹配全名的模块
mod_time : Modules with a matching modification date
mod_time:具有匹配修改日期的模块
name : Modules with a matching descriptive name
name:具有匹配描述性名称的模块
path : Modules with a matching path
path:具有匹配路径的模块
platform : Modules affecting this platform
platform:影响这个平台的模块
port : Modules with a matching port
port:端口匹配的模块
rank : Modules with a matching rank (Can be descriptive (ex: 'good') or numeric with comparison operators (ex: 'gte400'))
rank:具有匹配级别的模块(可以是描述性的(例如:'good')或带有比较操作符的数字(例如:'gte400'))
ref : Modules with a matching ref
ref:具有匹配ref的模块
reference : Modules with a matching reference
引用:具有匹配引用的模块
target : Modules affecting this target
目标:影响此目标的模块
type : Modules of a specific type (exploit, payload, auxiliary, encoder, evasion, post, or nop)
type:特定类型的模块(exploit, payload, auxiliary, encoder, evasion, post, or nop)
Supported search columns:
支持搜索列:
rank : Sort modules by their exploitabilty rank
rank:根据可开发性等级对模块进行排序
date : Sort modules by their disclosure date.
date:按模块的公开日期排序。
Alias for disclosure_date
别名disclosure_date
disclosure_date : Sort modules by their disclosure date
disclosure_date:按模块的公开日期排序
name : Sort modules by their name
name:按名称对模块进行排序
type : Sort modules by their type
type:按类型对模块进行排序
check : Sort modules by whether or not they have a check method
check:按模块是否有check方法进行排序
Examples:
例子:
search cve:2009 type:exploit
搜索cve: 2009类型:利用
search cve:2009 type:exploit platform:-linux
搜索cve:2009类型:利用平台:-linux
search cve:2009 -s name
搜索cve:2009 -s name
search type:exploit -s type -r
搜索类型:exploit -s type -r
常用1:通过name关键词去搜索
search mysql #查找关于mysql的内容
ps:查找内容太过广泛,不推荐,除非这个关键字特别的精确
search 漏洞名(ms08-067) #win7永恒之蓝漏洞
search name:mysql #使用name关键字查找
# Name Disclosure Date Rank Check Description
编号 名称 发布日期 排名 检查 说明
Rank按照可靠性降序排列:
excellent 漏洞利用程序绝对不会使目标服务崩溃,就像SQL注入、命令执行、远程文件包含、本地文件包含等等。
除非有特殊情况,典型的内存破坏利用程序不可以被评估为该级别。
great 该漏洞利用程序有一个默认的目标系统,并且可以自动检测适当的目标系统,或者在目标服务的版本检查之后可以返回到一个特定的返回地址。
good 该漏洞利用程序有一个默认目标系统,并且是这种类型软件的“常见情况”(桌面应用程序的Windows 7,服务器的2012等)
normal 该漏洞利用程序是可靠的,但是依赖于特定的版本,并且不能或者不能可靠地自动检测。
average 该漏洞利用程序不可靠或者难以利用。
low 对于通用的平台而言,该漏洞利用程序几乎不能利用(或者低于50%的利用成功率)
manual 该漏洞利用程序不稳定或者难以利用并且基于拒绝服务(DOS)。如果一个模块只有在用户特别配置该模块的时候才会被用到,否则该模块不会被使用到,那么也可以评为该等级
常用2:通过路径进行查找
search path:mysql
常用3:通过platform缩小范围
search platform:mysql
说明:使用platform命令后,所查询的结果会列出rank比较高的模块
常用4:通过类型进行查找
search type:exploit #搜索exploit模块
组合查找:
search name:mysql type:exploit #在exploit攻击模块内查找mysql相关漏洞
补充5:根据CVE搜索exploit相关模块
CVE概述:
CVE的英文全称是“Common Vulnerabilities & Exposures”公共漏洞和暴露。
CVE就好像是一个字典表,为广泛认同的信息安全漏洞或者已经暴露出来的弱点给出一个公共的名称。使用一个共同的名字,
可以帮助用户在各自独立的各种漏洞数据库中和漏洞评估工具中共享数据,虽然这些工具很难整合在一起。
这样就使得CVE成为了安全信息共享的“关键字”。如果在一个漏洞报告中指明的一个漏洞,如果有CVE名称,
你就可以快速地在任何其它CVE兼容的数据库中找到相应修补的信息,解决安全问题
科普:CVE-2017-8464漏洞
通过执行cve_2017_8464_lnk_rce.rb模块,将生成大量的.lnk文件(对应盘符从D到Z)和要加载的.dll文件(后门文件)。
将所有样本文件拷到U盘里,然后将U盘插到Windows7机器上,默认自动执行
查找:CVE-2017-8464远程命令执行漏洞
search cve:CVE-2017-8464 type:exploit
查找:2020年linux相关的漏洞模块
search cve:2020 name:linux #搜索参数可以组合使用,可以更精准的查询到对应的模块。
-----------------------------------------------------------------------------
模块相关命令use的使用方法
use使用参数。如你要使用到某个模块,就要使用到use命令
示例:
use 模块的名字
-----------------------------------------------------------------------------
模块相关命令info的使用方法
info:显示模块的相关信息
使用方法:直接info即可显示需要的参数
Available targets:
可用目标
Basic options:
调用漏洞需要的相关参数
Description:
漏洞的描述和执行过程
References:
参考文档
show关联:
装载后>show options #查看模块的选项
装载后>show targets #查看可以攻击的目标
设置参数指令:set
示例:set RHOSTS xxx.xxx.xxx.xxx
执行run命令:直接输入即可,模块即可开始工作。(ps:开干开干run起来)
back关键词:不退出metasploit程序,只退出装载。exit会退出metasploit程序。
本文标签: 框架测试Metasploit
版权声明:本文标题:Metasploit渗透测试框架的使用 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728822108a1175401.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论