Giter Site home page Giter Site logo

Comments (5)

guedou avatar guedou commented on June 14, 2024

from scapy.

BinomeDeNewton avatar BinomeDeNewton commented on June 14, 2024

I entered these commands to install scapy from Github instead of using pip:

git clone https://github.com/secdev/scapy
cd scapy
./run_scapy
bt = BluetoothHCISocket(0)

I encountered this error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/.../Developer/scapy/scapy/layers/bluetooth.py", line 2506, in __init__
    s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)  # noqa: E501
                      ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'socket' has no attribute 'AF_BLUETOOTH'

Indeed, macOS does not support AF_BLUETOOTH in Python's socket module. To work with Bluetooth in programming on macOS, you will need to use macOS-specific libraries or command-line tools like bluetoothctl (on Linux) or macOS-specific low-level programming interfaces. A good solution would be to use the PyBluez library.

So, I am applying some modifications in the code on my Mac (version : 14.2.1 (23C71)).

from scapy.

guedou avatar guedou commented on June 14, 2024

Could you show us your modifications? I don't understand if you modified Scapy to stop the exception from happening or if you added Bluetooth support on macOS.

from scapy.

BinomeDeNewton avatar BinomeDeNewton commented on June 14, 2024

I found a way to address the issue with the libc library that Scapy encountered when running on a Mac. The core issue was Scapy's attempt to load libc.so.6, which is specific to Linux systems, while macOS uses libc.dylib.

I implemented a conditional import based on the operating system. This solution utilizes the platform module to dynamically determine the operating system at runtime and then load the appropriate C library. For Linux, it continues to load libc.so.6, and for macOS, it switches to loading libc.dylib.

import platform
import ctypes

ctypes.cdll.LoadLibrary("libc.{}".format("so.6" if platform.system() != "Darwin" else "dylib"))
libc = ctypes.CDLL("libc.{}".format("so.6" if platform.system() != "Darwin" else "dylib"))

As for the socket.AF_BLUETOOTH issue on macOS, I'm currently exploring solutions and considering alternatives like PyBluez.

from scapy.

gpotter2 avatar gpotter2 commented on June 14, 2024

You said that already.

from scapy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.