Open krackers opened 2 years ago
did you get this working on an apple silicon mac?
I used chatgpt to come up with the compile command, unsurprisingly it failed
$ gcc -o based-connect based-connect.m -ObjC -arch arm64 -framework IOKit -framework Foundation
Undefined symbols for architecture arm64:
"_NSApp", referenced from:
-[AppDelegate dispatchAction] in based-connect-70700c.o
-[AppDelegate rfcommChannelData:data:length:] in based-connect-70700c.o
(maybe you meant: __OBJC_PROTOCOL_$_NSApplicationDelegate, __OBJC_LABEL_PROTOCOL_$_NSApplicationDelegate )
"_NSApplicationMain", referenced from:
_main in based-connect-70700c.o
"_OBJC_CLASS_$_IOBluetoothDevice", referenced from:
objc-class-ref in based-connect-70700c.o
"_OBJC_CLASS_$_IOBluetoothDeviceSelectorController", referenced from:
objc-class-ref in based-connect-70700c.o
"_OBJC_CLASS_$_IOBluetoothSDPUUID", referenced from:
objc-class-ref in based-connect-70700c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Yes, it will work fine on M1 (although sometimes you have to try several times before it finds the device, not sure why. Seems like a monterey bug).
Due to a change in getopt implementation, you need to change the getopt short_opt to
const char *short_opt = "hfbszqn:v:";
(add colon after n
) so it doesn't segfault when parsing input.
Also the compile command you gave is not quite enough, you also need linker flags -framework AppKit
and -framework IOBluetooth
. But also I think since it uses application delegate, it needs to be in a bundle structure with a default nib, otherwise no delegate will get loaded. So I recommend you create default xcode project and paste in that code (might need to put everything besides main into the AppDelegate.m so nib can launch it properly).
But it should also be possible to avoid the need for bundle by doing like https://stackoverflow.com/questions/8137538/cocoa-applications-from-the-command-line and manually or https://gist.github.com/karstenBriksoft/2bfe71e97e9b3ae1edd5bf4c37d55ecb and manually creating NSApplication
object and setting its delegate
Thanks for all the work in reverse-engineering this! Here's a version that that works with osx/macos, basically using cocoa apis to replay the bytes you reverse-engineered. The code is pretty ugly and there's no error handling (I have no idea what the
ack
sequences you used are for, but it seems to work fine without it). Link to IOKit and Foundation when compiling.