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

Function pkt2uptime

scapy/modules/p0fv2.py:343–358  ·  view source on GitHub ↗

Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501 pkt2uptime(pkt, [HZ=100])

(pkt, HZ=100)

Source from the content-addressed store, hash-verified

341
342@conf.commands.register
343def pkt2uptime(pkt, HZ=100):
344 """Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501
345pkt2uptime(pkt, [HZ=100])"""
346 if not isinstance(pkt, Packet):
347 raise TypeError("Not a TCP packet")
348 if isinstance(pkt, NoPayload):
349 raise TypeError("Not a TCP packet")
350 if not isinstance(pkt, TCP):
351 return pkt2uptime(pkt.payload)
352 for opt in pkt.options:
353 if opt[0] == "Timestamp":
354 # t = pkt.time - opt[1][0] * 1.0/HZ
355 # return time.ctime(t)
356 t = opt[1][0] / HZ
357 return t
358 raise TypeError("No timestamp option")
359
360
361def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,

Callers 1

prnp0fFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…