Scapy did not handle the DLT_LOOP type that is used when sniffing

from OpenBSD loopback device.  Add a new layer for that.
ok sthen@
This commit is contained in:
bluhm 2012-01-12 03:16:24 +00:00
parent bd20d5b11f
commit 144304141e
4 changed files with 55 additions and 3 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.17 2011/09/16 11:13:40 espie Exp $
# $OpenBSD: Makefile,v 1.18 2012/01/12 03:16:24 bluhm Exp $
COMMENT= powerful interactive packet manipulation in python
MODPY_EGG_VERSION= 2.1.0
DISTNAME= scapy-${MODPY_EGG_VERSION}
REVISION= 1
REVISION= 2
CATEGORIES= net

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-scapy_config_py,v 1.1 2012/01/12 03:16:24 bluhm Exp $
--- scapy/config.py.orig Mon Dec 14 16:31:55 2009
+++ scapy/config.py Tue Sep 20 23:49:47 2011
@@ -366,7 +366,7 @@ extensions_paths: path or list of paths where extensio
netcache = NetCache()
load_layers = ["l2", "inet", "dhcp", "dns", "dot11", "gprs", "hsrp", "inet6", "ir", "isakmp", "l2tp",
"mgcp", "mobileip", "netbios", "netflow", "ntp", "ppp", "radius", "rip", "rtp",
- "sebek", "skinny", "smb", "snmp", "tftp", "x509", "bluetooth", "dhcp6", "llmnr" ]
+ "sebek", "skinny", "smb", "snmp", "tftp", "x509", "bluetooth", "dhcp6", "llmnr", "loop" ]
if not Conf.ipv6_enabled:

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-scapy_layers_loop_py,v 1.1 2012/01/12 03:16:24 bluhm Exp $
Add layer for sniffing on OpenBSD loopback device.
http://trac.secdev.org/scapy/ticket/485
--- scapy/layers/loop.py.orig Wed Jan 11 23:58:04 2012
+++ scapy/layers/loop.py Thu Jan 12 00:12:21 2012
@@ -0,0 +1,31 @@
+## This file is part of Scapy
+## See http://www.secdev.org/projects/scapy for more informations
+## Copyright (C) Alexander Bluhm <alexander.bluhm@gmx.net>
+## Copyright (C) Philippe Biondi <phil@secdev.org>
+## This program is published under a GPLv2 license
+
+import scapy.arch
+from scapy.packet import *
+from scapy.fields import *
+from scapy.layers.inet import IP
+if conf.ipv6_enabled:
+ from scapy.layers.inet6 import IPv6
+from scapy.config import conf
+
+class Loop(Packet):
+ name = "Loop"
+ # from OpenBSD src/sys/net/if_loop.c
+ fields_desc = [ IntEnumField("addrfamily", 2, { socket.AF_INET: "IPv4",
+ socket.AF_INET6: "IPv6" }),
+ ]
+ def mysummary(self):
+ return self.sprintf("%Loop.addrfamily%")
+
+bind_layers(Loop, IP, addrfamily=socket.AF_INET)
+if conf.ipv6_enabled:
+ bind_layers(Loop, IPv6, addrfamily=socket.AF_INET6)
+
+if scapy.arch.OPENBSD:
+ conf.l2types.register(12, Loop)
+else:
+ conf.l2types.register(108, Loop)

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.3 2010/10/05 09:18:05 armani Exp $
@comment $OpenBSD: PLIST,v 1.4 2012/01/12 03:16:24 bluhm Exp $
@conflict scapy6-*
@pkgpath net/scapy6
bin/UTscapy
@ -96,6 +96,8 @@ lib/python${MODPY_VERSION}/site-packages/scapy/layers/l2tp.py
lib/python${MODPY_VERSION}/site-packages/scapy/layers/l2tp.pyc
lib/python${MODPY_VERSION}/site-packages/scapy/layers/llmnr.py
lib/python${MODPY_VERSION}/site-packages/scapy/layers/llmnr.pyc
lib/python${MODPY_VERSION}/site-packages/scapy/layers/loop.py
lib/python${MODPY_VERSION}/site-packages/scapy/layers/loop.pyc
lib/python${MODPY_VERSION}/site-packages/scapy/layers/mgcp.py
lib/python${MODPY_VERSION}/site-packages/scapy/layers/mgcp.pyc
lib/python${MODPY_VERSION}/site-packages/scapy/layers/mobileip.py