MCPcopy Create free account
hub / github.com/secdev/scapy / packet2p0f

Function packet2p0f

scapy/modules/p0f.py:647–674  ·  view source on GitHub ↗

Returns a p0f signature of the packet, and the direction. Raises TypeError if the packet isn't valid for p0f

(pkt)

Source from the content-addressed store, hash-verified

645
646
647def packet2p0f(pkt):
648 """
649 Returns a p0f signature of the packet, and the direction.
650 Raises TypeError if the packet isn't valid for p0f
651 """
652 pkt = validate_packet(pkt)
653 pkt = pkt.__class__(raw(pkt))
654
655 if pkt[TCP].flags.S:
656 if pkt[TCP].flags.A:
657 direction = "response"
658 else:
659 direction = "request"
660 sig = TCP_Signature.from_packet(pkt)
661
662 elif pkt[TCP].payload:
663 # XXX: guess_payload_class doesn't use any class related attributes
664 pclass = HTTP().guess_payload_class(raw(pkt[TCP].payload))
665 if pclass == HTTPRequest:
666 direction = "request"
667 elif pclass == HTTPResponse:
668 direction = "response"
669 else:
670 raise TypeError("Not an HTTP payload")
671 sig = HTTP_Signature.from_packet(pkt)
672 else:
673 raise TypeError("Not a SYN, SYN/ACK, or HTTP packet")
674 return sig, direction
675
676
677def fingerprint_mtu(pkt):

Callers 2

p0fFunction · 0.70
prnp0fFunction · 0.70

Calls 5

rawFunction · 0.90
HTTPClass · 0.90
validate_packetFunction · 0.85
from_packetMethod · 0.45
guess_payload_classMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…