vulhub Billub0x

vulhub Billub0x walkthrough

0x01 端口扫描

image.png

image.png

image.png

image.png

image.png

0x02 web渗透

image.png

好像在考注入,先目录爆破:

image.png

in.php:phpinfo

image.png

add.php:文件上传

image.png

test.php:任意文件下载

image.png

uploaded_images:图片保存路径

image.png

下载注入和文件上传页面的源码:

image.png

image.png

判断从注入下手:

1
$uname=str_replace('\'','',urldecode($_POST['un']));                                    $pass=str_replace('\'','',urldecode($_POST['ps']));                                     $run='select * from auth where  pass=\''.$pass.'\' and uname=\''.$uname.'\'';           $result = mysqli_query($conn, $run);      

单引号被事先转义,注入走不通,再看文件上传
从源码发现没有添加action标签指向地址,是空壳页面,再换
这次再将目录爆破时的其他php文件全下载

test.php:

image.png

应该存在文件包含,尝试:

image.png

image.png

shadow读不了,先放一边,看其他文件

in.php、show.php:

image.png

给一个continue参数:

image.png

拿到了两个user
再看其他文件

panel.php:主页面
页面逻辑:include对应功能页面,且参数可控

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if(isset($_POST['continue']))
{
$dir=getcwd();
$choice=str_replace('./','',$_POST['load']);

if($choice==='add')
{
include($dir.'/'.$choice.'.php');
die();
}

if($choice==='show')
{

include($dir.'/'.$choice.'.php');
die();
}
else
{
include($dir.'/'.$_POST['load']);
}

}

文件上传功能:检查后缀、MIME

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if(isset($_POST['upload']))
{

$name=mysqli_real_escape_string($conn,$_POST['name']);
$address=mysqli_real_escape_string($conn,$_POST['address']);
$id=mysqli_real_escape_string($conn,$_POST['id']);

if(!empty($_FILES['image']['name']))
{
$iname=mysqli_real_escape_string($conn,$_FILES['image']['name']);
$r=pathinfo($_FILES['image']['name'],PATHINFO_EXTENSION);
$image=array('jpeg','jpg','gif','png');
if(in_array($r,$image))
{
$finfo = @new finfo(FILEINFO_MIME);
$filetype = @$finfo->file($_FILES['image']['tmp_name']);
if(preg_match('/image\/jpeg/',$filetype ) || preg_match('/image\/png/',$filetype ) || preg_match('/image\/gif/',$filetype ))
{
if (move_uploaded_file($_FILES['image']['tmp_name'], 'uploaded_images/'.$_FILES['image']['name']))
{
echo "Uploaded successfully ";
$update='insert into users(name,address,image,id) values(\''.$name.'\',\''.$address.'\',\''.$iname.'\', \''.$id.'\')';
mysqli_query($conn, $update);

}
}
else
{
echo "<br>i told you dear, only png,jpg and gif file are allowed";
}
}
else
{
echo "<br>only png,jpg and gif file are allowed";

}
}
}

c.php:数据库配置文件

image.png

前往phpmy登录phpmyadmin:

image.png

image.png

从auth表拿到了登录凭据:biLLu@hEx_it

image.png

传内容为一句话的jpg文件,修改MIME:

image.png

尝试加mageic number:

image.png

成功上传

image.png

因为panel页面的load参数有include,所以也没必要用解析漏洞了,直接包含:

image.png

image.png

发现居然有一堆disable_funs:
pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority

幸运的是反弹shell用的没ban全,测试发现可以curl出网:

image.png

拿到立足点

0x03 提权

基础向量枚举后无思路,感觉又是内核提权,跑linpeas:

image.png

3.13版本也对上了,优先尝试CVE-2015-1328,其次脏牛,最后其他

image.png

image.png

成功提权

0x04 反思总结

  1. 提供文件下载功能的test页面通过curl传参直接可以看到内容:
1
curl -X POST --data "file=c.php" http://10.10.10.136/test.php

image.png

转义-单引号逃逸注入

登录页面可以sql注入:将第一个参数的后引号转义,从而使第二个参数的前引号被闭合,导致第二个参数逃逸

1
$uname=str_replace('\'','',urldecode($_POST['un']));                                    $pass=str_replace('\'','',urldecode($_POST['ps']));                                     $run='select * from auth where  pass=\''.$pass.'\' and uname=\''.$uname.'\'';           $result = mysqli_query($conn, $run);      

查询语句:
select * from auth where pass=’PASS’ and uname=’NAME’

故让PASS的值为\,NAME的值为 or 1#达成注入,写入后为:
select * from auth where pass=’ \‘ and uname=’ or 1#’
image.png

phpmyadmin配置文件获取

本机的非预期提权方式,拿phpmyadmin配置文件,ssh root密码使用了与之相同的密码

配置文件获取方式:

  1. 公开信息利用:常用敏感信息git项目Auto_Wordlists/wordlists/file_inclusion_linux.txt at main · carlospolop/Auto_Wordlists (github.com)

image.png

image.png

注:数据库的登录凭据不一定和phpmyadmin的相同,是映射关系

  1. 问gpt:

image.png

0x05 靶机总结

  1. 端口扫描:80 web、22 ssh
  2. web渗透:目录爆破出各功能页面,由文件包含拿到全部源码,审计后发现phpmyadmin登录凭据,登录后拿到主页面登录凭据;使用文件上传功能传图片马,由文件包含点getshell
  3. 提权:linpeas枚举,发现内核为熟悉的3.13.0(ubuntu),使用经典的37292.c成功提权

vulhub Billub0x
https://fyhypo.github.io/blog/vulnhub/vulnhub Billub0x/
作者
FYHypo
发布于
2024年3月28日
许可协议