win10下快速搭建metasploitable3教程-简单版-已避坑

最近搭建metasploitable3时遇到了诸多问题,有一说一不管是网上的教程还是官方的教程都tm全是坑,我也是服的,经过三天的折腾才tm装好靶场,网上有很多傻卵只会转发复制粘贴,坑人不浅,太智障了,这里记录下搭建教程给后来者避坑:

官方git:https://github.com/rapid7/metasploitable3

搭建方法:

1.你可以选择自己从github下载源文件编译自己的box,然后再安装;

2.也可以直接用vagrant快速搭建(vagrant相当于docker,vagrantfile相当于dockerfile,建议抽五分钟找个文章看一下);

 

因为本教程为快速搭建,从源码编译的方法有兴趣的自己探索,我们直接跳过packer,用vagrant搭建:

 

一、预准备

1.安装vagrant,自己去下载最新版即可;

2.安装插件:vagrant plugin install vagrant-reload;

3.安装virtualbox最新版;

 

二、开始安装

依次执行以下脚本

注意:vagrant up会安装两个虚拟机,一版是ubuntu1404下的,一版是win server 2008的,我们用一款即可(只用一款需要把Vagrantfile中对应的脚本删除),也可以都用

mkdir metasploitable3-workspace
cd metasploitable3-workspace
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile" -OutFile "Vagrantfile"
vagrant up

 没错,就是这么简单,如果你可以无报错地执行完,那恭喜你,你是一个幸运儿,不用继续看了

执行报错的同学可以参考我报错的解决方案(如果是同一种错误的话)

三、错误解决:

错误1.Invoke-WebRequest -Uri "https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile" -OutFile 执行太慢导致超时

解决:可以直接复制这个链接,在浏览器打开,然后复制内容并在本地某任意文件夹创建名为Vagrantfile的文件,粘贴进去,继续执行下一步

 

错误2:执行vagrant up时,在ssh时超时

解决:1.检查virtualbox的端口转发规则,发现没有问题

          2.在宿主机电脑执行

netstat -ano | findstr "2222"

发现没用进程使用2222端口(为什么是这个端口?脚本默认的virtualbox端口转发规则)

      3.执行

netsh winsock reset all
netsh int ipv4 reset all
netsh int ipv6 reset all
netsh int httpstunnel reset all
netsh int isatap reset all
netsh int portproxy reset all
netsh int tcp reset all
netsh int teredo reset all

重置网络,重启电脑,问题解决;

 

错误3.ub1404安装完成后,在安装win2k8版本时又出错了,远程桌面连接超时

解决:1.经过错误2的经验,优先考虑是端口转发失败的问题,查看端口占用后发现脚本设置的转发端口皆有监听并且telnet进行端口测试成功;

          2.多次删除重新执行脚本,未果;

         3.进C:\Users\用户名\.vagrant.d\boxes\rapid7-VAGRANTSLASH-metasploitable3-win2k8\0.1.0-weekly\virtualbox目录,会看到一个ovf文件(前面脚本下载的,按照我的顺序执行的都用,没有的自己去vagrand cloud下载)

        4.下载安装vmware,导入虚拟机,选择刚才的ovf文件,设置硬件参数,导入完成,启动虚拟机,一切正常;

        5.打开之前下载的Vagrantfile脚本,找到win2k8设置的那段代码

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.synced_folder '.', '/vagrant', disabled: true
  config.vm.define "ub1404" do |ub1404|
    ub1404.vm.box = "rapid7/metasploitable3-ub1404"
    ub1404.vm.hostname = "metasploitable3-ub1404"
    config.ssh.username = 'vagrant'
    config.ssh.password = 'vagrant'

    ub1404.vm.network "private_network", ip: '172.28.128.3'

    ub1404.vm.provider "virtualbox" do |v|
      v.name = "Metasploitable3-ub1404"
      v.memory = 2048
    end
  end

  config.vm.define "win2k8" do |win2k8|
    # Base configuration for the VM and provisioner
    win2k8.vm.box = "rapid7/metasploitable3-win2k8"
    win2k8.vm.hostname = "metasploitable3-win2k8"
    win2k8.vm.communicator = "winrm"
    win2k8.winrm.retry_limit = 60
    win2k8.winrm.retry_delay = 10

    win2k8.vm.network "private_network", type: "dhcp"

    win2k8.vm.provider "libvirt" do |v|
      v.memory = 4096
      v.cpus = 4
      v.video_type = 'qxl'
      v.input :type => "tablet", :bus => "usb"
      v.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
      v.channel :type => 'spicevmc', :target_name => 'com.redhat.spice.0', :target_type => 'virtio'
      v.graphics_type = "spice"

      # Enable Hyper-V enlightenments: https://blog.wikichoon.com/2014/07/enabling-hyper-v-enlightenments-with-kvm.html
      v.hyperv_feature :name => 'stimer',  :state => 'on'
      v.hyperv_feature :name => 'relaxed', :state => 'on'
      v.hyperv_feature :name => 'vapic',   :state => 'on'
      v.hyperv_feature :name => 'synic',   :state => 'on'
    end
    # Configure Firewall to open up vulnerable services
    case ENV['MS3_DIFFICULTY']
      when 'easy'
        win2k8.vm.provision :shell, inline: "C:\\startup\\disable_firewall.bat"
      else
        win2k8.vm.provision :shell, inline: "C:\\startup\\enable_firewall.bat"
        win2k8.vm.provision :shell, inline: "C:\\startup\\configure_firewall.bat"
    end

    # Insecure share from the Linux machine
    win2k8.vm.provision :shell, inline: "C:\\startup\\install_share_autorun.bat"
    win2k8.vm.provision :shell, inline: "C:\\startup\\setup_linux_share.bat"
    win2k8.vm.provision :shell, inline: "rm C:\\startup\\*" # Cleanup startup scripts
  end
end

 发现脚本只不过是在虚拟机加载成功后进行了硬件的设置和几个bat命令的执行,硬件我们自己按需设置即可,几个脚本大家可以在虚拟机的c\\startup目录下找到,

依次执行

C:\\startup\\disable_firewall.bat
C:\\startup\\install_share_autorun.bat
C:\\startup\\setup_linux_share.bat

即可

 
 
  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

THMAIL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值