-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Using RF24 in reverse engineering protocols #798
Comments
This is dense; grab a drink now - then continue
That commit is on my experimental fork's "revamped" branch... I haven't tested it in a while (at least a few months at this point). The main idea is that the added private bool The use of an extra bool to do this would occupy a whole byte in memory and only serves to resolve #496 seeming edge case (in spite of poor addressing outlined by ManiacBug)
Not likely because the added bool would not need a public scope (only the lib would need to use it), and the python wrapper does not expose private members (using either boost.python or pybind11). If it was a pure python lib (like my CirPy lib), then it could be accessed (because nothing is really private in python). However, the entire "null vs 0" problem is avoided with the difference between python's
Correct, each part of this register is handled according to it's relative feature. Instead, this would be accomplished with radio.setPALevel(RF24_PA_MIN, true); // `true` asserts the LNA_HCURR bit (which is done by default)
radio.setDataRate(RF24_250KBPS);
This can be done with RF24 lib like so for (uint8_t i = 0; i < 6; ++i)
radio.closeReadingPipe(i); However, it is no where near as efficient as clearing the whole register at once. I remember a comment in src from @TMRh20 explaining the lib's intention about handling pipes individually: Lines 1402 to 1405 in e22a8be
I often refer to the datasheet when faced with such questions. Observe
Where to go from hereI think your use case actually falls outside the scope of the RF24 lib's original intention which was to provide a beginner-friendly interface for the nRF24L01 transceiver. I talked a bit about inheriting from the RF24 class because it could be extended to suite your use case. Although, some things might need to be made protected for 2 reasons
|
This is great reading! I've been wanting to reverse engineer Logitech's unifying receiver dongle, so that maybe an open-source mouse doesn't need any new receiver plugged into the PC's USB ports... These findings can't be shared publicly as Logitech does well to patch wireless exploits. The last exploit published prompted Logitech to use encryption on keyboards (& possibly mice now too). |
Hey @2bndy5 , thanks for splitting this out. I've skimmed most of this and understand, but wanted to focus on one thing:
My understanding was that this was a forked version of the original beginners' library, as the library's documentation states:
I guess I gravitated towards this library in the hopes that it would be more amenable to RE use cases, rather than having to bitbang SPI to get what I am looking for. It's so very close -- and only needs a couple of very minor tweaks. Given I'd prefer to be calling this most often from something like JS or Python (and there are already many issues installing this library in a managed Python dependency toolchain such as Poetry), I'd rather not have to sub-class everything myself. Otherwise I'm looking at a) maintaining a fork of the C++ code (ugh), and b) having to sort out publishing Python bindings to that myself, whereas I'd much rather some sort of compile-time option to your library (something like FYI my intention has nothing to do with sniffing keyboard/mouse protocol stuff; I actually only got into this library to reverse engineer the protocol for my house's baseboard heaters, which turned out to be rather simple -- ONCE I got past the issues mentioned in my first post. 😉 Does my counter-proposal interest you at all? |
Two other minor comments:
That's fine, I've not needed to mess with this lower.
I'm actually doing most of this on a BeagleBone right now for the added bandwidth, especially when sniffing packets. I don't know if CirPy is fast enough in this situation, but I'd be willing to simply drop this use case from here and migrate to CirPy if you felt it would be more fruitful. |
Yes! Sorry about the info dump; I got overexcited when you mentioned RE. I've also been looking at appropriating the firmware for the (now deprecated) steam controller which literally uses the Nordic ESB protocol when its not in BLE mode. IIRC, controller uses nRF51822 while the receiver uses a nRF24LU1.
Specifically, what are you requesting? The code snippet in the OP is kinda broad and leaves me with a partial idea.
Ultimately the difference between this lib and the CirPy lib is C++'s amazing execution speed. Although I generally like to do rapid developing in python (for experiments and proof-of-concepts), then port the python algorithms to C++. Although, having a pip installable C extension of this lib would be more ideal.
If needed, I could easily add something like this to the CMake offering (still being tested on the rp2xxx branch but getting all good feedback). The old |
Hey @2bndy5 , sorry for the delay - been very busy with other stuff this past week, I'll try and review everything during the course of this coming week. |
@TMRh20 Would you approve a new function called @Avamander Am I correct in assuming that this new function would not affect existing applications' compile size if they never call it? |
Usually yes, much more certain with |
Hmm, I see ATTiny core and AVR core uses |
@wohali I took some pointers from the readings you provided and altered the CirPy lib's scanner example. It seems to work better now, and I added a |
Yeah I’m ok with a new function.
… On Oct 26, 2021, at 4:20 AM, Brendan ***@***.***> wrote:
@wohali I took some pointers from the readings you provided and altered the CirPy lib's scanner example. It seems to work better now, and I added a noise() function to show ambient noise for a specified channel. 🤓
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
@wohali I've added the new function
|
Hey @2bndy5 , sorry for the endless delays here. So very busy!
Can you give me a short summary of what this does - assuming I don't have time at the moment to read the code?
Only insofar as the writeRegister operation needed it: inline uint8_t writeRegister(uint8_t reg, uint8_t value)
{
uint8_t status;
digitalWrite(CSN, LOW);
status = SPI.transfer(W_REGISTER | (REGISTER_MASK & reg));
SPI.transfer(value);
digitalWrite(CSN, HIGH);
return status;
} and similar if passing in a If your abstractions now handle all of the things I had to use
The issue here is that order matters and has a significant impact on what the chip actually does - at least, in reveng scenarios; I haven't checked for normal operation. Things didn't work right if I I can live with the current limitation, but in the interest of making the library easier for end users, it might make sense to offer a ctor for the radio object that allows specifying this all at once, and letting the library take care of proper ordering. |
I'm very hesitant to allow users to directly manipulate the RF_SETUP register because it also exposes vital hardware manipulation, namely the PLL_LOCK (& continuous carrier wave flag for non-plus variants). Even for RE purposes, poorly configuring the PLL_LOCK will have detrimental side effects that could damage the radio or (at best) make it seem broken.
I guess we could add a c'tor that would take RF_SETUP parameters, but
|
I would be more inclined to add a new function void setupRF(uint8_t level, uint8_t rate, bool lna_enabled=true)
{
// manipulate certain bits while keeping all other bits set to 0
// write register value all at once
} |
Looking into the src codeTurns out that Furthermore, adding a
Any application that wasn't previously calling ps - I'm open to a better function name than |
I just tried compiling the RE-tricks branch (with the new @wohali I should note that |
@2bndy5 One of the standard nRF24L01+ transceivers you see everywhere for about US$10 - the ones with the extra LNA chip and the SMA connector. |
Also your finding re: |
I don't know when or where you were using the
That would be the PA/LNA module. You would need to disable auto-ack first for those because it cuts down the power consumption significantly. I say this because those modules are famous for excessive power consumption when TX-ing (including ACK packets). Changing the PA level also helps cut down the power consumption, so that would also need priority over data rate. How are you supplying power to that module? What MCU board are you using? |
@2bndy5 Bench power supply with meter, driven by a BeagleBone. And yes the code disables auto-ack first. It does work, just fine - no hardware issues - I just ended up with the code you see to make it work. |
I ask because usually the linear regulator on a RPi doesn't supply enough current to the PA/LNA radio module. Unless you're trying to say that you use the bench power supply to feed the radio and BB in parallel. Otherwise, if you're using a 3v pin from the BB to supply the radio, then you might want to monitor the current spikes from the BB to the radio and make sure they don't flatline (typically indicating the current limit isn't high enough). |
I would ask that you test the "RE-tricks" branch as that PR will close this issue when it gets merged. |
Hey @2bndy5 , thanks for your hard work on this library - much appreciated.
If this should be in a new issue, please split it out.
Just wanted to point out that there's a really important use case for setting the first address byte to
0x00
, namely protocol reverse engineering. Here's some reading if you're unfamiliar:Right now, to get around the limitations of this library, something like this is required:
where
writeRegister
is a raw SPI transfer that also handlesCSN
toggling. Not pleasant!I see 70786aa which looks encouraging to help with some of this - can you clarify how the use case I've outlined might be supported by this commit? I expect other language bindings (like the Python one) will need to have this variable exposed as well...) Thanks!
Originally posted by @wohali in #496 (comment)
The text was updated successfully, but these errors were encountered: