libmem | Advanced Game Hacking Library for C/C++ , Rust and Python | Cybersecurity library
kandi X-RAY | libmem Summary
kandi X-RAY | libmem Summary
Include libmem/libmem.h (C/C++) or libmem/libmem.hpp (C++) in your project. Compile libmem/libmem.c along with your project.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of libmem
libmem Key Features
libmem Examples and Code Snippets
Community Discussions
Trending Discussions on libmem
QUESTION
I have been trying to implement a small simulation to understand memory allocation of malloc(). I created a shared library called mem.c. I am linking the library to the main but cannot pass the correct address of the simulated "heap". Heap is created by a malloc() call in the shared library.
Address in the shared library: 0x55ddaff662a0 Address in the main: 0xffffffffaff662a0
Only last 4 bytes seem to be correct. Rest is set to 0xf.
However, when I #include "mem.c" in the main it works correctly. How can I achieve the same result without including the mem.c. I am trying to solve this without including mem.c or mem.h. I create shared library as this:
...ANSWER
Answered 2021-May-11 at 21:47From your comments
I am trying to implement without using #include mem.h or mem.c.
Then you must provide by other means a prototype for the function you're calling. Without an explicit function prototype, following the tradition of K&R and then later ANSI C, undeclared functions are assumed to return an int
and take parameters of type int
.
EDIT: Essentially you need to write what'd you normally find in a header, somewhere before you make first use of the function. Or of it's a function pointer you need an appropriate variable to store the function pointer.
For example to declare a function that returns an untyped pointer, and an arbitrary, unspecified number of arguments you'd write
QUESTION
I've been stuck with this problem for some days, and still haven't manage to fix it. Basically, I want to do a remote syscall from an attacker program to the target. But before showing the code, I think it'd be a good idea to present my thought process, as the problem could be anything at this point. I am doing this remote syscall through the following steps:
- Parse /proc//maps file to get an executable region.
- Store the data at the executable region and write a custom buffer that does the syscall to it.
- Store the old registers and setup new ones to make the syscall
- Write the new registers and continue the execution
- After the syscall, the target program will break, which would allow me to get the output of mmap, set back the old registers and therefore, restore the old execution flow.
I am using my memory lib to parse the mmap files, get process id and process information, etc. As far as I am concerned, it is working properly. In any case, here's the source: https://github.com/rdbo/libmem
And the code I am using to do the call:
...ANSWER
Answered 2020-Aug-14 at 16:18Turns out the problem was that I was reading/writing the memory using process_vm_read and process_vm_write. I got it to work by changing the read/write method to ptrace PEEK/POKE data. Fixed code (included on my memory lib):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install libmem
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page