Returns a p0f signature of the packet, and the direction. Raises TypeError if the packet isn't valid for p0f
(pkt)
| 645 | |
| 646 | |
| 647 | def 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 | |
| 677 | def fingerprint_mtu(pkt): |
no test coverage detected
searching dependent graphs…