python脚本将ascii码形式的文件转换为真正的二进制文件

1、通过tcpdump在越狱手机上面抓取所有包,包含环路包

  将手机通过USB线连接电脑,并将其映射到本地端口,启动抓包

rvictl -s bb44203ca128c7b13bfc66fa34f6c1c9b428d0d9

ssh root@localhost -p 2222

tcpdump -s0 -i any  -w /tmp/aaa123aaa.pcap

 

2、通过wireshark分析过滤感兴趣的包

python脚本将ascii码形式的文件转换为真正的二进制文件_第1张图片

3、利用python脚本将二进制文本转换成真正的二进制数据

#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
__author__ = 'qqvipfunction'
import struct

if __name__ == '__main__':
    with open('/Users/qqvipfunction/Downloads/asciihex.txt') as fp:
        list = []
        for line in fp:
            line = line.lstrip().rstrip()
            for i in range(0, len(line), 2):
                hexItem = line[i] + line[i+1]
                list.append(int(hexItem, 16))

        with open('/Users/qqvipfunction/Downloads/asciihex.plist', 'wb') as f:
            for byte in list:
                f.write(struct.pack('B', byte))

 

转载于:https://www.cnblogs.com/doudouyoutang/p/6550114.html

你可能感兴趣的:(python脚本将ascii码形式的文件转换为真正的二进制文件)