From 1b2c9496b6b5be2b46db0aa8336d7b0263c6cbbe Mon Sep 17 00:00:00 2001 From: William Stearns Date: Sat, 9 Feb 2019 14:41:40 -0500 Subject: [PATCH 1/2] Detect the location of p0f fingerprint libraries. --- scapy/modules/p0f.py | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scapy/modules/p0f.py b/scapy/modules/p0f.py index 96ae5c5c04a..29719208cd8 100644 --- a/scapy/modules/p0f.py +++ b/scapy/modules/p0f.py @@ -29,10 +29,34 @@ # unused import, only to initialize conf.route import scapy.route # noqa: F401 -conf.p0f_base = "/etc/p0f/p0f.fp" -conf.p0fa_base = "/etc/p0f/p0fa.fp" -conf.p0fr_base = "/etc/p0f/p0fr.fp" -conf.p0fo_base = "/etc/p0f/p0fo.fp" +if os.path.exists("/opt/local/share/p0f/p0f.fp"): + conf.p0f_base = "/opt/local/share/p0f/p0f.fp" +elif os.path.exists("/usr/share/p0f/p0f.fp"): + conf.p0f_base = "/usr/share/p0f/p0f.fp" +else: + conf.p0f_base = "/etc/p0f/p0f.fp" + +if os.path.exists("/opt/local/share/p0f/p0f.fp"): + conf.p0fa_base = "/opt/local/share/p0f/p0fa.fp" +elif os.path.exists("/usr/share/p0f/p0f.fp"): + conf.p0fa_base = "/usr/share/p0f/p0fa.fp" +else: + conf.p0fa_base = "/etc/p0f/p0fa.fp" + + +if os.path.exists("/opt/local/share/p0f/p0fr.fp"): + conf.p0fr_base = "/opt/local/share/p0f/p0fr.fp" +elif os.path.exists("/usr/share/p0f/p0fr.fp"): + conf.p0fr_base = "/usr/share/p0f/p0fr.fp" +else: + conf.p0fr_base = "/etc/p0f/p0fr.fp" + +if os.path.exists("/opt/local/share/p0f/p0fo.fp"): + conf.p0fo_base = "/opt/local/share/p0f/p0fo.fp" +elif os.path.exists("/usr/share/p0f/p0fo.fp"): + conf.p0fo_base = "/usr/share/p0f/p0fo.fp" +else: + conf.p0fo_base = "/etc/p0f/p0fo.fp" ############### From 48745251d0db4b198a04cf9552a3059d1331fc60 Mon Sep 17 00:00:00 2001 From: William Stearns Date: Sat, 9 Feb 2019 17:30:03 -0500 Subject: [PATCH 2/2] Fix tabs --- scapy/modules/p0f.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scapy/modules/p0f.py b/scapy/modules/p0f.py index 29719208cd8..c6da0113db2 100644 --- a/scapy/modules/p0f.py +++ b/scapy/modules/p0f.py @@ -30,33 +30,33 @@ import scapy.route # noqa: F401 if os.path.exists("/opt/local/share/p0f/p0f.fp"): - conf.p0f_base = "/opt/local/share/p0f/p0f.fp" + conf.p0f_base = "/opt/local/share/p0f/p0f.fp" elif os.path.exists("/usr/share/p0f/p0f.fp"): - conf.p0f_base = "/usr/share/p0f/p0f.fp" + conf.p0f_base = "/usr/share/p0f/p0f.fp" else: - conf.p0f_base = "/etc/p0f/p0f.fp" + conf.p0f_base = "/etc/p0f/p0f.fp" if os.path.exists("/opt/local/share/p0f/p0f.fp"): - conf.p0fa_base = "/opt/local/share/p0f/p0fa.fp" + conf.p0fa_base = "/opt/local/share/p0f/p0fa.fp" elif os.path.exists("/usr/share/p0f/p0f.fp"): - conf.p0fa_base = "/usr/share/p0f/p0fa.fp" + conf.p0fa_base = "/usr/share/p0f/p0fa.fp" else: - conf.p0fa_base = "/etc/p0f/p0fa.fp" + conf.p0fa_base = "/etc/p0f/p0fa.fp" if os.path.exists("/opt/local/share/p0f/p0fr.fp"): - conf.p0fr_base = "/opt/local/share/p0f/p0fr.fp" + conf.p0fr_base = "/opt/local/share/p0f/p0fr.fp" elif os.path.exists("/usr/share/p0f/p0fr.fp"): - conf.p0fr_base = "/usr/share/p0f/p0fr.fp" + conf.p0fr_base = "/usr/share/p0f/p0fr.fp" else: - conf.p0fr_base = "/etc/p0f/p0fr.fp" + conf.p0fr_base = "/etc/p0f/p0fr.fp" if os.path.exists("/opt/local/share/p0f/p0fo.fp"): - conf.p0fo_base = "/opt/local/share/p0f/p0fo.fp" + conf.p0fo_base = "/opt/local/share/p0f/p0fo.fp" elif os.path.exists("/usr/share/p0f/p0fo.fp"): - conf.p0fo_base = "/usr/share/p0f/p0fo.fp" + conf.p0fo_base = "/usr/share/p0f/p0fo.fp" else: - conf.p0fo_base = "/etc/p0f/p0fo.fp" + conf.p0fo_base = "/etc/p0f/p0fo.fp" ###############