2022巅峰极客misc

easy_Forensic

Volatility安装教程:https://www.cnblogs.com/Jinx8823/p/16642215.html

直接用工具Volatility查看镜像信息

vol.py -f secret.raw imageinfo

image-20220831110142019

用第一个profile:Win7SP1×64,去查看桌面文件

vol.py -f secret.raw --profile=Win7SP1x64 filescan | grep 'Desk'

image-20220831110422080

image-20220831110842927

尝试去下载一下这些文件gift.jpg, hint.txt, secret.zip, wechat.txt, 因为题目中有提示是和微信相关的内容

vol.py -f secret.raw --profile=Win7SP1x64 dumpfiles -Q 0x000000007d80a7d0 -D ./

-Q 后面的就是上面这些文件前面的信息

image-20220831110759408

image-20220902153709455

要把下载下来的这几个文件改成对应的后缀

在这张jpg的图片里好像隐写了什么内容

image-20220831114259432

尝试修改高度

image-20220831114420193

jpeg图片格式:

标记码:FFC0表示图片是JPEG FFC2是JPG

数据段长度:00 11 =》17 = 8 + 3*3,说明组件数量有3个

样本精度:08,每个样本的信息是8bit

样本高度:01 F4(原本是01,改成了02)

样本宽度:05 00

图片里写着passwd:Nothing is more important than your life!

image-20220902152925758

直接输进去发现密码是错误的

结果发现要把空格改成下划线才行

Nothing_is_more_important_than_your_life!

image-20220902154307309

解密后发现是一段类似base64的编码,直接解码发现是乱码

image-20220902155259350

还有一个wechat.txt文件,直接打开发现也是乱码

根据题目描述flag是在微信中发出去的

猜测这个文件可能是一个微信数据库文件

因为微信数据库是用256位的AES-CBC加密的,它的密钥是32位的,而gift文件里的编码进行解码后也是32位的,所以猜测这是一个被加密的数据库

然后在网上找到了一篇解密微信数据库的文章,里面有直接解密的脚本

https://blog.7herightp4th.top/index.php/archives/22/

# -*- coding: utf-8 -*-
from Crypto.Cipher import AES
import hashlib, hmac, ctypes

SQLITE_FILE_HEADER = bytes("SQLite format 3",encoding='ASCII') + bytes(1)#文件头
IV_SIZE = 16
HMAC_SHA1_SIZE = 20
KEY_SIZE = 32
DEFAULT_PAGESIZE = 4096 #4048数据 + 16IV + 20 HMAC + 12
DEFAULT_ITER = 64000
#yourkey
password = bytes.fromhex("C0778CB1C62F4E5BB246F8DFE5DEC0117E4AE15959794D88886A4A2C5CDE9354".replace(' ',''))
with open(r'1.db', 'rb') as f:
    blist = f.read()
print(len(blist))

salt = blist[:16]#微信将文件头换成了盐
key = hashlib.pbkdf2_hmac('sha1', password, salt, DEFAULT_ITER, KEY_SIZE)#获得Key

first = blist[16:DEFAULT_PAGESIZE]#丢掉salt

# import struct
mac_salt = bytes([x^0x3a for x in salt])
mac_key = hashlib.pbkdf2_hmac('sha1', key, mac_salt, 2, KEY_SIZE)

hash_mac = hmac.new(mac_key ,digestmod = 'sha1')#用第一页的Hash测试一下
hash_mac.update(first[:-32])
hash_mac.update(bytes(ctypes.c_int(1)))
# hash_mac.update(struct.pack('=I',1))
if (hash_mac.digest() == first[-32:-12]):
    print('Correct Password')
else:
    raise RuntimeError('Wrong Password')

blist = [blist[i:i+DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE,len(blist),DEFAULT_PAGESIZE)]
with open(r'1.db', 'wb') as f:
    f.write(SQLITE_FILE_HEADER)#写入文件头
    t = AES.new(key ,AES.MODE_CBC ,first[-48:-32])
    f.write(t.decrypt(first[:-48]))
    f.write(first[-48:])
    for i in blist:
            t = AES.new(key ,AES.MODE_CBC ,i[-48:-32])
            f.write(t.decrypt(i[:-48]))
            f.write(i[-48:])

因为那个key用到了fromhex()函数,所以我们需要把gift里的数据先base64解密,再进行hex编码

image-20220902162201068

那个1.db就是前面下载的wechat.txt改后缀得来的

然后改一下脚本里的key,以及解密的文件

解密数据库成功

image-20220902162352434

最后用navicat打开,因为微信数据库是SQLite,所以用SQLite连接打开数据库

image-20220902163010589

因为微信的消息存储在Session表里,所以在Session里找到flag

image-20220902163117332

posted @ 2022-09-02 16:33  Jinx8823  阅读(155)  评论(0编辑  收藏  举报