网络安全人员一定要知道的Metasploit渗透框架!

简介

Metasploit是一款开源安全漏洞检测工具,附带数百个已知的软件漏洞,并保持频繁更新。被安全社区冠以“可以黑掉整个宇宙”之名的强大渗透测试框架。

Metasploit官网:https://www.metasploit.com/

MetasploitGithub仓库地址:https://github.com/rapid7/metasploit-framework

在这里插入图片描述

框架和相关术语简介:

Vulnerability:允许攻击者入侵或危害系统安全性的弱点称为漏洞,漏洞可能存在于操作系统,应用软件甚至网络协议中。

Exploit:攻击代码或程序,它允许攻击者利用易受攻击的系统并危害其安全性。每个漏洞都有对应的漏洞利用程序。Metasploit有超过 1700 个漏洞利用程序。

Payload:攻击载荷。它主要用于建立攻击者和受害者机器直接的连接,Metasploit有超过 500个有效攻击载荷。

Module:模块是一个完整的构件,每个模块执行特定的任务,并通过几个模块组成一个单元运行。这种架构的好处是可以很容易的将自己写的利用程序和工具集成到框架中。

使用方法

在MSF里面msfconsole可以说是最流行的一个接口程序。很多人一开始碰到msfconsole的时候就害怕了。那么多复杂的命令语句需要学习,但是msfconsole真的是一个强大的接口程序。Msfconsole提供了一个一体化的集中控制台。通过msfconsole,你可以访问和使用所有的metasploit的插件,payload,利用模块,post模块等等。Msfconsole还有第三方程序的接口,比如nmap,sqlmap等,可以直接在msfconsole里面使用。

image-20210731121233931

大家可以直接在命令行窗口输入msfconsole,然后回车。这样就打开了msfconsole。Msfconsole的系统文件和用户文件位于/usr/share/metasploit-framework/目录下。

image-20210731123822325

msf5 > help
Core Commands
=============

    Command       Description
    -------       -----------
    ?             Help menu
    banner        Display an awesome metasploit banner
    cd            Change the current working directory
    color         Toggle color
    connect       Communicate with a host
    exit          Exit the console
    get           Gets the value of a context-specific variable
    getg          Gets the value of a global variable
    grep          Grep the output of another command
    help          Help menu
    history       Show command history
    load          Load a framework plugin
    quit          Exit the console
    repeat        Repeat a list of commands
    route         Route traffic through a session
    save          Saves the active datastores
    sessions      Dump session listings and display information about sessions
    set           Sets a context-specific variable to a value
    setg          Sets a global variable to a value
    sleep         Do nothing for the specified number of seconds
    spool         Write console output into a file as well the screen
    threads       View and manipulate background threads
    tips          Show a list of useful productivity tips
    unload        Unload a framework plugin
    unset         Unsets one or more context-specific variables
    unsetg        Unsets one or more global variables
    version       Show the framework and console library version numbers


Module Commands
===============

    Command       Description
    -------       -----------
    advanced      Displays advanced options for one or more modules
    back          Move back from the current context
    clearm        Clear the module stack
    info          Displays information about one or more modules
    listm         List the module stack
    loadpath      Searches for and loads modules from a path
    options       Displays global options or for one or more modules
    popm          Pops the latest module off the stack and makes it active
    previous      Sets the previously loaded module as the current module
    pushm         Pushes the active or list of modules onto the module stack
    reload_all    Reloads all modules from all defined module paths
    search        Searches module names and descriptions
    show          Displays modules of a given type, or all modules
    use           Interact with a module by name or search term/index


Job Commands
============

    Command       Description
    -------       -----------
    handler       Start a payload handler as job
    jobs          Displays and manages jobs
    kill          Kill a job
    rename_job    Rename a job
    
Database Backend Commands
=========================

    Command           Description
    -------           -----------
    analyze           Analyze database information about a specific address or address range
    db_connect        Connect to an existing data service
    db_disconnect     Disconnect from the current data service
    db_export         Export a file containing the contents of the database
    db_import         Import a scan result file (filetype will be auto-detected)
    db_nmap           Executes nmap and records the output automatically
    db_rebuild_cache  Rebuilds the database-stored module cache (deprecated)
    db_remove         Remove the saved data service entry
    db_save           Save the current data service connection as the default to reconnect on startup
    db_status         Show the current data service status
    hosts             List all hosts in the database
    loot              List all loot in the database
    notes             List all notes in the database
    services          List all services in the database
    vulns             List all vulnerabilities in the database
    workspace         Switch between database workspaces

search参数

你使用msfconsole的时候,你会用到各种漏洞模块、各种插件等等。所以search命令就很重要。

先查看search的帮助信息

msf5 > search -h
Usage: search [<options>] [<keywords>:<value>]

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
  -o <file>         Send output to a file in csv format
  -S <string>       Regex pattern used to filter search results
  -u                Use module if there is one result

Keywords:
  aka         :  Modules with a matching AKA (also-known-as) name
  author      :  Modules written by this author
  arch        :  Modules affecting this architecture
  bid         :  Modules with a matching Bugtraq ID
  cve         :  Modules with a matching CVE ID
  edb         :  Modules with a matching Exploit-DB ID
  check       :  Modules that support the 'check' method
  date        :  Modules with a matching disclosure date
  description :  Modules with a matching description
  fullname    :  Modules with a matching full name
  mod_time    :  Modules with a matching modification date
  name        :  Modules with a matching descriptive name
  path        :  Modules with a matching path
  platform    :  Modules affecting this platform
  port        :  Modules with a matching port
  rank        :  Modules with a matching rank (Can be descriptive (ex: 'good') or numeric with comparison operators (ex: 'gte400'))
  ref         :  Modules with a matching 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)

Examples:
  search cve:2009 type:exploit
  search cve:2009 type:exploit platform:-linux

通过名称查找

查找名称含有mysql的漏洞

msf5 > search name:sql 

image-20210731125308481

通过模块查找

Metasploit上只有三中模块可以利用:

  • 第一种是exploit模块,也就是利用模块,包含主流的漏洞利用脚本,通常是对某些可能存在漏洞的目标进行漏洞利用。命名规则:操作系统/各种应用协议分类

  • 第二种是auxiliary模块,辅助模块,辅助渗透(端口扫描、登录密码爆破、漏洞验证等)。

  • 第三种是post模块,后渗透阶段模块,漏洞利用成功获得meterpreter之后,向目标发送的一些功能性指令,如:提权等。

search name:mysql type:exploit

image-20210731125436544

使用一个模块

通过search查找到模块之后,就可以使用use去使用这个模块

image-20210731130503792

info查看模块的信息

image-20210731135505930

使用完一个模块之后,可以使用set设置模块参数

rhosts是设置攻击目标,threads是设置线程数

image-20210731131257223

再次使用info查看信息

image-20210731135213725

使用show options也可以查看我们设置的参数

image-20210731132956700

run执行模块

image-20210731131637436

run -j可以让进程后台运行

image-20210731141649232

jobs查看后台进程 ,根据提供的编号配合kill杀死进程

image-20210731141836027

setg这个和set有些类似,但是不同的是这个是一个全局变量设置。设置一次后再保存,那么以后,这个漏洞模块你就不用重复设置。

image-20210731140120139

unset取消设置的参数 unsetg取消设置的全局参数

image-20210731135937409

back取消选择的模块

image-20210731132750096

connect参数主要用于远程连接主机。一般用于内网渗透。参数一般为IP地址加上端口号。

image-20210731133606982

edit使用vim去编辑当前的模块

image-20210731134736794

exit是退出msfconsole的命令。可以完全退出msfconsole,并且回到linux终端界面。

image-20210731134849932

msfconsole中依旧可以执行shell命令

image-20210731141121018

参考文档

metasploit msfconsole 命令参数

metasploit介绍及使用

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Metasploit 是一个常用的渗透测试框架,它可以帮助安全研究人员渗透测试人员识别和利用漏洞,以便在测试过程中评估网络和系统的安全性。以下是 Metasploit 渗透测试框架的基本使用方法: 1. 安装 MetasploitMetasploit 可以在 Windows、Linux 和 Mac OS X 等操作系统上运行。你可以从 Metasploit 的官方网站下载并安装它。 2. 启动 Metasploit:在命令行界面中输入 msfconsole 命令启动 Metasploit。 3. 搜索漏洞:在 Metasploit 中,你可以使用 search 命令来搜索漏洞。例如,如果你想搜索所有与 Apache 相关的漏洞,可以输入以下命令: search apache 4. 选择漏洞:通过搜索漏洞,你可以找到感兴趣的漏洞,并且可以使用 use 命令来选择一个要利用的漏洞。例如,如果你想选择 Apache Struts2 远程代码执行漏洞,可以输入以下命令: use exploit/multi/http/struts2_content_type_ognl 5. 配置选项:在选择漏洞后,你需要配置一些选项,例如目标 IP 地址和端口号、攻击载荷等。可以使用 show options 命令来查看所有可用选项,并使用 set 命令来配置选项。例如,如果你想设置目标 IP 地址为 192.168.1.100,可以输入以下命令: set RHOST 192.168.1.100 6. 运行攻击:在配置选项后,你可以使用 exploit 命令来运行攻击。Metasploit 将自动启动攻击载荷,并尝试利用漏洞。例如,如果你想运行 Apache Struts2 远程代码执行漏洞攻击,可以输入以下命令: exploit 7. 获取访问权限:如果攻击成功,Metasploit 将尝试获取访问权限。在访问权限获取之后,你可以使用 shell 命令来访问目标系统的命令行界面。例如,如果你想访问目标系统的 shell,可以输入以下命令: shell 上述是 Metasploit 渗透测试框架的基本使用方法,但请注意,在进行渗透测试时,请确保获得了所有必要的授权和许可,以避免违反法律和伦理规定。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值