【CTF】WDCTF-2017 3-1 writeup

题目来源:WDCTF-2017

题目链接:https://adworld.xctf.org.cn/task/answer?type=misc&number=1&grade=1&id=4840&page=4

✨writeup

下载得到rar 解压得到没有扩展名的文件

刚拿到文件时完全没有思路

参考

https://blog.betamao.me/2017/09/17/2017-%E9%97%AE%E9%BC%8E%E6%9D%AF%E5%88%9D%E8%B5%9B-WP/

file命令

file命令查看文件类型

添加扩展名.pcapng然后用wireshark打开

wireshark追踪TCP流

追踪TCP流 流5时发现rar

显示和保存数据为原始数据

复制出来在010粘贴然后保存为rar

解压需要密码

追踪TCP流 流6时发现一段base64编码数据和一个Python脚本

19aaFYsQQKr+hVX6hl2smAUQ5a767TsULEUebWSajEo=

# coding:utf-8

__author__ = 'YFP'

from Crypto import Random
from Crypto.Cipher import AES

import sys
import base64

IV = 'QWERTYUIOPASDFGH'

def decrypt(encrypted):
  aes = AES.new(IV, AES.MODE_CBC, IV)
  return aes.decrypt(encrypted)

def encrypt(message):
  length = 16
  count = len(message)
  padding = length - (count % length)
  message = message + '' * padding
  aes = AES.new(IV, AES.MODE_CBC, IV)
  return aes.encrypt(message)

str = 'this is a test'

example = encrypt(str)
print(decrypt(example))

获取rar解压密码

对其进行base64解密然后使用Python脚本解密

修改Python脚本

# coding:utf-8

__author__ = 'YFP'

from Crypto import Random
from Crypto.Cipher import AES

import sys
import base64

IV = 'QWERTYUIOPASDFGH'

def decrypt(encrypted):
  aes = AES.new(IV, AES.MODE_CBC, IV)
  return aes.decrypt(encrypted)

def encrypt(message):
  length = 16
  count = len(message)
  padding = length - (count % length)
  message = message + '' * padding
  aes = AES.new(IV, AES.MODE_CBC, IV)
  return aes.encrypt(message)

str = 'this is a test'

example = encrypt(str)
print(decrypt(example))

#增加如下两行
a='19aaFYsQQKr+hVX6hl2smAUQ5a767TsULEUebWSajEo='
print(decrypt(base64.b64decode(a)))

脚本运行时Python3环境报错

使用Python2环境运行

需要安装pyCrypto模块

安装过程中出现报错可参考

https://blog.csdn.net/teloy1989/article/details/72862108

得到解压密码:No_One_Can_Decrypt_Me

解压后得到打开flag.txt得到flag

Flag:WDCTF{Seclab_CTF_2017}

结束。

⭐转载请注明出处

本文作者:双份浓缩馥芮白

原文链接:https://www.cnblogs.com/Flat-White/p/13714987.html

版权所有,如需转载请注明出处。

原文地址:https://www.cnblogs.com/Flat-White/p/13714987.html