文件隐写

文件隐写(Steganography)

文件头:List of file signatures

图片类


音频类


视频类


压缩包类

  • zip

    文件头:50 4B 03 04PK

    1. 伪加密(某压缩软件)

    2. 密码爆破(ARCHPR)

    3. 明文攻击工具

      bkcrack / rbkcrack

      攻击:

      1
      2
      3
      4
      5
      6
      7
      8
      rbkcrack -C xxx.zip -c xxx.png -p yyy.png

      -C 要攻击的压缩包
      -c 要攻击的压缩包里面的文件
      -p 刚创建的明文文件名

      *部分位置已知明文:
      bkcrack -C flag.zip -c flag.txt -p plain.txt -x 16 2d -x 21 2d -x 26 2d -x 31 2d -x 44 7d

      得到三个key解码:

      1
      2
      3
      4
      5
      6
      rbkcrack -C xxx.zip -c xxx.png -k be056038 0a143c0c 1ea08ca5 -d xxx.png

      -C 要攻击的压缩包
      -c 要攻击的压缩包里面的文件
      -k 刚生成的三个key
      -d 最终还原的文件名
  • rar

    文件头:52 61 72 21Rar!

    参考:https://blog.csdn.net/Claming_D/article/details/105899397

    1. 伪加密

      查看第24个16进制数后面的数是0还是4,是4表示进行了伪加密,将4改为0就可以解除伪加密(修改对应RarBlock的CRC值)。

    2. 爆破工具

      hashcat

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      获得hash值
      rar2john xxx.rar > rar.hash

      爆破
      hashcat -m 12500 -a 3 $RAR3$*0*a4243df9ba2d6023*b84a539412288864a2d6a9bfdcf2dd97 ?d?d?d?d?d?d -o out.txt
      hashcat -m 13000 -a 3 $RAR5$*0*a4243df9ba2d6023*b84a539412288864a2d6a9bfdcf2dd97 ?d?d?d?d?d?d -o out.txt

      -m 根据rar类型进行选择,hashcat官方提供的参数有两种,RAR3-hp类型为12500,RAR5类型为13000
      -a 3 为掩码方式破解,掩码格式如下
      ?d?d?d?d?d?d 表示为6位数字
      内置的掩码规则有:
      ?l :表示小写字母
      ?u :表示大写字母
      ?d :表示数字
      ?s :表示特殊字符
      ?a :表示上面四种的并集
      -o out.txt是输出结果

文本类


常用脚本

图片处理

  • CRC宽高爆破(png)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    import binascii
    import struct
    import sys

    fr = open('flag.png','rb').read()
    data = bytearray(fr[0x0c:0x1d])
    crc32key = eval('0x'+str(binascii.b2a_hex(fr[0x1d:0x21]))[2:-1])

    n = 4095
    for w in range(n):
    width = bytearray(struct.pack('>i', w))
    for h in range(n):
    height = bytearray(struct.pack('>i', h))
    for x in range(4):
    data[x+4] = width[x]
    data[x+8] = height[x]
    crc32result = binascii.crc32(data) & 0xffffffff
    if crc32result == crc32key:
    print(width,height)
    newpic = bytearray(fr)
    for x in range(4):
    newpic[x+16] = width[x]
    newpic[x+20] = height[x]
    fw = open('flag2.png','wb')
    fw.write(newpic)
    fw.close
    sys.exit()
  • 快速傅里叶变换(FFT)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    import cv2 as cv
    import numpy as np
    import matplotlib.pyplot as plt
    img = cv.imread('FFT.png', 0) #读为灰度图像
    f = np.fft.fft2(img)            #做频率变换
    fshift = np.fft.fftshift(f)     #转移像素做幅度谱
    s1 = np.log(np.abs(fshift))#取绝对值:将复数变化成实数取对数的目的为了将数据变化到0-255
    plt.subplot(121)
    plt.imshow(img, 'gray')
    plt.title('original')
    plt.subplot(122)
    plt.imshow(s1,'gray')
    plt.title('center')
    plt.show()

压缩包处理

  • 遍历zip压缩包

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    import os.path
    import zipfile
    import re
    dir_path='xxxxxxxx'
    files= os.listdir(dir_path)
    newfiles = files[::-1]
    print(newfiles)
    setee = []
    for file in newfiles: #遍历文件夹
    position = dir_path+'\\'+ file #构造绝对路径,"\\",其中一个'\'为转义符
    print (position)
    z = zipfile.ZipFile(position, 'r')
    for filename in z.namelist():
    bytes = z.read(filename)
    if b'Zmxh' in bytes:
    print(filename)
  • zlib解压字符串

    1
    2
    3
    4
    5
    6
    import zlib
    data = open("zlib_hex_data.txt", 'r', encoding="utf-8").read().replace(" ", "").replace("\n", "").strip()
    data_dec = zlib.decompress(bytes.fromhex(data))
    print(data_dec[:100])
    with open("zlib_data.rar", 'wb') as wf:
    wf.write(data_dec)

其他在线工具

wordle 填字:https://www.wsolver.com/

sokudo 数独:https://shudu.gwalker.cn/

virustotal 文件检测:https://www.virustotal.com/gui/home/upload

Tupper自指公式:https://tuppers-formula.ovh/

base-decode 任意base解码:https://basecrack.herokuapp.com/