Hack Forums
[Python] Memory reading and writing - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Memory reading and writing (/showthread.php?tid=6102696)



Memory reading and writing - Mr. Nihilous - Aug 14, 2020

So I've been looking into cheat engine and how it works and was wondering how I could go about writing up a python script that I could attach to a running process that reads from memory, can write to memory, get corresponding hex values and control the EIP. I know most standard debuggers do this but how does it work? What sort of modules are necessary? Any books or resources that could teach me about this?

Bonus question:
Is this how aimbots work in popular fps games? Do they read from memory to get the location of the opponent's head?


RE: Memory reading and writing - h0lyl337 - Aug 14, 2020

if you google "python game hacking" you will find some good guides, check out the counter strike ones. Pywin32, Ctypes, and Pymem, are modules you would probably use.


RE: Memory reading and writing - Mr. Nihilous - Aug 14, 2020

Thanks mate, cheat engine is extremely versatile, I see that I can get real time memory access to a virtual machine. I plan on reading variables from memory and seeing how I can edit them as well. I wanna see if I can automate a few things with some apps on an android for practice, I know I could just do clicks but I think it would be a lot more sophisticated to read from memory addresses instead. I just can't attach any scripts to cheat engine, so I look to use python in order to get access to and manipulate those variables.


RE: Memory reading and writing - tsuki - Aug 14, 2020

You can use the pymem Python module for this (or even make your own if you're more ambitious), but why Python? You're better off learning C and windows internals.


RE: Memory reading and writing - Mr. Nihilous - Aug 14, 2020

(Aug 14, 2020 11:44 AM)tsuki Wrote:  You can use the pymem Python module for this (or even make your own if you're more ambitious), but why Python? You're better off learning C and windows internals.

Good point, I was thinking the same thing with regards to C. I'm alright in python with a little experience in C. I've managed already to access as well as write to memory inside of a virtual machine running android. I've been tinkering with pymem all afternoon learning the ins and outs of the various modules. Pymem allows for assembly injection as well but I know C is pretty well suited for that sort of thing.