initial
This commit is contained in:
commit
d7ed085c79
45
main.py
Normal file
45
main.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from pcapng import FileScanner, blocks
|
||||
from pcapng.blocks import EnhancedPacket
|
||||
|
||||
def printdata(s):
|
||||
hex_bytes = [f"{i:02x}" for i in s]
|
||||
return str(hex_bytes)
|
||||
|
||||
with open(r'', 'rb') as fp:
|
||||
scanner = FileScanner(fp)
|
||||
source="linux"
|
||||
if source=="windows":
|
||||
out=21
|
||||
data_length_start=23
|
||||
start_of_data=27
|
||||
elif source=="linux":
|
||||
out=10
|
||||
data_length_start=36
|
||||
start_of_data=64
|
||||
|
||||
for block in scanner:
|
||||
if isinstance(block, EnhancedPacket):
|
||||
real_length = block.packet_data[data_length_start+3] << 24 | block.packet_data[data_length_start+2] << 16 | block.packet_data[data_length_start+1] << 8 | block.packet_data[data_length_start]
|
||||
try:
|
||||
#print(block.packet_data[out])
|
||||
#if (source=="windows" and block.packet_data[out]==0x02) or (source=="linux" and block.packet_data[out-1]==0x03):
|
||||
#print("real_length=" + str(real_length))
|
||||
#print("command=" + str(block.packet_data[start_of_data:]))
|
||||
if 0xd6 == block.packet_data[start_of_data+12]:
|
||||
print("set scan mode=" + printdata(block.packet_data[start_of_data+12+1:start_of_data+12+1 + real_length]))
|
||||
elif 0xe5 == block.packet_data[start_of_data+12]:
|
||||
print("set scan mode2=" + printdata(block.packet_data[start_of_data+12+1:start_of_data +12+1+ real_length]))
|
||||
elif 0x2A == block.packet_data[start_of_data+12]:
|
||||
print("send code=" + printdata(block.packet_data[start_of_data+12+1:start_of_data+12 +1+ real_length]))
|
||||
elif 0xe1 == block.packet_data[start_of_data+12]:
|
||||
print("color cal=" + printdata(block.packet_data[start_of_data+12+1:start_of_data +12+1+ real_length]))
|
||||
elif 0xd8 == block.packet_data[start_of_data+12]:
|
||||
print("cancel=" + printdata(block.packet_data[start_of_data+12+1:start_of_data+12+1 + real_length]))
|
||||
elif 0x03 == block.packet_data[start_of_data+12]:
|
||||
print("request sense=" + printdata(block.packet_data[start_of_data+12+1:start_of_data+12+1 + real_length]))
|
||||
elif 0x12 == block.packet_data[start_of_data + 12]:
|
||||
print("inquery code=" + printdata(
|
||||
block.packet_data[start_of_data + 12 + 1:start_of_data + 12 + 1 + real_length]))
|
||||
|
||||
except Exception as e:
|
||||
continue
|
||||
Loading…
Reference in New Issue
Block a user