Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501 pkt2uptime(pkt, [HZ=100])
(pkt, HZ=100)
| 341 | |
| 342 | @conf.commands.register |
| 343 | def pkt2uptime(pkt, HZ=100): |
| 344 | """Calculate the date the machine which emitted the packet booted using TCP timestamp # noqa: E501 |
| 345 | pkt2uptime(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 | |
| 361 | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None, |
no outgoing calls
no test coverage detected
searching dependent graphs…