代码拉取完成,页面将自动刷新
同步操作将从 openKylin/cybersectookits 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# Open the binary file and read it into a string
import os
from PIL import Image
# bin文件路径
filenames = os.listdir(r'F:\USTC-TK2016-master\normal-traffic\bin')
i=1
for filename in filenames:
# bin文件绝对路径
with open('F:\\USTC-TK2016-master\\normal-traffic\\bin\\'+filename, 'rb') as f:
#with open('F:\\USTC-TK2016-master\\bin\\110.bin', 'rb') as f:
data = f.read()
try:
print(filename)
# Create a list of pixels with the desired colors
pixels = []
for b in data:
if b >= 32 and b <= 127:
# Printable ASCII bytes are blue
pixels.append((0, 0, 255))
elif b >= 1 and b <= 31:
# Control bytes are green
pixels.append((0, 255, 0))
elif b >= 128 and b <= 255:
# Extend ASCII bytes are red
pixels.append((255, 0, 0))
elif b == 0:
# 0x00 is black
pixels.append((0, 0, 0))
elif b == 255:
# 0xFF is white
pixels.append((255, 255, 255))
image = Image.new('RGBA', (500, 1000))
# Put the pixel data into the image
image.putdata(pixels)
# 图片保存路径
image.save('F:\\USTC-TK2016-master\\normal-traffic\\bin\\' + str(i) + '.png')
i+=1
except:
data = data[:500*1000]
pixels = []
for b in data:
if b >= 32 and b <= 127:
# Printable ASCII bytes are blue
pixels.append((0, 0, 255))
elif b >= 1 and b <= 31:
# Control bytes are green
pixels.append((0, 255, 0))
elif b >= 128 and b <= 255:
# Extend ASCII bytes are red
pixels.append((255, 0, 0))
elif b == 0:
# 0x00 is black
pixels.append((0, 0, 0))
elif b == 255:
# 0xFF is white
pixels.append((255, 255, 255))
image = Image.new('RGBA', (500, 1000))
# Put the pixel data into the image
image.putdata(pixels)
# 图片保存路径
image.save('F:\\USTC-TK2016-master\\normal-traffic\\bin\\' + str(i) + '.png')
i+=1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。