Last active
March 2, 2024 12:00
-
-
Save sneha-belkhale/dffa4c8dc2aed8dcce79850af2071e08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this script in Atom with the FoxDot Extension. | |
# Make sure "filepath" points to your TCPDump data. | |
# Set resample to True if you want to continuously resample the wifi packet data, | |
# if so, you will need to continuously run the TCPDump script which contains the following line: | |
# sudo tcpdump -y 'IEEE802_11_RADIO' -i en0 -c 3000 -I -ttttt > "filepath" | |
# set up this script to be run without sudo using visudo. | |
# at the end of this file, you will have all signals stored in the dictionary signalDictAligned, | |
# pipe these arrays into foxdot players and jam! | |
import os | |
import re | |
import time as timeLib | |
filepath = '/Users/xxx/packetDump.txt' | |
tcpDumpCommand = "sudo /Users/xxx/tcpDump.sh" | |
resample = False | |
# ----------------------------------- | |
looping = True | |
while looping: | |
signalDict = {} | |
if resample: | |
p = os.system(tcpDumpCommand) | |
with open(filepath) as fp: | |
line = fp.readline() | |
cnt = 1 | |
while line: | |
line = fp.readline() | |
os.write(2, str.encode(line)) | |
signal = re.search('(\S*)dBm signal', line) | |
time = re.search('00:00:(\S*)', line) | |
if signal == None or time == None: | |
continue | |
lastTime = float(time.group(1)) | |
key = re.search('Beacon (\S*)', line) | |
if key == None: | |
key = re.search('(\S*) \(oui Unknown', line) | |
if key == None: | |
continue | |
address = key.group(1) | |
if address in signalDict: | |
signalDict[address].append((signal.group(1), lastTime)) | |
else: | |
signalDict[address] = [(signal.group(1), lastTime)] | |
cnt += 1 | |
fp.close() | |
maxLength = 80 | |
signalDictSorted = [] | |
for address in signalDict: | |
signalDictSorted.append(signalDict[address]) | |
signalDictSorted.sort(key=len, reverse=True) | |
signalDictAligned = [] | |
for i, signalList in enumerate(signalDictSorted): | |
if i > 9: | |
continue | |
signalAligned = [None] * (maxLength+1) | |
for signal in signalList: | |
time = signal[1] | |
idx = int(maxLength * (time/lastTime)) | |
if idx > maxLength: | |
continue | |
signalAligned[idx] = int(0.4*pow(float(signal[0]),2)/100 + 20) | |
signalDictAligned.append(signalAligned) | |
count = 0 | |
execute("Clock.clear()") | |
count = 0 | |
looping = resample | |
# -------------------------------------- | |
count = 0 | |
for signals in signalDictAligned: | |
playerval = "d" + str(count) | |
count = count + 1 | |
execute(playerval + ">> pads(signals, dur=0.25)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tcpdump -y 'IEEE802_11_RADIO' -i en0 -c 3000 -I -ttttt > /Users/xxx/packetDump.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FoxDot Wifi Soundscapes
Reveal the intangible dimension of wifi by using TCPDump to capture packets in monitor mode and sonifying their signal strengths with python / FoxDot
Script Tips
[+] Run this script in Atom with the FoxDot Extension.
[+] Make sure
filepath
points to your TCPDump data.[+] Set
resample
toTrue
if you want to continuously resample the wifi packet data,if so, you will need a bash script which contains the following line:
sudo tcpdump -y 'IEEE802_11_RADIO' -i en0 -c 3000 -I -ttttt > filepath
set up this script to be run without sudo using
visudo
.[+] at the end of this file, you will have all signals stored in the dictionary
signalDictAligned
,pipe these arrays into foxdot players and jam!