服务热线

13879170742
网站导航
主营产品:
数据恢复学习
当前位置:主页 > 技术文章 > 数据恢复学习 >

一个文件按32768字节为一个逻辑块,然后查找块内

时间:2025-09-18 12:58 点击次数:
 
 
import sys
 
def filter_blocks(input_path, output_path, target_hex):
    """按32KB块过滤包含目标十六进制模式的块
    
    Args:
        input_path: 输入文件路径
        output_path: 输出文件路径
        target_hex: 要查找的十六进制字符串(带0x前缀)
    """
    # 移除0x前缀并转换为字节
    target_hex = target_hex.lower().replace('0x', '')
    target_bytes = bytes.fromhex(target_hex)
    block_size = 32768  # 32KB块大小
    
    with open(input_path, 'rb') as infile, open(output_path, 'wb') as outfile:
        while True:
            block = infile.read(block_size)
            if not block:
                break
            if target_bytes not in block:
                outfile.write(block)
 
if __name__ == '__main__':
    if len(sys.argv) != 4:
        print("用法: python hex_block_filter.py 输入文件 输出文件 0x目标十六进制")
        print("示例: python hex_block_filter.py input.bin output.bin 0x9c351d")
        sys.exit(1)
        
    filter_blocks(sys.argv[1], sys.argv[2], sys.argv[3])







  1. 功能:按32KB块处理二进制文件,过滤掉包含指定十六进制模式的块
  2. 特点:自动处理0x前缀,支持大文件流式处理
  3. 使用:命令行参数输入输出文件和目标十六进制值(带0x前缀)
  4. 示例:python hex_block_filter.py input.bin output.bin 0x9c351d
  5. 输出:生成的新文件将排除所有包含目标模式的32KB块
 

上一篇:powershell 删除包含 9C351D 的文件 录音笔

下一篇:没有了

Copyright © 2002-2020 南昌伟航数据恢复 版权所有  备案号:赣ICP备14010646-1号, 赣公网安备 36010302000054号

地址:江西省南昌市西湖区八一大道新大地2号楼3楼320(地铁2号线永叔路口2出口) 电话:13879170742 邮箱:827981817@qq.com

关注我们

服务热线

13879170742

扫一扫,关注我们