Calls p0f and returns a user-friendly output
(pkt)
| 312 | |
| 313 | |
| 314 | def prnp0f(pkt): |
| 315 | """Calls p0f and returns a user-friendly output""" |
| 316 | # we should print which DB we use |
| 317 | try: |
| 318 | r = p0f(pkt) |
| 319 | except Exception: |
| 320 | return |
| 321 | if r == []: |
| 322 | r = ("UNKNOWN", "[" + ":".join(map(str, packet2p0f(pkt)[1])) + ":?:?]", None) # noqa: E501 |
| 323 | else: |
| 324 | r = r[0] |
| 325 | uptime = None |
| 326 | try: |
| 327 | uptime = pkt2uptime(pkt) |
| 328 | except Exception: |
| 329 | pass |
| 330 | if uptime == 0: |
| 331 | uptime = None |
| 332 | res = pkt.sprintf("%IP.src%:%TCP.sport% - " + r[0] + " " + r[1]) |
| 333 | if uptime is not None: |
| 334 | res += pkt.sprintf(" (up: " + str(uptime / 3600) + " hrs)\n -> %IP.dst%:%TCP.dport% (%TCP.flags%)") # noqa: E501 |
| 335 | else: |
| 336 | res += pkt.sprintf("\n -> %IP.dst%:%TCP.dport% (%TCP.flags%)") |
| 337 | if r[2] is not None: |
| 338 | res += " (distance " + str(r[2]) + ")" |
| 339 | print(res) |
| 340 | |
| 341 | |
| 342 | @conf.commands.register |
nothing calls this directly
no test coverage detected
searching dependent graphs…