Git Product home page Git Product logo

ardrone2-injection's Introduction

This code is intended to be loaded as a shared library before libc, probably using the LD_PRELOAD environment variable. It intercepts calls to open() and redirects any that attempt to open any file with the string "ttyUSB" in its name.

The expected use case is on the AR Drone 2.0's program.elf, which assumes that a serial USB device must be a debugging tool intended for its use and immediately hijacks the device, leaving it useless for other programs. As far as I can tell, there is no command-line flag to disable this rude behavior. Hence this hack.

If you just want to intercept open()s of ttyUSBs, you can use the precompiled inject.so library. Copy it to the AR.Drone's /lib directory. Then, modify the script that loads program.elf: /bin/program.elf.respawner.sh. Prepend the following to the line that actually invokes program.elf:

LD_PRELOAD=/lib/inject.so

The modified program.elf.respawner.sh script is included if you are uncomfortable with modifying it. I recommend you back up the original script:

cp /bin/program.elf.respawner.sh /bin/program.elf.respawner.sh.orig

Note: I left the emergency restart command alone, thinking that if the drone needs to be in emergency mode, I probably want the flight control firmware to revert to the factory state. It seems to handle the I/O error it gets correctly though, so I don't think it would hurt to inject the library there as well if you need it in emergency mode.

If there are other annoying things that program.elf does that you would rather it not, you can always modify the source code. Essentially, any function that you define that has the same name as a libc function will be called instead of the libc function. You very likely don't want to block all calls to whatever function it is you're overriding, so look up the address of the original function (using the dlsym() function) and call it if you decide not to intercept the call.

Once you decide to build your modifications, you can use the build.sh script. (Yes, I know, it really should be a Makefile.) It assumes you have used crosstool-ng to set up a arm-cortex_a8-linux-gnueabi target in the default ~/x-tools directory. If you have crosstool-ng installed, you can set this up with

ct-ng build arm-cortex_a8-linux-gnueabi

This will take a long time to compile a version of GCC for you to use. After it's done, you can just do

./build.sh

and it should regenerate your new inject.so for you. If you don't want to deal with crosstool, you may be able to coax vanilla GCC into building for ARM, but I find that it's entirely too much trouble.

Happy hacking!

-- George Hilliard ("thirtythreeforty")

ardrone2-injection's People

Contributors

ryannazaretian avatar thirtythreeforty avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.