数位板流量分析探索

写这个主要是因为刷题刷到了[RoarCTF2019]davinci_cipher,流量包里有数位板流量不是很会搞,于是上网搜了一波顺便水篇博客(

这是查到的数位板流量的数据解析,简单解读下并以下面的这一段提取出的数据为例

10402a46001e3c0000000000000000003f00000000000000000000

其中x所对应的就是第5到8位,y对应的是11到14位,即'2a46'和'1e3c',并且x和y的数值都是以小端存储,所以这里x和y的10进制值就是17962和15390。因此,只要提取出数据然后提取这两位再转成10进制值后画图就可以还原数位板上的图像了。

于是先写出了这个初步的脚本

import os
import matplotlib.pyplot as plt
os.system("tshark -r 1.pcapng -T fields -e usb.capdata| sed '/^\s*$/d' > 1.txt")
line=open('1.txt').read().splitlines()
xx = []
yy = []
for i in line:
       x0=int(i[4:6],16)
       x1=int(i[6:8],16)
       x=x0+x1*256
       y0=int(i[10:12],16)
       y1=int(i[12:14],16)
       y=y0+y1*256
       xx.append(x)
       yy.append(y)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_title("result")
ax1.scatter(xx, yy, c='b', marker='o')
plt.show()

画出来的结果是这样的

草,居然是倒过来的,于是修改一下脚本

import os
import matplotlib.pyplot as plt
os.system("tshark -r 1.pcapng -T fields -e usb.capdata| sed '/^\s*$/d' > 1.txt")
line=open('1.txt').read().splitlines()
xx = []
yy = []
for i in line:
       x0=int(i[4:6],16)
       x1=int(i[6:8],16)
       x=x0+x1*256
       y0=int(i[10:12],16)
       y1=int(i[12:14],16)
       y=y0+y1*256
       xx.append(x)
       yy.append(-y)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_title("result")
ax1.scatter(xx, yy, c='b', marker='o')
plt.show()

结果如下

倒是能正常显示了,但是看起来很怪,再上网搜下大佬的博客,发现了大佬修改过的脚本显示结果还可以,于是改了一下整合成了最终版的脚本

import os
import matplotlib.pyplot as plt
os.system("tshark -r 1.pcapng -T fields -e usb.capdata| sed '/^\s*$/d' > 1.txt")
data=[]
with open('1.txt',"r") as f:
   for line in f.readlines():
       if line[16:18] !="00":
           data.append(line)
X = []
Y = []
for line in data:
       x0=int(line[4:6],16)
       x1=int(line[6:8],16)
       x=x0+x1*256
       y0=int(line[10:12],16)
       y1=int(line[12:14],16)
       y=y0+y1*256
       X.append(x)
       Y.append(-y)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_title("result")
ax1.scatter(X, Y, c='b', marker='o')
plt.show()

显示效果如下,很不错

ok,就这么多了,继续摆(

posted @ 2022-09-07 20:16  zysgmzb  阅读(304)  评论(0编辑  收藏  举报