Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create capturing_BLE_scapy #464

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/source/capturing_BLE_scapy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Capturing BLE in scapy
Use ubertooth-btle with -q and stream to a file.

[Workaround](https://github.com/secdev/scapy/issues/2764#issuecomment-674387163) the dilemma of reaching EOF due to scapy defaults in a low traffic area.

## Rough concept
In a terminal, run ubertooth-btle with -f, -n or -p. Use -q for the pcap output:
```
ubertooth-btle -f -q /tmp/pipe
```
In another terminal, open python and run:
```
from scapy.all import *

class Reader(PcapReader):
def read_packet(self, size = MTU):
try:
return super(Reader, self).read_packet(size)
except EOFError:
return None


p = sniff(opened_socket=Reader('/tmp/pipe'), prn = lambda x: x.summary())

```

## Takeaways from the concept
- p is now a list of the packets captured. This object is usable if you crtl+c
within a Python IDE such as [ipython](https://ipython.org/)
- Save RAM by using prn to do something other than print to stdout; set store = 0
- ubertooth-btle is blocking when invoked via os.system()
- "mount -t tmpfs -o size=10M tmpfs /tmp/foo" <~~~ might just be a friend