Tags:GIF分离
,QRCODE
,ZXING库
0x00. 题目
0x01. WP
01 分离GIF
工具路径:https://pan.baidu.com/s/1GyH7kitkMYywGC9YJeQLJA?pwd=Zmxh#list/path=/CTF附件/Tools
工具名称:风二西_GIF图片分离工具.zip
02 使用脚本批量扫描
exp.py
#将指定文件夹下的文件按顺序解码
import os
import zxingpath = "gifframe"
#读取多个文件
files= os.listdir(path) #按e和.将文件序号截出排序------依据实际情况修改
#files.sort(key=lambda x:int(x.split('e')[1].split(".")[0]))
files.sort(key=lambda x:int(x.split(".")[0]))
reader = zxing.BarCodeReader()
print(files)
#结果
string=''
for file in files:barcode = reader.decode(path+"\\"+file)print(file)#print(barcode.parsed,end="") #连续输出#需要分隔的情况#string+=barcode.parsed+','string+=barcode.parsed
print(string)
运行结果:
C:\Users\admin\Desktop\20220721_二维码GIF_CTF小学生群>python3 Barcodes_decode.py
000.png
001.png
002.png
003.png
004.png
005.png
006.png
007.png
008.png
009.png
010.png
011.png
012.png
013.png
014.png
015.png
016.png
017.png
SYC{F1aSh_so_f4sT}
扩展知识点:zxing库
1. 报错:zxing.BarCodeReaderException: ('Java JARs not found in classpath ...)
找到__init__.py
文件中的class BarCodeReader(object):
里面关于文件路径分隔符的判断:classpath_sep = ';' if sys.platform == 'nt' else ':' # https://stackoverflow.com/a/60211688
**【修正】 因为我们是在windows里面用,直接改为 classpath_sep = ';'
即可。
2. 报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdf in position 0: invalid continuation byte
找到__init__.py
文件中的class BarCodeReader
的decode
函数中codes = [BarCode.parse(result) for result in file_results]
使用了BarCode.parse(result)
中有两处bytes.decode()
调用,显然是utf-8
与中文编码GB18030/GBK/GB2312
不兼容导致
parsed = parsed[:-1].decode()raw = raw[:-1].decode()
【修正】 增加一个参数,改动如下:
BarCode.parse(cls, zxing_output, encoding='utf-8'):parsed = parsed[:-1].decode(encoding)raw = raw[:-1].decode(encoding)
BarCodeReader.(self, filenames, try_harder=False, possible_formats=None, pure_barcode=False, products_only=False, encoding='utf-8'):codes = [BarCode.parse(result, encoding=encoding) for result in file_results]
【使用】可以传参编码方式:zxing.BarCodeReader().decode(imgs[0],encoding='GBK')