Code Monkey home page Code Monkey logo

wlb's Introduction

Windows Lua Bridge

Rust is awesome. Windows is more awesome than it's given credit for. If only there was a way to programmatically explore the inconsistent windows API with the convenience of scripting, and the awesomeness of Rust. Well... now there is!

The Windows-Lua Bridge bridges the Windows API with lua, and makes it available in a package available via Rust. Influenced by what I have read of meterpreter's railgun (though I have never used railgun), wlb attempts to make it possible, and easy, to call into the C-level windows API from lua, all via code controlled through Rust.

Consider it a tool for, "Windows API exploration for people who don't Windows, but like Rust, and like Lua, and want to learn to Windows good too." Who knows, maybe you'll find other useful applications for it as well.

Examples

MessageBoxA

In our first example, we'll try to pop a Message box using the Windows API. For Windows noobs like me, let's take a look at the MessageBoxA documentation provided by Microsoft.

Here are the takeaways from the documentation:

  • Four arguments to this function:
    1. HWND, which can be null, so we'll just pass a 0.
    2. Pointer to an ASCII string (the A in MessageBoxA is for ASCII) for our message.
    3. Pointer to an ASCII string for our message box title.
    4. A DWORD (uint32) to describe the type of message box.
  • If you scroll to the bottom, you'll see this library is found in user32.dll. We need to make sure that library exists in the current process.

We have two primary problems to solve:

  • How do we actually locate the MessageBoxA function in memory so we can call it?
  • How do we make sure our arguments are interpreted correctly, especially things like pointers to strings?

Finding MessageBoxA

wlb will locate the target function by calling EnumProcessModules with the file handle returned by GetCurrentProcess. Those modules are walked to find one that matches indexed name into winapi. Once that module is located, the api calls GetProcAddress.

Passing arguments

TBD

wlb's People

Contributors

endeav0r avatar

Stargazers

Markus Hihn avatar Hilko Bengen avatar chrsm avatar Luidiblu avatar Erik avatar

Watchers

 avatar James Cloos avatar Michael Romig 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.