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

Function prnp0f

scapy/modules/p0fv2.py:314–339  ·  view source on GitHub ↗

Calls p0f and returns a user-friendly output

(pkt)

Source from the content-addressed store, hash-verified

312
313
314def 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

Callers

nothing calls this directly

Calls 5

pkt2uptimeFunction · 0.85
joinMethod · 0.80
p0fFunction · 0.70
packet2p0fFunction · 0.70
sprintfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…