vulhub Billub0x walkthrough
0x01 端口扫描
0x02 web渗透
好像在考注入,先目录爆破:
in.php:phpinfo
add.php:文件上传
test.php:任意文件下载
uploaded_images:图片保存路径
下载注入和文件上传页面的源码:
判断从注入下手:
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:
应该存在文件包含,尝试:
shadow读不了,先放一边,看其他文件
in.php、show.php:
给一个continue参数:
拿到了两个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:数据库配置文件
前往phpmy登录phpmyadmin:
从auth表拿到了登录凭据:biLLu@hEx_it
传内容为一句话的jpg文件,修改MIME:
尝试加mageic number:
成功上传
因为panel页面的load参数有include,所以也没必要用解析漏洞了,直接包含:
发现居然有一堆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出网:
拿到立足点
0x03 提权
基础向量枚举后无思路,感觉又是内核提权,跑linpeas:
3.13版本也对上了,优先尝试CVE-2015-1328,其次脏牛,最后其他
成功提权
0x04 反思总结
提供文件下载功能的test页面通过curl
传参直接可以看到内容:
1 curl -X POST --data "file=c.php" http://10.10.10.136/test.php
转义-单引号逃逸注入
登录页面可以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#’
phpmyadmin配置文件获取
本机的非预期提权方式,拿phpmyadmin配置文件,ssh root密码使用了与之相同的密码
配置文件获取方式:
公开信息利用:常用敏感信息git项目Auto_Wordlists/wordlists/file_inclusion_linux.txt at main · carlospolop/Auto_Wordlists (github.com)
注:数据库的登录凭据不一定和phpmyadmin的相同,是映射关系
问gpt:
0x05 靶机总结
端口扫描:80 web、22 ssh
web渗透:目录爆破出各功能页面,由文件包含拿到全部源码,审计后发现phpmyadmin登录凭据,登录后拿到主页面登录凭据;使用文件上传功能传图片马,由文件包含点getshell
提权:linpeas枚举,发现内核为熟悉的3.13.0(ubuntu),使用经典的37292.c成功提权