MemoryModifier is a tool and a library for scanning and modifying memory on Linux. It can also be used for creating patterns to search in your own C scripts.
$ cd MemoryModifier
$ make
$ make install
To use this tool you will need sudo permissions.
$ sudo mm
First open a process by name
Process *p;
if ((p = openProcess("application")) == NULL) {
fprintf(stderr, "Failed to open process memory");
}
Now open the memory region, you can manually look at it in /proc/PID/maps
In this case we open the heap.
MemoryRegion heap;
if (getMemoryRegion(p, "[heap]", &heap) == 0) {
fprintf(stderr, "Failed to open memory region");
}
byte number[4];
if (readProcessMemory(heap, heap.start + offset, number, sizeof(int)) == 0) {
fprintf(stderr, "Failed to read memory");
}
if (writeProcessMemory(heap, heap.start + offset, getBytes(int, 1234), sizeof(int)) == 0) {
fprintf(stderr, "Failed to write to memory");
}