Code Monkey home page Code Monkey logo

filehook's Introduction

FileHook

This DLL can be injected into a process to load up a buffer containing the contents of any file from disk, and then redirect any future file creates/reads to this buffer.

Pretty much like a RAM disk, but not an actual RAM disk.

I use this for fuzzing, when I want to have a single buffer in-memory for modifying a file and ensure the process only reads from my buffer (also prevents unneccessary disk accesses), so if the program does multiple reads, instead of intercepting and fuzzing each read, or by modifying the file and saving to disk before causing the reads, we simply have a single mapped buffer of the file in-memory and redirect all reads to perform against our mapped in-mem image instead of disk.

Initally developed this to work with a custom hypervisor fuzzer that doesn't support disks, but its useful in other cases too.

This should support both ASYNC and SYNC reads, including OVERLAPPED reads. Not great for running on a target long-term (due to likely mem-leaks or something), I use this for snapshot fuzzing so haven't been worrried about that.

Note: There are three #define HARDCODED_FILEPATH vars, one is the target to intercept, another is one we will map in-mem (may be the same as target or different), another is used if we fake writes.

Also Note: Due to the access we request of the HARDCODED filepaths, you may need to modify the security of the files to allow "Full Control" to your user or group.

The idea is:

  1. Prog attempts to call CreateFileW on e.g. c:\test.txt
  2. We load test.txt in-mem
  3. Prog attempts to read from file (ReadFile API or something that wraps it)
  4. We intercept read, and emulate the read through our mem-mapped version of the file

Note: Requires Detours https://github.com/microsoft/Detours

Note: Currently no real supports for writes, we can either fake it or forward to OS

filehook's People

Contributors

kharos102 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.