dji-log-parser icon indicating copy to clipboard operation
dji-log-parser copied to clipboard

Phantom 4 compatibility

Open skylow48 opened this issue 8 years ago • 44 comments

Hello,

It seem's to not be compatible with Phantom 4 FlightRecord. How to make it compatible ?

Thanks,

Regards.

skylow48 avatar Jan 23 '17 10:01 skylow48

FlightRecords are now encrypted by the DJI Go app (since 2.8.4)

More info here

  • http://reverseengineering.stackexchange.com/questions/13409/help-me-reverse-this/13429
  • http://www.phantompilots.com/threads/tool-win-offline-txt-flightrecord-to-csv-converter.70428/page-16

lvauvillier avatar Jan 26 '17 21:01 lvauvillier

Was there ever an update on this? Any publicly available way to decode them?

n4ru avatar Mar 21 '17 00:03 n4ru

Unfortunately I don't have a drone available at the moment in order to check this out.

If you've got any encrypted log files, feel free to send them over and i'll take a look.

mikeemoo avatar Mar 21 '17 09:03 mikeemoo

Here's a couple from the Mavic Pro - encrypted using the same app as the Phantom 4 and Inspire 2.

n4ru avatar Mar 21 '17 17:03 n4ru

@mikeemoo i already rewrite some part of the lib to work properly with encrypted dataframes. My only missing piece is the getKey() function which i understand the logic but doesn't work...

I also collect some frames on which the key is easy to reverse (frames containing fields with zero values, which a xor return the key)

Feel free to contact me in private.

lvauvillier avatar Mar 31 '17 14:03 lvauvillier

Hi @lvauvillier I would like to help you with this, but I am unfamiliar with the new DJI format. Any pointers to get going?

tonymorris avatar Apr 16 '17 12:04 tonymorris

@tonymorris

  • The "detail" frame remains unchanged and raw.
  • For the others, the logic of parsing the frame type and frame length remains also the same, but there is is two more bytes in the data frame : one at the beginning and one at the end. Each data frames are encrypted with a specific key.
  • To decode the frame, the 8 bytes key is simply XORed across the data.

The getKey() function is my only missing part. The key is computed from the first byte, a fixed seed and the frame length using a CRC64. I'm not sure for the frame length, but i can say that two different frames with the same first byte may have not the same key. This is my only missing part.

To go further i suggest you to read the two linked posts in my previous reply.

lvauvillier avatar Apr 18 '17 09:04 lvauvillier

@lvauvillier I was planning on going public with my (free) website for DJI logs just when DJI started encrypting logs. I got as far as you did and have observed:

  • Position of frame within file is not relevant, only the parameters you have mentioned are needed to generate the key, e.g. frames with same message type and length have always the same key
  • Identical frames have the same additional second byte, but frames of same message type and different data have not. Makes me believe it is some kind of checksum
  • I've asked one of the guys who managed to decode the encryption in the phantom pilots forum for help, but they won't provide the solution nor did he answer a PN for hints. I personally find that a bit annoying since ot was the same group who asked for public help on the reverse engineering site.
  • The fact that it did not take them very long to decode the messages as soon as they knew what we know here makes me think it can't be too complicated but I could be wrong.
  • Happy to support so that we can solve this

SwissDroneHome avatar Apr 18 '17 09:04 SwissDroneHome

I'm interested in getting the flight data logs decoded as well.

skandragon avatar Jun 05 '17 20:06 skandragon

Anyone have any luck with this?

Neilfau avatar Jul 06 '17 12:07 Neilfau

The XOR key is generated for every possible value so you have 4096 possibilities. Which can be obtained by calling the function in the C lib. Hope it helps :)

abaschen avatar Sep 28 '17 15:09 abaschen

Now fixed by #15 !

Thanks a lot @TecHunter for the tip !

lvauvillier avatar Oct 01 '17 20:10 lvauvillier

Hi @lvauvillier how to get your #15 release ? (sorry I don't realy know GitHub)

skylow48 avatar Oct 11 '17 19:10 skylow48

I'm not the owner. I cannot release it on npm. You can download the working project from my repo and add it manually to your project.

lvauvillier avatar Oct 12 '17 12:10 lvauvillier

Great thanks. Did you succeed in decoding a recent encrypted DJI log ? I don't succeed in it with your update.

skylow48 avatar Oct 12 '17 19:10 skylow48

Can you send me your log file ? I'll give a try.

lvauvillier avatar Oct 13 '17 08:10 lvauvillier

It works for me. Are you running it within your browser or using nodejs ?

lvauvillier avatar Oct 16 '17 08:10 lvauvillier

Good new thanks :) I'm running it with my browser

skylow48 avatar Oct 16 '17 08:10 skylow48

@skylow48 Fixed !

lvauvillier avatar Oct 16 '17 09:10 lvauvillier

It works :) thanks a lot

skylow48 avatar Oct 16 '17 11:10 skylow48

Sorry I tested the wrong file... it doesn't work, but I'm not sure to run the right function : I test it from "exemples/browser-example.html" : is it correct ?

skylow48 avatar Oct 16 '17 11:10 skylow48

Yes it is correct. But the sample use a compiled version of the library (browser.js) and i push only the modified source files.

I just add a build script and an updated browser.js version to my repo.

Everything should work for you now.

lvauvillier avatar Oct 16 '17 13:10 lvauvillier

You are the best, thanks :)

skylow48 avatar Oct 16 '17 13:10 skylow48

I also update my online visualisation demo with the new parser version : https://flighttrack.now.sh

You can easily check your encrypted flight logs and report bug if it is not working.

lvauvillier avatar Oct 16 '17 16:10 lvauvillier

Very nice! Did you manage to recover the battery SN ? And the pictures ? How to report a bug out of Github (do you have a bug reporting tool ?)

skylow48 avatar Oct 16 '17 20:10 skylow48

Pictures are my next step. Stay tuned

lvauvillier avatar Oct 17 '17 20:10 lvauvillier

First Image extraction is working :) You can test it with my repo's code. (code sample in example.js)

@skylow48 you can report bugs opening issues here or on my repo. @mikeemoo are you still working on this project ? If you have no time for it, i propose to help you to maintain this library.

lvauvillier avatar Oct 19 '17 16:10 lvauvillier

Nice ! :) But I don't know how to use node.js, do you have a way to test your code in HTML/javascript or better : in C# ?

skylow48 avatar Oct 19 '17 16:10 skylow48

I update the browser sample with an image extraction code

lvauvillier avatar Oct 19 '17 22:10 lvauvillier

That works perfectly :) thanks ! Do you have an easy way to convert your script into C# to run it in a winform ?

skylow48 avatar Oct 20 '17 17:10 skylow48