ufrisk / LeechCore

LeechCore - Physical Memory Acquisition Library & The LeechAgent Remote Memory Acquisition Agent
GNU General Public License v3.0
517 stars 92 forks source link

Python binding improvements - mark 2 #22

Closed ikelos closed 3 years ago

ikelos commented 3 years ago

Hiya, I just tried building the python bindings for linux and found pull request #14. I've tried to update it to the support the latest version, but I have to admit my C code isn't all that great.

It compiles just fine, but LcCreate fails and I've no idea how to add the structure needed to LcCreateEx to see what's actually causing the problem. On the same system I can run leechcore with the same device parameter and it reads just fine.

I'm happy to help test and develop improvements, but my C skills are pretty basic. Anything that can help drive this forward a bit would be appreciated. It feels like so much work has already been done, there's just a little bit extra needed to get linux supported too... 5:)

ikelos commented 3 years ago

I agree that packaging for pypi containing binary components is likely difficult. I guess look at things like distorm/capstone for how to do that?

The README doesn't really explain why you don't accept contributions, but that's fine. The changes aren't a significant work and I fully trust you could and possibly will make them on your own, but if you don't have time to work on python support this may help motivate others to try it out and develop it. If you get a CLA in place I'd probably sign it, I'm not really in it for profit I just want a cool tool that everyone can use at the end of it. 5;)

I'd really like to see example code with LeechCorePyc so that the compiled library can be tested with known working code and possibly also to give the API a feel and see if it can be made easier (you might want to stick with the LeechCore API as closely as possible, but if you'd done the work of making a python API it might be worth deviating in order to make it more pythonic?). I don't have any figures to back up the claim, but I suspect that a strong interpreted interface like python will get people playing with the technology more than having to wrestle with C to then play with it.

Thanks for the pointers, I'll check out the optional driver. The fact that it works on the system installed pcileech suggest that's not the problem, but it might be a linking issue or something, given the python module seems to be a complete rebuild of the library. I was looking at a CFFI interface but all the defines for Windows/Linux made that a little tricky so I haven't gotten too far with it (particularly once I found leechcorepyc).

Errr, I don't think build from source on linux is necessarily a must, but offering people the possibility will likely go down well (I use a source-based distribution, so I much appreciate having the option). It will also mean that the build process will get stress tested and you'll end up with quite a robust system if you have the time and energy to fix the bugs that'll get filed. 5;)

Ah, ok, I thought it might be for general errors like "can't find library" or "USB device not plugged in" or similar. It would be useful to expose such troubleshooting responses from the call, but I understand if that's tricky. I haven't gone anywhere near the agent yet, so I don't have a great deal to comment on it.

Getting it to build (and work) on linux with instructions (so pointers about where the FPGA libraries need to be etc) would be awesome! Packaging it as a binary might be nice to make it slightly more convenient but it's certainly not critical to me personally.

In short, any help you can provide would be appreciated and if you can help get past the hurdles so I can start building on it, then I can make more use of it and contribute/suggest things that might make stuff easier. I'm also happy to wait for a CLA before expecting merges... 5;) Thanks Ulf!

ikelos commented 3 years ago

Not sure if this is the right place for discussion, happy to move it elsewhere if there's somewhere better.

I managed to get it going and found the following:

So things that would make this much better/easier for linux users to use would be:

So things that would make this much better/easier for python users to use would be:

I know there's a lot there and it's absolutely a niche part of a niche project that probably doesn't consume all your time in the first place, so no problem on if/when it gets done, but I figured I'd let you know what I think would help and then at least it's out there. I can at the moment pull data back using what's there, it's fully usable as is, so thanks for that!!! 5:D If you are interested in making any of the changes, or get a CLA that you're happy with then I'm happy to help test, etc where I can... 5:)

ufrisk commented 3 years ago

I'm closing this for now. The plan is to release an updated version of this python binding within the next 1-2 months; and possibly on python pip as well as discussed separately.

ikelos commented 3 years ago

Just noticed a couple more things, and this seems like a reasonable place to keep track of them, even though the issue's closed: