Getting Variables From Scapy Using Python
Hi I need help trying to access elements in what seems to be a tuple that scapy is returning. The code is below. ans,unans=sr(IP(dst='www.google.com',ttl=5)/ICMP(),verbose=0) ans.s
Solution 1:
If you ever need the value of a layer use the getlayer method. So just change things to:
ans = sr1(IP(dst="www.google.com",ttl=5)/ICMP(),verbose=0)
address = ans.getlayer(IP).src
There is also another method to if a layer exists that returns true or false. Here is an example of that one.
if ans.haslayer(IP):
print "Packet has the layer IP"
Post a Comment for "Getting Variables From Scapy Using Python"