Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running unexported .dll functions with python

This may seem like a weird question, but I would like to know how I can run a function in a .dll from a memory 'signature'. I don't understand much about how it actually works, but I needed it badly. Its a way of running unexported functions from within a .dll, if you know the memory signature and adress of it. For example, I have these:

respawn_f "_ZN9CCSPlayer12RoundRespawnEv"
respawn_sig "568BF18B06FF90B80400008B86E80D00"
respawn_mask "xxxxx?xxx??xxxx?"

And using some pretty nifty C++ code you can use this to run functions from within a .dll.

Here is a well explained article on it: http://wiki.alliedmods.net/Signature_Scanning

So, is it possible using Ctypes or any other way to do this inside python?

like image 880
Lobe Avatar asked Nov 05 '22 22:11

Lobe


1 Answers

If you can already run them using C++ then you can try using SWIG to generate python wrappers for the C++ code you've written making it callable from python.

http://www.swig.org/

Some caveats that I've found using SWIG:

Swig looks up types based on a string value. For example an integer type in Python (int) will look to make sure that the cpp type is "int" otherwise swig will complain about type mismatches. There is no automatic conversion.

Swig copies source code verbatim therefore even objects in the same namespace will need to be fully qualified so that the cxx file will compile properly.

Hope that helps.

like image 50
mabbit Avatar answered Nov 14 '22 21:11

mabbit