Git Product home page Git Product logo

nvram-faker's Introduction

nvram-faker

When using emulation to run an application found in an embedded Linux firmware, such as a wireless router's web server, one of the main problems encountered is the application attempting to source NVRAM for configuration parameters. A common library, libnvram.so, is often used in embedded Linux to abstract access to NVRAM. This provides nvram_get() and nvram_set() functions to get and set configuration parameters. The calls to nvram_get() will fail, since the emulated environment has no NVRAM. Without configuration parameters the target application will likely fail to run.

nvram-faker is a simple library to intercept calls to libnvram using LD_PRELOAD. By providing sane values in an INI-style NVRAM configuration file you can answer queries to NVRAM, enabling the application to start up and run.

BUILDING

There should be no external dependencies. I have tested building in Ubuntu Linux.

You can build the shared library, libnvram-faker.so, simply by typing make. However, you'll almost certainly want to cross-compile for your target architecture. For convenience, I've provided shell scripts for building on big and little endian MIPS, since these are the most common architectures I work with. The shell scripts set up your toolchain variables such as $CC to point to your cross-compilation tools, if they're in your $PATH. If you need to cross compile with other architectures, such as ARM, this shouldn't be too hard to set up.

USING

Put libnvram-faker.so somewhere in your firmware's extracted filesystem. Edit nvram.ini and put it in the root of the firmware's filesystem. If you want to put the configuration file somewhere else, define INI_FILE_PATH at compile time however you like[1]. Set the LD_PRELOAD environment variable to load the library.

Every nvram query and the answer returned will be printed to standard output. If the answer is not found, NULL is returned by nvram_get and the query is printed to the console in red, so it will easy to notice.

The library currently does not support calls to nvram_set().

ACKNOWLEDGMENTS

I shamelessly aped this idea from Craig Heffner [email protected], (@devttyS0 on Twitter). I improved on it by adding support for INI configuration and colorized console output.

INI support is provided by this excellent project, which I have included in this source tree.


[1] You can export a CFLAGS environment variable on the command line to do this.

nvram-faker's People

Contributors

zcutlip avatar

Watchers

 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.