[Python-apps-team] Bug#850692: pyrit: failed with 'BitEnumField' object has no attribute 'names'

Sophie Brun sophie at freexian.com
Mon Jan 9 13:10:52 UTC 2017


Package: pyrit
Version: 0.4.0-7
Severity: normal
Tags: patch

Hello,

Trying to run the command "pyrit -r file.cap analyze" failed:
Traceback (most recent call last):
  File "/usr/bin/pyrit", line 6, in <module>
    pyrit_cli.Pyrit_CLI().initFromArgv()
  File "/usr/lib/python2.7/dist-packages/pyrit_cli.py", line 115, in initFromArgv
    func(self, **options)
  File "/usr/lib/python2.7/dist-packages/pyrit_cli.py", line 163, in new_f
    f(*args, **kwds)
  File "/usr/lib/python2.7/dist-packages/pyrit_cli.py", line 447, in analyze
    parser = self._getParser(capturefile)
  File "/usr/lib/python2.7/dist-packages/pyrit_cli.py", line 179, in _getParser
    parser.parse_pcapdevice(dev)
  File "/usr/lib/python2.7/dist-packages/cpyrit/pckttools.py", line 601, in parse_pcapdevice
    self.parse_packet(pckt)
  File "/usr/lib/python2.7/dist-packages/cpyrit/pckttools.py", line 614, in parse_packet
    if dot11_pckt.isFlagSet('type', 'Control'):
  File "/usr/lib/python2.7/dist-packages/cpyrit/pckttools.py", line 66, in isFlagSet
    return (1 << field.names.index([value])) & self.__getattr__(name) != 0
AttributeError: 'BitEnumField' object has no attribute 'names'

It's caused by the new version of python-scapy (2.3.3).

Here is a patch to fix it.
The patch is from the https://github.com/JPaulMora/Pyrit repo (dev branch):
https://github.com/JPaulMora/Pyrit/commit/14ec997174b8e8fd20d22b6a97c57e19633f12a0

John Mora seems to have taken maintenance of pyrit and should consider tracking new release from this repository.

Consider joining the pkg-security team, we could co-maintain pyrit there:
https://wiki.debian.org/Teams/pkg-security

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.8.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages pyrit depends on:
ii  libc6        2.24-8
ii  libpcap0.8   1.8.1-3
ii  libssl1.0.2  1.0.2j-4
ii  python       2.7.13-1
pn  python:any   <none>

Versions of packages pyrit recommends:
ii  python-scapy       2.3.3-1
ii  python-sqlalchemy  1.0.15+ds1-1

Versions of packages pyrit suggests:
ii  python-mysqldb   1.3.7-1+b1
ii  python-psycopg2  2.6.2-1

-- no debconf information
-------------- next part --------------
Subject: Update isinstance(EnumField) for scapy 2.3.3+
 scapy 2.3.2- requires that scapy.fields.EnumField is passed to
 isinstance, while scapy 2.3.3+ needs scapy.fields._EnumField.
 This patch accomodates pyrit for both versions.
Author: Ilya Terentyev <bacondropped at gmail.com>
Origin: https://github.com/JPaulMora/Pyrit/commit/14ec997174b8e8fd20d22b6a97c57e19633f12a0
Bug: https://github.com/JPaulMora/Pyrit/issues/500
Bug-Kali: https://bugs.kali.org/view.php?id=3801
Date: Tue, 1 Nov 2016 20:40:15 +0300
Forwarded: not-needed
Last-Update: 2017-01-06

---
 cpyrit/pckttools.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/cpyrit/pckttools.py b/cpyrit/pckttools.py
index 326829d..d58fff1 100644
--- a/cpyrit/pckttools.py
+++ b/cpyrit/pckttools.py
@@ -54,12 +54,23 @@
                                             scapy.layers.dot11.PrismHeader)
 
 
+def isEnumField(f):
+    """Return True if f is an instance of EnumField.  This function tries to be
+       portable: scapy versions 2.3.2 and earlier need isinstance(EnumField),
+       while scapy 2.3.3+ requires isinstance(_EnumField).
+    """
+    try:
+        return isinstance(f, scapy.fields._EnumField)
+    except AttributeError:
+        return isinstance(f, scapy.fields.EnumField)
+
+
 def isFlagSet(self, name, value):
     """Return True if the given field 'includes' the given value.
        Exact behaviour of this function is specific to the field-type.
     """
     field, val = self.getfield_and_val(name)
-    if isinstance(field, scapy.fields.EnumField):
+    if isEnumField(field):
         if val not in field.i2s:
             return False
         return field.i2s[val] == value


More information about the Python-apps-team mailing list