Metasploit 渗透测试框架的基本使用(msf)

Metasploit 渗透测试框架的基本使用

一、Metasploit 渗透测试框架介绍

1.1 Metasploit 体系框架

image-20210210193939234

1.基础库:metasploit 基础库文件位于源码根目录路径下的 libraries 目录中,包括 Rex、framework-core和framework-base三部分

  • Rex:是整个框架所依赖的最基础的一些组件,如包装的网络套接字,网络应用协议客户端与服务器实现、日志子系统、渗透攻击支持例程、PostgreSQL以及 MySQL数据库支持等;
  • framework-core 库:扩展了 framework-core,提供更加简单的包装例程,并为处理框架各个方面的功能提供了一些功能类,用于支持用户接口与功能程序调用框架本身功能及框架集成模块;

2.模块:模块组织按照不同的用途分为6种类型的模块(Modules):

  • 辅助模块(Aux)
  • 渗透攻击模块(Exploits)
  • 后渗透攻击模块(Post)
  • 攻击载荷模块(payloads)
  • 编码器模块(Encoders)
  • 空指令模块(Nops)

payload 又称攻击载荷,主要用来建立目标与攻击机稳定连接的,可返回shell,也可以进行程序注入等

3.插件:插件能够扩充框架的功能,或者组装已有功能构成高级特性的组件。插件可以集成现有的一些外部安全工具,如 Nessus、OpenVAS 漏洞扫描器等,为用户接口提供了一些新的功能。

4.接口:包括msfconsole控制终端,msfcli命令行,msfgui图形化界面,armitage图形化界面以及msfapi远程调用接口。

5.功能程序:metsploit 还提供了一系列可直接运行的功能程序,支持渗透者与安全人员快速地利用metasploit框架内部能力完成一些特定任务,比如msfpayload、msfencode和msfvenom 可以将攻击载荷封装为可执行文件、C 语言、JavaScript 语言等多种形式、并可以进行各种类型的编码。

二、Metasploittable2-Linux 靶机系统介绍

2.1 靶机信息

image-20210211112042866

普通用户:msfadmin

密码:msfadmin

2.2 修改root用户密码

msfadmin@metasploitable:~$ sudo passwd root
[sudo] password for msfadmin:         //msfadmin
Enter new UNIX password:              //123456
Retype new UNIX password: 		       //123456
passwd: password updated successfully
msfadmin@metasploitable:~$ su root   //切换root用户
Password:                            //123456
root@metasploitable:/home/msfadmin# 

image-20210211112337793

三、Metasploit 基本使用方法

3.1 Metasploit 基本命令

Metasploit 程序需要使用 Postgresql数据库

PostgreSQL 世界上最先进的开源关系数据库

3.1.1 手动启动数据库

启动数据库是必须的,我们设置成开机自启

root@fengzilin53:~# systemctl start postgresql   //启动postgresql 
root@fengzilin53:~# systemctl enable postgresql  //设置为开机自启

启动metasploit两种方式

第一种:点击图标

image-20210211121012277

第二种:命令行启动

root@fengzilin53:~# msfconsole 

image-20210211121214549

3.1.2 查看帮助信息
msf5 > help

image-20210211121711856

通过help 查看帮助,能对msf有个整体的认识,msf相关命令分成以下类型

命令译文
Core Commands核心命令
Module Commands模块命令
Job Commands后台任务命令
Resource Script Commands资源脚本命令
Database Backend Commands数据库后端命令
Crendentials Backend Commands证书/凭证后端命令
Developer Commands开发人员命令

3.2 常用命令介绍

3.2.1 核心命令中 connect 命令

connect 命令 主要用于 远程连接主机,一般用于内网渗透,比较常用的命令就是 “connect 192.168.37.140 80

查看connect 命令参数

msf5 > connect 

image-20210211164701020

连接目标端口 80

msf5 > connect 192.168.37.111 80
[*] Connected to 192.168.37.111:80           //出现这个就可以输入 get/ 就可以看到服务器版本信息,有些网站看不到
/get
HTTP/1.1 400 Bad Request
Server: nginx/1.6.2
Date: Thu, 11 Feb 2021 09:04:00 GMT
Content-Type: text/html
Content-Length: 172
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
3.2.2 模块相关的命令 show 使用方法

show 命令用的很多

show 参数:all,encoders,nops,exploits,payloads,auxiliary,post,plugins,info,options

举例:列出metasploit 框架中的所有渗透攻击模块 expoits、payloads、auxiliary

msf5 > show exploits     //渗透攻击模块
msf5 > show payloads     //攻击载荷模块
msf5 > show auxiliary    //辅助攻击模块
3.2.3 模块相关的命令 search 搜索的使用方法
msf5 > search -h //查看帮助

image-20210211172144493

1.通过name 关键字查找

msf5 > search mysql //mysql是名字

image-20210211172343441

Name                                  Disclosure Date   Rank   Check  Description
名字                                      披露日期       排名   检查    说明        

2.通过路径进行查找

我们只记得模块的路径,可以用search 查找

msf5 > search path:mysql

image-20210211172801666

3.缩小查找范围 platfrom

platform:列出可以影响次平台的模块,也就是比较好的漏洞有时我们会搜索到大量的模块,可以用platform

msf5 > search platform:mysql

image-20210211173048703

4.通过类型查找 type

type:特定类型的模块(exploit,payload,auxiliary,encoder,evasion,post,or nop)

msf5 > search type:auxiliary

5.联合查找

msf5 > search name:mysql type:auxiliary

image-20210211173456912

6.根据 CVE 搜索 exploit 相关模块

查找:CVE-2017-8464 远程命令执行漏洞

msf5 > search cve:CVE-2017-8464 type:exploit

image-20210211174239336

3.2.4 模块相关的命令 use 使用方法

use 使用方法,找到模块的名字

1.找到漏洞名字

msf5 > search cve:CVE-2017-8464 type:exploit

2.装载一个渗透模块

msf5 > use exploit/windows/fileformat/cve_2017_8464_lnk_rce 
msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > back //退出 当前调用模块

image-20210211174641549

3.2.5 模块相关的命令 info 的使用方法

info:显示模块的相关信息

方法1
msf5 > info exploit/windows/fileformat/cve_2017_8464_lnk_rce 

方法2
msf5 > use exploit/windows/fileformat/cve_2017_8464_lnk_rce 
msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > info

image-20210211175039338

image-20210211175114937

信息内容介绍

1.可用目标,支持哪些操作系统

image-20210211175402934

2.Basic options: 调用漏洞需要的相关

image-20210211175448953

3.漏洞描述和执行过程

image-20210211175516912

4.参考文献

image-20210211175543336

3.2.6 模块的使用方法

查看模块的选项

msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > show options

image-20210211175743626

查看可以攻击哪些操作系统

msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > show targets

image-20210211175806298

设置 target 目标系统 并查看设置结果

msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > set target 1
msf5 exploit(windows/fileformat/cve_2017_8464_lnk_rce) > show options

image-20210211180213814

四、总结

本章学习了metasploit 的整个框架,以及常用命令介绍,攻击的整个流程,在实战会体现出来,整体的攻击方式类似,就是需要的信息不同,这里要收集相关的信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值