parent
a6ebee15c9
commit
83c01736b3
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import scapy.all as scapy
|
|
||||||
import scapy.contrib.modbus as mb
|
|
||||||
|
|
||||||
valeursPropres={}
|
|
||||||
valeursPasPropres=[]
|
|
||||||
machin=["","",""]
|
|
||||||
|
|
||||||
def decode(pkt):
|
|
||||||
prt=0
|
|
||||||
cle=["",""]
|
|
||||||
f=open("truc.txt","w")
|
|
||||||
if "ModbusADU" in pkt:
|
|
||||||
grPkt=pkt["ModbusADU"].show(dump=True)
|
|
||||||
lPkt=grPkt.splitlines()
|
|
||||||
for i in lPkt:
|
|
||||||
if "Addr" in i:
|
|
||||||
print(i)
|
|
||||||
addresse=i[17:]
|
|
||||||
cle[1]=addresse
|
|
||||||
machin[1]=addresse
|
|
||||||
if "Write" in i or "Read" in i:
|
|
||||||
print(i)
|
|
||||||
if "Coil" in i:
|
|
||||||
cle[0]="C"
|
|
||||||
machin[0]="C"
|
|
||||||
else:
|
|
||||||
cle[0]="R"
|
|
||||||
machin[0]="R"
|
|
||||||
if "Value" in i or "coilStatus" in i or "registerVal" in i:
|
|
||||||
print(i)
|
|
||||||
machin[2] = i[-5:]
|
|
||||||
if "" not in machin:
|
|
||||||
print(machin)
|
|
||||||
|
|
||||||
scapy.sniff(iface="lo", prn=decode)
|
|
||||||
|
|
Loading…
Reference in new issue