import scapy.all as scapy
pkt = scapy.rdpcap('99.pcap')
test = pkt[0].sprintf("%IP.src%=%127.0.0.1%")
print(test)
result:
scapy.error.Scapy_Exception: Bad format string [%127.0.0.1%]
How can i assign 127.0.0.1 using the sprintf function ?
>Solution :
try this it may work:
import scapy.all as scapy
pkt = #the file
assignment = pkt[0].sprintf('%IP.src%')
assignment = '127.0.0.1'
print(assignment)
Note: sprintf expression cannot have the assignment operator