securing/gattacker

Bug in ws-slave lets crash it when userDescriptorDescriptor gets read

mloepfe opened this issue · 2 comments

Hi

Im running the current version of gattacker (git clone) on Kali-Linux.
When I try to get the service description of a device with userDescriptorDescriptor ws-slave crashes. I checked the async.detect() API and found that the crashing code does not follow the specification. It does not use the error argument. I tried to fix it with the following patch - and it works.

957c957
<                           return callback(descriptor.uuid === '2901');

---
>                           return callback(null, descriptor.uuid === '2901');
959c959
<                         function(userDescriptionDescriptor){

---
>                         function(error, userDescriptionDescriptor){

Here is the exception traceback:

/root/projects/gattacker/ws-slave.js:961
                            userDescriptionDescriptor.readValue(function(error, data) {
                                                      ^

TypeError: userDescriptionDescriptor.readValue is not a function
    at /root/projects/gattacker/ws-slave.js:961:55
    at /root/projects/gattacker/node_modules/async/dist/async.js:2736:29
    at /root/projects/gattacker/ws-slave.js:957:34
    at wrappedIteratee (/root/projects/gattacker/node_modules/async/dist/async.js:2733:17)
    at eachOfArrayLike (/root/projects/gattacker/node_modules/async/dist/async.js:1002:13)
    at eachOf (/root/projects/gattacker/node_modules/async/dist/async.js:1052:9)
    at Object.<anonymous> (/root/projects/gattacker/node_modules/async/dist/async.js:2753:17)
    at /root/projects/gattacker/ws-slave.js:954:29
    at Characteristic.<anonymous> (/root/projects/gattacker/lib/noble/lib/characteristic.js:115:7)
    at Characteristic.g (events.js:260:16)

Hi,
thanks for that, you are right!
The code was written for previous async (up to 1.5.2) which used different params syntax. As you can see:
https://github.com/caolan/async/blob/v1.5.2/README.md#detectarr-iterator-callback
the docs explicitly bold the callback does not take error as first argument.

As in package.json we have async 2.0 dependency, I will clear that up, thanks!

I have tested the patch and pushed it d335b80.
BTW it turned out this was the real cause of #1 ;)
Closing, thank you.